var gDoc;
var gFrm;

var errorMess;
var intMaxRows;
intMaxRows=5000;//disable maxrows runction





<!--

function checkdate(objName) {
	var datefield = objName;
	if (chkdate(objName) == false) {
		datefield.select();
		alert(TranslateAFLT_That_date_is_invalid);
		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 = addZero(intday,2) + "/" + addZero(intMonth,2) + "/" + addZero(strYear,4);
	}
	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 addZero(intValue,numZero) {
	var i=intValue.toString();
	for (var n=i.length;n<numZero;++n){
		i = "0" + i;
	}
	intValue = i;
	return intValue;
}

function IsValidTime(timeObj) {
//	Checks if time is in HH:MM:SS AM/PM format.
//	The seconds and AM/PM are optional.

	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
	var timeStr = timeObj.value
	var matchArray = timeStr.match(timePat);
	if (matchArray == null) {
		alert("Time is not in a valid format.");
		return false;
	}
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];

	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }

	if (hour < 0  || hour > 23) {
		alert("Hour must be between 0 and 23");
		return false;
	}

	if (minute<0 || minute > 59) {
		alert ("Minute must be between 0 and 59.");
		return false;
	}
	if (second != null && (second < 0 || second > 59)) {
		alert ("Second must be between 0 and 59.");
		return false;
	}
	timeObj.value = addZero(hour,2) + ":" + addZero(minute,2)
	return true;
}

function checkTime(timeObj){
	if (timeObj.value != ""){
		if (!(IsValidTime(timeObj))){
			timeObj.select();
			timeObj.focus();
			return false
		}
	}
}

function dateDiff(dateVal1, dateVal2){
	var inDate1
	var inDate2

	date1 = new Date();
	date2 = new Date();
	diff  = new Date();

	inDate1 = (dateVal1.substring(3,5) + "/" + dateVal1.substring(0,2) + "/" + dateVal1.substring(6,10))
	inDate2 = (dateVal2.substring(3,5) + "/" + dateVal2.substring(0,2) + "/" + dateVal2.substring(6,10))

	date1temp = new Date(inDate1);
	date1.setTime(date1temp.getTime());

	date2temp = new Date(inDate2);
	date2.setTime(date2temp.getTime());

	// sets difference date to difference of first date and second date

	diff.setTime((date1.getTime() - date2.getTime()));

	timediff = diff.getTime();

	days = Math.floor(timediff / (1000 * 60 * 60 * 24)); 

	return days; // form should never submit, returns false
}

function addDate(dateVal, numDays){
	var inDate1
	var inDate2

	date1 = new Date();
	date2 = new Date();
	diff  = new Date();

	inDate1 = (dateVal.substring(3,5) + "/" + dateVal.substring(0,2) + "/" + dateVal.substring(6,10))

	date1temp = new Date(inDate1);
	date1.setTime(date1temp.getTime());

	date2.setTime(numDays * (1000 * 60 * 60 * 24));

	// sets difference date to difference of first date and second date

	diff.setTime((date1.getTime() + date2.getTime()));

	inDate2 = addZero(diff.getDate(),2) + "/";
	inDate2 = inDate2 + addZero((diff.getMonth() + 1),2) + "/";
	inDate2 = inDate2 + addZero(diff.getFullYear(),4);

	return inDate2; // returns Date
}


//-->






function selDepGenericPort_OnChange()
{
var i;
var dest;
var dep;
var strGenericDepPortSelected 
var strGenericDepPortSelected

//arr[Dep]/[Dest]GenericPorts arrays contain a one for one list of the possible port-port combinations, sorted by dep,dest.

	
	
	//pop the dest dropdown with entries relevant to the Dep dropdown.
	dest=gFrm.selDestGenericPort;
	dep=gFrm.selDepGenericPort;
	
	if (dest.selectedIndex==-1)
	{
		dest.options[0].selected=true;
	}
	
	
	if (dep.selectedIndex!=0)
		strGenericDepPortSelected=dep.options[dep.selectedIndex].text;
	else
		strGenericDepPortSelected="";
	
	if (dest.selectedIndex!=0)
		strGenericDestPortSelected=dest.options[dest.selectedIndex].text;
	else
		strGenericDestPortSelected="";
		
	//destroy dest.
	dest.length=0;

	dest.length++;
	dest.options[dest.length-1].text = TranslateAFLT_Select_arrival_airport
	dest.options[dest.length-1].value=0
	
	//if we have a dep value, build the dest accordingly
	if (strGenericDepPortSelected!="")
	{
		for (i=0;i<dp.length;i++)
		{
			if (dp[i]==strGenericDepPortSelected)	
			{
				// add a new entry to dest - it will be empty
				dest.length++;
				dest.options[dest.length-1].text=ds[i];
				dest.options[dest.length-1].value=ds[i];
				
				if (strGenericDestPortSelected==ds[i])
				{// retain previous value if possible.
					dest.options[dest.length-1].selected=true;
				}
			}
		}
	}
}

function onClickProceed()
// Charter Book
{
		
	var i;
	var c;
	c=-1;

	if (cgbIsIE) 
	{
		for (i=0;i<=document.all("radSelect").length-1;i++)
		{
			if (document.all("radSelect")[i].checked)
				c=i;
		}
		c=c-1;//we have a hidden radSelect to help indexing.
	}
	else
	{
	
		var l;
		var b;
		b=0;
		
		l=document.getElementsByTagName("INPUT").length;
		var sName;
		for (i=0;i<=l-1;i++)
		{
			sName=document.getElementsByTagName("INPUT").item(i).name;
		
			if (sName=="radSelect")
				{
					if (document.getElementsByTagName("INPUT").item(i).checked)
						{
							c=b;	
							
						}
						b++;
				}
		}
		c=c-1;
	}
		
	if (c!=-2)
		{
		
		var strForm;
		strForm="frmBook" + c;
		document[strForm].submit();
		//alert(document[strForm].hidRoute1.value);
		}
	else
	{
		alert(TranslateAFLT_Please_select_flight);
	}
		
}
	
function btnBookOnClick()
//Singles Book
{
	// establish which radio buttons have been clicked,
	// and populate the values in frmBookSingles accordingly
	
	
	//input will be 
	// out and ret
	// frmBookSingles0 - dummy
	// frmBookSingles1 radoutbound1 hidroute1... hidroute2...
	// frmBookSingles2 radoutbound1 hidroute1... hidroute2...
	// frmBookSingles2 radinbound1 hidroute1... hidroute2...
	
	// out only
	// frmBookSingles0 - dummy
	// frmBookSingles1 radoutbound1 hidroute1... hidroute2...
	
	// ret only
	// frmBookSingles0 - dummy
	// frmBookSingles1 radinbound1 hidroute1... hidroute2...
	

	
	/*
		var l;
		var cc;
		l=document.getElementsByTagName("INPUT").length;
		cc=0;
		var sName;
		for (i=0;i<=l-1;i++)
		{
			sName=document.getElementsByTagName("INPUT").item(i).name;
			//if (sName.search("selPerm")!=-1)
			if (sName=="radInbound")
				cc++;	
			//{
			//	document.selDetail(sName).style.visibility='hidden'
				//alert(sName);
			//}
		}
		//alert(cc);
	*/
		
	/////////////////////////////////////////////////////////////////////
	 
	var s;
	var out;
	var ret;
	var i;
	var b;
	
	var errorMess;
	
	errorMess = validateformBook();
	
	if (errorMess!="")
	{
		alert(errorMess)
		return false;
	}
	
	
	if (cgbIsIE)
	{
		b=0;
		out=-1;
		if (document.all("radOutbound"))
		{
			s=document.all("radOutbound")
			
			//alert("--" + s.length);
			for (i=0;i<s.length;i++)
			{
				if (s[i].checked==true)
				{
					out=b+1;//remember we have one hidden rad to help indexing
					
				}
				b++;
			}
			out=out-1;
		}
	
		if (out<0) b++; // skip the hidden radinbound+frmBookSingles
	
		ret=-1;
		if (document.all("radInbound"))
		{
			
			s=document.all("radInbound")
			//alert("--" + s.length);
			for (i=0;i<s.length;i++)
			{
				if (s[i].checked==true)
					ret=b-1;//remember we have one hidden rad  to help indexing
				b++;
			}
		}
	}
	else
	{
		//Netscape NSCX
		var sName;
		var bFound;
		
		b=0;
		out=-1;
		bFound=false;
		var l;
		l=document.getElementsByTagName("INPUT").length;
		for (i=0;i<=l-1;i++)
		{
			sName=document.getElementsByTagName("INPUT").item(i).name;
			
			if (sName=="radOutbound")
			{
				bFound=true;
				if (document.getElementsByTagName("INPUT").item(i).checked==true)
				{
					out=b+1;//remember we have one hidden rad to help indexing
					
				}
				b++;
			}
		}
		
		if (bFound)
			out=out-1;
			
		if (out<0) b++; // skip the hidden radinbound+frmBookSingles
		
		bFound=false;
		ret=-1;
		
		l=document.getElementsByTagName("INPUT").length;
		for (i=0;i<=l-1;i++)
		{
			sName=document.getElementsByTagName("INPUT").item(i).name;
			
			if (sName=="radInbound")
			{
				if (document.getElementsByTagName("INPUT").item(i).checked==true)
					ret=b-1;//remember we have one hidden rad to help indexing
				b++;
			}
		}
		
		
	}
	
	//alert (document[st].hidRoute1.value);
	var strOutForm;
	var strRetForm;
	
	//remember we have one hidden frmBookSingles0 to help indexing.
	strOutForm="frmBookSingles" + out;
	strRetForm="frmBookSingles" + ret;

	if ((ret>=0) && (out>=0)) 
	{
		document.frmBookSingles.hidCost.value=Math.abs(document[strOutForm].hidCost.value) + Math.abs(document[strRetForm].hidCost.value);
		
		document.frmBookSingles.hidRoute1.value=document[strOutForm].hidRoute1.value;
		document.frmBookSingles.hidCompany1.value=document[strOutForm].hidCompany1.value;
	
		document.frmBookSingles.hidRoute1Year.value=document[strOutForm].hidRoute1Year.value;
		document.frmBookSingles.hidRoute1Month.value=document[strOutForm].hidRoute1Month.value;
		document.frmBookSingles.hidRoute1Day.value=document[strOutForm].hidRoute1Day.value;
		document.frmBookSingles.hidRoute1Time.value=document[strOutForm].hidRoute1Time.value;
		document.frmBookSingles.hidItinRef1.value=document[strOutForm].hidItinRef1.value;
		document.frmBookSingles.hidFlightNum1.value=document[strOutForm].hidFlightNum1.value;
		
		document.frmBookSingles.hidQuotePageRef1.value=document[strOutForm].hidQuotePageRef1.value;
		document.frmBookSingles.hidBookPageRef1.value=document[strOutForm].hidBookPageRef1.value;
		
		
		document.frmBookSingles.hidDepPort1.value=document[strOutForm].hidDepPort1.value;
		document.frmBookSingles.hidDestPort1.value=document[strOutForm].hidDestPort1.value;
		
	
	
		document.frmBookSingles.hidRoute2.value=document[strRetForm].hidRoute1.value;
		document.frmBookSingles.hidCompany2.value=document[strRetForm].hidCompany2.value;
	
		document.frmBookSingles.hidRoute2Year.value=document[strRetForm].hidRoute1Year.value;
		document.frmBookSingles.hidRoute2Month.value=document[strRetForm].hidRoute1Month.value;
		document.frmBookSingles.hidRoute2Day.value=document[strRetForm].hidRoute1Day.value;
		document.frmBookSingles.hidRoute2Time.value=document[strRetForm].hidRoute1Time.value;
		document.frmBookSingles.hidItinRef2.value=document[strRetForm].hidItinRef1.value;
		document.frmBookSingles.hidFlightNum2.value=document[strRetForm].hidFlightNum1.value;
		
		document.frmBookSingles.hidQuotePageRef2.value=document[strRetForm].hidQuotePageRef1.value;
		document.frmBookSingles.hidBookPageRef2.value=document[strRetForm].hidBookPageRef1.value;
		
		document.frmBookSingles.hidDepPort2.value=document[strRetForm].hidDepPort1.value;
		document.frmBookSingles.hidDestPort2.value=document[strRetForm].hidDestPort1.value;
	
		
		var outDay,outMonth,outYear;
		var retDay,retMonth,retYear;
		
		outDay=Math.abs((document[strOutForm].hidRoute1Day.value));
		outMonth=Math.abs((document[strOutForm].hidRoute1Month.value));
		outYear=Math.abs((document[strOutForm].hidRoute1Year.value));
		//alert(document[strOutForm].hidRoute1Time.value);
		
		retDay=Math.abs((document[strRetForm].hidRoute1Day.value));
		retMonth=Math.abs((document[strRetForm].hidRoute1Month.value));
		retYear=Math.abs((document[strRetForm].hidRoute1Year.value));
		//alert(document[strRetForm].hidRoute1Time.value);
				
		var blnIllegalItinerary;
		blnIllegalItinerary=false;
		
		if (retYear<outYear)
			blnIllegalItinerary=true;
			
		if (retYear==outYear)
		{
			if (retMonth<outMonth)
				blnIllegalItinerary=true;
			if (retMonth==outMonth)
			{
				if (retDay<=outDay)
					blnIllegalItinerary=true;
			}
		}
		
		if (blnIllegalItinerary)
		{
			alert(TranslateAFLT_Return_date_one_day_after);
			return false;
		}
		
		
	}
	if ((out>=0) && (ret<0)) 
	{
	
		document.frmBookSingles.hidCost.value=Math.abs(document[strOutForm].hidCost.value);
		
		document.frmBookSingles.hidRoute1.value=document[strOutForm].hidRoute1.value;
		document.frmBookSingles.hidCompany1.value=document[strOutForm].hidCompany1.value;
	
		document.frmBookSingles.hidRoute1Year.value=document[strOutForm].hidRoute1Year.value;
		document.frmBookSingles.hidRoute1Month.value=document[strOutForm].hidRoute1Month.value;
		document.frmBookSingles.hidRoute1Day.value=document[strOutForm].hidRoute1Day.value;
		document.frmBookSingles.hidRoute1Time.value=document[strOutForm].hidRoute1Time.value;
		document.frmBookSingles.hidItinRef1.value=document[strOutForm].hidItinRef1.value;
		document.frmBookSingles.hidFlightNum1.value=document[strOutForm].hidFlightNum1.value;
		
		document.frmBookSingles.hidQuotePageRef1.value=document[strOutForm].hidQuotePageRef1.value;
		document.frmBookSingles.hidBookPageRef1.value=document[strOutForm].hidBookPageRef1.value;
		
		
		document.frmBookSingles.hidDepPort1.value=document[strOutForm].hidDepPort1.value;
		document.frmBookSingles.hidDestPort1.value=document[strOutForm].hidDestPort1.value;
	
		document.frmBookSingles.hidRoute2.value="";
	
		document.frmBookSingles.hidRoute2Year.value="";
		document.frmBookSingles.hidRoute2Month.value="";
		document.frmBookSingles.hidRoute2Day.value="";
		document.frmBookSingles.hidRoute2Time.value="";
		document.frmBookSingles.hidItinRef2.value="";
		document.frmBookSingles.hidFlightNum2.value="";
		document.frmBookSingles.hidQuotePageRef2.value="";
		document.frmBookSingles.hidBookPageRef2.value="";
		
		
		document.frmBookSingles.hidDepPort2.value="";
		document.frmBookSingles.hidDestPort2.value="";
	
	}
	
	if ((out<0) && (ret>=0)) 
	{
		document.frmBookSingles.hidCost.value=Math.abs(document[strRetForm].hidCost.value);
		
		document.frmBookSingles.hidRoute1.value=document[strRetForm].hidRoute1.value;
		document.frmBookSingles.hidCompany1.value=document[strRetForm].hidCompany1.value;
	
		document.frmBookSingles.hidRoute1Year.value=document[strRetForm].hidRoute1Year.value;
		document.frmBookSingles.hidRoute1Month.value=document[strRetForm].hidRoute1Month.value;
		document.frmBookSingles.hidRoute1Day.value=document[strRetForm].hidRoute1Day.value;
		document.frmBookSingles.hidRoute1Time.value=document[strRetForm].hidRoute1Time.value;
		document.frmBookSingles.hidItinRef1.value=document[strRetForm].hidItinRef1.value;
		document.frmBookSingles.hidFlightNum1.value=document[strRetForm].hidFlightNum1.value;
		
		document.frmBookSingles.hidQuotePageRef1.value=document[strRetForm].hidQuotePageRef1.value;
		document.frmBookSingles.hidBookPageRef1.value=document[strRetForm].hidBookPageRef1.value;
	
		
		document.frmBookSingles.hidDepPort1.value=document[strRetForm].hidDepPort1.value;
		document.frmBookSingles.hidDestPort1.value=document[strRetForm].hidDestPort1.value;

	
		document.frmBookSingles.hidRoute2.value="";
	
		document.frmBookSingles.hidRoute2Year.value="";
		document.frmBookSingles.hidRoute2Month.value="";
		document.frmBookSingles.hidRoute2Day.value="";
		document.frmBookSingles.hidRoute2Time.value="";
		document.frmBookSingles.hidItinRef2.value="";
		document.frmBookSingles.hidFlightNum2.value="";
		
		document.frmBookSingles.hidQuotePageRef2.value="";
		document.frmBookSingles.hidBookPageRef2.value="";
				
		document.frmBookSingles.hidDepPort2.value="";
		document.frmBookSingles.hidDestPort2.value="";
	}	

	//alert(document.frmBookSingles.hidRoute1.value);
    warnIfSingleSelectedAfterReturnQuery();

	document.frmBookSingles.submit();

}


function warnIfSingleSelectedAfterReturnQuery()
{
    if (document.frmForm.hidSingleOrReturn.value == "Return") {

        if (document.frmBookSingles.hidDepPort2.value == "") {
            alert("note: only a single leg of the searched for return trip\nhas been selected");
        }
    }
}


function setDuration()
{
	
}

function btnproceedP1_onClick(btnVal){
var bInsRead;

    UpdateMonthYearFields();
	
	errorMess = validateformSearch();

	if (errorMess!="")
	{
		alert(errorMess)
		return false;
	}
	
	gFrm.hidRowCount.value = 0
	gFrm.submit()
		
}		


function UpdateMonthYearFields()
{
    var form = document.frmForm

    var arrOut = form.selOutMonthYear.value.split("~")
    var arrRet = form.selRetMonthYear.value.split("~")

    form.selOutMonth.value = arrOut[0]
    form.selOutYear.value = arrOut[1]
    form.selRetMonth.value = arrRet[0]
    form.selRetYear.value = arrRet[1]
}


function validateformSearch()
{
var blnRequestIsOneWay;

	errorMess="";
	
	blnRequestIsOneWay = (gFrm.SelSingRet(1).checked==true);
		
	if (gFrm.selDepGenericPort)
	{
		
		if (document.frmForm.selDestGenericPort.selectedIndex==0)
			errorMess=TranslateAFLT_Please_supply_a_destination;
			
		if (document.frmForm.selDepGenericPort.selectedIndex==0)
			errorMess=TranslateAFLT_Please_supply_a_departure;
	}	
	
	if (gFrm.route)
	{
		
		if (document.frmForm.route.selectedIndex==0)
			errorMess=TranslateAFLT_Please_supply_a_destination;
			
		if (document.frmForm.route.selectedIndex==0)
			errorMess=TranslateAFLT_Please_supply_a_departure;
	}
	
	//validate dates

	var v=new Date();
	var currentDate=addLZero(String(v.getDate()),2) + "/" + addLZero(String(v.getMonth()+1),2) + "/" + v.getYear();
	
	
	var OutDay=document.frmForm.selOutDay.options[document.frmForm.selOutDay.options.selectedIndex].value;
	var OutMonth=document.frmForm.selOutMonth.value;
	var OutYear=document.frmForm.selOutYear.value;
	var OutDate=addLZero(OutDay,2) + "/" + addLZero(OutMonth,2) + "/" + OutYear;
	
	
	var RetDay=document.frmForm.selRetDay.options[document.frmForm.selRetDay.options.selectedIndex].value;
	var RetMonth=document.frmForm.selRetMonth.value;
	var RetYear=document.frmForm.selRetYear.value;
	var RetDate=addLZero(RetDay,2) + "/" + addLZero(RetMonth,2) + "/" + RetYear;
	
	if (dateDiff(OutDate,currentDate)<=0)
	{
		errorMess=TranslateAFLT_Departure_date_must_be_at_least_tomorrow;
	}
	
	if (!blnRequestIsOneWay)
	{
		if (dateDiff(RetDate,OutDate)<0)
		{
			errorMess=TranslateAFLT_Return_date_cannot_be_before_departure_date;
		}
	}
		
	// validate number of passengers.
	//var intNumAdu=document.frmForm.selNumAdu.options[document.frmForm.selNumAdu.options.selectedIndex].value;
	
	//var intNumChi=document.frmForm.selNumChi.options[document.frmForm.selNumChi.options.selectedIndex].value;
	//var intNumInf=document.frmForm.selNumInf.options[document.frmForm.selNumInf.options.selectedIndex].value;
	
	var intnS17=document.frmForm.S17.options[document.frmForm.S17.options.selectedIndex].value;
	var intnS16=document.frmForm.S16.options[document.frmForm.S16.options.selectedIndex].value;

	intnS17=Math.abs(intnS17);
	intnS16=Math.abs(intnS16);
	
	if (intnS17 + intnS16==0)
		errorMess=TranslateAFLT_Please_select_number_of_passengers;
		
	if ((intnS17 + intnS16  ) > 9)
		errorMess=TranslateAFLT_No_more_than_9_passengers_can_travel;
		
	var tmpErrorMess="";
	tmpErrorMess=checkPaxAges(intnS16,intnS17);
	
	if (tmpErrorMess!="")
		errorMess=tmpErrorMess;
	
	return errorMess;
	
}

function checkPaxAges(pintnS16,pintnS17)
{
	var l;
	var i;
	
	//Check all child ages have been entered.
	l=document.frmForm.selPaxLX.length;
	for (i=1;i<l;i++)
	{
		var ageSelect = document.frmForm.selPaxLX[i]
		var childAge = ageSelect.options[ageSelect.options.selectedIndex].value;
		
		if (ageSelect.style.visibility != 'hidden' & childAge == -1)
			return TranslateAFLT_Please_enter_ages_of_passengers_16_or_under;
	}

	//check all infants are accompanied by an adult.
	var ic;
	ic=0;
	for (i=1;i<l;i++)
	{
		var ageSelect = document.frmForm.selPaxLX[i]
		var childAge = ageSelect.options[ageSelect.options.selectedIndex].value;

		if (ageSelect.style.visibility != 'hidden' & childAge >= 0  & childAge < 2)
			ic++;
	}
	if (ic>pintnS17)
		return TranslateAFLT_Each_infant_must_be_accompanied_by_one_adult;
		 
	return "";
	
}


function addLZero(strIn,numZero){
    var strOut
    var i 
    var k
	i = strIn.length
	for (var k=i; k<numZero; ++k){
      strIn = "0" + strIn
      i = i + 1
	}
    strOut = strIn
    return (strOut)
}



function validateformBook()
{
	
	var s;
	var i;
	var bChecked
	var bFound;
	
	
	errorMess="";
	
	bChecked=false;
	bFound=false;
	
	if (cgbIsIE)
	{
		if (document.all("radInbound"))
		{
			s=document.all("radInbound");
			if (s.length>1)
			{
				// more than one radio button
				for (i=0;i<s.length;i++)
				{
					if (s[i].checked==true)
						bChecked=true;
				}
				if (bChecked==false)
					errorMess=TranslateAFLT_Please_choose_an_inbound_journey;
			}
		}
	}
	else
	{
		for (i=0;i<=document.getElementsByTagName("INPUT").length-1;i++)
		{
			if (document.getElementsByTagName("INPUT").item(i).name=="radInbound")
			{
				bFound=true;
				if (document.getElementsByTagName("INPUT").item(i).checked==true)
					bChecked=true;
			}
		}
		if (bFound && bChecked==false)
			errorMess=TranslateAFLT_Please_choose_an_inbound_journey;
	}	
			
	bChecked=false;
	bFound=false;
	
	if (cgbIsIE)
	{
		if (document.all("radOutbound"))
		{
			s=document.all("radOutbound");
			if (s.length>1)
			{
				// more than one radio button
				for (i=0;i<s.length;i++)
				{
					if (s[i].checked==true)
						bChecked=true;
				}
				if (bChecked==false)
					errorMess=TranslateAFLT_Please_choose_an_outbound_journey;
			}
			/*
			else
			{
				// only one radio button
				if (s.checked==false)
					errorMess="Please choose an outbound journey";
			}
			*/
			
		}
	}
	else
	{
		for (i=0;i<=document.getElementsByTagName("INPUT").length-1;i++)
		{
			if (document.getElementsByTagName("INPUT").item(i).name=="radOutbound")
			{
				bFound=true;
				if (document.getElementsByTagName("INPUT").item(i).checked==true)
					bChecked=true;
			}
		}
		if (bFound && bChecked==false)
			errorMess=TranslateAFLT_Please_choose_an_outbound_journey;

	}
				
	return errorMess;
	
}

function rI(pthis)
{
	var s;
	s=document.all("radInbound");
	for (i=0;i<s.length;i++)
	{
		if (pthis!=s[i])
			s[i].checked=false;
	}
}

function rO(pthis)
{

	var s;
	s=document.all("radOutbound");
	for (i=0;i<s.length;i++)
	{
		if (pthis!=s[i])
			s[i].checked=false;
	}
}


function longPortOLD(pthis)
{
	var s = pthis.value.split(',')
	document.all.SelDepPort.value = ''
	document.all.SelDestPort.value = ''
	document.all.SelDepName.value = ''
	document.all.SelDestName.value = ''
	for (var i=0;i<s.length;i++)
	{
		if (document.all.SelDepPort.value == '') 
		{
			document.all.SelDepPort.value  = decodePort(s[i].substr(0,2))
			document.all.SelDestPort.value = decodePort(s[i].substr(2,2))
			document.all.SelDepName.value  = decodeName(s[i].substr(0,2))
			document.all.SelDestName.value = decodeName(s[i].substr(2,2))
		}
		else
		{
			document.all.SelDepPort.value  = document.all.SelDepPort.value + ',' + decodePort(s[i].substr(0,2))
			document.all.SelDestPort.value = document.all.SelDestPort.value + ',' + decodePort(s[i].substr(2,2))
			document.all.SelDepName.value  = document.all.SelDepName.value + ',' + decodeName(s[i].substr(0,2))
			document.all.SelDestName.value = document.all.SelDestName.value + ',' + decodeName(s[i].substr(2,2))
		}
	}
}
function decodePort(port)
{		
		switch (port)
		{
		case 'DO' : return 'DOVE';
					break;
		case 'NE' : return 'NEWH';
					break;
		case 'CA' : return 'CALA';
					break;
		case 'DU' : return 'DUNK';
					break;
		case 'DI' : return 'DIEP';
					break;
		case 'PL' : return 'PLYM';
					break;
		case 'RC' : return 'RCOF'
					break;
		case 'FO' : return 'FOLK'
					break;
		case 'SA' :	return 'SANT'
					break;
		case 'ST' : return 'STMA'
					break;
		case 'PU' : return 'POOL'
					break;
		case 'PE' : return 'PEMB'
					break;
		case 'FI' : return 'FISH'
					break;
		case 'RO' : return 'ROSS'
					break;
		case 'HO' : return 'HOLY'
					break;
		case 'HA' : return 'HARW'
					break;
		case 'HK' : return 'HOOK'
					break;
		case 'CH' : return 'CHER'
					break;
		case 'PO' : return 'PORS'
					break;
		case 'BI' : return 'BILB'
					break;
		case 'CN' : return 'CAEN'
					break;
		case 'LE' : return 'LEHA'
					break;
		case 'DB' : return 'DUBL'
					break;
		case 'SR' : return 'STRA'
					break;
		case 'BE' :	return 'BELF'
					break;
		case 'HU' : return 'HULL'; break;
		case 'RD' : return 'ROTT'; break;
		}
//	alert('SelDepPort : ' + document.all.SelDepPort.value)
//	alert('SelDestPort : ' + document.all.SelDestPort.value)
	
}
function decodeName(port)
{		
		switch (port)
		{
		case 'DO' : return 'Dover';
					break;
		case 'NE' : return 'Newhaven';
					break;
		case 'CA' : return 'Calais';
					break;
		case 'DU' : return 'Dunkerque';
					break;
		case 'DI' : return 'Dieppe';
					break;
		case 'PL' : return 'Plymouth';
					break;
		case 'RC' : return 'Roscoff'
					break;
		case 'FO' : return 'Folkestone'
					break;
		case 'SA' :	return 'Santander'
					break;
		case 'ST' : return 'St Malo'
					break;
		case 'PU' : return 'Poole'
					break;
		case 'PE' : return 'Pembroke'
					break;
		case 'FI' : return 'Fishguard'
					break;
		case 'RO' : return 'Rosslare'
					break;
		case 'HO' : return 'Holyhead'
					break;
		case 'HA' : return 'Harwich'
					break;
		case 'HK' : return 'Hook of Holland'
					break;
		case 'CH' : return 'Cherbourg'
					break;
		case 'PO' : return 'Portsmouth'
					break;
		case 'BI' : return 'Bilbao'
					break;
		case 'CN' : return 'Caen'
					break;
		case 'LE' : return 'Le Havre'
					break;
		case 'DB' : return 'Dublin'
					break;
		case 'SR' : return 'Stranraer'
					break;
		case 'BE' :	return 'Belfast'
					break;
		case 'HU' : return 'Hull'; break;
		case 'RD' : return 'Rotterdam Europoort'; break;
		}
//	alert('SelDepPort : ' + document.all.SelDepPort.value)
//	alert('SelDestPort : ' + document.all.SelDestPort.value)	
}
var caWin
function getChildAges()
{
//	winAll = window.open(t,'AllAvail','width=220,height=100,top=0,left=0,menubar=no,scrollbars=no,resizable')
//	window.open('child-popup.htm','','width=350,height=350,top=100,left=100,menubar=no,scrollbars=yes')
	if (document.all.selNumChi.selectedIndex == 0)
	{
		alert('Please first select number of children in party')
		return false;
	}
	var t = 'childAges.asp?C='+document.all.selNumChi.selectedIndex+'&A='+document.all.childAges.value
//	alert(t)
	caWin = window.open(t,'ChildAges','toolbars=no,scrollbars=yes,location=no,statusbars=no,menubars=no,resizable=0,width=300,height=300')
	
}

function single_return_onclick(pvalue)
{
	if (pvalue == 'Single')
	{
		document.all.selRetDay.disabled = true;
        document.all.selRetMonthYear.disabled = true;
		document.all.selRetAMPM.disabled = true;
	}
	else
	{
		document.all.selRetDay.disabled = false;
        document.all.selRetMonthYear.disabled = false;
		document.all.selRetAMPM.disabled = false;
	}
}

function body_onLoad()
{
	
//	longPort(document.all.route)
	//SelMoT_onChange(document.all.SelMoT)
	
	
	if (cgbIsIE)
		gDoc = document.all;
	else
		gDoc = document;
	gFrm = document.frmForm;
	gbLoaded = true;
	
	if (gFrm.selDepGenericPort)
	{
		if (gFrm.selDepGenericPort.selectedIndex!=0) 
			selDepGenericPort_OnChange();
	}
	
	//alert("Hello!!")
	//alert(document.all("SPX").innerHTML);
	
    if(typeof(document.all.SPX)!="undefined") AgeChangeHandler("LOAD");
    else if(typeof(document.all.ChildAgesBlock)!="undefined") SmallFormAgeChangeHandler("LOAD");


	// disabled return date if single (not return)
	if(gFrm.SelSingRet) {
		// 'SelSingRet(1)' is 'Single'
		if(gFrm.SelSingRet(1).checked) {
			single_return_onclick(gFrm.SelSingRet(1).value)
		}
	}
}

function btnNext_onclick(){
	
	document.frmForm.submit()
}

function SelMoT_onChange(pthis)
{
	
	if ((pthis.value == 'Any') || (pthis.value == 'FOO') || (pthis.value == 'MTC') || (pthis.value == 'COM') || (pthis.value == 'BIC'))
	{
		document.all.SelMoTH.disabled = true
		document.all.SelMoTL.disabled = true
		document.all.SelTrl.disabled = true
	}
	else
	{
		document.all.SelMoTH.disabled = false
		document.all.SelMoTL.disabled = false
		document.all.SelTrl.disabled = false
	}
}
function checkOther(pthis)
{
	
	if (pthis.value == 'G0006R0000')
	{
		alert('Please select one of the available routes')
		pthis.selectedIndex = pthis.selectedIndex + 1
		
		
	}
}
function btnPrev_onclick(){

	strRowCount = document.frmForm.hidRowCount.value
	strLastNum = strRowCount.substring(strRowCount.length,1)
	if (strLastNum == 0) 
	{
		document.frmForm.hidRowCount.value = document.frmForm.hidRowCount.value - intMaxRows;
	}
	else
	{
		document.frmForm.hidRowCount.value = document.frmForm.hidRowCount.value - intMaxRows - strLastNum
	}

	document.frmForm.submit()
}

function onMouseOverHand(evt)
{
	//This function doesnt work yet! - NN doesnt show the hand - TBI.
	//alert(evt.target.tagName);
	evt.target.style.cursor='hand';

}

