$(document).ready(function(){	var 	noSelectBox = false;		isMobile = false;		isIE6 = ($.browser.msie && parseFloat( $.browser.version) < 7 );		var brwser=(navigator.userAgent + navigator.vendor + window.opera);		if(/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(brwser)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(brwser.substr(0,4))){isMobile=true};		if( isIE6 || isMobile ) {			noSelectBox = true;			}			$("#nav1 td.lnx").hover(function() { $(this).addClass("lnxHov") },function() { $(this).removeClass("lnxHov") });		//$("#offersSpaceContainer2").css('display','none'); This needs to be loaded when the slider rendering have been finished ==> see further down	$('#otb #tabs2 li a').click(function(e){		$(this).parents('ul#tabs2').find('li').removeClass('act');		$(this).parent().addClass('act').removeClass('left');		e.preventDefault();		$(this).parent().prevAll().addClass('left');		//Get the index		index = $(this).attr("index");		$("#offersSpaceContainer1").css('display','none');		$("#offersSpaceContainer2").css('display','none');		$("#offersSpaceContainer" + (index)).css('display','block');	});	$('#etacountry, select#xettcountry, #car').selectBox({entries:"8"});	$('#etastation,  select#xettstation').selectBox({entries:"8", showDetails:true});    $('#check_code').click(function(){	// now toggle here because of cross browser issues,bubbleevents        if($(this).is(':checked'))		{			$('#codeOptional').slideDown();		} else {			$('#codeOptional').slideUp();		}    });	$('label[for="check_code"]').click(function(){		$('#codeOptional').slideToggle();	});	$('#ettcountry_ro a').click(function(e){			var xS = $(this).prevAll('select');		var d = $(this).parents('div:eq(0)');		//d.next().show();		d.replaceWith( xS );		if( !noSelectBox ) {			xS.selectBox({entries:"8"});		} else {			xS.show();		}		$('#ettstation_ro a').trigger('click');		try{gCTR2changed = 0;}catch(e){}		e.preventDefault();	})	$('#ettstation_ro a').click(function(e){			var xS = $(this).prevAll('select');		var d = $(this).parents('div:eq(0)');		d.prevAll('.restrictStations').find('table').show();		x = $('input[name="restrictstationsSTA"]:checked').val();		$('#restrictstationsILC' + x ).attr('checked','checked');		//restrictstationsILC		d.replaceWith( xS );		if( !noSelectBox ) {			xS.selectBox({entries:"8", showDetails:true});		} else {			xS.show();		}		e.preventDefault();	})	$('#cor_ro a').click(function(e){			var xS = $(this).prevAll('select');		var d = $(this).parents('div:eq(0)');		d.replaceWith( xS );		if( !noSelectBox ) {			xS.selectBox({entries:"8", showDetails:false});		} else {			xS.show();		}		e.preventDefault();		$('#check_code').css({position:'relative'});	})	//== cargroup-selector	$('#cargroupSelector li a').click(function(e){		$(this).parents('ul').find('li').removeClass('act');		$(this).parent().addClass('act');		e.preventDefault();	})	// Offersspace 1	var api = $("div.#offersSpaceContent1").scrollable({		keyboard:false,		next:'#offersSpaceContainer1Next',		prev:'#offersSpaceContainer1Prev',		prevPage: '#offersSpaceBottomNavPrevLink1',		nextPage: '#offersSpaceBottomNavNextLink1',		api:true,		size:1,		speed:1000,		onSeek:function(){			this.getRoot().parents().find("#offersSpaceBottomPageCounter1").text(this.getPageIndex()+1);		}	});     	if( api ){	     if (api.getPageAmount() <= 1 ){	     	//alert('items:' + api.getItems().length + "anzeigemenge:" + api.getSize())			$("#offersSpaceBottomNavNextLink1").addClass("disabled")			api.getRoot().parents('.sliderContainer').find(".sliderNext").hide();		}  		api.getRoot().parents().find("#offersSpaceBottomPageCounter1").text(api.getPageIndex()+1);		api.getRoot().parents().find("#offersSpaceBottomPageCounterTotal1").text(api.getPageAmount());	}    // Offersspace 2	var api2 = $("div.#offersSpaceContent2").scrollable({		keyboard:false,		next:'#offersSpaceContainer2Next',		prev:'#offersSpaceContainer2Prev',		prevPage: '#offersSpaceBottomNavPrevLink2',		nextPage: '#offersSpaceBottomNavNextLink2',		api:true,		speed:1000,		size:1,		onSeek:function(){			this.getRoot().parents('.sliderContainer').find("#offersSpaceBottomPageCounter2").text(this.getPageIndex()+1);		}	});		if( api2){	     if (api2.getPageAmount() <= 1 ) {			$("#offersSpaceBottomNavNextLink2").addClass("disabled")			api2.getRoot().parents('.sliderContainer').find(".sliderNext").hide();		}		api2.getRoot().parents().find("#offersSpaceBottomPageCounter2").text(api2.getPageIndex()+1);		api2.getRoot().parents().find("#offersSpaceBottomPageCounterTotal2").text(api2.getPageAmount());	 }    // ReasonSpace  	var api_reason = $("div.#reasonSpaceContainer").scrollable({		keyboard:false,		next: '#reasonSpaceContainerNext',		prev: '#reasonSpaceContainerPrev',		api:true,		clickable:false,		size:3,		onSeek:function(){			if(this.getIndex() == 0) $("#reasonSpaceBottomNavPrevLink").addClass("disabled");			else  $("#reasonSpaceBottomNavPrevLink").removeClass("disabled");        	        if (this.getIndex() >= this.getSize() - this.getConf().size) $("#reasonSpaceBottomNavNextLink").addClass("disabled");	        else  $("#reasonSpaceBottomNavNextLink").removeClass("disabled");	    }    });    	if(api_reason)	{		//       	if (api_reason.getItems().length <= api_reason.getSize() ){        	if (api_reason.getPageAmount() <= 1 ){			$("#reasonSpaceBottomNavNextLink").addClass("disabled")			$('#reasonSpaceContainer').find(".sliderNext").hide();		}        			$("#reasonSpaceBottomNavPrevLink").click(function(){			api_reason.prev();		});		$("#reasonSpaceBottomNavNextLink").click(function(){			api_reason.next();		});	}            // LocationSpace	var api3 = $("div.#locations").scrollable({		keyboard: false,		prevPage: '#locationSpaceBottomNavPrevLink',		nextPage: '#locationSpaceBottomNavNextLink',		api:true,		size:1,		onSeek:function(){			this.getRoot().siblings().find(".pageCounter").text(this.getPageIndex()+1);		}	});    if( api3){    api3.getRoot().siblings().find(".pageCounter").text(api3.getPageIndex()+1);    api3.getRoot().siblings().find(".pageCounterTotal").text(api3.getPageAmount());      }		// == styling for offer und reasonspace    $('.cts').before('<div class="container c305t"></div>');    $('.cts').after('<div class="container c305b"></div>');    $('.cts').addClass('ccb c305');    $('.cts').removeClass('container');    $('.ctm').before('<div class="container c630t"></div>');    $('.ctm').after('<div class="container c630b"></div>');    $('.ctm').addClass('ccb c630');    $('.ctm').removeClass('container');    $('.ctl').before('<div class="container c955t"></div>');    $('.ctl').after('<div class="container c955b"></div>');    $('.ctl').addClass('ccb c955');    $('.ctl').removeClass('container');    $('.container.cl').before('<div class="container c955t"></div>');    $('.container.cl').after('<div class="container c955b"></div>');    $('.container.cl').addClass('ccb c955');    $('.container.cl').removeClass('container');				/* == STEP 2 == */	//== cargroup-selector	$('#cargroupSelector li a').click(function(e){		sel = $(this);		sel.parents('ul').find('li').removeClass('act');		sel.parent().addClass('act');		sel_cg = sel.attr('href').split('#')[1];		if( !(sel_cg == 'all') )		{			$('.cargroup:not(.not' + sel_cg+')').show();			$('.not' + sel_cg ).fadeOut();		}		else		{			$('.cargroup').show();		}		e.preventDefault();	})	//== price	$('.cg_details img').click(function(){		var pp = $(this).parents('.cargroup').find('td.pp');		var poa = $(this).parents('.cargroup').find('td.poa');		if( pp.length ) {			pp.trigger('click');		} else {			poa.trigger('click');		}	})		$( '.cg_price td a.bb' ).click( function(e){		// prevent the "#"-Click		e.preventDefault();	} )		$('.cg_price td.poa, .cg_price td.pp').click(function(){				if( $(this).hasClass('active') ) {			return false;		}		try{			window.clearTimeout(killOverlay)		}catch(e){			//console.log( e )		}				var cell = $(this);		var cell_class = cell.attr('class');		var cell_type = cell_class.replace(/active|inactive/, "");		    cell_type = cell_type.replace(/ /, "").toUpperCase();		//console.log(cell_type)						var cont = $(".continue");		//hide continue buttons until other content is loaded		//cont.hide();				$('.poa, .pp').removeClass('active').removeClass('inactive').find('input').removeAttr('checked');				cell.addClass("active" ).removeClass('inactive');		cell.siblings('td').removeClass('active').addClass('inactive')		cell.find('input').attr('checked', 'checked');				var cg_extras = $(this).parents('.cargroup').find('.cg_extras');				$('.cg_extras').hide();			if( 			$('.loading').length && 			(				( $('.active').hasClass('poa') && $(this).hasClass('poa') ) ||				( $('.active').hasClass('pp') && $(this).hasClass('pp') )			)		) {			$('.loading').remove();		}				if( !cg_extras.find('.loading').length && !(cg_extras.is(':visible')) )		{			$('.cg_extras').slideUp();						//$('#addextras').appendTo( cg_extras.find('.addextras') ).show();						_SEELEMENTS = [];			$('[name="SEELEMENTS"]').each(function(idx){			    if( $(this).is(':checkbox') && $(this).is(':checked') ){			         _SEELEMENTS.push( $(this).val() )			    }			    if( !$(this).is(':checkbox') ){			        _SEELEMENTS.push( $(this).val() )			    }			});			var SEELEMENTS = _SEELEMENTS.join('|');			$('#addextras').remove();			var addExtras = cg_extras.find('.addextras');			addExtras.hide();			addExtras.load( 				seUrl  +"&GRP="+ ( cg_extras.parents('.cargroup').attr('id').split('_')[1] ) 				+ gSEChanged 				+ "&PREFILL=" + escape( SEELEMENTS ),				function(){					if ( $.browser.msie ) { // fix IE 						//cg_extras.find('.loading:first').height( cg_extras.height()-20 )					}					addExtras.slideDown();				}			).show();						var xrf = cg_extras.find('.addextras').next().empty().addClass("inclusions");			//try{console.log(xrf.html())}catch(e){}						cg_extras.show(); // ie fix, please leave.						cg_extras.find('select').hide();						//set min-height for loading message			//cg_extras.css("minHeight", "290px");					cg_extras.css({'position':'relative'}).append(				'<div class="loading" id="load0" style="background-color:#ccc;opacity:0.7;filter:alpha(opacity=70);position:absolute;top:10px;bottom:10px;left:10px;z-index:1001;width:576px;float:left;"></div>' + 				'<div class="loading" id="load1" style="padding:2em;text-align:center;background-color:#fff;position:absolute;top:30px;right:50px;width:452px;z-index:1002;">'+					'<div class="subh" style="text-align:center;padding-bottom:2em;">' + gWaitText + '</div>'+					"<div>"+ gWaitImageURL  +"</div>"+  				'</div>'			).show();					if ( $.browser.msie &&  $.browser.version < 6.5 ) // IE6 FIX			{				cg_extras.find('#load0').height( cg_extras.height()-20-50 )				document.getElementById('load0' ).style.left = "10px";			}				}		// needs to be 		var cargrp = cell.parents('div.cargroup').attr('id');						var cargrpid = cell.parents('div.cargroup').attr('data-name');		var reqcg = cargrp.split('_')[1];		    reqcg = reqcg.toUpperCase();		// set the car group		//console.log(cell_type+  '_' + reqcg)		$('input[name="upspayment"]').val( cell_type+  '_' + reqcg );				// fade other cargroups:		$('div.cargroup').removeClass('inactive_cargroup')		$('div.cargroup:not(#'+cargrp+')').addClass('inactive_cargroup')		var rate = poaPrices[ cargrp ].rat;		/* AJAX-Request for extras  */		cg_extras.find('.exclusions').remove();		var inclusions = cg_extras.find('.inclusions').hide();		$.get(			inclusionUrl + "&RAT=" + rate + "&GRP=" + reqcg + "&ID=" + cargrpid,			function(data){								//try{console.log(data)}catch(e){}				//inclusions.replaceWith('<div style="display:none" class="inclusions">' + (data) + '</div>').slideDown(); //old call, do not remove				inclusions.replaceWith( '<div>' + (data) + '</div>' ).slideDown(); //old call, do not remove								//cg_extras.find('.inclusions').html(data);				//cg_extras.find('.continue').before( data );				if ( $.browser.msie &&  $.browser.version < 6.5 )				{					cg_extras.find('#load0').height( cg_extras.height()-20-50 )					document.getElementById('load0' ).style.left = "10px";									}				inclusions.slideDown();				//cg_extras.css("minHeight", "");				//show continue buttons only after inlusions pane is successfully loaded				//cont.slideDown();				killOverlay = window.setTimeout("$('.loading').remove();$('.cg_extras select:hidden').show()	", 2000);							},"html"		)		if( cell.parents('div.cargroup').find('.poa.active').length )		{			$( '#' + cargrp + " .continue .par").hide();			$( '#' + cargrp + " .continue .par2").show();				} else {			$( '#' + cargrp + " .continue .par2").hide();			$( '#' + cargrp + " .continue .par").show();		}		/*				// -- CALL recalculate SE in Form ReservationStep2 --*/				recalculateSEPrice( $('#ADDR'), "");						});			if( typeof( openSingleCGWithPrice) != "undefined" && typeof( openSingleCGIndex ) != "undefined"  ) {		if ( openSingleCGWithPrice == "POA" )		{			$('.cargroup:eq('+ openSingleCGIndex+ ') .cg_price td.pr').trigger('click');		}		if ( openSingleCGWithPrice == "PP" )		{			$('.cargroup:eq(' + openSingleCGIndex + ') .cg_price td.pp').trigger('click');		}	}	// == local information toggle	$('a#sli').click(		function(){			link = $(this);			$('#sli_det').slideToggle('',function(){				link.toggleClass('down');			});			link.find('.show, .hide').toggle();			return false;		}	);			$('a#sfr').click(		function(){					link = $(this);			$('#sfr_det').slideToggle('',function(){				link.toggleClass('down');			});			link.find('.show, .hide').toggle();			return false;		}	);			/* JS HOVER TOOLTIPS ( FIX FOR IE6 ) */	$('.info').live('mouseover', function(){		xBodyWidth = $('body').width() - 30;				var off = $(this).offset();		var txt = $(this).find('.txt')		txt2 = txt.clone()		txt2.appendTo('body');		if( off.left + 210 > xBodyWidth )		{			$(this).removeClass('info_hover').addClass('info_left_hover');			txt2.css({				position: 'absolute',				top: off.top - 15,				left: off.left - 212,				display: 'block'			});			if( $(this).parent().hasClass('subh') || $(this).parent().hasClass('act_cg_h') ) {				txt2.css({					Mieterleft: off.left - 208				})			}		}else{			$(this).addClass('info_hover');			txt2.css({				position: 'absolute',				top: off.top - 15,				left: off.left + 26,				display: 'block'			});			if( $(this).parent().hasClass('subh') || $(this).parent().hasClass('act_cg_h') ) {				txt2.css({					left: off.left + 30				})			}		}		})	$('.info').live('mouseout',function(){		$(this).removeClass('info_hover').removeClass('info_left_hover');		$('body > .txt').remove();	})	$('body > .txt').mouseover(		function(e){			e.preventDefault();		}	)					/* JS HOVER TOOLTIPS for details ( FIX FOR IE6 ) */	$('.details input, .details select').focus(		function(){			$(this).next('span.details_infow').addClass('details_infow_hover');			var off= $(this).parents('td').offset();					var txt = $(this).next('span.details_infow')			txt2 = txt.clone().appendTo('body');			txt2.css({				position: 'absolute',				top: off.top - 10,				left: off.left + 183,				display:'block'			});					})		$('.details input, .details select').blur(		function(){			$(this).next().removeClass('details_infow_hover');			$('body > .details_infow').remove();		}	)			/* fix for ie for step 2*/	$('.continue a.bb').hover(		function(){			$(this).find('span').css({				color:'#ff9800',				backgroundPosition: 'left -30px'			})		},		function(){			$(this).find('span').css({				color:'#fff',				backgroundPosition: 'left 0px'			})				}	)	$('.upgrade a.bs').hover(		function(){			$(this).find('span').css({				color:'#00338d',				backgroundPosition: 'left -22px'			})		},		function(){			$(this).find('span').css({				color:'#ff9800',				backgroundPosition: 'left 0px'			})				}	)})/*==== NORMAL JS FUNCTIONS AFTER HERE ====*//* QUICKBOOKING FUNCTIONS FOR Iq-SHARE and IBE*/function adjustETT(iDay, iMonth, iYear , iSep, iDiff){	var xF = document.forms[0];	var Day = Number( iDay );	var Month = Number( iMonth );	var Year = Number( iYear );	var Diff = iDiff ;	var Stop = 31;		if( Month==4 ||Month==6 || Month==9 || Month==11 )  {		--Stop;		xxx = "Month = 4,6,9,oder 11";	}	if(Month==2){		Stop =28;		xxx = "Month = 2";		if(Year%4==0) Stop++;		if(Year%100==0) Stop--;		if(Year%400==0) Stop++;	}	if ((Day + Diff) > Stop){		if (Month == 12){			var  xMonth = 1  + '';			var xDay =  Day + Diff - Stop   + '';   			var xYear = Year+1 ;		}		else{			var xMonth = Month+1   + '';			var xDay =  Day + Diff - Stop   + '';			var xYear = Year  ;		}	}	else{		xMonth = Month   + '';		xDay = Day + Diff   + '';		xYear = Year  ;	}	if( xMonth.length == 1) 		xMonth = '0' + xMonth;	if( xDay.length == 1) 		xDay = '0' + xDay;	var xNewDate = gDateFormat.replace(/dd/ , xDay).replace(/mm/ , xMonth).replace(/yy/g , xYear);	$('input[name="ettDate"]').val( xNewDate );}function loadCarGroups( iURL,  iSTA, iDefaultGRP ){	gSelectedSTA = iSTA;	$.get( iURL + '&STA=' + gSelectedSTA +  '&RAN=' + Math.random() , 		function(data){			toggleCarGroups( data , iDefaultGRP);			}		);}function setReturnLocation( iSTA ){	if( gILCchanged == false){		var 	xSelectILC = $('#ettstation');		$('#ettstationTXT').text( $('#etastation').find('option:selected').text());		xSelectILC.val( $('#etastation').val() );		xSelectILC = xSelectILC.parent();		xSelectILC.find( '.display' ).text( xSelectILC.find('option:selected').text());	}}function toggleCarGroups( iXMLOutput , iDefault ){	var xSelectGRP = $('#car');	xHTML= '';	xLbl = $( '#PleaseSelectGRP' ).val();	 	if( iXMLOutput.search(/^ERROR/) == -1)	{		var xSelected = false;				var xTextArray;		var xLocList = unescape(decodeURI(iXMLOutput.replace( /\n/, ""))).split('~'); 		xHTML += '<option value="">' + xLbl + '</option>';		for( var i=0; i<xLocList.length; i++)		{			xTextArray = xLocList[i].split('|');						if( xTextArray[1] == iDefault){				xHTML += '<option value="' + xTextArray[1] + '" selected="selected">' + xTextArray[0] + '</option>';				xDefaultFound = true;			}			else				xHTML += '<option value="' + xTextArray[1] + '">' + xTextArray[0] + '</option>';		}		}	xSelectGRP.html( xHTML);	xSelectGRP = xSelectGRP.parent();	xSelectGRP.find( '.display' ).text( xSelectGRP.find('option:selected').text());}function loadLocationDetailsData( iXMLOutput ){ 	if( iXMLOutput.search(/^ERROR/) == -1)	{		var xSelected = false;				var xHTML = '';		var xAllLocationsListEntry ='';		var xMenmonicCode = '';		var xDetails = '';		var xAllLocationsList = unescape(decodeURI(iXMLOutput.replace( /\n/, "") )).split('~'); 		// go through the list and write data into object		//=========================================================================		for( var xCounter = 0; xCounter < xAllLocationsList.length; xCounter++)			{			xAllLocationsListEntry = xAllLocationsList[xCounter].split('$A$');	// left from $A$ = label and value, right from $A$ = 1 if airport stat			xMenmonicCode = xAllLocationsListEntry[0];			xDetails =  xAllLocationsListEntry[1];			stationDetails[ xMenmonicCode ] =  xDetails ;		}	} }function wrapError( _elem, _message ){	if( $( _elem ).parents('.errWrapper').length )	{		$('.qb_errordiv .qb_top_error').append( '<div class="errCt">' + _message + '</div>' );		return;	}	$( _elem ).parents('.select_replace, table').wrap('<div class="errWrapper"></div>').parent().append('<div class="errMessage">'+ _message +'</span>')	$('.qb_errordiv .qb_top_error').append( '<div class="errCt">' + _message + '</div>' );}function wrapErrorInner( _elem, _message ){	if( $( _elem ).parents('.errWrapper').length )	{		$('.qb_errordiv .qb_top_error').append( '<div class="errCt">' + _message + '</div>' );		return;	}	$( _elem ).wrap('<div class="errWrapper"></div>').parent().append('<div class="errMessage">'+ _message +'</span>')	$('.qb_errordiv .qb_top_error').append( '<div class="errCt">' + _message + '</div>' );}function removeError( _elem ){	var dd = $( _elem ).parents('.select_replace, table, td');	$( _elem ).parents('.errWrapper').replaceWith(dd);}function removeErrorInner( _elem ){	var dd = $( _elem );	$( _elem ).parents('.errWrapper').replaceWith(dd);}validate = function(){	$('.errCt').remove();	$('.qb_errordiv').hide()	var ret = true;	/*  PICKUP VALIDATION */	if( $('.typeahead').is(':visible') ) {		if( 	$('#sta_search').data('country') == "" 	) {wrapError( '#etacountry', gErrMSG01 );			ret = false;		}else (removeError('#etacountry') )	} else {		if( 	$('#etacountry').val() == "" 	) {wrapError( '#etacountry', gErrMSG01 );			ret = false;		}else (removeError('#etacountry') )	}			/*  COR VALIDATION */	if( 	$('#cor').val() == "" 	) {wrapError( '#cor', gErrMSG08 );		ret = false;	}else (removeError('#cor') )	if( $('.typeahead').is(':visible') ) {		if( 	$('#eta_search').data('station') == "" 	) {wrapError( '#etastation', gErrMSG01 );			ret = false;		} else (removeError('#etastation') )			} else {		if( 	$('#etastation').val() == "" 	) {wrapError( '#etastation', gErrMSG01 );			ret = false;		} else (removeError('#etastation') )	}	/* DATE VALIDATION */	var etaDate = $('#etaDate').datepicker('getDate' );		etaDate.setHours( $('#etatimehour').val() );		etaDate.setMinutes( $('#etatimeminute').val() );	var ettDate = $('#ettDate').datepicker('getDate' );		ettDate.setHours( $('#etttimehour').val() );		ettDate.setMinutes( $('#etttimeminute').val() );	var dateDiff = ettDate - etaDate;	if( dateDiff <= 0  )	{		wrapErrorInner( '.date:has(#ettDate)' , gErrMSG03  );		$('#ettDate').parents('.errWrapper').css({marginTop:"15px"});		$('#ettDate').parents('table').css({marginTop:"16px"});		ret = false;	} else {removeErrorInner('.date:has(#ettDate)') }	if( $('#dropoffLocationSec .select_replace').length )	{		$('#dropoffLocationSec .select_replace select').each(			function() 			{				if( $(this).val() == '' ) 				{					wrapError( ( '#' + $(this).attr('id') ), gErrMSG02 );				}			}		)	} 	if( $('#check_code').is(':checked') )	{				bcd_el = $('#bcd');		var bcd="";		try {			if( bcd_el.is('input') )  {				bcd = bcd_el.val();			} else {				bcd = bcd_el.text();			}		}catch(e){}				testBCD = /\b([a-zA-Z][0-9]{6})\b/;		if( $('#bcd').length && bcd != "" &&  !testBCD.test( bcd ) )		{			wrapErrorInner( '#bcd' , gErrMSG04  );			ret = false;		} //else (removeErrorInner('#bcd') )		bcn = $('#bcn').val();		testBCN = /\b([a-zA-Z0-9]{6})\b/;		if( $('#bcn').length && bcn != "" && !testBCN.test( bcn ) )		{			wrapErrorInner( '#bcn' , gErrMSG06  );			ret = false;		}else (removeErrorInner('#bcn') )		removeErrorInner('#code_surname')		removeErrorInner('#bcn')		if(  $('#bcn').length && bcn != "" && $('#code_surname').val() == "" )		{			wrapErrorInner( '#code_surname' , gErrMSG05  );			ret = false;		}		if(  $('#bcn').length && bcn == "" && $('#code_surname').val() != "" )	{			wrapErrorInner( '#bcn' , gErrMSG07  );			ret = false;		}	}	if( $('#car').parents('.select_replace:visible').length )	{		if( gIsCarMandatory && ($('#car').val() == "") )		{			wrapError( '#car', gErrMSG09 );			ret = false;		}	}	if(ret == false)	{		$('.qb_errordiv').show();	}	return ret;}function toggleFilteredLocations( iXMLOutput, iType, iCrossBorder, iDefault, iName, iCountry ){//	try{console.log(//		 ","+ iType +","+ iCrossBorder +","+ iDefault +","+ iName +","+ iCountry//	)}catch(e){}	//alert('START TOOGLE LOCATION');	ReturnLocationFixed = false;	var xTargetItemSTA = document.getElementById( 'etastation' );	var xTargetItemILC = document.getElementById( 'ettstation');	 		if( iXMLOutput.search(/^ERROR/) == -1)		{			var xSelected = false;					var yAir = 0;			var yFav = 0;			var yFavAir = 0;			var yFavDown = 0;			var yDow = 0;			var yCBCountryCount =0;			var xDefaultFound = false;			var Default = ''; 			var xTextArray;			var xHTML = ''; 			var xAllLocationsList = new Array();			var xAllLocationsListEntry = new Array();			var xFavList = new Array();			var xFavListComplete = new Array();			var xFavListCompleteAir = new Array();			var xFavListCompleteDown = new Array();			var xAirportListComplete = new Array();			var xDowntownListComplete = new Array();			var xCBCountryList = new Array(); 			var xFav = $( '#CookieStations' );			xFavList = xFav.val().split('~');  			var xAllLocationsList = unescape(decodeURI(iXMLOutput.replace( /\n/, "") )).split('~');  			// go through the list and write airport staions and downtown stations into different lists			//=========================================================================			for( var xCounter = 1; xCounter < xAllLocationsList.length; xCounter++)	// the 1st entry is always '- - - - - - | -1' . 1st value is written by AjaxWebServices agent			{				xAllLocationsListEntry = xAllLocationsList[xCounter].split('$A$');	// left from $A$ = label and value, right from $A$ = 1 if airport stat				var xLocList = xAllLocationsListEntry[0]; 				if( xLocList != '' )				{					var xAirportFlag = 0;  					if( xAllLocationsListEntry[2] && (xAllLocationsListEntry[2] == '1') ){	 					xTextArray = xLocList.split('|'); 						xCBCountryList[ yCBCountryCount ] = xTextArray[1] ;		//array with dynamic Cross border stations						yCBCountryCount++; //gCBLocationCount  					} 					 					if( xAllLocationsListEntry[1] && (xAllLocationsListEntry[1] == '1') )						xAirportFlag = 1;									if( xAirportFlag )	// >>> write airport stations into a list ============						{						xAirportListComplete[yAir] = xLocList ;		//array with airport stations						yAir++;												// >>> write favorits into a list airport only ============						xTextArray = xLocList.split('|');						for( var c=0; c<xFavList.length; c++)						{								if( xTextArray[1] == xFavList[c] )							{								xFavListCompleteAir[yFavAir]= xLocList;	//array with favorit stations								yFavAir++;							}						}																	}									else			// >>> write downtown stations into a list ============					{						xDowntownListComplete[yDow] = xLocList ;	//array with favorit stations						yDow++;												// >>> write favorits into a list downtown only ============						xTextArray = xLocList.split('|');						for( var c=0; c<xFavList.length; c++)						{								if( xTextArray[1] == xFavList[c] )							{								xFavListCompleteDown[yFavDown]= xLocList;	//array with favorit stations								yFavDown++;							}						}					} 					// >>> write favorits into a list ============					xTextArray = xLocList.split('|');					for( var c=0; c<xFavList.length; c++)					{							if( xTextArray[1] == xFavList[c] )						{							xFavListComplete[yFav]= xLocList;	//array with favorit stations							yFav++;						}					}				}			}						//+++ assign correct list of favorites +++++++++++++++++++++++++++++++			if( iType=='a')				xFavListComplete = xFavListCompleteAir;			else if( iType=='c')				xFavListComplete = xFavListCompleteDown;			 			// go through all lists and write stations into the fields			//========================================================================= 			xLbl = $( '#PleaseSelectSTA' ).val();			xHTML += '<option value="">' + xLbl  + '</option>';						// >>> write FAVORITS into stations fields ============			if( xFavListComplete.length > 0 )			{				xLbl = $( '#FavoriteLocations' ).val();	// headline Favorits				xHTML += '<optgroup label="' + xLbl + '">';				for( var i=0; i< xFavListComplete.length; i++){					xTextArray = xFavListComplete[i].split('|');															if( xTextArray[1] == iDefault){						xHTML += '<option value="' + xTextArray[1] + '" selected="selected">' + xTextArray[0] + '</option>';						xDefaultFound = true;					}					else						xHTML += '<option value="' + xTextArray[1] + '">' + xTextArray[0] + '</option>';				}				xHTML += '</optgroup>';			} 				// >>> write Airports into stations fields ============			if( xAirportListComplete.length > 0 )			{				if( iType == 'ALL' | ( iType == 'a'  & xFavListComplete.length > 0 ) ){					xLbl = $( '#AirportLocations' ).val();	// headline Airports					xHTML += '<optgroup label="' + xLbl + '">';				}				if( iType == 'a' || iType == 'ALL'){					for( var i=0; i< xAirportListComplete.length; i++){						xTextArray = xAirportListComplete[i].split('|');						if( xTextArray[1] == iDefault && xDefaultFound == false){							xHTML += '<option value="' + xTextArray[1] + '" selected="selected">' + xTextArray[0] + '</option>';							xDefaultFound = true;						}						else							xHTML += '<option value="' + xTextArray[1] + '">' + xTextArray[0] + '</option>';					}				} 				if( iType == 'ALL' | ( iType == 'a'  & xFavListComplete.length > 0 )){					xHTML += '</optgroup>';				}			}			else{				if( iType == 'a' )					xHTML += '<optgroup label="' + gTxtNoAirportLoc  + '">' + '</optgroup>';			}			 			// >>> write Downtowns into stations fields ============			if( xDowntownListComplete.length > 0 )			{				if( iType == 'ALL' | ( iType == 'c'  & xFavListComplete.length > 0 )) {					xLbl = $( '#DowntownLocations' ).val();	// headline Downtown					xHTML += '<optgroup label="' + xLbl + '">';				}				if( iType == 'c' || iType == 'ALL'){					for( var i=0; i< xDowntownListComplete.length; i++){						xTextArray = xDowntownListComplete[i].split('|');						if( xTextArray[1] == iDefault && xDefaultFound == false){							xHTML += '<option value="' + xTextArray[1] + '" selected="selected">' + xTextArray[0] + '</option>';							xDefaultFound = true;						}						else							xHTML += '<option value="' + xTextArray[1] + '">' + xTextArray[0] + '</option>';					}				} 				if( iType == 'ALL' | ( iType == 'c'  & xFavListComplete.length > 0 )){					xHTML += '</optgroup>';				}			}			else{				if( iType == 'c' )					xHTML += '<optgroup label="' + gTxtNoCityLoc  + '">' + '</optgroup>';			} 			var xSelectSTA = $('#etastation');			var xSelectILC = $('#ettstation');								if( iName == 'etacountry') {							// write dynamic cross border locations in global list				gCBLocationCount = yCBCountryCount;				for( i=0; i<gCBLocationCount; i++){					gCBCountry2List[i] = xCBCountryList[i];				}							xSelectSTA.html( xHTML);				xSelectSTA = xSelectSTA.parent();				xSelectSTA.find( '.display' ).text( xSelectSTA.find('option:selected').text());				if( gCTR2changed == 0 )				{					xSelectILC.html( xHTML);					xSelectILC = xSelectILC.parent();					xSelectILC.find( '.display' ).text( xSelectILC.find('option:selected').text());														$('#ettcountryTXT').text( $('#etacountry').find('option:selected').text());					$('#ettcountry').parent().find('.display').text( $('#etacountry').find('option:selected').text());											$('#ettcountry').val( $('#etacountry').find('option:selected').val() );									if( xDefaultFound == true)						$('#ettstationTXT').text( xSelectILC.find('option:selected').text());					else						$('#ettstationTXT').text( '...');				}				// US / CA with lenght = 4 --> DropOff-Options change				if( gSelectedCountry.length == 4 && gUSCAcrossBorderAllowed && !gCrossBorderActive  )				{					$('#ettcountry_ro').show().find('a').trigger('click');					$('.select_replace:has(#ettcountry)').show(); // alt. if ettcountry has been activated				}				else{					//$('#ettcountryTXT').text( $('#etacountry').find('option:selected').text());					//$('#ettcountry').parent().find('.display').text( $('#etacountry').find('option:selected').text());											//$('#ettcountry').val( $('#etacountry').find('option:selected').val() );					//$('.select_replace:has(#ettcountry)').hide();				}			}	 			else if( iName == 'ettcountry') { 							xSelectILC.html( xHTML);				xSelectILC = xSelectILC.parent();				xSelectILC.find( '.display' ).text( xSelectILC.find('option:selected').text());				$('#ettcountryTXT').text( $('#ettcountry').find('option:selected').text());				//$('#ettcountry').val( $('#etacountry').find('option:selected').val() );				if( xDefaultFound == true)					$('#ettstationTXT').text( xSelectILC.find('option:selected').text());				else					$('#ettstationTXT').text( '...');			} 		}}
