﻿// JScript File


 
var __prevTimeoutID;

function XMLReqObj(strMethod,strUrl,
                   strObjNameToSet,oFunction)
{
	 this.CallBackFunction=null;
	 this.objXML_onreadystatechange= function () 
		{var retCount=0;
		 var retText="",retErr=null;
		 if(objXML.readyState == 4) 
           { 
            if(objXML.status == 200) 
               {retText=objXML.responseText;}          
            else 
               {retErr=objXML.statusText; }
           //alert();    
           if(typeof CallBackFunction=='function'){CallBackFunction(retText,retErr);}
          window.clearTimeout(__prevTimeoutID);   
         }      
	}//end objXML_onreadystatechange
	
  if(window.XMLHttpRequest) 
     {
      try {objX = new XMLHttpRequest();}
       catch(e){objX = null;}
      }
   else if(window.ActiveXObject) 
     {
      try {objX = new ActiveXObject("Microsoft.XMLHTTP");}
      catch(e) 
         {try {objX = new ActiveXObject("Msxml2.XMLHTTP");}
          catch(e){objX = null;}
        }
    }
    if(objX!=null)
       {
        if(strObjNameToSet!=null)
           {window[strObjNameToSet]=objX;
            if(oFunction!=null)CallBackFunction =(typeof(oFunction)=="string")?window[oFunction]:oFunction;
           }
        
        objX.onreadystatechange=this.objXML_onreadystatechange;
        
        if(strMethod==null)strMethod='GET'; 
       
        if(strUrl!=null)
          try{objX.open(strMethod,strUrl,true);}
          catch(e){if(typeof CallBackFunction=='function'){CallBackFunction(null,(document.all?e.message:e));}}
        
        if(strMethod.toLowerCase()=='post')
           {objX.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded");}
        
       }
       
    return objX;
}

function getAjaxRequestError(ResponseText)
{
 var ErrID,Message;
 if(ResponseText.substring(0,5)=="+ERR:")
    {
     ErrID   = ResponseText.substring(5,ResponseText.indexOf("\n"))
     Message = ResponseText.substring(ResponseText.indexOf("\n")+1);     
    }
  var ret=new Object();
  ret.ErrID=ErrID;
  ret.Message=Message; 
  alert("ERR:" +ResponseText)  
    return ret;// new Array(ErrID,Message);
}

function setButtonMouseMoveEvents(button)
{
  button.style.color='#808080';
  button.onmouseover=function(){this.style.color='#808080'}; 
  button.onmouseout=function(){this.style.color='#000000';};
}

function setEnterSubmitForTextBox(TextBox,CommandButtonName)
{
  if(document.captureEvents)
     document.captureEvents(Event.KEYPRESS);
  if(typeof TextBox =='string')TextBox=document.getElementById(TextBox)     
  TextBox.onkeypress=function(e)
     {
       if(getkeyCode(e)==13)
          {
           if(typeof CommandButtonName =='string')      
               __doPostBack(CommandButtonName,'');
           else (typeof CommandButtonName =='object') 
             {
              if(CommandButtonName.onclick)
                 if(CommandButtonName.onclick()==false)
                    return false;     
              if(CommandButtonName.tagName.toUpperCase()=='A')
                 {if(CommandButtonName.href!='')
                     document.location.href=CommandButtonName.href;}
              }
             
          }
     }   
}

function getkeyCode(e)
{ var keyPressed;
   if(document.all)
       {keyPressed = window.event.keyCode;}
    else
       {if(e.which) keyPressed= e.which;
        else keyPressed = e.keyCode;}
    return keyPressed;
}



function IsValedEMail(sEmail)
{var strRegExp=/[\w]{1}[\w+-.]{1,}[@][\w]{2,}[.][\W\w]{1,}$/i;
 return sEmail.search(strRegExp)==0;
}
function IsValedZipCode(sZipCode)
{var strRegExp=/\d{5}((-\d{4})|[.]{0})$/i;
 return sZipCode.search(strRegExp)==0;
}
function IsValedPhoneNumber(sPhone)
{if(!(sPhone.length==10 || sPhone.length==12))return false;
 var strRegExp=/^([0-9]{3}[-]{0,1}){2}[0-9]{4}$/i;
 return sPhone.search(strRegExp)==0;
}


function trim(str)
{return str.replace(/^[ ]*(.*[^ ])*[ ]*$/ig,"$1");}




 var ValidatingTypes=new Function();
ValidatingTypes.prototype=
{
 EmailAddress:1,
 Phone:2,
 Date:3,
 Integer:4
 }
 var vType=new ValidatingTypes();