function createXHR() 
{
    var request = false;
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (err2) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (err3) {
		try {
			request = new XMLHttpRequest();
		}
		catch (err1) 
		{
			request = false;
		}
            }
        }
    return request;
}

function regWrite(url, content)	// url is the script and data is a string of parameters
{ 
	var xhr = createXHR();

	xhr.onreadystatechange=function()
	{ 
		if(xhr.readyState == 4)
		{
			// nothing for now
			// alert("sent " + url + " " + content);
		}
	}; 
	xhr.open("POST", url, true);		
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send(content); 
}

function clickform(obj) {
	if (obj.value.substr(0,6) == "Enter ") {
		obj.value = '';
	}
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function GPsubscribe()
{ 
	var contentn = document.ajaxreg.regn.value;
	var contente = document.ajaxreg.rege.value;
	var contentp = document.ajaxreg.regp.value;
	var contentu = document.ajaxreg.regurl.value;
	
	var storing = document.getElementById("regstatus");
	var regformy = document.getElementById("regforms");
	
	var regerror = 0;
	
	if (contentn.length <= 4) { regerror = 1; }
	if (echeck(contente) == false) { regerror = 1; }
	
	if (regerror == 0) {	
		regWrite(contentu+"plhb_subscribe.php", "sentplhbsubscribe=1&name="+ contentn +"&email=" + contente +"&phone="+ contentp);
		storing.innerHTML = "Thank you!<br />&nbsp;<br />You will recieve a confirmation within 72 hours to validate your Free Session Pass.<br />You must be a first time visitor, a Florida resident, and at least 18 years of age.<br />";
		regformy.style.display = "none";
		//var t = setTimeout("animatedcollapse.hide('regdiv')",10000);
	} else {
		storing.innerHTML = "Please enter a valid name<br />and&#47;or e-mail address.";
	}
}
