﻿var AutoFocus = new String
var CcValidation  = new String
var CcPreselect  = new String
var CcTotalValue 
var CcCurrency
var CssClass = new Object
var SelectedDate = new Object
var Airports
var isGroupBooking =  new Boolean(false)

var Status = new Boolean(true)
var SingleFlight =  new Boolean(false)
var goToRow 
//var DateValid = 'M/d/y'
//var DateValidText = 'mm/dd/yyyy'
var DateValid = 'd/M/y'
var DateValidText = 'dd/mm/yyyy'

//var pl = 3
var pl = 0
var pt = new Boolean(true)
var ptv = new Boolean(false)

var eMsg = new Array();
eMsg[0]	= 'It is not possible to book more Infants than Adults!';
eMsg[1]	= 'Please check your Return Date! It has to be equal to or higher than the Departure Date.';
eMsg[2]	= 'Please supply a valid Passenger Name.';
eMsg[3]	= 'Please supply a valid date of birth ';
eMsg[4]	= 'Please supply a valid Passenger Name at passenger ';
eMsg[5]	= 'Please supply a valid Date of Birth at passenger ';
eMsg[6]	= 'Please supply a valid Phone Number.';
eMsg[7]	= 'Please supply a valid Email Address.';
eMsg[8]	= 'Please supply a valid Address.';
eMsg[9]	= 'Please accept Terms and Conditions.';
eMsg[10]= 'Please supply a valid Passport Number at passenger ';
eMsg[11]= 'Please supply a valid Issue Place at passenger ';
eMsg[12]= 'Please supply a valid Expiry Date at passenger ';
eMsg[13]= 'Please supply a valid Issue Date at passenger ';
eMsg[14]= 'Please supply a valid Email format';
eMsg[15]= 'Please check your Issue Date! It must be in the past at passenger ';
eMsg[16]= 'Please check your Expiry Date! It must be in the future at passenger ';
eMsg[17]= 'Please check your Date of Birth! It must be in the past at passenger ';
eMsg[18]= 'Please check your Date of Birth! It must be in the past';
//SetAutoFocus()

function dgItem_over(object){
	object.className = (object.className == "GridItems0_o" ? "GridItems0" : "GridItems0_o")
}

function dgItem_click(s){
	if (event.srcElement.tagName != 'A'){
		o = document.getElementById(s)
		o.checked = 'true'
	}
}

function ValidFlightSelection(o){
	//Status =  true;
	//var d = GetSelectFlight('FlightAvailability0',0)
	//if (LibDaysDiff(d,new Date()) < 0 ){
	//	alert('For Flights departing within 4 hours please contact Reservations on 0871 871 0717.')
	//	Status =  false;
	//	return
	//}
	//if (document.getElementById('FlightAvailability1') != null) {
	//	var d = GetSelectFlight('FlightAvailability0',1)
	//	var r = GetSelectFlight('FlightAvailability1',0)
	//	if (r != undefined){
	//		if (LibDaysDiff(r,d) < 0){
	//			alert('Please check your Return Date! It has to be equal to or higher than the Departure Date.')
	//			Status =  false;
	//			return
	//		}
	//	}
	//}	
}

function ShowCvvCode(o){
	//if (document.getElementById(o + '_cbmFormOfPaymentSubtype') != null){

	//	var iA = document.getElementById(o + '_cbmFormOfPaymentSubtype').options[document.getElementById(o + '_cbmFormOfPaymentSubtype').selectedIndex].value.split('|')
	//	if (iA.length > 0 ){
			//document.getElementById('CvvForm').style.visibility = (iA[2] == '1') ?  'visible' : 'hidden' ;
			//document.getElementById('CvvLabel').style.visibility = (iA[2] == '1') ? 'visible' : 'hidden' ;
			//document.getElementById('IssueDateForm').style.visibility = (iA[3] == '1') ?  'visible' : 'hidden' ;
			//document.getElementById('IssueDateLabel').style.visibility = (iA[3] == '1') ? 'visible' : 'hidden' ;
			//document.getElementById('IssueNumberForm').style.visibility = (iA[4] == '1') ?  'visible' : 'hidden' ;
			//document.getElementById('IssueNumberLabel').style.visibility = (iA[4] == '1') ? 'visible' : 'hidden' ;
			//document.getElementById('IssueRow').style.visibility = (iA[3] == '1' || iA[4] == '1') ? 'visible' : 'hidden' ;
	//	}
	//}
}

function isInteger(val){
	if( isNaN( parseFloat(val))) {
		return false;
	} else {
		return parseFloat(val);
	}
}

function fillDestination(e,o){
	var i = 0
	var eD = document.getElementById(e)
	var oD = document.getElementById(o)
	var sOv = eD[eD.selectedIndex].value
	var sDv = oD[oD.selectedIndex].value
	oD.options.length = 0;
	for (ii=0;ii < Airports.length;ii++){
		var at = Airports[ii].split('|')
		if (at[0] == sOv){
			oD.options[i] = new Option(at[2],at[1]);
			i++
		}
	}
	eD.focus()
}

function addFullNumerical(num,bit){
	var str = num.toString();
	if(str.length < parseInt(bit)){
		do
		str = "0" + str;
		while(str.length < parseInt(bit));
	}
	return str;
}

function changeToDate(str){
	var dd
	var mm
	var yy
	switch(DateValidText){
		case "dd/mm/yyyy":
			dd = str.substr(0,2)
			mm = str.substr(3,2)
			yy = str.substr(6,4)
		  return new Date(mm+"/"+dd+"/"+yy)
		  break    
		case "mm/dd/yyyy":
			mm = str.substr(0,2)
			dd = str.substr(3,2)
			yy = str.substr(6,4)
		  return new Date(mm+"/"+dd+"/"+yy)
		  break
		default:		
	}
}

function subStringLeft(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function subStringRight(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var strLen = String(str).length;
       return String(str).substring(strLen, strLen - n);
    }
}