fsInfoFlight = new Array;

fsInfoSubFlight0 = new Array('AUH|Abu Dhabi'

       ,'Manila |MNL'


); fsInfoFlight[0] = fsInfoSubFlight0;


fsInfoSubFlight1 = new Array('BCD|Bacolod'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[1] = fsInfoSubFlight1;


fsInfoSubFlight2 = new Array('BAH|Bahrain'

       ,'Manila |MNL'


); fsInfoFlight[2] = fsInfoSubFlight2;


fsInfoSubFlight3 = new Array('BKK|Bangkok'

       ,'Manila |MNL'


); fsInfoFlight[3] = fsInfoSubFlight3;


fsInfoSubFlight4 = new Array('BWN|Begawan'

       ,'Manila |MNL'


); fsInfoFlight[4] = fsInfoSubFlight4;


fsInfoSubFlight5 = new Array('PEK|Beijing'

       ,'Manila |MNL'


); fsInfoFlight[5] = fsInfoSubFlight5;


fsInfoSubFlight6 = new Array('BNE|Brisbane'

       ,'Manila |MNL'


); fsInfoFlight[6] = fsInfoSubFlight6;


fsInfoSubFlight7 = new Array('PUS|Busan'

       ,'Manila |MNL'


); fsInfoFlight[7] = fsInfoSubFlight7;


fsInfoSubFlight8 = new Array('USU|Busuanga'

       ,'Manila |MNL'


       ,'Puerto Princesa |PPS'


); fsInfoFlight[8] = fsInfoSubFlight8;


fsInfoSubFlight9 = new Array('BXU|Butuan'

       ,'Manila |MNL'


); fsInfoFlight[9] = fsInfoSubFlight9;


fsInfoSubFlight10 = new Array('CGY|Cagayan de Oro'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[10] = fsInfoSubFlight10;


fsInfoSubFlight11 = new Array('CYP|Calbayog'

       ,'Manila |MNL'


); fsInfoFlight[11] = fsInfoSubFlight11;


fsInfoSubFlight12 = new Array('CRM|Catarman'

       ,'Manila |MNL'


); fsInfoFlight[12] = fsInfoSubFlight12;


fsInfoSubFlight13 = new Array('MPH|Caticlan (Boracay)'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[13] = fsInfoSubFlight13;


fsInfoSubFlight14 = new Array('CEB|Cebu'

       ,'Bacolod |BCD'


       ,'Cagayan De Oro |CGY'


       ,'Caticlan (Boracay) |MPH'


       ,'Davao |DVO'


       ,'Dipolog |DPL'


       ,'Hong Kong |HKG'


       ,'Iloilo |ILO'


       ,'Kota Kinabalu |BKI'


       ,'Kuala Lumpur |KUL'


       ,'Manila |MNL'


       ,'Ozamiz |OZC'


       ,'Tacloban |TAC'


       ,'Tokyo |NRT'


       ,'Zamboanga |ZAM'


); fsInfoFlight[14] = fsInfoSubFlight14;


fsInfoSubFlight15 = new Array('CBO|Cotabato'

       ,'Manila |MNL'


); fsInfoFlight[15] = fsInfoSubFlight15;


fsInfoSubFlight16 = new Array('DVO|Davao'

       ,'Cebu |CEB'


       ,'Manila |MNL'


       ,'Zamboanga |ZAM'


); fsInfoFlight[16] = fsInfoSubFlight16;


fsInfoSubFlight17 = new Array('DPL|Dipolog'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[17] = fsInfoSubFlight17;


fsInfoSubFlight18 = new Array('DOH|Doha'

       ,'Manila |MNL'


); fsInfoFlight[18] = fsInfoSubFlight18;


fsInfoSubFlight19 = new Array('DXB|Dubai'

       ,'Manila |MNL'


); fsInfoFlight[19] = fsInfoSubFlight19;


fsInfoSubFlight20 = new Array('DGT|Dumaguete'

       ,'Manila |MNL'


); fsInfoFlight[20] = fsInfoSubFlight20;


fsInfoSubFlight21 = new Array('FUK|Fukuoka'

       ,'Manila |MNL'


); fsInfoFlight[21] = fsInfoSubFlight21;


fsInfoSubFlight22 = new Array('GES|General Santos'

       ,'Manila |MNL'


); fsInfoFlight[22] = fsInfoSubFlight22;


fsInfoSubFlight23 = new Array('GUM|Guam'

       ,'Manila |MNL'


); fsInfoFlight[23] = fsInfoSubFlight23;


fsInfoSubFlight24 = new Array('SGN|Ho Chi Minh'

       ,'Manila |MNL'


); fsInfoFlight[24] = fsInfoSubFlight24;


fsInfoSubFlight25 = new Array('HKG|Hong Kong'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[25] = fsInfoSubFlight25;


fsInfoSubFlight26 = new Array('HNL|Honolulu'

       ,'Manila |MNL'


); fsInfoFlight[26] = fsInfoSubFlight26;


fsInfoSubFlight27 = new Array('ILO|Iloilo'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[27] = fsInfoSubFlight27;


fsInfoSubFlight28 = new Array('CGK|Jakarta'

       ,'Manila |MNL'


       ,'Singapore |SIN'


); fsInfoFlight[28] = fsInfoSubFlight28;


fsInfoSubFlight29 = new Array('KLO|Kalibo'

       ,'Manila |MNL'


); fsInfoFlight[29] = fsInfoSubFlight29;


fsInfoSubFlight30 = new Array('BKI|Kota Kinabalu'

       ,'Cebu |CEB'


); fsInfoFlight[30] = fsInfoSubFlight30;


fsInfoSubFlight31 = new Array('KUL|Kuala Lumpur'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[31] = fsInfoSubFlight31;


fsInfoSubFlight32 = new Array('LAO|Laoag'

       ,'Manila |MNL'


); fsInfoFlight[32] = fsInfoSubFlight32;


fsInfoSubFlight33 = new Array('LAS|Las Vegas'

       ,'Manila |MNL'


       ,'Vancouver |YVR'


); fsInfoFlight[33] = fsInfoSubFlight33;


fsInfoSubFlight34 = new Array('LGP|Legaspi'

       ,'Manila |MNL'


); fsInfoFlight[34] = fsInfoSubFlight34;


fsInfoSubFlight35 = new Array('LAX|Los Angeles'

       ,'Manila |MNL'


); fsInfoFlight[35] = fsInfoSubFlight35;


fsInfoSubFlight36 = new Array('MFM|Macau'

       ,'Manila |MNL'


); fsInfoFlight[36] = fsInfoSubFlight36;


fsInfoSubFlight37 = new Array('MNL|Manila'

       ,'Abu Dhabi  |AUH'


       ,'Bacolod |BCD'


       ,'Bahrain |BAH'


       ,'Bangkok |BKK'


       ,'Begawan |BWN'


       ,'Beijing |PEK'


       ,'Brisbane |BNE'


       ,'Busan |PUS'


       ,'Busuanga |USU'


       ,'Butuan |BXU'


       ,'Cagayan De Oro |CGY'


       ,'Calbayog |CYP'


       ,'Catarman |CRM'


       ,'Caticlan (Boracay) |MPH'


       ,'Cebu |CEB'


       ,'Cotabato |CBO'


       ,'Davao |DVO'


       ,'Dipolog |DPL'


       ,'Doha |DOH'


       ,'Dubai |DXB'


       ,'Dumaguete |DGT'


       ,'Fukuoka |FUK'


       ,'General Santos |GES'


       ,'Guam |GUM'


       ,'Ho Chi Minh City |SGN'


       ,'Hong Kong |HKG'


       ,'Honolulu |HNL'


       ,'Iloilo |ILO'


       ,'Jakarta |CGK'


       ,'Kalibo |KLO'


       ,'Kuala Lumpur |KUL'


       ,'Laoag |LAO'


       ,'Las Vegas |LAS'


       ,'Legaspi |LGP'


       ,'Los Angeles |LAX'


       ,'Macau |MFM'


       ,'Melbourne |MEL'


       ,'Naga |WNP'


       ,'Nagoya |NGO'


       ,'Ormoc |OMC'


       ,'Osaka |KIX'


       ,'Ozamiz |OZC'


       ,'Puerto Princesa |PPS'


       ,'Riyadh |RUH'


       ,'Roxas |RXS'


       ,'San Francisco |SFO'


       ,'San Jose |SJI'


       ,'Seoul |ICN'


       ,'Shanghai |PVG'


       ,'Singapore |SIN'


       ,'Surigao |SUG'


       ,'Sydney |SYD'


       ,'Tacloban |TAC'


       ,'Tagbilaran |TAG'


       ,'Taipei |TPE'


       ,'Tokyo |NRT'


       ,'Tuguegarao |TUG'


       ,'Vancouver |YVR'


       ,'Xiamen |XMN'


       ,'Zamboanga |ZAM'


); fsInfoFlight[37] = fsInfoSubFlight37;


fsInfoSubFlight38 = new Array('MEL|Melbourne'

       ,'Brisbane |BNE'


       ,'Manila |MNL'


       ,'Sydney |SYD'


); fsInfoFlight[38] = fsInfoSubFlight38;


fsInfoSubFlight39 = new Array('WNP|Naga'

       ,'Manila |MNL'


); fsInfoFlight[39] = fsInfoSubFlight39;


fsInfoSubFlight40 = new Array('NGO|Nagoya'

       ,'Manila |MNL'


); fsInfoFlight[40] = fsInfoSubFlight40;


fsInfoSubFlight41 = new Array('OMC|Ormoc'

       ,'Manila |MNL'


); fsInfoFlight[41] = fsInfoSubFlight41;


fsInfoSubFlight42 = new Array('KIX|Osaka'

       ,'Manila |MNL'


); fsInfoFlight[42] = fsInfoSubFlight42;


fsInfoSubFlight43 = new Array('OZC|Ozamiz'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[43] = fsInfoSubFlight43;


fsInfoSubFlight44 = new Array('PPS|Puerto Princesa'

       ,'Busuanga |USU'


       ,'Manila |MNL'


); fsInfoFlight[44] = fsInfoSubFlight44;


fsInfoSubFlight45 = new Array('RUH|Riyadh'

       ,'Manila |MNL'


); fsInfoFlight[45] = fsInfoSubFlight45;


fsInfoSubFlight46 = new Array('RXS|Roxas'

       ,'Manila |MNL'


); fsInfoFlight[46] = fsInfoSubFlight46;


fsInfoSubFlight47 = new Array('SFO|San Francisco'

       ,'Manila |MNL'


); fsInfoFlight[47] = fsInfoSubFlight47;


fsInfoSubFlight48 = new Array('SJI|San Jose'

       ,'Manila |MNL'


); fsInfoFlight[48] = fsInfoSubFlight48;


fsInfoSubFlight49 = new Array('ICN|Seoul'

       ,'Manila |MNL'


); fsInfoFlight[49] = fsInfoSubFlight49;


fsInfoSubFlight50 = new Array('PVG|Shanghai'

       ,'Manila |MNL'


); fsInfoFlight[50] = fsInfoSubFlight50;


fsInfoSubFlight51 = new Array('SIN|Singapore'

       ,'Jakarta |CGK'


       ,'Manila |MNL'


); fsInfoFlight[51] = fsInfoSubFlight51;


fsInfoSubFlight52 = new Array('SUG|Surigao'

       ,'Manila |MNL'


); fsInfoFlight[52] = fsInfoSubFlight52;


fsInfoSubFlight53 = new Array('SYD|Sydney'

       ,'Manila |MNL'


       ,'Melbourne |MEL'


); fsInfoFlight[53] = fsInfoSubFlight53;


fsInfoSubFlight54 = new Array('TAC|Tacloban'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[54] = fsInfoSubFlight54;


fsInfoSubFlight55 = new Array('TAG|Tagbilaran'

       ,'Manila |MNL'


); fsInfoFlight[55] = fsInfoSubFlight55;


fsInfoSubFlight56 = new Array('TPE|Taipei'

       ,'Manila |MNL'


); fsInfoFlight[56] = fsInfoSubFlight56;


fsInfoSubFlight57 = new Array('NRT|Tokyo'

       ,'Cebu |CEB'


       ,'Manila |MNL'


); fsInfoFlight[57] = fsInfoSubFlight57;


fsInfoSubFlight58 = new Array('TUG|Tuguegarao'

       ,'Manila |MNL'


); fsInfoFlight[58] = fsInfoSubFlight58;


fsInfoSubFlight59 = new Array('YVR|Vancouver'

       ,'Las Vegas |LAS'


       ,'Manila |MNL'


); fsInfoFlight[59] = fsInfoSubFlight59;


fsInfoSubFlight60 = new Array('XMN|Xiamen'

       ,'Manila |MNL'


); fsInfoFlight[60] = fsInfoSubFlight60;


fsInfoSubFlight61 = new Array('ZAM|Zamboanga'

       ,'Cebu |CEB'


       ,'Davao |DVO'


       ,'Manila |MNL'


); fsInfoFlight[61] = fsInfoSubFlight61;



function submitDep(){
  varboolean = false;
  document.topForm.querytype.value = "";
    
  //Fields are empty
  if ((document.forms['topForm']['in_fltno'].value == "") && (document.forms['topForm']['in_depstn'].value == "000") && (document.forms['topForm']['in_arrstn'].value == "000"))
  {
     alert ("You need to enter a flight number or select a flight origin and destination.");

  } else { //Something is entered
   
                if (document.topForm.in_fltno.value != "") {
	          document.topForm.querytype.value = "flight";
                          varboolean = validateChar(document.topForm.in_fltno, '0123456789', true, 'Only numeric characters are allowed.');
	}else{
		if (document.topForm.in_depstn.value != "000"){
			if (document.topForm.in_arrstn.value != "000"){
                                                     document.topForm.querytype.value = "station";
                                                     document.topForm.prevFrom.value = document.topForm.in_depstn[document.topForm.in_depstn.options.selectedIndex].value;    
                                                     document.topForm.prevTo.value = document.topForm.in_arrstn[document.topForm.in_arrstn.options.selectedIndex].value;
                                                     varboolean = true;
			} else {
                                                     alert ("You need to select a flight destination.");
                                                }
		}
	}
  


  }
    
	
	
	
    if (varboolean == true) {
        document.topForm.op_deparr.value = "Departure";
         if (document.topForm.querytype.value != "") {
            document.topForm.action.value = "search";
            document.topForm.submit();
        }
    }
    
}

function submitArr(){
    varboolean = false;
    document.topForm.querytype.value = "";

    //Fields are empty
  if ((document.forms['topForm']['in_fltno'].value == "") && (document.forms['topForm']['in_depstn'].value == "000") && (document.forms['topForm']['in_arrstn'].value == "000"))
  {
     alert ("You need to enter a flight number or select a flight origin and destination.");

  } else { //Something is entered
	
                if (document.topForm.in_fltno.value != "") {
	                document.topForm.querytype.value = "flight";
                                varboolean = validateChar(document.topForm.in_fltno, '0123456789', true, 'Only numeric characters are allowed.');
                }else{
		if (document.topForm.in_depstn.value != "000"){
			if (document.topForm.in_arrstn.value != "000"){
                                                                document.topForm.querytype.value = "station";
                                                                document.topForm.prevFrom.value = document.topForm.in_depstn[document.topForm.in_depstn.options.selectedIndex].value;    
                                                                document.topForm.prevTo.value = document.topForm.in_arrstn[document.topForm.in_arrstn.options.selectedIndex].value;  
                                                                varboolean = true;
			} else {
                                                        alert ("You need to select a flight destination.");
                                                }
		}
	}
 }

    if (varboolean == true) {
        document.topForm.op_deparr.value = "Arrival";
        if (document.topForm.querytype.value != "") {
            document.topForm.action.value = "search";
            document.topForm.submit();
        }
    }
}
	
//validates the characters within a text
//sample usage
//booloean = validateChar(document.frmSupplyItem.strCode, '0123456789', true, 'Only numeric characters are allowed.');
//booloean = validateChar(document.frmSupplyItem.strCode, '0123456789', false, 'Numeric characters are not allowed.');
function validateChar(field, charList, valid, errMsg) {
	var status;
	var char;
	
	for (var i = 0; i < field.value.length; i++) {
		char = "" + field.value.substring(i, i+1);
		if (charList.indexOf(char) != -1) {
			if (valid == true) {
				status = true;
			} else {
				status = false;
				break;
			}
		} else {
			if (valid == true) {
				status = false;
				break;
			} else {
				status = true;
			}
		}
	}
	if (status == false) {
		alert(errMsg);
		field.focus();
		field.select();
		return false;
	} else {
		return true;
	}   	
}

// Generating arrival dropdown list
function generateListDA() {
	fromObj = document.forms['topForm']['in_depstn'];
	toObj     = document.forms['topForm']['in_arrstn'];
	//Resetting arrival dropdown
                toObj.options.selectedIndex=0;
                toObj.length=1;
	if(fromObj.options.selectedIndex!=0){
                                for(var i=0;i<fsInfoFlight.length;i++){
                                               if(fsInfoFlight[i][0].split("|")[0].indexOf(fromObj[fromObj.options.selectedIndex].value)==0){ 
                                                               //Generating new list
				for(var j=1;j<fsInfoFlight[i].length;j++) {
                                                                                var newOption = document.createElement("option");
                                                                                newOption.value = fsInfoFlight[i][j].split("|")[1];
                                                                                newOption.appendChild(document.createTextNode(fsInfoFlight[i][j].split("|")[0]));
					toObj.appendChild(newOption);
                                                                                if(document.forms['topForm']['prevTo'].value != ""){
                                                                                          if(newOption.value == document.forms['topForm']['prevTo'].value){
                                                                                                         newOption.selected = true;
                                                                                                         document.forms['topForm']['prevTo'].value = "";
                                                                                          }
                                                                                }
                                                                }
                                               }
                                }
                }
}

function generateFromDA(){
                fromObj = document.forms['topForm']['in_depstn'];
                fromObj.options.selectedIndex=0;
                fromObj.length=1;

                //sort
                fromDAArray = new Array();
                fromDAArray[0] = fsInfoFlight[0][0];
                for(var h=1;h<fsInfoFlight.length;h++){
                      fromDAArray[h] = fsInfoFlight[h][0];
                      for(g=fromDAArray.length-1; g>=1; g--){
                                if(fromDAArray[g].split("|")[1] < fromDAArray[g-1].split("|")[1]){
                                              var tempString = fromDAArray[g];
                                              fromDAArray[g] = fromDAArray[g-1];
                                              fromDAArray[g-1] = tempString;
                                }
                      }//end sort
                }

                for(var i=0;i<fsInfoFlight.length;i++){
                                var newOption = document.createElement("option");
                                newOption.value = fromDAArray[i].split("|")[0];
                                newOption.appendChild(document.createTextNode(fromDAArray[i].split("|")[1]));
		fromObj.appendChild(newOption);
                                if(document.forms['topForm']['prevFrom'].value != ""){
                                           if(newOption.value == document.forms['topForm']['prevFrom'].value){
                                                    newOption.selected = true;
                                                    document.forms['topForm']['prevFrom'].value = "";
                                            }
                                 }
                 }
}


function docEnDis(){

  // fields are empty...

  if ((document.forms['topForm']['in_fltno'].value == "") && (document.forms['topForm']['in_depstn'].value == "000") && (document.forms['topForm']['in_arrstn'].value == "000"))
  { 
    document.forms['topForm']['in_fltno'].disabled = false;
    document.forms['topForm']['in_depstn'].disabled = false;
    document.forms['topForm']['in_arrstn'].disabled = true;
    //document.depbutton.src = butDep_out.src;
    //document.arrbutton.src = butArr_out.src;
  } else {
  // something is entered... 
    // a flight number is entered
    if (document.forms['topForm']['in_fltno'].value != "") 
    { document.forms['topForm']['in_depstn'].disabled = true;
      document.forms['topForm']['in_arrstn'].disabled = true;
      //document.depbutton.src = butDep_act.src;
      //document.arrbutton.src = butArr_act.src;
    } else
    // DEP&ARR stations are selected
    { if (document.forms['topForm']['in_depstn'].value != "000")
      { 
        document.forms['topForm']['in_fltno'].disabled = true;
        document.forms['topForm']['in_arrstn'].disabled = false;
        
        if (document.forms['topForm']['in_arrstn'].value != "000")
        { 
          //document.depbutton.src = butDep_act.src;
          //document.arrbutton.src = butArr_act.src;
        } else
        { 
          //document.depbutton.src = butDep_out.src;
          //document.arrbutton.src = butArr_out.src;
        }
      } else
      { document.forms['topForm']['in_fltno'].disabled = false;
        document.forms['topForm']['in_depstn'].disabled = false;
        document.forms['topForm']['in_arrstn'].disabled = true;
	//document.depbutton.src = butDep_out.src;
	//document.arrbutton.src = butArr_out.src;
      }
    }
  }
	setTimeout("docEnDis()", 500);
}

function entsub(e) {
  if(e && e.which){
     e = e
     characterCode = e.which
  }else{
     e = event
     characterCode = e.keyCode
  }	

  
  if (characterCode == 13){
     if ((document.forms['topForm']['in_fltno'].value == "") && (document.forms['topForm']['in_depstn'].value == "000") && (document.forms['topForm']['in_arrstn'].value == "000")){
        alert ("You need to enter a flight number or select a flight origin and destination."); 
        return false;
     } else {
        submitDep();
     }
  }    

}

// for switching

function switchTab(tabName) {
	if(tabName == "timetable") {						
		document.getElementById('deparrDiv').style.display = 'none'; 
		document.getElementById('timetableDiv').style.display = 'block'; 						 	
		document.getElementById('timetableDiv').style.height = '100%';
                                document.getElementById('tabframe').className = 'daframe2';
	}
	else if (tabName == "deparr") {
		
		document.getElementById('deparrDiv').style.display = 'block'; 
		document.getElementById('deparrDiv').style.height = '100%';						
		document.getElementById('timetableDiv').style.display = 'none';
                                document.getElementById('tabframe').className = 'daframe';	
	}
}

