function Fcheck()
{
	cid = document.form1.dt.value;
		if(cid == 'Select Date' || cid ==''){
		alert("Please check 'Check in Date'");
		document.form1.dt.focus();
		exit;
		}else{
var cidarray = cid.split("-");
cidy = cidarray[0];
cidm = cidarray[1]-1;
cidd = cidarray[2];
var today = new Date();
var cd = new Date();
cd.setYear(cidy);
cd.setMonth(cidm);
cd.setDate(cidd);
		if(cd <= today){
		alert("We do not book in History");
		document.form1.dt.focus();
		exit;
		}
	}
	cod = document.form1.dt.value;
	cod = new Date(cod);
		if(cod == 'Select Date' || cod =='' || cid > cod){
		alert("Please check 'Check out Date' should be later than Check in Date");
		document.form1.dt.focus();
		}else{
		document.form1.submit();
		}
}
//----------------------------------------------------------

function Check()
	{
/*		
	names = document.form_book.name.value;
	if(names =='')
		{
		alert("Please give yourself a name");
		document.form_book.name.focus();
		exit;
		}

	txt = document.form_book.email.value;
		if (txt.indexOf("@")<3){
		alert("I'm sorry. This email address seems wrong. Please"
		+" check the prefix and '@' sign.");
		document.form_book.email.focus();
		exit;
		}

		if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
		&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
		&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".co")<5)&&(txt.indexOf(".in")<5)){
		alert("I'm sorry. This email address seems wrong. Please"
		+" check the suffix for accuracy. (It should include a "
		+".com,.net,.org,.gov or .mil)");
		document.form_book.email.focus();
		exit;
		}
*/
	tel = document.form_book.roomType.value;
		if(tel =='' || tel =='0')
		{
		alert("Please select roomtype from list!");
		document.form_book.roomType.focus();
		exit;
		}

	cid = document.form_book.CIY.value + '-' + document.form_book.CIM.value + '-' + document.form_book.cid.value;
		if(cid == 'Select Date' || cid ==''){
		alert("Please check 'Check in Date'");
		document.form_book.cid.focus();
		exit;
		}
var cidarray = cid.split("-");
cidy = cidarray[0];
cidm = cidarray[1]-1;
cidd = cidarray[2];
var today = new Date();
var cd = new Date();
cd.setYear(cidy);
cd.setMonth(cidm);
cd.setDate(cidd);

		if(cd < today){
		alert("We do not book in the past! Please select a date ahead");
		document.form_book.cid.focus();
		return false;
		}

	cod = document.form_book.COY.value + '-' + document.form_book.COM.value + '-' + document.form_book.COD.value;
	//alert("Check out Date "+ cod);
var codarray = cod.split("-");
cody = codarray[0];
codm = codarray[1]-1;
codd = codarray[2];
//var today = new Date();
var od = new Date();
od.setYear(cody);
od.setMonth(codm);
od.setDate(codd);

		if(cod == 'Select Date' || cod =='' || cd > od){
		alert("Please check 'Check out Date' should be later than Check in Date");
		document.form_book.cod.focus();
		}else{
		document.form_book.submit();
		}
}

function submitformbook()
{
        document.form_book.submit();
}
function form_validate() {
		if (document.form_book.userid.value == "") {
			alert("Please Select login ID.");
			document.form_book.userid.focus();
			return false;
		}
		if (document.form_book.pasword.value =="") {
			alert("Please Enter password");
			document.form_book.pasword.focus();
			return false;
		} 
	var f_len= document.form_book.elements.length;
	for(i=0;i<=f_len-1;i++)
	{
		if (document.form_book.elements[i].type == "select-one")
		{	
			if (document.form_book.elements[i].value == "") {
			alert("Please select Room " + (i + 1));
			return false;
			}
		}
	} 
		return true;
}
function regform_validate() {
	
	var f_len= document.form_book.elements.length;
	for(i=0;i<=f_len-1;i++)
	{
		if (document.form_book.elements[i].type == "select-one")
		{	
			if (document.form_book.elements[i].value == "") {
			alert("Please select Room " + (i + 1));
			return false;
			}
		}
	} 
		
		if (document.form_book.loginid.value == "") {
			alert("Please Enter Login Id");
			document.form_book.loginid.focus();
			return false;

		} if (document.form_book.pword.value == "") {
			alert("Please Enter Password");
			document.form_book.pword.focus();
			return false;

		}if (document.form_book.pword1.value == "") {
			alert("Please Enter Password to Confirm");
			document.form_book.pword1.focus();	
			return false;
		} 
		if ((document.form_book.pword.value != document.form_book.pword1.value)) {
			alert("Confirm Password should be same as the password ");
			document.form_book.pword1.focus();
			return false;
		}	

	if(document.form_book.name.value =='')
		{
		alert("Please give yourself a name");
		document.form_book.name.focus();
		return false;
		}
	if(document.form_book.address.value =='')
		{
		alert("Please give yourself a Address");
		document.form_book.address.focus();
		return false;
		}	
/*
	txt = document.form_book.email.value;
		if (txt.indexOf("@")<3){
		alert("I'm sorry. This email address seems wrong. Please"
		+" check the prefix and '@' sign.");
		document.form_book.email.focus();
		return false;
		}

		if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
		&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
		&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".co")<5)&&(txt.indexOf(".in")<5)){
		alert("I'm sorry. This email address seems wrong. Please"
		+" check the suffix for accuracy. (It should include a "
		+".com,.net,.org,.gov or .mil)");
		document.form_book.email.focus();
		return false;
		} */
		if(document.form_book.city.value =='')
		{
		alert("Please give yourself a City");
		document.form_book.city.focus();
		return false;
		}
		if(document.form_book.teleres.value =='')
		{
		alert("Phone No please, it will not be made public");
		document.form_book.teleres.focus();
		return false;
		}
		return true;
}

function register_validate() {
names = document.frmnew.name.value;
	if(names =='')
		{
		alert("Please give yourself a name");
		document.frmnew.name.focus();
		return false;
		}
	login = document.frmnew.loginid.value;
	if(login =='')
		{
		alert("Please enter login name");
		document.frmnew.loginid.focus();
		return false;
		}
	if(document.frmnew.pword.value =='')
		{
		alert("Please enter password");
		document.frmnew.pword.focus();
		return false;
		}
	if(document.frmnew.pword1.value =='')
		{
		alert("Please again enter password");
		document.frmnew.pword1.focus();
		return false;
		}
	//txt = document.frmnew.email.value;
		//if (txt.indexOf("@")<3){
	//	alert("I'm sorry. This email address seems wrong. Please"
	//	+" check the prefix and '@' sign.");
	//	document.frmnew.email.focus();
	//	return false;
	//	}

	//	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
	//	&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
	//	&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".co")<5)&&(txt.indexOf(".in")<5)){
	//	alert("I'm sorry. This email address seems wrong. Please"
	//	+" check the suffix for accuracy. (It should include a "
	//	+".com,.net,.org,.gov or .mil)");
	//	document.frmnew.email.focus();
	//	return false;
	//	}

	tel = document.frmnew.teleres.value;
		if(tel =='')
		{
		alert("Phone No please, it will not be made public");
		document.frmnew.teleres.focus();
		return false;
		}
		return true;
}
function userlogin_validate () {
login = document.frmnew.loginid.value;
	if(login =='')
		{
		alert("Please enter login name");
		document.frmnew.loginid.focus();
		return false;
		}
	if(document.frmnew.pword.value =='')
		{
		alert("Please enter password");
		document.frmnew.pword.focus();
		return false;
		}	
}
function Submitregister(ActionType)
{
	if (ActionType == "login")	{

		if (document.form_book.userid.value == "") {
			alert("Please Select login ID.");
			document.form_book.userid.focus();
		}else if (document.form_book.pasword.value =="") {
			alert("Please Enter password");
			document.form_book.pasword.focus();
		} else 	{
			document.form_book.action="varifybooking.php";
			document.form_book.submit();				
		}
	} else if (ActionType == "register")	{
		alert('ans '+ActionType);
		if (document.form_book.name.value=="") {
			alert("Please Enter your full Name ");
			document.form_book.name.focus();

		}else if (document.form_book.address.value=="") {
			alert("Please Enter Address");
			document.form_book.address.focus();

		} else if (document.form_book.loginid.value == "") {
			alert("Please Enter Login Id");
			document.form_book.loginid.focus();

		}else if (document.form_book.pword.value == "") {
			alert("Please Enter Password");
			document.form_book.pword.focus();			

		}else if (document.form_book.pword1.value == "") {
			alert("Please Enter Password to Confirm");
			document.form_book.pword1.focus();			
		} 
		else if ((document.form_book.pword.value != document.form_book.pword1.value)) {

			alert("Confirm Password should be same as the password ");
			document.form_book.txt_confpassword.focus();			
		} else 	{
			document.form_book.action= "submitbooking.php";
			document.form_book.submit();				
		}
		
	} 
}
