function update_bdate() {
yyyy = document.forms[0].D_Month.value.substring(0,4);
mm = document.forms[0].D_Month.value.substring(4,6);
document.forms[0].Departure_date.value = document.forms[0].D_Day.value + "-" + mm + "-" + yyyy ;

}
function update_rdate() {
yyyy = document.forms[0].R_Month.value.substring(0,4);
mm = document.forms[0].R_Month.value.substring(4,6);
document.forms[0].Return_date.value = document.forms[0].R_Day.value + "-" + mm + "-" + yyyy ;
}

function ChangeReturnDate(){
var myform = document.AIR_ENTRY_FORM
var selectedMonth
var IsShortMonth
var btnRetDate = false

selectedMonth = myform.B_MONTH.options[myform.B_MONTH.selectedIndex].value.charAt(4) + myform.B_MONTH.options[myform.B_MONTH.selectedIndex].value.charAt(5)
IsShortMonth = (selectedMonth == "02" || selectedMonth == "04" || selectedMonth == "06" || selectedMonth == "09" || selectedMonth == "11")

if(myform.TRIP_TYPE[1].checked)
btnRetDate = true

if(btnRetDate && departing_date_selected){
if(myform.B_MONTH.selectedIndex > myform.E_MONTH.selectedIndex || myform.B_MONTH.options[myform.B_MONTH.selectedIndex].value == "XX")
myform.E_MONTH.selectedIndex = myform.B_MONTH.selectedIndex
if((myform.B_DAY.selectedIndex >= myform.E_DAY.selectedIndex || myform.E_DAY.options[myform.E_DAY.selectedIndex].value == "XX")&&(myform.E_MONTH.selectedIndex == myform.B_MONTH.selectedIndex)){
if(((myform.B_DAY.options[myform.B_DAY.selectedIndex].value > 29) && (IsShortMonth))||(myform.B_DAY.options[myform.B_DAY.selectedIndex].value == 31)||((myform.B_DAY.options[myform.B_DAY.selectedIndex].value > 27) && (myform.B_MONTH.selectedIndex == 6))){
myform.E_MONTH.selectedIndex = myform.B_MONTH.selectedIndex + 1
myform.E_DAY.selectedIndex = 0
}
else
myform.E_DAY.selectedIndex = myform.B_DAY.selectedIndex + 1
}
document.AIR_ENTRY_FORM.E_TIME.selectedIndex = document.AIR_ENTRY_FORM.B_TIME.selectedIndex
}
departing_date_selected = false
}

function ReturnFlight(){

document.AIR_ENTRY_FORM.TRIP_TYPE[1].checked = true

ChangeReturnDate()
}


function showFL(details){
guindou = open(details, "FLDetails", "toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=no,width=540,height=440")
if(navigator.appName == "Netscape")
guindou.focus()
}
function airDate() {
    now = new Date();
	now3 = new Date(now.getTime() + 48 * 3600 * 1000);
	document.AIR_ENTRY_FORM.B_DAY.selectedIndex = now3.getDate();
	document.AIR_ENTRY_FORM.B_MONTH.selectedIndex = now3.getMonth();
	
	then = new Date(now.getTime() + 168 * 3600 * 1000);
	document.AIR_ENTRY_FORM.E_DAY.selectedIndex = then.getDate();
	document.AIR_ENTRY_FORM.E_MONTH.selectedIndex = then.getMonth();
}
function hotelDate() {
    now = new Date();
	now3 = new Date(now.getTime() + 48 * 3600 * 1000);
	document.HOTEL_SEARCH_FORM.B_DAY.selectedIndex = now3.getDate();
	document.HOTEL_SEARCH_FORM.B_MONTH.selectedIndex = now3.getMonth();
	
	then = new Date(now.getTime() + 168 * 3600 * 1000);
	document.HOTEL_SEARCH_FORM.E_DAY.selectedIndex = then.getDate();
	document.HOTEL_SEARCH_FORM.E_MONTH.selectedIndex = then.getMonth();
}

function carDate() {
    now = new Date();
	now3 = new Date(now.getTime() + 48 * 3600 * 1000);
	document.CAR_SEARCH_FORM.B_Day.selectedIndex = now3.getDate();
	document.CAR_SEARCH_FORM.B_Month.selectedIndex = now3.getMonth();
	
	then = new Date(now.getTime() + 168 * 3600 * 1000);
	document.CAR_SEARCH_FORM.E_Day.selectedIndex = then.getDate();
	document.CAR_SEARCH_FORM.E_Month.selectedIndex = then.getMonth();
}

function timetableDate() {
    now = new Date();
	now3 = new Date(now.getTime() + 48 * 3600 * 1000);
	document.TimeTableSearch.B_Day.selectedIndex = now3.getDate();
	document.TimeTableSearch.B_Month.selectedIndex = now3.getMonth();
	
	then = new Date(now.getTime() + 168 * 3600 * 1000);
	document.TimeTableSearch.E_Day.selectedIndex = then.getDate();
	document.TimeTableSearch.E_Month.selectedIndex = then.getMonth();
}

// PTRs1038075
function GoToAirAuxWin(n, page) {
indexAirlines = NumFields('AIRLINE_1');
GoToAuxWin(n, page)
}
// PTRe1038075

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 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()
}

function CheckDates(month, day, year, returning){
var year = parseInt(year)
var leap_year = (year % 4 == 0 & year % 100 != 0) || (year % 400 == 0)
if(month == "02" && (day == "30" || day == "29") && !leap_year){
if(returning == 0)
return "<li> Invalid departure date."
else
return "<li> Invalid return date."
}
var comp1 = (month == "02" || month == "04" || month == "06" || month == "09" || month == "11")
var comp2 = (day == "31")
if(comp1 && comp2){
if(returning == 0)
return "<li> Invalid departure date."
else
return "<li> Invalid return date."
}
else
return ""
}

function CheckFields(myfieldsarray, myvarsarray){
for(n = 0;n < document.forms[0].elements.length;n ++){
var elementName = document.forms[0].elements[n].name
for(j = 0;j < myfieldsarray.length;j ++){
if(elementName == myfieldsarray[j])
eval(myvarsarray[j] + " = n")
}
}
}

function ShowFlightInfo(details){
guindou = window.open(details, "", "toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=yes,width=600,height=450")
if(navigator.appName == "Netscape")
guindou.focus()
}

function ShowPopupTripElementDetail(urlParam){
guindou = window.open(urlParam, "","toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=no,width=545,height=400")
if(navigator.appName == "Netscape")
guindou.focus()
}

function CheckFieldsNew(name){
for(n = 0;n < document.forms[0].elements.length;n ++){
var elementName = document.forms[0].elements[n].name
if(elementName == name)
indexHotel = n
}
}

function GoToAuxWinNew(n, page,name){
CheckFieldsNew(name)
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 existsincombo(mystring, mycombo, textorvalue){
for(i = 0;i < mycombo.length;i ++){
if(textorvalue == "text" && mycombo.options[i].text == mystring)
return true
if(textorvalue == "value" && mycombo.options[i].value == mystring)
return true
}
return false
}

function addoptionatthebegin(mytext, myvalue, mycombo){
var keepselectedindex = mycombo.selectedIndex
mycombo.options[mycombo.options.length] = new Option(mycombo.options[mycombo.options.length - 1].text,mycombo.options[mycombo.options.length - 1].value,false,false)
for(i = mycombo.length - 2;i >= 0;i --){
mycombo.options[i+1].text = mycombo.options[i].text
mycombo.options[i+1].value = mycombo.options[i].value
}
var myoption = new Option(mytext, myvalue, false, false)
myoption.selected = false
mycombo.options[0] = myoption
mycombo.options[keepselectedindex].defaultSelected = true
mycombo.selectedIndex = keepselectedindex
}


// 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
