// JavaScript Document
<!-- 
if (window != window.top) 
  top.location.href = location.href; 

function promowin(filename)
{
   window.open(filename,"programwindow","scrollbars=yes,menubar=no,resizable=no,width=500,height=400");
}

function promowin2(filename)
{
   window.open(filename,"programwindow","scrollbars=yes,menubar=no,resizable=no,width=605,height=400");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function CheckBookingForm(){

if(document.airSearch.elements["INF"]!=null){
var totPaxNo = parseInt(document.airSearch["ADT"].value) + parseInt(document.airSearch["CHD"].value) + parseInt(document.airSearch["INF"].value);
}
if(document.airSearch.elements["IFS"]!=null){
var totPaxNo = parseInt(document.airSearch["ADT"].value) + parseInt(document.airSearch["CHD"].value) + parseInt(document.airSearch["IFS"].value);
}

if ((document.airSearch["departCity"].value) == "")
{
//alert("Invalid flight. Please select a departure city.")
$('#book-error').html("Invalid flight. Please select a departure city.");
$('#book-error').fadeIn("slow");
return false;
};

if (document.airSearch["returnCity"].value == "")
{
//alert("Invalid flight. Please select an arrival city.")
$('#book-error').html("Invalid flight. Please select an arrival city.");
$('#book-error').fadeIn("slow");
return false;
};

if (document.airSearch["departCity"].value == document.airSearch["returnCity"].value)
{
//alert("Invalid flight. Please select a different arrival city.")
$('#book-error').html("Invalid flight. Please select a different arrival city.");
$('#book-error').fadeIn("slow");
return false;
};

if (document.airSearch["depDay"].value == '' || document.airSearch["depMonth"].value == '')
{
//alert("Please complete your Departure Date.")
$('#book-error').html("Please complete your Departure Date.");
$('#book-error').fadeIn("slow");
return false;
};

if (document.airSearch.direction[0].checked == true && (document.airSearch["retDay"].value == '' || document.airSearch["retMonth"].value == ''))
{
//alert("Please complete your Return Date.")
$('#book-error').html("Please complete your Return Date.");
$('#book-error').fadeIn("slow");
return false;
};

if (document.airSearch.elements["Children"].selectedIndex > 0)
{
	if(document.airSearch["ADT"].value=='0'){
		$('#book-error').html("Invalid combination. Please include an Adult.");
		$('#book-error').fadeIn("slow");
		return false;	
	}
		for (i = 1; i <= document.airSearch["CHD"].value; i++) {
			//if (i <= j("chAge"+i).selectedIndex) {
			if (j("chAge"+i).selectedIndex != 0) {
				/*$("chAge"+i).style.display = "block";
				$("spacerChildDateBirth"+i).style.display = "block";
				} else {
				$("childDOB"+i).style.display = "none";
				$("spacerChildDateBirth"+i).style.display = "none";
				}*/
			}else{
				//alert("test "+i);
				$('#book-error').html("Please complete your Child's age.");
				$('#book-error').fadeIn("slow");
				return false;
			}
		}
};

if(document.airSearch.elements["IFS"]!=null){
if (document.airSearch.elements["IFS"].selectedIndex > 0){
	if(document.airSearch["ADT"].value=='0'){
		$('#book-error').html("Invalid combination. Please include an Adult.");
		$('#book-error').fadeIn("slow");
		return false;	
	}
}
};

if(document.airSearch.elements["INF"]!=null){
if (document.airSearch.elements["INF"].selectedIndex > 0){
	if(document.airSearch["ADT"].value=='0'){
		$('#book-error').html("Invalid combination. Please include an Adult.");
		$('#book-error').fadeIn("slow");
		return false;	
	}
}
};

if (totPaxNo>6){
	$('#book-error').html("Maximum of 6 passengers allowed.");
	$('#book-error').fadeIn("slow");
	return false;	
};


//get the user time
//setUserTime();

return true;

}


function updatedate() {
  var day1 = document.airSearch.elements["depDay"].selectedIndex;
  var month1 = document.airSearch.elements["depMonth"].selectedIndex;
 
  var day2 = document.airSearch.elements["retDay"].selectedIndex;
  var month2 = document.airSearch.elements["retMonth"].selectedIndex;
 

  if ( month1 > month2 ) {
    document.airSearch.elements["retDay"].value = document.airSearch.elements["depDay"].value;
    document.airSearch.elements["retMonth"].value = document.airSearch.elements["depMonth"].value;
  } else if ( (day1 >=  day2) && (month1 == month2) ) {
    document.airSearch.elements["retDay"].value = document.airSearch.elements["depDay"].value;
    document.airSearch.elements["retMonth"].value = document.airSearch.elements["depMonth"].value;
  }
 if ( month1 < month2 ) {
    document.airSearch.elements["retDay"].value = document.airSearch.elements["depDay"].value;
    document.airSearch.elements["retMonth"].value = document.airSearch.elements["depMonth"].value;
  } else if ( (day1 <=  day2) && (month1 == month2) ) {
    document.airSearch.elements["retDay"].value = document.airSearch.elements["depDay"].value;
    document.airSearch.elements["retMonth"].value = document.airSearch.elements["depMonth"].value;
  }
  
  
}

function ShowBooking() {
document.getElementById('booking').style.display = "block";
document.getElementById('checkIn').style.display = "none";
$("#bookingState").removeClass("selected");
$("#checkinState").addClass("selected");
/*document.getElementById('bookingState').style.background = "none";
document.getElementById('bookingState').style.backgroundColor = "#FCC618";
document.getElementById('checkinState').style.backgroundColor = "#FDE15E";*/

}
function ShowCheckIn() {
document.getElementById('checkIn').style.display = "block";
document.getElementById('booking').style.display = "none";
/*document.getElementById('checkinState').style.background = "none";
document.getElementById('checkinState').style.backgroundColor = "#FCC618";
document.getElementById('bookingState').style.backgroundColor = "#FDE15E";
document.getElementById('bookingState').style.color = "#555555";*/
$("#bookingState").addClass("selected");
$("#checkinState").removeClass("selected");
buttonState(true);
}

function checkCheckIn(){
//resetForm();
var firstName = document.getElementById('cFirstName').value;
var lastName = document.getElementById('cLastName').value;
var deptFrom = document.getElementById('cDeptFrom').value;
var flightNo = document.getElementById('cFlightNo').value;
var bookingReff = document.getElementById('cBookingReff').value;
if(lastName == ''){
$('#error').html("Please enter Last Name");
$("#error").fadeIn("slow");
document.getElementById('cLastName').style.borderColor = "#FF0000";
return false;
}else{
document.getElementById('cLastName').style.borderColor = "";
}
if(firstName == ''){
$('#error').html("Please enter First Name");
$("#error").fadeIn("slow");
document.getElementById('cFirstName').style.borderColor = "#FF0000";
return false;
}else{
document.getElementById('cFirstName').style.borderColor = "";
}
if(deptFrom == ''){
$('#error').html("Please enter Departure From");
$("#error").fadeIn("slow");
document.getElementById('cDeptFrom').style.borderColor = "#FF0000";
return false;
}else{
document.getElementById('cDeptFrom').style.borderColor = "";
}

/*
if(bookingReff == ''){
document.getElementById('error').style.display = "block";
document.getElementById('errorMessage').innerHTML = 'Please enter a six-letter Booking Reference(PNR)';
document.getElementById('cBookingReff').style.borderColor = "#FF0000";
return false
}else{
document.getElementById('cFlightNo').style.borderColor = "";
}

if(flightNo == '' && bookingReff == ''){
document.getElementById('error').style.display = "block";
document.getElementById('errorMessage').innerHTML = 'Please enter a six-letter Booking Reference(PNR) OR Flight Number';
document.getElementById('cFlightNo').style.borderColor = "#FF0000";
document.getElementById('cBookingReff').style.borderColor = "#FF0000";
return false
}else{
document.getElementById('cFlightNo').style.borderColor = "";
document.getElementById('cBookingReff').style.borderColor = "";
}*/

if(flightNo == ''){
$('#error').html("Please enter Flight Number");
$("#error").fadeIn("slow");
document.getElementById('cFlightNo').style.borderColor = "#FF0000";
return false
}else{
document.getElementById('cFlightNo').style.borderColor = "";
}

if(firstName == '' || lastName == '' || deptFrom == '' && (flightNo == '' && bookingReff == '')){
return false;
}else{
document.getElementById('checkinForm').style.display = "none";
document.getElementById('loading').style.display = "block";
}
}


       /* function showCouponInputBox(form)  {
            var kk = 0;
            var mm = 0;
            var disindex = 0;
            var totalCouponInputBox = 0; // number of coupon number text box displayed
            var strListName = "";
            var strLabelName = "";
            var elemLabel;
            var minstrdivv;
            var totalPax = 0;
            if (document.airSearch.ADT != null && document.airSearch.ADT != undefined) {
                var numOfAdult=document.airSearch.ADT.options[document.airSearch.ADT.selectedIndex].value;
                totalPax += parseInt(numOfAdult);
            }
            if (document.airSearch.CHD != null && document.airSearch.CHD != undefined) {
                var numOfChild=document.airSearch.CHD.options[document.airSearch.CHD.selectedIndex].value;
                totalPax += parseInt(numOfChild);
            }
            if (document.airSearch.IFS != null && document.airSearch.IFS != undefined) {
                var numOfIfs=document.airSearch.IFS.options[document.airSearch.IFS.selectedIndex].value;
                totalPax += parseInt(numOfIfs);
            }
            if (document.airSearch.YTH != null && document.airSearch.YTH != undefined) {
                var numOfYouth=document.airSearch.YTH.options[document.airSearch.YTH.selectedIndex].value;
                totalPax += parseInt(numOfYouth);
            }
            if (document.airSearch.SCR != null && document.airSearch.SCR != undefined) {
                var numOfSenior=document.airSearch.SCR.options[document.airSearch.SCR.selectedIndex].value;
                totalPax += parseInt(numOfSenior);
            }
            if (document.airSearch.STU != null && document.airSearch.STU != undefined) {
                var numOfStudent=document.airSearch.STU.options[document.airSearch.STU.selectedIndex].value;
                totalPax += parseInt(numOfStudent);
            }
            if (document.airSearch.MIL != null && document.airSearch.MIL != undefined) {
                var numOfMilitary=document.airSearch.MIL.options[document.airSearch.MIL.selectedIndex].value;
                totalPax += parseInt(numOfMilitary);
            }
            if (document.airSearch.UMNR != null && document.airSearch.UMNR != undefined ) {
                var numOfMinors=document.airSearch.UMNR.options[document.airSearch.UMNR.selectedIndex].value;
                totalPax += parseInt(numOfMinors);
            }
            if (document.airSearch.STR != null && document.airSearch.STR != undefined ) {
                var numOfSTR=document.airSearch.STR.options[document.airSearch.STR.selectedIndex].value;
                totalPax += parseInt(numOfSTR);
            }
            if (document.airSearch.EMI != null && document.airSearch.EMI != undefined ) {
                var numOfEMI=document.airSearch.EMI.options[document.airSearch.EMI.selectedIndex].value;
                totalPax += parseInt(numOfEMI);
            }
            if (document.airSearch.DIS != null && document.airSearch.DIS != undefined ) {
                var numOfDIS=document.airSearch.DIS.options[document.airSearch.DIS.selectedIndex].value;
                totalPax += parseInt(numOfDIS);
            }
            //alert(totalPax);
            if(totalPax == 0)
            {
                totalCouponInputBox = 1;
            }
            else if(totalPax > 6)
            {
                totalCouponInputBox = 6;
            }
            else
            {
                totalCouponInputBox = totalPax;
            }

            minstrdivv = document.getElementById("lblCouponInstr");
            minstrdivv.style.display = "";

            //enable coupon Input box controls

            for (kk = 1; kk <= totalCouponInputBox; kk++) {
                strListName = "couponNumber" + kk;
                strLabelName = "lblCouponNumber" + kk;
                form.elements[strListName].disabled = false;
                form.elements[strListName].style.display = "";
                elemLabel = document.getElementById(strLabelName);
                elemLabel.style.display = "";
            }
            if(totalCouponInputBox > 1)
            {
             form.elements["applyToAll"].style.display = "";
             elemLabelApplyToAll = document.getElementById("lblApplyCouponToAll");
             elemLabelApplyToAll.style.display = "";
            }
            else
            {
                form.elements["applyToAll"].style.display = "none";
            }
            //disable Input box controls
            disindex = parseInt(totalCouponInputBox) + 1;
            for (mm = disindex; mm <= maxPassenger; mm++) {
              strListName = "couponNumber" + mm;
              strLabelName = "lblCouponNumber" + mm;
              form.elements[strListName].disabled = true;
              form.elements[strListName].style.display = "none";
              elemLabel = document.getElementById(strLabelName);
              elemLabel.style.display = "none";
            }
            if(totalCouponInputBox == 1)
            {
             elemLabelApplyToAll = document.getElementById("lblApplyCouponToAll");
             elemLabelApplyToAll.style.display = "none";
            }
        }*/
		

function childrenDropdownValueChanged() {
	//alert();
	if (j("Children").selectedIndex === 0) {
		j("childDOBTxt").style.display = "none";
		j("spacerChildDescription").style.display = "none";
		j("spacerInfants").style.display = "none";
		j("infants").style.styleFloat="left";

	} else {
		j("childDOBTxt").style.display = "block";
		//$("infants").style.clear = "left";
		j("spacerInfants").style.display = "block";
		j("spacerChildDescription").style.display = "block";
	}
		for (i = 1; i <= 6; i++) {
			if (i <= j("Children").selectedIndex) {
				j("childDOB"+i).style.display = "block";
				j("spacerChildDateBirth"+i).style.display = "block";
			} else {
				j("childDOB"+i).style.display = "none";
				j("spacerChildDateBirth"+i).style.display = "none";
			}
		}
				j("childDOB").style.display = "block";
}//end function

				
function j(obj) {
try {
return document.getElementById(obj);
} catch (e) {}			
}//end function



function resetForm() {
document.getElementById('errorMessage').innerHTML = '';
document.getElementById('cFirstName').style.borderColor = "";
document.getElementById('cLastName').style.borderColor = "";
document.getElementById('cDeptFrom').style.borderColor = "";
document.getElementById('cFlightNo').style.borderColor = "";
document.getElementById('cBookingReff').style.borderColor = "";
document.getElementById('checkinForm').style.display = "block";
document.getElementById('loading').style.display = "none";
}



function buttonState(state){
document.getElementById('agree').checked = false;
document.getElementById('checkinBtn').disabled = true;
} 
function checkform () {
if (!document.getElementById('agree').checked) {
document.getElementById('checkinBtn').disabled = true;
}
if (document.getElementById('agree').checked) {
document.getElementById('checkinBtn').disabled = false;
}
}

function setUserTime () {
var usertime = new Date();
//usertime.setMinutes(usertime.getMinutes() + 10);
usertime.setHours(usertime.getHours() + 1);
var curHour = usertime.getHours()
var curMin = "0";
//var curMin = usertime.getMinutes();
var curTime = ((curHour < 10) ? "0" : "") + curHour + ((curMin < 10) ? "0" : "") + curMin
document.airSearch.elements["depTime"].value = curTime;
document.airSearch.elements["retTime"].value = curTime;

}
// -->