// global namespace-object
if (typeof(op) == 'undefined') op = {};
if (typeof(op.labels) == 'undefined') op.labels = {};
if (typeof(op.labels.country) == 'undefined') op.labels.country = '';
if (typeof(op.paths) == 'undefined') op.paths = {};
op.paths.scripts = 'fileadmin/templates/js/';	// Script-Path

op.paths.flightsURL = '/opodo/flights/resolveLocation';	// Airports-Autosuggest
op.paths.dpFlightsURL = '/opodo/flights/resolveLocation';	// Airports-Autosuggest
op.paths.placesURL = '/opodo/hotel/LocationAjaxSearch';	// Hotel-Destination-Autosuggest
op.paths.locationObjURL = '/opodo/hotel/LocationAjaxCoordinates';	// Hotel-Destination-MapCoordinates
op.paths.railStation = '/opodo/flights/bahnLandingSearchStation';	// Rail stations for IATA
op.paths.carURL = '/opodo/StrutsServlet/CarRentalLocationSearch';	// Hotel-Destination-Autosuggest
op.paths.carLocationURL = '/opodo/StrutsServlet/CarRentalLocationSearch';	// Hotel-Destination-Autosuggest
op.paths.carIcons = '/fileadmin/templates/img/';
op.paths.familyCountry = 'http://www.familienurlaub.opodo.de/index.php?zielgebiet';
op.paths.familyZiel = 'http://www.familienurlaub.opodo.de/index.php?uebersicht';


//Dummy-Data:
/*
op.paths.flightsURL = op.paths.scripts+'responses/flughaefen.html';
op.paths.dpFlightsURL = op.paths.scripts+'responses/flughaefen.html';
op.paths.placesURL = op.paths.scripts+'responses/reiseziele.html';	
op.paths.locationObjURL = op.paths.scripts+'responses/reiseziel_map.html';
//op.paths.railStation = op.paths.scripts+'responses/rail.php';	// Rail stations for IATA
op.paths.railStation = op.paths.scripts+'responses/rail.html';	// Rail stations for IATA
op.paths.carURL = op.paths.scripts+'responses/car1.html';	
op.paths.carLocationURL = op.paths.scripts+'responses/car2.html';
op.paths.carIcons = 'fileadmin/templates/img/';
op.paths.familyCountry = 'http://www.familienurlaub.opodo.de/index.php?zielgebiet';
op.paths.familyZiel = 'http://www.familienurlaub.opodo.de/index.php?uebersicht';
*/
op.le_ie7 = ($.browser.msie && parseInt($.browser.version.substr(0, 1)) <= 7);
op.le_ie6 = ($.browser.msie && parseInt($.browser.version.substr(0, 1)) <= 6);

// This one was wrong: its the one for UK: op.paths.multistopp = '/opodo/flights/multistopFlights'; // Link multiflight
// op.paths.multistopp -> move to the country ts!!!
op.paths.multistopp = '/opodo/buchen/flug/gabelFlug'; // Link multiflight
op.paths.flightAndHotel = '/opodo/dp/dp';	// Link Flight&Hotel, if no tab

op.isTestEnv = (document.URL.indexOf('dev3.opodo-system.de') != -1) ? true : false;
op.currentContentid = null;

op.flightEnableOneway=function() {
	var form= $('#' + op.forms.flight.contentid, op.context);
	var dpTo = $('#' + op.forms.flight.dpContainerId, form);
	var toDisable = $('.disableByOneway', form);
	toDisable.each(function(){
		var current = $(this);
		if(!current.hasClass('disabled')){
			current.addClass('disabled');
			current.attr('disabled','disabled');
		}
	});
	dpTo.addClass('disabledTo');
}
op.flightOnewayUK=function() {
		if( $('#trip-type-oneway-uk').is(":checked") )
		{
			op.flightEnableOnewayUK();
		}else{			
			op.flightDisableOnewayUK();
		}

	}
op.flightEnableOnewayUK=function() {
	var form= $('#' + op.forms.flight.contentid, op.context);
	var dpTo = $('#' + op.forms.flight.dpContainerId, form);
	var toDisable = $('.disableByOneway', form);
	toDisable.each(function(){
		var current = $(this);
		if(!current.hasClass('disabled')){
			current.addClass('disabled');
			current.attr('disabled','disabled');

			dpTo.datepicker("option","disabled", true);
		}
	});
	dpTo.datepicker("option","disabled");
	if(!dpTo.hasClass('disabledTo')){
		dpTo.addClass('disabledTo');
		//dpTo.attr('disabled','disabled');
	}

}

op.flightDisableOnewayUK=function() {
	var form= $('#' + op.forms.flight.contentid, op.context);
	var dpTo = $('#' + op.forms.flight.dpContainerId, form);
	var toDisable = $('.disableByOneway', form);
	toDisable.each(function(){
		var current = $(this);
		if(current.hasClass('disabled')){
			current.removeClass('disabled');
			current.removeAttr('disabled');

	dpTo.datepicker("option","disabled", false);
		}
	});
	dpTo.datepicker("option","disabled");
	if(dpTo.hasClass('disabledTo')){
		dpTo.removeClass('disabledTo');
		//dpTo.removeAttr('disabled','disabled');



	}

}
op.familyFromOnly=function() {
	var form= $('#' + op.forms.family.contentid, op.context);
	var dpTo = $('#' + op.forms.family.dpContainerId, form);
	var toDisable = $('.disableByOneway', form);
	toDisable.each(function(){
		var current = $(this);
		if(!current.hasClass('disabled')){
			current.addClass('disabled');
			current.attr('disabled','disabled');
		}
	});
	dpTo.addClass('disabledTo');
}
// Opodo Forms declaration
op.forms = {
	//flightsearchform
	flight : {
		initialized: false,
		tabid: 'flight',
		contentid: 'flight-content',
		dpFromId: 'flight-from-dp',
		dpToId: 'flight-to-dp',
		dpContainerId: 'flight-dp-container',
		dpTriggerFromId: 'flight-from-trigger',
		dpTriggerToId: 'flight-to-trigger',
		dpFromMonthYearSelectDiff: '0',
		dpToMonthYearSelectDiff: '0',
		init: function(){
			if(this.initialized) return;
					
			// DATEPICKER
			op.initDatepicker(this);
			
			var form = $('#' + this.contentid, op.context);
			
			// TRAVEL TYPES
			var dpTo = $('#' + this.dpContainerId, form);
			var roundtripRadio =  $('#trip-type-roundtrip');
			
			function enableRoundtrip() {
				roundtripRadio.attr('checked','checked');
				var toEnable = $('.disableByOneway', form);
				toEnable.each(function(){
					var current = $(this);
					if(current.hasClass('disabled')){
						current.removeClass('disabled');
						current.removeAttr('disabled');
					}
				});
				dpTo.removeClass('disabledTo');
			}
			
			roundtripRadio.click(enableRoundtrip);
			$('#multiStop').click(function(){
			var multiStoppLink= $("#multiStop").attr("href")+
				'?departureAirports[0]='+$('[name=departureAirport]').val()+
				'&departureAirportCodes[0]='+$('[name=departureAirportCode]').val()+
				'&arrivalAirports[0]='+$('[name=arrivalAirport]').val()+
				'&arrivalAirportCodes[0]='+$('[name=arrivalAirportCode]').val();
			$("#multiStop").attr("href", multiStoppLink)
			});
			
			$('#trip-type-oneway').click(function(){
				op.flightEnableOneway();
			});
			// UK ONLY
			if(op.labels.country=='uk'){
				$('#trip-type-oneway-uk').click(function(){
					op.flightOnewayUK();
				});
			}
			
			$('#trip-type-multistop').click(function(){
				enableRoundtrip();
				$(this).removeAttr('checked');
				window.location = op.paths.multistopp;
			});
			
			$('#trip-type-dp').click(function(){
				enableRoundtrip();
				$(this).removeAttr('checked');
				var tab = $('#' + op.forms.dp.tabid, op.context);
				if (tab.length){
					op.toggleTabs(op.forms.dp.tabid);
				} else {
					window.location = op.paths.flightAndHotel;
				}
			});
			
			// PREFERED AIRLINES
			$("#flight_moveOptionRight").click(function(){
				op.moveSelectedItems("#flight_preferredAirlinesSelected", "#flight_preferredAirlines", false);
			});
			$("#flight_moveOptionLeft").click(function(){
				op.moveSelectedItems("#flight_preferredAirlines", "#flight_preferredAirlinesSelected", true);
			});			
			
			// EXTENDED SEARCH
			$('#flightsShowMoreOptions', form).click(function(){
				if (op.labels.country=='uk') op.changeArrow(form); 

				$('.vis_flightsShowMoreOptions',form).toggleClass('dn');
				$(this).find('div.icon').toggleClass('dn');
				op.addDummyContentForIE();
				return false;
			});
			
			form.find('[name="departureAirport"], [name="arrivalAirport"]').blur(
				function(event){
					var self = $(this);
					form.find('[name="' + self.attr('name') + 'Code"]').val('').change();
					/*
					if(self.val().length<3){
						var codeObj;
						form.find('[name="' + self.attr('name') + 'Code"]').val('').change();
					}
					*/
				}
			);
			
			// Bahn Trigger for MPS // OFF for Workaround HP 22.03.
			/*
			if(op.rail){
				op.rail.use = true;
				(op.rail.use == true) ? op.rail.init(this) : '';
			}
			*/
			
			this.initialized = true;
		},
		update: function(form){
			

			//if ( $("#trip-type-oneway").is(":checked") ) $("#trip-type-oneway").attr("value","O")
			if( op.labels.country=='uk'){
			
			if(form.find('[name="tripType"]').is(":checked") ) form.find('[name="tripType"]').attr("value","O");
			if(form.find('#low-cost').is(":checked") ) {
			
				form.find('[name="searchLowCost"]').attr("value","true");
			} else {
					form.find('[name="searchLowCost"]').attr("value","false");
				}
			}
			// op.flight._async = false;
			// op.flight.ajax(form, 'auto');
			// FLIGHT DEPARTURE_DAY, DEPARTURE_MONTH
			var departureTimestamp = form.find('.dp.from').datepicker('getDate');

			if(op.labels.country=="uk") op.helper.trim(form.find('.from').val())!='' ? departureTimestamp = formatDate(op.helper.trim(form.find('.from').val())) : "";
			
			form.find('[name="departureDay"]').val("" + op.helper.leadingZero(departureTimestamp.getDate()));
			var departureMonth = departureTimestamp.getMonth() + 1;
			form.find('[name="departureMonth"]').val("" + departureTimestamp.getFullYear() + "" + op.helper.leadingZero(departureMonth));
			
			// FLIGHT RETURN_DAY, RETURN_MONTH
			var returnTimestamp = form.find('.dp.to').datepicker('getDate');
			
			if(op.labels.country=="uk") op.helper.trim(form.find('.to').val())!='' ? returnTimestamp = formatDate(op.helper.trim(form.find('.to').val())) : "";
			
			form.find('[name="returnDay"]').val("" + op.helper.leadingZero(returnTimestamp.getDate()));
			var returnMonth = returnTimestamp.getMonth() + 1;
			form.find('[name="returnMonth"]').val("" + returnTimestamp.getFullYear() + "" + op.helper.leadingZero(returnMonth));
			
			// Update prefered Airlines
		if(op.labels.country!="uk") {
			var prefAirlines = form.find('#flight_preferredAirlines').val();
			if(prefAirlines != null){
				var length = prefAirlines.length;
				for(var i=0; i < length; i++){
					$('#' + this.contentid).prepend(
						$("<input/>").attr({
							name : "preferredAirlines[" + i + "]", 
							type : "hidden",
							value : prefAirlines[i]
							})
						);
					}
				}
			}

			// AIRPORTCODES
			var departureAirportCodeObj = form.find('[name="departureAirportCode"]');
			var departureAirportCode = departureAirportCodeObj.val();
			var departureAirportObj = form.find('[name="departureAirport"]');
			var departureAirport = departureAirportObj.val();
			if(departureAirportCode == '' || departureAirport.length <= 3){
				op.helper.setThreeLetterCode(departureAirportCodeObj, departureAirportObj, departureAirport);
			}
			
			var arrivalAirportCodeObj = form.find('[name="arrivalAirportCode"]');
			var arrivalAirportCode = arrivalAirportCodeObj.val();
			var arrivalAirportObj = form.find('[name="arrivalAirport"]');
			var arrivalAirport = arrivalAirportObj.val();
			if(arrivalAirportCode == '' || departureAirport.length <= 3){
				op.helper.setThreeLetterCode(arrivalAirportCodeObj, arrivalAirportObj, arrivalAirport);
			}
		},
		validate: function(form){			
			
			// DEPARTURE_CODE AND ARRIVAL_CODE
			var departureAirport = form.find('[name="departureAirport"]').val();
			var arrivalAirport = form.find('[name="arrivalAirport"]').val();
			var departureAirportCode = form.find('[name="departureAirportCode"]').val();
			var arrivalAirportCode = form.find('[name="arrivalAirportCode"]').val();
			var leavingDate = $("#flight-from-trigger").val();
			var returningDate = $("#flight-to-trigger").val(); 
      var sLeaving = leavingDate.split("/"); 
      var sReturning = returningDate.split('/');
      var dateLeaving = new Date(sLeaving[2],sLeaving[1]-1,sLeaving[0]);
      var dateReturning = new Date(sReturning[2],sReturning[1]-1,sReturning[0]); 
			var oneway = (form.find('[name="tripType"]').is(":checked")) ? true : false;
			var departureTime = form.find('[name="departureTime"]').val();			
			var currentTime = new Date(); currentTime = currentTime.getHours();
			
			// Removing error class 
			if ( op.labels.country=="uk" ) {
				form.find('[name="departureAirport"]').removeClass("err");
				form.find('[name="arrivalAirport"]').removeClass("err");
				$("#flight-from-trigger").removeClass("err");
				$("#flight-to-trigger").removeClass("err");
			}

/*
			if (departureAirportCode==''){
				if(departureAirport != ''){
					$('input.suggest', form).trigger('keyup');
					op.errors.push('selectDepartureAirport');
				} else {
					if ( op.labels.country=="uk" ) form.find('[name="departureAirport"]').addClass("err");
					op.errors.push('noDepartureAirport');
				}		
			}				

			if (arrivalAirportCode==''){
				if(arrivalAirport != ''){
					$('input.suggest', form).trigger('keyup');
					op.errors.push('selectArrivalAirport');
				} else {
					if ( op.labels.country=="uk" ) form.find('[name="arrivalAirport"]').addClass("err");
					op.errors.push('noArrivalAirport');
				}		
			}				
*/
	
			if(departureAirportCode == ''){
				if ( op.labels.country=="uk" ) form.find('[name="departureAirport"]').addClass("err");
				op.errors.push('noDepartureAirport');
			}
			if(arrivalAirportCode == ''){
				if ( op.labels.country=="uk" ) form.find('[name="arrivalAirport"]').addClass("err");
				op.errors.push('noArrivalAirport');
			}			

			if(departureAirportCode != '' 
				&& arrivalAirportCode != '' 
				&& departureAirportCode == arrivalAirportCode)
			{
				op.errors.push('equalAirports');
			}
			
			if(leavingDate == ''){
				if ( op.labels.country=="uk" ) $("#flight-from-trigger").addClass("err");
				op.errors.push('noLeavingDate');
			}
			if(returningDate == '' && !oneway){
				if ( op.labels.country=="uk" ) $("#flight-to-trigger").addClass("err");
				op.errors.push('noReturningDate');
			}			
						
			if ( (dateLeaving-op.curDate)==0 && op.labels.country=="uk") {
				if ( departureTime!='ANY' && currentTime >= op.getSelectedTime(departureTime) ) {
					$("#flight-from-trigger").addClass("err");
					op.errors.push('pastTime');		
				}
			}

			if ( (dateLeaving < op.curDate) && op.labels.country=="uk" ) {
				$("#flight-from-trigger").addClass("err");
				op.errors.push('pastDate');
			}
			if ( (dateReturning < op.curDate) && !oneway && op.labels.country=="uk") {
				$("#flight-to-trigger").addClass("err");
				op.errors.push('pastDate');
			}
			
			if( (dateLeaving > dateReturning) && !oneway && dateLeaving >= op.curDate && dateReturning >= op.curDate && op.labels.country=="uk" ){
				$("#flight-to-trigger").addClass("err");
				op.errors.push('higherReturningDate');
			}
			// Date > 360 days in advance
			if ( (dateReturning > op.maxDateTo) && !oneway && dateLeaving >= op.curDate && dateReturning >= op.curDate && op.labels.country=="uk" ) {
				op.errors.push('numDaysMaxFlights');
			}

			return (!Boolean(op.errors.length));
		}
	},
	//hotelSearchFormBeanV2
	hotel: {
		initialized: false,
		tabid: 'hotel',
		contentid: 'hotel-content',
		dpFromId: 'hotel-from-dp',
		dpToId: 'hotel-to-dp',
		dpContainerId: 'hotel-dp-container',
		dpTriggerFromId: 'hotel-from-trigger',
		dpTriggerToId: 'hotel-to-trigger',
		dpFromMonthYearSelectDiff: '0',
		dpToMonthYearSelectDiff: '0',
		init: function(){
			if(this.initialized) return;
			
			var form = $('#' + this.contentid, op.context);
			
			// Show/hide child selection
			$('#HotelshowHotelsChildren',form).click(function(){
			
				$('.vis_showHotelsChildren', form).toggleClass('dn');
				op.addDummyContentForIE();
			});
			
			form.find('[name="destinationName"]').change(function(){
				form.find('[name="locationId"]').val('');
				form.find('[name="address"]').val('');
			});
						
			
			op.initDatepicker(this);
			
			if ($('#hotelsShowMoreOptions', form)) {
				// EXTENDED SEARCH
				$('#hotelsShowMoreOptions', form).click(function(){
					if (op.labels.country=='uk') op.changeArrow(form); 
					
				$('.vis_hotelsShowMoreOptions',form).toggleClass('dn');
					$(this).find('div.icon').toggleClass('dn');
					op.addDummyContentForIE();
					return false;
				});		
			}
			
			
			if(op.initMapEvents) {
				op.initMapEvents();
			}
			
			if(op.labels.country=="uk") op.onSelectPrices(this.contentid);
			
			this.initialized = true;
		},
		update: function(form){
			// FLIGHT DEPARTURE_DAY, DEPARTURE_MONTH
			var departureTimestamp = form.find('.dp.from').datepicker('getDate');
			
			if(op.labels.country=="uk") op.helper.trim(form.find('.from').val())!='' ? departureTimestamp = formatDate(op.helper.trim(form.find('.from').val())) : "";
			
			form.find('[name="checkInDay"]').val("" + op.helper.leadingZero(departureTimestamp.getDate()));
			var departureMonth = departureTimestamp.getMonth() + 1;
			form.find('[name="checkInMonthYear"]').val("" + departureTimestamp.getFullYear() + "" + op.helper.leadingZero(departureMonth));
			
			// FLIGHT RETURN_DAY, RETURN_MONTH
			var returnTimestamp = form.find('.dp.to').datepicker('getDate');
			
			if(op.labels.country=="uk") op.helper.trim(form.find('.to').val())!='' ? returnTimestamp = formatDate(op.helper.trim(form.find('.to').val())) : "";
			
			form.find('[name="checkOutDay"]').val("" + op.helper.leadingZero(returnTimestamp.getDate()));
			var returnMonth = returnTimestamp.getMonth() + 1;
			form.find('[name="checkOutMonthYear"]').val("" + returnTimestamp.getFullYear() + "" + op.helper.leadingZero(returnMonth));
		},
		validate: function(form){
			// LOCATION_ID
			var locationId= form.find('[name="locationId"]').val();
			var checkinDate = $("#hotel-from-trigger").val();
			var checkoutDate = $("#hotel-to-trigger").val();
			var sCheckin = checkinDate.split("/"); 
      var sCheckout = checkoutDate.split('/');
      var dateCheckin = new Date(sCheckin[2],sCheckin[1]-1,sCheckin[0]);
      var dateCheckout = new Date(sCheckout[2],sCheckout[1]-1,sCheckout[0]);
			var numNights = (dateCheckout-dateCheckin) / (24*60*60*1000);

			// Removing error class 
			if ( op.labels.country=="uk" ) {
				form.find('[name="destinationName"]').removeClass("err");
				$("#hotel-from-trigger").removeClass("err");
				$("#hotel-to-trigger").removeClass("err");
				var content = $('#' + this.contentid);
				var roomCount = content.find('[name="numberOfRooms"]').val();
				var childCount = content.find('[name="roomOccupancies[0].numberOfChildren"]').val();
				for (var room = 0; room < roomCount; room++){
					for (var child = 0; child < childCount; child++){
						$('[name="childAges' + (room+1) + '[' + child + ']"]', content).removeClass("err");
					}
				}
			}
				
			if(locationId == ''){
				var destinationName = $('[name="destinationName"]').val();
				if(destinationName != ''){
					$('input.suggest', form).trigger('keyup');
					op.errors.push('selectDestination');
				} else {
					if ( op.labels.country=="uk" ) form.find('[name="destinationName"]').addClass("err");
					op.errors.push('noDestination');
				}				
			}
			
			if (checkinDate=='') {
				if ( op.labels.country=="uk" ) $("#hotel-from-trigger").addClass("err");
				op.errors.push('noCheckinDate');
			}
			if (checkoutDate=='') {
				if ( op.labels.country=="uk" ) $("#hotel-to-trigger").addClass("err");
				op.errors.push('noCheckoutDate');
			}
			if ( (dateCheckin < op.curDate) && op.labels.country=="uk" ) {
				$("#hotel-from-trigger").addClass("err");
				op.errors.push('pastDate');
			}		
			if ( (dateCheckout < op.curDate) && op.labels.country=="uk" ) {
				$("#hotel-to-trigger").addClass("err");
				op.errors.push('pastDate');
			}
			if( (dateCheckin > dateCheckout) && dateCheckin >= op.curDate && dateCheckout >= op.curDate && op.labels.country=="uk"){
				$("#hotel-to-trigger").addClass("err");
				op.errors.push('higherCheckinDate');
			}
			if( (dateCheckout-dateCheckin) == 0 & dateCheckin >= op.curDate && dateCheckout >= op.curDate && op.labels.country=="uk"){
				$("#hotel-from-trigger").addClass("err");
				$("#hotel-to-trigger").addClass("err");
				op.errors.push('sameDatesHotels');
			}
			// Date > 360 days in advance
			if ( (dateCheckout > op.maxDateTo) & dateCheckin >= op.curDate && dateCheckout >= op.curDate && op.labels.country=="uk" ) {
				op.errors.push('numDaysMaxHotels');
			}
			// Not possible booking more than 99 nights
			if ( numNights > 99 & dateCheckin >= op.curDate && dateCheckout >= op.curDate && op.labels.country=="uk"){
				op.errors.push('numNightsMaxHotels');
			}

			// CHILDREN VALIDATION
			var content = $('#' + this.contentid);
			var emptyValue = '-1';
			
			//alert($('#HotelshowHotelsChildren', content).is(':checked'));
			
			if($('#HotelshowHotelsChildren', content).is(':checked') || op.labels.country=="uk" ){
				var roomCount = content.find('[name="numberOfRooms"]').val();
				var childCount = content.find('[name="roomOccupancies[0].numberOfChildren"]').val();

				if ( op.labels.country=="uk" ) {
					for (var room = 0; room < roomCount; room++){
						for (var child = 0; child < childCount; child++){
							if ($('[name="childAges' + (room+1) + '[' + child + ']"]', content).val() == emptyValue) $('[name="childAges' + (room+1) + '[' + child + ']"]', content).addClass("err");
						}
					}
				}
				
				for (var room = 0; room < roomCount; room++){
					for (var child = 0; child < childCount; child++){
						if ($('[name="childAges' + (room+1) + '[' + child + ']"]', content).val() == emptyValue){
							op.errors.push('missingChilrenAge');
							return false;
						}
					}
				}
			} else {
				content.find('[name="roomOccupancies[0].numberOfChildren"]').val('0');
				content.find('.updateCol').each(function(){
					var currentRoom = $(this);
					currentRoom.find('.updateRow').each(function(){
						$(this).find('select').val(emptyValue);
					});
				});
			}
			return (!Boolean(op.errors.length));
		}
	},	
	//dpsearchform
	dp : {
		initialized: false,
		tabid: 'dp',
		contentid: 'dp-content',
		dpFromId: 'dp-from-dp',
		dpToId: 'dp-to-dp',
		dpContainerId: 'dp-dp-container',
		dpTriggerFromId: 'dp-from-trigger',
		dpTriggerToId: 'dp-to-trigger',
		dpFromMonthYearSelectDiff: '0',
		dpToMonthYearSelectDiff: '0',
		init: function(){
			if(this.initialized) return;
			
			var form = $('#' + this.contentid, op.context);
			
			// Show/hide child selection
			$('#dpShowChildren',op.context).click(function(){
				$('.vis_showHotelFlightChildren', op.context).toggleClass('dn');
				op.addDummyContentForIE();
			});

			// EXTENDED SEARCH
			$('#hotelFlightsShowMoreOptions',op.context).click(function(){
				if (op.labels.country=='uk') op.changeArrow(form);

				$('.vis_hotelFlightsShowMoreOptions',op.context).toggleClass('dn');
				$(this).find('div.icon').toggleClass('dn');
				op.addDummyContentForIE();
				return false;
			});


			//preferred airlines
			$("#dp_moveOptionRight").click(function(){
				op.moveSelectedItems("#dp_preferredAirlinesSelected", "#dp_preferredAirlines", false);
			});
			$("#dp_moveOptionLeft").click(function(){
				op.moveSelectedItems("#dp_preferredAirlines", "#dp_preferredAirlinesSelected", true);
			});
			
		
			op.initDatepicker(this);
			
			form.find('[name="departureAirport"], [name="arrivalAirport"]').blur(
				function(event){
					var self = $(this);
					form.find('[name="' + self.attr('name') + 'Code"]').val('').change();
				}
			);
			
			this.initialized = true;
		},
		update: function(form){
			// op.flight._async = false;
			// op.flight.ajax(form, 'auto');
			if( op.labels.country=='uk'){
				if( form.find('#low-cost-dp').is(":checked") ) {
					form.find('[name="searchLowCost"]').attr("value","true");
				} else {
					form.find('[name="searchLowCost"]').attr("value","false");
				}
			}
			
			// FLIGHT DEPARTURE_DAY, DEPARTURE_MONTH
			var departureTimestamp = form.find('.dp.from').datepicker('getDate');
			
			if(op.labels.country=="uk") op.helper.trim(form.find('.from').val())!='' ? departureTimestamp = formatDate(op.helper.trim(form.find('.from').val())) : "";

			form.find('[name="departureDay"]').val("" + op.helper.leadingZero(departureTimestamp.getDate()));
			var departureMonth = departureTimestamp.getMonth() + 1;
			form.find('[name="departureMonth"]').val("" + departureTimestamp.getFullYear() + "" + op.helper.leadingZero(departureMonth));
			
			// Departure Hotel dates (by default, the same as flights)
			form.find('[name="departureDayHotel"]').val("" + op.helper.leadingZero(departureTimestamp.getDate()));
			form.find('[name="departureMonthHotel"]').val("" + departureTimestamp.getFullYear() + "" + op.helper.leadingZero(departureMonth));
			
			// FLIGHT RETURN_DAY, RETURN_MONTH
			var returnTimestamp = form.find('.dp.to').datepicker('getDate');
			
			if(op.labels.country=="uk") op.helper.trim(form.find('.to').val())!='' ? returnTimestamp = formatDate(op.helper.trim(form.find('.to').val())) : "";
			
			form.find('[name="returnDay"]').val("" + op.helper.leadingZero(returnTimestamp.getDate()));
			var returnMonth = returnTimestamp.getMonth() + 1;
			form.find('[name="returnMonth"]').val("" + returnTimestamp.getFullYear() + "" + op.helper.leadingZero(returnMonth));

			// Return Hotel dates (by default, the same as flights)
			form.find('[name="returnDayHotel"]').val("" + op.helper.leadingZero(returnTimestamp.getDate()));
			form.find('[name="returnMonthHotel"]').val("" + returnTimestamp.getFullYear() + "" + op.helper.leadingZero(returnMonth));
			
			// Update prefered Airlines
			if(op.labels.country!="uk") {
				var prefAirlines = form.find('#dp_preferredAirlines').val();
				if(prefAirlines != null){
					var length = prefAirlines.length;
					for(var i=0; i < length; i++){
						// if(console || window.console){
							// console.log(prefAirlines[i]);
						// }
						$('#' + this.contentid).prepend(
							$("<input/>").attr({
								name : "preferredAirlines[" + i + "]", 
								type : "hidden",
								value : prefAirlines[i]
							})
						);
					}
				}
			}

			// AIRPORTCODES
			var departureAirportCodeObj = form.find('[name="departureAirportCode"]');
			var departureAirportCode = departureAirportCodeObj.val();
			var departureAirportObj = form.find('[name="departureAirport"]');
			var departureAirport = departureAirportObj.val();
			if(departureAirportCode == '' || departureAirport.length <= 3){
				op.helper.setThreeLetterCode(departureAirportCodeObj, departureAirportObj, departureAirport);
			}
			
			var arrivalAirportCodeObj = form.find('[name="arrivalAirportCode"]');
			var arrivalAirportCode = arrivalAirportCodeObj.val();
			var arrivalAirportObj = form.find('[name="arrivalAirport"]');
			var arrivalAirport = arrivalAirportObj.val();
			if(arrivalAirportCode == '' || departureAirport.length <= 3){
				op.helper.setThreeLetterCode(arrivalAirportCodeObj, arrivalAirportObj, arrivalAirport);
			}
		},
		validate: function(form){			
			
		// DEPARTURE_CODE AND ARRIVAL_CODE
			var departureAirportCode = form.find('[name="departureAirportCode"]').val();
			var arrivalAirportCode = form.find('[name="arrivalAirportCode"]').val();
			var leavingDate = $("#dp-from-trigger").val();
			var returningDate = $("#dp-to-trigger").val();
      var sLeaving = leavingDate.split("/"); 
      var sReturning = returningDate.split('/');
      var dateLeaving = new Date(sLeaving[2],sLeaving[1]-1,sLeaving[0]);
      var dateReturning = new Date(sReturning[2],sReturning[1]-1,sReturning[0]);
			var departureTime = form.find('[name="departureTime"]').val();			
			var currentTime = new Date(); currentTime = currentTime.getHours();		
			
			// Removing error class 
			if ( op.labels.country=="uk" ) {
				form.find('[name="departureAirport"]').removeClass("err");
				form.find('[name="arrivalAirport"]').removeClass("err");
				$("#dp-from-trigger").removeClass("err");
				$("#dp-to-trigger").removeClass("err");
				var content = $('#' + this.contentid);
				var roomCount = content.find('[name="numberOfRooms"]').val();
				var childCount = content.find('[name="roomOccupancies[0].numberOfChildren"]').val();
					for (var room = 0; room < roomCount; room++){
						for (var child = 0; child < childCount; child++){
							$('[name="childAges' + (room+1) + '[' + child + ']"]', content).removeClass("err");
						}
					}
			}
			
			if(departureAirportCode == ''){
				if ( op.labels.country=="uk" ) form.find('[name="departureAirport"]').addClass("err");
				op.errors.push('noDepartureAirport');
			}			
			if(arrivalAirportCode == ''){
				if ( op.labels.country=="uk" ) form.find('[name="arrivalAirport"]').addClass("err");
				op.errors.push('noArrivalAirport');
			}			
			if(departureAirportCode != '' 
				&& arrivalAirportCode != '' 
				&& departureAirportCode == arrivalAirportCode)
			{
				if ( op.labels.country=="uk" ) form.find('[name="departureAirport"]').addClass("err");
				form.find('[name="arrivalAirport"]').addClass("err");
				op.errors.push('equalAirports');
			}
			if (leavingDate=='') {
				if ( op.labels.country=="uk" ) $("#dp-from-trigger").addClass("err");
				op.errors.push('noLeavingDate');
			}
			if (returningDate=='') {
				if ( op.labels.country=="uk" ) $("#dp-to-trigger").addClass("err");
				op.errors.push('noReturningDate');
			}
			
			if ( (dateLeaving-op.curDate)==0 && op.labels.country=="uk") {
				if ( departureTime!='ANY' && currentTime >= op.getSelectedTime(departureTime) ) {
					$("#dp-from-trigger").addClass("err");
					op.errors.push('pastTime');		
				}
			} 
			
			if ( (dateLeaving < op.curDate) && op.labels.country=="uk" ) {
				$("#dp-from-trigger").addClass("err");
				op.errors.push('pastDate');
			}
			if ( (dateReturning < op.curDate) && op.labels.country=="uk") {
				$("#dp-to-trigger").addClass("err");
				op.errors.push('pastDate');
			}			
			if ( (dateLeaving > dateReturning) && dateLeaving >= op.curDate && dateReturning >= op.curDate && op.labels.country=="uk" ) {
				$("#dp-to-trigger").addClass("err");
				op.errors.push('higherReturningDate');
			}
			if( (dateReturning-dateLeaving) == 0 && dateLeaving >= op.curDate && dateReturning >= op.curDate && op.labels.country=="uk"){
				$("#dp-from-trigger").addClass("err");
				$("#dp-to-trigger").addClass("err");
				op.errors.push('sameDatesDP');
			}			
			if ( (dateReturning > op.maxDateTo) && dateLeaving >= op.curDate && dateReturning >= op.curDate && op.labels.country=="uk" ) {
				op.errors.push('numDaysMaxDP');
			}

			// CHILDREN VALIDATION
			var content = $('#' + this.contentid);
			var emptyValue = '-1';
			if($('#dpShowChildren', content).is(':checked')  || op.labels.country=="uk"){
				var roomCount = content.find('[name="numberOfRooms"]').val();
				var childCount = content.find('[name="roomOccupancies[0].numberOfChildren"]').val();

				if ( op.labels.country=="uk" ) {
					for (var room = 0; room < roomCount; room++){
						for (var child = 0; child < childCount; child++){
							if ($('[name="childAges' + (room+1) + '[' + child + ']"]', content).val() == emptyValue) $('[name="childAges' + (room+1) + '[' + child + ']"]', content).addClass("err");
						}
					}
				}
				
				for (var room = 0; room < roomCount; room++){
					for (var child = 0; child < childCount; child++){
						if ($('[name="childAges' + (room+1) + '[' + child + ']"]', content).val() == emptyValue){
							op.errors.push('missingChilrenAge');
							return false;
						}
					}
				}
			} else {
				content.find('[name="roomOccupancies[0].numberOfChildren"]').val('0');
				content.find('.updateCol').each(function(){
					var currentRoom = $(this);
					currentRoom.find('.updateRow').each(function(){
						$(this).find('select').val(emptyValue);
					});
				});
			}
			
			return (!Boolean(op.errors.length));
		}		
	},
	//carSearchFormBean
	car : {
		initialized: false,
		tabid: 'car',
		contentid: 'car-content',
		dpFromId: 'car-from-dp',
		dpToId: 'car-to-dp',
		dpContainerId: 'car-dp-container',
		dpTriggerFromId: 'car-from-trigger',
		dpTriggerToId: 'car-to-trigger',
		dpFromMonthYearSelectDiff: '0',
		dpToMonthYearSelectDiff: '0',
		init: function(){
			if(this.initialized) return;
			
			var form = $('#' + this.contentid, op.context);

			form.find('[name="searchString"]').keyup(function(){
				form.find('[name="idcarlocation"]').val('');
			});
															
			var carShowMoreOptions = $('#carsShowMoreOptions',op.context);
			carShowMoreOptions.click(function(){
				if (op.labels.country=='uk') op.changeArrow(form);

				$('.vis_carsShowMoreOptions',op.context).toggleClass('dn');
				carShowMoreOptions.find('div.icon').toggleClass('dn');
				op.addDummyContentForIE();
				return false;
			});

			$(".qm").click(function (e) {
				var content = $(this).text();
				var pos = $(this).offset();
				$(".message").empty().wrapInner("<span class=\"tooltip-content\"></span>").prepend("<span class=\"tooltip-top\"></span>").append("<span class=\"tooltip-bot\"></span>").wrapInner("<span class=\"tooltip-wrapper\"></span>").prepend("<span class=\"tooltip-arrow\"></span><span class=\"close\"></span>").show().css("top", pos.top - 207).css("left", pos.left - 350);
				$(".message .tooltip-content").text(content);
				$(".close").click(function () {
					$(".message, .overlay-cars").hide();
				});
				$(".overlay-cars").show().height($(document).height()).click(function () {
					$(".message, .overlay-cars").hide();
				});
				return false;
			});

			op.initDatepicker(this);
			this.initialized = true;
			
			$('#pickHour', form).val(10) ;
			$('#dropHour', form).val(10) ;			
			
		},
		update: function(form){
			if($("#searchpod_pickup_location").val().length==3)
				{
					$('[name="destination1"]').val($("#searchpod_pickup_location").val());
					$('[name="destination2"]').val($("#searchpod_pickup_location").val());
			}
			// CAR DEPARTURE_DATE
			var departureTimestamp = form.find('.dp.from').datepicker('getDate');		
			var pickHour = form.find('[name="pickHour"]').val();
			// op.helper.trim(form.find('.from').val())!='' ? departureTimestamp = formatDate(op.helper.trim(form.find('.from').val())) : "";
			form.find('[name="pickDate"]').val("" + op.helper.leadingZero(departureTimestamp.getDate()));
			var departureMonth = departureTimestamp.getMonth() + 1;
			form.find('[name="pickMonth"]').val("" + departureTimestamp.getFullYear() + "" + op.helper.leadingZero(departureMonth));		
			form.find('[name="pickUpDateForm"]').val(op.helper.leadingZero( departureTimestamp.getFullYear() ) + "" + op.helper.leadingZero(departureTimestamp.getMonth() + 1) + "" + op.helper.leadingZero(departureTimestamp.getDate()) + pickHour+"00");
			
			// CAR RETURN_DATE
			var returnTimestamp = form.find('.dp.to').datepicker('getDate');
			var dropHour = form.find('[name="dropHour"]').val();
			// op.helper.trim(form.find('.to').val())!='' ? returnTimestamp = formatDate(op.helper.trim(form.find('.to').val())) : "";				
			form.find('[name="dropDate"]').val("" + op.helper.leadingZero(returnTimestamp.getDate()));
			var returnMonth = returnTimestamp.getMonth() + 1;
			form.find('[name="dropMonth"]').val("" + returnTimestamp.getFullYear() + "" + op.helper.leadingZero(returnMonth));	
			form.find('[name="dropOffDateForm"]').val(op.helper.leadingZero( returnTimestamp.getFullYear() ) + "" + op.helper.leadingZero(returnTimestamp.getMonth() + 1) + "" + op.helper.leadingZero(returnTimestamp.getDate()) + dropHour+"00");		
		
		},
		validate: function(form){
			
			var idcarlocation = form.find('[name="idcarlocation"]').val();
			var destination1 = form.find('[name="destination1"]').val();
			var destination2 = form.find('[name="destination2"]').val();
			var pickupDate = $("#car-from-trigger").val();
			var dropoffDate = $("#car-to-trigger").val();
     	var sPickupDate = pickupDate.split("/"); 
      var sDropoffDate = dropoffDate.split('/');
      var datePickupDate = new Date(sPickupDate[2],sPickupDate[1]-1,sPickupDate[0]);
      var dateDropoffDate = new Date(sDropoffDate[2],sDropoffDate[1]-1,sDropoffDate[0]);
			var numDaysRental = (dateDropoffDate-datePickupDate)/(24*60*60*1000);
			
			var datePickupDateTime = new Date(sPickupDate[2],sPickupDate[1]-1,sPickupDate[0],$("#pickHour").val());			
			var currentTime = new Date();	currentTime = new Date(currentTime.getFullYear(),currentTime.getMonth(),currentTime.getDate(),currentTime.getHours());		
			var diffHours = (datePickupDateTime-currentTime)/(1000*60*60);
			
			// Removing error class
			if ( op.labels.country=="uk" ) {
				$("#car-from-trigger").removeClass("err");
				$("#car-to-trigger").removeClass("err");
			}

			if ( idcarlocation == '' && op.labels.country=="uk" ){
				var pickupDestination = $("#searchpod_pickup_location").val();
				if(pickupDestination != ''){
					$('input.suggest', form).trigger('keyup');
					op.errors.push('selectCityCars');
				} else {
					if ( op.labels.country=="uk" ) $("#searchpod_pickup_location").addClass("err");
					op.errors.push('noCityCars');
				}				
			}
			
			//if ( destination2 == '' && idcarlocation != '' && op.labels.country=="uk" ){
			if ( destination2 == '' && op.labels.country=="uk" ){
					op.errors.push('noPickLocation');
			}

			if ( destination1 == '' && op.labels.country!="uk" ){
					op.errors.push('noPickLocation');
			}
		
			if (pickupDate=='') {
				if ( op.labels.country=="uk" ) $("#car-from-trigger").addClass("err");
				op.errors.push('noPickupDate');
			}			
			if (dropoffDate=='') {
				if ( op.labels.country=="uk" ) $("#car-to-trigger").addClass("err");
				op.errors.push('noDropoffDate');
			}	
			if ( (datePickupDate < op.curDate) && op.labels.country=="uk" ) {
				$("#car-from-trigger").addClass("err");
				op.errors.push('pastDate');
			}
			if ( (dateDropoffDate < op.curDate) && op.labels.country=="uk") {
				$("#car-to-trigger").addClass("err");
				op.errors.push('pastDate');
			}					
			if ( (datePickupDate > dateDropoffDate) && datePickupDate >= op.curDate && dateDropoffDate >= op.curDate && op.labels.country=="uk" ) {
				$("#car-to-trigger").addClass("err");
				op.errors.push('higherDropoffDate');
			}
			if ( (dateDropoffDate > op.maxDateTo) && datePickupDate >= op.curDate && dateDropoffDate >= op.curDate && op.labels.country=="uk" ) {
				op.errors.push('numDaysMaxCars');
			}
			if ( numDaysRental > 90 && datePickupDate >= op.curDate && dateDropoffDate >= op.curDate && op.labels.country=="uk" ) {
				op.errors.push('numRentalDaysMaxCars');
			}
			if ( diffHours < 12 && datePickupDate >= op.curDate && dateDropoffDate >= op.curDate && op.labels.country=="uk" ) {
				op.errors.push('numHoursMaxCars');
			}
			
			return (!Boolean(op.errors.length));
			
		}		
	},
	package : {
		initialized: false,
		tabid: 'package',
		contentid: 'package-content',
		dpFromId: 'package-from-dp',
		dpToId: 'package-to-dp',
		dpContainerId: 'package-dp-container',
		dpTriggerFromId: 'package-from-trigger',
		dpTriggerToId: 'package-to-trigger',
		dpFromMonthYearSelectDiff: '0',
		dpToMonthYearSelectDiff: '0',
		init: function(){
			if(this.initialized) return;
			// Show/hide child selection
			var showChildren = $('#lastMinuteShowChildren',op.context);
			var visChildren = $('#vis_lastMinuteShowChildren', op.context);
			if(showChildren.is(':checked')){
				visChildren.removeClass('dn');
			};
			showChildren.click(function(){
				$('#vis_lastMinuteShowChildren', op.context).toggleClass('dn');
				op.addDummyContentForIE();
			});
			
			//
			var lastMinuteShowMoreOptions = $('#lastMinuteShowMoreOptions',op.context);
			lastMinuteShowMoreOptions.click(function(){
				$('.vis_lastMinuteShowMoreOptions',op.context).toggleClass('dn');
				lastMinuteShowMoreOptions.find('div.icon').toggleClass('dn');
				op.addDummyContentForIE();
				return false;
			});
			
			op.initDatepicker(this);
			
			this.initialized = true;
		},
		update: function(form){
			// Update TT persons befor submitting
			var out = '';
			for (var i=0;i < parseInt(form.find('.counter[rel="erwachsene"]').find('input:first').val()); i++){
				out += '25;';
			}
			form.find('[name="erwachsene"]').val(out);
			
			// Update TT flextime befor submitting
			form.find('[name="flextime"]').val(((form.find('[name="dauer"]').val() == '0') ? '2' : '' ));
			
			// Update TT termin/ruecktermin befor submitting
			form.find('[name="termin"]').val(op.getTimestamp(form.find('.dp.termin').datepicker('getDate')));
			form.find('[name="ruecktermin"]').val(op.getTimestamp(form.find('.dp.ruecktermin').datepicker('getDate')));
			
			var visChildren = $('#vis_lastMinuteShowChildren', op.context);
			if(visChildren.hasClass('dn')){
				visChildren.find('select').each(function(){
					$(this).val('-1');
				});
			}			
		},
		validate: function(form){
			// if(form.find('[name="abflughafen"]').val() != 47){
				// op.errors.push('noDropLocation');
				// return false;
			// }
			return true;
		}	
	},
	//carSearchFormBean
	flat : {
		initialized: false,
		init: function(){},
		tabid: 'flat',
		contentid: 'flat-content',
		dpFromId: 'flat-from-dp',
		dpToId: 'flat-to-dp',
		dpContainerId: 'flat-dp-container',
		dpTriggerFromId: 'flat-from-trigger',
		dpTriggerToId: 'flat-to-trigger',
		dpFromMonthYearSelectDiff: '0',
		dpToMonthYearSelectDiff: '0',
		init: function(){
			if(this.initialized) return;
			
			// op.initDatepicker(this);
			
			this.initialized = true;
		},
		update: function(form){},
		validate: function(form){}	
	},
	family : {
		initialized: false,
		tabid: 'family',
		contentid: 'family-content',
		dpFromId: 'family-from-dp',
		dpToId: 'family-to-dp',
		dpContainerId: 'family-dp-container',
		dpTriggerFromId: 'family-from-trigger',
		dpTriggerToId: 'family-to-trigger',
		dpFromMonthYearSelectDiff: '0',
		dpToMonthYearSelectDiff: '0',
		init: function(){
						if(this.initialized) return;
						// Show/hide child selection
		
			$('#familyChildren').change(function() {
				if($(this).val()==0){
				$('#vis_familyPackagesShowChildren', op.context).addClass('dn');
				$('#familyChild12', op.context).val('-1');
				}
				if($(this).val()==1){
				$('#vis_familyPackagesShowChildren', op.context).removeClass('dn');
				$('#familyChild21', op.context).addClass('dn');
				$('#familyChild22', op.context).addClass('dn');
				$('#familyChild22', op.context).val('-1');
				}
				if($(this).val()==2){
				$('#familyChild21', op.context).removeClass('dn');
				$('#familyChild22', op.context).removeClass('dn');
				$('#familyChild31', op.context).addClass('dn');
				$('#familyChild32', op.context).addClass('dn');
				$('#familyChild32', op.context).val('-1');
				}
				if($(this).val()==3){
				$('#familyChild31', op.context).removeClass('dn');
				$('#familyChild32', op.context).removeClass('dn');
				$('#familyChild41', op.context).addClass('dn');
				$('#familyChild42', op.context).addClass('dn');
				$('#familyChild42', op.context).val('-1');
				}
				if($(this).val()==4){
				$('#familyChild41', op.context).removeClass('dn');
				$('#familyChild42', op.context).removeClass('dn');
				}
							op.addDummyContentForIE();
			});
			
			
			//
			var familyPackagesShowMoreOptions = $('#familyPackagesShowMoreOptions',op.context);
			familyPackagesShowMoreOptions.click(function(){
				$('.vis_familyPackagesShowMoreOptions',op.context).toggleClass('dn');
				familyPackagesShowMoreOptions.find('div.icon').toggleClass('dn');
				op.addDummyContentForIE();
				return false;
			});
		
			$('#sucheLand').change(function() {
					
				  var element = $('#sucheLand option:selected');
				  var searchParam=element[0].value;
			
						/* $.ajax({
						url: op.paths.familyDestination+searchParam,
						success: function(transport){
							$('#sucheReiseziel').html(transport);
						}
					});
					 //*/
					$('#sucheReiseziel ').empty();
					$('#sucheReiseziel ').append($('#bkReiseziel').html());
					$('#sucheReiseziel  > option').each(function() {
						if($(this).val().split('|')[0]!=searchParam && searchParam!='' && $(this).val()!='|' ){
							$(this).remove();
						}
					});
					$("#sucheReiseziel option[value='|']").attr('selected','true');
					//attr('disabled','disabled') 
			}); 

			$('#sucheReiseziel').change(function(){
			   var idland = $('#sucheReiseziel option:selected').val().split('|')[0];
			   if( $('#sucheReiseziel option:selected').val()!='|')
				{ 
					$('#sucheLand').val(idland);	
				}
				$('#sucheReiseziel  > option').each(function() {
					if($(this).val().split('|')[0]!=idland&& idland!='' && $(this).val()!='|' ){
						$(this).remove();
					} 
				});
			}); 
			
			op.initDatepicker(this);
			op.familyFromOnly();
			this.initialized = true;
		
		
		},
		update: function(form){
			// Update TT termin/ruecktermin befor submitting
			var departureTimestamp = form.find('.dp.familyTermin').datepicker('getDate');
			form.find('[name="param_sucheHinreiseTag"]').val("" + op.helper.leadingZero(departureTimestamp.getDate()));
			var departureMonth = departureTimestamp.getMonth() + 1;
			form.find('[name="param_sucheHinreiseMonatJahr"]').val("" + departureTimestamp.getFullYear() + "" + op.helper.leadingZero(departureMonth));
			
			var visChildren = $('#vis_familyPackagesShowChildren', op.context);
			if(visChildren.hasClass('dn')){
				visChildren.find('select').each(function(){
					$(this).val('-1');
				});
			}			
		},
		validate: function(form){
		$('[name="param_sucheReiseziel"]').val($('#sucheReiseziel').val().split('|')[1]);
		if(form.find('[name="param_sucheReiseziel"]').val() != ""){
			$('#family-content').attr( 'action', op.paths.familyZiel);
		}else{
		 	 $('#family-content').attr( 'action', op.paths.familyCountry);
		}
		

			if($('#familyChildren').val()>0){
				for (var room = 0; room < $('#familyChildren').val(); room++){
						if ($('[name="param_sucheKind' + (room+1) +'"]').val() == '-1'){
							op.errors.push('missingChilrenAge');
							return false;
						}
				}
			} 
		
			// if(form.find('[name="abflughafen"]').val() != 47){
				// op.errors.push('noDropLocation');
				// return false;
			// }
			return true;
		}	
	}
};

op.toggleTabs = function(tabId){

	$('.message-dialog').hide();
	var li = $('#' + tabId);
	var curTab = $('.tabcontent[rel=' + li.attr('id') + ']',op.context);
	$('.tabcontent:visible,op.context').hide();
	curTab.show();
	curTab.animate({left: '+=1'},1);
	curTab.animate({left:'-=1'},1);
	curTab.queue(function () {
		op.addDummyContentForIE();
		op.selectTab(li);	
		op.closeOther();
		curTab.dequeue();
	});
	if(op.labels.country=='uk'){
		$(document).unbind('click');
	}

	jQuery.cookie ? jQuery.cookie('op_' + op.labels.country + '_tab', tabId ) : '';
	// op.closeOther();
	// // $('.tabnavigation li',op.context).removeClass('active coactive_left coactive_right');
	// $.each(op.forms, function(){
		// op.errors = [];
		// $('.message-dialog').hide();
		// var content = $('#' + this.contentid, op.context);
		// var tab = $('#' + this.tabid, op.context);
		// tab.removeClass('active coactive_left coactive_right');
		// if(this.tabid == tabId){
			// tab.prev('li').addClass('coactive_left');
			// tab.next('li').addClass('coactive_right');
			// content.show();
			// op.addDummyContentForIE();
			// tab.addClass('active');
			// op.currentContentid = this.contentid;
			// this.init();
		// } else {
			// content.hide();
		// }
	// });
}

op.helper = {};
op.helper.leadingZero = function(num){
	return (num < 10) ? ("0" + num) : num;
};
op.helper.setThreeLetterCode = function(codeInput, textInput, text){
	if(codeInput != 'undefined' && text != ''){
		var isDP = !textInput.hasClass('airports');
		var url = isDP ? op.paths.dpFlightsURL : op.paths.flightsURL;
		text = text.toLowerCase();

		// fix because on enter(key) the selected item was not filled into 3LetterCode field
		if(text.match(/\[/)){
			text = (text.split('[')[1]).replace(/\]/g, '');
		}	

		jQuery.ajax({
			url: url,
			data: {query : text},
			success: function(data){
				data = eval(data);
				var length = data.length;
				for(var i = 0; i < length; i++){
					var locationObj = data[i];
					var code = locationObj[4];
					var location = locationObj[1];
					var airportName = locationObj[2];
					var countryName = locationObj[3];
					var combined = airportName + ', ' + location + ', ' + countryName + ' [' + code + ']';
					if((code.length === 3 && code.toLowerCase() == text)
						|| location.toLowerCase() == text
						|| airportName.toLowerCase() == text
						|| combined.toLowerCase() == text){
							
						if(op.rail){
							op.rail.async = false;
						};
						codeInput.val(code).change();
						textInput.val(combined).change();
						break;
					}
				}
			},
			async: false,
			dataType: 'html'
		});
	}
};
op.helper.rtrim = function(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
};
op.helper.ltrim = function(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
};
op.helper.trim = function(str, chars) {
	return op.helper.ltrim(op.helper.rtrim(str, chars), chars);
};
op.helper.trimNumber = function(str) {
  while (str.substr(0,1) == '0' && str.length>1) {str = str.substr(1,9999);}
  return str;
};

// HELPER: IE-Bug
op.addDummyContentForIE = function(){
	if (op.le_ie7) {
		$('#sendForm,.subsection,.subsection-left,.message-dialog').append($('<div/>').addClass('dummy'));
		$('.dummy').remove();
	}
};

// HELPER: checks, if an element exists, before starting to work on it
$.fn.doOnce = function(func){
	this.length && func.apply(this);
	return this;
};

// validates counter: number, range[min,max]
op.validateCounter = function(input){
	var val = {};
	val.val = parseInt(input.val());
	val.min = parseInt(input.prev('a').attr('rel'));
	val.max = parseInt(input.next('a').attr('rel'));
	if (isNaN(val.val) || val.val < val.min) val.val = val.min;
	if (val.val > val.max) val.val = val.max;
	return val;
};

op.closeOther = function(){
	$('.dateContainer').addClass('dn');
};

// SPECIAL HANDLING
// FLIGHTS: CHILDREN/BABIES COUNT DEPENDING ON COUNT OF ADULTS
op.specialUpdate = function(counter){
		if (counter.hasClass('specialUpdateChildren')){

		var val = counter.find('input').val();
//		alert("Num. of rooms: "+val);
		
		// Code to control arrow toggles for DP
		var isdp_uk = (counter.parents('ul').attr('id')=="uk_dp_subsection")?true:false ;		
		//alert(isdp);		
		
		if (isdp_uk) {
			
			
			if ( counter.attr("rel")=="numberOfRooms" ) {
						
				var adults = counter.parents('.subsection').find('[rel=roomOccupancy[0].numberOfAdults]');
				var children = counter.parents('.subsection').find('[rel=roomOccupancy[0].numberOfChildren]');
	
				switch(val) {
					case "1":
							adults.find('a.trigger.right').attr('rel',4);children.find('a.trigger.right').attr('rel',4);						
							break;
					case "2":
							adults.find('a.trigger.right').attr('rel',2);children.find('a.trigger.right').attr('rel',2);
							if ( adults.find('input').val() > 2 ) adults.find('input').val(2);
							if ( children.find('input').val() > 2 ) children.find('input').val(2);
							break;
					case "3":
							adults.find('a.trigger.right').attr('rel',3);children.find('a.trigger.right').attr('rel',2);
							if ( adults.find('input').val() == 2 ) {children.find('a.trigger.right').attr('rel',1);}
							if ( children.find('input').val() == 2 && adults.find('input').val() > 1 ) {children.find('input').val(1);children.find('a.trigger.right').attr('rel',1);}
							break;						
					case "4":
							adults.find('a.trigger.right').attr('rel',2);children.find('a.trigger.right').attr('rel',1);
							if ( adults.find('input').val() == 2 ) {children.find('input').val(0);children.find('a.trigger.right').attr('rel',0);}
							if ( children.find('input').val() == 2 ) {children.find('input').val(1);}
							break;						
				}
			
		}
		
		if ( counter.attr("rel")=="roomOccupancy[0].numberOfAdults" ) {
				
				var rooms = counter.parents('.subsection').find('[rel=numberOfRooms]');
				var children = counter.parents('.subsection').find('[rel=roomOccupancy[0].numberOfChildren]');
				
				
				switch(rooms.find('input').val()) {
					case "3":
							if ( val == 1 ) children.find('a.trigger.right').attr('rel',2); 
							if ( val == 2 ) children.find('a.trigger.right').attr('rel',1); 							
							if ( val == 2 && children.find('input').val() > 1) children.find('input').val(1);
							if ( val == 3 ) {children.find('input').val(0);children.find('a.trigger.right').attr('rel',0);}
							break;
					case "4":
							if ( val == 1 ) children.find('a.trigger.right').attr('rel',1);
							if ( val == 2 ) {children.find('a.trigger.right').attr('rel',0);children.find('input').val(0);}
							break;
				}						

		}
				
			// Update the number of children ages dropdowns
			//op.updateRows($('.counter a.trigger',op.context).parents('.formsection'));
			op.updateRows($('.counter a.trigger',op.context).parents('#dp-content'));			
			return;
		}
	// End code to control arrow toggles for DP
	
		var children = counter.parents('.subsection').find('[rel=numberOfChildren]');
		children.find('a.trigger.right').attr('rel',9-val);
		if (children.find('input').val() > (9-val)) children.find('input').val(9-val);

		var babies = counter.parents('.subsection').find('[rel=numberOfInfants]');
		babies.find('a.trigger.right').attr('rel',val);
		if (babies.find('input').val() > val) babies.find('input').val(val);
	}
};


/*
// HELPER: close menuboxes at content-click
$(document).click(function(event) {
    if ( $(event.target).closest('.dateContainer, .datepicker').get(0) == null )  {
         op.closeOther();
    }
});
*/

function initEvents(){
		// COUNTER
		// EVENT: +/- Click
		$('.counter a.trigger',op.context).click(function(){			
						
			var a = $(this);
			var input = a.blur().parents('.counter').find('input');
			var val = op.validateCounter(input);
			val.valNew = a.hasClass('right') ? (val.val+1>val.max ? val.val : val.val+1) : (val.val-1<val.min ? val.val : val.val-1);
			input.val(val.valNew);
			// if (op.currentContentid == op.forms.flight.contentid){
				// if(op.rail && op.rail.update){ op.rail.update(); }
			// }
			// show content depending on value
			if (a.parents('.counter').hasClass('rowsUpdater') || a.parents('.counter').hasClass('colsUpdater')) {
				op.updateRows(a.parents('.formsection'));
			}
			// special validation
			if (a.parents('.counter').hasClass('specialUpdate')) {
				op.specialUpdate(a.parents('.counter'));
			}
			input.change();
			return false;
		});
		// EVENT: counter looses focus
		$('.counter input',op.context).blur(function(){
			var inp = $(this);
			var val = op.validateCounter(inp).val;
			inp.val(val);
			// show content depending on value
			if (inp.parents('.counter').hasClass('rowsUpdater') || inp.parents('.counter').hasClass('colsUpdater')) {
				op.updateRows(inp.parents('.formsection'));
			}
			// special validation
			if (inp.parents('.counter').hasClass('specialUpdate')) {
				op.specialUpdate(inp.parents('.counter'));
			}
			inp.change();
		});


		//TOOL-TIP-EVENTS
		$('.info-icon').hover(function(e){
				var pos = $(this).position();
				$("#infotip", this)
						.addClass('expand')
						.css({top:parseInt(pos.top-10)+'px',left:parseInt(pos.left+30)+'px'});

				$('#sendForm', op.context).css('zIndex','50');
		});

		//EVENT: info-image mouseout
		$('.info-icon').mouseout(function(e){
				$('#sendForm').css('zIndex','');
				$("#infotip", this).removeClass('expand');
		});
		// EVENT: info-image click
		$('.info-icon').click(function(e){return false;});
		//ENDE TOOL-TIP-EVENTS



		// SELECTBOX change
		// EVENT: change TT GEO Select Box => change related engine parameters (1.ziel 1.region)
		$("#package-content #allGeo").click(function() {  
		   var selectval = $('#package-content #allGeo').val();   
		   var ziel = '-1';
		   var region = '-1';
		   
			if (selectval != '-1') {
				// if a destination is selected
				var geo = selectval.split('|');
				ziel = geo[0];
				if(geo[0] != geo[1]) {
					region = ziel + '|' + geo[1];	   
			   }  
			}	
			 
			$("#package-content #ziel").val( ziel );
			$("#package-content #region").val( region );    
		});
		
}


// init datepicker
op.initDatepicker = function(form){
	op.prefillDate ? op.prefillDate( (jQuery.cookie) ? jQuery.cookie('op_' + op.labels.country + '_' + op.currentContentid) : '') : '';

	// initial datepicker-configuration
	var curDateFrom = op.curDate;
	var minDateTo = curDateFrom;
	var curDateTo = new Date(Date.parse(op.curDate) + 1000*60*60*24*7);
	var defaultIsEmpty = false;
	if (typeof(form.datepicker) != 'undefined'){
		curDateFrom = new Date(Date.parse(op.curDate) + parseInt(form.datepicker.from));
		if (form.datepicker.atLeastOneDay) minDateTo = new Date(Date.parse(minDateTo) + 1000*60*60*24);
		curDateTo = new Date(Date.parse(op.curDate) + parseInt(form.datepicker.to));
		if (typeof(form.datepicker.defaultIsEmpty) != 'undefined') defaultIsEmpty=true;
	}
	if(typeof(form.datepicker.fromPF) != 'undefined') curDateFrom = form.datepicker.fromPF;
	if(typeof(form.datepicker.toPF) != 'undefined') curDateTo = form.datepicker.toPF;
	var dpSpec = {
		prevText:'',
		nextText:'',
		dayNames:op.dayNames,
		dayNamesMin:op.dayNamesShort,
		dayNamesShort:op.dayNamesShort,
		monthNames:op.monthNames,
		monthNamesShort:op.monthNames,
		firstDay:1,
		dateFormat:op.labels.dateFormat,
		defaultDate:curDateFrom,
		minDate:op.curDate,
		maxDate:op.maxDateFrom,
		beforeShowDay:DP_CALL_beforeShowDay,
		onSelect:DP_CALL_onSelect,
		changeMonth: true,
		changeYear: true
	};
	var dpFrom = $('#' + form.dpFromId);
	dpFrom.datepicker(dpSpec);
	dpSpec.minDate = minDateTo;
	dpSpec.defaultDate = curDateTo;
	dpSpec.maxDate = op.maxDateTo;
	var dpTo = $('#' + form.dpToId);
	dpTo.datepicker(dpSpec);
	
	$('#' + form.dpTriggerFromId).val($.datepicker.formatDate(op.labels.dateFormat,dpFrom.datepicker('getDate'),{dayNamesShort: op.dayNamesShort, dayNames: op.dayNames, monthNamesShort: op.monthNamesShort, monthNames: op.monthNames}))
	$('#' + form.dpTriggerToId).val($.datepicker.formatDate(op.labels.dateFormat,dpTo.datepicker('getDate'),{dayNamesShort: op.dayNamesShort, dayNames: op.dayNames, monthNamesShort: op.monthNamesShort, monthNames: op.monthNames}))


	// $( ".selector" ).datepicker( "option", "dayNamesShort", ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'] );
	
	var dpContainer = $('#' + form.dpContainerId);
	if(op.le_ie6) dpContainer.bgiframe();
	
	op.context.find('.datepicker:not(.disabled)').click(function(){
		// $(window).unbind('click',op.closeOther);


		jQuery.fn.isChildOf = function(b){
			return (this.parents(b).length > 0);
		};
		//Trigger for not loading loading Datepicker


		
			if(op.labels.country=='uk'){
				$(document).click(function(e){
					//alert($(e.target).attr("id"));
						var activeTab=op.forms[op.currentContentid.split("-")[0]];
						if(!$(e.target).isChildOf("#"+activeTab.dpContainerId)&&!$(e.target).isChildOf('.ui-datepicker-calendar')&&  $(e.target).attr("id")!=activeTab.dpTriggerFromId && $(e.target).attr("id")!=activeTab.dpTriggerToId){
							dpContainer.addClass('dn');
							$(this).unbind('click');
						}
					});


			}
			dpContainer.toggleClass('dn');


	});
	// dpContainer.hover(function(){$(window).unbind('click',op.closeOther);},function(){$(window).click(op.closeOther);});
		
	dpContainer.find('.dp .dpTitle').after(
		$('.monthSelectDraft').clone().removeClass('monthSelectDraft dn').addClass('monthYearSelect')
	);
	
	dpContainer.append($('#datepickerStuff').clone().attr('id','').removeClass('dn').html());
	selectMonthYearDropdown(dpFrom);
	selectMonthYearDropdown(dpTo);
	
	dpContainer.find('.buttonDate').click(function(){
		// $(window).bind('click',op.closeOther);
		op.closeOther();
	});
	// EVENT: switch month by next/prev
	dpContainer.find('.dpPrevMonth, .dpNextMonth',op.context).click(function(){
		var m = ($(this).hasClass('dpPrevMonth') ? -1 : 1);
		incDecMonthOpodo($(this).parents('.dp'),parseInt(m));
	});
	
	// MonthYear handling
	var monthYear = dpContainer.find('.monthYear');
	// monthYear
		// .attr({'disabled':'disabled','style':'cursor: default; border: none; font-weight: bold; text-align: center; width: 165px; background: none;'})
		// .wrap('<div style="width: 150px; height: 15px; overflow: hidden; margin: 0; padding: 0; float: left;"/>');
	if(op.labels.country=='uk'){
	//	if($.browser.msie){
		//	 monthYear.attr('style','cursor: default; border: none; font-weight: bold; text-align: center; width: 165px; background: none; position: relative; left: 15%;');

		// }
	}
// $("#viewByOrg").bind($.browser.msie? 'propertychange': 'change', function(e) {
  // e.preventDefault(); // Your code here 
// });
//	if($.browser.msie){
		// monthYear.click(monthYearFunc);
//		dpContainer.find('.updateDp').click(updateDp);
//	} else {
		// monthYear.change(monthYearFunc);
		dpContainer.find('.updateDp').change(updateDp);

//	}
	
	function monthYearFunc(){
		var dp = $(this).parents('.dp');
		var value = getMonthYearValue(dp).split(':');
		var month = parseInt( op.helper.leadingZero( value[0]) );
		var year = parseInt(value[1]);
		if(dp.hasClass('to')){
			var fromDate = $('#' + form.dpFromId).datepicker('getDate');
			var fromYear = fromDate.getFullYear();
			var fromMonth = fromDate.getMonth();
			var toVal = $(this).val().split(':');
			var toYear = parseInt(toVal[1]);
			var toMonth = parseInt(toVal[0]);
			if(fromYear > toYear || (fromYear == toYear && fromMonth > toMonth)){
				dp.find('option:selected',monthYear).removeAttr("selected");
				dp.find('option',monthYear).each(function(){
					var option = $(this);
					if(option.attr('value') == (fromMonth + ':' + fromYear)){
						option.attr("selected","selected");
					}
				});
				month = fromMonth;
				year = fromYear;
			}
		}
		if(op.labels.country!='uk'){
			setMonthOpodo(dp, month, year);
		}
	}
	
	function updateDp(){
		var cur = $(this);
		op.curReg = cur.val();
		incDecMonthOpodo(dpFrom,0);
		incDecMonthOpodo(dpTo,0);
	}
	
	// dpContainer.find('.updateDp').change(function(){
		// var cur = $(this);
		// op.curReg = cur.val();
		// incDecMonthOpodo(dpFrom,0);
		// incDecMonthOpodo(dpTo,0);
	// });
	
	function DP_CALL_onSelect(date,inst){

		var jForm = $(this).parents('.tabcontent');
		// var form = jForm.attr('rel');
		var partner = $('#' + $(this).attr('rel'));
		var caller = $('.datepicker[rel=' + $(this).parents('.dateContainer').attr('id') + ']');
		var thisDate = $(this).datepicker('getDate');
		var partnerDate = partner.datepicker('getDate');
	

		var termin = op.getTimestamp(thisDate);
		var ruecktermin;
		
		updateMonthYearDropdownOpodo($(this), (thisDate.getMonth()), thisDate.getFullYear());
		updateMonthYearDropdownOpodo(partner, (partnerDate.getMonth()), partnerDate.getFullYear());
		
		if ($(this).hasClass('from')){
			// UK ONLY
			if(op.labels.country=='uk'){
				hin=$(this).attr('id').split("-")[0];
			}
			caller.filter('.from').val($(this).val());
			// caller.filter('.from').find('select').val(date);
			var validDate = $(this).datepicker('getDate');
			if (Date.parse(validDate) >= Date.parse(partner.datepicker('getDate'))) {
				if(op.labels.country=='uk'){
					delete rueck;
				}
				// var offset = (typeof(op.forms[form].datepicker.offset) != 'undefined' ? op.forms[form].datepicker.offset : (1000*60*60*24*21));
				var offset = (typeof(form.datepicker.offset) != 'undefined' ? form.datepicker.offset : (1000*60*60*24*21));
				var newDate = new Date(Date.parse(validDate)+offset);
				if (Date.parse(newDate)>Date.parse(op.maxDateTo)) {newDate = op.maxDateTo;}
				if(op.labels.country!='uk'){
				setMonthOpodo(partner,newDate.getMonth(),newDate.getFullYear());
				}
				// caller.filter('.to').find('.select').html($.datepicker.formatDate(op.labels.dateFormat,newDate,{dayNamesShort: op.dayNamesShort, dayNames: op.dayNames, monthNamesShort: op.monthNamesShort, monthNames: op.monthNames}));
				updateMonthYearDropdownOpodo(partner, (newDate.getMonth()), newDate.getFullYear());
				caller.filter('.to').val($.datepicker.formatDate(op.labels.dateFormat,newDate,{dayNamesShort: op.dayNamesShort, dayNames: op.dayNames, monthNamesShort: op.monthNamesShort, monthNames: op.monthNames}));
				partner.datepicker('setDate',newDate);
			}
			// var oneDay = (typeof(op.forms[form].datepicker.atLeastOneDay) != 'undefined' && op.forms[form].datepicker.atLeastOneDay ? (1000*60*60*24) : 0);
			var oneDay = (typeof(form.datepicker.atLeastOneDay) != 'undefined' && form.datepicker.atLeastOneDay ? (1000*60*60*24) : 0);
			partner.datepicker('option','minDate',new Date(Date.parse(validDate) + oneDay));
		}
		if ($(this).hasClass('to')){
			// UK ONLY
			if(op.labels.country=='uk'){
				rueck=$(this).attr('id').split("-")[0];
			}
			caller.filter('.to').val($(this).val()).change();
			// if (op.currentContentid == op.forms.flight.contentid){
				// if(op.rail && op.rail.update){ op.rail.update(); }
			// }
		}
		incDecMonthOpodo(partner,0);
		// UK ONLY Calendar Closing

		if(op.labels.country=='uk'){
			if($('#trip-type-oneway-uk').attr('checked')){
				if ((typeof hin != 'undefined')){
					$(document).unbind('click');
					dpContainer.toggleClass('dn');
				}
			}else{
				if (((typeof hin != 'undefined')&&(typeof rueck != 'undefined')) && rueck==hin ){
					$(document).unbind('click');
					dpContainer.toggleClass('dn');
				}
			}
		}
	};
	
	// CALLBACK: called before each day is rendered
	function DP_CALL_beforeShowDay(date){
		var dateC = $(this).datepicker('getDate');	// current date
		var date2 = $('#' + $(this).attr('rel')).datepicker('getDate'); // date from partner-datepicker
		// alert( dateC + ' | ' + date2)
		// var jForm = $(this).parents('.tabcontent');
		// var form = jForm.attr('rel');
		var outClass = '';
		var title = '';
		var i;
		var date2Set = false;
		
		// selected range
		if ($(this).hasClass('from')){
			if (!date2Set && date2 == null) {
				// if (typeof(op.forms[form].datepicker) != 'undefined') {
				if (typeof(form.datepicker) != 'undefined') {
					// date2 = new Date(Date.parse(op.curDate) + parseInt(op.forms[form].datepicker.to));
					date2 = new Date(Date.parse(op.curDate) + parseInt(form.datepicker.to));
				} else {
					date2 = new Date(Date.parse(op.curDate) + 1000*60*60*24*7);
				}
				date2set = true;
			}
			if ((date > dateC)&&(date < date2)) {
				outClass += ' border';
			}
		}
		if ($(this).hasClass('to')){
			if (date2==null) date2 = new Date(Date.parse(op.curDate) - 1000*60*60*24*7);
			if ((date < dateC)&&(date > date2)) {
				outClass += ' border';
			}
		}
		if (date.getTime() == date2.getTime()) {outClass += ' otherEnd';}
		if (date2.getTime() == dateC.getTime()) {outClass = 'noBorder';}
		if (op.showVacations && op.curReg.length) {
			// holidays
			if (typeof(op.holidays[op.curReg]) != 'undefined') {
				for (i = 0; i < op.holidays[op.curReg].length; i += 1) {
					var h = op.holidays[op.curReg][i];
					var startDate = new Date(h[0], h[1] - 1, h[2]);
					var endDate = new Date(h[3], h[4] - 1, h[5]);
					if (date >= startDate && date <= endDate) {
						outClass += ' holiday';
						title = h[6];
					}
				}
			}
			// local days
			if (typeof(op.locDays[op.curReg]) != 'undefined') {
				for (i = 0; i < op.locDays[op.curReg].length; i += 1) {
					var loc = op.locDays[op.curReg][i];
					if ((date.getFullYear() == loc[0]) && date.getMonth() == loc[1] - 1 && date.getDate() == loc[2]) {
						outClass += ' natDay';
						title = loc[3];
					}
				}
			}
		}
		// national days
		for (i=0; i<op.natDays.length; i+=1){
			if ((date.getFullYear() == op.natDays[i][0]) && date.getMonth() == op.natDays[i][1] - 1 && date.getDate() == op.natDays[i][2]) {
				outClass += ' natDay';
				title = op.natDays[i][3];
			}
		}
		return [true,outClass,title];
	};
	
	// HELPER: set value at month/year-select OPODO
	function updateMonthYearDropdownOpodo (dp, month, year){
		dp.find('.monthYear option:selected').removeAttr("selected");
		var type = dp.hasClass('from');
		var diff = (month-op.curM)+(12*(year-op.curY));
		(type ? (form.dpFromMonthYearSelectDiff = diff) : (form.dpToMonthYearSelectDiff = diff))
		if(op.labels.country=='uk'){





			selectMonthYearDropdown2(dp, month, year,type);
		}else{
			selectMonthYearDropdown(dp, month, year);
		}
	};
	
	// HELPER: jump to given month/year
	function setMonthOpodo(dp,m,y){
		var m = parseInt(m);
		var y = parseInt(y);
		// var diff = (m-op.curM)+(12*(y-op.curY));
		var date = dp.datepicker('getDate');
		var month = date.getMonth();
		var year = date.getFullYear();
		var diff = (m - month)+(12*(y - year));
		var jump = true;
		if (dp.hasClass('to')) {
			tmpDate = new Date(dp.datepicker('option','minDate'));
			jump = ((y-tmpDate.getFullYear())*12 + m-tmpDate.getMonth()>=0);
		}
		if (jump) {
			var type = dp.hasClass('from');
			// $.datepicker._adjustDate(dp, +diff - (type ? form.dpFromMonthYearSelectDiff : form.dpToMonthYearSelectDiff), 'M');
			if(diff < 0){
				$.datepicker._adjustDate(dp, +diff , 'M');
			} else {
				$.datepicker._adjustDate(dp, +diff - (type ? form.dpFromMonthYearSelectDiff : form.dpToMonthYearSelectDiff), 'M');
			}
			(type ? (form.dpFromMonthYearSelectDiff = diff) : (form.dpToMonthYearSelectDiff = diff));
			return true;
		}
		return false;
	};
	
	/*
	 * DATEPICKER
	 */
	function selectMonthYearDropdown(dp, month, year){
		var date = dp.datepicker('getDate');
		var month = month | (date.getMonth());
		var year = year | date.getFullYear();
		dp.find('.monthYear option').each(function(){
			var option = $(this);
			if(option.attr('value') == (month + ':' + year)){
				option.attr("selected","selected");
			}
		});
	}
	function selectMonthYearDropdown2(dp, month, year,from){
		var date = dp.datepicker('getDate');
		var month = month;
		if( !from ){
			var toDP =  $('#dp-to-dp').datepicker('getDate');
			var partner = $('#' + dp.attr('rel'));
			var partnerDate=partner.datepicker('getDate');
			var originalMonth=partnerDate.getMonth();
			var originalYear=partnerDate.getFullYear();
			var originalDay=partnerDate.getDate();
		}

		if(op.labels.country=='uk'){
			if(!from){

					dp.find('.monthYear option').each(function(){
						var option = $(this);
						option.removeClass("disabled");
						option.removeAttr("class");	
						option.removeAttr("disabled");	
					});
			}
		}


		var year = year;
		dp.find('.monthYear option').each(function(){
			var option = $(this);
			var monthYear =option.attr('value').split(':');
			(!from&&originalDay==op.getDateEndOfLastMonth(originalYear,originalMonth)&&(form.datepicker.atLeastOneDay))  ?originalMonth++:'';
			if(typeof(originalMonth)!='undefined'&&typeof(originalYear)!='undefined')
			if(((monthYear[0]<originalMonth && monthYear[1]<=originalYear) || (monthYear[1]<originalYear)) && !from) 
			{
				option.addClass("disabled");
				option.attr("disabled","disabled");
			}
			if(option.attr('value') == (month + ':' + year)){
				option.attr("selected","selected");
			}
		});
	}
	if(op.labels.country=='uk'){	
		$('.monthYear').change( function()
		{
			var dp=$(this).parents('.dp');
			 var dpuuid;
				if (!dpuuid) {
					for (attr in window) {
						  if(/^DP_jQuery_/.test(attr)) {
							dpuuid = attr.replace(/^DP_jQuery_([0-9]+)/, '$1');
						}
					}
				}
			dpuuid='DP_jQuery_'+dpuuid;
			var m=$(this).val().split(':')[0];
			var y=$(this).val().split(':')[1];
			var id=$(this).parent().parent().attr('id');
			eval(dpuuid+".datepicker._selectMonthYear('#"+id+"', {options:[{value:'"+parseInt(y)+"'}],selectedIndex:0}, 'Y');");
			eval(dpuuid+".datepicker._selectMonthYear('#"+id+"',{options:[{value:'"+parseInt(m)+"'}],selectedIndex:0}, 'M');");		
		} )
	}



	// HELPER: inc/dec calendar by given month-difference
	function incDecMonthOpodo(dp,diff){
		var date = dp.datepicker('getDate');
		var month = date.getMonth()+1;
		var year = date.getFullYear();
		var selected = dp.find('.monthYear option:selected');
		var selectElement = dp.find('.monthYear')[0];
		var selectedIndex = selectElement.selectedIndex;
		var incDec = true;
		var newIndex = selectedIndex + diff;
		if (newIndex < 0 || newIndex>=selectElement.length) incDec = false;
		if (dp.hasClass('to') && dp.find('.otherEnd:visible').length && (diff<0)) incDec = false;
		var m = (newIndex + op.curM);
		if (dp.datepicker('option','minDate').getMonth() > m) incDec = false;
		if (incDec) {
			$.datepicker._adjustDate(dp, +diff, 'M');
			selectElement.selectedIndex = newIndex;
		}
	};
	
	function getMonthYearValue(dp){
		return dp.find('.monthYear option:selected').val();
	}
};

op.getTimestamp = function(dpTime){
	return (Date.parse(dpTime)/1000).toString();
}
op.getDateEndOfLastMonth =function(year,month) {
var end = new Date(Date.UTC(year,month+1,0,0,0,0));
return end.getDate();
}

// VALIDATE
op.showErrors = function(){
	$('.message-dialog').show().find('.content').empty();
	for (var i=0; i<op.errors.length; i+=1){
		$('.message-dialog .content').append(op.errorCodes[op.errors[i]] + '<br/>');
	}
	op.addDummyContentForIE();
};



//setzt die Forms fuer children/rooms
op.updateRows = function(p){		
	
	var colsCount = p.find('.colsUpdater input').val();
	var rowsCount = p.find('.rowsUpdater input').val();	
	
	//alert("rooms: "+colsCount+" - children: "+rowsCount);
	
	if (rowsCount > 0) { 
		p.find('.subsection.left.vis_showHotelsChildren').removeClass('dn');
	} else {p.find('.subsection.left.vis_showHotelsChildren').addClass('dn');}
	
	var cols = p.find('.updateCol').addClass('dn'); 
	p.find('.updateRow').addClass('dn');
	for (var i = 0; i<colsCount; i+=1) {
		$(cols[i]).removeClass('dn');
		var rows = $(cols[i]).find('.updateRow');
		for (var j=0; j<rowsCount; j+=1){
			$(rows[j]).removeClass('dn');
		}
	}
	var inv = p.find('.updateRow.dn');
	for (var k = 0; k < inv.length; k += 1) {
		var first = $(inv[k]).find('p:first a:first');
		inv.find('.select a')
			.html(first.text())
			.attr('rel',first.attr('rel'));
	}
	op.addDummyContentForIE();
};

$(document).ready(function() {	
	op.context = $('#formbox');	
	
	// TABS
	// EVENT: click form-tab
	$('.tabnavigation li',op.context).click(function(){
		op.toggleTabs($(this).attr('id'));
		// $('.message-dialog').hide();
		// var li = $(this);
		// var curTab = $('.tabcontent[rel=' + li.attr('id') + ']',op.context);
		// $('.tabcontent:visible,op.context').hide();
		// curTab.show();
		// curTab.animate({left: '+=1'},1);
		// curTab.animate({left:'-=1'},1);
		// curTab.queue(function () {
			// op.addDummyContentForIE();
			// // if (!curTab.hasClass('initialized')) {
				// // curTab.initTabForm();
			// // } else {
				// // $('#sms_spinner,#sms_spinner_img').hide();
			// // }
			// op.selectTab(li);	
			// op.closeOther();
			// li.find('a').blur();
			// curTab.dequeue();
		// });
		
		return false;
	});
	// HELPER: select tab at navi
	op.selectTab = function(li){
					
			// We set the from/to date depending of the product for UK page
			if ( op.labels.country=="uk" ) {

				// Removing error class from all forms
				op.removeInputErrors();
								
				switch (li.attr('id')){
					case 'flight':op.maxDateTo = new Date(op.curY,op.curM,op.curDate.getDate()+360); // max UK value for datepickers TO
								 				  op.maxDateFrom = new Date(Date.parse(op.maxDateTo)-1000*60*60*24); // max UK value for datepickers FROM		
								   break;
					case 'hotel':op.maxDateTo = new Date(op.curY,op.curM,op.curDate.getDate()+360); // max UK value for datepickers TO
												op.maxDateFrom = new Date(Date.parse(op.maxDateTo)-1000*60*60*24); // max UK value for datepickers FROM											 										 			
										  	break;
					case 'dp':op.maxDateTo = new Date(op.curY,op.curM,op.curDate.getDate()+360); // max UK value for datepickers TO
										 op.maxDateFrom = new Date(Date.parse(op.maxDateTo)-1000*60*60*24); // max UK value for datepickers FROM											 	
									 	 break;
					case 'car':op.maxDateTo = new Date(op.curY,op.curM+11,op.curDate.getDate()); // max UK value for datepickers TO
											// We extend days of the last month until the last day of it
											op.maxDateTo = new Date(op.maxDateTo.getFullYear(),op.maxDateTo.getMonth(),daysOfMonth(op.maxDateTo.getMonth(),op.maxDateTo.getFullYear()));
											op.maxDateFrom = new Date(Date.parse(op.maxDateTo)-1000*60*60*24); // max UK value for datepickers FROM											 																							
									 		break;
				}
			}


		$('.tabnavigation li',op.context).removeClass('active coactive_left coactive_right');
		li.addClass('active');
		li.prev('li').addClass('coactive_left');
		li.next('li').addClass('coactive_right');
		if (op.le_ie6) {
			$('.tabnavigation li',op.context).removeClass('ie6_active_firsttab ie6_active_fluege ie6_active_hotels ie6_active_flug_und_hotel ie6_active_mietwagen ie6_active_last_minute ie6_active_flat');
			if (li.hasClass('firsttab')) li.addClass('ie6_active_firsttab');
			var iec = '';
			switch (li.attr('id')){
				case 'flight':iec = 'ie6_active_fluege';break;
				case 'hotel':iec = 'ie6_active_hotels';break;
				case 'dp':iec = 'ie6_active_flug_und_hotel';break;
				case 'car':iec = 'ie6_active_mietwagen';break;
				case 'package':iec = 'ie6_active_last_minute';break;
				case 'flat':iec = 'ie6_active_flat';break;
			}
			li.addClass(iec);
		}
		var form = op.forms[li.attr('id')];
		if (form) {
			op.currentContentid = form.contentid;
			form.init();
		}
		op.prefill ? op.prefill( (jQuery.cookie) ? jQuery.cookie('op_' + op.labels.country + '_' + op.currentContentid) : '') : '';
		//removing last month dropdown item, if it is not selectable
		if ( op.labels.country=="uk" ) {
		//alert(li.attr('id'));
			$("#"+op.forms[li.attr('id')].dpFromId +" .monthYearSelect option[value="+(op.maxDateFrom.getMonth()+1)+":"+	op.maxDateTo.getFullYear()+"]").remove();
			$("#"+op.forms[li.attr('id')].dpToId +" .monthYearSelect option[value="+(op.maxDateTo.getMonth()+1)+":"+	op.maxDateTo.getFullYear()+"]").remove();
		}
	};
	
	op.autosuggest();
		
	// EXECUTE: INIT FORMS
	// set init values
	op.curDate = new Date();
	op.curM = op.curDate.getMonth();
	op.curY = op.curDate.getFullYear();
	op.curReg = '';	// chosen region at holiday-select
	op.maxDateTo = new Date(op.curY+1,op.curM,op.curDate.getDate()); // max value for datepickers TO
	op.maxDateFrom = new Date(Date.parse(op.maxDateTo)-1000*60*60*24); // max value for datepickers FROM

	var activeTab = $('#formbox .tabnavigation .active');
	op.selectTab(activeTab);
	var arrVals = new Array();
	$("#formbox").find('.tabnavigation li').each(function(){	
		arrVals.push( $(this).attr('id'));	
	});
	
	if (jQuery.cookie && jQuery.cookie('op_' + op.labels.country + '_tab')) {
		if(jQuery.inArray( jQuery.cookie('op_' + op.labels.country + '_tab'), arrVals )!='-1'){
			op.selectTab( $('#formbox .tabnavigation #' + jQuery.cookie('op_' + op.labels.country + '_tab')) ); 
			op.toggleTabs(jQuery.cookie('op_' + op.labels.country + '_tab'));
		}
	}
	// $.each(op.forms, function(){
		// var form = this;
		// var tabId = form.tabid;
		// var tab = $('#' + tabId);
		// tab.click(function(){
			// op.toggleTabs(tabId);
			// // form.init(form);
		// });
		// if(activeTab.attr('id') == tabId) {
			// form.init(form);
			// op.currentContentid = form.contentid;
		// }
	// });
	
	$('#sendForm').click(function(event){
		event.preventDefault();
		$('.message-dialog').hide();
		// get actual form
		var form = $('#' + op.currentContentid);

		var formName = form.attr('rel');
		
		(op.forms[formName].update) ? op.forms[formName].update(form) : '';
		op.errors = [];

		
		if(op.forms[formName].validate && !op.forms[formName].validate(form)){
			op.showErrors();
		} else {
			jQuery.cookie ? jQuery.cookie('op_' + op.labels.country + '_' + op.currentContentid, form.serialize()) : '';
			
			// trigger bahn URL
			if( jQuery('#bahnInnerContainer').is(':visible') && jQuery('#showBahn:checked') ) {
				form.attr("action", '/opodo/buchen/flug/suchergebnis' ); 
			}
			
			form.submit();
		}
			
		return false;
	});
	initEvents();

	
	// Multistop link
/*
	$('#multiStop').click(function(event){
		var form = $('#' + op.currentContentid);
		var departureTimestamp = form.find('.dp.from').datepicker('getDate');		
		var departureMonth = departureTimestamp.getMonth() + 1;
		
		var deeplink="departureAirports[0]="+form.find('#departureAirport').val()+
								 "&arrivalAirports[0]="+form.find('#arrivalAirport').val()+
								 "&departureDays[0]="+op.helper.leadingZero(departureTimestamp.getDate())+
								 "&departureMonths[0]="+departureTimestamp.getFullYear() + "" +op.helper.leadingZero(departureMonth)+
								 "&departureTimes[0]="+form.find('#departure-time').val()+
								 "&cabinType="+form.find('#class').val();
		location.href="http://www.opodo.co.uk/opodo/flights/multistopFlights?"+deeplink;
	});
*/	
	// Initializing Starrating functionality for UK
	if ( op.labels.country=="uk" ) {
		initStarRating('hotel-content');
		initStarRating('dp-content');
	}

	// input fields mark when focus
	$('#departureAirport,#arrivalAirport,#destination,#searchpod_pickup_location').click(function(event) {
		$(this).focus().select();	
	});
	/**
	 * TODO: does not work with "umlauten"
	 *
	 * If fixed it can go live
	 */
if ( op.labels.country!="uk" )	{	 
	var sms_opo_referrer='';
	// MNE set h1 value from Google search string
	try {
       sms_opo_referrer = decodeURI(document.referrer);
     } catch (error) {
       sms_opo_referrer = unescape(document.referrer);
     }
	//sms_opo_referrer="http://www.google.de&q=Suchwort";
	if (sms_opo_referrer.length>0) {
		if (sms_opo_referrer.indexOf("google")>0) {
			sms_opo_refparts=sms_opo_referrer.split("&");
			for (i=0;i<sms_opo_refparts.length;i++) {
				sms_opo_part_parts=sms_opo_refparts[i].split("=");
				if (sms_opo_part_parts[0]=="q") {
					if (document.getElementById("pagetitle")!=null) {
						document.getElementById("pagetitle").innerHTML=op.labels.google+sms_opo_part_parts[1];
						//alert(sms_opo_googleword);
					}
				}
			}
		}
	}
}

	op.prefill ? op.prefill( (jQuery.cookie) ? jQuery.cookie('op_' + op.labels.country + '_' + op.currentContentid) : '') : '';
		
	/*load destination for family
	
		 $.ajax({
						url: op.paths.familyDestination+"-1",
						success: function(transport){
						$('#sucheReiseziel').html(transport);
						}
					});	
 */
 
 // Removing topcontent div for UK if it's empty (problem with IE8 in compatibility view)
 if( op.labels.country=='uk' && $(".topcontent").html()=="" ) $(".topcontent").remove();
 
 // If the first tab for UK is not Flights, then we change the margin-left
 if( op.labels.country=='uk' && $(".tabnavigation > li").attr("id")!="flight" ) $(".tabnavigation").addClass("notflighttab");
 
});

//kopiert inhalte ovn einem select in ein anderes
op.moveSelectedItems = function(source, destination, setsourcepref){
	var selected = $(source+' option:selected').remove();
	var sorted = $.makeArray($(destination+' option').add(selected)).sort(function(a,b){
	return $(a).text() > $(b).text() ? 1:-1;
	});
	$(destination).empty().append(sorted);    
	//keine-praeferenzen setzen
    $(source).find("option[value='']").remove();
    $(destination).find("option[value='']").remove();
    if(($(source).children().length == 0) && setsourcepref){
        $(source).append("<option value=''>Keine Pr\u00E4ferenzen</option>");
    }
    if($(destination).children().length == 0){
        $(destination).append("<option value=''>Keine Pr\u00E4ferenzen</option>");
    }
}

op.removeInputErrors = function() {
	//Flights
	$("#flight-content").find('[name="departureAirport"]').removeClass("err");
	$("#flight-content").find('[name="arrivalAirport"]').removeClass("err");
	$("#flight-from-trigger").removeClass("err");
	$("#flight-to-trigger").removeClass("err");								 	
	
	//Hotels
	$("#hotel-content").find('[name="destinationName"]').removeClass("err");
	$("#hotel-from-trigger").removeClass("err");
	$("#hotel-to-trigger").removeClass("err");
	var roomCount = $("#hotel-content").find('[name="numberOfRooms"]').val();
	var childCount = $("#hotel-content").find('[name="roomOccupancies[0].numberOfChildren"]').val();
	for (var room = 0; room < roomCount; room++){
		for (var child = 0; child < childCount; child++){
			$("#hotel-content").find('[name="childAges' + (room+1) + '[' + child + ']"]').removeClass("err");
		}
	}

	//DP
	$("#dp-content").find('[name="departureAirport"]').removeClass("err");
	$("#dp-content").find('[name="arrivalAirport"]').removeClass("err");
	$("#dp-from-trigger").removeClass("err");
	$("#dp-to-trigger").removeClass("err");
	var roomCount = $("#dp-content").find('[name="numberOfRooms"]').val();
	var childCount = $("#dp-content").find('[name="roomOccupancies[0].numberOfChildren"]').val();
		for (var room = 0; room < roomCount; room++){
			for (var child = 0; child < childCount; child++){
				$("#dp-content").find('[name="childAges' + (room+1) + '[' + child + ']"]').removeClass("err");
			}
		}

	//Cars
	$("#car-from-trigger").removeClass("err");
	$("#car-to-trigger").removeClass("err");

}

op.onSelectPrices = function(idform) {
	var form = $('#' + idform);			
	
	form.find('#maxRate').change(function() {	
		var minRate = parseInt(form.find('#minRate').val());
		var maxRate = parseInt(form.find('#maxRate').val());		
		if ( minRate!="-1" && maxRate!="-1" && minRate>maxRate ) form.find('#maxRate').find("option[value=-1]").attr("selected", "selected");
	});

	form.find('#minRate').change(function() {	
		var minRate = parseInt(form.find('#minRate').val());
		var maxRate = parseInt(form.find('#maxRate').val());		
		if ( minRate!="-1" && maxRate!="-1" && minRate>maxRate ) form.find('#minRate').find("option[value=-1]").attr("selected", "selected");
	});

}

op.getSelectedTime = function(time) {
	var times = new Array();
	times["BEFORE_NINE"] = "8";
	times["MORNING"] = "12";
	times["AFTERNOON"] = "18";
	times["EVENING"] = "0";
	times["ZERO"] = "0";
	times["ONE"] = "1";
	times["TWO"] = "2";
	times["THREE"] = "3";
	times["FOUR"] = "4";
	times["FIVE"] = "5";
	times["SIX"] = "6";
	times["SEVEN"] = "7";
	times["EIGHT"] = "8";
	times["NINE"] = "9";
	times["TEN"] = "10";
	times["ELEVEN"] = "11";
	times["TWELVE"] = "12";
	times["THIRTEN"] = "13";
	times["FOURTEEN"] = "14";
	times["FIFTEEN"] = "15";
	times["SIXTEEN"] = "16";
	times["SEVENTEEN"] = "17";
	times["EIGHTEEN"] = "18";
	times["NINETEEN"] = "19";
	times["TWENTY"] = "20";
	times["TWENTY_ONE"] = "21";
	times["TWENTY_TWO"] = "22";
	times["TWENTY_THREE"] = "23";

	return times[time];
}

NumberOfDays=[31,29,31,30,31,30,31,31,30,31,30,31]; 
function daysOfMonth(month,year){ 
	lastday=0; 
	if (month==1){ 
		mydate=new Date(year,1,29) 
		viewmonth=mydate.getMonth(); 
		if(viewmonth!=month){ultimo=28} 
	} 
	if(lastday==0){lastday=NumberOfDays[month]} 
	return lastday; 
} 
op.changeArrow = function(idform){		
				
           var formbox = idform.find('.advanced_formbox'); 
                        /*alert(idform.find('.advanced_formbox'));   
                        
                        alert(idform.find('.advanced_formbox').hasClass("open")); */
                        if (formbox.hasClass("open")){
            
                            formbox.removeClass('open'); 
                        }else
                            formbox.addClass('open');                             
                }

function initStarRating(idform){		
				
			var form = $('#' + idform);				

				
		form.find('.starrating a').mouseover(function(){ 		
			var starvalue = $(this).html();
			
			// Lighting all the previous stars
			for(i=1;i <= starvalue;i++) {
				form.find('#star_'+i).addClass("selected");
			}

			// Unlighting all the next stars
			for(i=parseInt(starvalue)+1;i <= 5;i++) {
				form.find('#star_'+i).removeClass("selected");
			}
		});

		form.find('.starrating a').mouseout(function(){ 		
			var current_starvalue = form.find('[name=minStarRating]').attr('value');
			
			// Lighting all the previous stars
			for(i=1;i <= current_starvalue;i++) {
				form.find('#star_'+i).addClass("selected");
			}

			// Unlighting all the next stars
			for(i=parseInt(current_starvalue)+1;i <= 5;i++) {
				form.find('#star_'+i).removeClass("selected");
			}
		});
		
		form.find('.starrating a').click(function(){
			var starvalue = $(this).html();
		




			form.find('[name=minStarRating]').attr('value',starvalue);		
		
			// Lighting all the previous stars
			for(i=1;i <= starvalue;i++) {
				form.find('#star_'+i).addClass("selected");

			}
	
			// Unlighting all the next stars
			for(i=parseInt(starvalue)+1;i <= 5;i++) {
				form.find('#star_'+i).removeClass("selected");

			}

			return false;
		});
			
		
}
function prefillStarRating(idform){		
				
		var form = $('#' + idform);				
		
		//var starid = $(this).attr('id');
		var starvalue = form.find('.star-rating').val();
		//alert(starvalue);				

		
		
		// Lighting all the previous stars
		for(i=1;i <= starvalue;i++) {
			form.find('#star_'+i).addClass("selected");
		}
	
		// Unlighting all the next stars
		for(i=parseInt(starvalue)+1;i <= 5;i++) {
			form.find('#star_'+i).removeClass("selected");
		}

			return false;
		
		
}


function formatDate(date)
{
	var day = date.substr(0,2);
	var month = date.substr(3,2);
	var year = date.substr(6,4);
	var formattedDate = new Date(year,month-1,day);

	return formattedDate;
}

// Firefox Cookie Solution / BackButton Feature
window.onunload = function(){};
