// JavaScript Document
function validBdayEvent()
{
	if(getVal())
	{
		if((document.bday.res_from.value == "") || (document.bday.res_time_from.value == "")){
			alert("Please Select Time of Reservation !!! Some Fields are Missing !!!");
			document.bday.res_from.focus();
			return false;
		}
		/*else if(!doDateCheck(document.bday.res_from, document.bday.res_to)){
			alert("Please check From and To date, To date should be greater than From date. !!!");
			return false;
		}*/

		else if(document.bday.bday_no_of_person.value == "")
		{
			alert("Please Specify the number of person will be in Event");
			return false;
		}
		else if(!document.getElementById('bday_spec_dec_yes').checked && !document.getElementById('bday_spec_dec_no').checked){
			alert("Please check one about special decoration");
			return false;
		}
		else if(document.getElementById('bday_spec_dec_yes').checked && (document.bday.bday_decoration_style.value.length < 1))
		{
			alert("Please specify your thought of decoration");
			document.bday.bday_decoration_style.focus();
			return false;
			
		}
		else if(!document.getElementById('bday_flower_yes').checked && !document.getElementById('bday_flower_no').checked){
			alert("Please check whether you need flower or not");
			return false;
		}
		else if(document.getElementById('bday_flower_yes').checked && (document.bday.bday_flower_name.value == "")){
				alert("Please specify the name to be displayed in flower");
				document.bday.bday_flower_name.focus();
				return false;
			}
		else if(document.getElementById('bday_flower_yes').checked && !document.getElementById('f1').checked && !document.getElementById('f2').checked && !document.getElementById('f3').checked){
				alert("Please Indicate how would you like to present the flower");
				return false;
			}
		else if(!document.getElementById('bday_welcome_yes').checked && !document.getElementById('bday_welcome_no').checked){
			alert("Please Specify whether your team needs welcome by us");
			return false;
		}
		else if(document.getElementById('bday_welcome_yes').checked && (document.bday.bday_menu_desc.value == "")){
				alert("Please specify the welcome menu list");
				return false;
		}
		
		else document.bday.submit();
		
	}//End of main if
}



function validFamilyGathering()
{
	if(getVal())
	{
		if((document.family_gathering.res_from.value == "") || (document.family_gathering.res_time_from.value == "")){
			alert("Please Select Time of Reservation !!! Some Fields are Missing !!!");
			return false;
		}
		/*
		else if(!doDateCheck(document.family_gathering.res_from, document.family_gathering.res_to)){
			alert("Please check from and to date !!!");
			return false;
		}
		
		*/
		else if(document.family_gathering.family_no_of_person.value == "")
		{
			alert("Please Specify the number of person will be in the Event");
			return false;
		}
		else if(!document.getElementById('fam_spec_dec_yes').checked && !document.getElementById('fam_spec_dec_no').checked){
			alert("Please check one about special decoration");
			return false;
		}
		else if(document.getElementById('fam_spec_dec_yes').checked && (document.family_gathering.family_decoration_style.value.length < 1))
		{
			alert("Please specify your thought of decoration");
			document.family_gathering.family_decoration_style.focus();
			return false;
			
		}
		else if(!document.getElementById('fam_chil_tbl_yes').checked && !document.getElementById('fam_chil_tbl_no').checked){
			alert("Please check whether you need the table for or not");
			return false;
		}
		else if(document.getElementById('fam_chil_tbl_yes').checked && (document.family_gathering.family_children_no.value == "")){
				alert("Please specify the number of childrens");
				return false;
			}
			
		else if(!document.getElementById('fam_welcome_yes').checked && !document.getElementById('fam_welcome_no').checked){
			alert("Please Specify whether your family needs welcome by refershment drink");
			return false;
		}
		else if(document.getElementById('fam_welcome_yes').checked && (document.family_gathering.family_menu_desc.value == "")){
			alert("Please specify the welcome menu list");
			return false;
		}
		else
		document.family_gathering.submit();
		
	}//End of main if
}

function validFriendGathering()
{
	if(getVal())
	{
		if((document.friend_gathering.res_from.value == "") ||(document.friend_gathering.res_time_from.value == "")){
			alert("Please Select Time of Reservation !!! Some Fields are Missing !!!");
			return false;
		}
		/*
		else if(!doDateCheck(document.friend_gathering.res_from, document.friend_gathering.res_to)){
			alert("Please check from and to date !!!");
			return false;
		}
		*/
		else if(document.friend_gathering.fren_no_of_person.value == "")
		{
			alert("Please Specify the number of person will be in the Event");
			return false;
		}
		else if(!document.getElementById('fren_spec_dec_yes').checked && !document.getElementById('fren_spec_dec_no').checked){
			alert("Please check one about special decoration");
			return false;
		}
		else if(document.getElementById('fren_spec_dec_yes').checked && (document.friend_gathering.fren_decoration_style.value.length < 1))
		{
			alert("Please specify your thought of decoration");
			document.friend_gathering.fren_decoration_style.focus();
			return false;
			
		}
					
		else if(!document.getElementById('fren_welcome_yes').checked && !document.getElementById('fren_welcome_no').checked){
			alert("Please Specify whether your group needs welcome by refershment drink.");
			return false;
		}
		else if(document.getElementById('fren_welcome_yes').checked && (document.friend_gathering.fren_menu_desc.value == "")){
			alert("Please specify the welcome menu list");
			return false;
		}
		else
		document.friend_gathering.submit();
		
	}//End of main if
}

function validChristmas()
{
	if(getVal())
	{
		if(document.christmas.christmas_no_of_person.value == "")
		{
			alert("Please Specify the number of person will be in the Event");
			return false;
		}
		else if(!document.getElementById('christmas_spec_dec_yes').checked && !document.getElementById('christmas_spec_dec_no').checked){
			alert("Please check one about special decoration");
			return false;
		}
		else if(document.getElementById('christmas_spec_dec_yes').checked && (document.christmas.christmas_decoration_style.value.length < 1))
		{
			alert("Please specify your thought of decoration");
			document.christmas.christmas_decoration_style.focus();
			return false;
			
		}
		else if(!document.getElementById('christmas_chil_tbl_yes').checked && !document.getElementById('christmas_chil_tbl_no').checked){
			alert("Please check whether you need the table for children or not");
			return false;
		}
		else if(document.getElementById('christmas_chil_tbl_yes').checked && (document.christmas.christmas_children_no.value == "")){
			alert("Please specify the number of childrens");
			return false;
		}
		
		else if(!document.getElementById('christmas_chil_gift_yes').checked && !document.getElementById('christmas_chil_gift_no').checked){
			alert("Please check whether you need to provide suprise gift for your children");
			return false;
		}
		
		else if(document.getElementById('christmas_chil_gift_yes').checked && (document.christmas.christmas_children_sup_gift.value == "")){
			alert("Please specify the suprise gift for childrens");
			return false;
		}		
		else if(!document.getElementById('christmas_welcome_yes').checked && !document.getElementById('christmas_welcome_no').checked){
			alert("Please Specify whether your team needs welcome by refershment drink");
			return false;
		}
		else if(document.getElementById('christmas_welcome_yes').checked && (document.christmas.christmas_menu_desc.value == "")){
			alert("Please specify the welcome menu list");
			return false;
		}
		else
		document.christmas.submit();
		
	}//End of main if
}

function validCompanyEvent()
{
	if(getVal())
	{
		if((document.event_company.res_from.value == "") || (document.event_company.res_time_from.value == "")){
			alert("Please Select Time of Reservation !!! Some Fields are Missing !!!");
			return false;
		}
		/*
		else if(!doDateCheck(document.event_company.res_from, document.event_company.res_to)){
			alert("Please check from and to date !!!");
			return false;
		}
		*/
		else if(document.event_company.comp_no_of_person.value == "")
		{
			alert("Please Specify the number of person will be in the Event");
			return false;
		}
		else if(!document.getElementById('comp_spec_dec_yes').checked && !document.getElementById('comp_spec_dec_no').checked){
			alert("Please check one about special decoration");
			return false;
		}
		else if(document.getElementById('comp_spec_dec_yes').checked && (document.event_company.comp_decoration_style.value.length < 1))
		{
			alert("Please specify your thought of decoration");
			document.event_company.comp_decoration_style.focus();
			return false;
			
		}
					
		else if(!document.getElementById('comp_welcome_yes').checked && !document.getElementById('comp_welcome_no').checked){
			alert("Please Specify whether your team needs welcome by refershment drink.");
			return false;
		}
		else if(document.getElementById('comp_welcome_yes').checked && (document.event_company.comp_menu_desc.value == "")){
			alert("Please specify the welcome menu list");
			return false;
		}
		else
		document.event_company.submit();	
	}//End of main if
}

function validOtherEvents()
{
	if(getVal())
	{
		if(document.event_other.other_event_name.value == ""){
			alert("Please specify the event for which you are booking the hotel");
			document.event_other.other_event_name.focus();
			return false;
		}
		
		else if((document.event_other.res_from.value == "")|| (document.event_other.res_time_from.value == "")){
			alert("Please Select Time of Reservation !!! Some Fields are Missing !!!");
			return false;
		}
		/*
		else if(!doDateCheck(document.event_other.other_from, document.event_other.other_to)){
			alert("Please check from and to date !!!");
			return false;
		}
		*/
		else if(document.event_other.other_no_of_person.value == "")
		{
			alert("Please Specify the number of person will be in the Event");
			return false;
		}
		else if(!document.getElementById('other_spec_dec_yes').checked && !document.getElementById('other_spec_dec_no').checked){
			alert("Please check one about special decoration");
			return false;
		}
		else if(document.getElementById('other_spec_dec_yes').checked && (document.event_other.other_decoration_style.value.length < 1))
		{
			alert("Please specify your thought of decoration");
			document.event_other.other_decoration_style.focus();
			return false;
			
		}
					
		else if(!document.getElementById('other_welcome_yes').checked && !document.getElementById('other_welcome_no').checked){
			alert("Please Specify whether your team needs welcome by refershment drink.");
			return false;
		}
		else if(document.getElementById('other_welcome_yes').checked && (document.event_other.other_menu_desc.value == "")){
			alert("Please specify the welcome menu list");
			return false;
		}
		else
		document.event_other.submit();	
	}//End of main if
}


function getVal()
{
//document.write ("asdasdasd" + jpt);
//var jpt = document.getElementById('1n').value;
if((document.getElementById('1n').value == "") || (document.getElementById('2n').value == "") || (document.getElementById('3n').value == "") || (document.getElementById('4n').value == "")){
	alert("Please Provide the Required Information !!!");
	document.getElementById('1n').focus();
	return false;
}
else if(isNaN(document.getElementById('3n').value)){
	alert("Contact number shoulld be all number");
	document.getElementById('3n').focus();
	return false;
}
else if(!checkMail(document.getElementById('4n').value)){
	document.getElementById('4n').focus();
	return false;
}
else{
document.bday.hid1.value = document.getElementById('1n').value;
document.bday.hid2.value = document.getElementById('2n').value;
document.bday.hid3.value = document.getElementById('3n').value;
document.bday.hid4.value = document.getElementById('4n').value;

document.family_gathering.hid1.value = document.getElementById('1n').value;
document.family_gathering.hid2.value = document.getElementById('2n').value;
document.family_gathering.hid3.value = document.getElementById('3n').value;
document.family_gathering.hid4.value = document.getElementById('4n').value;

document.friend_gathering.hid1.value = document.getElementById('1n').value;
document.friend_gathering.hid2.value = document.getElementById('2n').value;
document.friend_gathering.hid3.value = document.getElementById('3n').value;
document.friend_gathering.hid4.value = document.getElementById('4n').value;

document.christmas.hid1.value = document.getElementById('1n').value;
document.christmas.hid2.value = document.getElementById('2n').value;
document.christmas.hid3.value = document.getElementById('3n').value;
document.christmas.hid4.value = document.getElementById('4n').value;

document.event_company.hid1.value = document.getElementById('1n').value;
document.event_company.hid2.value = document.getElementById('2n').value;
document.event_company.hid3.value = document.getElementById('3n').value;
document.event_company.hid4.value = document.getElementById('4n').value;

document.event_other.hid1.value = document.getElementById('1n').value;
document.event_other.hid2.value = document.getElementById('2n').value;
document.event_other.hid3.value = document.getElementById('3n').value;
document.event_other.hid4.value = document.getElementById('4n').value;
return true;
}
}


function doDateCheck(from, to) {
	if (Date.parse(from.value) <= Date.parse(to.value))
		return false;
	else
		return true;
}


function checkdate(objName) {
var datefield = objName;
if (chkdate(objName) == false) {
datefield.select();
alert("That date is invalid.  Please try again.");
datefield.focus();
return false;
}
else {
return true;
   }
}


function chkdate(objName) {
var strDatestyle = "US"; //United States date style
//var strDatestyle = "EU";  //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "Jan";
strMonthArray[1] = "Feb";
strMonthArray[2] = "Mar";
strMonthArray[3] = "Apr";
strMonthArray[4] = "May";
strMonthArray[5] = "Jun";
strMonthArray[6] = "Jul";
strMonthArray[7] = "Aug";
strMonthArray[8] = "Sep";
strMonthArray[9] = "Oct";
strMonthArray[10] = "Nov";
strMonthArray[11] = "Dec";
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
if (strDate.length>5) {
strDay = strDate.substr(0, 2);
strMonth = strDate.substr(2, 2);
strYear = strDate.substr(4);
   }
}
if (strYear.length == 2) {
strYear = '20' + strYear;
}
// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = parseInt(strDay, 10);
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}
if (strDatestyle == "US") {
datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
datefield.value = intday + " " + strMonthArray[intMonth-1] + " " + strYear;
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

function checkMail(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
		}

		else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		else if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		else if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 else if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		else return true;	
}

