$(function() {		$('#quickbooking select').FancySelect({maxEntries: 10}); // use Fancy-Select-Plugin by Chris Jung	//$('#quickbooking').prepend( $('<div/>', ({id:'debug' })) );	$('#p_country').change(function() {		// what to do when p_country is changed		// sample for adding Ajax-Behavour		// call getLocationsPerCountryPreRendered		// call getCarGroupsPerCountry		ctr = $(this).val();				if( $(this).val()== "head" || $(this).val()== "showall" ){				//	return;			ctr = defaultCTR;		}				//ctr = $('#p_country').val();		$.ajax({			url: gFleetURL + "/AjaxWebService?OpenAgent&RAN=" + Math.random() + "&F=getCarGroupsPerCountry&SRCXL=p_country_change&COUNTRY="+ctr+"&CTR="+xQBLNG+"&MST=" + gMST  + '&MSTPATH=' + gMstPath + gAgentParam,//			cache: false,			dataType: 'text',			success: function( data ){				var options = unescape(decodeURI( data )).split('~');				var optionsLength = options.length;				var htmlOptions = '';				htmlOptions += '<option value="head">' + selectCarGroupText +'</option>'  //add 'Please select...'  text				for( var i = 0; i < optionsLength; i++ ) {					var value = options[i].split('|')[1]; // this is mnemonic code plus flag (airport/city)					var text = options[i].split('|')[0];					if( value != '-1' ) { // cut the first entry with dashes only						htmlOptions += '<option value="' + value + '">' + text + '</option>';					}				}				//$('#cargroup').html( htmlOptions ).update();				$('#cargroup').html( htmlOptions );								if( gDefaultGRP != '' && $('#cargroup option[value="' + gDefaultGRP + '"]').length > 0 ) {					$('#cargroup').val( gDefaultGRP ).update();				} else {					if ($('#cargroup option').length > 0 ){						$('#cargroup').val( $('#cargroup option:eq(1)').val() ).update();					}				}			}		});		$.ajax({ 			// CALLING THIS SYNCRONOUS IS IMPORTANT!!!			// This will prevent strange station setting effects			url: gStationsURL + "/AjaxWebService?OpenAgent&SOURCE=QB&COUNTRY=" + ctr + "&F=getLocationsPerCountryPreRendered&MST=" + gMST + '&MSTPATH=' + gMstPath + gAgentParam,//			cache: false,			dataType: "html",			async: false,			success: function( data ){				//var options = unescape(decodeURI( data )).split('~');				htmlOptions = "";				htmlOptions += '<option value="head">' + standardSelectText + '</option>';				htmlOptions += data;				htmlOptions = htmlOptions.replace( /%%AIRPORT%%/, airportStationsHeadline  );				htmlOptions = htmlOptions.replace( /%%DOWNTOWN%%/, cityStationsHeadline  );				//htmlOptions = htmlOptions.replace( /%3B/g, ',');				$('#p_all_station').html( htmlOptions ).update();								if( !cbr || !uscacbr ){					$('#r_all_station').html( htmlOptions ).update();				}				if( uscacbr && ctr.length == 4 ) {					$('#r_country').setVal(ctr);				}				if( !returnChangedManually ) {					$('#r_all_station').html( htmlOptions ).update();				}			}		})		if( !returnChangedManually ) {			$('#r_country').setVal( $(this).val() ); // set the return to the pickup, if not return has done manual changes			$('input[name="r_type"]:checked').trigger('click');		}	});		$('#r_country').change(function(){		ctr = $(this).val();				if( ctr == "head" || ctr == "showall" ){				//	return;			ctr = defaultCTR;		}				$.ajax({ 			// CALLING THIS SYNCRONOUS IS IMPORTANT!!!			// This will prevent strange station setting effects			url: gStationsURL + "/AjaxWebService?OpenAgent&SOURCE=QB&RAN=" + Math.random() + "&COUNTRY=" + ctr + "&F=getLocationsPerCountryPreRendered&MST=" + gMST + '&MSTPATH=' + gMstPath + gAgentParam,//			cache: false,			dataType: "text",			async: false,			success: function( data ){				//var options = unescape(decodeURI( data )).split('~');				htmlOptions = "";				htmlOptions += '<option value="head">' + standardSelectText + '</option>';				htmlOptions += data;				htmlOptions = htmlOptions.replace( /%%AIRPORT%%/, airportStationsHeadline  );				htmlOptions = htmlOptions.replace( /%%DOWNTOWN%%/, cityStationsHeadline  );												//htmlOptions = htmlOptions.replace( /%3B/g, ',');				$('#r_all_station').html( htmlOptions ).update();			}		})	});			// #### TOP location list changed ###########################	$('#p_top_station').change(function() {		// call getSEPerCountryAndLocation				if( $(this).val()== "head" || $(this).val()== "empty"  ){			return;		}				seCTR = $(this).val().split('-')[1];		if( typeof( seCTR ) == 'undefined') {			seCTR = defaultCTR;		}		gCurrentSTA=  $(this).val().substr(0,3);		$.ajax({ 			url: gStationsURL+ "/AjaxWebService?OpenAgent&RAN=" + Math.random() + "&F=getSEPerCountryAndLocation&MST=" + gMST  + '&MSTPATH=' + gMstPath +  '&AWD=' + gAWD + '&SEDEFAULT=' + gDefaultSE + gAgentParam + '&COUNTRY=' + seCTR + '&STA=' + $(this).val().substr(0,3),			dataType: "text",			success: function( html ) {				html = unescape( decodeURI( html ) );				$('#ExtrasLine').html( html );				$('#SESection select').FancySelect({maxEntries: 8}); // use stylish-plugin for dropdowns			}		});				$.ajax({			url: gFleetURL + "/AjaxWebService?OpenAgent&RAN=" + Math.random() + "&F=getCarGroupsPerCountry&SRCXL=p_top_station_change_" + $(this).val() + "&COUNTRY="+seCTR+"&CTR="+xQBLNG+"&MST=" + gMST  + '&MSTPATH=' + gMstPath + gAgentParam,			dataType: 'text',			success: function( data ){				var options = unescape(decodeURI( data )).split('~');				var optionsLength = options.length;				var htmlOptions = '';				htmlOptions += '<option value="head">' + selectCarGroupText +'</option>'  //add 'PLease select' text				for( var i = 0; i < optionsLength; i++ ) {					var value = options[i].split('|')[1]; // this is mnemonic code plus flag (airport/city)					var text = options[i].split('|')[0];					if( value != '-1' ) { // cut the first entry with dashes only						htmlOptions += '<option value="' + value + '">' + text + '</option>';					}				}				//$('#cargroup').html( htmlOptions ).update();				//$('#cargroup').html( htmlOptions ).val( $('#cargroup option:eq(1)').val() ).update();				$('#cargroup').html( htmlOptions );								if( gDefaultGRP != '' && $('#cargroup option[value="' + gDefaultGRP + '"]').length > 0 ) {					$('#cargroup').val( gDefaultGRP ).update();				} else {					if ($('#cargroup option').length > 0 ){						$('#cargroup').val( $('#cargroup option:eq(1)').val() ).update();					}				}			}		});							if( !returnChangedManually ) {			$('#r_top_station').setVal( $(this).val() );		}		if( $(this).val() == "showall" ) {			$('input[name="p_type"][value="all"]').trigger('click');		}	});			//### ALL location list changed ########################## 	$('#p_all_station').change(function() {		seCTR =  $('#p_country').val() == "head" ? defaultCTR : $('#p_country').val();		gCurrentSTA=  $(this).val();		$.ajax({ 			url: gStationsURL+ "/AjaxWebService?OpenAgent&RAN=" + Math.random() + "&F=getSEPerCountryAndLocation&MST=" + gMST  + '&MSTPATH=' + gMstPath +  '&AWD=' + gAWD + '&SEDEFAULT=' + gDefaultSE + gAgentParam  + '&COUNTRY=' + seCTR + '&STA=' + $(this).val(),			dataType: "html",			success: function( html ) {				html = unescape( decodeURI( html ) );				$('#ExtrasLine').html( html );				$('#SESection select').FancySelect({maxEntries: 8 }); 			}		});		if( !returnChangedManually ) {				$('#r_all_station').setVal( $(this).val() );		};	});				//### set return radio button to THIS value if not changed manually ###########	$('input[name="p_type"]').click(function() {		if( !returnChangedManually  && $( '#ret_diff' ).attr('checked') == false) {				$('input[name="r_type"][value="' + $(this).val() + '"]').trigger('click')		}	});			/*===  RETURN BEHAVIOUR === */	$('#r_top_station').change(function(){		if( $(this).val() == "showall" ) {			$('input[name="r_type"][value="all"]').trigger('click');		}	});				/* ============= BEHAVIOUR ============= */	$('#ret_diff').change(function(){		if( $(this).attr('checked') == true ) {			$('#quickbooking-returnsec').show();			if( cbr || ( uscacbr && $('#p_country').val().length > 3  )) {				$('#s_r_country').show();			} else {				$('#s_r_country').hide();			}		} else {			$('#quickbooking-returnsec').hide();			$('#ret_options').hide();		}		$( 'input[name="r_type"][value="' + $( 'input[name="r_type"]:checked' ).val() + '"]' ).trigger('click')	});	/*	 * set var "returnChangedManually to true on changing values	 * in qb-returnsec	 */	$('#quickbooking-returnsec input, #quickbooking-returnsec select').change(function() {		if( $('#quickbooking-returnsec').is(':visible') )			returnChangedManually = true;	});	/* 	 * change visible options of pickup and return section	 */	 	 	 //### set rental location type to ALL ####################	$( 'input[name="p_type"][value="all"]' ).click(function() {//		if( cbr == true || uscacbr == true ) {//			$( '#s_p_country' ).show();//		} else {//			$( '#s_p_country' ).hide();//		}		$( '#s_p_country' ).show();		$( '#s_p_top_station' ).hide();		$( '#s_p_all_station' ).show();				$( '#ret_diff_txt' ).html( xRetTBLblAll );				$( 'input[name="r_type"][value="all"]' ).trigger('click');								$('#ret_options label, #ret_options span').hide();			$('#ret_options .showallstations').show();		$('#ret_options input[value="station"]').trigger( 'click' );				//*** load car groups *******		ctr = $('#p_country').val();		$.ajax({			url: gFleetURL + "/AjaxWebService?OpenAgent&RAN=" + Math.random() + "&F=getCarGroupsPerCountry&SRCXL=p_type_val_all&COUNTRY=" + ctr +"&CTR="+xQBLNG+"&MST=" + gMST  + '&MSTPATH=' + gMstPath + gAgentParam,			dataType: 'text',			success: function( data ){				var options = unescape(decodeURI( data )).split('~');				var optionsLength = options.length;				var htmlOptions = '';				htmlOptions += '<option value="head">' + selectCarGroupText +'</option>'				for( var i = 0; i < optionsLength; i++ ) {					var value = options[i].split('|')[1]; // this is mnemonic code plus flag (airport/city)					var text = options[i].split('|')[0];					if( value != '-1' ) { // cut the first entry with dashes only						htmlOptions += '<option value="' + value + '">' + text + '</option>';					}										}				//$('#cargroup').html( htmlOptions ).update();				//$('#cargroup').html( htmlOptions ).val( $('#cargroup option:eq(1)').val() ).update();								$('#cargroup').html( htmlOptions );								if( gDefaultGRP != '' &&  $('#cargroup option[value="' + gDefaultGRP + '"]').length > 0 ) {					$('#cargroup').val( gDefaultGRP ).update();				} else {									if ( $('#cargroup option').length > 0 ){						$('#cargroup').val( $('#cargroup option:eq(1)').val() ).update();					}				}			}		});		$('#ovly').remove();	});				//### set rental location type to TOP #################	$( 'input[name="p_type"][value="top"]' ).click(function() {		$( '#s_p_country' ).hide();		$( '#s_p_top_station' ).show();		$( '#s_p_all_station' ).hide();		//if( !returnChangedManually ) {	// always show the other val on changin		$( '#s_r_country' ).hide();				$( '#s_r_top_station' ).show();		$( '#s_r_all_station' ).hide();		$('.r_type_chooser').show();		$('input[name="r_type"][value="top"]').trigger('click')						//}			$( '#ret_diff_txt' ).html( xRetTBLblTop );				$('#ret_options label, #ret_options span').hide();		$('#ret_options .showwithhomedel').show();		if( !$('#ret_options input:checked').is(':visible') ){			$('#ret_options input:visible').first().trigger( 'click' )		} else {			$('#ret_options input:checked').trigger('click')		}	});		$('#ret_options input').click(function(){		val = $(this).val();				switch( val ){						default: // stations				$('input[name="r_type"]').last().trigger( 'click' );			break;		}	})		$( 'input[name="r_type"][value="all"]' ).click(function() {		if( cbr == true || ( uscacbr == true && $( '#p_country' ).val().length == 4 ) ) {			$( '#s_r_country' ).show();		} else {			$( '#s_r_country' ).hide();		}		$( '#s_r_top_station' ).hide();		$( '#s_r_all_station' ).show();				$('#ovly').remove();			});			$( 'input[name="r_type"][value="top"]' ).click(function() {			$( '#s_r_country' ).hide();			$( '#s_r_top_station' ).show();			$( '#s_r_all_station' ).hide();	});					/* ============= DEFAULT SETTNGS ============= */		$( '#s_p_top_station' ).hide();	if( 		defaultTOPreturn == "" &&		defaultCTRreturn == "" &&		defaultSTAreturn == "" 	) {		$( '#quickbooking-returnsec' ).hide();	}		if( defaultCTR != "" && defaultSTA != "" && defaultTOP == ""  ) {		// normal avis location prefill and show		$( '#p_country' ).setVal( defaultCTR );		$( '#p_all_station' ).setVal( defaultSTA );		$( 'input[name="p_type"][value="all"]' ).trigger( 'click' );		$( '#s_p_top_station').hide();		$( '#s_p_all_station').show();	}	if( defaultCTR != "" && defaultTOP != ""  ) {		// top location prefilled		$( '#p_country' ).setVal( defaultCTR );		$( '#p_top_station' ).setVal( defaultTOP );		$( 'input[name="p_type"][value="top"]' ).trigger( 'click' );	}		// ------------ IF NOTHING PRESET ----------------	if( defaultSTA == "" && defaultTOP == "" ) {		//alert('No Presets')		$( '#p_country' ).setVal( defaultCTR );		$( 'input[name="p_type"][value="all"]' ).trigger( 'click' );		$( '#ret_options').hide();	}		/* =========== RETURN PREFILL ============ */	if( defaultCTRreturn != "" && defaultSTAreturn != ""  && defaultRetEnabeld  ) {		// switch on qb-returnsec		$( '#ret_diff' ).attr('checked', true);		$( '#quickbooking-returnsec' ).show();		// normal avis location return prefill and show		$( '#r_country' ).setVal( defaultCTRreturn );		$( '#r_all_station' ).setVal( defaultSTAreturn );				$( '#s_r_all_station' ).show();		$( '#s_r_top_station' ).hide();				//$( 'input[name="r_type"][value="all"]' ).trigger('click');		//$( '#ret_options' ).show()		$( '#ret_options input[value="station"]' ).trigger('click');				$( '#lbl_r_deliverhome' ).hide();			}	if( defaultCTRreturn != "" && defaultTOPreturn != "" && defaultRetEnabeld  ) {		// top location prefilled 		$( '#ret_diff' ).attr('checked', true);		$( '#quickbooking-returnsec' ).show();		$( '#ret_options').hide();		$( '#r_country' ).setVal( defaultCTRreturn );		$( '#r_top_station' ).setVal( defaultTOPreturn );		$( '#s_r_top_station' ).show();				$( 'input[name="r_type"][value="top"]' ).trigger( 'click' );	}	if( topLocations ){		$( '#s_r_all_station').show();		$( '#s_r_top_station').hide();			}		if( gDefaultGRP != '' ) {		$('#cargroup').setVal( gDefaultGRP );	}		$('#quickbooking').css({visibility:'visible'})		$('#AWD').change(function()		{			gAWD = $(this).val(); 			$.ajax({ 			url: gStationsURL+ "/AjaxWebService?OpenAgent&RAN=" + Math.random() + "&F=getSEPerCountryAndLocation&MST=" + gMST  + '&MSTPATH=' + gMstPath +  '&AWD=' + gAWD + '&SEDEFAULT=' + gDefaultSE + gAgentParam + '&COUNTRY=' + seCTR + '&STA=' + gCurrentSTA,			dataType: "text",			success: function( html ) {				html = unescape( decodeURI( html ) );				$('#ExtrasLine').html( html );				$('#SESection select').FancySelect({maxEntries: 8}); // use stylish-plugin for dropdowns			}		});		}		)	// ----- end jquery});		
