﻿/*JS-VERSION:2.4.0.0*/
/***************************************************** START FLIGHT ******************************************************/

function submitMethodStandard(msg, valid, isMore){
   validateMethodStanard(msg, valid, isMore);
}
/*rosh:13.03.07: validate method for standard search*/
function validateMethodStanard(msg, valid, isMore){
	try	{
		var request = submitUrlSwiss;
		request += '&BOOKBY=SP';
		request += '&Origin=' + encodeURIComponent($('Origin').value);
		request += '&Destination=' + encodeURIComponent($('Destination').value);
		request += '&depart=' + $('depart').value; 
		request += '&inbound=' + $('inbound').value;
		request += '&flex=' + $('flex').value;
		request += '&OutboundFlex=' + $('flex').value;
		request += '&InboundFlex=' + $('flex').value;
		request += '&Adults=' + $('adults').value;
		request += '&Children=' + $('children').value;
		request += '&Infants=' + $('children2').value;
		request += '&AIRLINE=' + 'LX';
		request += '&OutboundClass=' + $('OutboundClass').value;
		
		request += '&DirectFlightsOnly=' + 'true';
		if(!isMore)
		{
			request += '&submit.x=' + 'true';
			request += '&submit.y=' + 'true';
		}
		
		/*partner id's which are transferred to booking engine*/
		if(queryString('mlid') != 'false')
		{
			request += '&mlid=' + queryString('mlid');
		}
			
		if(queryString('pnid') != 'false')
		{
			request += '&mlid=' + queryString('mlid');
		}
		
		location.href = request;
	} 
	catch(ex)
	{
		if(debugMode)
		{
			alert(errorCatchHandler(ex));
		}
	}
}
/***************************************************** END FLIGHT ******************************************************/
/***************************************************** START HOTEL ******************************************************/
function validateMethodHotels(){	
	try	
	{
		var eleId = getRadioSelection('searchtypeHotel');
		if($('locationHotel') && $('locationHotel').value == '' && eleId == 'searchtypeHotel1')
		{
		    $('formerrorAccommodationDiv').style.visibility = 'visible';
		    $('formerrorAccommodation').innerHTML = KuoniErrorLocation;
		}
		else
		{
		    if(eleId == '')
		    {
			    eleId = 'searchtypeHotel1';
			    //eleId = 'none';
    			
			    $('formerrorAccommodationDiv').style.visibility = 'visible';
			    $('formerrorAccommodation').innerHTML = ErrorAffiliate;
			    
		    }		
		    if(eleId)
		    {
			    switch(eleId)
			    {
				    case "searchtypeHotel1":
				    {
				        $('formerrorAccommodationDiv').style.visibility = 'hidden';
					    kuoniHandler('qs');
					    break;
				    }
				    case "searchtypeHotel2":
				    {
				        $('formerrorAccommodationDiv').style.visibility = 'hidden';
					    stcHandler();
					    break;
				    }
			    }
		    }
		}
		return false;
	}
	catch(ex)
	{
		if(debugMode)
			alert(errorCatchHandler(ex));
	}
}

/*metm:03.03.09: KHI quicksearch  integration handler*/
function kuoniHandler(reference){
	try	{
		var children = $('hotelChildren').options[$('hotelChildren').selectedIndex].value;
	    var adults = $('hotelAdults').options[$('hotelAdults').selectedIndex].value;
	    var rooms = $('rooms').options[$('rooms').selectedIndex].value;
	    var waitscreenForwardUri = 'Loader.aspx?page=Khi&ref=qs'; 
		var location = getCleanedLocation($('locationHotel').value, 'KUONI');
		var url = submitUrlKuoni;
	    var isWaitscreen = false;
		var urlParams;
		
        var protocol = 'http';
        if (window.location.protocol == 'https:') {
	        protocol = 'https';
        }
		
		var language = getLanguage();
		if(!language || language=='')
		{
			language = 'EN';
	    }
	    
	    var ref = reference;	    
	    if(ref == 'qs')
	    {
	        if(children == '0' && parseInt(adults) < 5 && rooms == '1')
	        {   
	            ref = 'ws';
	            isWaitscreen = true;
	        }        
	    }
		
		url += "page=Khi&ref=" + ref;
		
		urlParams = "&des=" + location;
	    urlParams += "&cki=" + $('checkin').value;
	    urlParams += "&cko=" + $('checkout').value;
	    urlParams += "&rqr=" + rooms;
	    urlParams += "&rqa=" + adults;
	    urlParams += "&rqc=" + children;
	    urlParams += "&lng=" + language;
		    
		if(!isWaitscreen)
		{   		
		    url = unescape(submitUrlKuoniTrack) + escape(url + urlParams);
		}else
		{
		    url += '&fwd=' + escape(waitscreenForwardUri + urlParams);
		}
		
		url = url.replace(/</g, '');
        url = url.replace(/>/g, '');
        
		window.location.href = url;
	}
	catch(ex)
	{
		if(debugMode)
		{
			alert(errorCatchHandler(ex));
		}
	}
}

function hotelsComHandler(){
	try	{
	    var location = $('locationHotel').value;
	    location = getCleanedLocation(location, 'HOTELSCOM');
	    
		var language = getLanguage();
		if(!language || language=='')
		{
			language = 'EN';
	    }
		
		var ProtocolHotels = 'http';
	    if (window.location.protocol == 'https:') {
		    ProtocolHotels = 'https';
	    }
		var url = ProtocolHotels + submitUrlAffiliates;
		
		
		url += "target=hotels&action=redirect";
		url += "&language=" + language;
		url += "&fromDate=" + $('checkin').value;
		url += "&toDate=" + $('checkout').value;
		url += "&rooms=" + $('rooms').options[$('rooms').selectedIndex].value;
		url += "&adults=" + $('hotelAdults').options[$('hotelAdults').selectedIndex].value;
		url += "&childs=" + $('hotelChildren').options[$('hotelChildren').selectedIndex].value;
	    url += "&location=" + location;
		url = unescape(url);
		
		url = url.replace(/</g, '');
        url = url.replace(/>/g, '');

		/*open the new window and set the focus.*/	
		openWindow(url, true);
	}
	catch(ex)
	{
		if(debugMode)
		{
			alert(errorCatchHandler(ex));
		}
	}
}

function stcHandler()
{
	try	{
	    var location = $('locationHotel').value;
	    location = getCleanedLocation(location, 'MYSWITZERLAND');
	    
		var language = getLanguage();
		if(!language || language=='')
		{
			language = 'EN';
	    }
		
		var ProtocolSTC = 'http';
	    if (window.location.protocol == 'https:') {
		    ProtocolSTC = 'https';
	    }
		var url = ProtocolSTC + submitUrlAffiliates;
		

		
		url += "target=myswitzerland&action=redirect";
		url += "&language=" + language;
		url += "&fromDate=" + $('checkin').value;
		url += "&toDate=" + $('checkout').value;
		url += "&rooms=" + $('rooms').options[$('rooms').selectedIndex].value;
		url += "&adults=" + $('hotelAdults').options[$('hotelAdults').selectedIndex].value;
		url += "&childs=" + $('hotelChildren').options[$('hotelChildren').selectedIndex].value;
	    url += "&location=" + location;
		url = unescape(url);
		
	    url = url.replace(/</g, '');
        url = url.replace(/>/g, '');
		
		/*open the new window and set the focus.*/	
		openWindow(url, true);
	}
	catch(ex)
	{
		if(debugMode)
		{
			alert(errorCatchHandler(ex));
		}
	}
}

/***************************************************** END HOTEL ******************************************************/
/***************************************************** START RENTAL CAR ******************************************************/
function validateMethodRentalCar()
{	
	try	
	{
		var eleId = getRadioSelection('searchtypeRental');
		if($('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive') && $('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive').options[$('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive').selectedIndex].value == '')
		{
		    $('formerrorRentalDiv').style.visibility = 'visible';
		    $('formerrorRental').innerHTML = ErrorResidence;
		}
		else
		{		    
		    if(eleId == '')
		    {
			    eleId = 'none';
    			
			    $('formerrorRentalDiv').style.visibility = 'visible';
			    $('formerrorRental').innerHTML = ErrorAffiliate;
			    
		    }		
		    if(eleId)
		    {	    
			    switch(eleId)
			    {
				    case "searchtypeRental1":
				    {
				        $('formerrorRentalDiv').style.visibility = 'hidden';
					    avisHandler(selectionLanguage, selectionCountry);
					    break;
				    }
				    case "searchtypeRental2":
				    {
				        $('formerrorRentalDiv').style.visibility = 'hidden';
					    europcarHandler(selectionLanguage, selectionCountry);
					    break;
				    }
				    case "searchtypeRental3":
				    {
				        $('formerrorRentalDiv').style.visibility = 'hidden';
					    sixtHandler(selectionLanguage, selectionCountry);
					    break;
				    }
			    }
		    }
		}
		return false;
	}
	catch(ex)
	{
		if(debugMode)
			alert(errorCatchHandler(ex));
	}
}

/* rosh: 17.04.06: handling europcar merchant*/
function europcarHandler(language, country)
{
        var location = $('locationRental').value;
        location = getCleanedLocation(location, 'EUROPCAR');
        
	    var language = getLanguage();
		if(!language || language=='')
		{
			language = 'EN';
	    }
		
		var ProtocolEuropcar = 'http';
	    if (window.location.protocol == 'https:') {
		    ProtocolEuropcar = 'https';
	    }
		var url = ProtocolEuropcar + submitUrlAffiliates;
		
		url += "target=europcar&action=redirect";
		url += "&language=" + language;
		url += "&fromDate=" + $('pickupDate').value;
		url += "&toDate=" + $('returnDate').value;
		url += "&fromTime=" + $('departtime').options[$('departtime').selectedIndex].value; 
		url += "&toTime=" + $('arrivetime').options[$('arrivetime').selectedIndex].value; 
		url += "&miles=" + milesAndMoreEuropcar[$('miles').options[$('miles').selectedIndex].value];
		
		if($('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive'))
		{
		    url += "&youlive=" + $('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive').options[$('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive').selectedIndex].value;
		}
		
		url += "&location=" + location;

		url = unescape(url);
		
	    url = url.replace(/</g, '');
        url = url.replace(/>/g, '');
	
		/*open the new window and set the focus.*/	
		openWindow(url, true);
}

/* rosh: 17.04.06: handling avis merchant*/
function avisHandler(language, country)
{
        var location = $('locationRental').value;
        location = getCleanedLocation(location, 'AVIS');
        
		var language = getLanguage();
		if(!language || language=='')
		{
			language = 'EN';
	    }
		
		var ProtocolAvis = 'http';
	    if (window.location.protocol == 'https:') {
		    ProtocolAvis = 'https';
	    }
		var url = ProtocolAvis + submitUrlAffiliates;
		
		url += "target=avis&action=redirect";
		url += "&language=" + language;
		url += "&fromDate=" + $('pickupDate').value;
		url += "&toDate=" + $('returnDate').value;
		url += "&fromTime=" + $('departtime').options[$('departtime').selectedIndex].value; 
		url += "&toTime=" + $('arrivetime').options[$('arrivetime').selectedIndex].value; 
		url += "&miles=" + milesAndMoreAvis[$('miles').options[$('miles').selectedIndex].value];
		
		if($('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive'))
		{
		    url += "&youlive=" + $('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive').options[$('ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive').selectedIndex].value;
		}
		
	    url += "&location=" + location;

	    url = unescape(url);

		url = url.replace(/</g, '');
        url = url.replace(/>/g, '');
        
		/*open the new window and set the focus.*/	
		openWindow(url, true);
}

/*once sixt is available as affiliate, this function has to be written */
function sixtHandler(language, country)
{
}
/***************************************************** END RENTAL CAR ******************************************************/

/***************************************************** START TOGGLE SCREEN DETAILS ******************************************************/
/*rosh:13.03.07: toggles between search selection on start site*/
function toggleSearchSelection(ele)
{
	runToggleDIVCalendar(false, null);
	
	switch(ele.id)
	{				
		case "searchtype1":
		{
			/* handle case for 'standardSearch'*/
			$('searchtype1').checked=true;					
			$('standardSearch').style.display = "";
			$('oneClickSearch').style.display = "none";
			
			$('fpssalternateContainerFlash').style.display = 'none';
			$('fpss-alternateContainer').style.display = 'none';
			$('presenternavi').style.display = '';
			$('fpss-container').style.display = '';
			
			break;
		}
		case "searchtype2":
		{
			/* handle case for 'oneClickSearch'*/
			$('searchtype2').checked=true;
			$('standardSearch').style.display = "none";
			$('oneClickSearch').style.display = "";
			break;
		}
		case "searchtype3":
		{			
			/* handle case for 'worldMapSearch'*/
			$('searchtype3').checked=true;
			$('standardSearch').style.display = "";
			$('oneClickSearch').style.display = "none";
			
			$('tabFlightContent').style.display = '';
			$('tabHotelContent').style.display = 'none';
			$('tabRentalCarContent').style.display = 'none';
			$('fpss-alternateContainer').style.display = 'none';
			$('presenternavi').style.display = 'none';
			$('fpss-container').style.display = 'none';
			
			$('fpssalternateContainerFlash').style.display = "";
			
			break;
		}
		case "searchtypeRental1":
		{
			$('searchtypeRental1').checked=true;
		    $('formerrorRentalDiv').style.visibility = 'hidden';
			break;
		}
		case "searchtypeRental2":
		{
			$('searchtypeRental2').checked=true;
			$('formerrorRentalDiv').style.visibility = 'hidden';
			break;
		}
		case "searchtypeRental3":
		{
			$('searchtypeRental3').checked=true;
			$('formerrorRentalDiv').style.visibility = 'hidden';
			break;
		}
		case "searchtypeHotel1":
		{
			$('searchtypeHotel1').checked=true;
			$('formerrorAccommodationDiv').style.visibility = 'hidden';
			break;
		}
		case "searchtypeHotel2":
		{
			$('searchtypeHotel2').checked=true;	
			$('formerrorAccommodationDiv').style.visibility = 'hidden';
			break;
		}
		case "ctl00_PlaceHolderMain_SwissSearchBox1_ddlYouLive":
		{
		    $('formerrorRentalDiv').style.visibility = 'hidden';
		}
		default:
		{
			ele.checked = true;
		}
	}
}
/*rosh:13.03.07: toggles between tabs on start site*/
function switchTab(ele)
{
	var protocol = 'http';
    if (window.location.protocol == 'https:') 
    {
        protocol = 'https';
    }
	/* welcome screen */
	if(ele == 'show')
	{
		if(readCookie("welcomeScreen")=="true")
		{
			return;
		}
		else
		{
			/*stop presenter - per default it starts*/
			createCookie("com_jw_fpss", "false",365);
			
			var welcomeScreenImage = new Image();
			welcomeScreenImage.src = protocol+'://www.swiss.com/Data/PresenterPictures/welcome_default.jpg';

			$('tabFlight').className = 'active';
			$('tabHotel').className = '';
			$('tabRental').className = '';
			
			$('tabFlightContent').style.display = '';
			$('tabHotelContent').style.display = 'none';
			$('tabRentalCarContent').style.display = 'none';
			$('fpss-alternateContainer').style.display = '';
			$('presenternavi').style.display = 'none';
			$('fpss-container').style.display = 'none';
			$('alternateContainerImage').src = welcomeScreenImage.src;			
			$('fpssalternateContainerFlash').style.display = "none";
				
			createCookie("welcomeScreen","true",365);
			window.setTimeout('switchTab(\"hide\")', 3000)
		}
	}
	else if(ele == 'hide')
	{
			$("tabFlight").className = 'active';
			$('tabHotel').className = '';
			$('tabRental').className = '';
			
			$('tabFlightContent').style.display = '';
			$('tabHotelContent').style.display = 'none';
			$('tabRentalCarContent').style.display = 'none';
			$('fpss-alternateContainer').style.display = 'none';
			$('presenternavi').style.display = '';
			$('fpss-container').style.display = '';
			
			/*start presenter - per default it starts*/
			createCookie("com_jw_fpss", "true",365);
			if(typeof(playButtonClicked) != 'undefined')
			{
				playButtonClicked();
			}
			
	}
	runToggleDIVCalendar(false, null);
	
	if($('alternateContainerImage'))
    {
	    $('alternateContainerImage').onclick = null;
	    $('alternateContainerImage').style.cursor='default';
    }
    
	switch(ele.id)
	{
		case "tabFlight":
		{
		    getDataFromFlight(ele.id);
			$("tabFlight").className = 'active';
			$('tabHotel').className = '';
			$('tabRental').className = '';
			
			$('tabFlightContent').style.display = '';
			$('tabHotelContent').style.display = 'none';
			$('tabRentalCarContent').style.display = 'none';
			$('fpss-alternateContainer').style.display = 'none';
			$('presenternavi').style.display = '';
			$('fpss-container').style.display = '';
			$('searchtype1').checked = true;
			setDataFromFlight(ele.id);
			break;
		}
		case "tabHotel":
		{
		    $('formerrorAccommodationDiv').style.visibility = 'hidden';
		    CloseAllHelpBoxes();
		    
			getDataFromFlight(ele.id);
			/*rosh:14.04.07:preaload alternate images for hotel*/
			var hotelImage = new Image();
			if(selectionLanguage)
			{
				hotelImage.src = protocol+'://www.swiss.com/Data/PresenterPictures/kuoni_648x254_'+selectionLanguage+'.jpg';
			}
			else if (getLanguage())
			{			
				hotelImage.src = protocol+'://www.swiss.com/Data/PresenterPictures/kuoni_648x254_'+getLanguage()+'.jpg';				
			}
			else
			{
				hotelImage.src = protocol+'://www.swiss.com/Data/PresenterPictures/kuoni_648x254_EN.jpg';
			}
			
			var ProtocolKhi = 'http';
	        if (window.location.protocol == 'https:') {
		        ProtocolKhi = 'https';
	        }
				
			$('tabFlight').className = '';
			$('tabHotel').className = 'active';
			$('tabRental').className = '';
			
			$('tabFlightContent').style.display = 'none';
			$('tabHotelContent').style.display = '';
			$('tabRentalCarContent').style.display = 'none';
			$('fpss-alternateContainer').style.display = '';
			$('presenternavi').style.display = 'none';
			$('fpss-container').style.display = 'none';
			
			$('alternateContainerImage').src = hotelImage.src;
			$('alternateContainerImage').style.cursor='pointer';
			$('alternateContainerImage').onclick = function() {document.location.href=submitUrlKuoni+'Page=KHI'}			
			
			$('fpssalternateContainerFlash').style.display = "none";
			
			$('searchtypeHotel1').checked = true;
			
			setDataFromFlight(ele.id);
			break;
		}
		case "tabRental":
		{
		    $('formerrorRentalDiv').style.visibility = 'hidden';
			getDataFromFlight(ele.id);
			/*rosh:14.04.07:preaload alternate images for car*/
			var carImage = new Image();
			if(selectionLanguage)
			{
				carImage.src = protocol+'://www.swiss.com/Data/PresenterPictures/car_rental_'+selectionLanguage+'.jpg';
			}
			else if (getLanguage())
			{
				carImage.src = protocol+'://www.swiss.com/Data/PresenterPictures/car_rental_'+getLanguage()+'.jpg';
			}
			else
			{
				carImage.src = protocol+'://www.swiss.com/Data/PresenterPictures/car_rental_EN.jpg';
			}

			$('tabFlight').className = '';
			$('tabHotel').className = '';
			$('tabRental').className = 'active';
			
			$('tabFlightContent').style.display = 'none';
			$('tabHotelContent').style.display = 'none';
			$('tabRentalCarContent').style.display = '';
			$('fpss-alternateContainer').style.display = '';
			$('presenternavi').style.display = 'none';
			$('fpss-container').style.display = 'none';
			$('alternateContainerImage').src = carImage.src;			
			
			$('fpssalternateContainerFlash').style.display = "none";
			
			setDataFromFlight(ele.id);
			break;
		}
	}
}
/***************************************************** END TOGGLE SCREEN DETAILS ******************************************************/

/****************************** START COPY DATA ************************************/
/*rosh:16.03.07: copy data from local variables to html elements*/
function setDataFromFlight(tabName)
{
	switch(tabName)
	{
		case "tabHotel":
		{
			$('checkin').value	 = formOutbound;
			$('checkout').value	 = formInbound;
			break;
		}
		case "tabRental":
		{
			$('pickupDate').value	 = formOutbound;
			$('returnDate').value	 = formInbound;
			break;
		}
		case "tabFlight":
		{
			$('Destination').value = formDestination;
			$('depart').value	 = formOutbound;
			$('inbound').value	 = formInbound;
			setDropDownValue($('adults'),formAdult);
			setDropDownValue($('children'),formChildern);
			break;
		}
	}
}
/*rosh:16.03.07: save user input to local variables.*/
function getDataFromFlight(tabName)
{
	formDestination     = $('Destination').value;
	formAdult				= $('adults').options[$('adults').selectedIndex].value;
	formChildern		= $('children').options[$('children').selectedIndex].value;


    /*Source tab == Hotels*/
    if(document.getElementById("tabHotel") != null && document.getElementById("tabHotel").className == "active")
    {
       formOutbound    = $('checkin').value;
       formInbound    = $('checkout').value;
    }
    /*Source tab == Cars*/
    else if(document.getElementById("tabRental") != null && document.getElementById("tabRental").className == "active")
    {
       formOutbound    = $('pickupDate').value;
       formInbound    = $('returnDate').value;
    }
    /*Source tab == Flights*/
    else
    {
        if(document.getElementById("tabFlight") != null)
        {
            formOutbound    = $('depart').value;
            formInbound    = $('inbound').value;
        }
    }
}
/****************************** END COPY DATA ************************************/
/****************************** START PRE-FILL FUNCTIONS ************************************/
/*ROSH: 20.04.2007: check if booking engine has set */
function checkCookie4Parameters()
{
	var name = "travelDates";
	
	if( readCookie(name) )
	{
		try
		{
			if( getCookieValue('Origin',readCookie(name) ) != 'false')
				$('Origin').value = getCookieValue('Origin',readCookie(name));
				
			if(getCookieValue('Destination',readCookie(name) ) != 'false')
				$('Destination').value = getCookieValue('Destination',readCookie(name));

			if(getCookieValue('Adults',readCookie(name) ) != 'false')
				setDropDownValue($('adults'), getCookieValue('Adults',readCookie(name)));
				
			if(getCookieValue('Children',readCookie(name) ) != 'false')
				setDropDownValue($('children'), getCookieValue('Children',readCookie(name)));
			
			if(getCookieValue( 'Infants',readCookie(name) ) != 'false')
				setDropDownValue($('children2'), getCookieValue('Infants',readCookie(name)));
		
			var dateValue = unescape( getCookieValue('OutboundDate',readCookie(name))  ).split('.');
			
			if(dateValue && dateValue.length)
			{
				cal1.calendar(null, parseInt(dateValue[1]), parseInt(dateValue[0]), cal1.id);
				cal1.showSpecificCal('select_'+cal1.id, parseInt(dateValue[1]));
				cal1.setSelected($(cal1.id+'_possibleSlelecteDay_'+parseInt(dateValue[0])), parseInt(dateValue[0]));
			}			
			dateValue = null;
			var dateValue = unescape( getCookieValue('InboundDate',readCookie(name))  ).split('.');
			if(dateValue && dateValue.length)
			{
				cal2.calendar(null, parseInt(dateValue[1]), parseInt(dateValue[0]), cal2.id);
				cal2.showSpecificCal('select_'+cal2.id, parseInt(dateValue[1]));
				cal2.setSelected($(cal2.id+'_possibleSlelecteDay_'+parseInt(dateValue[0])), parseInt(dateValue[0]));
			}	
		}
		catch(ex)
		{
			if(debugMode)
			{
				alert(errorCatchHandler(ex));
			}
		}
	}
}


/*ROSH: 20.04.2007: Check if URI contains parameters which the functin is able to prefill on search form for flights*/
function checkUri4Parameters()
{
	try
	{
		/* sample querystring: http://swrbslcms01:8086/web/DE/Pages/index.aspx?from=ZRH&to=JFK&depm=08&depd=14&retm=09&retd=20&adults=1&childern=0&infants=0 */
		if(queryString('from') != 'false')
		{
			$('Origin').value = queryString('from');
		}
		if(queryString('to') != 'false')
		{
			$('Destination').value = queryString('to');
		}	
		if(queryString('depd') != 'false' &&  queryString('depm') != 'false')
		{
			$('depart').value = queryString('depd') + '.' + queryString('depm');
		}	
		if(queryString('retm') != 'false' && queryString('retd') != 'false')
		{
			$('inbound').value = queryString('retd') + '.' + queryString('retm');
		}		
		if(queryString('adults') != 'false')
		{
			setDropDownValue($('adults'), queryString('adults'));
		}	
		if(queryString('childern') != 'false')
		{
			setDropDownValue($('children'), queryString('childern'));
		}	
		if(queryString('infants') != 'false')
		{
			setDropDownValue($('children2'), queryString('infants'));
		}	
		if(cal1 && queryString('depd') != 'false' &&  queryString('depm') != 'false')
		{
			cal1.calendar(null, queryString('depm'), queryString('depd'), cal1.id);
			cal1.showSpecificCal('select_'+cal1.id, queryString('depm'));
			cal1.setSelected($(cal1.id+'_possibleSlelecteDay_'+queryString('depd')), queryString('depd'));
		}	
		if(cal2 && queryString('retm') != 'false' && queryString('retd') != 'false')
		{
			cal2.calendar(null, queryString('retm'), queryString('retd'), cal2.id);		
			cal2.showSpecificCal('select_'+cal2.id, queryString('retm') );
			cal2.setSelected($(cal2.id+'_possibleSlelecteDay_'+queryString('retd')), queryString('retd'));
		}
	}
	catch(ex)
	{
		if(debugMode)
		{
			alert(errorCatchHandler(ex));
		}
	}
}
/****************************** START PRE-FILL FUNCTIONS ************************************/


function HandleKeyPressed(e, button) 
{ 
	var key = getKey(e); 
	if (key && key == 13) 
	{ 
	button = button.replace(new RegExp(/:/g), "_"); 
	var but=document.getElementById(button); 
	if (but) but.click(); 
	return false; 
	} 
	else return true; 
} 


function getKey(e) 
{ 
	if (window.event) 
	return window.event.keyCode; 
	else if (e) 
	return e.which; 
	else 
	return null; 
} 


function check4Return(e)
{
	var key = getKey(e);
	return (key && key == 13) ? true : false;
}


function submitPresenterForm(formName)
{

	runToggleDIVCalendar(false, null);

	switch (formName) {
		case 'flight':
			validateMethodStanard(null, null, false);
		break;
		case 'hotel':
			validateMethodHotels();
		break;
		case 'rental':
			validateMethodRentalCar();
		break;
	}
}


function submitOnReturn(event,formName)
{
	if (check4Return(event))
	{
		submitPresenterForm(formName);
	}
}


/*070821 xlbr: (safari opera) dummies to prevent sharepoint form error*/
if (typeof UpdateFormDigest == 'undefined')
{
	var UpdateFormDigest = new Function("a", "b", "");
}
if (typeof _spFormOnSubmitWrapper == 'undefined')
{
	var _spFormOnSubmitWrapper = new Function("return false;");
}

function getCleanedLocation(location, affiliate)
{
    /*081126 metm: Do not change these values client side only!*/
    location = location.replace('/', '-');
    
    if(affiliate == 'KUONI')
    {
    	location = location.replace(/ä/g, '_ae_');
	    location = location.replace(/Ä/g, '_Ae_');
	    location = location.replace(/ö/g, '_oe_');
	    location = location.replace(/Ö/g, '_Oe_');
	    location = location.replace(/ü/g, '_ue_');
	    location = location.replace(/Ü/g, '_Ue_');
	    location = location.replace(/ /g, '___');
    }
    else
    {
	    location = location.replace(/ä/g, 'a');
	    location = location.replace(/Ä/g, 'A');
	    location = location.replace(/ö/g, 'o');
	    location = location.replace(/Ö/g, 'O');
	    location = location.replace(/ü/g, 'u');
	    location = location.replace(/Ü/g, 'U');
	    location = location.replace(/ /g,'___');
	}
	

	
	location = location.replace(/â/g, 'a');
	location = location.replace(/Â/g, 'A');
	location = location.replace(/è/g, 'e');
	location = location.replace(/È/g, 'E');
	location = location.replace(/à/g, 'a');
	location = location.replace(/À/g, 'A');
	location = location.replace(/é/g, 'e');
	location = location.replace(/É/g, 'E');
	
	return location;	
}
