var tempX = 0;
var tempY = 0;
var roomDivId="";
var iWidth=0;
var iHeight=0;
var isLoadPage=false; 
var newTrId=1;
var headReFreshTime=5000;
var headNumber=-1;
var maxNumber=0;
var setTopMenuOfferTimeOut;
var hiddenImgDivs = new Array();
var loadTopMenuTimeOut;
var loadTopMenuTimeStep = 60;
var loadTopMenuTimeStepUserActive = 30;
var fadeEnabled = true;
var quickSearchUserActionTimeOut;
var quickSearchUserActionDelay = 200;
var quickSearchPage = 1;
var pageCount = 1;
var checkedCountryId = 0;
var trBackGroundDark = true;

var citSlideTemplateHtml = 
	'<table><tbody>' +
		'<tr><td><div class="cit_slide_img_container" id="cit_slide_img_container">' +
			'<table cellspacing="0" cellpadding="0"><tbody>' +
				'<tr><td class="cit_slide_border_top_left"></td><td class="cit_slide_border_top_middle"></td><td class="cit_slide_border_top_right"></td></tr>' +
				'<tr><td class="cit_slide_border_middle_left"></td>' +
					'<td class="cit_slide_border_middle_middle"><img src="" alt="" id="cit_slide_main_img" class="cit_slide_main_img" /><div style="display: none;" class="cit_slide_contant_container" id="cit_slide_contant_container"></div></td>' +
				'<td class="cit_slide_border_middle_right"></td></tr>' +
				'<tr><td class="cit_slide_border_middle_left"></td>' +
					'<td class="cit_slide_border_middle_middle"><div class="cit_slide_img_title_container" id="cit_slide_img_title_container"></div></td>' +
				'<td class="cit_slide_border_middle_right"></td></tr>' +
				'<tr><td class="cit_slide_border_bottom_left"></td><td class="cit_slide_border_bottom_middle"></td><td class="cit_slide_border_bottom_right"></td></tr>' +
			'</tbody></table>' +
			'<table class="cit_slide_bottom_button_container" cellspacing="0" cellpadding="0" id="cit_slide_bottom_button_container"><tbody><tr>' +
				'<td class="cit_slide_bottom_button_c_left"></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_prev" id="cit_slide_arrow_link_prev"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_play" id="cit_slide_arrow_link_play"></a><a class="cit_slide_arrow_link_pause" id="cit_slide_arrow_link_pause"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><div class="picture_position"><span id="cit_slide_info_container_act_img"></span> / <span id="cit_slide_info_container_sum_img"></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_next" id="cit_slide_arrow_link_next"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_close_link" id="cit_slide_close_link"></a></td>' +
				'<td class="cit_slide_bottom_button_c_right"></td>' +
			'</tr></tbody></table>' +
		'</div>' +
		'<div id="cit_slide_loading_div">' +
			'<table cellspacing="0" cellpadding="0" class="cit_slide_loading_opacity"><tbody><tr>' +
				'<td class="cit_slide_bottom_button_c_left"></td>' +
				'<td class="cit_slide_bottom_button_white">' +
					'<div class="cit_slide_loading_div">' +
					'</div>' +
				'</td>' +
				'<td class="cit_slide_bottom_button_c_right"></td>' +
			'</tr></tbody></table>' +
		'</div>' +
		'</td></tr>' +
	'</tbody></table>';

var citSlideTemplateHtmlHeightDiff = 75;
var citSlideImgTitleHide = false;

var isIE=false;
var isIE6=false;
var isIE8=false;

if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
 var ieversion=new Number(RegExp.$1);
 if (ieversion>=6) isIE=true;
 if (ieversion>=6 &&ieversion<7) isIE6=true;
 if (ieversion>=8 &&ieversion<9) isIE8=true;
}

if (!isIE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

function openPrintableVersion(){
	document.getElementById('offer_print_form').submit();
}

function change_menu(id){
	for (var i=1;i<=4;i++){
		if (document.getElementById('right_head_button'+i)!=null){
			if (i==id) {
				document.getElementById('right_head'+i).style.display='inline';
				document.getElementById('right_head_button'+i).className='right_head_button' + i + '_on';
			} else {
				document.getElementById('right_head'+i).style.display='none';
				document.getElementById('right_head_button'+i).className='right_head_button' + i;
			}
		}
		if (id==1){
			document.getElementById('banner_left').style.display='';
			document.getElementById('banner_right').style.display='';
			fadeEnabled = true;
		} else {
			document.getElementById('banner_left').style.display='none';
			document.getElementById('banner_right').style.display='none';
			fadeEnabled = false;
		}
	}
}

function copyData(){
	if (document.getElementById('offer_request_form_container') != null &&
		document.getElementById('offer_request_form_container_seo') != null) {
		var x = document.getElementById('offer_request_form_container_seo').childNodes;
		document.getElementById('offer_request_form_container').innerHTML = '';
		while (x.length>0){
			document.getElementById('offer_request_form_container').appendChild(x[0]);
		}
	}
}

function travel_onload(){
	isLoadPage=true;
	
	if (document.getElementById('offer_request_form_container')!=null) {
		copyData();
	}
	
	if (document.getElementById('right_head_button1')!=null) {
		document.getElementById('right_head_button1').onclick=function(){
			change_menu(1);
		};
	}
	
	if (document.getElementById('right_head_button2')!=null) {
		document.getElementById('right_head_button2').onclick=function(){
			change_menu(2);
		};
	}
	
	if (document.getElementById('right_head_button3')!=null) {
		document.getElementById('right_head_button3').onclick=function(){
			change_menu(3);
		};
	}
	
	if (document.getElementById('right_head_button4')!=null) {
		document.getElementById('right_head_button4').onclick=function(){
			change_menu(4);
		};
	}
	
	if (document.getElementById('cal_add_button')!=null) {
		document.getElementById('cal_add_button').onclick=function(){
			addNewCalculatorRow();
		};
	}
	
	if (document.getElementById('cal_db')!=null) {
		document.getElementById('cal_db').onkeypress=function(event){
			return onlynumbers(event,this);
		};
	}
	
	if (document.getElementById('cornerright')!=null) {
		if (isIE6){
			document.getElementById('cornerright').style.right="1px";
		}
	}
	
	if (document.getElementById('cal_age')!=null) {
		document.getElementById('cal_age').onchange=function(){
			setCalculatorType();
		};
	}
	
	if (document.getElementById('cal_season')!=null) {
		document.getElementById('cal_season').onchange=function(){
			setCalculatorType();
		};
	}

	if (document.getElementById('userDataClickA')!=null) {
		document.getElementById('userDataClickA').onclick=function(){
			setUserData();
		};	
	}

	if (document.getElementById('cal_type')!=null) {
		setCalculatorType();	
	}
	
	if (document.getElementById('qs_skiing')!=null) {
		document.getElementById('qs_skiing').onclick=function(){
			quickSearchPage = 1;
			unCheckStep1Divs();
			divChangeCheck(this);
			showSecondQuickLayer();
		};		
	}
	
	if (document.getElementById('qs_seas')!=null) {
		document.getElementById('qs_seas').onclick=function(){
			quickSearchPage = 1;
			unCheckStep1Divs();
			divChangeCheck(this);
			showSecondQuickLayer();
		};		
	}
	
	if (document.getElementById('qs_mountains')!=null) {
		document.getElementById('qs_mountains').onclick=function(){
			quickSearchPage = 1;
			unCheckStep1Divs();
			divChangeCheck(this);
			showSecondQuickLayer();
		};		
	}
	
	if (document.getElementById('qs_city')!=null) {
		document.getElementById('qs_city').onclick=function(){
			quickSearchPage = 1;
			unCheckStep1Divs();
			divChangeCheck(this);
			showSecondQuickLayer();
		};		
	}
	
	if (document.getElementById('qs_hotel_45')!=null) {
		document.getElementById('qs_hotel_45').onclick=function(){
			quickSearchPage = 1;
			unCheckStep2Divs();
			divChangeCheck(this);
			clearTimeout(quickSearchUserActionTimeOut);
			quickSearchUserActionTimeOut = setTimeout('showThirdQuickLayer();',quickSearchUserActionDelay);
		};		
	}
	
	if (document.getElementById('qs_hotel_23')!=null) {
		document.getElementById('qs_hotel_23').onclick=function(){
			quickSearchPage = 1;
			unCheckStep2Divs();
			divChangeCheck(this);
			clearTimeout(quickSearchUserActionTimeOut);
			quickSearchUserActionTimeOut = setTimeout('showThirdQuickLayer();',quickSearchUserActionDelay);
		};		
	}
	
	if (document.getElementById('qs_apartman')!=null) {
		document.getElementById('qs_apartman').onclick=function(){
			quickSearchPage = 1;
			unCheckStep2Divs();
			divChangeCheck(this);
			clearTimeout(quickSearchUserActionTimeOut);
			quickSearchUserActionTimeOut = setTimeout('showThirdQuickLayer();',quickSearchUserActionDelay);
		};		
	}
	
	if (document.getElementById('qs_for_groups')!=null) {
		document.getElementById('qs_for_groups').onclick=function(){
			quickSearchPage = 1;
			unCheckStep2Divs();
			divChangeCheck(this);
			clearTimeout(quickSearchUserActionTimeOut);
			quickSearchUserActionTimeOut = setTimeout('showThirdQuickLayer();',quickSearchUserActionDelay);
		};		
	}
	
	if (document.getElementById('qs_advanced_search_button')!=null) {
		document.getElementById('qs_advanced_search_button').onclick=function(){
			quickSearchPage = 1;
			divChangeCheck(this);
			showFourQuickLayer();
		};		
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_track_lodging')!=null) {
			document.getElementById('qs' + i +'_track_lodging').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_ski_bus')!=null) {
			document.getElementById('qs' + i +'_ski_bus').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_hungarian_trainer')!=null) {
			document.getElementById('qs' + i +'_hungarian_trainer').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_family_friendly_ski')!=null) {
			document.getElementById('qs' + i +'_family_friendly_ski').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_ski_over_70km')!=null) {
			document.getElementById('qs' + i +'_ski_over_70km').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_close_to_shore')!=null) {
			document.getElementById('qs' + i +'_close_to_shore').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_air_conditioner')!=null) {
			document.getElementById('qs' + i +'_air_conditioner').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_sandy_shore')!=null) {
			document.getElementById('qs' + i +'_sandy_shore').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_bicycle_storage')!=null) {
			document.getElementById('qs' + i +'_bicycle_storage').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};		
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_over_1000m')!=null) {
			document.getElementById('qs' + i +'_over_1000m').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_biker_friendly')!=null) {
			document.getElementById('qs' + i +'_biker_friendly').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_close_to_water')!=null) {
			document.getElementById('qs' + i +'_close_to_water').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_family_friendly')!=null) {
			document.getElementById('qs' + i +'_family_friendly').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_sport')!=null) {
			document.getElementById('qs' + i +'_sport').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_child_discount')!=null) {
			document.getElementById('qs' + i +'_child_discount').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_unobstructed')!=null) {
			document.getElementById('qs' + i +'_unobstructed').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_travel_by_bus')!=null) {
			document.getElementById('qs' + i +'_travel_by_bus').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_travel_by_plane')!=null) {
			document.getElementById('qs' + i +'_travel_by_plane').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_pet_friendly')!=null) {
			document.getElementById('qs' + i +'_pet_friendly').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_all_inclusive')!=null) {
			document.getElementById('qs' + i +'_all_inclusive').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_wellness')!=null) {
			document.getElementById('qs' + i +'_wellness').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_max_600km_from_bp')!=null) {
			document.getElementById('qs' + i +'_max_600km_from_bp').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_max_800km_from_bp')!=null) {
			document.getElementById('qs' + i +'_max_800km_from_bp').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_conference_room')!=null) {
			document.getElementById('qs' + i +'_conference_room').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_internet')!=null) {
			document.getElementById('qs' + i +'_internet').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_car_parking')!=null) {
			document.getElementById('qs' + i +'_car_parking').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_close_to_central')!=null) {
			document.getElementById('qs' + i +'_close_to_central').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_for_groups')!=null) {
			document.getElementById('qs' + i +'_for_groups').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}

	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_senior_discount')!=null) {
			document.getElementById('qs' + i +'_senior_discount').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
	
	for (var i=1;i<=4;i++){
		if (document.getElementById('qs' + i +'_travel_by_train')!=null) {
			document.getElementById('qs' + i +'_travel_by_train').onclick=function(){
				quickSearchPage = 1;
				divChangeCheck(this);
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			};	
		}
	}
}

function searchReloadPage(pageNumber) {
	if (!pageNumber) {
		pageNumber = 1;
	}
	document.getElementById('pagenumber').value = pageNumber;
	document.getElementById('hidden_search_form').submit();
}

function indexReloadPage(pageNumber) {
	if (!pageNumber) {
		pageNumber = 1;
	}
	var page = document.location.href;
	if (page.search("#")!=-1){
		var tmp=page.split("#");
		page=tmp[0];
	}
	page = page.replace(/#/g, "");
	if (page.indexOf('pagenumber=') != -1) {
		page = page.replace(/pagenumber=[0-9]*/, 'pagenumber=' + pageNumber);
	} else {
		if (page.indexOf('?') != -1) {
			page += '&pagenumber=' + pageNumber;
		} else {
			page += '?pagenumber=' + pageNumber;
		}
	}
	document.location.href = page + "#offers";
}

function changeMonth(actIndex) {
	var start_month = parseInt(document.getElementById('start_month').value, 10);
	for (var i = start_month; i < start_month + 10; i++) {
		var index = i % 12;
		index = 0 == index ? 12 : index;
		if (index == actIndex) {
			document.getElementById('monthtd_' + index).className='cjfw_travel_offer_month_active';
			document.getElementById('daystable_' + index).style.display = '';
		} else {
			document.getElementById('monthtd_' + index).className='cjfw_travel_offer_month';
			document.getElementById('daystable_' + index).style.display = 'none';
		}
	}
}

function showRoomData(id,data){
	var roomDiv=document.createElement("div");
	roomDiv.style.border="1px solid #777777";
	roomDiv.style.background="white";
	roomDiv.style.position="absolute";
	roomDiv.style.width="150px";
	roomDiv.style.height="50px";
	roomDiv.style.padding = "5px";
	roomDiv.style.fontFamily = "Tahoma";
	roomDiv.style.fontSize = "12px";
	roomDiv.style.color = "#585858";
	roomDiv.id=id;
	roomDivId=id;
	setRoomDataDivPosition(tempY,tempX);
	roomDiv.innerHTML=data;
	document.getElementsByTagName('body')[0].appendChild(roomDiv);
}

function delRoomData(id){
	if (document.getElementById(id)!=null) 
		document.getElementById(id).parentNode.removeChild(document.getElementById(id));
}

function getMouseXY(e) {
	if (isIE) {
		/*tempX = window.event.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
		tempY = window.event.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);*/
	} else {  
		tempX = e.pageX;
		tempY = e.pageY;
	}  

	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}
	setRoomDataDivPosition(tempY,tempX);
	return true;
}

function setRoomDataDivPosition(top,left){
	if (isLoadPage){
		if (document.getElementById(roomDivId)!=null){
			var sTop=(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop);
			var sLeft=(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
			if (isIE){
				iWidth=document.documentElement.clientWidth;
				iHeight=document.documentElement.clientHeight;	
			}
			else{
				iWidth=window.innerWidth-20;
				iHeight=window.innerHeight-20;
			}
			var divHeight=document.getElementById(roomDivId).clientHeight;
			var divWidth=document.getElementById(roomDivId).clientWidth;
			var maxH=sTop+iHeight-divHeight-20;
			if (isIE) maxH=maxH-20;	
			if (maxH<=top)
				top=top-40-divHeight;
			var maxW=sLeft+iWidth-divWidth-20;
			if (isIE) maxW=maxW-7;	
			if (maxW<=left)
				left=maxW;
			
			document.getElementById(roomDivId).style.top=(top+20)+"px";
			document.getElementById(roomDivId).style.left=(left+20)+"px";
		}	
	}
}

function validateEmail(domain) {
	var working = document.getElementById('newsletter_working');
	var repeat = document.getElementById('newsletter_already_subscribed');
	var fail = document.getElementById('newsletter_bad_email_format');
	var fail_mx = document.getElementById('newsletter_invalid_mx');

	var visible = "display:block; color:yellow;";
	var hidden = "display:none;";

	working.style.cssText = visible;
	repeat.style.cssText = hidden;
	fail.style.cssText = hidden;
	fail_mx.style.cssText = hidden;

	var email = document.getElementById("newsletter").value;
	var xml = executeSyncronRequest("/Ajax/SubscribeNewsletter?email="+email+(domain != null ? '&siberlet=1' : ''));
	var status = xml.getElementsByTagName('status').item(0).firstChild.data;

	if ("OK" == status) {
		top.location.href = (domain != null ? domain : '') + "/hirlevel?action=sent"+(domain != null ? '&siberlet=1' : '');
	}
	if ("ALREADY_SUBSCRIBED" == status) {
		working.style.cssText = hidden;
		repeat.style.cssText = visible;
		fail_mx.style.cssText = hidden;
	}
	if ("BAD_EMAIL" == status) {
		working.style.cssText = hidden;
		fail.style.cssText = visible;
		fail_mx.style.cssText = hidden;
	}
	if ("INVALID_MX" == status) {
		working.style.cssText = hidden;
		repeat.style.cssText = hidden;
		fail.style.cssText = hidden;
		fail_mx.style.cssText = visible;
	}
	 
}

function unSubscribe(domain) {
	var working = document.getElementById('newsletter_working');
	var fail = document.getElementById('newsletter_bad_email_format');

	var visible = "display:block; color:yellow;";
	var hidden = "display:none;";

	working.style.cssText = visible;
	fail.style.cssText = hidden;

	var email = document.getElementById("newsletter").value;
	var xml = executeSyncronRequest("/Ajax/CheckEmail?mail="+email);
	var status = xml.getElementsByTagName('result').item(0).firstChild.data;

	if ("OK" == status) {
		xml = executeSyncronRequest("/Ajax/UnSubscribeNewsletter?mail="+email+(domain != null ? '&siberlet=1' : ''));
		top.location.href = (domain != null ? domain : '') + "/leiratkozas?action=sent"+(domain != null ? '&siberlet=1' : '');
	}
	if ("WRONG" == status) {
		working.style.cssText = hidden;
		fail.style.cssText = visible;
	}
}

function subscribeNewsletter(e,domain){
	var key=window.event?window.event.keyCode:e.which;
	if(key==13){
		validateEmail(domain);
	}
}

function loadlink(link){
	window.location = link;
}

function removeTr(id){
	id.parentNode.parentNode.parentNode.removeChild(id.parentNode.parentNode);
	if (document.getElementById("cal_newSumTd")!=null)
		document.getElementById("cal_newSumTd").innerHTML=getCalSum();
}

function getCalSum(){
	var sum = 0;
	var resultSum = 0;
	rowNumber = 0;
	for (var i=1;i<=500;i++){
		if (document.getElementById("cal_newTd_"+i) != null){
			resultSum = resultSum + Math.ceil(document.getElementById("cal_hidden_result_"+i).value);
			sum = parseInt(sum)+parseInt(document.getElementById("cal_newTd_"+i).innerHTML.replace(/[^0-9,\.\-]/g, ""));
			rowNumber++;
		}
	}
	if (rowNumber == 0){
		removeSumRow();
		document.getElementById("cal_submit_button").style.display = "none";
		document.getElementById("cal_form_div").style.display = "none";
		document.getElementById("cal_form_div_error").style.display = "none";
	}
	else{ 
		document.getElementById("cal_submit_button").style.display = "";
	}
	var isEuro = true;
	if (document.getElementById("iseuro") != null){
		if (document.getElementById("iseuro").value == 0) 
			isEuro = false;
	}
	sum = Math.round(sum * 100) / 100;
	if (isEuro){
		return sum + " €";
	} else {
		return sum + " Ft";
	}
}

function getNumberFormat(number){
	number = number.toString(); 
	var returnNumber = '';
	var i = number.length;
	while (0 < i - 3) {
		returnNumber = '&nbsp;' + number.substring(i - 3, i) + returnNumber;
		i -= 3;
	}
	returnNumber = number.substring(0, i) + returnNumber;
	return returnNumber;
}

function removeSumRow(){
	if (document.getElementById("cal_newSumTr")!=null){
		document.getElementById("cal_newSumTr").parentNode.removeChild(document.getElementById("cal_newSumTr"));
	}
}

function addNewCalculatorRow(){
	if (document.getElementById('cal_type').options[document.getElementById('cal_type').selectedIndex].value!=-1 && document.getElementById('cal_db').value!=''){
		var isEuro = true;
		if (document.getElementById("iseuro") != null){
			if (document.getElementById("iseuro").value == 0) 
				isEuro = false;
		}
		
		var table=document.getElementById("cal_table_tbody");
		var newTr=document.createElement("TR");
		var newTd1=document.createElement("TD");
		var newTd2=document.createElement("TD");
		var newTd3=document.createElement("TD");
		var newTd4=document.createElement("TD");
		var newTd5=document.createElement("TD");
		var resultHiddenInput=document.createElement("INPUT");
		
		newTr.appendChild(newTd1);
		newTr.appendChild(newTd2);
		newTr.appendChild(newTd3);
		newTr.appendChild(newTd4);
		newTr.appendChild(newTd5);
		table.appendChild(newTr);
		
		newTr.id="cal_newTr_"+newTrId;
		newTd1.innerHTML=document.getElementById('resort_price_table_menu_' + document.getElementById('cal_season').options[document.getElementById('cal_season').selectedIndex].value).getElementsByTagName('a')[0].innerHTML;
		newTd1.id="cal_Td_s_"+newTrId;
		newTd1.style.borderBottom = 'none';
		newTd1.style.borderLeft = '1px solid #CCCCCC';
		newTd2.innerHTML=document.getElementById('cal_age').options[document.getElementById('cal_age').selectedIndex].text;
		newTd2.id="cal_Td_a_"+newTrId;
		newTd2.style.borderBottom = 'none';
		newTd3.innerHTML=document.getElementById('cal_type').options[document.getElementById('cal_type').selectedIndex].text;
		newTd3.id="cal_Td_t_"+newTrId;
		newTd3.style.borderBottom = 'none';
		newTd4.innerHTML=document.getElementById('cal_db').value + document.getElementById('loc_cal_db_unit').value;
		newTd4.id="cal_Td_d_"+newTrId;
		newTd4.style.borderBottom = 'none';
		newTd5.id="cal_newTd_"+newTrId;
		newTd5.style.borderBottom = 'none';
		if (trBackGroundDark){
			newTd1.style.background = '#F7F7F7';
			newTd2.style.background = '#F7F7F7';
			newTd3.style.background = '#F7F7F7';
			newTd4.style.background = '#F7F7F7';
			newTd5.style.background = '#F7F7F7';
			trBackGroundDark = false;
		} else {
			trBackGroundDark = true;
		}
		
		var xml = executeSyncronRequest("/Ajax/ResortPrice?resortid="+document.getElementById('resortid').value+"&season="+document.getElementById('cal_season').options[document.getElementById('cal_season').selectedIndex].value+"&age="+document.getElementById('cal_age').options[document.getElementById('cal_age').selectedIndex].value+"&type="+document.getElementById('cal_type').options[document.getElementById('cal_type').selectedIndex].value+"&db="+document.getElementById('cal_db').value);
		var result=xml.getElementsByTagName('result')[0].firstChild.nodeValue;
		newTd5.innerHTML=result + (isEuro?' €':' Ft');
		
		var xml2 = executeSyncronRequest("/Ajax/ChangePrice?price="+stringToUrl(result/Math.ceil(document.getElementById('cal_db').value)));
		var result2 = xml2.getElementsByTagName('result')[0].firstChild.nodeValue;
		
		resultHiddenInput.type = 'hidden';
		resultHiddenInput.id='cal_hidden_result_'+newTrId;
		resultHiddenInput.value = parseFloat(result2.replace(/[^0-9,\.\-]/g, "")) * parseInt(document.getElementById('cal_db').value);

		removeSumRow();
		var newSumTr=document.createElement("TR");
		var newSumTd1=document.createElement("TD");
		var newSumTd2=document.createElement("TD");
		
		newSumTr.appendChild(newSumTd1);
		newSumTr.appendChild(newSumTd2);
		table.appendChild(newSumTr);
		newTd1.appendChild(resultHiddenInput);
		
		newSumTr.id = "cal_newSumTr";
		newSumTd1.colSpan = 4;
		newSumTd1.innerHTML = document.getElementById('loc_sum').value;
		newSumTd1.style.borderRight = 'none';
		newSumTd1.style.borderBottom = 'none';
		newSumTd1.style.textAlign = 'right';
		newSumTd1.style.fontWeight = 'bold';
		newSumTd1.style.fontSize = '12px';
		newSumTd1.style.paddingTop = '5px';
		newSumTd1.style.verticalAlign = 'bottom';
		newSumTd2.id = "cal_newSumTd";
		newSumTd2.innerHTML = getCalSum();
		newSumTd2.style.borderRight = 'none';
		newSumTd2.style.borderBottom = 'none';
		newSumTd2.style.fontWeight = 'bold';
		newSumTd2.style.fontSize = '16px';
		newSumTd2.style.paddingTop = '5px';
		newSumTd2.style.verticalAlign = 'bottom';
		newTrId++;
	}
}

function setUserData(){
	if (document.getElementById("cal_form_div")!=null) {
		document.getElementById("cal_form_div").style.display="";
		travel_offer_cal_setup();
	}
}

function onlynumbers(e,id){
	 var key=window.event?window.event.keyCode:e.which;
	 if (key==46)
		return true;
	 if (key==44)
		return true;
	 if (key<40 && key!=32)
		 return true;
	 var value=String.fromCharCode(key);
	 var ret=(/^(?:\d+\.){0,2}\d*$/).test(value);
	 return ret;
}


function change_price_table_season(id){
	for (var i=0;i<3;i++){
		if (i==id) {
			document.getElementById('resort_price_table_'+i).style.display='';
			document.getElementById('resort_price_table_menu_'+i).className='active_menu';
		} else {
			document.getElementById('resort_price_table_'+i).style.display='none';
			document.getElementById('resort_price_table_menu_'+i).className='menu';
		}
	}
}

function stringToUrl(string) {
	return encodeURIComponent(string); 
}

function checkEmail(){
	var returnValue=false;
	var xml = executeSyncronRequest("/Ajax/CheckEmail?mail="+stringToUrl(document.getElementById('cal_email').value));
	var result=xml.getElementsByTagName('result')[0].firstChild.nodeValue;
	if (result=="OK") returnValue=true;
	return returnValue;	
}

function checkPhone(){
	var returnValue=false;
	var xml = executeSyncronRequest("/Ajax/CheckPhone?phone="+stringToUrl(document.getElementById('cal_phone').value));
	var result=xml.getElementsByTagName('result')[0].firstChild.nodeValue;
	if (result=="OK") returnValue=true;
	return returnValue;	
}

function colorInputError(element, isError) {
	if (isError) {
		element.style.backgroundColor="#CC3333";
		element.style.color="white";
	} else {
		element.style.backgroundColor="white";
		element.style.color="black";
	}
}

function checkUserData(){
	var returnValue=true;
	if (document.getElementById('cal_name').value==""){
		colorInputError(document.getElementById('cal_name'), true);
		returnValue=false;
	}else{
		colorInputError(document.getElementById('cal_name'), false);
	}
	if (document.getElementById('cal_address').value==""){
		colorInputError(document.getElementById('cal_address'), true);
		returnValue=false;
	}else{
		colorInputError(document.getElementById('cal_address'), false);
	}
	if (document.getElementById('cal_first_day').value==""){
		colorInputError(document.getElementById('cal_first_day'), true);
		returnValue=false;
	}else{
		colorInputError(document.getElementById('cal_first_day'), false);
	}
	if (!checkEmail()){
		colorInputError(document.getElementById('cal_email'), true);
		returnValue=false;
	}else{
		colorInputError(document.getElementById('cal_email'), false);
	}
	if (!checkPhone()){
		colorInputError(document.getElementById('cal_phone'), true);
		returnValue=false;
	}else{
		colorInputError(document.getElementById('cal_phone'), false);
	}
	return returnValue;
}

function sendUserPriceTable(domain){
	if (checkUserData()){
		if (document.getElementById("cal_form_div_error")!=null)
			document.getElementById("cal_form_div_error").style.display="none";
		var id=document.getElementById('cal_resort_id').value;
		var name=document.getElementById('cal_name').value;
		var email=document.getElementById('cal_email').value;
		var phone=document.getElementById('cal_phone').value;
		var address=document.getElementById('cal_address').value;
		var firstDay=document.getElementById('cal_first_day').value;
		var receiveBy=document.getElementById('cal_receive_by').value;
		var prices="<table cellpadding=\"0\" cellspacing=\"0\">";
		prices+="<tr>";
		prices+="<th>Időszak</th><th>Típus</th><th>Bérlet (nap)</th><th>Darab</th><th>Ár</th>";
		prices+="</tr>";
		for (var i=1;i<=500;i++){
			if (document.getElementById("cal_newTd_"+i)!=null){
				prices+="<tr>";
				prices+="<td>"+document.getElementById("cal_Td_s_"+i).innerHTML+"</td>";
				prices+="<td>"+document.getElementById("cal_Td_a_"+i).innerHTML+"</td>";
				prices+="<td>"+document.getElementById("cal_Td_t_"+i).innerHTML+"</td>";
				prices+="<td>"+document.getElementById("cal_Td_d_"+i).innerHTML+"</td>";
				prices+="<td>"+document.getElementById("cal_newTd_"+i).innerHTML+"</td>";
				prices+="</tr>";
			}
		}
		prices+="</table>";
		name=stringToUrl(name);
		address=stringToUrl(address);
		email=stringToUrl(email);
		phone=stringToUrl(phone);
		prices=stringToUrl(prices);
		var xml = executeSyncronRequestPost("/Ajax/SendPrices", "id=" + id
				+ "&mail=" + email + "&address=" + address + "&receive_by="
				+ receiveBy + "&first_day=" + firstDay + "&name=" + name
				+ "&phone=" + phone + "&prices=" + prices
				+ (domain != null ? "&resort=1" : ""));
		var result=xml.getElementsByTagName('result')[0].firstChild.nodeValue;
		if (result=="OK"){
			if (domain != null)
				window.location="/ajanlat_elkuldve";
			else
				window.location="/ajanlatkeres/elkuldve";
		}
		
		else alert(document.getElementById("loc_try_later").value);
	}else{
		if (document.getElementById("cal_form_div_error")!=null)
			document.getElementById("cal_form_div_error").style.display="";
	}
}

function setCalculatorType(){
	var calType = document.getElementById("cal_type");
	var season=document.getElementById("cal_season").options[document.getElementById("cal_season").selectedIndex].value;
	var age=document.getElementById("cal_age").options[document.getElementById("cal_age").selectedIndex].value;
	
	var calTypeSelect = calType.value;
	while (calType.length > 0)
		calType.remove(0);

	calType.disabled = true;
	var xml = executeSyncronRequest("/Ajax/SetCalType?season="+season+"&age="+age+"&resortid="+document.getElementById('resortid').value);
	
	for(var i = 0; i < xml.documentElement.childNodes.length; i++)
	{
		var obj = xml.documentElement.childNodes[i];
		var id = obj.getAttribute("id");
		var option;
		if (obj.firstChild!=null){
			option = new Option(obj.firstChild.data + (obj.firstChild.data != '-'?document.getElementById('loc_cal_type_unit').value:''), id);
			calType.options[i] = option;
			if (id == calTypeSelect) {
				calType.options[i].selected = true;
			}
		}
	}
	calType.disabled=false;
}

function loadoffer(link){
	var extension = link.indexOf('?') != -1 ? '&discount=1' : '?discount=1'; 
	window.location = link + extension;
}

function showHead1(percent,user){
	clearTimeout(loadTopMenuTimeOut);
	if (!fadeEnabled) {
		percent = 100;
	}
	if (percent<1){
		var i;
		if (isIE){
			if (isIE8 || isIE6){
				var x = document.getElementById('right_head1_load').childNodes;
				var i;
				for (i=0;i<x.length;i++){
					if (x[i].className!='front')
						x[i].style.filter='alpha(opacity=' + Math.ceil(percent*100) + ')';
				}
			} else {
				document.getElementById('right_head1_load').style.filter='alpha(opacity=' + Math.ceil(percent*100) + ')';
			}
		} else {
			document.getElementById('right_head1_load').style.opacity=percent;
		}
		loadTopMenuTimeOut = setTimeout('showHead1(\''+(Math.ceil(percent*100+5)/100)+'\',' + (user?'true':'false') + ');',(user?loadTopMenuTimeStepUserActive:loadTopMenuTimeStep));
	} else {
		if (isIE8 || isIE6){
			var x = document.getElementById('right_head1_load').childNodes;
			var i;
			for (i=0;i<x.length;i++){
				if (x[i].className!='front')
					x[i].style.filter='alpha(opacity=100)';
			}
		}
		var x = document.getElementById("right_head1_load").childNodes;
		document.getElementById("right_head1").innerHTML = '';
		while (x.length>0){
			document.getElementById("right_head1").appendChild(x[0]);
		}
		document.getElementById("right_head1_load").parentNode.removeChild(document.getElementById("right_head1_load"));
	}
	if (!fadeEnabled) {
		clearTimeout(loadTopMenuTimeOut);
	}
}

function loadTopOffer(isResort,user){
	if (!fadeEnabled) {
		return false;
	}
	xml = executeSyncronRequest("/Ajax/NextTopMenu"+(isResort?"?resort=1&number="+headNumber:"?number="+headNumber));
	result=xml.getElementsByTagName('result');
	if (result[0]!=undefined){
		var link="";var img="";var text="";
		if (result[0].firstChild!=null)
			img=result[0].firstChild.nodeValue;
		if (result[2].firstChild!=null)
			text=result[2].firstChild.nodeValue;
		if (result[1].firstChild!=null)
			link=result[1].firstChild.nodeValue;
		
		var imgHtml=document.createElement("img");
		imgHtml.src=img;
		imgHtml.className="main";
		var frontDiv=document.createElement("div");
		frontDiv.className="front";
		var textDiv=document.createElement("div");
		textDiv.className="text";
		textDiv.innerHTML=text;
		
		if (document.getElementById("right_head1_load")!=null)
			showHead1(2,user);
		var head1_load = document.createElement('div');
		head1_load.id='right_head1_load';
		if (img!="") 
			head1_load.appendChild(imgHtml);
		head1_load.appendChild(frontDiv);
		head1_load.appendChild(textDiv);
		if (link!=""){
			head1_load.style.cursor="pointer";
			document.getElementById('right_head1').onclick=function(){
				loadoffer(link);
			};
			head1_load.onclick=function(){
				loadoffer(link);
			};
		}else{
			head1_load.style.cursor="default";
			document.getElementById('right_head1').onclick=function(){
				return false;
			};
			head1_load.onclick=function(){
				return false;
			};
		}
		document.getElementById('right_head1').parentNode.appendChild(head1_load);
		showHead1(0.05,user);
	}
}

function setTopMenuOfferLeft(){
	var isResort=true;
	if (document.getElementById("right_head3"))
		isResort=false;
	clearTimeout(setTopMenuOfferTimeOut);
	if (headNumber==-1){
		var xml = executeSyncronRequest("/Ajax/TopMenuBannerNumber"+(isResort?"?resort=1":""));
		result=xml.getElementsByTagName('result');
		maxNumber=result[0].firstChild.nodeValue;
		headNumber=Math.floor(Math.random()*maxNumber);
	}
	
	headNumber=headNumber-1;
	if (headNumber>=maxNumber)
		headNumber=0;
	else if (headNumber<0)
		headNumber=(maxNumber-1>=0?maxNumber-1:0);
	
	loadTopOffer(isResort,true);
}

function setTopMenuOfferRight(){
	var isResort=true;
	if (document.getElementById("right_head3"))
		isResort=false;
	clearTimeout(setTopMenuOfferTimeOut);
	if (headNumber==-1){
		var xml = executeSyncronRequest("/Ajax/TopMenuBannerNumber"+(isResort?"?resort=1":""));
		result=xml.getElementsByTagName('result');
		maxNumber=result[0].firstChild.nodeValue;
		headNumber=Math.floor(Math.random()*maxNumber);
	}
	
	headNumber=headNumber+1;
	if (headNumber>=maxNumber)
		headNumber=0;
	else if (headNumber<0)
		headNumber=(maxNumber-1>=0?maxNumber-1:0);
	
	loadTopOffer(isResort,true);
}

function setTopMenuOfferOnLoad() {
	setTopMenuOfferTimeOut=setTimeout("setTopMenuOffer();",headReFreshTime);
}

function setTopMenuOffer(){
	var isResort=true;
	if (document.getElementById("right_head3"))
		isResort=false;
	if (headNumber==-1){
		var xml = executeSyncronRequest("/Ajax/TopMenuBannerNumber"+(isResort?"?resort=1":""));
		result=xml.getElementsByTagName('result');
		maxNumber=result[0].firstChild.nodeValue;
		headNumber=Math.floor(Math.random()*maxNumber);
	}
	headNumber=headNumber+1;
	if (headNumber>=maxNumber)
		headNumber=0;
	else if (headNumber<0)
		headNumber=maxNumber-1;
	
	loadTopOffer(isResort,false);

	setTopMenuOfferTimeOut=setTimeout("setTopMenuOffer();",headReFreshTime);
}

if (window.attachEvent) {
	window.attachEvent("onload", travel_onload);
} else{
	window.addEventListener("load", travel_onload, false);
}

function travel_offer_cal_setup() {
	Calendar.setup(
	{
		inputField  : "cal_first_day",
		ifFormat    : "%Y-%m-%d",
		button      : "cal_first_day",
		align		: null,
		showsTime   : false,
		weekNumbers : false
	}
	);
}

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

function showImgs(percent){
	if (percent<100){
		var i;
		for (i=0;i<hiddenImgDivs.length;i++){
			if (isIE){
				hiddenImgDivs[i].style.filter='alpha(opacity=' + Math.ceil(percent*100) + ')';
			} else {
				hiddenImgDivs[i].style.opacity=percent;
			}
		}
		setTimeout('showImgs(\''+(Math.ceil(percent*100+5)/100)+'\');',60);
	}
}

function showMorePicture(thisId){
	var imagesDiv = document.getElementsByTagName('div');
	var i,j,k;
	for (i=0;i<imagesDiv.length;i++){
		if (imagesDiv[i].className=='images'){
			var hiddenDivs = imagesDiv[i].getElementsByTagName('div');
			for (j=0;j<hiddenDivs.length;j++){
				if (hiddenDivs[j].className=='hidden-container'){
					if (isIE){
						var imgs = hiddenDivs[j].getElementsByTagName('img');
						for (k=0;k<imgs.length;k++){
							if (imgs[k].className!='front'){
								imgs[k].style.filter='alpha(opacity=1)';
								hiddenImgDivs.push(imgs[k]);
							}
						}
					} else {
						hiddenImgDivs.push(hiddenDivs[j]);
						hiddenDivs[j].style.opacity=0.01;
					}
					hiddenDivs[j].className = 'image';
				}
			}
		}
	}
	showImgs(0.05);
	thisId.parentNode.parentNode.removeChild(thisId.parentNode);
}

function divChangeCheck(element){
	if (element!=null){
		if (element.className != 'text qs_label_active')
			element.className = 'text qs_label_active';
		else
			element.className = 'text qs_label';
	}
}

function divChecked(element){
	if (element!=null){
		if (element.className == 'text qs_label_active')
			return true;
	}
	return false;
}

function showSecondQuickLayer(){
	var skiingChecked = divChecked(document.getElementById('qs_skiing'));
	var seasChecked = divChecked(document.getElementById('qs_seas'));
	var mountainsChecked = divChecked(document.getElementById('qs_mountains'));
	var cityChecked = divChecked(document.getElementById('qs_city'));
	if (skiingChecked || seasChecked || mountainsChecked || cityChecked){
		document.getElementById('qs_advanced_search_button').innerHTML = '';
		document.getElementById('qs_advanced_search_button').appendChild(getTableElement(localizationAdvancedSearch));
		if (divChecked(document.getElementById('qs_advanced_search_button')))
			divChangeCheck(document.getElementById('qs_advanced_search_button'));
		document.getElementById('qs_four_layer').style.display = 'none';
		document.getElementById('travel_container').style.display = 'none';
		unCheckStep4Divs();
		showThirdQuickLayer();
	} else {
		document.getElementById('travel_container').style.display = '';
		document.getElementById('qs_advanced_search_button').innerHTML = '';
		document.getElementById('qs_advanced_search_button').appendChild(getTableElement(localizationAdvancedSearch));
		if (divChecked(document.getElementById('qs_advanced_search_button')))
			divChangeCheck(document.getElementById('qs_advanced_search_button'));
		document.getElementById('qs_four_layer').style.display = 'none';
		unCheckStep4Divs();
		document.getElementById('qs_offers').innerHTML = '';
		document.getElementById('pageturn_container').innerHTML = '';
		checkedCountryId = 0;
	}
}

function getQuickSearchGreenDiv(last,side){
	var div = document.createElement('div');
	if (last)
		div.className = 'qs_label_'+side;
	else
		div.className = 'qs_label_'+side+'2';
	return div;
}

function unCheckStep1Divs(){
	if (divChecked(document.getElementById('qs_skiing')))
		divChangeCheck(document.getElementById('qs_skiing'));
	if (divChecked(document.getElementById('qs_seas')))
		divChangeCheck(document.getElementById('qs_seas'));
	if (divChecked(document.getElementById('qs_mountains')))
		divChangeCheck(document.getElementById('qs_mountains'));
	if (divChecked(document.getElementById('qs_city')))
		divChangeCheck(document.getElementById('qs_city'));
}

function unCheckStep2Divs(){
	if (divChecked(document.getElementById('qs_hotel_45')))
		divChangeCheck(document.getElementById('qs_hotel_45'));
	if (divChecked(document.getElementById('qs_hotel_23')))
		divChangeCheck(document.getElementById('qs_hotel_23'));
	if (divChecked(document.getElementById('qs_apartman')))
		divChangeCheck(document.getElementById('qs_apartman'));
	if (divChecked(document.getElementById('qs_for_groups')))
		divChangeCheck(document.getElementById('qs_for_groups'));
}

function unCheckCountriesDivs(){
	var divs = document.getElementById('qs_third_layer_inputs').getElementsByTagName('div');
	var i,j;
	for (i=0;i<divs.length;i++){
		if (divChecked(divs[i]))
			divChangeCheck(divs[i]);
	}
}

function unCheckStep4Divs(){
	var divs = document.getElementById('qs_four_layer').getElementsByTagName('div');
	var i,j;
	for (i=0;i<divs.length;i++){
		if (divChecked(divs[i]))
			divChangeCheck(divs[i]);
	}
}

function getTableElement(content){
	var table = document.createElement('table');
	var tbody = document.createElement('tbody');
	var tr = document.createElement('tr');
	var td = document.createElement('td');
	
	td.innerHTML = content;
	
	tr.appendChild(td);
	tbody.appendChild(tr);
	table.appendChild(tbody);
	return table;
}

function showThirdQuickLayer(){
	var numberOfElementRow = 4;
	var skiingChecked = divChecked(document.getElementById('qs_skiing'));
	var seasChecked = divChecked(document.getElementById('qs_seas'));
	var mountainsChecked = divChecked(document.getElementById('qs_mountains'));
	var cityChecked = divChecked(document.getElementById('qs_city'));
	var hotel45Checked = divChecked(document.getElementById('qs_hotel_45'));
	var hotel23Checked = divChecked(document.getElementById('qs_hotel_23'));
	var apartmanChecked = divChecked(document.getElementById('qs_apartman'));
	var forGroupsChecked = divChecked(document.getElementById('qs_for_groups'));
	if (hotel45Checked || hotel23Checked || apartmanChecked || forGroupsChecked){
		document.getElementById('qs_third_layer_inputs').innerHTML = '';
		var xml = executeSyncronRequest("/Ajax/GetQuickSearchCountries?skiing="+(skiingChecked?"1":"0")+"&seas="+(seasChecked?"1":"0")+"&mountains="+(mountainsChecked?"1":"0")+"&city="+(cityChecked?"1":"0")+"&hotel45="+(hotel45Checked?"1":"0")+"&hotel23="+(hotel23Checked?"1":"0")+"&apartman="+(apartmanChecked?"1":"0")+"&forgroups="+(forGroupsChecked?"1":"0"));
		if (xml != null) {
			var callSearch = false;
			if (xml.documentElement.childNodes.length==0){
				thirdQuickLayerNoResult();
				return;
			}
			if (xml.documentElement.childNodes.length==1){
				quickSearchPage = 1;
				callSearch = true;
				var obj = xml.documentElement.childNodes[0];
				var id = obj.getAttribute("id");
				checkedCountryId = id;
			}
			var i = 0;
			for (i = 0; i < xml.documentElement.childNodes.length; i++) {
				document.getElementById('qs_third_layer_no_result').style.display = 'none';
				document.getElementById('qs_third_layer_search_more').style.display = 'none';
				var lastRow = (xml.documentElement.childNodes.length-i <= (xml.documentElement.childNodes.length%numberOfElementRow==0?numberOfElementRow:xml.documentElement.childNodes.length%numberOfElementRow));
				if (i%numberOfElementRow == 0){
					document.getElementById('qs_third_layer_inputs').appendChild(getQuickSearchGreenDiv(lastRow,'left'));
				}
					
				var obj = xml.documentElement.childNodes[i];
				var id = obj.getAttribute("id");
				var name = obj.getAttribute("name");
				
				var country = document.createElement('div');
				
				country.id = 'qs_country_' + id;
				if (checkedCountryId == id){
					country.className = 'text qs_label_active';
					callSearch = true;
				} else {
					country.className = 'text qs_label';
				}
				country.onclick = function(){
					unCheckCountriesDivs();
					divChangeCheck(this);
					checkedCountryId = this.id.substr(11);
					quickSearchPage = 1;
					clearTimeout(quickSearchUserActionTimeOut);
					quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
				};
				country.appendChild(getTableElement(name));
				
				document.getElementById('qs_third_layer_inputs').appendChild(country);
				
				if (i%numberOfElementRow == 3){
					document.getElementById('qs_third_layer_inputs').appendChild(getQuickSearchGreenDiv(lastRow,'right'));
				}
			}
			var isNullDivs = false;
			if (xml.documentElement.childNodes.length%numberOfElementRow!=0){
				for (i = 0; i < numberOfElementRow-(xml.documentElement.childNodes.length%numberOfElementRow); i++) {
					isNullDivs = true;
					var nullDiv = document.createElement('div');
					nullDiv.className = 'qs_label no_pointer';
					document.getElementById('qs_third_layer_inputs').appendChild(nullDiv);
				}
			}
			if (isNullDivs)
				document.getElementById('qs_third_layer_inputs').appendChild(getQuickSearchGreenDiv(true,'right'));
			if (callSearch){
				clearTimeout(quickSearchUserActionTimeOut);
				quickSearchUserActionTimeOut = setTimeout('showOfferQuickLayer();',quickSearchUserActionDelay);
			} else {
				thirdQuickLayerNoResultWithCountries();
			}
		} else { 
			thirdQuickLayerNoResult();
		}
	} else {
		document.getElementById('qs_offers').innerHTML = '';
		document.getElementById('pageturn_container').innerHTML = '';
		checkedCountryId = 0;
	}
}

function thirdQuickLayerNoResult(){
	thirdQuickLayerNoResultWithCountries();
	document.getElementById('qs_third_layer_no_result').style.display = '';
	document.getElementById('qs_third_layer_search_more').style.display = 'none';
	document.getElementById('qs_no_offer_result').style.display = 'none';
}

function thirdQuickLayerNoResultWithCountries(){
	document.getElementById('qs_offers').innerHTML = '';
	document.getElementById('pageturn_container').innerHTML = '';
	document.getElementById('qs_successful').style.display = 'none';
	document.getElementById('qs_more_title_padding').style.display = 'none';
	document.getElementById('qs_four_layer').style.display = 'none';
	unCheckStep4Divs();
}

function showOfferQuickLayer(){
	var skiingChecked = divChecked(document.getElementById('qs_skiing'));
	var seasChecked = divChecked(document.getElementById('qs_seas'));
	var mountainsChecked = divChecked(document.getElementById('qs_mountains'));
	var cityChecked = divChecked(document.getElementById('qs_city'));
	var hotel45Checked = divChecked(document.getElementById('qs_hotel_45'));
	var hotel23Checked = divChecked(document.getElementById('qs_hotel_23'));
	var apartmanChecked = divChecked(document.getElementById('qs_apartman'));
	var forGroupsChecked = divChecked(document.getElementById('qs_for_groups'));
	var countries = '';
	var advancedSearch = '';
	var inputs = document.getElementById('qs_third_layer_inputs').getElementsByTagName('div');
	var i,j;
	for (i=0;i<inputs.length;i++){
		if (divChecked(inputs[i])){
			var countryId = inputs[i].id.substr(11);
			countries += countryId + ':';
		}
	}
	var divs = document.getElementById('qs_four_layer').getElementsByTagName('div');
	for (i=0;i<divs.length;i++){
		if (divChecked(divs[i])){
			var advancedSearchId = divs[i].id.substr(4);
			advancedSearch += advancedSearchId + ':';
		}
	}
	if ((skiingChecked || seasChecked || mountainsChecked || cityChecked) &&
		(hotel45Checked || hotel23Checked || apartmanChecked || forGroupsChecked)){
		document.getElementById('qs_offers').innerHTML = '';
		var loadingImg = document.createElement('img');
		loadingImg.alt = 'TravelTeam';
		loadingImg.src = '/images/loading.gif';
		loadingImg.className = 'loading';
		document.getElementById('qs_offers').appendChild(loadingImg);
		document.getElementById('pageturn_container').innerHTML = '';
		var xml = executeSyncronRequest("/Ajax/QuickSearch?skiing="+(skiingChecked?"1":"0")+"&seas="+(seasChecked?"1":"0")+"&mountains="+(mountainsChecked?"1":"0")+"&city="+(cityChecked?"1":"0")+"&hotel45="+(hotel45Checked?"1":"0")+"&hotel23="+(hotel23Checked?"1":"0")+"&apartman="+(apartmanChecked?"1":"0")+"&forgroups="+(forGroupsChecked?"1":"0")+"&countries="+countries+"&page="+quickSearchPage+"&advancedsearch="+advancedSearch);
		document.getElementById('qs_offers').innerHTML = '';
		var sumOffer = 0;
		document.getElementById('qs_successful').style.display = 'none';
		document.getElementById('qs_no_offer_result').style.display = '';
		if (document.getElementById('qs_four_layer').display == 'none'){
			document.getElementById('qs_more_title_padding').style.display = 'none';
		}
		for (i = 0; i < xml.documentElement.childNodes.length; i++) {
			document.getElementById('qs_successful').style.display = '';
			document.getElementById('qs_no_offer_result').style.display = 'none';
			document.getElementById('qs_more_title_padding').style.display = '';
			var obj = xml.documentElement.childNodes[i];
			var id = obj.getAttribute("id");
			var name = obj.getAttribute("name");
			var offerUrl = obj.getAttribute("url");
			var imageUrl = obj.getAttribute("image");
			var offerPrice = obj.getAttribute("price");
			var offerPrice2 = obj.getAttribute("price2");
			var rating = obj.getAttribute("rating");
			var offerLead = obj.getAttribute("lead");
			var hotel = obj.getAttribute("hotel");
			var apartment = obj.getAttribute("apartment");
			var seoname = obj.getAttribute("seoname");
			var tripName = obj.getAttribute("triptype");
			sumOffer = obj.getAttribute("sum");
			
			var offerDiv = createOffer(name, offerUrl, imageUrl, offerPrice, offerPrice2, rating, offerLead, hotel, apartment, seoname, tripName);
			
			document.getElementById('qs_offers').appendChild(offerDiv);
		}
		if (sumOffer>travelteam_offers_pagesize_long){
			var startIndex = 1;
			var endIndex = 1;
			var radius = 3;
			pageCount = Math.ceil(sumOffer/travelteam_offers_pagesize_long);
			
			startIndex = quickSearchPage - radius;
			
			var pageturnFirst = document.createElement('div');
			var pageturnFirstLink = document.createElement('a');
			var pageturnPrevious = document.createElement('div');
			var pageturnPreviousLink = document.createElement('a');
			var pageturnCenter = document.createElement('div');
			var pageturnNext = document.createElement('div');
			var pageturnNextLink = document.createElement('a');
			var pageturnLast = document.createElement('div');
			var pageturnLastLink = document.createElement('a');
			var pageturnCenterDots = document.createTextNode('... ');
			var pageturnCenterDots2 = document.createTextNode('... ');
			
			pageturnFirst.className = 'pageturn_first';
			pageturnPrevious.className = 'pageturn_previous';
			pageturnCenter.className = 'pageturn_center';
			pageturnNext.className = 'pageturn_next';
			pageturnLast.className = 'pageturn_last';
			pageturnFirstLink.href = '#';
			pageturnFirstLink.innerHTML = '« '+localizationFirst;
			pageturnFirstLink.onclick = function(){
				quickSearchPage = 1;
				showOfferQuickLayer();
				return false;
			};
			pageturnPreviousLink.href = '#';
			pageturnPreviousLink.innerHTML = '« '+localizationPrevious;
			pageturnPreviousLink.onclick = function(){
				quickSearchPage--;
				showOfferQuickLayer();
				return false;
			};
			pageturnNextLink.href = '#';
			pageturnNextLink.innerHTML = localizationNext+ ' »';
			pageturnNextLink.onclick = function(){
				quickSearchPage++;
				showOfferQuickLayer();
				return false;
			};
			pageturnLastLink.href = '#';
			pageturnLastLink.innerHTML = localizationLast+ ' »';
			pageturnLastLink.onclick = function(){
				quickSearchPage = pageCount;
				showOfferQuickLayer();
				return false;
			};
			
			if (quickSearchPage>1){
				pageturnFirst.appendChild(pageturnFirstLink);
				pageturnPrevious.appendChild(pageturnPreviousLink);
			}
			if (startIndex > 1) {
				pageturnCenter.appendChild(pageturnCenterDots);
			} else {
				startIndex = 1;
			}
			endIndex = quickSearchPage + radius;
			var hasMore = false;
			if (endIndex < pageCount) {
				hasMore = true; 
			} else {
				endIndex = pageCount;
			}
			for (var index = startIndex; index <= endIndex; ++index) {
				if (index == quickSearchPage){
					var pageturnCenterActiveLink = document.createElement('span');
					pageturnCenterActiveLink.innerHTML = index;
					pageturnCenter.appendChild(pageturnCenterActiveLink);
				}else{
					var pageturnCenterLink = document.createElement('a');
					pageturnCenterLink.href = '#';
					pageturnCenterLink.innerHTML = index;
					pageturnCenterLink.onclick = function(){
						quickSearchPage = this.innerHTML;
						showOfferQuickLayer();
						return false;
					};
					pageturnCenter.appendChild(pageturnCenterLink);
				}
				var pageturnCenterLinkSpace = document.createTextNode(' ');
				pageturnCenter.appendChild(pageturnCenterLinkSpace);
			}
			if (hasMore)
				pageturnCenter.appendChild(pageturnCenterDots2);
			if ((quickSearchPage < pageCount && pageCount > 1)) {
				pageturnNext.appendChild(pageturnNextLink);
				pageturnLast.appendChild(pageturnLastLink);
			}
			document.getElementById('pageturn_container').appendChild(pageturnFirst);
			document.getElementById('pageturn_container').appendChild(pageturnPrevious);
			document.getElementById('pageturn_container').appendChild(pageturnCenter);
			document.getElementById('pageturn_container').appendChild(pageturnNext);
			document.getElementById('pageturn_container').appendChild(pageturnLast);
		}
	}
}

function createOffer(name, offerUrl, imageUrl, offerPrice, offerPrice2, rating, offerLead, hotel, apartment, seoname, triptype){
	var offerDiv = document.createElement('div');
	var imageDiv = document.createElement('div');
	var imageLink = document.createElement('a');
	var imageMain = document.createElement('img');
	var imageFront = document.createElement('img');
	var textDiv = document.createElement('div');
	var price = document.createElement('p');
	var price2 = document.createElement('p');
	var title = document.createElement('p');
	var titleLink = document.createElement('a');
	var starsDiv = document.createElement('div');
	var leadDiv = document.createElement('div');
	var leadLink = document.createElement('a');
	var tripLeadDiv = document.createElement('div');
	var tripLeadLink = document.createElement('a');
	
	offerDiv.className = 'travel';
	imageDiv.className = 'image';
	imageLink.href = offerUrl;
	imageLink.target = '_blank';
	imageLink.title = seoname;
	imageMain.src = imageUrl;
	imageMain.alt = seoname;
	if (isIE6){
		imageFront.src = "/images/spacer.gif";
		imageFront.style.filter += "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/image_front.png', sizingMethod=image);";
	}else{
		imageFront.src = '/images/image_front.png';
	}
	imageFront.alt = name;
	imageFront.className = 'front';
	textDiv.className = 'text';
	price.className = 'price';
	price.innerHTML = offerPrice; 
	price2.className = 'price2';
	price2.innerHTML = offerPrice2;
	title.className = 'title';
	titleLink.href = offerUrl;
	titleLink.target = '_blank';
	titleLink.innerHTML = name;
	starsDiv.className = 'stars_conatiner';
	starsDiv.innerHTML = starsDiv.innerHTML + hotel;
	starsDiv.innerHTML = starsDiv.innerHTML + apartment;
	for (j=1;j<=rating;j++)
		starsDiv.innerHTML = starsDiv.innerHTML + '<img src="/images/star.png" alt="' + rating + ' csillag" />';
	leadDiv.className = 'lead';
	leadLink.href = offerUrl;
	leadLink.target = '_blank';
	leadLink.innerHTML = offerLead;
	
	tripLeadDiv.className = 'lead';
	tripLeadLink.href = offerUrl;
	tripLeadLink.target = '_blank';
	tripLeadLink.innerHTML = triptype;

	leadDiv.appendChild(leadLink);
	tripLeadDiv.appendChild(tripLeadLink);
	title.appendChild(titleLink);
	textDiv.appendChild(title);
	textDiv.appendChild(starsDiv);
	textDiv.appendChild(leadDiv);
	if (triptype != "") {
		textDiv.appendChild(tripLeadDiv);
	}
	imageLink.appendChild(imageMain);
	imageLink.appendChild(imageFront);
	imageDiv.appendChild(imageLink);
	offerDiv.appendChild(imageDiv);
	offerDiv.appendChild(textDiv);
	offerDiv.appendChild(price);
	offerDiv.appendChild(price2);
	
	return offerDiv;
}

function showFourQuickLayer(){
	var skiingChecked = divChecked(document.getElementById('qs_skiing'));
	var seasChecked = divChecked(document.getElementById('qs_seas'));
	var mountainsChecked = divChecked(document.getElementById('qs_mountains'));
	var cityChecked = divChecked(document.getElementById('qs_city'));
	var isBackButton = false;
	if (document.getElementById('qs_advanced_search_button').childNodes[0].childNodes[0].childNodes[0].childNodes[0].innerHTML == localizationAdvancedSearch){
		document.getElementById('qs_advanced_search_button').innerHTML = '';
		document.getElementById('qs_advanced_search_button').appendChild(getTableElement(localizationBackStep3));
	} else {
		document.getElementById('qs_advanced_search_button').innerHTML = '';
		document.getElementById('qs_advanced_search_button').appendChild(getTableElement(localizationAdvancedSearch));
		isBackButton = true;
	}
	if (isBackButton){
		document.getElementById('qs_four_layer').style.display = 'none';
		unCheckStep4Divs();
		showOfferQuickLayer();
	} else {
		document.getElementById('qs_four_layer').style.display = '';
		if (skiingChecked){
			showQuickSearchStepFourGroup(1);
		} else if (seasChecked){
			showQuickSearchStepFourGroup(2);
		} else if (mountainsChecked){
			showQuickSearchStepFourGroup(3);
		} else if (cityChecked){
			showQuickSearchStepFourGroup(4);
		}
	}
}

function showQuickSearchStepFourGroup(group){
	var i;
	for (i=1;i<=4;i++){
		if (i==group)
			document.getElementById('qs_four_layer_group_' + i).style.display = '';
		else
			document.getElementById('qs_four_layer_group_' + i).style.display = 'none';
	}
}

function setResortOrder(name, actName, actType){
	var page = document.location.href;
	var orderString = '/rendezes';
	if (page.charAt(page.length-1) == '/') {
		orderString = 'rendezes';
	}
	var orderType = '/elore';
	if (name == 'name'){
		if (actName == name && actType == 'asc') 
			orderType = '/vissza';
	} else {
		orderType = '/vissza';
		if (actName == name && actType == 'desc') 
				orderType = '/elore';
	}
	
	if (page.indexOf(orderString) != -1)
		page = page.substring(0,page.indexOf(orderString));
	
	window.location = page + orderString +'/' + getOrderName(name) + orderType + '#resort';
}

function getOrderName(name){
	if (name == 'name') return "nev";
	if (name == 'blackski') return "fekete-palya";
	if (name == 'redski') return "piros-palya";
	if (name == 'blueski') return "kek-palya";
	if (name == 'sumski') return "osszesen";
	if (name == 'sled') return "szankopalya";
	if (name == 'mountain_railway') return "hegyivasut";
	if (name == 'cabin_lift') return "kabinos-lift";
	if (name == 'chair_lift') return "ulos-lift";
	if (name == 'simple_lift') return "huzos-lift";
	return '';
}