﻿// JScript File

function updateairportlist(aircode){
  i = 0
      var itemFound = false
      while ((i < document.login.airport.options.length) && (!itemFound)) {
         if (document.login.airport.options[i].value == aircode) {
            document.login.airport.options[i].selected = true
            itemFound = true
         }
         i++
      }
   }

function updatedestlist(aircode){
  	if (aircode == 'E') 
  		document.forms[0].destination[0].checked = true;
   	else
   		if (aircode == 'W') 
	  			document.forms[0].destination[1].checked = true;
}


function OpenInfoWindow(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=600,height=550,scrollbars=yes');
return false;
}

function OpenExtInfoWindow(mylink, windowname, params)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, params);
return false;
}

function pophelp(mylink)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, 'infopop','width=650,height=650,scrollbars=yes');
return false;
}
function pophelpsml(mylink)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, 'infopopsml','width=285,height=300,scrollbars=yes');
return false;
}


function poplist(mylink)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, 'infopop','width=300,height=250,scrollbars=no');
return false;
}



function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}



function defaultmonth() {
document.login.retMonth.options[document.login.BkMonth.selectedIndex].selected = true}

function defaultyear() {
document.login.retYear.options[document.login.BkYear.selectedIndex].selected = true}


function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}


function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }
  return null;
}

function geturn()
 {
	 
 urnhold=GetCookie('URN');
 document.forms[0].urn.value=(urnhold == null) ? "" : urnhold;
  }

function dollarchange(radionum) {
var rad1
var rad2
var rad3
var rad4
	if (document.Forex.amount[radionum].checked)
		document.Forex.dollaramount.disabled=false
	else
		document.Forex.dollaramount.disabled=true;

	if (document.Forex.amount[7].checked)
		document.Forex.euroamount.disabled=false
	else
		document.Forex.euroamount.disabled=true;
	
	if (document.Forex.amount[1].checked)
		rad1 = 'yes'
	else
		rad1 = 'no';
	if (document.Forex.amount[2].checked)
		rad2 = 'yes'
	else
		rad2 = 'no';
	if (document.Forex.amount[3].checked)
		rad3 = 'yes'
	else
		rad3 = 'no';
	if (document.Forex.amount[4].checked)
		rad4 = 'yes'
	else
		rad4 = 'no';

	return true;
	
}



function OpenHelpWindow(mylink)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, 'userinfo', 'width=700,height=550,scrollbars=yes');
return false;
}

function popUp(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0, status=1,menubar=1,scrollbars=1,resizable=1,WIDTH=650,height=500');
self.name = "mainWin"; }

function popctc(url) {
sealWin=window.open(url,"winctc",'toolbar=0,location=0,directories=0, status=1,menubar=1,scrollbars=1,resizable=1,width=540,height=650');
self.name = "mainWin"; }

var currentField, nextField; 
function advance(s1,s2,l) { 
var s  = document.CustDet[s1].value;
	if (s.length == l)
		document.CustDet[s2].focus();
	return true;
	}

function setentry(etype) {
 document.CustDet.entrytype.value=etype;
 document.forms["CustDet"].submit();
}

function setqqentry(etype) {
 document.qqcross.entrytype.value=etype;
 document.forms["qqcross"].submit();
}

function keypressed(etype) {
 document.forms[0].entrytype.value=etype;
 document.forms[0].submit();
}

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}


function UpdateCookie(CookieName,CookieVal) {
	var expdate = new Date ();
	expdate.setTime (expdate.getTime() + (60 * 24 * 60 * 60 * 1000)); // 60 days from now 
	SetCookie (CookieName, CookieVal , expdate);
	}

function dollarchange(radionum) {
var rad1
var rad2
var rad3
var rad4
	if (document.Forex.amount[radionum].checked)
		document.Forex.dollaramount.disabled=false
	else
		document.Forex.dollaramount.disabled=true;

	if (document.Forex.amount[7].checked)
		document.Forex.euroamount.disabled=false
	else
		document.Forex.euroamount.disabled=true;
	
	if (document.Forex.amount[1].checked)
		rad1 = 'yes'
	else
		rad1 = 'no';
	if (document.Forex.amount[2].checked)
		rad2 = 'yes'
	else
		rad2 = 'no';
	if (document.Forex.amount[3].checked)
		rad3 = 'yes'
	else
		rad3 = 'no';
	if (document.Forex.amount[4].checked)
		rad4 = 'yes'
	else
		rad4 = 'no';

	return true;
	
}

function disablelists() {
var x=document.getElementById("dollardrop")
x.options[0].selected = true 
x.disabled=true
var x=document.getElementById("eurodrop") 
x.options[0].selected = true 
x.disabled=true
}

function enabledollar() {
var x=document.getElementById("dollardrop") 
x.disabled=false
var x=document.getElementById("eurodrop")
x.options[0].selected = true  
x.disabled=true
}

function enableeuro() {
var x=document.getElementById("dollardrop")
x.options[0].selected = true 
x.disabled=true
var x=document.getElementById("eurodrop") 
x.disabled=false
}
var _img = new Array();
    _img[0] = new Image(); _img[0].src="furniture/ageopt1.gif";
    _img[1] = new Image(); _img[1].src="furniture/ageopt2.gif";
    
function doIt(_obj)
{
  if(!_obj)return;
  var _index = _obj.selectedIndex;
  if(!_index)return;
  var _item  = _obj[_index].value;
  if(!_item)return;
  if(_item == 'LHR4  ')
  document.images["ageopt"].src=_img[1].src;
  else
  document.images["ageopt"].src=_img[0].src;
}

function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}

function CloseTheWindow()
{
window.close();
}

function small_pop(mylink, windowname, width, height)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
var pars
pars = "width=" + width + ",height=" + height + ",scrollbars=yes"
window.open(href, windowname, pars);
return false;
}

function openhistory(mylink)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, 'history', 'width=620,height=550,scrollbars=yes');
return false;
}



function rolloverButton (id, state) {
  if (document.getElementById) {
    var element_id = document.getElementById(id);
	if (state == 'over') {
	  element_id.className = 'continuebuttonhover'
	}else{
	  element_id.className = 'continuebutton'
	}
  }
}

function validatecpentry() {
var errormessage = ''
var arrival = new Date();
var returning = new Date();
var today = new Date();
var months = "JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC";
var monthpos;
monthpos = months.indexOf(document.forms[0].dispstartmonth.value.substring(0,3));
monthpos = (( monthpos + 3 ) / 3 ) - 1;
if (isValidDate(document.forms[0].dispstartday.value, monthpos, 2000 + parseInt(document.forms[0].dispstartmonth.value.substring(3,5),10)))
   {
   
   arrival.setDate(1);
   arrival.setMonth(monthpos);
   arrival.setYear( 2000 + parseInt(document.forms[0].dispstartmonth.value.substring(3,5),10));
   
   arrival.setDate(document.forms[0].dispstartday.value);
   
   if (arrival < today) 
      {
      errormessage = (errormessage + 'Please select an arrival date after today\'s date\n' ); 
      }
   else
      {
      if (arrival > today)
         {
         }
      else
         {
         errormessage = (errormessage + 'Please select an arrival date after today\'s date\n'); 
         }
      }
   }
else
   {
   errormessage = (errormessage + 'Please enter a valid arrival date\n' );
   } 
monthpos = months.indexOf(document.forms[0].dispendmonth.value.substring(0,3));
monthpos = (( monthpos + 3 ) / 3 ) - 1;
if (isValidDate(document.forms[0].dispendday.value, monthpos, 2000 + parseInt(document.forms[0].dispendmonth.value.substring(3,5),10)))
   {
   returning.setDate(1)
   returning.setMonth(monthpos);
   returning.setYear(2000 + parseInt(document.forms[0].dispendmonth.value.substring(3,5),10));
   returning.setDate(document.forms[0].dispendday.value);
   
   if (returning < today) 
      {
      errormessage = (errormessage + 'Please select a departure date after today\'s date\n' ); 
      }
   else
      {
      if (returning > today)
         {
         if (returning < arrival)
	    {
	    errormessage = (errormessage + 'Please select a departure date that is after the arrival date\n'); 
	    
	    }
	 }
      else
         {
         errormessage = (errormessage + 'Please select a departure date after today\'s date\n'); 
         }
      }
   }
else
   {
   errormessage = (errormessage + 'Please enter a valid departure date\n' );
   } 






if (errormessage.length > 0 )
   {
   alert(errormessage);
   return false;
   }

document.forms[0].submit();
}



function isValidDate(day,month,year){
/*
Purpose: return true if the date is valid, false otherwise

Arguments: day integer representing day of month
month integer representing month of year
year integer representing year

Variables: dteDate - date object

*/
var dteDate;

//set up a Date object based on the day, month and year arguments
//javascript months start at 0 (0-11 instead of 1-12)
dteDate=new Date(year,month,day);

return ((day==dteDate.getDate()) && (month==dteDate.getMonth()) && (year==dteDate.getFullYear()));
}



function SetToFirstControl()
{
  var bFound = false;  

  //for each form
  for (f=0; f < document.forms.length; f++) 
  { 
    //for each element in each form
    for(i=0; i < document.forms[f].length; i++) 
    { 
      //if it's not a hidden element
      if (document.forms[f][i].type != "hidden") 
      { 
        //and it's not disabled
        if (document.forms[f][i].disabled != true) 
        {
          try {
             //set the focus to it
             document.forms[f][i].focus();
             var bFound = true;
          }
          catch(er) {
          }
        }
      }
      //if found in this element, stop looking
      if (bFound == true)
        break;
    }
    //if found in this form, stop looking
    if (bFound == true)
      break;
  }
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
    input.form[(getIndex(input)+1) % input.form.length].select();

  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}
