function validate_email(field){
	 if (field.length < 6) return false;
	 var filter=/^.+@.+\..{2,3}$/
	 if (filter.test(field))
	     return true;
	 return false;
}
  function isValidNumber(str){
	regex =  /[^0-9]/i;
	if (regex.test(str))
		return true;
	else
		return false;
}
function validatemycruisequoteform(){
	var alertMsg = 'Please complete the following fields:\n';
	var l_Msg = alertMsg.length;
	 var room1adults = document.forms["requestquote"].elements["room1adults"].selectedIndex;
	 var room2adults = document.forms["requestquote"].elements["room2adults"].selectedIndex;
	 var room3adults = document.forms["requestquote"].elements["room3adults"].selectedIndex;
	 var room4adults = document.forms["requestquote"].elements["room4adults"].selectedIndex;

	 var room1children = document.forms["requestquote"].elements["room1children"].selectedIndex;
	 var room1childages = document.forms["requestquote"].elements["room1childages"].value;
	 var room2children = document.forms["requestquote"].elements["room2children"].selectedIndex;
	 var room2childages = document.forms["requestquote"].elements["room2childages"].value;
	 var room3children = document.forms["requestquote"].elements["room3children"].selectedIndex;
	 var room3childages = document.forms["requestquote"].elements["room3childages"].value;
	 var room4children = document.forms["requestquote"].elements["room4children"].selectedIndex;
	 var room4childages = document.forms["requestquote"].elements["room4childages"].value;
	 var myroomcount = document.forms["requestquote"].elements["numrooms"].selectedIndex + 1;
	 var mycontacttype = document.forms["requestquote"].elements["contactmethod"].selectedIndex;
	 var myfirstname = document.forms["requestquote"].elements["first"].value;
	 var mylastname = document.forms["requestquote"].elements["last"].value;
	 var mypostalcode = document.forms["requestquote"].elements["tpostalcode"].value;
	 var myemail = document.forms["requestquote"].elements["email"].value;
	 var myreemail = document.forms["requestquote"].elements["reemail"].value;
	 var myphoneareacode = document.forms["requestquote"].elements["tcodearea"].value;
	 var myphonenumber = document.forms["requestquote"].elements["tnumberphone"].value;
	 if (myfirstname.length < 3)
	     alertMsg += '- First Name\n';
	 if (mylastname.length < 3)
	     alertMsg += '- Last Name\n';
     if (mypostalcode.length == 0)
         alertMsg += '- Postal Code Missing\n';
     if (mypostalcode.length > 0 && mypostalcode.length < 5)
         alertMsg += '- Incorrect Postal Code.  You need at least 5 characters. If your country does not support at least 5 characters or does not have postal codes, then please try one of the following: \n 1) Pad zeros before your postal code to make into 5 characters \n 2) Put the name of your country\n';	 
	 if (!validate_email(myemail) || myemail != myreemail)
	     alertMsg += '- Email Address\n';
	 if (mycontacttype == 0)
	    alertMsg += '- Contact Method\n';
	 if (mycontacttype == 2 && (myphoneareacode.length < 3 || myphonenumber.length < 7 || isValidNumber(myphoneareacode) || isValidNumber(myphonenumber)))
	     alertMsg += '- Contact Number\n';
	 var room1count = 0;
	 var room2count = 0;
	 var room3count = 0;
	 var room4count = 0;
	 switch (myroomcount){
		 case 1: room1count = room1adults + room1children;  break;
		 case 2: room1count = room1adults + room1children; room2count = room2adults + room2children; break;
		 case 3: room1count = room1adults + room1children; room2count = room2adults + room2children; room3count = room3adults + room3children; break;
		 case 4: room1count = room1adults + room1children; room2count = room2adults + room2children; room3count = room3adults + room3children; room4count = room4adults + room4children; break;
	 }
	 if (room1count > 4) alertMsg += '- Cabin 1 can have a maximum of 4 passengers\n';
	 if (room2count > 4) alertMsg += '- Cabin 2 can have a maximum of 4 passengers\n';
	 if (room3count > 4) alertMsg += '- Cabin 3 can have a maximum of 4 passengers\n';
	 if (room4count > 4) alertMsg += '- Cabin 4 can have a maximum of 4 passengers\n';
	 if (room1count == 0) alertMsg += '- Number of Passengers missing in Cabin 1\n';
	 if (myroomcount >= 2 && room2count == 0) alertMsg += '- Number of Passengers missing in Cabin 2\n';
	 if (myroomcount >= 3 && room3count == 0) alertMsg += '- Number of Passengers missing in Cabin 3\n'; 
	 if (myroomcount == 4 && room4count == 0) alertMsg += '- Number of Passengers missing in Cabin 4\n'; 
	 if (room1count > 0 && room1children > 0 && room1childages.length == 0) alertMsg += '- Cabin 1 Children Ages\n';
	 if (room2count > 0 && room2children > 0 && room2childages.length == 0) alertMsg += '- Cabin 2 Children Ages\n';
	 if (room3count > 0 && room3children > 0 && room3childages.length == 0) alertMsg += '- Cabin 3 Children Ages\n';
	 if (room4count > 0 && room4children > 0 && room4childages.length == 0) alertMsg += '- Cabin 4 Children Ages\n';
	 if (alertMsg.length == l_Msg){
		requestquote.mysubmitbttn.disabled = true;
		return true;
	}
	alert(alertMsg);
	return false;

}
function onchangepeople1(){
	 var adults = 0;
	 var children = 0;
	 var seniors = 0;
	 var total = 0;
	 var room1adults = document.forms["requestquote"].elements["room1adults"].selectedIndex;
	 var room2adults = document.forms["requestquote"].elements["room2adults"].selectedIndex;
	 var room3adults = document.forms["requestquote"].elements["room3adults"].selectedIndex;
	 var room4adults = document.forms["requestquote"].elements["room4adults"].selectedIndex;
	 var room1children = document.forms["requestquote"].elements["room1children"].selectedIndex;
	 var room2children = document.forms["requestquote"].elements["room2children"].selectedIndex;
	 var room3children = document.forms["requestquote"].elements["room3children"].selectedIndex;
	 var room4children = document.forms["requestquote"].elements["room4children"].selectedIndex;
	 var myroomcount = document.forms["requestquote"].elements["numrooms"].selectedIndex;
	 myroomcount = myroomcount + 1;
	 switch (myroomcount){
		 case 1: adults = room1adults; children = room1children;
			 document.getElementById('totpax1').innerHTML = room1adults + room1children; 
			 break;
		 case 2: adults = room1adults + room2adults; children = room1children + room2children; 
			 document.getElementById('totpax1').innerHTML = room1adults + room1children; 
			 document.getElementById('totpax2').innerHTML = room2adults + room2children;
			 break;
		 case 3: adults = room1adults + room2adults + room3adults; children = room1children + room2children + room3children; 
			 document.getElementById('totpax1').innerHTML = room1adults + room1children;
			 document.getElementById('totpax2').innerHTML = room2adults + room2children;
			 document.getElementById('totpax3').innerHTML = room3adults + room3children; 
			 break;
		 case 4: adults = room1adults + room2adults + room3adults + room4adults; children = room1children + room2children + room3children + room4children; 
			 document.getElementById('totpax1').innerHTML = room1adults + room1children;
			 document.getElementById('totpax2').innerHTML = room2adults + room2children;
			 document.getElementById('totpax3').innerHTML = room3adults + room3children;
			 document.getElementById('totpax4').innerHTML = room4adults + room4children; 
			 break;
	 }
	 total = adults + seniors + children;
	 document.forms["requestquote"].elements["numpeople"].value = total;
}

function disabletextbox1(){
	if (document.forms["requestquote"]) {
	    document.forms["requestquote"].elements["numpeople"].disabled = true;
	    onchangepeople1();
	}
}
function changecontacttype(){
	 var mycontacttype = document.getElementById("contactmethod").selectedIndex;
	 if (mycontacttype == 2)
	     document.getElementById("scontacttype").style.display = '';
	 else
	     document.getElementById("scontacttype").style.display = 'none';
}
function changenumrooms(){
	 var myroomcount = document.forms["requestquote"].elements["numrooms"].selectedIndex;	 
	 switch (myroomcount){
		 case 0: document.getElementById('sroom2').style.display = 'none'; document.getElementById('sroom3').style.display = 'none'; document.getElementById('sroom4').style.display = 'none'; break;
		 case 1: document.getElementById('sroom2').style.display = ''; document.getElementById('sroom3').style.display = 'none'; document.getElementById('sroom4').style.display = 'none'; break;
		 case 2: document.getElementById('sroom2').style.display = ''; document.getElementById('sroom3').style.display = ''; document.getElementById('sroom4').style.display = 'none'; break;
		 case 3: document.getElementById('sroom2').style.display = ''; document.getElementById('sroom3').style.display = ''; document.getElementById('sroom4').style.display = ''; break;
	 }
}
function showobs(roomnum){
    var roomselectname = 'room' + roomnum + 'cabintype';
    var roomobsname = 'sroomobspan' + roomnum;
    if (document.forms["requestquote"].elements[roomselectname].selectedIndex > 0)
	document.getElementById(roomobsname).style.display = '';
    else
	document.getElementById(roomobsname).style.display = 'none';    
}
