// 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["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;
};

//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 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;

}
// -->