var xmlHttp;

function AddLeads()
{ 
    try
    {
        var Email,FName,LName,PhoneArea,Phone,Address1,Address2,City,State,Zip1,Zip2;
        try{Email = document.getElementById('txtEmail').value} catch(ex){Email=''};
        try{FName = document.getElementById('txtFName').value} catch(ex){FName=''};
        try{LName = document.getElementById('txtLName').value} catch(ex){LName=''};
        try{PhoneArea = document.getElementById('txtPhoneArea').value} catch(ex){PhoneArea=''};
        try{Phone = document.getElementById('txtPhone').value} catch(ex){Phone=''};
        try{Address1 = document.getElementById('txtAddress1').value} catch(ex){Address1=''};
        try{Address2 = document.getElementById('txtAddress2').value} catch(ex){Address2=''};
        try{City = document.getElementById('txtCity').value} catch(ex){City=''};
        try{State = document.getElementById('cmbState').value} catch(ex){State='1'};
        try{Zip1 = document.getElementById('txtZip1').value} catch(ex){Zip1='00000'};
        try{Zip2 = document.getElementById('txtZip2').value} catch(ex){Zip2=''};

	    var objXMLHttp=null;

	    if (window.XMLHttpRequest)
	    {
	            objXMLHttp=new XMLHttpRequest();
	    }
	    else if (window.ActiveXObject)
	    {
		    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }

	    xmlHttp=objXMLHttp;
	    if (xmlHttp==null)
	    {
		    alert ("Browser does not support HTTP Request");
		    return;
	    } 
     
	    var url="LeadHanlder.aspx?";   //G.Singh | URL Edited: Directory Structure Changed | 07182008
	    url=url + "&Email=" + Email ;
	    url=url + "&FName=" + FName ;
	    url=url + "&LName=" + LName ;
	    url=url + "&PhoneArea=" + PhoneArea ;
	    url=url + "&Phone=" + Phone ;	
	    url=url + "&Address1=" + Address1 ;
	    url=url + "&Address2=" + Address2 ;	
	    url=url + "&City=" + City ;
	    url=url + "&State=" + State; 
	    url=url + "&Zip1=" + Zip1 ;
	    url=url + "&Zip2=" + Zip2 ;
    	
   	    xmlHttp.onreadystatechange=stateChanged ;
	    xmlHttp.open("GET",url,true) ;
	    xmlHttp.send(null) ;
	}
	catch (ex)
	{}
}

function stateChanged() 
{ 
    try
    {
	    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	    { 
		    document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	    } 
	}
	catch (ex)
	{}
} 

//[Added] [Neeraj K.] [For new distributors e-mail registration; using emailhandler.aspx.vb]
function AddEmails()
{ 
    try
    {
        var Email,FName,LName,PhoneArea,Phone,Address1,Address2,City,State,Zip1,Zip2,Company,Brands;
        try{Email = document.getElementById('txtEmail').value} catch(ex){Email=''};
        try{FName = document.getElementById('txtFName').value} catch(ex){FName=''};
        try{LName = document.getElementById('txtLName').value} catch(ex){LName=''};
        try{PhoneArea = document.getElementById('txtPhoneArea').value} catch(ex){PhoneArea=''};
        try{Phone = document.getElementById('txtPhone').value} catch(ex){Phone=''};
        try{Address1 = document.getElementById('txtAddress1').value} catch(ex){Address1=''};
        try{Address2 = document.getElementById('txtAddress2').value} catch(ex){Address2=''};
        try{City = document.getElementById('txtCity').value} catch(ex){City=''};
        try{Brands=document.getElementById('txtOtherBrands').value}catch(ex){Brands=''};
        var w = document.forms[0].cmbState.selectedIndex;
        var selected_text = document.forms[0].cmbState.options[w].text;

        try{State = selected_text} catch(ex){State='Not Selected'};
        try{Zip1 = document.getElementById('txtZip').value} catch(ex){Zip1='00000'};
        try{Company=document.getElementById('txtCompany').value}catch(ex){Company=''};
        try{Brands=document.getElementById('txtOtherBrands').value}catch(ex){Brands=''};

        var objXMLHttp=null;

        if (window.XMLHttpRequest)
        {
                objXMLHttp=new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        {
	        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }

        xmlHttp=objXMLHttp;
        if (xmlHttp==null)
        {
	        alert ("Browser does not support HTTP Request");
	        return;
        } 
     
        var url="emailHandler.aspx?";  //G.Singh | URL Edited: Directory Structure Changed | 07072008
        url=url + "&Email=" + Email ;
        url=url + "&FName=" + FName ;
        url=url + "&LName=" + LName ;
        url=url + "&PhoneArea=" + PhoneArea ;
        url=url + "&Phone=" + Phone ;	
        url=url + "&Address1=" + Address1 ;
        url=url + "&Address2=" + Address2 ;	
        url=url + "&City=" + City ;
        url=url + "&State=" + State ;
        url=url + "&Zip1=" + Zip1 ;
        url=url+"&Company="+Company;
        url=url+"&Brands="+Brands;
        xmlHttp.onreadystatechange=EmailstateChanged ;
        xmlHttp.open("GET",url,true) ;
        xmlHttp.send(null) ;
	}
	    catch (ex)
	    {}
}

function EmailstateChanged() 
{ 
    try
    {
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	    { 
	            //document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	            document.getElementById("main").style.visibility='hidden';
	            document.getElementById("txtHint").style.visibility='visible';
	            document.getElementById("txtHint").style.display='block';
        } 
        document.getElementById("btnEmail").value="Submit";
    }
    catch (ex)
    {}
} 
// [End Addition] [Neeraj K.][For new distributors e-mail registration; using emailhandler.aspx.vb]

//[Added] [Neeraj K.] [For new investors e-mail registration; using investoremailhandler.aspx.vb]
function AddInvestorEmails()
{ 
    try
    {
        var Email,FName,LName,PhoneArea,Phone,Address1,Address2,City,State,Country,Zip1,Zip2,CompName,Region,Brands;
        try{Email = document.getElementById('txtEmail').value} catch(ex){Email=''};
        try{FName = document.getElementById('txtFName').value} catch(ex){FName=''};
        try{LName = document.getElementById('txtLName').value} catch(ex){LName=''};
        try{PhoneArea = document.getElementById('txtPhoneArea').value} catch(ex){PhoneArea=''};
        try{Phone = document.getElementById('txtPhone').value} catch(ex){Phone=''};
        try{Address1 = document.getElementById('txtAddress1').value} catch(ex){Address1=''};
        try{Address2 = document.getElementById('txtAddress2').value} catch(ex){Address2=''};
        try{City = document.getElementById('txtCity').value} catch(ex){City=''};
        
        /*<Addition> Ravinder|20070602|We also need to send state in the email if the country is United States*/
        try{
            var u = document.forms[0].cmbState.selectedIndex;
            var selected_text1 = document.forms[0].cmbState.options[u].text;
            }
        catch(ex){};
        try{State = selected_text1} catch(ex){State='Not Selected'};
        /*</Addition> 
        /*<Change>Ravinder|20070602|Changed the field name of selected_text to selected_text2*/
        try{
            var w = document.forms[0].cmbCountry.selectedIndex;
            var selected_text2 = document.forms[0].cmbCountry.options[w].text;
            }
        catch(ex){};
        try{Country = selected_text2} catch(ex){Country='Not Selected'};
        /*<Change>*/

        try{Zip1 = document.getElementById('txtZip').value} catch(ex){Zip1='00000'};
        try{CompName=document.getElementById('txtCompName').value}catch(ex){CompName=''};
        try{Region=document.getElementById('txtRegion').value}catch(ex){Region=''};
        try{Brands=document.getElementById('txtOtherBrands').value}catch(ex){Brands=''};

	    var objXMLHttp=null;

	    if (window.XMLHttpRequest)
	    {
	            objXMLHttp=new XMLHttpRequest();
	    }
	    else if (window.ActiveXObject)
	    {
		    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }

	    xmlHttp=objXMLHttp;
	    if (xmlHttp==null)
	    {
		    alert ("Browser does not support HTTP Request");
		    return;
	    } 
     
	    var url="investorEmailHandler.aspx?";  //G.Singh | URL Edited: Directory Structure Changed | 07072008
	    url=url + "&Email=" + Email ;
	    url=url + "&FName=" + FName ;
	    url=url + "&LName=" + LName ;
	    url=url + "&PhoneArea=" + PhoneArea ;
	    url=url + "&Phone=" + Phone ;	
	    url=url + "&Address1=" + escape(Address1) ;
	    url=url + "&Address2=" + escape(Address2) ;
	    url=url + "&City=" + City ;
	    url=url + "&State=" + State ;
	    url=url + "&Country=" + Country ;
	    url=url + "&Zip1=" + Zip1 ;
	    url=url + "&CompName=" + CompName;
	    url=url + "&Region=" + Region;
	    url=url + "&Brands=" + Brands;

   	    xmlHttp.onreadystatechange=investorEmailstateChanged ;
	    xmlHttp.open("GET",url,true) ;
	    xmlHttp.send(null) ;
	}
	catch (ex)
	{}
}

function investorEmailstateChanged() 
{ 
    try
    {
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	    { 
	            document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
	            //document.getElementById("main").style.visibility='hidden';
	            document.getElementById("txtHint").style.visibility='visible';
	            document.getElementById("txtHint").style.display='block';
        } 
      //  document.getElementById("btnEmail").value="Submit";
    }
    catch(ex){};
    
} 
// [End Addition] [Neeraj K.][For new investors e-mail registration; using investoremailhandler.aspx.vb]


function GetXmlHttpObject()
{ 
    try
    {
	    var objXMLHttp=null;
	    if (window.XMLHttpRequest)
	    {
	            objXMLHttp=new XMLHttpRequest();
	    }
	    else if (window.ActiveXObject)
	    {
		    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    return objXMLHttp;
	}
	catch (ex)
	{}
}


 function GetDNS()
    {
        try
        {
            cookieDomain = document.location.hostname;
        }
        catch (ex)
        {}
    }
 function SetCookie(name,value,expires,path,domain,secure)
    {
        try
        {
            var strDNS = GetDNS();
            document.cookie = name + "=" +escape(value) +
            ( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
            ( (path) ? ";path=" + path : "") +
            //( (domain) ? ";domain=" + domain : "") +
            ( (domain) ? ";domain=" + strDNS : "") +
            ( (secure) ? ";secure" : "");             
            return true
        }
        catch (ex)
        {}
    }
    
 function GetCookie() 
    {
        try
        {
            var strName = "varCook";        
            if (document.cookie.indexOf(strName) == -1)
            {            
                return false;
            }
            else
            {
            cookieStart = document.cookie.indexOf(strName);        
            cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
            cookieValEnd = document.cookie.indexOf(";", cookieStart);
            if (cookieValEnd == -1)
                {
                cookieValEnd = document.cookie.length;
                }
            cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
            }
            if (cookieValue = "True")
            {
                return ("True");
            }
        }
        catch (ex)
        {}
    }
      
    SetCookie('varCook','True','','/','','');
    if (GetCookie() == "True")
    {         
           //alert('Cookies are Currently enable.');             
    } 
    else 
    {        
            alert('Cookies are Currently disabled. Please enable cookies.');             
    }  
    
 function doEnter(btnid)
   {
       try
       {
            var btn = document.getElementById(btnid); 
            if(window.Event)
                {
                 window.captureEvents(Event.KEYPRESS)
                }
            document.onkeypress=  keyPressed;
            function keyPressed(e)
               {
                 var n
                 (window.Event) ? n=e.which : n=event.keyCode
                 if (n==13)
                   {
                    btn.click(); 
                    return false;
                   }
                }
       }
       catch (ex)
        {}
    } 
    
function ShowPaypalProgress()
{
    try
    {
        var cancelbtn = document.getElementById("imgCancel"); 
        imgCancel.style.display="none";
        var submitbtn = document.getElementById("imgSubmit"); 
        submitbtn.style.display="none";    
        var paypalbtn = document.getElementById("divPaypalProcess"); 
        paypalbtn.style.display="block";
 	    return true;
 	}
 	catch (ex)
 	{}
} 

//G.Singh | Added:- To get height and width of Objects | 06172008
function getObjectWidth(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (elem.offsetWidth) {
        result = elem.offsetWidth;
    } else if (elem.clip && elem.clip.width) {
        result = elem.clip.width;
    } else if (elem.style && elem.style.pixelWidth) {
        result = elem.style.pixelWidth;
    }
    return parseInt(result);
}
function getRawObject(obj) {
    var theObj;
    if (typeof obj == "string") {
        if (isW3C) {
            theObj = document.getElementById(obj);
        } else if (isIE4) {
            theObj = document.all(obj);
        } else if (isNN4) {
            theObj = seekLayer(document, obj);
        }
    } else {
        // pass through object reference
        theObj = obj;
    }
    return theObj;
}
function getObjectLeft(obj)  {
    var elem = getRawObject(obj);
    var result = 0;
    if (document.defaultView) {
        var style = document.defaultView;
        var cssDecl = style.getComputedStyle(elem, "");
        result = cssDecl.getPropertyValue("left");
    } else if (elem.currentStyle) {
        result = elem.currentStyle.left;
    } else if (elem.style) {
        result = elem.style.left;
    } else if (isNN4) {
        result = elem.left;
    }
    return parseInt(result);
}

//G.Singh | Till Here:- To get height and width of Objects | 06172008

//G.Singh | Added: TO get event on Key press | 06242008
function doClick(buttonName,e)
    {
        //the purpose of this function is to allow the enter key to 
        //point to the correct button to click.
        var key;
        if(window.event)
            key = window.event.keyCode;     //IE
        else
            key = e.which;     //firefox
        
        if (key == 13)
        { 
           //Get the button the user wants to have clicked
            //alert(buttonName);
            var btn = document.getElementById(buttonName);
            //alert(btn);
            if (btn != null)
            {                     
               //If we find the button click it
                btn.click();
                return false;
                //event.keyCode = 0;
            }
        }
   }
//G.Singh | Till Here: TO get event on Key press | 06242008

//ticking clock
 function countdown(obj)
        {
	        this.obj= obj;
	        this.CountActive= true;
	        this.DisplayStr;
            this.Calcage= cd_Calcage;
	        this.CountBack= cd_CountBack;
	        this.Setup= cd_Setup;
        }
    function cd_Calcage(secs, num1, num2)
        {
          s = ((Math.floor(secs/num1))%num2).toString();
          if (s.length < 2) s = s;  /*G.Singh | Edited: "0" + s; Changed | 07082008*/
          return (s);
        }
    function cd_CountBack(secs,flag)
    {
          this.DisplayStr = this.DisplayFormat.replace(/%%D%%/g,	this.Calcage(secs,86400,100000));
          this.DisplayStr = this.DisplayStr.replace(/%%H%%/g,		this.Calcage(secs,3600,24));
          this.DisplayStr = this.DisplayStr.replace(/%%M%%/g,		this.Calcage(secs,60,60));
          this.DisplayStr = this.DisplayStr.replace(/%%S%%/g,		this.Calcage(secs,1,60));
          var abc=document.getElementById(this.Div).innerHTML;

            if (flag==1)
            {
             document.getElementById(this.Div).innerHTML = "<font color='#A92B77'>TIME&nbsp;LEFT &nbsp;</font> "+ this.DisplayStr;
            }
            else
            {
             document.getElementById(this.Div).innerHTML = "<div style='float:left;font-size:10px;text-align:center;width:100%;'><font color='#ffffff'>THIS SALE ENDS &nbsp;</div>"+ this.DisplayStr + "</font>";
            }
          
          if (this.CountActive) setTimeout(this.obj +".CountBack(" + (secs-1) + ","+ flag +")", 990);
    }
    function cd_Setup(flag)
    {
	    var dthen	= new Date(this.TargetDate);
	    var hdntt=document.getElementById('ctl00_ctl00_Body_Hdnservertime');
  	    var dnow	= new Date(hdntt.value);
	    ddiff		= new Date(dthen-dnow);
	    gsecs		= Math.floor(ddiff.valueOf()/1000);
	    this.CountBack(gsecs,flag);
    }
    
 /* Function for Click On SizeChart Images */
  function ViewBoxImages(URL)
    {
    var szStyle = 'width=770,height=400,top=10,left=10,toolbars=no,scrollbars=yes,status=no,resizable=yes';
    var win = window.open(URL, 'ViewImages', szStyle);
    win.focus();
    return false;
    }
  /* END */
  
 //[Neeraj K.][To open popup for variant details][07-May-2007]
function showVariantDetails(url)
   {
      var settings='height=420,width=500,scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes;left=300;';
      window.open(url,"Details",settings);
    }
//[End Neeraj K.]

/* Function To open the Popup in the Checkoutpage */
    function opencvv2()
    {
        var szStyle = 'top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no,width=500px,height=200px';
        window.open( 'SecurityCode.htm', '_blank', szStyle);
    }
    
/* END */
function ShowPopUp(StatusCode)
{
	var szURL = "../Common/OrderStatusPopUp.aspx?StatusCode=" + StatusCode + "&StatusType=OrderItem"
	
	var szStyle = 'width=600,height=600,top=10,left=10,toolbars=no,scrollbars=yes,status=no,resizable=yes';
	var win = window.open(szURL, 'StatusPopUp', szStyle);
	win.focus();
	return false;
}

function getInternetExplorerVersion()        
{
    try
    {
        // Returns the version of Internet Explorer or a -1
        // (indicating the use of another browser).
        var rv = -1; // Return value assumes failure.
        if (navigator.appName == 'Microsoft Internet Explorer')
        {
                var browser='IE'
                var ua = navigator.userAgent;
                var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                if (re.exec(ua) != null)
                rv = parseFloat( RegExp.$1 );
        }
        return rv;
    }
    catch (ex)
    {}
}  
/*G.Singh | Added: To raise event on Textbox Enter for LinkButton | 07112008*/
function LinkButton_keyPress(evt,but)
   {
        if(evt.which || evt.keyCode)
        {  
            if((evt.which == 13) || (evt.keyCode == 13))
            {
              location=document.getElementById(but).href;
              return false;  
             }
              return true;
        }
  }
/*G.Singh | Till Here: To raise event on Textbox Enter for LinkButton | 07112008*/
/*k.singh | 20090406 | Apply class to top right div (Already Login)*/
/*BEGIN*/
    function ApplyClass(objid)
    {
        try{
            var objtoplinklogin=document.getElementById(objid);
            if(objtoplinklogin != null)
                objtoplinklogin.className="Alreadylogindef2 Alreadylogintoplinkdef2";
            }
        catch(ex){}
    }
/*END*/