// JavaScript Document

var xmlHttp

var params

var checkform = true;

function submitQuote() { 

	if (checkform) {
							
		if(document.getElementById("contact").value == ""){
			alert("Please enter the name of your contact");
			checkform = false;
		} else {
			checkform = true;
		}
							
		if (checkform) {
								
			var x = document.getElementById("emailaddress").value;
			var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if (filter.test(x)) {
				checkform = true;
			} else {
				alert("Please enter a valid contact email address");
				checkform = false;
			}
							
			if (checkform) {
							
				if(document.getElementById("telephone").value == ""){
					alert("Please enter your contact telephone number");
					checkform = false;
				} else {
					checkform = true;
				}
							
				if (checkform) {
	
	
					var multiCheckbox = false;
					var temp = "";
					var rad_temp;
					for (i = 0; i < document.plannerandquote.activities.length; i++) {
						if (document.plannerandquote.activities[i].checked) {
							temp = temp + "&activities[]=" + document.plannerandquote.activities[i].value;
							multiCheckbox = true;
						}
					}
	
					for (var i=0; i < document.plannerandquote.typeof_eventbreak.length; i++) {
  						if (document.plannerandquote.typeof_eventbreak[i].checked) {
      						rad_temp = "&eventbreak=" + document.plannerandquote.typeof_eventbreak[i].value;
      					}
   					}
								
					if (!multiCheckbox) {
						alert("Please select one or more activities");
						checkform = false;
					} else {
					
						// Start Quote Code
						xmlHttp=GetXmlHttpObject();
						if (xmlHttp==null) {
  							alert ("Your browser does not support AJAX!");
  							return;
  						} 								
				
						params = "noofpeople=" + document.getElementById("noofpeople").value+
						"&noofnights=" + document.getElementById("noofnights").value+
						"&noofdays=" + document.getElementById("noofdays").value+
						"&noofdayslunch=" + document.getElementById("noofdayslunch").value+
						"&noofdaysevemeal=" + document.getElementById("noofdaysevemeal").value+
						"&contact=" + document.getElementById("contact").value+
						"&emailaddress=" + document.getElementById("emailaddress").value+
						"&telephone=" + document.getElementById("telephone").value+
						rad_temp+
						temp;
						if (rad_temp == "&eventbreak=Activity Break") {
							var url="sendquote.php";
						} else {
							var url="sendquote_corporate.php";
						}
						xmlHttp.onreadystatechange=stateChanged4;
						xmlHttp.open("POST",url,true);
						//Send the proper header information along with the request
						xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  						xmlHttp.setRequestHeader("Content-length", params.length);
  						xmlHttp.setRequestHeader("Connection", "close");
						xmlHttp.send(params);
					}
				} // End of 4th Check
			} // End of 3rd Check
		} // End of 2nd Check
	} // End of 1st Check
	
} // End of function



function stateChanged4() 
{ 
if (xmlHttp.readyState==4)
{ 
window.location = "thankyou_plannerandquote.htm";
}
}

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;
}