window.DEBUG=true;
(function(){
    eval(liligo.namespace);
    
/*
 * Included file begin: /seo/v3/common/js/forms/air.js
 * Included from:       /seo/v3/common/js/_main_air.js:4
 */

/*
 * Included file begin: /seo/v3/common/js/forms/_common.js
 * Included from:       /seo/v3/common/js/forms/air.js:1
 */

/*
 * Included file begin: /v3/searchforms/common/js/formbase.js
 * Included from:       /seo/v3/common/js/forms/_common.js:1
 */

	/**
	 * we'd like a common base class, for UrchinTracker/tracking
	 * the submit actions of the forms
	 */
	var FormBase = new Class({
	
		constructor: function(form) {
			this.form = $(form);
		},

		submit: function() {
			FormBase._fireEvent("submit", this.form);
			this.form.submit();
		}
		
	}, {
	
		init: function() {
			Observable.makeIt(this);
		},
		
		/**
		 * Change the submit function of the form to fire
		 * the static FormBase.submit event before the
		 * real submitting.
		 * Note: if you dont call the submit method of form,
		 * then this code will not work. In this case
		 * you have to add an event manager for the submit
		 * event of form.  
		 */
		hookSubmit: function(form) {
			var realSubmit = form.submit;
			form._ = form.submit;
			form.submit = function() {
			FormBase._fireEvent("submit", this);
			this.submit = realSubmit;
			this.submit();
			this.submit = arguments.callee;
		   }
		 }
	
	});
/*
 * Included file end: /v3/searchforms/common/js/formbase.js
 * Included from:     /seo/v3/common/js/forms/_common.js:1
 */


/*
 * Included file begin: /v3/searchforms/common/js/searchform.js
 * Included from:       /seo/v3/common/js/forms/_common.js:2
 */

	var SearchForm = liligo.SearchForm = new Abstract(Observable, {
		
		name: null, // required abstract
		ajaxHP: false, // is the form run in an ajax environment (like seo pages)?
		allowMultipleSubmits: false,
		
		errorMessageBgImage: "/v3/homepage/img/error-msg-bg.png",
		submitBtnLoadingImage: "/v3/searchforms/common/img/"+liligo.getLang()+"/submit-loading.png",
		
		/**
		 * you can access in the javascript, the last created
		 * searchform singleton with the static SearchForm.last.
		 * This constructor store that. 
		 */
		init: function() {
			SearchForm.last = this; 
		},
		
		/**
		 * Initialize the form and events
		 */
		initialize: function() {
			if (window.config && window.config.ajaxHP) {
				this.ajaxHP = true;
			}
				
			var that = this;
			if (!that._form) {
				that._form = $("searchform-"+that.name);
			}
			if (that._form) {
				__Eo(that._form, "submit", __EbS(that._onSubmit, that));
				if (typeof FormBase != "undefined") {
					FormBase.hookSubmit(that._form);
				}
			} else {
				return false;
			}
			if (!that._submitButton) {
				that._submitButton = $(that.name+"-submit");
				that._submitButton.disabled = this._submitted;
			}
			that.initialized = true;
			this.preload();
			return true;
		},
		
		preload: function() {
			preload([
				this.errorMessageBgImage,
				this.submitBtnLoadingImage
			]);
		},
		
		/**
		 * Override it if you need form validation 
		 */
		_validate: function() {
			return true;
		},
		
		/**
		 * Override it if the form can be filled from a json
		 */
		fill: nullFunc,
		
		preset: function() {
			var values = 
					( config && config[this.name] &&
					  extend(config[this.name].preset,(this.getValuesInCookie2JSON ? this.getValuesInCookie2JSON(): {}))
					) 
				 || ( this.getValuesInCookie2JSON && 
					 this.getValuesInCookie2JSON() );
			if (values && this.fill != nullFunc) {
				this.fill(values);
			}
		},
		
		_submitted: false,

		_onSubmit: function(event) {
			if (this._submitted && !this.allowMultipleSubmits) return;
			if (this._validate()) {
				this._submitted = true;
				this._doSubmit();
			}
		},
		
		/**
		 * Override (and call the base inside) if you want
		 * to do something (e.g. fill up a hidden field) before
		 * submit. Don't do validation here, this function
		 * have to submit the form.
		 */
		_doSubmit: function() {
			this._fireEvent("doSubmit");
			if (this._submitButton) {
				
				//multiclick fix #2
				if (!this.allowMultipleSubmits) {
					this._submitButton.src = this.submitBtnLoadingImage;
					this._submitButton.setAttribute("disabled", "disabled");
				}
			}
			this._form.submit();
			return true;
		},
		
		/**
		 * @return   true if there was an error
		 */
		_setError: function(field, error, notArray) {
			if (!notArray && (typeof field == "object") && (field.constructor == [].constructor)) {
				var result = false;
				forEach(field, function(field) {
					if (this._setError(field, error, true)) {
						result = true;
					}
				}, this);
				return result;
			}
			Style.setClassIf(error, field, "error");
			Style.setClassIf(error, this._form, "error");
			if (error) {
				$(this._form.id+"-error").innerHTML = labels[error];
				try {
					$(field).focus();
				} catch(e) {};
			}
			return !!error;
		},
		
		/**
		 * Add an <input type="hidden" /> element into form
		 */
		addHidden: function(name, value) {
			if (DEBUG) {
				if (!this._form) {
					var message = "No form in the SearchForm.addHidden. this.name: '"+this.name+"'"; 
					console.log("Error! "+message);
					throw new Error(message);
				}
			}
			var elem = Element("input", {
				type: "hidden",
				name: name,
				value: value
			});
			this._form.appendChild(elem);
			return elem;
		}
			
	});
/*
 * Included file end: /v3/searchforms/common/js/searchform.js
 * Included from:     /seo/v3/common/js/forms/_common.js:2
 */


/*
 * Included file begin: /v3/searchforms/common/js/popunders.js
 * Included from:       /seo/v3/common/js/forms/_common.js:3
 */

	var PopUnders = new Class(Observable, {
		
		constructor: function() {
			this._list = [];
		},
		
		add: function(options) {
			this._list.push(options);
		},
		
		open: function() {
			var
				list = this._list,
				total = list.length, i, win, doc, options,
				screenWidth = screen.availWidth || 800,
				screenHeight = screen.availHeight || 600,
				width = Math.min(800, Math.floor(screenWidth/total - 10));
			try {
				for (i=0;i<total;i++) {
					options = list[i];
					win = open(
						"", "", "height="+screenHeight+",width="+width+",left="+Math.floor((width+10) * i)+","+
						"top=0,menubar=1,location=1,resizable=1,scrollbars=1,toolbar=1,status=1"
					);
					win.blur();
					doc = win.document;
					doc.write("<body></body>");
					doc.close();
					doc.body.appendChild(form = Element("form", {
						method: "post",
						action: options.url
					}, doc));
					if (options.parameters) {
						forEach(options.parameters, function(value, name) {
							form.appendChild(Element("input", {
								type: "hidden",
								name: name,
								value: value
							}, doc));
						});
					}
					form.submit();
				}
			} catch (ignored) {
				return false;
			} finally {
				focus();
			}
			return true;
		}
		
	});
/*
 * Included file end: /v3/searchforms/common/js/popunders.js
 * Included from:     /seo/v3/common/js/forms/_common.js:3
 */


/*
 * Included file begin: /v3/searchforms/common/js/morelesssearchform.js
 * Included from:       /seo/v3/common/js/forms/_common.js:4
 */
	
	var MoreLessSearchForm = new Abstract(SearchForm, {
		
		name: null, // required abstract
		
		withMore: false,
		
		initialize: function() {
			if (!this._base_initialize()) return false;
			if($(this.name+"-more-")) __Eo(this.name+"-more-", "click", __EbS(this.moreLess, this, true));
			if($(this.name+"-more")) __Eo(this.name+"-more", "click", __EbS(this.moreLess, this, true));
			__Eo(this.name+"-less", "click", __EbS(this.moreLess, this, false));
			return true;
		},
		
		/**
		 * Override if you want to do something after change
		 */
		toMore: nullFunc,
		toLess: nullFunc,
		
		moreLess: function(e, more) {
			this.withMore = typeof more != "undefined" ? more :  this.withMore;
			Style.setClassIf(this.withMore, this._form, "more");
			more ? this.toMore() : this.toLess();
		}
		
	});
/*
 * Included file end: /v3/searchforms/common/js/morelesssearchform.js
 * Included from:     /seo/v3/common/js/forms/_common.js:4
 */

/*
 * Included file end: /seo/v3/common/js/forms/_common.js
 * Included from:     /seo/v3/common/js/forms/air.js:1
 */


/*
 * Included file begin: /v3/searchforms/air/js/form.js
 * Included from:       /seo/v3/common/js/forms/air.js:2
 */
	
	
/*
 * Included file begin: /v3/searchforms/air/js/compareSite.js
 * Included from:       /v3/searchforms/air/js/form.js:2
 */
	
	var CompareSite = Class({
		
		constructor : function(_block, _popUnders, _form) {
						
			this._block = _block;
			this._popUnders = _popUnders;
			this._fromInputElem = $("air-from");
			this._fromHiddenInputElem = $("air-fromCode");
			this._toInputElem = $("air-to");
			this._toHiddenInputElem = $("air-toCode");
			this._isFetching = false;
			this._cache = {};
			this._form = _form;
			this._prevContent = "";
			this._checkBoxState = {};
			this._isFlightResultsPage = false;
			this._isLaunchCompareSite = true;
			
			if (liligo.air && liligo.air.header){
				this._isFlightResultsPage = true;
			}
			this._setCheckboxes();
			
			if (config.air && config.air.preset.toCode || this._isFlightResultsPage){
				this._defaultHTML = "";
				this._isDefault = false;
				this._prevContent = this._fromInputElem.value + "_" + this._toInputElem.value;
			}else{
				this._defaultHTML = this._block.innerHTML;
				this._isDefault = true;
			}	
						
			Event.observe(_form._fromLoc,"keydown",bind(function(event){				
				if (event.keyCode == Event.KEY_TAB || event.keyCode == Event.KEY_RETURN) return;
				this._reset();
			},this));
			
			Event.observe(_form._toLoc,"keydown",bind(function(event){				
				if (event.keyCode == Event.KEY_TAB || event.keyCode == Event.KEY_RETURN) return;
				this._reset();
			},this));
					
			__Eo(_form._fromLoc, "change", bind(this._change, this));			
			__Eo(_form._fromLoc, "unchange", bind(this._change, this));
			__Eo(_form._toLoc, "change", bind(this._change, this));
			__Eo(_form._toLoc, "unchange", bind(this._change, this));
		},
		
		_setCheckboxes : function(){
			forEach($$("input", this._block), function(input) {				
				if(this._isFlightResultsPage) input.checked = false
				else input.checked = Style.hasClass(input, "checked");				
			}, this);
		},
		
		_storeCheckboxState : function(){
			forEach($$("input", this._block), function(input) {
				this._checkBoxState[input.id] = input.checked;				
			}, this);
		},
		
		_restoreCheckboxState : function(){
			forEach($$("input", this._block), function(input) {				
				input.checked = this._checkBoxState[input.id] != undefined ? this._checkBoxState[input.id] : input.checked;
			}, this);
		},
		
		_reset : function(){			
			if(this._isDefault ) {
				this._isFetching = false;
				return;
			}						
			if (this._isFetching) return;
			
			this._isFetching = true;
			this._storeCheckboxState();
			this._prevContent = "";
			this._resetDo();		
		},
		
		_resetDo : function(){			
			var that = this;			
			if (that._defaultHTML){						
				that._isFetching = false;
				that._resetFinish(that._defaultHTML); 
				return;			
			}			
			new AjaxRequest("/v3/searchforms/air/data/compareSite.jsp", {
				method: "post",					
				onSuccess: function(xhr,responseText){						
					that._defaultHTML = responseText;
					that._isFetching = false;
					that._resetFinish(responseText);
				}
			});						
		},
		
		_resetFinish : function(_html){
			this._block.innerHTML = _html;				
			this._setCheckboxes();				
			this._restoreCheckboxState();	
			this._isDefault = true;			
		},
		
		_getContent : function(_inputElem, _item){			
			var content,
				prevContentFrags = this._prevContent && this._prevContent.split("_");
			if (_inputElem.id == "air-from"){
				content = _item.label + "_" + (prevContentFrags[1] || "");
			}else{
				content = (prevContentFrags[0] || "")  + "_" + _item.label; 
			}			
			return content;
		},
		
		_getCacheKey : function(_inputElem, _item){			
			var cacheKey;			
			if (_inputElem.id == "air-from"){
				cacheKey = _item.value.split(",")[1] + "_" + (this._toHiddenInputElem.value.split(",")[1] || "");
			}else{
				cacheKey =  (this._fromHiddenInputElem.value.split(",")[1] || "")  + "_" + _item.value.split(",")[1];
			}
			return cacheKey;
		},
		
		_change : function(_inputElem, _item){
			var actContent = this._getContent(_inputElem, _item);			
			if (this._prevContent == actContent) return;
			this._isDefault = false;
			this._prevContent = actContent;
			this._storeCheckboxState();
			this._changeDo(_inputElem, _item);
		},
		
		_changeDo : function(_inputElem, _item){			
			var that = this, 
				cacheKey = this._getCacheKey(_inputElem, _item),
				cityIds = cacheKey.split("_");
			if (that._cache[cacheKey]){				
				that._isFetching = false;			
				that._changeFinish(that._cache[cacheKey]);
				return;
			}
			
			new AjaxRequest("/v3/searchforms/air/data/compareSite.jsp", {
				method: "post",
				parameters : {
					fromCityId	: cityIds[0],
					toCityId 	: cityIds[1] 
				},
				onSuccess: function(xhr,responseText){						
					that._prevContent = _item.label;
					that._cache[cacheKey] = responseText;					
					that._isFetching = false;
					that._changeFinish(responseText);
				}
			});
		},
		
		_changeFinish : function(_html){
			this._isDefault = false;		
			this._block.innerHTML = _html;
			this._setCheckboxes();				
			this._restoreCheckboxState();	
		},
		
		setDefaultStateToFalse : function(){
			this._defaultHTML = "";
			this._isDefault = false;
		},
		
		updateCompareSite : function(_fromItem, _toItem){
			this._change(null,_fromItem);
			this._change(null,_toItem);
		},
		
		launchCompareSites : function() {			
			var parameters = {}, list = [];
			forEach(this._form._form.elements, function(input) {
				parameters[input.name] = input.value;
			})
			forEach($$("input", this._block), function(input) {
				if (input.checked && input.value && this._isLaunchCompareSite) {					
					list.push(input.id.replace(/air-cs-/,""));
					this._popUnders.add({
						url: "/air_v3/compareSite/launch.jsp",
						parameters: extend({
							compareSiteId : input.value
						}, parameters)
					});
				}else{
					Style.removeClass(input, "checked");
					input.checked = false;
				}
			}, this);
			return list;
		},
		
		setLaunchCompareSite : function(_to){
			this._isLaunchCompareSite = _to;
		},
		
		getLaunchCompareSite : function(){
			return this._isLaunchCompareSite;
		}
				
});
/*
 * Included file end: /v3/searchforms/air/js/compareSite.js
 * Included from:     /v3/searchforms/air/js/form.js:2
 */


	new Singleton(MoreLessSearchForm, {
		
		name: "air",
		
		initialize: function() {
			if (!this._base_initialize()) return;			
			if (typeof(PopUnders) != "undefined") {//quick fix
				this._popUnders = new PopUnders();
			} else {
				this._popUnders = {open: nullFunc, add: nullFunc};
			}
			$("air-from-nearby").checked = true;
			$("air-direct").checked = // false;
			$("air-hotel").checked = false;
			$("air-from").value = $("air-to").value = "";
			var contentElem = $("air-content");
			this._splitCompareSite = contentElem.className.match(/splitCompareSite\-(\d)/)[1]*1;
			this._compareSiteSplitted = Style.hasClass("air-content", "compareSiteSplitted");
			if ($("searchform-air")) $("searchform-air").action = 
				((window.config && window.config.flightUrl) ? window.config.flightUrl : "") + "/air/SearchFlights.jsp";
			var layerHolder, form = this._form;
			if (Query.up(form, "table.popup")) {
				Style.set(layerHolder = Element("div"), {
					width: "100%",
					position: "absolute",
					left: 0
				});
				form.appendChild(layerHolder);
			}
			this._fromLoc = new CompLoc({
				type: "air",
				field: "air-from",
				nextFocus: "air-to",
				prevFocus: "air-submit",
				container: layerHolder
			});
			__Eo(this._fromLoc, "keydown", bind(this._setError, this, "air-from", null));
			this._toLoc = new CompLoc({
				type: "air",
				field: "air-to",
				prevFocus: "air-from",
				nextFocus: "air-out-date",
				container: layerHolder
			});
			__Eo(this._toLoc, "keydown", bind(this._setError, this, "air-to", null));
			__Eo("air-to", "focus", bind(this.preload, this, true));
			this._outDate = new DatePicker({
				direction: DatePicker.DIR_DEP,
				field:     "air-out-date",
				oldNaming: true,
				oneWayRadio:"air-subcategory-oneway",
				container: layerHolder
			});
			this._retDate = new DatePicker({
				direction: DatePicker.DIR_RET,
				field:     "air-ret-date",
				depPicker: this._outDate,
				oldNaming: true,
				oneWayRadio:"air-subcategory-oneway",
				container: layerHolder
			});
			__Eo(this._retDate, "set", bind(this.toRoundtrip, this));
			this._outDate.retPicker = this._retDate;
			this.initializeNearby();
			this.moreLess();
			$("air-flexible").checked = false;
			__Eo("air-subcategory-oneway", "click", __EbS(this.toOneway, this));
			__Eo("air-subcategory-roundtrip", "click", __EbS(this.toRoundtrip, this));
			if(!BOM.detect("firefox")){
				__Eo("air-subcategory-oneway-link", "click", __EbS(this.toOneway, this));
				__Eo("air-subcategory-roundtrip-link", "click", __EbS(this.toRoundtrip, this));
			}			
			this._roundTripInput = this.addHidden("roundTrip");
	
			//manage subcategories
			if (!this.ajaxHP) {
				forEach(document.getElementsByName("air-subcategory"), function(radio) {
					if (radio.id.indexOf("oneway") == -1 && radio.id.indexOf("roundtrip") == -1) {
						__Eo(radio, "click", __Eb(this.subCategoryClick, this, radio.id + "-link"));
					}
				}, this);
				
				forEach($$("label > a"), function(a) {
					if (a.id.indexOf("oneway") == -1 && a.id.indexOf("roundtrip") == -1) {
						__Eo(a, "click", __EbS(this.subCategoryClick, this, a.id));
					}
				}, this);
			}
			
			//when siteunder is active none of the checkboxes shall
			//be checked for the very first visit
			this._splitSiteunderActive = (document.cookie.match(/split16_hpsiteunder_carhotel=B/));
			if (this._splitSiteunderActive) {
				liligo.forEach(liligo.$$("#air-compare input[type=checkbox]"), function(el){
					Style.removeClass(el, "checked");
				});
			}			
			if($("air-subcategory-oneway") && $("air-subcategory-oneway").checked ) this.toOneway();
			if (this._splitCompareSite){		
				this.compareSite = new CompareSite($("air-compare"), this._popUnders, this);
			}
			return true;
		},
		
		updateCompareSite : function(fromElem, toElem){
			this.compareSite && this.compareSite.updateCompareSite(fromElem, toElem);
		},	
		
		preload: function(really) {
			if (really) {
				this._base_preload();
			}
		},
				
		subCategoryClick: function(event, a) {								
			this.setValues2Cookie(a);
			var targetTab = "air";
			if (a.split("-")[2] == "multi") targetTab += "-multi";			
			window.location.href = "/v3/searchforms/" + targetTab;
		},
		
		_doSubmit: function() {
			var isRoundTrip = !Style.hasClass(this._form, "oneway");
			this._roundTripInput.value = isRoundTrip ? "roundTrip" : "oneWay";
			if (!Style.hasClass(this._form, "more")) {
				var flexible = $("air-flexible").checked;
				$("air-out-flexibility").value =
				$("air-ret-flexibility").value = flexible ? 3 : 0;
			}
			if ($("air-hotel").checked) {
				this._launchHotel();
			}
			var splitCompareSite = this._splitCompareSite, checkedCompareSites;
			if (splitCompareSite) {
				checkedCompareSites = this.compareSite.launchCompareSites();
				if (checkedCompareSites.length) {
					this.addHidden("focusResults", "1");
				}
			}
			this._popUnders.open();
			if (this._compareSiteSplitted) {
				this.addHidden("splitCompareSite", splitCompareSite);
				var
					trackingPrefix = "/Comparesite/Flight",
					trackingSearchLaunched = trackingPrefix+"/SearchLaunched";
				urchinTracker(trackingSearchLaunched);
				if (splitCompareSite) {
					urchinTracker(trackingSearchLaunched+"/"+checkedCompareSites.length);
					forEach(checkedCompareSites, function(code) {
						urchinTracker(trackingPrefix+"/CompareLaunched/"+code);
					});
				}
			}
			this._base__doSubmit();
		},		
		
		
		_launchHotel: function() {
			var parameters = {};
			forEach(this._form.elements, function(input) {
				parameters[input.name] = input.value;
			})
			this._popUnders.add({
				url: ((window.config && window.config.hotelUrl) ? window.config.hotelUrl : "") + "/hotel/searchHotelsByFlight.jsp",
				parameters: parameters
			});
		},
		
		initializeNearby: function() {
			var copyFrom = function() {
				if (!$("air-to-nearby") || !$("air-from-nearby")) return;
				$("air-to-nearby").checked = $("air-from-nearby").checked;
				if (IE) {
					setTimeout(bind(arguments.callee, 0, true), 10);
				}
			};
			var copyTo = function() {
				if (!$("air-to-nearby") || !$("air-from-nearby")) return;
				$("air-from-nearby").checked = $("air-to-nearby").checked;
				if (IE) {
					setTimeout(bind(arguments.callee, 0, true), 10);
				}
			};
			Event.observe("air-from-nearby", {
				keyup: copyFrom,
				change: copyFrom,
				mouseup: copyFrom
			});
			Event.observe("for-air-from-nearby", {
				keyup: copyFrom,
				mouseup: copyFrom
			});
			Event.observe("air-to-nearby", {
				keyup: copyTo,
				change: copyTo,
				mouseup: copyTo
			});
			Event.observe("for-air-to-nearby", {
				keyup: copyTo,
				mouseup: copyTo
			});
		},
		
		fill: function(values) {
			if (!values) return;
			var value;
			if (value = values.toSubCategory){
				 $(values.toSubCategory).checked = true;
				 setTimeout(bind(function(){
					 if (values.toSubCategory == "air-subcategory-oneway"){				 	
					 	this.toOneway();
					 }else if (values.toSubCategory == "air-subcategory-roundtrip") {
					 	this.toRoundtrip();
					 }
				 },this),0);
			}
			if (value = values.from) $("air-from").value = value;
			if (value = values.fromCode) $("air-fromCode").value = value;
			if (value = values.to) $("air-to").value = value;
			if (value = values.toCode) $("air-toCode").value = value;
			if (value = values._class) $("air-class").value = value;
			if ((value = values.adults) !== undefined)
				$("air-adults").value = value;
			if ((value = values.children) !== undefined)
				$("air-children").value = value;
			if ((value = values.infants) !== undefined)
				$("air-infants").value = value;
			if ((value = values.roundtrip) !== undefined)
				this.setRoundtrip(value);
			if ((value = values.direct) !== undefined)
				$("air-direct").checked = value;
			if (value = values.dtime) $("air-out-time").value = value;
			if (value = values.rtime) $("air-ret-time").value = value;
			if (value = values.fromDateParts || values.fromDate) this._outDate.set(value);
			if (value = values.toDateParts   || values.toDate) this._retDate.set(value);
			if ((value = values.nearby) !== undefined) {
				$("air-from-nearby").checked =
				$("air-to-nearby").checked = value;
			}
			var flexChanged = false;
			if ((value = values.depDayInterval) !== undefined) {
				$("air-out-flexibility").value = value;
				flexChanged = true;
			}
			if ((value = values.retDayInterval) !== undefined) {
				$("air-ret-flexibility").value = value;
				flexChanged = true;
			}			
			if (flexChanged) {
				this.copyFlex(true);
			}
			
			if( (this.compareSite && (value = values.fillCompareSite) !== undefined )){
				this.compareSite.setLaunchCompareSite(value);
			}		
						
			if (values.submit) {
				this._onSubmit();
			}
		},
	
		getValuesInJSON : function(a) {
			var name = this.name, 
				retJSON = {			
					from 		: [$(name + "-from").value],
					fromCode	: [$(name + "-fromCode").value],
					to 			: [$(name + "-to").value],
					toCode		: [$(name + "-toCode").value],
					fromDate	: [this._outDate.value.getTime()],
					toDate		: [this._retDate.value.getTime()],
					dtime		: [$(name+"-out-time").value],
					fromNearby	: [$(name+"-from-nearby").checked],
					toNearby	: [$(name+"-to-nearby").checked],
					_class		: $(name+"-class").value,
					adults		: $(name+"-adults").value,
					children	: $(name+"-children").value,
					infants		: $(name+"-infants").value,
					direct		: $(name+"-direct").checked				
				};
			if (a){
				extend(retJSON,{
					toSubCategory : a.split("-link")[0]
				})
			}
			return retJSON;
		},
		
		getValuesInJSON2String : function(a){
			return JSON.escape(JSON.encode(this.getValuesInJSON(a))).replace(/,/g,"%%");
		},
			
		getValuesInCookie2JSON : function() {
			if (!(window.Cookie && Cookie.load && Cookie.destroy)) return;
			var values = Cookie.load("getSearchJSON");
			if(values) values = values.replace(/%%/g,",");			
			Cookie.destroy("getSearchJSON");
			return JSON.decode(JSON.decode(values)) || false;
		},
		
		setValues2Cookie : function(a) {
			if (!(window.Cookie && Cookie.save)) return;
			Cookie.save("getSearchJSON",this.getValuesInJSON2String(a));					
		},
		
		toOneway:    function() { this.setRoundtrip(false); },
		toRoundtrip: function() { this.setRoundtrip(true);  },
		
		toOnewayRountrip: function(e) {
			var el = Event.element(e), isOneWay;
			if (!el.id) return false;
			
			isOneWay = el.id.match(/.*-oneway$/); 
			this.setRoundtrip(!isOneWay);
			$("air-roundtrip-" + (isOneWay ? "oneway" : "roundtrip")).checked = "checked";  
			if (el.tagName == "input") {
				Event.stop(e);
			}			
		},
		
		setRoundtrip: function(roundtrip) {			
			this.roundtrip = roundtrip;
			Style.setClassIf(!roundtrip, this._form, "oneway");
			if (roundtrip) {
				this._retDate.set(this._retDate.value);
				if(this.withMore === false)
					this._outDate.nextFocus = $("air-ret-date");												
				else
					this._outDate.nextFocus = $("air-out-time");
			} else {
				var label = labels.homepage_top_form_air_roundtrip_oneway;
				$("air-ret-date").value = label;
				if(this.withMore === false)
					this._outDate.nextFocus = $("air-adults");
				else
					this._outDate.nextFocus = $("air-out-time");			
			}			
			setTimeout(function(){
				var item = $("air-subcategory-" + (roundtrip ? "roundtrip" : "oneway")); 
				if (item) item.checked = "checked";
			},10);  
			
		},
		
		toMore: function() {
			this._fromLoc.nextFocus = $("air-from-nearby");
			this._toLoc.nextFocus = $("air-to-nearby");
			this._outDate.nextFocus = $("air-out-time");
			this._retDate.nextFocus = $("air-ret-time");
			this.copyFlex(false);
			try {
				$("air-from").focus();
			} catch(e) {}
		},
		
		toLess: function() {
			this._fromLoc.nextFocus = $("air-to");
			this._toLoc.nextFocus = $("air-out-date");			
			if(this.roundtrip === false)
				this._outDate.nextFocus = $("air-adults");				
			else
				this._outDate.nextFocus = $("air-ret-date");			
			this._retDate.nextFocus = $("air-adults");
			this.copyFlex(true);
			try {
			 $("air-from").focus();
			} catch(e) {}
		},
		
		copyFlex: function(isMoreToLess) {
			if (isMoreToLess) {
				$("air-flexible").checked =
					1*$("air-out-flexibility").value +
					1*$("air-ret-flexibility").value;
			} else {
				$("air-out-flexibility").value =
				$("air-ret-flexibility").value = 3*$("air-flexible").checked;
			}
		},
		
		_validate: function() {
			if (!$("air-from").value || !$("air-fromCode").value) {
				return !this._setError("air-from", "homepage_top_form_air_alert_departure");
			}
			this._setError("air-from", "");
			if (!$("air-to").value || !$("air-toCode").value) {
				return !this._setError("air-to", "homepage_top_form_air_alert_destination");
			}
			this._setError("air-to", "");
			try {
				if (
					(this._fromLoc.hidden.value.split(",")[1] ==
				 	this._toLoc.hidden.value.split(",")[1])
				) {
					return !this._setError("air-from", "homepage_top_form_air_same_city");
				}
			} catch (e) {}
			return true;
		}
		
});
/*
 * Included file end: /v3/searchforms/air/js/form.js
 * Included from:     /seo/v3/common/js/forms/air.js:2
 */

/*
 * Included file end: /seo/v3/common/js/forms/air.js
 * Included from:     /seo/v3/common/js/_main_air.js:4
 */

    liligo.SEOSearchForm = SearchForm.last;
    
/*
 * Included file begin: /seo/v3/common/js/full.js
 * Included from:       /seo/v3/common/js/_main_air.js:6
 */

/*
 * Included file begin: /v3/popups/js/popup.js
 * Included from:       /seo/v3/common/js/full.js:1
 */

	//maintain the number of opened cover layers
	if (!liligo._v3_popup_overlays_shown) liligo._v3_popup_overlays_shown = 0;
		
	var Popup = new Class(Observable, {
	
		y: 100, // y position of the popup from the top part of view
	
		skin: "default",
		close: true,   // show or not the close button?
		className: "", // additional className
		
		overlay: true, // show or not an overlay? (aka background fading)
		fixOverlay: false, // click on overlay will not close the popup
		opacity: 0.8,  // opacity of overlay layer
		bgColor: "#b4cf01", // color of overlay layer
		canvasWidth: "100%", // the width of the container
		
		/**
		 * Required in options:
		 *   - content:  HTML string or a DOM node (not just an id)
		 *   - template: the template of popup (V, S, os TPTemplate)
		 */
		constructor: function(options) {
			extend(this, options || {});
			this.id = unique();
			this.templateData = extend({
				id:   this.id,
				skin: this.skin,
				close: this.close
			}, this.templateData || {});
		},
	
		/**
		 * Show/hide the popup. If the popup is not yet created,
		 * then create it.
		 * @param show  if false (===false), then hide the layer, otherwise show
		 */
		show: function(show) {
			this.create();
			if (!show) this._fireEvent("hide");
			show = show !== false;
			this._showOverlay(show);
			if (show && IE6) {
				this._reposition();
			}
			Style.showIf(show, this._container);
			if (IE6) {
				if (this.wheelObserver) {
					this._wheelObserver.stop();
					this._resizeObserver.stop();
					this._scrollObserver.stop();
				}
				if (show) {
					this._wheelObserver = new Event.Observer(
						document, "resize", bind(this._reposition, this)
					);
					this._resizeObserver = new Event.Observer(
						window, "resize", bind(this._reposition, this)
					);
					this._scrollObserver = new Event.Observer(
						window, "scroll", bind(this._reposition, this)
					);
				}
				forEach($$("select"), function(select) {
					select.style.visibility = !show
						? "visible"
						: "hidden";
				});
				forEach($$("select", this._container), function(select) {
					select.style.visibility = "visible";
				});
			}
			if (show) this._fireEvent("show");
		},
		
		hide: function() { this.show(false); },
		
		create: function() {
			if (this._container) return;
			var container = Element("div", {
				className: "skin-"+this.skin+" "+this.className,
				innerHTML: this.template.process(this.templateData)
			});
			Style.set(container, {
				display:  "none",
				position: "fixed",
				top: this.y+"px",
				left: 0,
				width: this.canvasWidth,
				zIndex: 45
			});
			DOM.add(container);
			__Eo(container, "click", __Eb(this._containerClick, this));
			var
				content = this.content,
				contentElem = $("popup-"+this.id+"-content"),
				closeElem = $("popup-"+this.id+"-close");
			if (typeof content == "string") {
				contentElem.innerHTML = content;
			} else {
				contentElem.appendChild(content);
				Style.show(content);
			}
			if (closeElem) {
				__Eo(closeElem, "click", __EbS(this.hide, this));
			}
			if (this.title) {
				var titleElem = $("popup-"+this.id+"-title");
				if (titleElem) {
					titleElem.innerHTML = this.title;
				}
			}
			this._container = container;
		},
		
		_containerClick: function(event) {
			var elem = Event.element(event);
			if (elem == this._container) {
				this.hide();
			}
		},
		
		/**
		 * Recalculate the real y position of the popup (only for IE6)
		 */
		_reposition: function() {
			if (this._overlay) this._updateOverlay();
			var container = this._container;
			container.style.position = "absolute";
			container.style.top =
				document.documentElement.scrollTop + this.y + "px";
		},
		
		/**
		 * Show/hide the overlay layer. If the overlay is not yet
		 * created, then create it.
		 * @param show  if false (===false), then hide the layer, otherwise show
		 */
		_showOverlay: function(show) {
			if (!this.overlay) return;
			show = show !== false;
			if (!this._overlay) {
				var overlay = DOM.add("div");
				Style.set(overlay, {
					position: "fixed",
					display: "none",
					opacity: this.opacity,
			    top: 0,
			    left: 0,
			    width: "100%",
			    height: "100%",
			    zIndex: 40,
			    backgroundColor: this.bgColor
				});
				this._overlay = overlay; 
				if (IE6) {
					this._updateOverlay();
				}
				if (!this.fixOverlay) {
					__Eo(this._overlay, "click", bind(this.hide, this));
				}
			}
			Style.showIf(show, this._overlay);
			
			//add a class to the body, so that one may hide certain flash banners;
			// + take care of stacking; for example:
			//   modify search + add more results + wait message
			var action = "addClass"
			if (show) {
				liligo._v3_popup_overlays_shown++;
			} else {
				if (--liligo._v3_popup_overlays_shown <= 0) {//-1 on hotel?
					action = "removeClass";
					liligo._v3_popup_overlays_shown = 0;
				}
			}
			Style[action](document.body, "v3-popup-with-overlay");
			
			if (IE6) {
				if (this._ieInterval) {
					clearInterval(this._ieInterval);
					this._resizeObserver.stop();
					this._scrollObserver.stop();
				}
				if (show) {
					this._ieInterval = setInterval(
						bind(this._updateOverlay, this),
						300
					);
					this._resizeObserver = new Event.Observer(
						window, "resize", bind(this._updateOverlay, this)
					);
					this._scrollObserver = new Event.Observer(
						window, "scroll", bind(this._updateOverlay, this)
					);
				}
			}
		},
		
		/**
		 * Update the size of overlay layer. Only for IE6
		 */
		_updateOverlay: function() {
			var
				body = document.body,
				winHeight =
					document.documentElement.clientHeight || // IE6 strict
					body.clientHeight; // IE6 quirks
			body.style.height = "auto";
			Style.set(this._overlay, {
				position: "absolute",
		    width:  body.scrollWidth+"px",
		    height: Math.max(body.scrollHeight, winHeight)+"px"
		  });
		}
		
	});
/*
 * Included file end: /v3/popups/js/popup.js
 * Included from:     /seo/v3/common/js/full.js:1
 */

this.Popup = Popup;

//anclude("airwidget.js");
//anclude("airwidget_form.js");

/*
 * Included file begin: /seo/v3/common/js/hotelwidget.js
 * Included from:       /seo/v3/common/js/full.js:6
 */
HotelWidget = new Class(Observable, {
	targetId: "hotelwidget",
	container : "seo-result",
	containerOffsetX : 445,	
	visible: null,
	
	constructor: function(params){
		extend(this, params);
		this.target = $(this.targetId);
		Event.observe(window,"resize",bind(function(){
			this.hide();
		},this));
		Event.observe(this.target, "click", bindAsEventListener(this.onWidgetClick, this));
		Mediator.addEventListener("Filters", function(_source,_action){
			if (_action == "before_startFiltering") {
				this.hide();
			};
		}, this);
		Mediator.addEventListener("Layout.ResultDisplay", function(_source,_action){
			if (_action == "before_setPage") {
				this.hide();
			};
		}, this);
		
		if (BOM.detect("ie6")){
			this.safelayer = new params.safelayer("safelayer",this.targetId);
		}		
	},
	
	onWidgetClick: function(e){
		var self = Event.element(e);
		if (self.id == "swclosebtn"){
			this.hide();
			Event.stop(e);
			return;
		}
		if (self.name == "hotel-submit"){
			this._fireEvent("doSubmit");
			this.hide();
		}
	},
	
	show: function(itemnum, self){	
	
		var containerPos = Geometry.position($("seo-result")),
			selfPos = Geometry.position(self.parentNode),
			searchJSON = this.getSearchJSON(itemnum);		
		if (this.hotelform) this.hotelform.moreLess(null, false);
		this.hotelform.fill(searchJSON);
		this.hotelform.resetSubmit();
		var offsetX = containerPos[0] + this.containerOffsetX,
			offsetY = containerPos[1] + (selfPos[1] - containerPos[1] - 80);
		this.target.style.left = offsetX + "px";		
		this.target.style.top = offsetY + "px";		
		if (BOM.detect("ie6")){
			this.safelayer.move(offsetX, offsetY);
			this.safelayer.show();
		}		
		Style.show(this.target);		
		this.visible = itemnum;		
	},
	
	hide: function(){
		if (this.hotelform) this.hotelform.moreLess(null, false);
		Style.hide(this.target);
		if (BOM.detect("ie6")){
			this.safelayer.hide();
		}
		this.visible = null;
	},
	
	getSearchJSON: function(itemnum){
		var item = window.results[itemnum];
		return {
			to: (item.to) ? item.to : window.config.hotel.preset.to,
			toCode: (item.toCode) ? item.toCode : window.config.hotel.preset.toCode,
			name: item.acc_name,
			stars: item.acc_stars
		}
	}
});
/*
 * Included file end: /seo/v3/common/js/hotelwidget.js
 * Included from:     /seo/v3/common/js/full.js:6
 */


/*
 * Included file begin: /seo/v3/common/js/hotelwidget_form.js
 * Included from:       /seo/v3/common/js/full.js:7
 */

HotelForm = new Class(MoreLessSearchForm, {

		name: "UID-hotel",
		maxNights: 60,

		initialize: function() {
			if (!this._base_initialize()) return;
			this._city = new CompLoc({
				type: "hotel",
				field: "UID-hotel-city",
				hidden: "UID-hotel-cityCode",
				nextFocus: "UID-hotel-from-date"
			});
			__Eo(this._city, "keydown", bind(this._setError, this, "hotel-city", ""));
			$("UID-hotel-city").value = "";
			this._fromDate = new DatePicker({
				direction: DatePicker.DIR_DEP,
				field:     "UID-hotel-from-date",
				nextFocus: "UID-hotel-to-date",
				offsetLeft: 5,
				preReturnDays: 1,
				oldNaming: true
			});
			__Eo(this._fromDate, "set", bind(this.updateNights, this));
			this._toDate = new DatePicker({
				direction: DatePicker.DIR_RET,
				field:     "UID-hotel-to-date",
				nextFocus: "UID-hotel-rooms",
				depPicker: this._fromDate,
				offsetLeft: 4,
				preReturnDays: 1,
				minDays:   1,
				oldNaming: true
			});
			__Eo(this._toDate, "set", bind(this.updateNights, this));
			this._fromDate.retPicker = this._toDate;
			this.updateNights();
			this._initRooms();
			for (var i=1; i<=5; i++) {
				$("UID-hotel-category-"+i).checked = true;
			}
			this.moreLess();
			return true;
		},
		
		constructor: function() {
			this.initialize();
		},
		
		resetSubmit: function(){
			this._submitted = false;
			this._submitButton.disabled = false;
		},

		fill: function(values) {
			if (!values) return;
			var value;
			if (value = values.name) $("UID-hotel-name").value = value;
			if (value = values.to) $("UID-hotel-city").value = value;
			if (value = values.toCode) $("UID-hotel-cityCode").value = value;
			if (value = values.arrDate) this._fromDate.set(value);
			if (value = values.depDate) this._toDate.set(value);
			this.updateNights();
			if (
				(values.minPrice !== undefined) &&
				(values.maxPrice !== undefined)) {
				$("UID-hotel-max-price").value = values.minPrice + "-" + values.maxPrice;
			}
			/*if (values.stars != null){
				var value = values.stars;
				if (value > 0) {
					for (var i=1;i<=5;i++) {
						$("UID-hotel-category-"+i).checked = false;
					}
					$("UID-hotel-category-"+value).checked = true;
				} else {
					for (var i=1;i<=5;i++) {
						$("UID-hotel-category-"+i).checked = true;
					}
				}
			}*/
			if (value = values.rooms) {
				$("UID-hotel-rooms").value = value.length;
				this._onRoomsChange();
				forEach(value, function(room, index) {
					index++;
					$("UID-hotel-adults-"   + index).value = room.adults;
					$("UID-hotel-children-" + index).value = room.children;
				});
			}
			if (values.submit) {
				this._onSubmit();
			}
		},

		updateNights: function() {
			var nights = Math.ceil((this._toDate.value-this._fromDate.value)/86400000);
			this.nights = nights;
			$("UID-hotel-nights").innerHTML = nights;
			var cont = $("UID-hotel-nights").parentNode;
			Style.setClassIf(nights > 1, cont, "plural");
			Style.setClassIf(nights < 2, cont, "singular");
			if (nights > this.maxNights) {
				this._setError("UID-hotel-to-date-picker", "homepage_top_form_hotel_alert_nights");
				return false;
			} else {
				this._setError("UID-hotel-to-date-picker");
				return true;
			}
		},

		toLess: function() {
			var rooms = $("UID-hotel-rooms").value;
			for (var i=1; i<=rooms; i++) {
				$("UID-hotel-adults-"+i).value = 2;
				$("UID-hotel-children-"+i).value = 0;
			}
			try { // try-catch focus for IE
				$("UID-hotel-city").focus();
			} catch(e) {}
		},

		toMore: function() {
			try { // try-catch focus for IE
				$("UID-hotel-city").focus();
			} catch(e) {}
		},

		_initRooms: function() {
			var
				roomCount = 3, // $("UID-hotel-rooms").options.length,
				template = new VTemplate("/seo/v3/common/templates/hotel-room.vm", function (context) { 
var text = new liligo.__VT_StringCat(), _function = 'function', 
velocityCount = 0;
if (context.velocityCount) velocityCount=context.velocityCount;

text.push('	<label for="UID-hotel-adults-');
text.push( context.roomNumber);
text.push('" class="number">');
text.push( context.roomNumber);
text.push('.</label>	<select id="UID-hotel-adults-');
text.push( context.roomNumber);
text.push('" name="room');
text.push( context.roomNumber);
text.push('adults" class="adults">		<option value="0">0</option><option value="1">1</option><option value="2" selected="selected">2</option>		<option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option>	</select>	<select id="UID-hotel-children-');
text.push( context.roomNumber);
text.push('" name="room');
text.push( context.roomNumber);
text.push('children" class="children">		<option value="0" selected="selected">0</option><option value="1">1</option><option value="2">2</option>		<option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option>	</select>');
return text.toString();
}
);
				rooms = this._rooms = {};
			for (var i = 1; i<=roomCount; i++) {
				var room = rooms[i] = $("UID-hotel-room-"+i);
				Style.hide(room);
				room.innerHTML = template.process({
					roomNumber: i
				});
				__Eo(room, "mousedown", __Eb(this._onRoomAction, this, i));
				__Eo(room, "change", __Eb(this._onRoomAction, this, i));
			}
			Style.show(rooms[1]);
			this._onRoomsChange();
			__Eo("UID-hotel-rooms", "change", bind(this._onRoomsChange, this));
		},

		_onRoomAction: function(event, roomNumber) {
			var element = Event.element(event);
			if (element.nodeName != "SELECT") return;
			this._setError([
				"UID-hotel-adults-"  +roomNumber,
				"UID-hotel-children-"+roomNumber
			]);
		},

		_onRoomsChange: function() {
			var value = $("UID-hotel-rooms").value, rooms = this._rooms;
			Style.setClassIf(value == 1, "UID-hotel-persons", "single");
			Style.showIf(value > 1, rooms[2]);
			Style.showIf(value > 2, rooms[3]);
		},

		_validate: function() {
			var errorLabelPrefix = "homepage_top_form_hotel_alert_alert_";
			if (!$("UID-hotel-city").value) {
				this._setError("UID-hotel-city", errorLabelPrefix+"city");
				return false;
			}
			this._setError("UID-hotel-city", "");
			var rooms = 1*$("UID-hotel-rooms").value;
			for (var i=1; i<=rooms; i++) {
				var
					adults   = 1*$("UID-hotel-adults-"+i).value,
					children = 1*$("UID-hotel-children-"+i).value,
					fields   = ["UID-hotel-adults-"+i, "UID-hotel-children-"+i];
				if (adults + children > 10) {
					return !this._setError(fields, errorLabelPrefix+"guests");
				}
				this._setError(fields, "");
				if (!adults && children) {
					return !this._setError(fields, errorLabelPrefix+"adults");
				}
				this._setError(fields, "");
				if (!adults && !children) {
					return !this._setError(fields, errorLabelPrefix+"rooms");
				}
				this._setError(fields, "");
			}
			return this.updateNights();
		},

		_doSubmit: function() {
			var minMax = $("UID-hotel-max-price").value;
			if (minMax == "-1") {
				minMax = [-1, -1];
			} else {
				minMax = minMax.split(/-/);
			}
			this.addHiddens({
				roomdetails: "true",
				room1type:   1,
				room2type:   1,
				room3type:   1,
				nights:      this.nights,
				minPrice:    minMax[0],
				maxPrice:    minMax[1],
				javaDates:   1
			});
			this._base__doSubmit();
			this._submitButton.src = "/seo/v3/common/img/"+getLang()+"/searchwidget_submit.png";
		},

		addHiddens: function(hiddensMap) {
			forEach(hiddensMap, function(value, name) {
				this.addHidden(name, value);
			}, this);
		}

	});
/*
 * Included file end: /seo/v3/common/js/hotelwidget_form.js
 * Included from:     /seo/v3/common/js/full.js:7
 */


/*
 * Included file begin: /myliligo/popups/common/js/popup.js
 * Included from:       /seo/v3/common/js/full.js:8
 */

	window.hpPopup = Abstract({
		
		name: null,
		submit: null,
		
		opener: false,
		noForm: false,
		
		initialize: function() {
			if (this.initialized) return;
			this.initialized = true;
			if (this.opener) {
				__Eo(this.opener, "click", __EbS(this.show, this));
			}
			if (!this.noForm) {
				Event.observe("hp-"+this.name+"-form", "submit",
					this.bindedSubmit = Event.bindStop(this.submit, this)
				);
			}
			__Eo("hp-"+this.name+"-close", "click", __EbS(this.close, this));
		},
		
		// If the hash of url contains the name of popup, then show it (e.g.: #register)
		hashOpen: function() {
			var hash = document.location.hash;
			if (hash && hash.indexOf(this.name) != -1) {
				this.show();
			}
		},
		
		show: function() {
			if (!this.initialized) this.initialize();
			if (!this.noFade) {
				hpPopupTools.setPosition("hp-"+this.name);
				hpPopupTools.fadeScreen(true);
			}
			Style.show("hp-"+this.name);
		},
		
		close: function() {
			Style.hide("hp-"+this.name);
			if (!this.noFade) {
				hpPopupTools.fadeScreen(false);
			}
		},
		
		setError: function(target, error, toParent) {
			target = $(target);
			if (toParent) target = target.parentNode;
			if (error === null) {
				Style.removeClass(target, "error");
				Style.removeClass(target, "valid");
			} else {
				Style.setClassIf(error,  target, "error");
				Style.setClassIf(!error, target, "valid");
			}
			return error;
		}
		
	});
/*
 * Included file end: /myliligo/popups/common/js/popup.js
 * Included from:     /seo/v3/common/js/full.js:8
 */


/*
 * Included file begin: /myliligo/popups/common/js/popuptools.js
 * Included from:       /seo/v3/common/js/full.js:9
 */

	window.hpPopupTools = Singleton({
		
		tabChain: 
/*
 * Included file begin: /myliligo/popups/common/js/tabchain.js
 * Included from:       /myliligo/popups/common/js/popuptools.js:4
 */

	Class({
		
		constructor: function() {
			var
				observers = this.observers = this.observers || [],
				chain = arguments,
				listener,
				_Event = Event;
			if (chain.length == 1 && typeof chain[0] == "object" && chain[0].length) {
				chain = chain[0];
			}
			this.list = chain;
			for (var i=0; i<chain.length-1; i++) {
				listener = function(event, index) {
					if (event.keyCode == _Event.KEY_TAB) {
						try {
							if (event.shiftKey) {
								if (index) $(chain[index-1]).focus();
							} else {
								$(chain[index+1]).focus();
							}
						} catch (e) {}
						_Event.stop(event);
					}
				};
				listener = _Event.bind(listener, 0, i);
				observers.push(
					new _Event.Observer(chain[i], "keydown", listener)
				);
			}
		},
		
		remove: function() {
			var observers = this.observers, observer;
			while (observer = observers.shift()) {
				observer.stop();
			}
			delete this.list;
		}
		
	})
/*
 * Included file end: /myliligo/popups/common/js/tabchain.js
 * Included from:     /myliligo/popups/common/js/popuptools.js:4
 */
,
		Shadow:   
/*
 * Included file begin: /myliligo/popups/common/js/shadow.js
 * Included from:       /myliligo/popups/common/js/popuptools.js:5
 */
	
	Class({
			
		constructor: function(elem, params) {
			params = params || {};
			this.params = {
				offsetX: 4,
				offsetY: 4,
				opacity: 0.25,
				color: "#9d9d9d",
				zIndex: 55,
				img: "/myliligo/popups/common/img/shadow-gray-alpha.png"
			};
			if ((params.color == "#c9db58") && !params.img) {
				params.img = "/myliligo/popups/common/img/shadow-green-alpha.png";
			}
			params = extend(this.params, params);
			var
				dim = Geometry.dimension(this.elem = elem = $(elem)),
				pos = Geometry.position(elem),
				html = [];
			Style.hide(this.div = Element("div"));
			document.body.insertBefore(this.div, document.body.firstChild);
			Style.set(this.div, {
				opacity: params.opacity,
				zIndex: params.zIndex
			});
			(this.inner = Element("div")).style.position = "relative";
			this.div.appendChild(this.inner);
			if (dim[0] > 20) html.push(
				'<div style="height:20px;width:', dim[0]-20, 'px;position:absolute;background:', params.color, ';right:20px;bottom:0"></div>'
			);
			if (dim[1] > 20) html.push(
				'<div style="width:', dim[0],
				'px;height:', dim[1]-20, 'px;position:absolute;background:', params.color, ';bottom:20px;right:0"></div>'
			);
			html.push('<div style="width:', Math.min(dim[0], 20), 'px;height:', Math.min(dim[0], 20), 'px;position:absolute;bottom:0;right:0;');
			if (IE) {
				html.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'', params.img, '\', sizingmethod=\'crop\')');
			} else {
				html.push('background:url(', params.img, ') 100% 100%;');
			}
			html.push('"></div>');
			this.inner.innerHTML = html.join("");
			Style.set(this.inner, {
				height: dim[1]+"px",
				width: dim[0]+"px"
			});
			Style.set(this.div, {
				position: "absolute",
				display: "block",
				left: pos[0]+params.offsetX+"px",
				top: pos[1]+params.offsetY+"px"
			});
		},
		
		remove: function() {
			this.div.removeChild(this.inner);
			document.body.removeChild(this.div);
			delete this.inner;
			delete this.div;
			this.remove = nullFunc;
		}
		
	})
/*
 * Included file end: /myliligo/popups/common/js/shadow.js
 * Included from:     /myliligo/popups/common/js/popuptools.js:5
 */
,
		
		setPosition: function(popup, diff, center) {
			popup = $(popup);
			if (self.pageYOffset) {
				offset = self.pageYOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {
				offset = document.documentElement.scrollTop;
			} else if (document.body) {
				offset = document.body.scrollTop;
			}
			if (center) {
				var docElem, winHeight = 0;
				if (self.innerHeight) {
					winHeight = self.innerHeight;
				} else if ((docElem = document.documentElement) && docElem.clientHeight) {
					winHeight = docElem.clientHeight;
				} else if (document.body) {
					winHeight = document.body.clientHeight;
				}
				diff = Math.round((winHeight-Geometry.dimension(popup)[1])/2);
			} else {
				if (diff == undefined) diff = 100;
			}
			popup.style.top = offset+diff+"px"
		},
		
		getViewportY: function() {
			var docElem;
			if (self.innerHeight) {
				return [window.pageYOffset, window.pageYOffset+self.innerHeight];
			} else if ((docElem = document.documentElement) && docElem.clientHeight) {
				return [docElem.scrollTop, docElem.scrollTop+docElem.clientHeight];
			} else if (document.body) {
				return [document.body.scrollTop, document.body.scrollTop+document.body.clientHeight];
			}
		},
		
		fadeScreen: function(show, _params) {
			var params = {
				opacity: 0.8,
				zIndex: 40,
				color: "#abc600",
				minHeight: 0
			};
			extend(params, _params || {});
			if (!this.fader) {
				this.fader = Element("div");
				Style.set(this.fader, {
					position: "absolute",
					top: 0,
					left: 0,
					overflow: "hidden",
					display: "none"
				});
				document.body.insertBefore(this.fader, document.body.firstChild);
			}
			if (show) {
				var dim, docElem, winHeight = 0;
				if (self.innerHeight) {
					winHeight = self.innerHeight;
				} else if ((docElem = document.documentElement) && docElem.clientHeight) {
					winHeight = docElem.clientHeight;
				} else if (document.body) {
					winHeight = document.body.clientHeight;
				}
				var oldHeight = document.body.style.height;
				document.body.style.height = "auto";
				if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
					dim = [document.body.scrollWidth+"px", Math.max(document.body.scrollHeight, params.minHeight, winHeight)+"px"];
				} else if( document.body.offsetWidth ) {
					dim = [document.body.offsetWidth+"px", Math.max(document.body.offsetHeight, params.minHeight, winHeight)+"px"];
				} else {
					dim = ["100%", "100%"];
				}
				document.body.style.height = oldHeight;
				DatePicker && DatePicker.actual && DatePicker.actual.close();
				Style.set(this.fader, {
					opacity: params.opacity,
					zIndex: params.zIndex,
					backgroundColor: params.color,
					width: dim[0],
					height: dim[1]
				});
				if (IE) {
					forEach($$("select"), function(sel) {
						sel.style.visibility = "hidden";
					});
				}
				Style.show(this.fader);
			} else {
				Style.hide(this.fader);
				if (IE) {
					forEach($$("select"), function(sel) {
						sel.style.visibility = "visible";
					});
				}
			}
		}
		
	});
/*
 * Included file end: /myliligo/popups/common/js/popuptools.js
 * Included from:     /seo/v3/common/js/full.js:9
 */


/*
 * Included file begin: /seo/v3/common/js/crosslink-widget.js
 * Included from:       /seo/v3/common/js/full.js:10
 */
CrosslinkPager = new Class({
	constructor: function(widget) {
		this.widget = widget;
		this.current = 1;
		
		this.box = $("crosslink-"+this.widget);
		this.prevPage = $("crosslink-"+this.widget+"-prev");
		this.nextPage = $("crosslink-"+this.widget+"-next");
		this.items = $$(".crosslink-items li", $("crosslink-"+this.widget));
		this.pagers = $$(".crosslink-pages a", $("crosslink-"+this.widget));
		
		Event.observe(this.prevPage, "click", Event.bindStop(function() {
			this.prevnext(-1);
		}, this));
		Event.observe(this.nextPage, "click", Event.bindStop(function() {
			this.prevnext(+1);
		}, this));
		forEach(this.pagers, function(pager, index) {
			Event.observe(pager, "click", Event.bindStop(function() {
				this.setpage(index+1);
			}, this));
		}, this);
		Event.observe(this.box, "mouseover", bind(function() {
			clearInterval(this.timerId);
		}, this));
		Event.observe(this.box, "mouseout", bind(function(e) {
			this.mouseout(e);
		}, this));

		this.starttimer();
	},
	
	setpage: function(page) {
		Style.hide(this.items[this.current-1]);
		Style.removeClass(this.pagers[this.current-1], "active");
		Style.show(this.items[page-1]);
		Style.addClass(this.pagers[page-1], "active");
		this.current = page;
	},
	
	prevnext: function(pDelta) {
		if ((pDelta > 0) && (this.current + pDelta > this.items.length)) this.setpage(1);
		else if ((pDelta < 0) && (this.current + pDelta < 1)) this.setpage(this.items.length);
		else this.setpage(this.current + pDelta);
	},
	
	starttimer: function() {
		this.timerId = setInterval(bind(function() {
			this.prevnext(1);
		}, this), 8000);
	},
	
	mouseout: function(e) {
		var tg = (window.event) ? e.srcElement : e.target;
		if (tg.className != "hp-widget-content") return;

		var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
		if (reltg) {
			while (reltg != tg && reltg.nodeName != 'BODY') reltg = reltg.parentNode
			if (reltg == tg) return;
			
			setTimeout(bind(function() {
				this.prevnext(1);
				this.starttimer();
			}, this), 1000);
		}
	}
	
});
/*
 * Included file end: /seo/v3/common/js/crosslink-widget.js
 * Included from:     /seo/v3/common/js/full.js:10
 */


liligo.jsOp=function(s, ext) {
	s = s.replace(/ /g,"/");//spacebol legyen slash
	if (!s.match(/.*\/$/)) s += (!ext ? ".jsp" : "." + ext);//es ha nincs a vegen slash, akkor legyen default .jsp
	window.open(s, "_self")
}

liligo.SEOApp = new Application({
	
	init : function(){},
	
	initialize: function(){
		if ($("airwidget")) {
			airWidget = new AirWidget({
				airform: new AirForm()
			});
			/*Event.observe(Query.selectNode("body"), "click", function(e) {
				var el = Event.element(e), up = Query.up(el, "#airwidget");
				if (!up && el.tagName != "A") airWidget.hide();
			});*/
		} else if ($("hotelwidget")) {
			
			hotelWidget = new HotelWidget({					
				hotelform: new HotelForm(),
				safelayer: new Class(SafeLayer, {
					constructor : function(iframe,element){
					element = this.element = $(element);
					element.style.zIndex = 91;
					this.iframe = $(iframe);
					this.container = document.body;
				}})						
			});
			/*Event.observe(Query.selectNode("body"), "click", function(e) {
				var el = Event.element(e), up = Query.up(el, "#hotelwidget");
				if (!up && el.className != "button-small") hotelWidget.hide();
			});*/
		}
		
		forEach(["guide","air","route","hotel","car","news","depnews","lang"], function(tab) {
			if ($("seopage-"+tab)) {
				Event.observe($$("a", $("seotab-"+tab))[0], "click", function(e) {
					Event.stop(e);
					if (tab == "lang") {
						popup = new Popup({
							y: 220,
							template: new liligo.VTemplate("/v3/popups/templates/default.vm", function (context) { 
var text = new liligo.__VT_StringCat(), _function = 'function', 
velocityCount = 0;
if (context.velocityCount) velocityCount=context.velocityCount;

text.push('	<table class="popup" cellspacing="0">		<tr>			<td class="popup-frame-tl">				<div id="popup-');
text.push( context.id);
text.push('-title" class="popup-title"></div>				');
if (context.close) {
text.push('					<a id="popup-');
text.push( context.id);
text.push('-close" class="popup-close" href="');
text.push('#close');
text.push('">						');
text.push( context.labels.common_popup_close);
text.push('					</a>				');
}
text.push('			</td>			<td class="popup-frame-tr"></td>		</tr>		<tr>			<td class="popup-content" id="popup-');
text.push( context.id);
text.push('-content">			</td>			<td class="popup-frame-right"></td>		</tr>		<tr>			<td colspan="2">				<span class="popup-frame-bl"></span>				<span class="popup-frame-br"></span>			</td>		</tr>	</table>');
return text.toString();
}
),
							content: $("seopage-lang"),
							skin: "default-whitebg",
							close: true,
							title: labels.seotab_language
						});
						popup.create();
						popup.show();
					} else $('seo-content').className = tab;
				});
			}
		});
		
		forEach(["package","route","hotel","car"], function(crosscat) {
			if ($("crosslink-"+crosscat)) new CrosslinkPager(crosscat);
		});
		
		if ($("seo-lang")) __Eo("seo-lang", "click", __Eb(this.langClick, this));
		
		new FooterNofollow("footer-nofollow");		
		
	},

	langClick: function(event) {
		var elem = Event.element(event);
		
		//show/hide flags; the wrapper box is needed for IE
		if ((Style.hasClass(elem, "langsel")) || (Style.hasClass(elem.parentNode, "langsel"))) {
			Event.stop(event);
			this.box = Query.selectNode("div.lang_wrapper", this._div);
			Style.showIf(this.box.style.display, this.box);
		}
	}	
	
});

domLoaded(function(){
	liligo.SEOApp.initialize();
    liligo.addScript(config.ajaxHPsrc);
    var interval = setInterval(function(){
        if (liligo.hp) {
            clearInterval(interval);
            liligo.hp.formHtmls[window.config.form] = $("searchbox").innerHTML;
            //so that we can catch subcategory clicks
            new liligo.hp.formEventTracker("searchbox");
        }
    }, 100)
    
});
    
//# copy urls from buffer (noindex nofollow request)
var FooterNofollow = new Class({
    constructor: function(target){
        if (!(this.target = $(target))) 
            return false;
        var match;
        
        forEach($$("a[class]", this.target), function(link){
            if ((match = link.className.match(/url:([^ ]*)/)) && (match[1])) {
                link.href = match[1];
                link.className = link.className.replace(/url:[^ ]*/, "");
            }
        });
    }
    
});  





/*
 * Included file end: /seo/v3/common/js/full.js
 * Included from:     /seo/v3/common/js/_main_air.js:6
 */

	
})()
    

/*
 * Included file begin: /seo/v3/common/js/_main_common.js
 * Included from:       /seo/v3/common/js/_main_air.js:10
 */
function buzzrelaunch(i, outdate, retdate){
	document.getElementById("searchid").value = i;
	
	if ((outdate) && (retdate)) {
		document.getElementById("relform_outdate").value = outdate;
		document.getElementById("relform_retdate").value = retdate;
	}
	
	var relForm = document.getElementsByName('relaunch')[0];
	relForm.action = ((window.config && window.config.flightUrl) ? window.config.flightUrl : "") + "/air/callbackSearch.jsp?buzz=true";
	relForm.submit();
}


function carSearch(i){
	document.getElementById("searchid").value = i;
	
	var relForm = document.getElementsByName('relaunch')[0];
	relForm.action = ((window.config && window.config.carUrl) ? window.config.carUrl : "") + "/cars/sc.jsp";
	relForm.submit();
}


function redirectLink(json){
	var linkParams = eval(json);
	var queryParams = linkParams.query.split("&");
	var form = document.getElementById("redirectForm");

	form.innerHTML = "";
	form.action = linkParams.server + linkParams.url;
	
	for (var i=0;i<queryParams.length;i++) {
		var pair = queryParams[i].split("=");
		var input = document.createElement('input');		
		input.type = "hidden";
		input.name = pair[0];
		input.value = pair[1];
		form.appendChild(input);
	}

	form.submit();
	return false;				
}
/*
 * Included file end: /seo/v3/common/js/_main_common.js
 * Included from:     /seo/v3/common/js/_main_air.js:10
 */



