
function CheckOK() {
	var strURL;
	var f = document.form1;
	var strTripType;
	var screenW = 800, screenH = 600;

	if (parseInt(navigator.appVersion)>3) {
		screenW = screen.width;
		screenH = screen.height;
	}
	else if (navigator.appName == "Netscape" 
		&& parseInt(navigator.appVersion)==3
		&& navigator.javaEnabled()
	   ) 
	{
		var jToolkit = java.awt.Toolkit.getDefaultToolkit();
		var jScreenSize = jToolkit.getScreenSize();
		screenW = jScreenSize.width;
		screenH = jScreenSize.height;
	}

    
	if (f.txtDepCity.value=="") {
		alert("Please enter the departure city");
		return;
    }

	if (f.txtArrCity.value=="") {
		alert("Please enter the arrival city");
		return;
    }


  strURL='https://wftc3.e-travel.com/plnext/tgpnext/Override.action?LANGUAGE=GB&SITE=CATRCATR&PAYMENT_TYPE=CON&TYPE=AIR_TRIP_FARE&EMBEDDED_TRANSACTION=AirComplexAvailability';


   var NowDate=new Date();
	var one_day=1000*60*60*24 ;
	
	var yeardate = f.lstDepMonth.value ;
	var monthdate = f.lstDepMonth.value ;
	
	var depdate = new Date(yeardate.substr(0,4), monthdate.substr(4,2)-1 , f.lstDepDay.value);
			
	var diffdate=Math.ceil((depdate.getTime()-NowDate.getTime())/(one_day)) ;

			 if ((f.txtDepCity.value!="cgp")&&
				(f.txtDepCity.value!="bwn")&&
				(f.txtDepCity.value!="dme")&&
				(f.txtDepCity.value!="bwn")&&
				(f.txtDepCity.value!="kwi")&&
				(f.txtDepCity.value!="mow")&&
				(f.txtDepCity.value!="dme")&&
				(f.txtDepCity.value!="del")&&
				(f.txtDepCity.value!="bom")&&
				(f.txtDepCity.value!="hyd")&&
				(f.txtDepCity.value!="blr")&&
				(f.txtDepCity.value!="ccu")&&
				(f.txtDepCity.value!="gay")&&
				(f.txtDepCity.value!="maa")&&
				(f.txtDepCity.value!="vns")&&
   			    (f.txtDepCity.value!="rgn"))  {

                   if(f.txtDepCity.value=="mnl") {
                         strURL=strURL+'&SO_SITE_MINIMAL_TIME=H72' ;
                     }
					
                // Below for boarding from cities that eligible for eticket 
                    if (diffdate < 6) {
        				strURL=strURL+'&SO_SITE_MOD_E_TICKET=TRUE&SO_SITE_MOD_PICK_CITY=FALSE';
	                   if((f.txtDepCity.value=="cgk")||(f.txtDepCity.value=="dps")) {
                           strURL=strURL+'&SO_SITE_MINIMAL_TIME=H12' ;
                       }else{
                           if((f.txtDepCity.value=="nrt")||(f.txtDepCity.value=="kix")||(f.txtDepCity.value=="fuk")||(f.txtDepCity.value=="ngo") ||(f.txtDepCity.value=="hnd") ||(f.txtDepCity.value=="tyo")) {
                               strURL=strURL+'&SO_SITE_MINIMAL_TIME=H72&SO_SITE_CURRENCY_FORMAT_JAVA=0';
                           }else{
							   strURL=strURL+'&SO_SITE_MINIMAL_TIME=H6&SO_SITE_TK_TIME_PERIOD=H6&SO_SITE_TK_ARRANGEMENT=TL&SO_SITE_TK_OFFICE_ID=BKKTG08AA' ;
                           }
                       }    
                   //if not < 6 
	               }else{
                          if((f.txtDepCity.value=="nrt")||(f.txtDepCity.value=="kix")||(f.txtDepCity.value=="fuk")||(f.txtDepCity.value=="ngo")||(f.txtDepCity.value=="hnd")||(f.txtDepCity.value=="tyo")) {
                               strURL=strURL+'&SO_SITE_MINIMAL_TIME=H72&SO_SITE_CURRENCY_FORMAT_JAVA=0' ;
                          }else{
                               strURL=strURL+'&SO_SITE_MOP_CALL_ME=TRUE&SO_SITE_MINIMAL_TIME=H12' ;
                          }
                   }
               }else{
	           // Below for boarding from cities that not eligible for eticket  
               alert("For your selected origin"+" \" "+f.txtDepCity[f.txtDepCity.selectedIndex].text+" \" "+", only reservation can be made.  On-line payment cannot be made and electronic ticket cannot be issued on-line through our web site. Please contact THAI ticket office in the country where the journey commences to purchase your ticket.") ;
               strURL=strURL+'&SO_SITE_MOP_EXT=FALSE&SO_SITE_MOP_CALL_ME=TRUE&SO_SITE_MINIMAL_TIME=H72';
               }
			   if((f.txtDepCity.value=="sel")||(f.txtDepCity.value=="pus")||(f.txtDepCity.value=="icn")){
                   strURL=strURL+'&SO_SITE_CURRENCY_FORMAT_JAVA=0';
               }


     f.txtDepDate.value=f.lstDepMonth.value+f.lstDepDay.value+"0000"
     var txtDepDate0 = f.lstDepMonth0.value+f.lstDepDay0.value+"0000"
     var txtDepDate1 = f.lstDepMonth1.value+f.lstDepDay1.value+"0000"
     var txtDepDate2 = f.lstDepMonth2.value+f.lstDepDay2.value+"0000"
     var txtDepDate3 = f.lstDepMonth3.value+f.lstDepDay3.value+"0000"
     var txtDepDate4 = f.lstDepMonth4.value+f.lstDepDay4.value+"0000"

 		var NowDate=new Date();
		var NowYear=""+NowDate.getFullYear();			
						
		
		var NowMonth=setTo2Digits(""+(NowDate.getMonth()+1));
		var NowDay=setTo2Digits(""+NowDate.getDate());
		var NowPLDate=NowYear+NowMonth+NowDay+"0000";
        //alert(strURL)
	
		//if ((f.txtDepDate.value-NowPLDate < 30000) && (strURL != 'https://wftc3.e-travel.com/plnext/tgdv9/AirAvailability.action?LANGUAGE=GB&SITE=CAVDCAVD&PAYMENT_TYPE=CON&TYPE=AIR_TRIP_FARE'))
		//{
		//	if(!confirm("Reservation for multi-city or international must be made at least 72 hours before departure.The flight/date you have selected will depart within less than 72 hours and, therefore, will be inhibited for on-line reservation.However, you may view  schedule information and check if seats are available only."))
		//		return;		
		//}
 

		var NowDate=new Date();
		  var NowYear=""+NowDate.getFullYear();			
						
		
		var NowMonth=setTo2Digits(""+(NowDate.getMonth()+1));
		var NowDay=setTo2Digits(""+NowDate.getDate());
		var NowPLDate=NowYear+NowMonth+NowDay+"0000";

        
	strURL=strURL+'&TRIP_FLOW=YES&TRAVELLER_TYPE_1=ADT&SESSION_ID=&EXTERNAL_ID=NORMAL';	
	//if (f.PaxType2.value!='') {	strURL=strURL+'&TRAVELLER_TYPE_2='+f.PaxType2.value; }	
	//if (f.PaxType3.value!='') {	strURL=strURL+'&TRAVELLER_TYPE_3='+f.PaxType3.value; }	
	//if (f.PaxType4.value!='') {	strURL=strURL+'&TRAVELLER_TYPE_4='+f.PaxType4.value; }		
	
	
	//-- Begin : Kaew edit Traveller dropdown ---------------------
	var nTraveller = 1;
	for(var i=1;i<f.lstTravellerAdults.value;i++) {
		nTraveller++;
		strURL=strURL+"&TRAVELLER_TYPE_"+nTraveller+"=ADT";
	}
	for(var i=0;i<f.lstTravellerChildren.value;i++) {
		nTraveller++;
		strURL=strURL+"&TRAVELLER_TYPE_"+nTraveller+"=CHD";
	}
	//-- End : Kaew edit Traveller dropdown ------------------------
		
		
		f.txtDepDate.value=f.lstDepMonth.value+f.lstDepDay.value+"0000"
		
		strURL=strURL+'&B_DATE_1='+f.txtDepDate.value;
        strURL=strURL+'&B_DATE_2='+txtDepDate0 ;
        strURL=strURL+'&B_DATE_3='+txtDepDate1 ;
        strURL=strURL+'&B_DATE_4='+txtDepDate2 ;
        strURL=strURL+'&B_DATE_5='+txtDepDate3 ;
        strURL=strURL+'&B_DATE_6='+txtDepDate4 ;
        
		strURL=strURL+'&B_ANY_TIME_1=TRUE';
        strURL=strURL+'&B_ANY_TIME_2=TRUE';                                   
	    strURL=strURL+'&B_ANY_TIME_3=TRUE';                                   
	    strURL=strURL+'&B_ANY_TIME_4=TRUE';                                   
        strURL=strURL+'&B_ANY_TIME_5=TRUE';
	    strURL=strURL+'&B_ANY_TIME_6=TRUE';
        

		strURL=strURL+'&B_LOCATION_1='+f.txtDepCity.value;
		strURL=strURL+'&E_LOCATION_1='+f.txtArrCity.value;
		strURL=strURL+'&B_LOCATION_2='+f.txtDepCity0.value;
		strURL=strURL+'&E_LOCATION_2='+f.txtArrCity0.value;
		strURL=strURL+'&B_LOCATION_3='+f.txtDepCity1.value;
		strURL=strURL+'&E_LOCATION_3='+f.txtArrCity1.value;
		strURL=strURL+'&B_LOCATION_4='+f.txtDepCity2.value;
		strURL=strURL+'&E_LOCATION_4='+f.txtArrCity2.value;
		strURL=strURL+'&B_LOCATION_5='+f.txtDepCity3.value;
		strURL=strURL+'&E_LOCATION_5='+f.txtArrCity3.value;
		strURL=strURL+'&B_LOCATION_6='+f.txtDepCity4.value;
		strURL=strURL+'&E_LOCATION_6='+f.txtArrCity4.value;


		var NowDate=new Date();
		var NowYear=""+NowDate.getFullYear();			
						
		
		var NowMonth=setTo2Digits(""+(NowDate.getMonth()+1));
		var NowDay=setTo2Digits(""+NowDate.getDate());
		var NowPLDate=NowYear+NowMonth+NowDay+"0000";
		
	
		var NowDate=new Date();
		var NowYear=""+NowDate.getFullYear();			
						
		
		var NowMonth=setTo2Digits(""+(NowDate.getMonth()+1));
		var NowDay=setTo2Digits(""+NowDate.getDate());
		var NowPLDate=NowYear+NowMonth+NowDay+"0000";
	
  		
	strURL=strURL+'&TRIP_TYPE=M';



	////////////////for  temporary checking city for pricing on BKKTG08CC/////////////////////////////////////////////	   
	//		if ((f.txtDepCity.value =="pnh")||
	//		   (f.txtDepCity.value =="vte")||
	//		   (f.txtDepCity.value =="sgn")||
	//		   (f.txtDepCity.value =="osl")||
	//		   (f.txtDepCity.value =="cmb")||
	//		   (f.txtDepCity.value =="han"))  {
    //               strURL=strURL+'&SO_SITE_OFFICE_ID=BKKTG08CC' ;
	//		}
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
   
	strURL=strURL+'&SO_GL=<?xml%20version=%221.0%22%20encoding=%22iso-8859-1%22?><SO_GL><GLOBAL_LIST%20mode=%22complete%22><NAME>SO_SINGLE_MULTIPLE_COMMAND_BUILDER</NAME><LIST_ELEMENT><CODE>1</CODE><LIST_VALUE><![CDATA[OS YY IP <CLIENT_IP_ADDRESS>]]></LIST_VALUE><LIST_VALUE>S</LIST_VALUE></LIST_ELEMENT></GLOBAL_LIST></SO_GL>';

	strURL = strURL.replace(/LANGUAGE=GB/, g_Param_LANGUAGE);  //Kaew add code

	//strURL=strURL+'&CABIN='+f.CABIN.value;
	  
	//window.navigate(strURL);
    	//screenW=screenW-10;
    	//screenH=screenH;
	//window.open(strURL,'1ARES','location,menubar,resizable,dependent,status,Width=800,Height=600,location,toolbar');
	//window.open(strURL,'1ARES', ' menubar,resizable,status,location,scrollbars,toolbar,left=0,top=0,width=' +  screenW + ',height=' +  screenH + '');
	
	
	//window.open(strURL,"1ARES","toolbar,location,status,resizable,scrollbars,menubar,top=0,left=0,width="+(screen.width*0.99)+",height="+(screen.height*0.78))

	//window.open(strURL,"ebooking","status=yes,toolbar=yes,menubar=yes,resizable,scrollbars,top=0,left=0,width="+(screen.width*0.99)+",height="+(screen.height*0.88))
	window.open(strURL,"1ARES","toolbar,status,resizable,scrollbars,top=0,left=0,width="+(screen.width*0.99)+",height="+(screen.height*0.88))

	// window.open("","1ARES","toolbar,status,resizable,scrollbars,top=0,left=0,width="+(screen.width*0.99)+",height="+(screen.height*0.88));
	// document.forms['tripflowForm'].elements['tripflow'].value = strURL;
	// document.forms['tripflowForm'].submit();
}



window.onload = function() {
	var f = document.form1;
	setTravellerDropDown(null);
	setCityDropDown(f.txtDepCity, g_Inter_CityList['full'], 0);
	setCityDropDown(f.txtArrCity, g_Inter_CityList['full'], 0);	
	setDateMonthDropDown(f.lstDepDay, f.lstDepMonth);
	
	for(var i=0;i<=4;i++) {
		setCityDropDown(eval("f.txtDepCity"+i), g_Inter_CityList['full'], 0);
		setCityDropDown(eval("f.txtArrCity"+i), g_Inter_CityList['full'], 0);
		setDateMonthDropDown(eval("f.lstDepDay"+i), eval("f.lstDepMonth"+i));
	}
		

}
