function loader() {
	var searchString = document.location.search;

	// strip off the leading '?'
	searchString = searchString.substring(1);

	var nvPairs = searchString.split("&");

	for (i = 0; i < nvPairs.length; i++)
	{
		 var nvPair = nvPairs[i].split("=");
		 var name = nvPair[0];
		 var value = nvPair[1];
	}
	//document.write(value);
	if (value) {
		makerequest('guestbook/thank.php', 'content');
	}
}
	
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 validate() {
	
	// first_name
	if (document.getElementById("first_name").value.length < 1) {
		alert("Please enter a valid first name.");
		document.getElementById("first_name_label").style.color = "red";
		document.getElementById("first_name").focus();
		return false;
	} else {
		document.getElementById("first_name_label").style.color = "black";
	}
	
	// last_name
	if (document.getElementById("last_name").value.length < 1) {
		alert("Please enter a valid last name.");
		document.getElementById("last_name_label").style.color = "red";
		document.getElementById("last_name").focus();
		return false;
	} else {
		document.getElementById("last_name_label").style.color = "black";
	}
	
	// email_address_1 (validate)
	if (echeck(document.getElementById("email_address_1").value) == false) {
		alert("Please enter a valid email address.");
		document.getElementById("email_address_1_label").style.color = "red";
		document.getElementById("email_address_1").focus();
		return false;
	} else {
		document.getElementById("email_address_1_label").style.color = "black";
	}
	
	// email_address_2 (match)
	if (document.getElementById("email_address_2").value != document.getElementById("email_address_1").value) {
		alert("Your email addresses do not match.");
		document.getElementById("email_address_2_label").style.color = "red";
		document.getElementById("email_address_2").focus();
		return false;
	} else {
		document.getElementById("email_address_2_label").style.color = "black";
	}
	
	/*if (!document.getElementById("agree").checked) {
		alert("Please read our terms and conditions and tick the checkbox if you agree with them.");
		return false;
	}*/
			
	// comment
	if (document.getElementById("comment").value.length < 1) {
		alert("Please enter a valid comment.");
		document.getElementById("comment_label").style.color = "red";
		document.getElementById("comment").focus();
		return false;
	} else {
		document.getElementById("comment_label").style.color = "black";
	}
	
	if (document.getElementById('result').innerHTML != 'PASS') {
		//getParam(document.getElementById('request'));
		alert("Please enter the exact code on the image into the text box and click the SECURITY CHECK link.");
		document.getElementById("txtCaptcha").focus();
		return false;
	}
	
}
