var s=/^[0-9-() ]+$/;
var iChars = "`~!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
var e=/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,4}$/;
function CompareDates()
{
	var str1 = document.getElementById("checkin").value;
    var str2 = document.getElementById("checkout").value;
    var dt1  = parseInt(str1.substring(0,2),10);
    var mon1 = parseInt(str1.substring(3,5),10);
    var yr1  = parseInt(str1.substring(6,10),10);
    var dt2  = parseInt(str2.substring(0,2),10);
    var mon2 = parseInt(str2.substring(3,5),10);
    var yr2  = parseInt(str2.substring(6,10),10);
    var date1 = new Date(yr1, mon1, dt1);
    var date2 = new Date(yr2, mon2, dt2);
	//check todays date
	var myDate=new Date();
	//Date formate yyyy,mm,dd | mm = mm-1 months starts 0	
	myDate.setFullYear(yr1,mon1-1,dt1);
	var today = new Date();
	if (myDate<today) {
	  alert("Check in date should be greater than today date");
	  return false;
	}
	//check date comparison
	if(yr1 == yr2) {
		if(mon1 == mon2) {
			if(dt1 == dt2) {
        		alert("Check in and Check out date should not equal");
        		return false;
			}
		}
    }	
	if(date2 < date1) {
        alert("Invalid Check in and Check out date range");
        return false;
    }
	if(document.checkAvail.checkin.value == ''){
		alert("Please select the check in date");
		document.checkAvail.checkin.focus();
		return false; 
	}
	if(document.checkAvail.checkout.value == ''){
		alert("Please select the check out date");
		document.checkAvail.checkout.focus();
		return false; 
	}
	if(document.checkAvail.persons.value == ''){
		alert("Please enter number of persons");
		document.checkAvail.persons.focus();
		return false; 
	}
	if (!isInteger(document.checkAvail.persons.value)){
		alert("Please enter a valid number");
		document.checkAvail.persons.select();
		return false;
	}
	if(document.checkAvail.rooms.value == ''){
		alert("Please enter number of rooms");
		document.checkAvail.rooms.focus();
		return false; 
	}
	if (!isInteger(document.checkAvail.rooms.value)){
		alert("Please enter a valid number");
		document.checkAvail.rooms.select();
		return false;
	}
}	
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function conformBookingFrm(){ 

	gnamepre = document.conformBooking.gname.value;
	if(document.conformBooking.gname.value == ''){
		alert("Please enter the guest name");
		document.conformBooking.gname.focus();
		return false; 
	}
	if(document.conformBooking.gname.value != ''){
		for (var i = 0; i < gnamepre.length; i++) {
			var pos = iChars.indexOf(gnamepre.charAt(i));
			if (pos != -1) {
				alert("Please enter the valid char");
				document.conformBooking.gname.select();
    			return false;
			}
		}
	}
	if(document.conformBooking.gemail.value == ''){
		alert("Please enter the email address");
		document.conformBooking.gemail.focus();
	  	return false;
	}
	if(!document.conformBooking.gemail.value.match(e))
	{
		alert("Please enter the valid email address");
		document.conformBooking.gemail.select();
	  	return false;
	}
	if(document.conformBooking.gaddress.value == ''){
		alert("Please enter the address");
		document.conformBooking.gaddress.focus();
		return false; 
	}
	if(document.conformBooking.gcity.value == ''){
		alert("Please enter the city");
		document.conformBooking.gcity.focus();
		return false; 
	}
	if(document.conformBooking.gcountry.value == ''){
		alert("Please enter the country");
		document.conformBooking.gcountry.focus();
		return false; 
	}
	if(document.conformBooking.gmobile.value == ''){
		alert("Please enter the mobile number");
		document.conformBooking.gmobile.focus();
		return false; 
	}
	if(document.conformBooking.accept.checked == false){
		alert("Please accept the terms and condition");
		document.conformBooking.accept.focus();
		return false;
	}
	if(document.conformBooking.payment[0].checked == false && document.conformBooking.payment[1].checked == false){
		alert("Please select the payment mode");
		return false;
	}
}
function showDevakielite(){
	document.getElementById('mainhotel').style.display = 'none';
	document.getElementById('annex').style.display = 'block';
	document.getElementById('imgAnnex').src = 'WebResources/Images/Rooms_Annex_But.jpg';
	document.getElementById('imgHotel').src = 'WebResources/Images/Rooms_Main_But_Hover.jpg';
}
function showAnnex(){
	document.getElementById('mainhotel').style.display = 'block';
	document.getElementById('annex').style.display = 'none';
	document.getElementById('imgAnnex').src = 'WebResources/Images/Rooms_Annex_But_Hover.jpg';
	document.getElementById('imgHotel').src = 'WebResources/Images/Rooms_Main_But.jpg';
}