
function setDate(formName,field,day,month,year)
{
document.forms[""+formName][field].value=day+"/"+month+"/"+year
}
function isValidFlight(formName,obDate,ibDate)
{
var CHD=document.forms[""+formName].CHD.value;
var ADT=document.forms[""+formName].ADT.value;
var INF=document.forms[""+formName].INF.value;
var a=document.forms[""+formName].origin.value;
var d =document.forms[""+formName].destination.value;
var totPax=parseInt(ADT)+parseInt(CHD);
var isvalidD=isDate(obDate)
var isvalidR=isDate(ibDate)
if(!isvalidD || !isvalidR){
return false;
}
var obDate=obDate.split('/');
var ibDate=ibDate.split('/');
var obDay=obDate[0];
var obYear=obDate[2];
var obMonth=(obDate[1]-1)
var ibDay=ibDate[0];
var ibYear=ibDate[2];
var ibMonth=(ibDate[1]-1)
var today=new Date();
var D=today.getDate();if(D<10){D="0"+D;}
var M=today.getMonth();if(M<10){M="0"+M;}
var Y=today.getFullYear();
var objDiff=daysElapsed(new Date(ibYear,ibMonth,ibDay),new Date(obYear,obMonth,obDay));
var objDt=daysElapsed(new Date(obYear,obMonth,obDay),new Date(Y,M,D));
if(objDt<0){
alert("Depart date can't be in past")
return false;
}
if(d==a){
alert("Depart and arrival airport can't be same")
return false;
}
if(totPax>9)
{
alert("You are allowed a maximum of 9 passengers per Flight booking online.\nIf your group is larger than this, please call our call center.")
return false;
}
if(INF>ADT)
{
alert("Total number of infant can't be greater than adult")
return false;
}

if(objDiff<0 && document.forms[""+formName].type[0].checked)
{
alert("Return date must occur after the Depart date.")
return false;
}
else{return true;}
}
function daysElapsed(date1,date2)
{
var difference =
Date.UTC(date1.getYear(),date1.getMonth(),date1.getDate(),0,0,0)
- Date.UTC(date2.getYear(),date2.getMonth(),date2.getDate(),0,0,0);
return  difference=(difference)/(1000*60*60*24);
}
//to check if date is valid or not;
var dtCh= "/";
var minYear=1900;
var maxYear=2100;
function isInteger(s){
var i;
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
return true;
}
function stripCharsInBag(s, bag){
var i;
var returnString = "";
for (i = 0; i < s.length; i++){
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function daysInFebruary (year){
return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}

function showAgeBlock(val){
if(val<1){
window.document.getElementById('hcha1').style.display='none';
window.document.getElementById('hcha2').style.display='none';
window.document.hotelform.age1.value='';
window.document.hotelform.age2.value='';
}
if(val == 1){
window.document.getElementById('hcha1').style.display='block';
window.document.getElementById('hcha2').style.display='none';
window.document.hotelform.age2.value='';
}
if(val == 2){
window.document.getElementById('hcha1').style.display='block';
window.document.getElementById('hcha2').style.display='block';
}
}
function submitForm(){
if(!document.paxDetailForm.tc.checked){
alert('Please check the terms and conditions')
return false;
}else{
return true;
}
}


function BC (id)
{
 var obj = document.getElementById(id);
 return obj;
}

function tabForm(obj)
{
	for (var ctr = 0; ctr < 3; ctr++)
	{
		BC('tab'+ctr).className = 'betab';
		BC('beform'+ctr).style.display = 'none';
	}
	BC(obj).className = 'betabA';
	BC('beform'+obj.substring(3,4)).style.display = 'block';
	document.getElementById('YTContainer').style.display="none";
	
}


