// BEGIN ALL AJAX FUNCTIONS//
var xmlHttp
// ---- THAIRAPY REQUEST ---------------------------------------------------//
function SendThairapyRequest(n,ea,p,r){ 
	show('onemomentcontact');
	hide('contactusdiv');
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}        
	var url="/assets/includes/send_request.aspx"
	url=url+"?n="+n
	url=url+"&ea="+ea
	url=url+"&p="+p
	url=url+"&r="+r
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	function stateChanged() {
		//alert(xmlHttp.readyState)
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			document.getElementById("contactusdiv").innerHTML="<strong>Thank you!<br />Your appointment request has been sent.</strong><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
			hide('onemomentcontact')
			show('contactusdiv')
		} 
	};
};
// ---- ADD TO MAILING LIST ---------------------------------------------------//
function MailListOptIn(OptInEmailAddress){
	hide('maillistoptin')
	show('onemoment')
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="/assets/includes/optin.aspx"
	url=url+"?OptInEmailAddress="+OptInEmailAddress
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null);
	function stateChanged() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
			document.getElementById("maillistoptin").innerHTML="Thank you for your interest in Thairapy Salon Spa.<br />Look for Thairapy Salon Spa mailings in your email inbox."
			hide('onemoment')
			show('maillistoptin')
		}
	};
};
//REQUIRED CODE FOR ALL AJAX FUNCTIONS------------------------------------//
function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
    	// Firefox, Opera 8.0+, Safari
    	xmlHttp=new XMLHttpRequest();
	}
	catch (e){
    	// Internet Explorer
    	try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
	}
	return xmlHttp;
};
// END ALL AJAX FUNCTIONS//
function show(id) {
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display='block';		
	} else { 
		if (document.layers) {	
			document.id.display='block';
		} else {
			document.all.id.style.display='block';
		}
	}
}
function hide(id) { 
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display='none';		
	} else { 
		if (document.layers) {	
			document.id.display='none';
		} else {
			document.all.id.style.display='none';
		}
	}
}
