/* =========================================================================

JavaScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1

NAME: 

AUTHOR: Roobin , Travelize
DATE  : 2007-03-16

COMMENT: 

============================================================================ */

// sets languages for alertboxes

// 0, Du måste ange varifrån du vill resa!
// 1, Du måste ange vilken ort du vill resa från!
// 2, Du måste ange vart du vill resa!
// 3, Du måste ange vilken destination du vill resa till!
// 4, Du måste ange antal rum!
// 5, Hemresedatum kan inte vara tidigare än utresedatum!
// 6, Utresedatum kan inte vara tidigare än dagens datum!
// 7, Du måste välja antal personer!
// 8, Du måste välja en upphämtningstid!
// 9, Du måste välja en avlämningstid!

var arrSearchEngineAlerts = new Array();

function SetLanguage(se) 
{
    arrSearchEngineAlerts = se;
}

//sets Values in PostForm used when user selects a hotel
function setrt(postStr,roomName,hotelName,hotelId,lins,hotusaInfo,roomPrice,roomName,hotelName,useJacob,sellPriceId,JacobOnLine_OptionId,ExternalHotelsId,isExternal,extSystem,xtrastr){
	
	document.forms['postToALcForm'].useJacobOnLine.value = useJacob;
	document.forms['postToALcForm'].SellPriceId.value = sellPriceId;
	document.forms['postToALcForm'].JacobOnLine_OptionId.value = JacobOnLine_OptionId;
	document.forms['postToALcForm'].ExternalHotelsId.value = ExternalHotelsId;

	document.forms['postToALcForm'].lins.value = lins;
	document.forms['postToALcForm'].rt1.value = postStr;
	document.forms['postToALcForm'].subject.value = hotelName;
	document.forms['postToALcForm'].hotel1.value = hotelId;
	document.forms['postToALcForm'].roomName.value = roomName;
	document.forms['postToALcForm'].roomType.value = roomName;
	
	/*document.forms['postToALcForm'].outboundwrite.value = outboundwrite;
	document.forms['postToALcForm'].returnwrite.value = returnwrite;
	document.forms['postToALcForm'].trpPrice.value = trpPrice;*/

	document.forms['postToALcForm'].hotusaInfo.value = hotusaInfo;
	document.forms['postToALcForm'].roomPrice.value  = roomPrice;
	document.forms['postToALcForm'].hotelName.value  = hotelName;
	document.forms['postToALcForm'].hotelWebservice.value = extSystem;
	if (extSystem == 'transhotel'){
		document.forms['postToALcForm'].transhotelRooms.value = xtrastr;
	}
	
	var rootpath = '';
	rootPath = document.forms['postToALcForm'].rootpath.value;
	//check if externalHotel, then post to alc3
	if(isExternal==true){
		document.forms['postToALcForm'].action=rootpath+'/alc/order3.asp'
		custTarget = document.forms['postToALcForm'].customtarget.value;
		if(custTarget!=''){
			document.forms['postToALcForm'].action=custTarget;
		}
	}
	//submit
	
	//testing modal here
	
	//Modalbox.show('<h1>HTML Header</h1><input type=\'button\' value=\'Resize me +100\' onclick=\'Modalbox.resize(0, 120)\' /><input type=\'button\' value=\'Resize me -100\' onclick=\'Modalbox.resize(0, -100)\' />', {title: this.title, height: 250 });
	var carobj = document.forms['postToALcForm'].car_data;
	if(carobj!=null){
		scroll(0,0);
		//alert('modalTest')
		var qs = "indate="+document.forms['postToALcForm'].indate.value+"&outdate="+document.forms['postToALcForm'].outdate.value;
		//Modalbox.show('searchModuleCarModal.asp?'+qs, {title: 'Rent a Car?',height: 300 });
		getAjaxmodal('searchModuleCarModal.asp?'+qs).open();
	}
	else{
		document.forms['postToALcForm'].submit();	
	}
	
	
}
			
//Toggles flight or hotelView
function tabToggle(inType,inactiveBg){
	//alert('tabtoggle2');
	if (inType=='flight'){
		hideLayer('hotelsContaner');
		//changeOpac(50,'flightsContaner');
		showLayer('flightsContaner');
		//opacity('flightsContaner', 0, 100, 1500);
		var objTabActive 	= document.getElementById('flightToggler');
		var objTabInactive 	= document.getElementById('hotelToggler');
	}
	else{
		
		//var anim3 = new Animator().addSubject(new NumericalStyleSubject(
		   // $("flightsContaner"), 'opacity', 1, 0.1));			
		//anim3.play();
		hideLayer('flightsContaner');
		
// 		var anim2 = Animator.addSubject(new NumericalStyleSubject(
// 		    $("hotelsContaner"), 'opacity', 1, 0.1));
		//var anim4 = Animator.addSubject(new NumericalStyleSubject(
// 		    $("hotelsContaner"), 'opacity', 1, 1.0));
		//anim2.play();		
		showLayer('hotelsContaner');
		//anim4.play();
		
		
	
		
		
		
		var objTabActive 	= document.getElementById('hotelToggler');
		var objTabInactive 	= document.getElementById('flightToggler');
	}

	sInactivBgColor =getStyleById('subheader','backgroundColor');
	
	objTabActive.style.backgroundColor = '#FFF';
	objTabActive.style.color = '#000';
	objTabInactive.style.backgroundColor = sInactivBgColor;
	objTabInactive.style.color = '#FFF';
}



function doSetTransportID(frm,list,triptype){
	//var list = new Array(<%=jsArr%>);
	var flight1
	var flight2
	var radio1Name = frm+'flightRadio1';
	var radio2Name = frm+'flightRadio2';
	var formName
	formName = 'form'+frm;		
	//for some reason getElementbyID doesnt seem to work here
	var inp = document.getElementsByTagName("input"); 
	var tmpoutCounter = 0;
	var tmpInCounter = 0;
	var clickedRadioNumbOut
	var clickedRadioNumbIn
	for (var i = 0; i < inp.length; i++) {  
	    if (inp[i].name==radio1Name){		
	    		if(inp[i].checked==true){
	    			flight1=inp[i].value;
					clickedRadioNumbOut=tmpoutCounter;
	    		}
				tmpoutCounter+=1;
	    }
	    if (inp[i].name==radio2Name){
	    		if(inp[i].checked==true){
	    			flight2=inp[i].value;
					clickedRadioNumbIn=tmpInCounter;
	    		}
				tmpInCounter+=1;
	    }	    
	}
	
	var checkstr = flight1+flight2;
	var lc=0;
	var id_displayPrice;
	//alert(list.length);
	for(k=0;k<list.length;k++)
	{
		if (list[k]==checkstr){
			//commented out below because it broke the javascript
			//document.forms[frm].transportID.value = list[k+1];
			var thisWsType = document.forms[formName].trpWsType.value.toLowerCase();
			// var a_a = document.forms[formName].elements;
			// for(b=0;b<a_a.length;b++){
				// alert('name = ' + a_a[b].name + 'value = ' + a_a[b].value);
			// }
			
			var xmlObj = eval('document.postToALcForm.'+thisWsType+'_xml');
			if (xmlObj != null){
				var sXMLvalue = xmlObj.value;
			}
			//var sXMLvalue = eval('document.postToALcForm.'+thisWsType+'_xml.value');
			
			document.postToALcForm.externalflightXmlfile.value = sXMLvalue;
			document.postToALcForm.transportID.value = list[k+1];
			if (thisWsType!='internaltransports'){
				document.postToALcForm.flightNumber1.value = flight1;
				document.postToALcForm.flightNumber2.value = flight2;
				document.postToALcForm.externalflightwebserviceType.value = thisWsType;
			}
			//document.postToALcForm.trpPrice.value = document.forms[formName].trpPrice.value;
			document.postToALcForm.trpPrice.value = document.forms[formName].trpPricePerPax.value;
			document.postToALcForm.dbe_trpPrice.value = document.forms[formName].trpPricePerPax.value;
			document.postToALcForm.PriceCode.value = document.forms[formName].priceCode.value;
			id_displayPrice = document.postToALcForm.trpPrice.value;
			var tOutTime 	= document.forms[formName].starttimeOut.value;
			var OutTimeArr 	= tOutTime.split(";");
			var tInTime   	= document.forms[formName].starttimeIn.value;
			var InTimeArr 	= tInTime.split(";");
			var acInTime  	= tInTime;
			var acOutTime 	= tOutTime;
			if (OutTimeArr.length>1){
				acOutTime=OutTimeArr[clickedRadioNumbOut];
			}
			if (InTimeArr.length>1){
				acInTime=InTimeArr[clickedRadioNumbIn];
			}
			document.postToALcForm.externalflightDepartureTimeOut.value = acOutTime;
			document.postToALcForm.externalflightDepartureTimeIn.value  = acInTime;
			
			if (thisWsType=='internaltransports'){
				var trpid1name 	 = 'internaltrpid1_'+frm;
				var trpid2name 	 = 'internaltrpid2_'+frm;
				var fsname	   	 = 'fsPrice_'+frm;
				var infPricename = 'infantprice_'+frm;
				//var objtrpid1 = document.getElementById(trpid1name);
				//var objtrpid2 = document.getElementById(trpid2name);
				var trpid1 		= eval('document.forms[formName].'+trpid1name+'.value');
				var trpid2 		= eval('document.forms[formName].'+trpid2name+'.value');
				var fsPrice 	= document.getElementById(fsname).value; //eval('document.forms[formName].'+fsname+'.value');
				id_displayPrice = fsPrice;
				var infantPrice = document.getElementById(infPricename).value; //eval('document.forms[formName].'+infPricename+'.value');
				//alert(fsPrice);
				//alert(infantPrice);
				//return false ;
				document.postToALcForm.trpid1.value=trpid1;
				document.postToALcForm.trpid2.value=trpid2;
				document.postToALcForm.transport1.value=trpid1;
				document.postToALcForm.transport2.value=trpid2;
				document.postToALcForm.fsprice.value=fsPrice;
				document.postToALcForm.infantprice.value=infantPrice;
				//alert(trpid1);
				//alert(trpid2);
			}
			
			if (thisWsType=='iceexp'){
				var tTransport = list[k+1];
				tTranspArr = tTransport.split(";");
				document.postToALcForm.transportID.value = tTranspArr[0];
				document.postToALcForm.transportID2.value = tTranspArr[1];
			}

		}
	}
	
	var arglength = doSetTransportID.arguments.length;
	if (arglength>=4){
		if (triptype.toLowerCase()=='flighthotel' && doSetTransportID.arguments[3].toLowerCase()=='true'){
			/*Logic for InfoDisplay*/
			var d_width = getStyleById('infoDisplayWrapper','width');
			d_width = returnNumericPart(d_width);
			if (d_width==null||d_width.length == 0){
				//set default 
				d_width ="500"
			}
			
			//alert(formName);
			var id_outdate 			= document.postToALcForm.outdate1.value; 
			var id_indate 			= document.postToALcForm.indate1.value;
			var id_flight1 			= document.forms[formName].flnrOut.value;
			var id_flight2 			= document.forms[formName].flnrIn.value;
			var id_carrierOut 		= document.forms[formName].carrierOut.value;
			var id_carrierIn 		= document.forms[formName].carrierIn.value;
			var id_startlocationOut = document.forms[formName].startlocationOut.value;
			var id_startlocationIn 	= document.forms[formName].startlocationIn.value;
			var id_endlocationOut 	= document.forms[formName].endlocationOut.value;
			var id_endlocationIn 	= document.forms[formName].endlocationIn.value;
			var id_starttimeOut 	= document.forms[formName].starttimeOut.value;
			var id_starttimeIn	 	= document.forms[formName].starttimeIn.value;
			var id_endtimeOut	 	= document.forms[formName].endtimeOut.value;
			var id_endtimeIn	 	= document.forms[formName].endtimeIn.value;

			var superstr = id_carrierOut+'_'+id_carrierIn+'_'+id_startlocationOut+'_'+id_startlocationIn+'_'+id_endlocationOut+'_'+id_endlocationIn+'_'+id_starttimeOut+'_'+id_starttimeIn+'_'+id_endtimeOut+'_'+id_endtimeIn;
			
			sidOut = formatStrings(id_flight1,id_carrierOut,id_startlocationOut,id_endlocationOut,id_starttimeOut,id_endtimeOut);
			sidIn =  formatStrings(id_flight2,id_carrierIn,id_startlocationIn,id_endlocationIn,id_starttimeIn,id_endtimeIn);
		
/*
"<span id='divInfoLabel'>"&t_flight&": </span><span id='divInfoText'>"&transport.Flights.item(iCount).SegmentId&t_with&transport.Flights.item(iCount).carrier&"</span><br>"&_
"<span id='divInfoLabel'>"&t_changeLogFrom&": </span><span id='divInfoText'>"&transport.Flights.item(iCount).startlocation&", "&transport.Flights.item(iCount).starttime&"</span><br>"&_
"<span id='divInfoLabel'>"&t_changeLogTo&": </span><span id='divInfoText'>"&transport.Flights.item(iCount).endlocation&", "&transport.Flights.item(iCount).endtime&"</span></p>"
*/


			//$("id_trip1").innerHTML = id_flight1;
			//$("id_trip1").innerHTML = id_flight2;
			//$("id_info").innerHTML 	= id_displayPrice+'<br />'+id_outdate+' - '+id_indate+'<br />'+superstr;
			
			
			var infoAnim = new Animator({
		    	//transition: Animator.makeElastic(1),
		    	duration: 500
				}
			)
			    .addSubject(new NumericalStyleSubject($("id_cont"), 'opacity', 0,1));
			
			var infoAnim3 = new Animator({
		    	//transition: Animator.makeElastic(1),
		    	duration: 10
				}
			)
			    .addSubject(new NumericalStyleSubject($("id_cont"), 'opacity', 1,0));		
			
			var infoAnim2 = new Animator({
		    	//transition: Animator.makeElastic(1),
		    	duration: 500
				}
			)
				.addSubject(new NumericalStyleSubject($('infoDisplayWrapper'), 'width', 10, d_width))
				.addSubject(new NumericalStyleSubject($('infoDisplayWrapper'), 'height', 10, 150));
							
			
			$('infoDisplayWrapper').width="0";
			$('infoDisplayWrapper').height="0";
			showLayer('infoDisplayWrapper');	
			
			//infoAnim.toggle();
			//infoAnim2.reverse();
			

			infoAnim2.toggle();
			
			$("id_outcontent").innerHTML = sidOut;
			$("id_incontent").innerHTML = sidIn;
			$("id_price").innerHTML = id_displayPrice;	
			//infoAnim.toggle();
			
		
			
			
		}
	}
		// alert(triptype);
	// alert(doSetTransportID.arguments[3]);
	if (triptype.toLowerCase()!='flight'){
		//Oldway
		/*
			hideLayer('flightsContaner');			
			showLayer('hotelsContaner');
			var objTabActive 	= document.getElementById('hotelToggler');
			var objTabInactive 	= document.getElementById('flightToggler');		
			objTabActive.style.backgroundColor = '#FFF';
			objTabActive.style.color = '#000';
			sInactivBgColor =getStyleById('subheader','backgroundColor');
			objTabInactive.style.backgroundColor = sInactivBgColor;
			objTabInactive.style.color = '#FFF';
		*/
		//New Way
		toggleTab(1);
	}
	else{
		var cartsess = $('cartSessionId');
		if(cartsess==null){
			document.forms['postToALcForm'].action='/alc/order3.asp';
			custTarget = document.forms['postToALcForm'].customtarget.value;
			if(custTarget!=''){
				document.forms['postToALcForm'].action=custTarget;
			}			
			document.postToALcForm.submit();
		}
		else{
			//its a cartsearch post to order2
			//alert('cart!!!');
			document.postToALcForm.submit();
		}
	}
	//document.forms[frm].submit();
}

function formatStrings(flight,carrier,startlocation,endlocation,starttime,endtime){
	
	var retstr = "";
	
	var split_flight 		= flight.split(";");
	var split_carrier 		= carrier.split(";");
	var split_startlocation = startlocation.split(";");
	var split_endlocation 	= endlocation.split(";");
	var split_starttime 	= starttime.split(";");
	var split_endtime 		= endtime.split(";");

	for(i = 0; i < split_flight.length; i++){
		retstr += split_starttime[i]+'\t'+split_flight[i]+' '+split_startlocation[i]+'\t<b>'+split_carrier[i]+'</b><br />';
		retstr +=split_endtime[i]+'\t'+split_flight[i]+' '+split_endlocation[i]+'\t<b>'+split_carrier[i]+'</b><br />';
	}
	
	return retstr;

}

function postOnlyFlight(){
	document.forms['postToALcForm'].action='/alc/order3.asp';
	document.forms['postToALcForm'].numberofHotels.value = '0';
	custTarget = document.forms['postToALcForm'].customtarget.value;
	if(custTarget!=''){
		document.forms['postToALcForm'].action=custTarget;
	}	
	if (document.forms['postToALcForm'].flightNumber1.value=='' ||document.forms['postToALcForm'].flightNumber2.value==''){
		alert('No flight choosen')
		return false;
	}
	else{
		document.postToALcForm.submit();
	}
}

function toggle(link, divId) { 
	var lText = link.innerHTML; 
 	var d = document.getElementById(divId)
 	if (d.style.display == 'none') { 
 		link.innerHTML = "<img src='/images/minus2.gif'>"; 
 		d.style.display = 'block'; 
 	}
 	else { 
 		link.innerHTML = "<img src='/images/plus.gif'>"; 
 		d.style.display = 'none'; 
 	} 
}

var transHotelRoomInfoIsDiplayed = false;

function _transroomdisp(rms){
	//alert(rms);
	$$('span[rel="selpersonsperroom"]').each(function(el) {
		el.hide();
	});	
	if (rms!='ERROR'){
		transHotelRoomInfoIsDiplayed = true;
		var tmpRoom
		var strToWrite = '';
		//var transHotelRoomInfo = $('transHotelRoomInfo');
		//$('selpersonsperroom').show();
		Effect.Fade('disp_selpax',{duration: 0.1});
		Effect.Fade('disp_selchildren',{duration: 0.1});
		Effect.Fade('disp_childrenage',{duration: 0.1});
		Effect.Appear('selpersonsperroom',{duration: 0.1});
		
		for(r=1;r<=parseInt(rms);r++){
			//alert(r);
			var thisRoomName = 'transRoomInfo'+r;
			//tmpRoom = $(thisRoomName);
			//alert(typeof(tmpRoom));
			//alert(tmpRoom.innerHTML);
			//strToWrite+=tmpRoom.innerHTML;
			//$(thisRoomName).style="";
			Effect.Appear(thisRoomName,{duration: 0.3});
			
		}
		//alert(strToWrite);
		//transHotelRoomInfo.
		//var txtToAppend = document.createTextNode(strToWrite);
		//transHotelRoomInfo.appendChild(strToWrite);
		
		//transHotelRoomInfo.innerHTML="";
		//transHotelRoomInfo.innerHTML=strToWrite;
		//transHotelRoomInfo.style.display = ''; 
		
		for(rr=1;rr<=parseInt(rms);rr++){
			var aTextBoxName = 'ChildrenAgeRoom'+rr;
			var aTextBox = $(aTextBoxName);
			aTextBox.onchange=function(){cChildrenAge(this);};
		}
	}
	else{
		Effect.Appear('disp_selpax',{duration: 0.2});
		Effect.Appear('disp_selchildren',{duration: 0.2});
		Effect.Appear('disp_childrenage',{duration: 0.2});
		
	}
}

function viewInfo(layer){
		var anim3 = new Animator()
		.addSubject(new NumericalStyleSubject($(layer), 'opacity', 0,0));
		anim3.play();
		showLayer(layer);
		
	var anim4 = new Animator({
    	duration: 500
		}
	)
	.addSubject(new NumericalStyleSubject($(layer), 'opacity', 0,1));
	anim4.play();	
}
function hideInfo(layer){
	var anim4 = new Animator({
    	transition: Animator.makeElastic(1),
    	duration: 200
		}
	)
	.addSubject(new NumericalStyleSubject($(layer), 'opacity', 0,1));
	anim4.reverse();
	hideLayer(layer);
}

//recursive finction to ensure only two childs
function cChildrenAge(e){
	var str = e.value;
	count = 0;
	pos = str.indexOf(",");
	while ( pos != -1 ) {
	   count++;
	   pos = str.indexOf(",",pos+1);
	}
	if(count>1){
		var newstr = str.substr(0,str.lastIndexOf(","));
		e.value = newstr;
		cChildrenAge(e);
	}
}
var globaltriptype = 'flighthotel';
function toggleRooms(triptype){
	globaltriptype = triptype;
	var roomSpan 			= document.getElementById('NumberOfRoomsSpan');
	var eRoom 				= document.getElementById('NumberOfRooms');
	var selectBoxesIn 		= document.getElementById('selectBoxesIn');
	var selectBoxesOut 		= document.getElementById('selectBoxesOut');
	var onlyFlightPaxInfo 	= document.getElementById('onlyFlightPaxInfo');
	var transHotelRoomInfo 	= document.getElementById('transHotelRoomInfo');
	var selectBoxesInSearchIATA = document.getElementById('selectBoxesInSearchIATA');
	
	//extra selects
	var selectBoxesIn_x 	= $('selectBoxesIn_x');
	var selectBoxesOut_x 	= $('selectBoxesOut_x');
	var childrenblock 		= $('childrenblock');
	var search_days 		= $('search_days');
	var calendar2 			= $('calendar2');
	var ac1                 = $('ac1');
	
	
	if  (eRoom == null || roomSpan == null  || selectBoxesOut == null ){
		//return false;
	}
	
	//alert(typeof(search_days));
	
	if (search_days 		!= null){search_days.style.display 		= 'none';}
	if (selectBoxesIn_x 	!= null){selectBoxesIn_x.style.display 	= 'none';}
	if (selectBoxesOut_x 	!= null){selectBoxesOut_x.style.display = 'none';}
	if (childrenblock		!= null){childrenblock.style.display 	= 'block';}
	if (calendar2			!= null){calendar2.style.display 		= 'block';}
	if ($('btnSub')			!= null){$('btnSub').disabled=false;}
	
	var hideOuSel = false;
	if (triptype=='bus' || triptype=='bushotel'){
		$('transporttype').value = 'bus';
		if (triptype=='bus'){triptype='flight';}
		if (triptype=='bushotel'){triptype='flighthotel';}
		hideOuSel = true;
	}
	else{
		$('transporttype').value = "";
	}
	
	
	switch (triptype)
	{
		case "flighthotel":
			//show all
			if (selectBoxesInSearchIATA != null) 
			{
			    selectBoxesInSearchIATA.style.display = 'none';
			}

			if (roomSpan!=null){
				roomSpan.style.display = 'block';
			}
			if (!hideOuSel){
				selectBoxesOut.style.display = 'block';
			}
			else{
				selectBoxesOut.style.display = 'none';
			}
			selectBoxesIn.style.display = 'block';
			
			if (eRoom!=null){
				eRoom.disabled=false;			
			}
			if (transHotelRoomInfo!=null){
				transHotelRoomInfo.style.display = 'block';
			}				
			if (onlyFlightPaxInfo!=null){
				onlyFlightPaxInfo.style.display = 'none'; 	
			}
			
			//alert($('transporttype').value);
			
			if ($('transporttype').value == 'bus')
			{
    			//setInOptions('DK');
	    		//setOutOptions('DK');
				if (is3letterModified){FillOnlyIATA3letterReverse();}
			}
			else
			{
			    FillOnlyIATA3letter();
			}
			
			break;
		case "car": case "flight":
			//hide rooms show rest
			if (selectBoxesInSearchIATA != null) 
			{
			    selectBoxesInSearchIATA.style.display = 'none';
			}

			if (roomSpan!=null){
				roomSpan.style.display = 'none'; 
			}
			if (!hideOuSel){
				selectBoxesOut.style.display = 'block'; 
			}
			else{
				selectBoxesOut.style.display = 'none';
			}
			selectBoxesIn.style.display = 'block'; 
			if (eRoom!=null){
				eRoom.disabled=true;				
			}
			if (transHotelRoomInfo!=null){
				transHotelRoomInfo.style.display = 'none';
			}
			//alert(transHotelRoomInfoIsDiplayed);
			if (onlyFlightPaxInfo!=null && transHotelRoomInfo!=null){
				onlyFlightPaxInfo.style.display = 'block'; 	
			}

			if ($('transporttype').value == 'bus')
			{
    			//setInOptions('DK');
	    		//setOutOptions('DK');
				if (is3letterModified){FillOnlyIATA3letterReverse();}
			}
			else
			{
			    FillOnlyIATA3letter();
			}
			
			break;
		case "hotel":

            if (selectBoxesInSearchIATA != null) 
            {
		        selectBoxesOut.style.display = 'none'; 
		        selectBoxesIn.style.display = 'none';
		        selectBoxesInSearchIATA.style.display = 'block';
		        if (ac1 != null) {
		            ac1.focus();
		            ac1.value = '';
		        }
            }
            else
            {
		        selectBoxesOut.style.display = 'none'; 
		        selectBoxesIn.style.display = 'block';
			    if (selectBoxesInSearchIATA != null) 
			    {
			        selectBoxesInSearchIATA.style.display = 'none';
			    }
			    
    			//setInOptions('DK');
	    		//setOutOptions('DK');
		    }

			if (roomSpan!=null){
				roomSpan.style.display = 'block'; 
			}
			if (eRoom!=null){
				eRoom.disabled=false;
			}
			if (transHotelRoomInfo!=null){
				transHotelRoomInfo.style.display = 'block';
			}			
			if (onlyFlightPaxInfo!=null){
				onlyFlightPaxInfo.style.display = 'none'; 	
			}
			
			if (is3letterModified){FillOnlyIATA3letterReverse();}

			break;
			
		case "":
			selectBoxesOut.style.display = 'none'; 
			selectBoxesIn.style.display = 'none'; 
			if (selectBoxesInSearchIATA != null) 
			{
			    selectBoxesInSearchIATA.style.display = 'none';
			}

			if (roomSpan!=null){
				roomSpan.style.display = 'none'; 
			}
					
			return false;
			break;
		default:
			//projects
			//hide selectBoxes
			selectBoxesOut.style.display = 'none'; 
			selectBoxesIn.style.display = 'none';
			if (selectBoxesInSearchIATA != null) 
			{
			    selectBoxesInSearchIATA.style.display = 'none';
			}
			if (roomSpan!=null){
				roomSpan.style.display = 'none'; 
			}
			if (eRoom!=null){
				//eRoom.disabled=false;
			}
			if (transHotelRoomInfo!=null){
				transHotelRoomInfo.style.display = 'none';
			}			
/*			if (onlyFlightPaxInfo!=null){
				onlyFlightPaxInfo.style.display = 'none'; 	
			}
*/			
			//alert(transHotelRoomInfoIsDiplayed);
			if (onlyFlightPaxInfo!=null && transHotelRoomInfo!=null){
				onlyFlightPaxInfo.style.display = 'block'; 	
			}			
			
			if (childrenblock!=null){childrenblock.style.display = 'none';}
			if (calendar2!=null){calendar2.style.display = 'none';}
			if (search_days!=null){search_days.style.display = 'block';}
			
			//alert(triptype);
			//alert(proj_prod);
			$('btnSub').disabled=true;
			get_result('smodEngineLogic.asp?projtype='+triptype+'&proj_prod='+proj_prod,'selectBoxesOut_x');
			
			//alert(proj_type);

    			//setInOptions('DK');
	    		//setOutOptions('DK');
	}
}

function update(result,id){
	//alert(result.responseText);
	$(id).innerHTML=result.responseText;
	showLayer(id);
	selVal = document.forms['postform'].proj_prod.options[document.forms['postform'].proj_prod.selectedIndex].value;
	var cStr = "ERROR"
	//alert(selVal+'!='+cStr);
	if (selVal!=cStr){
		$('btnSub').disabled=false;
	}	
	if (proj_prod.length>0&&id!='selectBoxesIn_x'){
		getProdSelect(proj_prod,proj_type);
		//alert(proj_prod);
	}	
}

function get_result(inUrl, ui_id){
	//alert('get_result');
	Http.get({
		url: inUrl,
		callback: update,
		cache: Http.Cache.GetNoCache
	}, [ui_id]);
}
function getProdSelect(prod,sel){
	if(prod=="ERROR"){
		return false;
	}
	//alert('getProdSelect  '+prod);
	//$('btnSub').disabled=false;
	get_result('smodEngineLogic.asp?prod='+prod+'&proj_type='+sel,'selectBoxesIn_x');
}
function rePostProjectSearch(p,t1,t2){
	document.forms['repostForm'].action='index.asp?action=flightsearch&Flightaction=search';
	document.forms['repostForm'].t1.value=t1;
	document.forms['repostForm'].t2.value=t2;
	document.forms['repostForm'].product.value=p;
	document.forms['repostForm'].radio_project.value=p+t1+t2;
	document.forms['repostForm'].plusDays.value  = document.forms['postform'].plusDays.options[document.forms['postform'].plusDays.selectedIndex].value;
	document.forms['repostForm'].minusDays.value = document.forms['postform'].minusDays.options[document.forms['postform'].minusDays.selectedIndex].value;
	document.forms['repostForm'].target="";
	document.repostForm.submit();
}

function openBookingDet(ps,wl){	
	JSbookWindowHeight = 650;
	 if (JSbookWindowHeight > window.screen.availHeight)
	 {
	     JSbookWindowHeight = window.screen.availHeight-50;  // Shape off 50 pix for the windowsbar and stuff.
	 }
    window.open('order2.asp?ps='+ps+'&waitinglist='+wl,'','resizable=yes, scrollbars=yes, width=650, height=' + JSbookWindowHeight + '')	
}

function returnNumericPart(str){
	str = str.replace(/[^\d]/g,'');
	return str;
}


function setcarstation(e,pickup,nr){
	var tmpA = e.value.split('|');
	var stationtype = tmpA[1]
	//alert(stationtype);
	
	if(pickup==true&&stationtype=='flight'){
		extdep  = $('externalflightDepartureTimeIn').value;
		flnr = $('flightNumber1').value;
		tmptmp = $('outboundwrite').value;
		nrName = "carflightnumber"+nr;
		objNr = $(nrName)
		timeName = "carflighttime"+nr;
		objTime = $(timeName);
		if (objTime!=null&&extdep.length>0){
			objTime.value=extdep;
		}
		if (objNr!=null&&flnr.length>0){
			objNr.value=flnr;
		}
		if(stationtype=='flight'){
			toggleName = "carflightinfo"+nr;
			toggleObj = $(toggleName);
			toggleObj.show();		
		}
	}
	if(pickup==true){
		$('car_pickupstationdata').value=tmpA[0]
		$('car_pickuptype').value=tmpA[1]
	}
	else{
		$('car_returnstationdata').value=tmpA[0]
	}
	
	
}

function setcardata(carnumber){
	//var tmpPickup = $(pickupName);
	//Dom must be really destroyed, $ doesnt work here :|
	var tmpPickup 	= eval("document.forms['carform'].carselect_pickup"+carnumber+".value");
	var tmpReturn 	= eval("document.forms['carform'].carselect_dropoff"+carnumber+".value");
	var aPickup   	= tmpPickup.split('|');
	var aReturn   	= tmpReturn.split('|');
	var sCardata  	= eval("document.forms['carform'].cardata"+carnumber+".value");
	var sCarprice 	= eval("document.forms['carform'].carprice"+carnumber+".value");
	var sCarname  	= eval("document.forms['carform'].carname"+carnumber+".value");
	var sCarflight	= eval("document.forms['carform'].carflightnumber"+carnumber+".value");		
	var sCarTime  	= eval("document.forms['carform'].carflighttime"+carnumber+".value");
	var sCarProduct = eval("document.forms['carform'].carproduct"+carnumber+".value");
	var sCarPtime 	= eval("document.forms['carform'].carpickuptime"+carnumber+".value");
	var sCarRtime	= eval("document.forms['carform'].carreturntime"+carnumber+".value");
	//$('cardata'+carnumber);
	$('car_pickupstationdata').value=aPickup[0]
	$('car_pickuptype').value=aPickup[1]	
	$('car_returnstationdata').value=aReturn[0]
	$('car_pickupplace').value=aPickup[2]	
	$('car_returnplace').value=aReturn[2]	
	$('car_data').value=sCardata;
	$('car_price').value=sCarprice;
	$('car_name').value=sCarname;
	$('car_flightnumber').value=sCarflight;
	$('car_arrivaltime').value=sCarTime;
	$('car_product').value=sCarProduct;	
	$('car_pickuptime').value=sCarPtime;
	$('car_returntime').value=sCarRtime;

	
	document.forms['postToALcForm'].action='/alc/order3.asp';
	custTarget = document.forms['postToALcForm'].customtarget.value;
	if(custTarget!=''){
		document.forms['postToALcForm'].action=custTarget;
	}	
	document.forms['postToALcForm'].submit();	
}

/*############################NEW LOGIC FUNCTIONS #####################################*/

function toggleDisp() {
	for (var i=0;i<arguments.length;i++){
		var d = $(arguments[i]);
		if (d.style.display == 'none')
			d.style.display = 'block';
		else
			d.style.display = 'none';
	}
}
var inumelems = -1;
function toggleTab(num,opennum,animate) {
	animate = false;
	if(inumelems==-1){
		var numelems = $$('div[class="tabContent"]').length;
		if(numelems>0){
			inumelems=numelems-1;
		}
		else{
			//alert('false');
			return false;
			
		}
	}
	else{
		numelems=inumelems;
	}
	if(typeof num == 'undefined'){
		num=0;
	}
	if ($('tabContent'+num).style.display == 'none'){
		for (var i=0;i<=inumelems;i++){
			if ((opennum == null) || (opennum != i)){
				var temph = 'tabHeader'+i;
				var h = $(temph);
				if (!h){
					var h = $('tabHeaderActive');
					h.id = temph;
				}
				var tempc = 'tabContent'+i;
				var c = $(tempc);
				if(c.style.display != 'none'){
					if (animate || typeof animate == 'undefined')
						Effect.toggle(tempc,'appear',{duration:0.5, queue:{scope:'menus', limit: 3}});
					else
						toggleDisp(tempc);
				}
			}
		}
		var h = $('tabHeader'+num);
		if (h)
			h.id = 'tabHeaderActive';
		h.blur();
		var c = $('tabContent'+num);
		c.style.marginTop = '2px';
		if (animate || typeof animate == 'undefined'){
			Effect.toggle('tabContent'+num,'appear',{duration:0.5, queue:{scope:'menus', position:'end', limit: 3}});
		}else{
			toggleDisp('tabContent'+num);
		}
	}
}

//Another temp
/*
 * Prototype/Scriptaculous corner plugin version 0.1 (6/29/2007)
 *
 * Based on the jQuery corner plugin version 1.7 (1/26/2007)
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

/**
 * The Effect.Corner class provides a simple way of styling DOM elements.  
 *
 * Effect.Corner constructor takes two arguments:  new Effect.Corner(element, "effect corners width")
 *
 *   effect:  The name of the effect to apply, such as round or bevel. 
 *            If you don't specify an effect, rounding is used.
 *
 *   corners: The corners can be one or more of top, bottom, tr, tl, br, or bl. 
 *            By default, all four corners are adorned. 
 *
 *   width:   The width specifies the width of the effect; in the case of rounded corners this 
 *            will be the radius of the width. 
 *            Specify this value using the px suffix such as 10px, and yes it must be pixels.
 *
 * For more details see: http://methvin.com/jquery/jq-corner.html
 * For a full demo see:  http://malsup.com/jquery/corner/
 *
 *
 * @example new Effect.Corner(element);
 * @desc Create round, 10px corners 
 *
 * @example new Effect.Corner(element, "25px");
 * @desc Create round, 25px corners 
 *
 * @name corner
 * @type scriptaculous
 * @author Ilia Lobsanov (first name @ last name dot com)
 */
/*
Effect.Corner = Class.create();
Object.extend(Object.extend(Effect.Corner.prototype, Effect.Base.prototype), {
    hex2: function (s) {
        var s = parseInt(s).toString(16);
        return ( s.length < 2 ) ? '0'+s : s;
    },
    gpc: function (node) {
        for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode  ) {
            //var v = jQuery.css(node,'backgroundColor');
            var v = Element.getStyle(node, 'backgroundColor');
            if ( v.indexOf('rgb') >= 0 ) { 
                rgb = v.match(/\d+/g); 
                return '#'+ this.hex2(rgb[0]) + this.hex2(rgb[1]) + this.hex2(rgb[2]);
            }
            if ( v && v != 'transparent' )
                return v;
        }
        return '#ffffff';
    },
    getW: function (i) {
        switch(this.fx) {
        case 'round':  return Math.round(this.width*(1-Math.cos(Math.asin(i/this.width))));
        case 'cool':   return Math.round(this.width*(1+Math.cos(Math.asin(i/this.width))));
        case 'sharp':  return Math.round(this.width*(1-Math.cos(Math.acos(i/this.width))));
        case 'bite':   return Math.round(this.width*(Math.cos(Math.asin((this.width-i-1)/this.width))));
        case 'slide':  return Math.round(this.width*(Math.atan2(i,this.width/i)));
        case 'jut':    return Math.round(this.width*(Math.atan2(this.width,(this.width-i-1))));
        case 'curl':   return Math.round(this.width*(Math.atan(i)));
        case 'tear':   return Math.round(this.width*(Math.cos(i)));
        case 'wicked': return Math.round(this.width*(Math.tan(i)));
        case 'long':   return Math.round(this.width*(Math.sqrt(i)));
        case 'sculpt': return Math.round(this.width*(Math.log((this.width-i-1),this.width)));
        case 'dog':    return (i&1) ? (i+1) : this.width;
        case 'dog2':   return (i&2) ? (i+1) : this.width;
        case 'dog3':   return (i&3) ? (i+1) : this.width;
        case 'fray':   return (i%2)*this.width;
        case 'notch':  return this.width; 
        case 'bevel':  return i+1;
        }
    },
    initialize: function(element, o) {
        element = $(element);
        o = (o||"").toLowerCase();
        var keep = /keep/.test(o);                       // keep borders?
        var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
        var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
        this.width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
        var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
        this.fx = ((o.match(re)||['round'])[0]);
        var edges = { T:0, B:1 };
        var opts = {
            TL:  /top|tl/.test(o),       TR:  /top|tr/.test(o),
            BL:  /bottom|bl/.test(o),    BR:  /bottom|br/.test(o)
        };
        if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
            opts = { TL:1, TR:1, BL:1, BR:1 };
        var strip = document.createElement('div');
        strip.style.overflow = 'hidden';
        strip.style.height = '1px';
        strip.style.backgroundColor = sc || 'transparent';
        strip.style.borderStyle = 'solid';
        var pad = {
            T: parseInt(Element.getStyle(element,'paddingTop'))||0,     R: parseInt(Element.getStyle(element,'paddingRight'))||0,
            B: parseInt(Element.getStyle(element,'paddingBottom'))||0,  L: parseInt(Element.getStyle(element,'paddingLeft'))||0
        };

        if ( /MSIE/.test(navigator.userAgent) ) element.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) element.style.border = 'none';
        strip.style.borderColor = cc || this.gpc(element.parentNode);
        var cssHeight = Element.getHeight(element);

        for (var j in edges) {
            var bot = edges[j];
            strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
            var d = document.createElement('div');
            var ds = d.style;

            bot ? element.appendChild(d) : element.insertBefore(d, element.firstChild);

            if (bot && cssHeight != 'auto') {
                if (Element.getStyle(element,'position') == 'static')
                    element.style.position = 'relative';
                ds.position = 'absolute';
                ds.bottom = ds.left = ds.padding = ds.margin = '0';
                if (/MSIE/.test(navigator.userAgent))
                    ds.setExpression('width', 'this.parentNode.offsetWidth');
                else
                    ds.width = '100%';
            }
            else {
                ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-this.width)+'px -'+pad.L+'px' : 
                                    (pad.B-this.width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
            }

            for (var i=0; i < this.width; i++) {
                var w = Math.max(0,this.getW(i));
                var e = strip.cloneNode(false);
                e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
            }
        }
    }
});
*/

	/*testTo Speed up*/
	var getElementsByClassName=function(className,parentNode) {
	 var results = [];
	 //if (document.getElementsByClassName) document.getElementsByClassName(className,parentNode);//this is the code for FF3. Prototype 1.5 doesn't play nice with this code, though.
	 if (document.evaluate) {
	  var query = document.evaluate(".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]", parentNode || document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
	  for (var i = 0, length = query.snapshotLength; i < length; i++) results.push(query.snapshotItem(i));
	 }
	 else {
	  var nodes = (parentNode || document).getElementsByTagName("*");
	  for (var i = 0, j = 0, length = nodes.length; i < length; i++) {
	   var nodes_i=nodes[i];
	   if ((" "+nodes_i+" ").indexOf(" "+className+" ") > -1) results[j++] = nodes_i;
	  }
	 }
	 return results;
	};	
	/*end speed*/

/*from inc_externalflightsearch*/
	var isFlight = false;
	function toggleDisplay(e){
		//alert('toggledisplay');
		$('disp_submit').show();
		
		if (e==null){
			if (toggleDisplay.arguments.length>1){
				e = $(toggleDisplay.arguments[1].toLowerCase());
			}
			else{
				//Hide Elements, this is the default with no triptype
				hideElements();
				$('disp_submit').hide();
				return false;
			}
		}
		var id = e.id;
		var eValue = '';
		if(e.value!=null){
			eValue = e.value.toLowerCase();
		}
		globaltriptype = eValue;		
		var vIdstr = id+'_vissibles';
		var sVissibles = $(vIdstr).value;
		var aVissibles=sVissibles.split(",");
		
		//Hide Elements
		hideElements();
		
		//check to see if we should make an ajaxCall
		if (eValue=='bus' || eValue=='bushotel'){
			//bus
			new Ajax.Updater('disp_selbus', 'smodEngineLogic.asp', {
				method: 'get',
				encoding: 'ISO-8859-1',			  
				parameters: { 
					sel: sel_bus,
					bus: 'yes'
			  }
			});				
		}
		isFlight=false;
		if (eValue.indexOf('flight')>-1){
			isFlight=true;
			//fix this so that normal functionality applies on countries and destinations
		}
		else{
			//it is possible to manipulate the searchengine, if this is a major prob then in the above if, 
			//we have to set error values as selected in incountry and indestination
			addAllCountries();
		}
		

		if (eValue.indexOf('projects')>-1){
			//project
				
			new Ajax.Updater('disp_selproduct', 'smodEngineLogic.asp', {
				method: 'get',
				encoding: 'ISO-8859-1',			  
				parameters: { 
					projtype: eValue,
					proj_prod: proj_prod,
					display: e.getAttribute('rel')
				
			  }
			});
			if(proj_prod!=''&&proj_prod.toLowerCase()!='error'){
				getProdSelect(proj_prod,proj_type);
			}
		}
		
		//show elements
		for (var x = 0; x < aVissibles.length; x++){	
			tmp = eval("'"+aVissibles[x]+"'").toLowerCase();
			
			objName = 'disp_'+tmp;
			toggleObject = $(objName);
			if(toggleObject == null){alert('Following element is not in DOM: '+objName);}
			Effect.Appear(objName,{duration: 0.2});
			//toggleObject.show();
			if(tmp=='selnumberofrooms'){
				objNrOfRooms = $('NumberOfRooms')
				if(objNrOfRooms!=null){
					transroomdisp(objNrOfRooms.value);
				}			
			}
		}
		
		//check if using the swap-model
		//first che to see if a swapTo element is found
		var swapTo = $(id+'_swapTo');
		if (swapTo!=null){
			//check for the swapContainer
			var swapFrom = $('swap');
			var swapClassName = swapTo.className;
			if(swapFrom!=null){
				//alert(swapFrom.innerHTML);
				//swapcontent
				swapTo.appendChild(swapFrom);
				if(arrDropables!=''){
					aDropables = arrDropables.split(',');
					for (var z = 0; z < aDropables.length; z++){
						dropToHide = $(aDropables[z]);
						if(dropToHide!=null){dropToHide.hide();}
					}
				}
				else{
					lst = document.getElementsByClassName(swapClassName);
					for (var z = 0; z < lst.length; z++){
						lst[z].style.display = "none";
					}
				}
				swapTo.show();
				swapFrom.show();	
			}
			
		}
		
		
	}
	//test to speed up
	// addLoadEvent('domSpeed');
	// function domSpeed(){
		// var lst = document.getElementsByClassName('menur_niv2');
	// }
	function hideAllOpenDropables(){
		if(arrDropables!=''){
			aDropables = arrDropables.split(',');
			for (var z = 0; z < aDropables.length; z++){
				dropToHide = $(aDropables[z]);
				if(dropToHide!=null){dropToHide.hide();}
			}
		}	
	}
	
	function getProdSelect(prod,sel){
		new Ajax.Updater('disp_selproject', 'smodEngineLogic.asp', {
			method: 'get',
			encoding: 'ISO-8859-1',			  
			parameters: { 
				proj_type: sel,
				prod: prod
		  }
		});		
	}
	
	function hideElements(){
		//hide all elemets with a rel of toggle
		$$('span[rel="toggle"]').each(function(el) {
			//alert('hiding = '+el.id);
			el.hide();
		});	
		$$('div[rel="selpersonsperroom"]').each(function(el) {
			el.hide();
		});			
	}
	
	var defText ="";
	var defValue = "";
	
	function setInOptions(Country){
		//alert('setInOptions');
		
		var box2 = document.forms['postform'].selInLocation;
		if(!box2){return false;}
		//set def-values only the first time when they are correct
		if(defText==""){
			defText = box2.options[0].text;
			defValue = box2.options[0].value;
		}
		box2.options.length = 0;
		
		if (Country=='ERROR'||typeof Country == 'undefined'){
			//set def-text
			box2.options[0] = new Option(defText,defValue);
			return false;
		} 
		
		//moved to class
		//alert('rIn'+rIn)
		//var rIn = '<%=request("InLocation")%>'
		
		//var list = sAi;
		var listStr = $('sai').value;
		var list = listStr.split(",");
		
		//var box2 = $('selInLocation');
		//var box2 = $('selInLocation');	
		/*
		alert(box2.id);
		alert(box2.innerHTML);
		*/

		
		var lc=0;
		var aCountry=Country.split(';');
		for(i=0;i<list.length;i+=3) //was +3
		{
			if (list[i+1]==aCountry[0]){
				//check for showOnlyConnectedAirports
				tmpIata = list[i+2].split(';');
				thisIata = tmpIata[0] 
				if(checkDestinationConnections(thisIata)){
					box2.options[lc] = new Option(list[i],list[i+2]);
					if (list[i+2]==rIn){
						box2.options[lc].selected=true;
					}			
					lc+=1;
				}
			}
		}
		if(lc==0){
			box2.options[0] = new Option(defText,defValue);
		}
		document.forms['postform'].InCountry.value = Country;
		//$('InCountry').value = Country;
		setValue(box2,'InLocation');
	}

	function setOutOptions(Country){
		//alert('setOutOptions');
		if (Country=='ERROR'){ return;}
		var box2 = document.forms['postform'].selOutLocation;
		if(!box2){return false;}
		
		listStr = $('sao').value;
		var list = listStr.split(",");

		box2.options.length = 0;
		var lc=0;
		var aCountry=Country.split(';');
		for(i=0;i<list.length;i+=3) //was +3
		{
			if (list[i+1]==aCountry[0]){
				box2.options[lc] = new Option(list[i],list[i+2]);
				if (list[i+2]==rOut){
					box2.options[lc].selected=true;
				}
				lc+=1;
			}
		}
		//$('OutCountry').value = Country;
		document.forms['postform'].OutCountry.value = Country;
		setValue(box2,'OutLocation');
	}
	
	function checkDestinationConnections(sIata){
		//alert('checkDestinationConnections');
		if(!isFlight){return true;}
		if(arrConnectionlist==''){
			return true;
		}
		else{
			aConns = arrConnectionlist.split(',');
			for(ip=0;ip<aConns.length;ip+=3){
				if(aConns[ip+1]==sIata){
					return true;
					//alert('TRÄFF   dim0='+aConns[ip]+' dim1='+aConns[ip+1]+' dim2='+aConns[ip+2]+' sIata='+sIata);		
				}
			}
		}
		return false;
	}
	
	function reBuildInCountries(sIata){
		//alert('reBuildInCountries');
		//var objIn = $('selInCountry');
		var objIn = document.forms['postform'].selInCountry
		var myCounter = 0;
		objIn.options.length = 0;
		
		for(ii=0;ii<countryInOptionValues.length;ii++){
				if(checkConnections(sIata,countryInOptionValues[ii])){
					objIn.options[myCounter] = new Option(countryInOptionTexts[ii],countryInOptionValues[ii]);
					if(typeof req_incountry != 'undefined'){
						if(countryInOptionValues[ii]==req_incountry){
							objIn.options[myCounter].selected=true;
						}
					}
					myCounter+=1
				}
				
				if(myCounter>500){
					alert('evig loop')
					return false;
				}
		}
		//alert(myCounter);
		if(myCounter==0){
			objIn.options[myCounter] = new Option(countryInOptionTexts[0],countryInOptionValues[0]);
			//reset inoptions
			setInOptions();
		}
		else{
			//set default
			//alert('setinoptions: '+objIn.options[0].value);
			setInOptions(objIn.options[0].value);
		}
	}	
	
	var countryInOptionTexts  = new Array()
	var countryInOptionValues = new Array()
	
	function reBuildInOptions(inVal){
		//alert('reBuildInOptions');
		var sIataArr = inVal.split(';');
		var sIata = sIataArr[0];
		//alert(sIata);
		
		if (countryInOptionTexts.length<=1){
			//oIn = $('selInCountry');
			var oIn = document.forms['postform'].selInCountry
			for(ci=0;ci<oIn.options.length;ci++){
				/*
				alert(oIn.options[ci].value)
				alert(oIn.options[ci].text)
				*/
				countryInOptionTexts[ci] = oIn.options[ci].text;
				countryInOptionValues[ci] = oIn.options[ci].value;
			}
		}
		reBuildInCountries(sIata);
		//alert(countryInOptionTexts.length);
	}
	
	function addAllCountries(){
		//alert('addAllCountries');
		if(arrConnectionlist!=''&&countryInOptionTexts.length>=1){
			//var objIn = $('selInCountry');
			var objIn = document.forms['postform'].selInCountry
			objIn.options.length = 0;
			for(i=0;i<countryInOptionTexts.length;i++)
			{
					objIn.options[i] = new Option(countryInOptionTexts[i],countryInOptionValues[i]);
			}
			//set ERROR as default 
			//$('InCountry').value = countryInOptionValues[0];
			document.forms['postform'].InCountry.value=countryInOptionValues[0];
		}
	}

	function setValue(e,id){	
		//alert('setValue');
		if(e==null){return false;}
		var updVal=e.value;
		//var updEl=$(id)
		var updEl=eval("document.forms['postform']."+id)
		//alert(updVal + ' ' +updEl.id);
		if(updEl!=null){
			updEl.value=updVal;
		}
		//alert(updEl.value);
		if (id=='OutLocation'){
			//if this bool is true then check for connections
			//else refill with original values
			// No we fill it in toggledisplay instead
			//alert('isFlight='+isFlight);
			if(isFlight&&arrConnectionlist!=''){
				reBuildInOptions(updVal);
			}
			else{
				//addAllCountries();
			}
		}
	}

	function checkConnections(inIata,inCountry){
		//alert('checkConnections');
		if(arrConnectionlist==''){
			return true;
		}
		else{
			aConns = arrConnectionlist.split(',');
			for(ip=0;ip<aConns.length;ip+=3){
				cCode = inCountry.split(";");
				if(cCode[0]==aConns[ip+2]&&inIata==aConns[ip]){
					//alert('TRÄFF   inIAta='+inIata+' dim0='+aConns[ip]+' dim1='+aConns[ip+1]+' dim2='+aConns[ip+2]+' country='+inCountry);		
					return true;
				}
				else{
					//alert('MISS   ' + cCode[0]+'=='+aConns[ip+2]+'&&'+inIata+'=='+aConns[ip]);
				}
			}
		}
		return false;
	}
	
	function checkConnectionsOnlyDestination(inIata,inVal){
		//alert('checkConnectionsOnlyDestination');
		if(!isFlight){return true;}
		if(arrConnectionlist==''){
			return true;
		}
		else{
			aConns = arrConnectionlist.split(',');
			aInVal = inVal.split(';');
			aInIata = inIata.split(';');
			for(ip=0;ip<aConns.length;ip+=3){
				//alert('inIata= '+inIata +'dim0='+aConns[ip]+' dim1'+aConns[ip+1]+' inVal='+inVal);
				//alert(aInIata[0]+'='+aConns[ip]+ ' ' +aInVal[0]+'='+aConns[ip+1]);
				if(aInIata[0]==aConns[ip]&&aInVal[0]==aConns[ip+1]){
					return true;
				}
			}
		}
		return false;
	}
	
	var InConnectionOptionTexts  = new Array()
	var InConnectionOptionValues  = new Array()
	
	function setInConnections(sCountry,sCity){
		//alert('setInConnections');
		//alert(sCountry);
		//alert(sCity);
		oIn = $('SelOnlyDestinationsIn');
		var myCounter = 0;
		if (InConnectionOptionTexts.length<=1){
			for(ci=0;ci<oIn.options.length;ci++){
				InConnectionOptionTexts[ci] = oIn.options[ci].text;
				InConnectionOptionValues[ci] = oIn.options[ci].value;
			}
		}
		oIn.options.length = 0;
		for(ii=0;ii<InConnectionOptionValues.length;ii++){
				if(checkConnectionsOnlyDestination(sCity,InConnectionOptionValues[ii])){
					oIn.options[myCounter] = new Option(InConnectionOptionTexts[ii],InConnectionOptionValues[ii]);				
					myCounter+=1
				}
				
				if(myCounter>500){
					alert('Eternal Loop, not so good ey?')
					return false;
				}
				if(myCounter==0){
					oIn.options[myCounter] = new Option(InConnectionOptionTexts[0],InConnectionOptionValues[0]);	
				}
		}		
	}
	
	function preSearchSubmit(f){
		//alert(globaltriptype);
		
		/*
		    Errorhandling
		*/
		var gtt = globaltriptype.toLowerCase();
		
		if (gtt == "flighthotel") 
		{
		    if ($('selOutCountry').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[0]);
		        return false;
		    }
		    
		    if ($('selOutLocation').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[1]);
		        return false;
		    }
		    
		    if ($('selInCountry').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[2]);
		        return false;
		    }

		    if ($('selInLocation').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[3]);
		        return false;
		    }

		    if ($('NumberOfRooms').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[4]);
		        return false;
		    }

		    var myOutDateDate=new Date();
            myOutDateDate.setFullYear($F('outdate_Year_ID'), $F('outdate_Month_ID'), $F('outdate_Day_ID'));

		    var myInDateDate=new Date();
            myInDateDate.setFullYear($F('indate_Year_ID'), $F('indate_Month_ID'), $F('indate_Day_ID'));
            
            if (myInDateDate<myOutDateDate) 
            {
                alert(arrSearchEngineAlerts[5]);
                return false;
            }
            
            if (myOutDateDate<new Date())
            {
                alert(arrSearchEngineAlerts[6]);
                return false;
            }
		} 
		else if (gtt == "flight") 
		{
		    if ($('selOutCountry').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[0]);
		        return false;
		    }
		    
		    if ($('selOutLocation').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[1]);
		        return false;
		    }
		    
		    if ($('selInCountry').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[2]);
		        return false;
		    }

		    if ($('selInLocation').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[3]);
		        return false;
		    }
		    
		    if ($('pax').value == 0 && $('selChildren').value == 0) 
		    {
                alert(arrSearchEngineAlerts[7]);
                return false;
		    }

		    var myOutDateDate=new Date();
            myOutDateDate.setFullYear($F('outdate_Year_ID'), $F('outdate_Month_ID'), $F('outdate_Day_ID'));

		    var myInDateDate=new Date();
            myInDateDate.setFullYear($F('indate_Year_ID'), $F('indate_Month_ID'), $F('indate_Day_ID'));
            
            if (myInDateDate<myOutDateDate) 
            {
                alert(arrSearchEngineAlerts[5]);
                return false;
            }

            if (myOutDateDate<new Date())
            {
                alert(arrSearchEngineAlerts[6]);
                return false;
            }
		}
		else if (gtt == "hotel") 
		{
		    if ($('ac1').value == "")
		    {
		        alert(arrSearchEngineAlerts[2]);
		        return false;
		    }
		    
		    if ($('NumberOfRooms').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[4]);
		        return false;
		    }

		    var myOutDateDate=new Date();
            myOutDateDate.setFullYear($F('outdate_Year_ID'), $F('outdate_Month_ID'), $F('outdate_Day_ID'));

		    var myInDateDate=new Date();
            myInDateDate.setFullYear($F('indate_Year_ID'), $F('indate_Month_ID'), $F('indate_Day_ID'));
            
            if (myInDateDate<myOutDateDate) 
            {
                alert(arrSearchEngineAlerts[5]);
                return false;
            }

            if (myOutDateDate<new Date())
            {
                alert(arrSearchEngineAlerts[6]);
                return false;
            }
        }
        else if (gtt == "car") 
        {
		    if ($('selInCountry').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[2]);
		        return false;
		    }

		    if ($('selInLocation').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[2]);
		        return false;
		    }

		    if ($('pickuptime').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[8]);
		        return false;
		    }

		    if ($('returntime').value.toLowerCase() == "error")
		    {
		        alert(arrSearchEngineAlerts[9]);
		        return false;
		    }

		    var myOutDateDate=new Date();
            myOutDateDate.setFullYear($F('outdate_Year_ID'), $F('outdate_Month_ID'), $F('outdate_Day_ID'));

		    var myInDateDate=new Date();
            myInDateDate.setFullYear($F('indate_Year_ID'), $F('indate_Month_ID'), $F('indate_Day_ID'));
            
            if (myInDateDate<myOutDateDate) 
            {
                alert(arrSearchEngineAlerts[5]);
                return false;
            }

            if (myOutDateDate<new Date())
            {
                alert(arrSearchEngineAlerts[6]);
                return false;
            }
        }
		else if (gtt == "pakke") 
		{
		    if ($('pax').value == 0 && $('selChildren').value == 0) 
		    {
                alert(arrSearchEngineAlerts[7]);
                return false;
		    }

		    var myOutDateDate=new Date();
            myOutDateDate.setFullYear($F('outdate_Year_ID'), $F('outdate_Month_ID'), $F('outdate_Day_ID'));

            if (myOutDateDate<new Date())
            {
                alert(arrSearchEngineAlerts[6]);
                return false;
            }
		}		
		/*
		    End Errorhandling
		*/
		
		objOutLoc = $('SelOnlyDestinationsOut');
		if($('OutLocation').value==""){
			if(objOutLoc!=null){
				if(objOutLoc.value.length>0&&objOutLoc.value.toLowerCase()!='error'){
					setCountryValue(true,$('SelOnlyDestinationsOut').value);
				}
			}
			else if($('selOutLocation')!=null){
				setValue($('selOutLocation'),'OutLocation')
			}
		}
		objInLoc = $('SelOnlyDestinationsIn');
		if($('InLocation').value==""){
			if(objInLoc!=null){
				if(objInLoc.value.length>0&&objInLoc.value.toLowerCase()!='error'){
					setCountryValue(false,objInLoc.value);
				}
			}
			else if($('selInLocation')!=null){
				setValue($('selInLocation'),'InLocation')
			}
		}
		
		// JB: kommentera detta om man inte vill submitta formuläret under test.
		f.submit();
	}

	function setCountryValue(bout,val){
		//alert('setCountryValue');
		var oCountry;
		if (bout){
			oCountry = $('OutCountry');
			oLocation = $('OutLocation');
		}
		else{
			oCountry = $('InCountry');
			oLocation = $('InLocation');
			
		}
		var a1 = val.split("_");
		var sCity	 = a1[0];
		var sCountry = a1[1];
		sCity.replace(/'/gi, "");
		sCountry.replace(/'/gi, "");
		//only list available connections if condition below
		if(bout&&arrConnectionlist!=''){
			setInConnections(sCountry,sCity);
		}
		oCountry.value = sCountry;
		oLocation.value = sCity;
		/*
		alert('out='+bout);
		//alert(sCity);
		alert(sCountry);
		alert(document.getElementById('OutCountry').id + ' = ' + document.getElementById('OutCountry').value)
		alert(document.getElementById('InCountry').id + ' = ' + document.getElementById('InCountry').value)
		*/		
	}
	
	function transroomdisp(rms){
		$$('div[rel="selpersonsperroom"]').each(function(el) {
			el.hide();
		});
		if (rms!='ERROR'){
			/*
			Effect.Fade('disp_selpax',{duration: 0.1});
			Effect.Fade('disp_selchildren',{duration: 0.1});
			Effect.Fade('disp_childrenage',{duration: 0.1});
			*/
			ojbSelppr = $('disp_selpersonsperroom');
			if (ojbSelppr!=null){
				//Effect.Appear('selpersonsperroom',{duration: 0.1});
				ojbSelppr.show();
			}
			//alert('after');
			for(r=1;r<=parseInt(rms);r++){
				var thisRoomName = 'transRoomInfo'+r;
				//Effect.Appear(thisRoomName,{duration: 0.1});
				$(thisRoomName).show();	
			}
			
			for(rr=1;rr<=parseInt(rms);rr++){
				var aTextBoxName = 'ChildrenAgeRoom'+rr;
				var aTextBox = $(aTextBoxName);
				aTextBox.onchange=function(){cChildrenAge(this);};
			}
		}
		else{
		
			//I don think this should be shown by this function, set it in the array
			/*
			Effect.Appear('disp_selpax',{duration: 0.2});
			Effect.Appear('disp_selchildren',{duration: 0.2});
			Effect.Appear('disp_childrenage',{duration: 0.2});
			*/
		}
	}

	//AutoCompleter
	function GetValue(element, selectedElement) 
	{
		//alert(globaltriptype);
		var arrIataData = selectedElement.childNodes.item(1).innerHTML.split(";");
		$('InLocation').value = '';
		$('InCountry').value = arrIataData[1];
		$('InLocation').value = arrIataData[1] + "," + arrIataData[4] + "," +  arrIataData[0] + ";" +  arrIataData[1] +";;transhotel|-1;" + arrIataData[8];
		$('InCountry').value = arrIataData[4] + ";";
	}

	function initAutoComplete(){
		new Ajax.Autocompleter('ac1','ac1update','functions/GetPlacesIataWebService.asp',{
			afterUpdateElement: GetValue,
			method: 'post',
			paramName: "value",
			minChars: 3,
			parameters:'fromsearchengine=yes',
			callback: getCurrentTripType
			
			}
		)
	}
	
	function getCurrentTripType(element, entry){
		//alert(element);
		//alert(entry);
		return entry+'&triptype='+globaltriptype;
	}
	//parameters:{ajax:'yes',triptype:globaltriptype}
	/*
	function addLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
	    window.onload = func;
	  } else {
	    window.onload = function() {
	      if (oldonload) {
	        oldonload();
	      }
	      func();
	    }
	  }
	}
	*/
	//postback functions
	function pb_setOutOptions(){
		//alert(req_outcountry.length);
		if(req_outcountry.length>0){
			setOutOptions(req_outcountry);
		}
	}
	function pb_setInOptions(){
		//alert(req_incountry.length+' '+req_incountry);
		if(req_incountry.length>0){
			//alert('pb_setInOptions '+req_incountry);
			setInOptions(req_incountry);
		}
	}
	function pb_transroomdisp(){
		//alert(req_incountry.length);
		if(req_numberofrooms.length>0){
			transroomdisp(req_numberofrooms);
		}
	}	
	//removed the class handles it now
	//addLoadEvent(initAutoComplete);
	function roundcars(){
		$$('div[rel="round"]').each(function(el) {
			//new Effect.Corner(el);
		});	
	}

	function loadmodal(){
		/*
		loadScript("functions/modalbox.js");
		loadStyle("functions/modalbox.css");
		*/

		var oldPath = true;
		var thisPath = pagePath.toLowerCase();
		if (thisPath.indexOf("searchresult_iframe.asp")!=-1||thisPath.indexOf("101-1.html")!=-1){
			var oldPath = false;
		}
		if(oldPath==true){
			loadScript("/functions/control.modal.js");
			loadScript("/functions/modalFunctions.js");
		}
		else{
			loadScript("../../scripts/control.modal.js");
			loadScript("../../scripts/modalFunctions.js");		
		}
	}
	
	function littleCarSearch(frm){
		var tmp_indate = frm.indate2.value;  
		var tmp_outdate = frm.outdate2.value;  
		var tmp_pickuptime = frm.pickuptime.value;  
		var tmp_returntime = frm.returntime.value;
		
		var tmp_incity = document.forms['postToALcForm'].id_incity.value;
		var tmp_InIata = document.forms['postToALcForm'].InIata.value;
		var tmp_InCountry = document.forms['postToALcForm'].InCountry.value;
		var qs="search=yes&indate="+tmp_indate+"&outdate="+tmp_outdate+"&pickuptime="+tmp_pickuptime+"&returntime="+tmp_returntime+"&iniata="+tmp_InIata+"&incity="+tmp_incity+"&incountry="+tmp_InCountry;
		//Modalbox.show('searchModuleCarModal.asp?'+qs, {title: 'Rent a Car',height: 600,loadingString: 'Wait searching...'});
		getAjaxmodal('searchModuleCarModal.asp?'+qs).open();
	
	}
	
	

//addLoadEvent(roundcars);
//addLoadEvent(test);
//addLoadEvent(toggleTab);
   //Event.observe(window, 'load', function() { apa() });
   //Event.observe(window, 'load', function() { myFunction2.init() });

		function openSearchEngine(e){
			
			//var clickedOffset = cumulativeOffset(e);
			var clickedOffset = $(e).cumulativeOffset();
			//alert(clickedOffset[0]);
			//alert(clickedOffset[1]);
			
			var top = clickedOffset[1] - 10;
			var left = clickedOffset[0] + 50;
			
			//content
            var elt         = $('dynSearchEngineFrame');
 
            // retrieve required dimensions
            //var eltDims     = elt.getDimensions();
            //var browserDims = document.viewport.getDimensions();
            //var browserDims = $('tabs').getDimensions();
 
            // calculate the center of the page using the browser and element dimensions
            //var top  = ((browserDims.height - eltDims.height) / 2)+200;
            //var left = (browserDims.width - eltDims.width) / 2;
 
            // set the style of the element so it is centered
            var styles = {
                position : 'absolute',
                top      : top + 'px',
                left     : left + 'px'
            };
 
            elt.setStyle(styles);
			elt.show();
		}
		

		
		function testJson(runNr){
			var jsonVal = $('json'+runNr).value;
			//alert(jsonVal);
			var jsonobj = eval('(' + jsonVal + ')');
			var obj2 = eval('jsonobj.json'+runNr);
			//alert(jsonobj.TransportPriceToShow);
			//alert(obj2.TransportPriceToShow);
		
		}

		function setTransports(bout,transportid,runnr,boundCounter){
		

		    
			//alert(bout);
			//alert('boundCounter::::'+boundCounter);
			//alert(segmentid);
			//alert($F('radio_out_'+runnr));

			
			//var outtransports = $RF('radio_out_'+runnr);
			//var intransports = $RF('radio_in_'+runnr);

			var outtransports = $RF('frm'+runnr,'radio_out_'+runnr);
			var intransports = $RF('frm'+runnr,'radio_in_'+runnr);
		
			
			var jsonTrpVal = $('json'+runnr).value;
			var jsonTrpobj = eval('(' + jsonTrpVal + ')');
			var oTrp = eval('jsonTrpobj.json'+runnr);
			
			//alert(oTrp.TransportPriceToShow)
			//alert(jsonobj.TransportPriceToShow);
			//alert(obj2.TransportPriceToShow);			
			
			
			//alert(outtransports);
			//alert(intransports);
			if(outtransports&&intransports){	
		
				var a_outtransports_bounds = outtransports.split("|");
				var a_intransports_bounds = intransports.split("|");
				var s_outtransports = a_outtransports_bounds[0]
				var s_intransports = a_intransports_bounds[0]
				var outboundcount = a_outtransports_bounds[1]
				var inboundcount = a_intransports_bounds[1]				
				var outlegcount = parseInt($('legs_out_'+runnr).value);
				var inlegcount = parseInt($('legs_in_'+runnr).value);
				
			    //alert("a_outtransports_bounds" + a_outtransports_bounds);
			    //alert("a_intransports_bounds" + a_intransports_bounds);
			    //alert("s_outtransports" + s_outtransports);
			    //alert("s_intransports" + s_intransports);
									    
				var outlegArray = [];
				for(olc = 0; olc < outlegcount; olc++){				
					var RealLegCount = olc+1;
					//alert('flight_out_json_'+runnr+"_"+RealLegCount+"_"+outboundcount)
					var jsonVal = $('flight_out_json_'+runnr+"_"+RealLegCount+"_"+outboundcount).value;
					var jsonobj = eval('(' + jsonVal + ')');
					outlegArray[olc] = eval('jsonobj.out'+RealLegCount);
				}

				var inlegArray = [];
				for(ilc = 0; ilc < inlegcount; ilc++){	
					var RealLegCount = ilc+1;					
					var jsonVal = $('flight_in_json_'+runnr+"_"+RealLegCount+"_"+inboundcount).value;
					var jsonobj = eval('(' + jsonVal + ')');
					inlegArray[ilc] = eval('jsonobj.in'+RealLegCount);
				}					
				
				var a_outtransports = s_outtransports.split(",");
				var a_intransports = s_intransports.split(",");
				for(i = 0; i < a_outtransports.length; i++){
					for(ii = 0; ii < a_intransports.length; ii++){
						if(a_outtransports[i]==a_intransports[ii]){
							//alert('matching transport: '+a_outtransports[i]);
							//alert('out:');
							//printlegArray(outlegArray);
							//alert('in:');
							//printlegArray(inlegArray);
							updateInfoBoxFlights(outlegArray,inlegArray,oTrp);
							return true;
						}
					}
				}
			}
			
		}
		// need to make globals
		var trpidOutArray;
		var trpidInArray;
		var matchingTrpId;		
		function updateInfoBoxFlights(outlegArray,inlegArray,oTrp){
			//$('dynInfoFlights').update();
			trpidOutArray ='';
			trpidInArray ='';
			var sOut = printlegArray(outlegArray,true);
			var sIn = printlegArray(inlegArray,false);
// 			alert('trpid was set to:'+matchingTrpId)
			
			
			// här ska alltså hidden-variablerna som återfinns i new 3(nästa flik)
			// jag tror att de flesta värden ligger på oTrp.xxx eller i funktionen printlegarray nedan under inArray[io].xxx
			// sedan är det kvar logiken för att posta, till order2 eller 3 eller byta flik, den logiken börjar på rad 242 i new 3
			// den tror jag att det bara skall vara att saxa in.
			// hej hopp... 0736918203 roobin.ericsson@gmail.com 
			// Roobin (ta bort kommentaren annars hittar någon spindel min mailadress i källan osså blir det maaaassoor av viagramail)
			
			
			var InfoBox = $('search_infobox');						
			InfoBox.show();
			var flightBox = $('rightSearchWrap');
			var vo=flightBox.viewportOffset()[1]; 
			if(vo<0){
				flightBox.scrollTo();
			}
			$('dynInfoFlights').update('<p>Out<br />'+sOut+'In<br />'+sIn+'</p>');
			$('dynInfoPrice').update('<p><b>'+oTrp.TransportPriceToShow+'</b></p>');			
			new Effect.Highlight('search_infobox', {startcolor: "#ffffff",endcolor: "#666666",restorecolor: "#ffffff",duration: 0.3});
			
			var thiswsType = oTrp.webservice;
			var sXml = $(thiswsType+'_xml').value;
			document.postToALcForm.externalflightXmlfile.value = sXml;
			var sId = oTrp.id;
			
			document.postToALcForm.trpPrice.value = oTrp.TransportPriceToShow;
			document.postToALcForm.dbe_trpPrice.value = oTrp.TransportPriceToShow;
			document.postToALcForm.PriceCode.value = oTrp.priceCode;
			 
			if (thiswsType!='internaltransports'){
				if(outlegArray.length>=0&&inlegArray.length>=0){
					document.postToALcForm.flightNumber1.value = outlegArray[0].SegmentId;
					document.postToALcForm.flightNumber2.value = inlegArray[0].SegmentId;
					
					//alert("outlegArray[0].StartTime: " + outlegArray[0].StartTime);
					//alert("outlegArray[0].StartTime: " + inlegArray[0].StartTime);
					
					document.postToALcForm.externalflightDepartureTimeOut.value = outlegArray[0].StartTime;
					document.postToALcForm.externalflightDepartureTimeIn.value  = inlegArray[0].StartTime;
					
					if (thiswsType=='iceexp')
					{
						document.postToALcForm.transportID.value = outlegArray[0].transportId;
						document.postToALcForm.transportID2.value = inlegArray[0].transportId;
					}
					else if (thiswsType=='sterling')
					{
						document.postToALcForm.transportID.value = sId;
					}
					else if (thiswsType=='galileo')
					{
					    //alert("!!!");
					    document.postToALcForm.transportID.value = sId;
					}
					else if (thiswsType == 'LCC')
					{
					    //alert("!");
					    //alert("sId: " + sId);
					    //alert("document.postToALcForm.trpPrice.value: " + document.postToALcForm.trpPrice.value);
					    thiswsType = "lcc";
                        document.postToALcForm.transportID.value = matchingTrpId;
                        document.postToALcForm.trpPrice.value = oTrp.price;					
                    }
					else 
					{
						document.postToALcForm.transportID.value = matchingTrpId;
					}
					
				}
				document.postToALcForm.externalflightwebserviceType.value = thiswsType;
			}
			
        	


		//  	alert("sId= "+sId);
// 			alert("thiswsType= "+thiswsType);
// 			alert("oTrp.runNr= "+oTrp.runNr);
// 			alert('matchingTrpId: '+matchingTrpId);
// 			
// 				alert('SegmentId ' + inArray[io].SegmentId);
//  				alert('transportId ' + inArray[io].transportId);
// 				alert('CarrierCode ' + inArray[io].CarrierCode);
// 				alert('flightDuration ' + inArray[io].flightDuration);
// 				alert('flightCounter ' + inArray[io].flightCounter);
			
			//InfoBox.show();

			
			//new Effect.Shake('search_infobox',{duration:0.1,distance:5});
						
		}

		function printlegArray(inArray,isOut){
			var sRet='';
			for(io = 0; io < inArray.length; io++){
				if(inArray[io].testIds.length>=0){
					if(isOut){
						trpidOutArray = inArray[io].testIds.split(",");
					}
					else{
						trpidInArray = inArray[io].testIds.split(",");
					}
				}
				if(!isOut&&trpidOutArray.length>=0&&trpidInArray.length>=0){
					//alert('lengths:  '+trpidOutArray.length+' _ '+trpidInArray.length);
					matchingTrpId=-1;
					//alert('isout= ' + isOut);
					for(i = 0; i < trpidOutArray.length; i++){
						for(x = 0; x < trpidInArray.length; x++){
							if(trpidOutArray[i]==trpidInArray[x]){
								matchingTrpId = trpidOutArray[i];
								break;
							}

						}
						if(matchingTrpId!=-1){
									break;
						}
					}
				}
				
				sRet +='<span>'+inArray[io].StartLocation+' '+inArray[io].StartTime+'</span><br />';
				
				// alert(inArray[io].StartLocation);
// 				alert(inArray[io].StartTime);
// 				alert(inArray[io].CarrierCode);
// 				alert(inArray[io].endlocation);
// 				alert(inArray[io].EndTime);
				
			}
			return sRet;
		}
		
		/*
		function $RF(reid) {
			//return $$('input[type=radio][name='+ $(reid).name +']').find(function(el){return el.checked}).value;
			return Form.getInputs('myform','radio','type').find(function(radio) { return radio.checked; }).value;
		}
*/
		function $RF(el, radioGroup) {
			/*
			alert('rf');
			alert('el: '+ el);
			alert('$el' + $(el));
		    */
			if($(el).type && $(el).type.toLowerCase() == 'radio') {
		        var radioGroup = $(el).name;
		        var el = $(el).form;
		    } else if ($(el).tagName.toLowerCase() != 'form') {
		        return false;
		    }
		 
		    var checked = $(el).getInputs('radio', radioGroup).find(
		        function(re) {return re.checked;}
		    );
		    return (checked) ? $F(checked) : null;
		}
		

	function submitpostToALcForm(){
		var rootpath = '';
		rootpath = document.forms['postToALcForm'].rootpath.value;
		//alert(rootpath+'/alc/order3.asp');
		//document.forms['postToALcForm'].action='/postform_test.asp';	
		document.forms['postToALcForm'].action=rootpath+'/alc/order3.asp';
		//document.forms['postToALcForm'].target="_blank";
					
		document.postToALcForm.submit();
	}