function genericAmadeusDate(myform,d_day_name,last_name) {
	var d_sentence = "document." + myform + "." + d_day_name + ".value";
    d_sentence = last_name;
}
function amadeusDate() {
    now = new Date();
	document.forms[0].D_Day.selectedIndex = now.getDate();
	document.forms[0].D_Month.selectedIndex = now.getMonth();
	
	then = new Date(now.getTime()+(604800000))
	document.forms[0].R_Day.selectedIndex = then.getDate();
	document.forms[0].R_Month.selectedIndex = then.getMonth();
}

function amadeusDate3() {
    now = new Date();
	now3 = new Date(now.getTime()+(259200000))
	document.forms[0].D_Day.selectedIndex = now3.getDate();
	document.forms[0].D_Month.selectedIndex = now3.getMonth();
	
	then = new Date(now.getTime()+(864000000))
	document.forms[0].R_Day.selectedIndex = then.getDate();
	document.forms[0].R_Month.selectedIndex = then.getMonth();

}
function amadeusB_Date() {
    now = new Date();
	document.AirSearch.B_Day.selectedIndex = now.getDate();
	document.AirSearch.B_Month.selectedIndex = now.getMonth();
	document.TimeTableSearch.B_Day.selectedIndex = now.getDate();
	document.TimeTableSearch.B_Month.selectedIndex = now.getMonth();
	}
	

function amadeusDate1() {
    now = new Date();
	document.forms[0].B_DAY.selectedIndex = now.getDate();
	document.forms[0].B_MONTH.selectedIndex = now.getMonth();
	
	then = new Date(now.getTime()+(604800000))
	document.forms[0].E_DAY.selectedIndex = then.getDate();
	document.forms[0].E_MONTH.selectedIndex = then.getMonth();
}
function amadeusDate3adv() {
    now = new Date();
	now3 = new Date(now.getTime()+(259200000))
	document.forms[0].B_DAY.selectedIndex = now3.getDate();
	document.forms[0].B_MONTH.selectedIndex = now3.getMonth();
	
	then = new Date(now.getTime()+(604800000))
	document.forms[0].E_DAY.selectedIndex = then.getDate();
	document.forms[0].E_MONTH.selectedIndex = then.getMonth();
}


function isLeapYear(year){
	if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)){
		return true;
	} else {
	return false;
	}
}
function validMonthDay(dayVal, monthVal, yearVal){

	var error = 0;

	// check for september, april, june, nov entries where day is >30 
	if ((monthVal.substr(4,2) == 4)||(monthVal.substr(4,2) == 6)||(monthVal.substr(4,2) == 9)||(monthVal.substr(4,2) == 11)){
		if (dayVal>30){
			error = 1;
		}
	}
	// check for Feb 28+ entries
	else if (monthVal.substr(4,2) == 2){
				// if leap yr, allow 29 Feb
		 		if (isLeapYear(yearVal)){
				    if (dayVal>29) {
						error = 1;
					}
				// if not leap yr, allow 28 Feb max	
				} else if (dayVal>28){
						error = 1;
				}
	}
	
	if (error == 1){
		return false;
	} else {
		return true;
	}	 	
}

function createDate(day, monthYear) {
	dayVal = day.options[day.selectedIndex].value;
	monthYearVal = monthYear.options[monthYear.selectedIndex].value;
	
	x = dayVal.substr(0,1);
	if (x == "0") {
		day = parseInt(dayVal.substr(1,1));
	} else {
		day = parseInt(dayVal.substr(0,2));
	}
	
	y = monthYearVal.substr(4,1);
	if (y == "0") {
		month = parseInt(monthYearVal.substr(5,1));
	} else {
		month = parseInt(monthYearVal.substr(4,2));
	}
	
	year = parseInt(monthYearVal.substr(0,4));
	if (year < 1900) {
		year = year + 1900;
	}
	date = new Date(year, month-1, day);
	return date; 
}
function validReturnDate(formName, elementArray) {
	//set up field objects for createDate()
	firstDayField = eval('document.' + formName + '.'  + elementArray[0]);
	firstMonthField = eval('document.' + formName + '.'  + elementArray[1]);
	secondDayField = eval('document.' + formName + '.'  + elementArray[2]);
	secondMonthField = eval('document.' + formName + '.'  + elementArray[3]);
	//set up field values for validMonthDay()
	firstDay = eval('document.' + formName + '.'  + elementArray[0] + ".options[" + 'document.' + formName + '.' + elementArray[0] + '.selectedIndex].value');
	firstMonth = eval('document.' + formName + '.'  + elementArray[1] + ".options[" + 'document.' + formName + '.' + elementArray[1] + '.selectedIndex].value');
	firstYear = firstMonth.substr(0,4);
	secondDay = eval('document.' + formName + '.'  + elementArray[2] + ".options[" + 'document.' + formName + '.' + elementArray[2] + '.selectedIndex].value');
	secondMonth = eval('document.' + formName + '.'  + elementArray[3] + ".options[" + 'document.' + formName + '.' + elementArray[3] + '.selectedIndex].value');
	secondYear = secondMonth.substr(0,4);
	//check day of month is valid
	if ((validMonthDay(firstDay, firstMonth, firstYear))&& (validMonthDay(secondDay, secondMonth, secondYear))){
		//check that departure date is before return date			
		createDate(firstDayField, firstMonthField);
		outboundDate = date;
		createDate(secondDayField, secondMonthField);
		returnDate = date;
		if (outboundDate.valueOf() <= returnDate.valueOf() ) {
			return true;
		} else {
			return false;
		}		 
	} else {
	return false;
	}
}
function setfocus()
{
document.forms[0].D_City.focus()
}
function setfocus1()
{
document.forms[0].B_LOCATION.focus()
}
function setfocus2()
{
document.forms[0].B_LOCATION_1.focus()
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function OnewayTrip(){
var lengthMonth = document.forms[0].R_Month.length
var lengthDay = document.forms[0].R_Day.length
var lengthTime = document.forms[0].R_Time.length
if(!(document.forms[0].R_Month.selectedIndex == lengthMonth - 1 && document.forms[0].R_Day.selectedIndex == lengthDay - 1 && document.forms[0].R_Time.selectedIndex == lengthTime - 1)){
return_month_index = document.forms[0].R_Month.selectedIndex
return_day_index = document.forms[0].R_Day.selectedIndex
return_time_index = document.forms[0].R_Time.selectedIndex
document.forms[0].R_Month.options[lengthMonth-1].selected = true
document.forms[0].R_Day.options[lengthDay-1].selected = true
document.forms[0].R_Time.options[lengthTime-1].selected = true
}
function Lineas(){
var myelements = document.forms[0].elements
if(myelements[indexAirlines].value == "00")
myelements[indexAirlines].value = ""
if(myelements[indexAirlines+1].value == "00")
myelements[indexAirlines+1].value = ""
if(myelements[indexAirlines+2].value == "00")
myelements[indexAirlines+2].value = ""
}
function ErrorWindow(cadena){
var parameter = cadena
newWindow = window.open("error.htm","newWin","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=320,height=325")
if(navigator.appName == "Netscape")
newWindow.focus()
}
var num_field
function NumFields(name){
var index
for(n = 0;n < document.forms[0].elements.length;n ++){
if(document.forms[0].elements[n].name == name)
index = n
}
return(index)
}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openWindow(url) 
{ popupWin = window.open(url, 'openWin', "width=400, height=250, scrollbars=yes, resizable=yes"); 
} 

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function GoToAuxWin(n, page){
numero = n
i = page.indexOf("/")
if(i >= 0){
if(page.substring(0,i) == "LangDir"){
whole_url = document.URL
page = whole_url.substring(0,whole_url.lastIndexOf("/")) + page.substring(i,page.length)
}
}else
page = "/pl/" + page
listin = open(page, "", "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=320,height=300")
if(navigator.appName == "Netscape")
listin.focus()
}
function CheckFields(name){
for(n = 0;n < document.forms[0].elements.length;n ++){
if(document.forms[0].elements[n].name == name)
indexAirlines = n
}
}
function ReturnTrip(){
if(return_month_index == -1){
for(n = 0;n < document.forms[0].R_Month.length;n ++){
if(document.forms[0].R_Month.options[n].defaultSelected)
return_month_index = n
}
for(n = 0;n < document.forms[0].R_Day.length;n ++){
if(document.forms[0].R_Day.options[n].defaultSelected)
return_day_index = n
}

for(n = 0;n < document.forms[0].R_Time.length;n ++){
if(document.forms[0].R_Time.options[n].defaultSelected)
return_time_index = n
}

}
document.forms[0].R_Month.options[return_month_index].selected = true
document.forms[0].R_Day.options[return_day_index].selected = true
document.forms[0].R_Time.options[return_time_index].selected = true
}

}
function CheckFields(name){
for(n = 0;n < document.forms[0].elements.length;n ++){
if(document.forms[0].elements[n].name == name)
indexAirlines = n
}
}


// Popup Window Variables
var window_text = "#37376F";
var window_table_color = "#F4F4F4";
var tc_text = "#37376F";

var window_bgcolor = "#FFFFFE";
var window_link = "#3160C1";
var banner_bg_color = "#F4F4F4";
var bg_graphic = 0;
// End Popup Window Variables

function Expand() 
{
      parent.headerFr.cols = "170,*";
}

