var customertexterrorstring="=All fields must be completed";
var hotelemailinvalidstring="=Invalid email";
var hotelpasswordinvalidstring="=Invalid password";
var hoteluserinusestring="=Username already in use";
var hotelemailinusestring="=Email already in use";
var hotelunameinvalidstring="=Invalid username";

var customervalidated = false;

var fieldsvalidated=0;

var uname;

var pword;

var mail;

var name;

var sname;

var address1;

var address2;

var address3;

var XMLHTTP4;

var XMLHTTP;

var emailaddy;

function SendEmail_OnClick()
{

var emailvalidated=0;

document.getElementById("sendercell").style.color='#ece9d8';


document.getElementById("emailcell").style.color='#ece9d8';


document.getElementById("subjectcell").style.color='#ece9d8';


document.getElementById("messagecell").style.color='#ece9d8';


document.getElementById("row1cell1").style.color='#FFFFFF';

document.getElementById("row1cell2").innerHTML="";


document.getElementById("row2cell1").style.color='#FFFFFF';

document.getElementById("row2cell2").innerHTML="";

document.getElementById("row3cell1").style.color='#FFFFFF';

document.getElementById("row3cell2").innerHTML="";

document.getElementById("row4cell1").style.color='#FFFFFF';

document.getElementById("row4cell2").innerHTML="";







if(document.getElementById("ctl00_mainContentPlaceHolder_txtSenderName").value=="")
{


document.getElementById("sendercell").style.color="red";



document.getElementById("row1cell1").style.color="red";

    //shows the appropriate error string in bottom table cell
    document.getElementById("row1cell2").innerHTML="=Sender name cannot be blank";
    //validated is not zero
    emailvalidated = 1;

}

if(document.getElementById("ctl00_mainContentPlaceHolder_txtSenderEmail").value=="")
{


document.getElementById("emailcell").style.color='red';



document.getElementById("row2cell1").style.color='red';

    //shows the appropriate error string in bottom table cell
    document.getElementById("row2cell2").innerHTML="=Email address cannot be blank";
    //validated is not zero
    emailvalidated = 2;

}

if(document.getElementById("ctl00_mainContentPlaceHolder_txtSenderSubject").value=="")
{


document.getElementById("subjectcell").style.color='red';


document.getElementById("row3cell1").style.color='red';

    //shows the appropriate error string in bottom table cell
    document.getElementById("row3cell2").innerHTML="=Subject cannot be blank";
    //validated is not zero
    emailvalidated = 3;

}



if(document.getElementById("ctl00_mainContentPlaceHolder_txtSenderMessage").value=="")
{


document.getElementById("messagecell").style.color='red';



document.getElementById("row4cell1").style.color='red';

    //shows the appropriate error string in bottom table cell
    document.getElementById("row4cell2").innerHTML="=Body cannot be blank";
    //validated is not zero
    emailvalidated = 4;

}



if(emailvalidated==0)
    {

var sendername = document.getElementById("ctl00_mainContentPlaceHolder_txtSenderName").value;
var senderemail = document.getElementById("ctl00_mainContentPlaceHolder_txtSenderEmail").value;
var sendersubject = document.getElementById("ctl00_mainContentPlaceHolder_txtSenderSubject").value;
var sendermessage = document.getElementById("ctl00_mainContentPlaceHolder_txtSenderMessage").value;
var requestUrl ="Ajax2.aspx?Action=SendMail&name="+ encodeURIComponent(sendername)+"&email="+encodeURIComponent(senderemail)+"&subject="+encodeURIComponent(sendersubject)+"&message="+encodeURIComponent(sendermessage);
	
	CreateXMLHTTP();

	// If browser supports XMLHTTPRequest object
	if(XMLHTTP)
	{
		//Setting the event handler for the response
		XMLHTTP.onreadystatechange = ShowEmailSuccessMsg;
		
		//Initializes the request object with the "POST" method of posting), 
		//the request URL and sets the request as asynchronous="true".
		XMLHTTP.open("GET", requestUrl, true);
	
		//Sends the request to server
		XMLHTTP.send(null);	

	}


    }
    else
    
    {
    
    }

}




function clearEmailCells()
{


document.getElementById("sendercell").style.color='#ece9d8';

document.getElementById("row1cell1").style.color='#FFFFFF';


document.getElementById("emailcell").style.color='#ece9d8';


document.getElementById("subjectcell").style.color='#ece9d8';


document.getElementById("messagecell").style.color='#ece9d8';



document.getElementById("row1cell1").style.color='#FFFFFF';





document.getElementById("row2cell1").style.color='#FFFFFF';

document.getElementById("row1cell2").innerHTML="";

document.getElementById("row2cell2").innerHTML="";

document.getElementById("row3cell1").style.color='#FFFFFF';


document.getElementById("row3cell2").innerHTML="";

document.getElementById("row4cell1").style.color='#FFFFFF';


document.getElementById("row4cell2").innerHTML="";

document.getElementById("row5cell1").style.color='#FFFFFF';


document.getElementById("row5cell2").innerHTML="";

document.getElementById("row5cell2").style.color='#FFFFFF';


document.getElementById("ctl00_mainContentPlaceHolder_txtSenderName").value="";


document.getElementById("ctl00_mainContentPlaceHolder_txtSenderEmail").value="";


document.getElementById("ctl00_mainContentPlaceHolder_txtSenderSubject").value="";


document.getElementById("ctl00_mainContentPlaceHolder_txtSenderMessage").value="";

}


function ShowEmailSuccessMsg()
{

	//receiving response from server	
	
	if(XMLHTTP.readyState == 4)
	{
	

		//Valid Response is received
		if(XMLHTTP.status == 200)
		{	
			

alert("Message sent successfully");
    document.getElementById("divThankYouMessage").style.visibility = 'visible';
    document.getElementById("ctl00_mainContentPlaceHolder_txtSenderName").value="";
    document.getElementById("ctl00_mainContentPlaceHolder_txtSenderEmail").value="";
    document.getElementById("ctl00_mainContentPlaceHolder_txtSenderSubject").value="";
    document.getElementById("ctl00_mainContentPlaceHolder_txtSenderMessage").value="";
    

		}
		else //something is wrong 
		{
			alert("Could not send email, please check email address");
        
         }
		
	}
	else
	{
		 //Waiting for response for server 
	}
}





function CreateXMLHTTP()
{	  
	
	try
	{   //Creating XMLHTTP Request object for Internet Explorer browser
		XMLHTTP = new ActiveXObject("Msxml2.XMLHTTP");

param="POST";
	}
	catch(e)
	{
		try
		{
            //Creating XMLHTTP Request object for browsers other than Internet Explorer or 

			XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			//if the XMLHTTP Request object cannot be created
              
                 XMLHTTP = null;
			
		}
	}

	 //Creating XMLHTTP Request object for Mozilla and Safari browser
	 //(i.e. it has been created but the type is undefined)
	if(!XMLHTTP && typeof XMLHttpRequest != "undefined") 
	{
	
XMLHTTP = new XMLHttpRequest();
param="GET";
	}
}


function btnInsertCustomer_OnClick()
{
fieldsvalidated=0;
clearCustomerCells();

if(document.getElementById("ctl00_mainContentPlaceHolder_txtUsername").value=="")
{
    
//fourth row of the table


document.getElementById("unamecell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("unamecell").style.color="#ece9d8";

}



if(document.getElementById("ctl00_mainContentPlaceHolder_txtPassword").value=="")
{
    
//fourth row of the table


document.getElementById("pwordcell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("pwordcell").style.color="#ece9d8";

}



if(document.getElementById("ctl00_mainContentPlaceHolder_txtFname").value=="")
{
    
//fourth row of the table


document.getElementById("fnamecell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("fnamecell").style.color="#ece9d8";

}


if(document.getElementById("ctl00_mainContentPlaceHolder_txtSname").value=="")
{
    
//fourth row of the table


document.getElementById("snamecell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("snamecell").style.color="#ece9d8";

}


if(document.getElementById("ctl00_mainContentPlaceHolder_txtAdd1").value=="")
{
    
//fourth row of the table


document.getElementById("add1cell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("add1cell").style.color="#ece9d8";

}


if(document.getElementById("ctl00_mainContentPlaceHolder_txtAdd2").value=="")
{
    
//fourth row of the table


document.getElementById("add2cell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("add2cell").style.color="#ece9d8";

}

if(document.getElementById("ctl00_mainContentPlaceHolder_txtAdd3").value=="")
{
    
//fourth row of the table


document.getElementById("add3cell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("add3cell").style.color="#ece9d8";

}

if(document.getElementById("ctl00_mainContentPlaceHolder_txtEmail").value=="")
{
    
//fourth row of the table


document.getElementById("emailcell").style.color='red';


    //validated is not zero
    fieldsvalidated = 1;
    //shows the appropriate error string in bottom table cell
    showhoteltexterrorstring();
   
} 

else
{
   
document.getElementById("emailcell").style.color="#ece9d8";

}



if(fieldsvalidated==0)

{

 
uname=document.getElementById("ctl00_mainContentPlaceHolder_txtUsername").value;
pword=document.getElementById("ctl00_mainContentPlaceHolder_txtPassword").value;
name=document.getElementById("ctl00_mainContentPlaceHolder_txtFname").value;
mail=document.getElementById("ctl00_mainContentPlaceHolder_txtEmail").value;
sname=document.getElementById("ctl00_mainContentPlaceHolder_txtSname").value;
address1=document.getElementById("ctl00_mainContentPlaceHolder_txtAdd1").value;
address2=document.getElementById("ctl00_mainContentPlaceHolder_txtAdd2").value;
address3=document.getElementById("ctl00_mainContentPlaceHolder_txtAdd3").value;



validateInfo(uname,pword,mail,name);


}
else

{

}




}







function showhoteltexterrorstring (){
 
    // bottom table
    var tbl  = document.getElementById('tblbottomdiv2');
    //gets the rows
    var rows = tbl.getElementsByTagName('tr');

    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //color of text in first cell of that row is set to 'red'
    cels2[0].style.color='red';
     //text in first cell of that row is set to '*'
    cels2[0].innerHTML="*";
    
    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //text in second cell of that row is set to the appropropriate error string
    cels2[1].innerHTML=customertexterrorstring;
    
    //fullyvalidated variable is set to false
    customervalidated=false;
 }
 



 function clearCustomerCells()
 {
document.getElementById("unamecell").style.color="#ece9d8";
document.getElementById("pwordcell").style.color="#ece9d8";
document.getElementById("fnamecell").style.color="#ece9d8";
document.getElementById("snamecell").style.color="#ece9d8";
document.getElementById("add1cell").style.color="#ece9d8";
document.getElementById("add2cell").style.color="#ece9d8";
document.getElementById("add3cell").style.color="#ece9d8";
document.getElementById("emailcell").style.color="#ece9d8";
document.getElementById("waitloader").innerHTML="";




var tbl  = document.getElementById('tblbottomdiv2');
    //gets the rows
    var rows = tbl.getElementsByTagName('tr');

    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //color of text in first cell of that row is set to 'red'
   
    cels2[0].innerHTML="";
    
    
    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //text in second cell of that row is set to the appropropriate error string
    cels2[1].innerHTML="";


 }
 
 function showhotelemailinvalidstring()
 {
 var tbl  = document.getElementById('tblbottomdiv2');
    //gets the rows
    var rows = tbl.getElementsByTagName('tr');

    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //color of text in first cell of that row is set to 'red'
    cels2[0].style.color='red';
     //text in first cell of that row is set to '*'
    cels2[0].innerHTML="*";
    
    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //text in second cell of that row is set to the appropropriate error string
    cels2[1].innerHTML=hotelemailinvalidstring;
 
    //fullyvalidated variable is set to false
    customervalidated=false;
 }
 
  function showhotelpasswordinvalidstring()
 {
 var tbl  = document.getElementById('tblbottomdiv2');
    //gets the rows
    var rows = tbl.getElementsByTagName('tr');

    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //color of text in first cell of that row is set to 'red'
    cels2[0].style.color='red';
     //text in first cell of that row is set to '*'
    cels2[0].innerHTML="*";
    
    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //text in second cell of that row is set to the appropropriate error string
    cels2[1].innerHTML=hotelpasswordinvalidstring;
 
    //fullyvalidated variable is set to false
    customervalidated=false;
 }
 
 function showhoteluserinusestring()
{
var tbl  = document.getElementById('tblbottomdiv2');
    //gets the rows
    var rows = tbl.getElementsByTagName('tr');

    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //color of text in first cell of that row is set to 'red'
    cels2[0].style.color='red';
     //text in first cell of that row is set to '*'
    cels2[0].innerHTML="*";
    
    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //text in second cell of that row is set to the appropropriate error string
    cels2[1].innerHTML=hoteluserinusestring;
 
    //fullyvalidated variable is set to false
    customervalidated=false;
}
 
 function showhotelemailinusestring()
 
 {
 var tbl  = document.getElementById('tblbottomdiv2');
    //gets the rows
    var rows = tbl.getElementsByTagName('tr');

    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //color of text in first cell of that row is set to 'red'
    cels2[0].style.color='red';
     //text in first cell of that row is set to '*'
    cels2[0].innerHTML="*";
    
    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //text in second cell of that row is set to the appropropriate error string
    cels2[1].innerHTML=hotelemailinusestring;
 
    //fullyvalidated variable is set to false
    customervalidated=false;
 }
 
 
 
 function showhotelunameinvalidstring()
 
 {
 var tbl  = document.getElementById('tblbottomdiv2');
    //gets the rows
    var rows = tbl.getElementsByTagName('tr');

    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //color of text in first cell of that row is set to 'red'
    cels2[0].style.color='red';
     //text in first cell of that row is set to '*'
    cels2[0].innerHTML="*";
    
    //first row of the table
    var cels2 = rows[0].getElementsByTagName('td')
    //text in second cell of that row is set to the appropropriate error string
    cels2[1].innerHTML=hotelunameinvalidstring;
 
    //fullyvalidated variable is set to false
    customervalidated=false;
 }
 
 
 
 
 
 
 
 function btnClearCustomerFields_OnClick()
 {
clearCustomerCells();

document.getElementById("ctl00_mainContentPlaceHolder_txtUsername").value="";
document.getElementById("ctl00_mainContentPlaceHolder_txtPassword").value="";
document.getElementById("ctl00_mainContentPlaceHolder_txtFname").value="";
document.getElementById("ctl00_mainContentPlaceHolder_txtSname").value="";
document.getElementById("ctl00_mainContentPlaceHolder_txtAdd1").value="";
document.getElementById("ctl00_mainContentPlaceHolder_txtAdd2").value="";
document.getElementById("ctl00_mainContentPlaceHolder_txtAdd3").value="";
document.getElementById("ctl00_mainContentPlaceHolder_txtEmail").value="";



 }
 
 
 function validateInfo(uname,pword,mail,name)
 {

 
 requestUrl="";
    //re-assigning AjaxPage variable to "ActivateAjax.aspx"
	AjaxPage = "Ajax2.aspx";
	//creating the URL to be sent by the XMLHTTP Request object 
	var requestUrl =AjaxPage  += "?Action=CheckUser&user=" + encodeURIComponent(uname)+"&password="+ encodeURIComponent(pword)+"&email="+ encodeURIComponent(mail)+"&sname="+ encodeURIComponent(name);
	//calling the function that creates the XMLHTTPRequest object
	CreateXMLHTTP4();

	// If browser supports XMLHTTPRequest object
	if(XMLHTTP4)
	{
		//The state of the XMLHTTPRequest object has changed.
		//Specifying a reference to an event handler ("FindHotel" function) as the event that fires at every state change.
		//calling jscript function "FindHotel" 
		XMLHTTP4.onreadystatechange = ValidateCheck;
		//Passing 3 values to the "open" method of the XMLHTTP object we have just created
		//1.The first parameter is "POST" (method parameter)
		//2.The second parameter is the URL (as set above)
		//3.The third parameter (async) is set to "true".
		XMLHTTP4.open(param, requestUrl,  true);
		
		//Sends the request to server
		XMLHTTP4.send(null);	
	}



   
   
 }
 

 
 
 function CreateUser()
 {
  requestUrl="";
    //re-assigning AjaxPage variable to "ActivateAjax.aspx"
	AjaxPage = "Ajax2.aspx";
	//creating the URL to be sent by the XMLHTTP Request object 
	var requestUrl =AjaxPage  += "?Action=AddUser&username=" + encodeURIComponent(uname)+ "&pass="+ encodeURIComponent(pword)+"&firstname="+ encodeURIComponent(name)+"&surname="+ encodeURIComponent(sname)+"&add1="+ encodeURIComponent(address1)+"&add2="+ encodeURIComponent(address2)+"&add3="+ encodeURIComponent(address3)+"&mail="+ encodeURIComponent(mail);
	//calling the function that creates the XMLHTTPRequest object
	CreateXMLHTTP4();

	// If browser supports XMLHTTPRequest object
	if(XMLHTTP4)
	{
		//The state of the XMLHTTPRequest object has changed.
		//Specifying a reference to an event handler ("FindHotel" function) as the event that fires at every state change.
		//calling jscript function "FindHotel" 
		XMLHTTP4.onreadystatechange = AddCustomer;
		//Passing 3 values to the "open" method of the XMLHTTP object we have just created
		//1.The first parameter is "POST" (method parameter)
		//2.The second parameter is the URL (as set above)
		//3.The third parameter (async) is set to "true".
		XMLHTTP4.open(param, requestUrl,  true);
		
		//Sends the request to server
		XMLHTTP4.send(null);	
	}



   
   
 }
 
 function AddCustomer()
 
 {
 
 var usname = $get('ctl00_mainContentPlaceHolder_txtUsername').value;
 var paword = $get('ctl00_mainContentPlaceHolder_txtPassword').value;
 var isPersistent = false;
 var customInfo = null;
 var redirectUrl = null;
 var returnedstr2=null;
 var str2=null;
 
if(XMLHTTP4.readyState == 4)
	{
  



		//If a valid Response is received
		if(XMLHTTP4.status == 200)
		{
		 	changeLogin();
         alert("New User created");
		 document.getElementById("waitloader").innerHTML="";	
		   
         btnClearCustomerFields_OnClick();
                 
         returnedstr2=XMLHTTP4.responseText;
          
        
         str2=returnedstr2.substring(0,8);
    
         if(str2=="continue")	
          {                          	
		  window.location.href="http://www.centralreservations.ie/BookingDetails.aspx";
	      }
	      else
	      {
	      }
		   
		}
		else 
		{
		//if a valid response could not be retrieved from server
		alert("Could not retrieve data from server");
		}
		
	   
	}
	else
	{
	//Waiting for response for server 
	}
 
 }
 
 
 
 function ValidateCheck()
 
 {
  
 
document.getElementById("waitloader").innerHTML="<font color='red'>&nbsp;&nbsp;Please Wait</font>&nbsp;&nbsp;<img src='ajax-loader.gif' />";

if(XMLHTTP4.readyState == 4)
	{
  



		//If a valid Response is received
		if(XMLHTTP4.status == 200)
		{
		 	
		   var str=null;
		   var str=XMLHTTP4.responseText;
                

		  if(str=="invalidpassword")
		  {
		  document.getElementById("waitloader").innerHTML="";
		  document.getElementById("pwordcell").style.color='red';
          showhotelpasswordinvalidstring();
		  alert("Password provided is invalid");
		  }
		  else if (str=="invalidemail")
		  {
		   document.getElementById("waitloader").innerHTML="";
		   document.getElementById("emailcell").style.color='red';
		   showhotelemailinvalidstring();
		   alert("Email address provided is invalid");
		  }
		  
		  else if(str=="userinuse")
		  
		  {
		  document.getElementById("waitloader").innerHTML="";
		  document.getElementById("unamecell").style.color='red';
		  showhoteluserinusestring();
		  alert("Username provided in use");
		 
		  }
		  
		   else if(str=="invaliduser")
		  
		  {
		  document.getElementById("waitloader").innerHTML="";
		  document.getElementById("unamecell").style.color='red';
		  showhotelunameinvalidstring();
		  alert("Username provided is invalid");
		 
		  }
		  
	       else if(str=="emailinuse")
		  
		  {
		 document.getElementById("waitloader").innerHTML="";
		 document.getElementById("emailcell").style.color='red';
 		 showhotelemailinusestring();
		  alert("Email address provided in use");
		  }
	
		  else
		  {
		  
		 CreateUser();
		
                // Log them in.
               
                               
		  }
		 
           
		   	
		}
		else 
		{
		//if a valid response could not be retrieved from server
		alert("Could not retrieve data from server");
		}
		
	   
	}
	else
	{
	//Waiting for response for server 
	}
 
 
 }
 
 
  
            function logoutHandler() {
                // Log them out.
                var redirectUrl = null;
                var userContext = null;
                Sys.Services.AuthenticationService.logout(redirectUrl, onLogoutComplete,onError,userContext);
           
            }
           
            function onLoginComplete(result, context, methodName) {

                     
           if(result==true)
                   {
                
                   loggedinuser=document.getElementById("ctl00_mainContentPlaceHolder_txtUsername").value;
             
                   document.getElementById("userastcell").className = "donotshowcell"; 
                   document.getElementById("passastcell").className = "donotshowcell"; 
                   document.getElementById("usernamecell").className = "donotshowcell"; 
                   document.getElementById("usercell").className = "donotshowcell";
                   document.getElementById("passwordcell").className = "donotshowcell";
                   document.getElementById("pwordcell").className = "donotshowcell";
                   document.getElementById("remembermecell").className = "donotshowcell";
                   document.getElementById("btnlogoutcell").className = "showcell";
                   document.getElementById("btnlogincell").className = "donotshowcell";
                   document.getElementById("ctl00_Label1").innerHTML = " &nbsp;&nbsp;&nbsp;Logged in as <b>"+ loggedinuser+"</b>";
          
                   }    
            }
           
            function onLogoutComplete(result, context, methodName) {
           
                // Logged out.  Hide the logged in view.
                //$get('LoggedInView').style.display = 'none';
                //$get('AnonymousView').style.display = '';
            }
           
            function onError(error, context, methodName) {
                alert("onError " + error);
            }
		
 
 
 
 
function CreateXMLHTTP4()
{	  
	
	try
	{   //Creating XMLHTTP Request object for Internet Explorer browser
		XMLHTTP4 = new ActiveXObject("Msxml2.XMLHTTP");

param="POST";
	}
	catch(e)
	{
		try
		{
            //Creating XMLHTTP Request object for browsers other than Internet Explorer or 

			XMLHTTP4 = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			//if the XMLHTTP Request object cannot be created
              
                 XMLHTTP4 = null;
			
		}
	}

	 //Creating XMLHTTP Request object for Mozilla and Safari browser
	 //(i.e. it has been created but the type is undefined)
	if(!XMLHTTP4 && typeof XMLHttpRequest != "undefined") 
	{
	
XMLHTTP4 = new XMLHttpRequest();
param="GET";
	}
}






 function btnGetpassword(emailaddy)
 {
document.getElementById("ctl00_mainContentPlaceHolder_passworderror").innerHTML = "";

 emailaddy=document.getElementById("ctl00_mainContentPlaceHolder_txtEmailAddy").value;
  requestUrl="";
    //re-assigning AjaxPage variable to "ActivateAjax.aspx"
	AjaxPage = "Ajax2.aspx";
	//creating the URL to be sent by the XMLHTTP Request object 
	var requestUrl =AjaxPage  += "?Action=retrievePassword&email=" + encodeURIComponent(emailaddy);
	//calling the function that creates the XMLHTTPRequest object
	CreateXMLHTTP();

	// If browser supports XMLHTTPRequest object
	if(XMLHTTP)
	{
		//The state of the XMLHTTPRequest object has changed.
		//Specifying a reference to an event handler ("FindHotel" function) as the event that fires at every state change.
		//calling jscript function "FindHotel" 
		XMLHTTP.onreadystatechange = Retrieve;
		//Passing 3 values to the "open" method of the XMLHTTP object we have just created
		//1.The first parameter is "POST" (method parameter)
		//2.The second parameter is the URL (as set above)
		//3.The third parameter (async) is set to "true".
		XMLHTTP.open(param, requestUrl,  true);
		
		//Sends the request to server
		XMLHTTP.send(null);	
	}



   
   
 }




 function Retrieve()
 
 {

//receiving response from server	
	if(XMLHTTP.readyState == 4)
	{
		//If a valid Response is received
		if(XMLHTTP.status == 200)
		{			
			
			 
		        if(XMLHTTP.responseText=="nouser")
		        {
		        
		        document.getElementById("ctl00_mainContentPlaceHolder_passworderror").innerHTML = "<font color='red'> No user registered under this email address ";
		        }
		        else
		        
		        {
		       document.getElementById("ctl00_mainContentPlaceHolder_passworderror").innerHTML = "Your password has been sent to you. Please check your email. ";

		        }
		}
		else  
		{
			//if a valid response could not be retrieved from server
			alert("Could not retrieve data from server");
			
		}
		
	}
	
	else
	{
	   //Waiting for response for server 
	}
    }
 
 
