﻿// JScript File

var xmlHttp=null;

function ExecuteCall(Email)
{ 
  // debugger;
	
	$.get('CheckUserEmail.aspx', { Value: Email }, function(Data) {
        if (Data == "False") {
            document.getElementById("snMsg").innerHTML = "Email Address already exist.";
        }
        else {
            document.getElementById("snMsg").innerHTML = "";
            Describe = document.getElementsByName("describe");
            var describeValue;

            for (var x = 0; x < Describe.length; x++) {
                if (Describe[x].checked)
                    describeValue = Describe[x].value;
            }

            window.location = "/myaccount.htm?fname=" + fName.value + "&lname=" + lName.value + "&email=" + Email + "&password=" + Password.value +
                            "&location=" + Location.value + "&describe=" + describeValue + "&raterental=" + $('#raterental').val();
        }
    },"text");
  
    var url = 'CheckUserEmail.aspx?Value=' + Email;
    try 
    { 
        //SendXmlHttpRequest(xmlHttp, url); 
        //xmlHttp = GetXmlHttpObject(CallBackMethod); 
    }
    catch(e){} 
} 

function CallBackMethod() 
{ 
    var result = null;
    try
    {
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	    { 
	        //get the results from the callback 
            result =  xmlHttp.responseText;
            SetValues(result);
	    }
    }   
    catch(e) {} 
} 
					
function GetXmlHttpObject(Handler)
{ 
    var oXmlHttp=null;
   
   if (navigator.userAgent.indexOf("Opera")>=0)
	{
	    alert("This doesn't work in Opera"); 
		return; 
	}
	
    if(window.XMLHttpRequest)
    {
        //For IE7, Mozilla, Safari & Netscape. 
        try
        {
            oXmlHttp=new XMLHttpRequest();
            if (navigator.userAgent.indexOf("MSIE")>=0 && navigator.appVersion.indexOf("MSIE 7.0")>=0)
            {
                oXmlHttp.onreadystatechange=Handler;
            }
            else
            {
		        oXmlHttp.onload=Handler;
		        oXmlHttp.onerror=Handler;
		    }
		    return oXmlHttp; 
		} 
		catch(e)
		{ 
		    alert("Unable to create XMLHttpRequest!"); 
		    return null; 
		} 
    }
    
    if(window.ActiveXObject)
    {
        //For < IE7 
        try
        {
            oXmlHttp = GetMSXmlHttp();
            oXmlHttp.onreadystatechange=Handler;
			return oXmlHttp;
        }
        catch(e)
        {
            alert("Unable to create ActiveX OR ActiveX might be disabled!");
            return null; 
        }
    }
}	

function GetMSXmlHttp()
{
    var xmlHttp = null;
    var clsIds = ["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.5.0","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP.2.6","Msxml2.XMLHTTP","Microsoft.XMLHTTP.1.0","Microsoft.XMLHTTP.1","Microsoft.XMLHTTP"];
                  
    for(var i=0; i<clsIds.length && xmlHttp == null; i++)
    {
        xmlHttp = CreateXmlHttp(clsIds[i]);
    }
    return xmlHttp;
}

function CreateXmlHttp(clsIds)
{
    var xmlHttp = null;
    
    try
    {
        xmlHttp = new ActiveXObject(clsIds);  
        return xmlHttp;      
    }
    catch(e)
    {
        return null;
    }
}               
					
function SendXmlHttpRequest(xmlhttp, url)
{ 
    xmlhttp.open('GET', url, true); 
    xmlhttp.send(null); 
}

function SetValues(Data)
{
    if(Data=="False")
    {
       document.getElementById("snMsg").innerHTML = "Email Address already exist.";
    }
    else
    {
        document.getElementById("snMsg").innerHTML = "";
        Describe = document.getElementsByName("describe");  
        var describeValue;
                    
        for (var x = 0; x < Describe.length; x ++) 
        {
            if (Describe[x].checked)
             describeValue = Describe[x].value;
        }            
                                 
        window.location="/myaccount.htm?fname=" + fName.value + "&lname=" + lName.value + "&email=" + Email.value + "&password=" + Password.value +
                        "&location=" + Location.value + "&describe=" + describeValue + "&raterental=" + raterental.value;   
    }             
}