
function bookISIS( originPoint0 , destinationPoint0 , bookingClass , tripType , tripStartDate ,tripStartMonth ,  tripStartYear , searchType , promocode, adult, children, infants)
{

	var a =  'IS_DO';
	var b =  tripType;
	var c =  originPoint0;
	var d =  destinationPoint0;
	var e =  tripStartDate+'/'+tripStartMonth+'/'+tripStartYear;
	var f =  '';
	var g =  bookingClass;
	var h =  searchType;
	var i = promocode;
	var j = adult;
	var k = children;
	var l = infants;

	if (!tripStartDate && !tripStartMonth && !tripStartYear)
		{
		 e = '';
		}

	SendToFD('2',a,b,c,d,e,f,g,h,null,j,k,l,null,null,null,null,null,i);	
}

function checkPromoCode() {
	
	if(document.getElementById("flightsRadio")) {
		if(document.getElementById("flightsRadio").checked) {
			if(document.getElementById("promoCodeFFF")) {
				setPromoCode(document.getElementById("promoCodeFFF").value);
			} else {
				setPromoCode("");
			}
		} else if(document.getElementById("hotelsRadio") && document.getElementById("hotelsRadio").checked) {
			if(document.getElementById("promoCodeHotel")) {
				setPromoCode(document.getElementById("promoCodeHotel").value);
			} else {
				setPromoCode("");
			}
		} else if(document.getElementById("holidaysRadio") && document.getElementById("holidaysRadio").checked) {
			if(document.getElementById("promoCodeOLH")) {
				setPromoCode(document.getElementById("promoCodeOLH").value);
			} else {
				setPromoCode("");
			}
		}
	} else {
		if(document.getElementById("promoCodeFFF")) {
			setPromoCode(document.getElementById("promoCodeFFF").value);
		} else {
			setPromoCode("");
		}	
	}
}

function setPromoCode(value) {
	if(document.getElementById("s_promoCode")) {
		document.getElementById("s_promoCode").value = value;
	}
}

function SendToFD(ID,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,promocode) {

	checkPromoCode();
	checkHotelPackage();
	if (ID == '1') {	

		var prefix = a;
		var bookingWindow = window.open("about:blank", "booking", "", ""); 
		bookingWindow.focus();
		if (prefix == "h_")
		{
			document.getElementById("prefix").value = "h_";
		}
		try {
			if (isKioskBooking) {document.getElementById("finder_type").value = "FFFAgent";}
		} catch(E) { 
		
		}
		document.getElementById("FFFsendForm").action = SendString;
		document.getElementById("FFFsendForm").submit();
	}
					

					
			//--- BN / PP ---------------------------------------------------------		
				if (ID == '2')
					{	
						var engine = a;
						if (engine == "VO")
						{
										var cityPair = b;
										var programId = c;	
										var locale = getLocale();
								
										SendString = SendStringORG;
										SendString = SendString + '?engine=' 		+ engine;
										SendString = SendString + '&finder_type=BNPP';
										SendString = SendString + '&locale=' 		+ locale;
										SendString = SendString + '&cityPair=' 		+ cityPair;
										SendString = SendString + '&programId=' 	+ programId;
					
						}
						else
						{
										var fare_type 		= b;
										var depart_loc 		= c;
										var arrival_loc 	= d;
										var TripStart_ARRAY	= e.split("/");
										var TripEnd_ARRAY	= f.split("/");					
										var service_class 	= g;
										var SearchType 		= h;
										var iata 			= i;
										var adults 			= j;
										var children 		= k;
										var infants 		= l;
										var cityPair 		= m;
										var programId 		= n;
										
										var locale = getLocale();
					
										var depart_date;
										var depart_yearmonth;			
										var tripStartDate   = TripStart_ARRAY[0];
										var tripStartMonth  = TripStart_ARRAY[1];
										var tripStartYear   = TripStart_ARRAY[2];
					
										var arrival_date;
										var arrival_yearmonth;			
										var tripEndDate   	= TripEnd_ARRAY[0];
										var tripEndMonth  	= TripEnd_ARRAY[1];
										var tripEndYear   	= TripEnd_ARRAY[2];						
											
												
												if (tripStartYear && tripStartMonth && tripStartDate)
													{
														var tripDate = new Date();
														tripDate.setFullYear(tripStartYear, tripStartMonth-1, tripStartDate);
					
														var CurrentDate = new Date();
											
														if (CurrentDate > tripDate)
															{
															tripDate 			= CurrentDate
															tripDate.setDate(tripDate.getDate()+1)
															tripStartYear		= tripDate.getFullYear()
															tripStartMonth		= tripDate.getMonth()
															tripStartDate		= tripDate.getDate()				
															}
														
															
														depart_date 			= tripDate.getDate();
														depart_yearmonth 		= tripDate.getFullYear() + "-" + parseInt(tripDate.getMonth()+1);
					
														if (fare_type == "return" && (!tripEndYear || !tripEndMonth || !tripEndDate))
														{
															var endDate = new Date()
															
															endDate.setDate(tripDate.getDate());	
															endDate.setMonth(tripDate.getMonth());
															endDate.setYear(tripDate.getFullYear());
					
															endDate.setDate(endDate.getDate()+1);
					
															arrival_date		= endDate.getDate();
															arrival_yearmonth 	= endDate.getFullYear() + "-" + parseInt(endDate.getMonth()+1);
														}
														else if (fare_type == "return")
														{
															arrival_date		= tripEndDate;
															arrival_yearmonth 	= tripEndYear + "-" + tripEndMonth;
														}							
													}
					
										 SendString = SendStringORG;
										 SendString = SendString + '?engine=' + engine;
										 SendString = SendString + '&finder_type=BNPP';
										 SendString = SendString + '&locale=' + locale;
										 SendString = SendString + '&fare_type=' + fare_type;
										 
										 if(typeof(depart_loc) 			!= "undefined" || depart_loc == "")			{SendString = SendString + '&depart_loc=' + depart_loc;}
										 if(typeof(arrival_loc) 		!= "undefined" || arrival_loc == "")		{SendString = SendString + '&arrival_loc=' + arrival_loc;}
										 if(typeof(depart_date) 		!= "undefined" || depart_date == "")		{SendString = SendString + '&depart_date=' + depart_date;}
										 if(typeof(depart_yearmonth) 	!= "undefined" || depart_yearmonth == "")	{SendString = SendString + '&depart_yearmonth=' + depart_yearmonth;}
										 if(typeof(arrival_date) 		!= "undefined" || arrival_date == "")		{SendString = SendString + '&arrival_date=' + arrival_date;}
										 if(typeof(arrival_yearmonth) 	!= "undefined" || arrival_yearmonth == "")	{SendString = SendString + '&arrival_yearmonth=' + arrival_yearmonth;}
										 if(typeof(adults) 				!= "undefined" || adults == "")				{SendString = SendString + '&adults=' + adults;}
										 if(typeof(children) 			!= "undefined" || children == "")			{SendString = SendString + '&children=' + children;}
										 if(typeof(infants) 			!= "undefined" || infants == "")			{SendString = SendString + '&infants=' + infants;}
										 if(typeof(service_class) 		!= "undefined" || service_class == "")		{SendString = SendString + '&service_class=' + service_class;}
										 if(typeof(SearchType) 			!= "undefined" || SearchType == "")			{SendString = SendString + '&searchType=' + SearchType;}
										 if(typeof(iata) 				!= "undefined" || iata == "")				{SendString = SendString + '&iata=' + iata;}
										 if(typeof(promocode) 			!= "undefined" || promocode == "")			{SendString = SendString + '&promoCode=' + promocode;}
						
						}				
						var bookingWindow = window.open("about:blank", "ISISbooking", "", ""); 
						bookingWindow.focus();
						document.getElementById("BNPP").action = SendString;
						document.getElementById("BNPP").submit();
					
					}
					

				
					
			//--- FC ---------------------------------------------------------		
				if (ID == '3')
					{
					

					var fare_type 		= a;	
					var depart_loc 		= b;
					var arrival_loc 	= c;
					var depart_reg 		= d;
					var arrival_reg 	= e;
					
					var locale = getLocale();

					 SendString = SendStringORG;
					 SendString = SendString + '?finder_type=FFF';
					 SendString = SendString + '&locale=' + locale;
					 SendString = SendString + '&fare_type=' + fare_type;
					 SendString = SendString + '&depart_loc=' + depart_loc;
					 SendString = SendString + '&arrival_loc=' + arrival_loc;



				var bookingWindow = window.open("about:blank", "ISISbooking", "", ""); 
						bookingWindow.focus();

						document.getElementById("BNPP").action = SendString;
						document.getElementById("BNPP").submit();

						
					}
		
	}
	
function checkHotelPackage() {
	if(document.getElementById("holidaysRadio") && document.getElementById("holidaysRadio").checked) {
		document.getElementById("s_h_depart_loc").value = document.getElementById("h_depart_loc").value;
		document.getElementById("s_h_arrival_loc").value = document.getElementById("h_arrival_loc").value;
		document.getElementById("s_h_depart_date").value = document.getElementById("h_depart_date").value;
		document.getElementById("s_h_depart_yearmonth").value = document.getElementById("h_depart_yearmonth").value;
		document.getElementById("s_h_arrival_date").value = document.getElementById("h_arrival_date").value;
		document.getElementById("s_h_arrival_yearmonth").value = document.getElementById("h_arrival_yearmonth").value;
		document.getElementById("s_numOfNights").value = document.getElementById("h_numOfNights").value;
		document.getElementById("s_numOfTravellers").value = document.getElementById("h_numOfTravellers").value;
		document.getElementById("s_ageOfChild_1").value = document.getElementById("h_ageOfChild_1").value;
		document.getElementById("s_ageOfChild_2").value = document.getElementById("h_ageOfChild_2").value;
		document.getElementById("s_ageOfChild_3").value = document.getElementById("h_ageOfChild_3").value;
		document.getElementById("s_ageOfChild_4").value = document.getElementById("h_ageOfChild_4").value;
		document.getElementById("s_ageOfChild_5").value = document.getElementById("h_ageOfChild_5").value;
	} else if(document.getElementById("hotelsRadio") && document.getElementById("hotelsRadio").checked) {
		document.getElementById("s_h_depart_loc").value = "";
		document.getElementById("s_h_arrival_loc").value = document.getElementById("hh_arrival_loc").value;
		document.getElementById("s_h_depart_date").value = document.getElementById("hh_depart_date").value;
		document.getElementById("s_h_depart_yearmonth").value = document.getElementById("hh_depart_yearmonth").value;
		document.getElementById("s_h_arrival_date").value = document.getElementById("hh_arrival_date").value;
		document.getElementById("s_h_arrival_yearmonth").value = document.getElementById("hh_arrival_yearmonth").value;
		document.getElementById("s_numOfNights").value = document.getElementById("hh_numOfNights").value;
		document.getElementById("s_numOfTravellers").value = document.getElementById("hh_numOfTravellers").value;
		document.getElementById("s_ageOfChild_1").value = document.getElementById("hh_ageOfChild_1").value;
		document.getElementById("s_ageOfChild_2").value = document.getElementById("hh_ageOfChild_2").value;
		document.getElementById("s_ageOfChild_3").value = document.getElementById("hh_ageOfChild_3").value;
		document.getElementById("s_ageOfChild_4").value = document.getElementById("hh_ageOfChild_4").value;
		document.getElementById("s_ageOfChild_5").value = document.getElementById("hh_ageOfChild_5").value;

		document.getElementById("finder_type").value = "OLH-H01"
	}
}
