
var documentInited = false

var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
var rv = 0

// Browser detect

var browserType = navigator.appName

if (browserType == 'Microsoft Internet Explorer'){
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
}else if(browserType == 'Netscape'){
    var ua = navigator.userAgent;
    var re  = new RegExp("Firefox/([0-9]\.[0-9]{1,2})\.[0-9]{1,4}");
    
    if (re.exec(ua) != null){rv = RegExp.$1;}
	browserType = 'Firefox';
}else{
	browserType = 'none';
	rv = 0
}
 
var browserVersion = rv;


// home pager
var currentHomeAuto = true
var currentHomePage = 1
var maxHomePage = 5
var homeTimer

function homepager(id){
	try{clearTimeout(homeTimer)}catch(err){}
	$('homeaji_' + currentHomePage).fade({duration:0.8})
	$('homeajibutt_' + currentHomePage).removeClassName('active')	
	$('homeaji_' + id).appear({duration:0.8})
	$('homeajibutt_' + id).addClassName('active')
	currentHomePage = id
}

function homepager_next(){
	var myid 
	if(currentHomePage < maxHomePage){
		myid = currentHomePage+1
	}else{
		myid = 1
	}
	homepager(myid)
}

function homepager_prev(){
	var myid 
	if(currentHomePage > 1){
		myid = currentHomePage-1
	}else{
		myid = maxHomePage
	}
	homepager(myid)
}

function homepager_run(){
	clearTimeout(homeTimer)
	homepager_next()
	homeTimer = setTimeout("homepager_run()",5000);
}

function homepager_auto(){
	homeTimer = setTimeout("homepager_run()",5000);
	
}


var inpDefs = new Array() 
var inpTypes = new Array()
var inpDefTypes = new Array()
var initInputs = new Array()
var readAttrbs = new Array('type', 'name', 'id', 'style', 'class', 'onclick')

function initInputfield(inpId, defText, changeType){
	inpTypes[inpId] = changeType
	inpDefTypes[inpId] = $(inpId).readAttribute('type')
	inpDefs[inpId] = defText
	initInputs.push(inpId)
	$(inpId).blur()
	$(inpId).onfocus = autoinputFocus
	$(inpId).onblur = autoinputBlur
	$(inpId).autocomplete = 'off'
	$(inpId).value = defText
	
}

function noSendDefValues(){
	for(var n=0; n<initInputs.length; n++){
		if($(initInputs[n]).value == inpDefs[initInputs[n]]){
			$(initInputs[n]).value = ''
		}
	}
}

function autoinputFocus(){
	if(this.value == inpDefs[this.id]){
		
		this.removeClassName('autoInput')
		this.addClassName('autoInput_selected')
		this.value = ''
		
		
		if(inpTypes[this.id] !== undefined){
			if (browserType == 'Microsoft Internet Explorer'){
				var newObj = htmlObj2String(this)
				newObj = changeIeType(newObj, inpDefTypes[this.id], inpTypes[this.id])
				var thisId = this.id
				
				new Insertion.After(this, newObj)
				this.remove()
				$(thisId).onfocus = autoinputFocus
				$(thisId).onblur = autoinputBlur
				$(thisId).focus()
				
			}else{
				this.writeAttribute('type', inpTypes[this.id])
			}
			
		}
	}
}

function autoinputBlur(){
	if(this.value == ''){
		this.removeClassName('autoInput_selected')
		this.addClassName('autoInput')
		this.value = inpDefs[this.id]
		
		if(inpTypes[this.id] !== undefined){
			if (browserType == 'Microsoft Internet Explorer'){
				var newObj = htmlObj2String(this)
				newObj = changeIeType(newObj, inpTypes[this.id], inpDefTypes[this.id])
				var thisId = this.id
				var retValue = inpDefs[this.id]
				new Insertion.After(this, newObj)
				this.remove()
				$(thisId).onfocus = autoinputFocus
				$(thisId).onblur = autoinputBlur
				$(thisId).value = retValue
				$(thisId).blur()
			}else{
				this.type = inpDefTypes[this.id]
			}
		}
	}
}

function changeIeType(str, oldType, newType){
	var newstr = str.split('type="'+oldType+'"').join('type="'+newType+'"')
	return newstr
}

function htmlObj2String(obj){
	var myAttrbs = new Array()
	for(var n=0; n<readAttrbs.length; n++){
		myAttrbs[n] = obj.readAttribute(readAttrbs[n])
	}
	
	var attrbString = ''
	for(var z=0; z<readAttrbs.length; z++){
		if(myAttrbs[z] !== null){
			attrbString = attrbString + ' ' + readAttrbs[z] + '="' + myAttrbs[z] + '"'
		}
	}
	
	attrbString = '<input '+ attrbString +'/>';
	
	return attrbString
}


function textareaCounter(num, areaid, charid, maxid){
	if($(areaid).value.length < (num+1)){
		$(charid).innerHTML = $(areaid).value.length
	}else{
		$(areaid).value = $(areaid).value.substring(0, num);
	}
}

function insertInArea(target, type, data){
	var selection
	alert(target)
	
	//IE support

		if (document.selection) {

			target.focus();

			selection = document.selection.createRange();

			//sel.text = myValue;

		}
		
		else if (target.selectionStart || target.selectionStart == '0') {

			var startPos = target.selectionStart;

			var endPos = target.selectionEnd;

			//myField.value = myField.value.substring(0, startPos) + myField.value.substring(endPos, myField.value.length);
			selection = target.value.substring(0, startPos) + target.value.substring(endPos, target.value.length);

		} else {

			selection = target.value

		}
		
		alert(selection)
	

}

function insertAtCursor(myField, type, myValue) {
		var tags
		switch(type){
			case 'smile': 
				tags = new Array('', '')
				myValue = myValue; 
				break;
			case 'format': 
				tags = myValue.split('|')
				myValue = '';
			break;
			default: break;
		}

		//IE support

		if (document.selection) {

			myField.focus();

			sel = document.selection.createRange();
			
			//alert(sel.text)
			if(type == 'format'){
				sel.text = tags[0] + sel.text + tags[1];
			}else{
				sel.text = myValue;
			}

		}

		//MOZILLA/NETSCAPE support

		else if (myField.selectionStart || myField.selectionStart == '0') {

			var startPos = myField.selectionStart;

			var endPos = myField.selectionEnd;
			
			
			if(type == 'format'){
				myValue = tags[0] + myField.value.substring(startPos, endPos)+ tags[1]
			}
			
			//alert()

			myField.value = myField.value.substring(0, startPos)

			+ myValue

			+ myField.value.substring(endPos, myField.value.length)
			
			;

		} else {

			myField.value += myValue;

		}

	}
	
	//////////// Box tabok
	
	var currentCsomagTab = new Array()
	
	function initCsomagTabs(box, tab){
		currentCsomagTab[box] = tab
	}
	
	function csomagtabChange(box, tab){
		if(currentCsomagTab[box] !== tab){
			if(currentCsomagTab[box] == 1 && tab !== 1){
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').removeClassName('csbluetab_active_f');
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').addClassName('csbluetab');
				$('csomagtab_'+box+'_'+tab+'').removeClassName('csbluetab');
				$('csomagtab_'+box+'_'+tab+'').addClassName('csbluetab_active');
			}else if(currentCsomagTab[box] !== 1 && tab == 1){	
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').removeClassName('csbluetab_active');
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').addClassName('csbluetab');
				$('csomagtab_'+box+'_'+tab+'').removeClassName('csbluetab');
				$('csomagtab_'+box+'_'+tab+'').addClassName('csbluetab_active_f');
			}else{
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').removeClassName('csbluetab_active');
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').addClassName('csbluetab');
				$('csomagtab_'+box+'_'+tab+'').removeClassName('csbluetab');
				$('csomagtab_'+box+'_'+tab+'').addClassName('csbluetab_active');
			}
			
			$('cscontent_'+box+'_'+currentCsomagTab[box]+'').style.display = 'none'
			currentCsomagTab[box] = tab
			$('cscontent_'+box+'_'+currentCsomagTab[box]+'').style.display = 'block'
		}

	}
	
	
	function furdotabChange(box, tab){
		if(currentCsomagTab[box] !== tab){
			if(currentCsomagTab[box] == 1 && tab !== 1){
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').removeClassName('gybluetab_active_f');
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').addClassName('gybluetab');
				$('csomagtab_'+box+'_'+tab+'').removeClassName('gybluetab');
				$('csomagtab_'+box+'_'+tab+'').addClassName('gybluetab_active');
			}else if(currentCsomagTab[box] !== 1 && tab == 1){	
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').removeClassName('gybluetab_active');
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').addClassName('gybluetab');
				$('csomagtab_'+box+'_'+tab+'').removeClassName('gybluetab');
				$('csomagtab_'+box+'_'+tab+'').addClassName('gybluetab_active_f');
			}else{
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').removeClassName('gybluetab_active');
				$('csomagtab_'+box+'_'+currentCsomagTab[box]+'').addClassName('gybluetab');
				$('csomagtab_'+box+'_'+tab+'').removeClassName('gybluetab');
				$('csomagtab_'+box+'_'+tab+'').addClassName('gybluetab_active');
			}
			
			$('gycontent_'+box+'_'+currentCsomagTab[box]+'').style.display = 'none'
			currentCsomagTab[box] = tab
			$('gycontent_'+box+'_'+currentCsomagTab[box]+'').style.display = 'block'
		}

	}
	
	
	var currentCsomagExtTab = new Array()
	
	function initCsomagExtTabs(box, tab){
		currentCsomagExtTab[box] = tab
	}
	
	function csomagtabExtChange(box, tab){
		csomagtabExtCloser(box)
	
		if(currentCsomagExtTab[box] !== tab){
			if(currentCsomagExtTab[box] !== 0){
				$('csomagtabext_'+box+'_'+currentCsomagExtTab[box]+'').removeClassName('csbluetab_active_b');
				$('csomagtabext_'+box+'_'+currentCsomagExtTab[box]+'').addClassName('csbluetab');
			}
			
			$('csomagtabext_'+box+'_'+tab+'').removeClassName('csbluetab');
			$('csomagtabext_'+box+'_'+tab+'').addClassName('csbluetab_active_b');

			if(currentCsomagExtTab[box] !== 0) $('csomagbot_cont_'+box+'_'+currentCsomagExtTab[box]+'').style.display = 'none'
			currentCsomagExtTab[box] = tab
			$('csomagbot_cont_'+box+'_'+currentCsomagExtTab[box]+'').style.display = 'block'
		}else{
			if(currentCsomagExtTab[box] !== 0){
				$('csomagtabext_'+box+'_'+currentCsomagExtTab[box]+'').removeClassName('csbluetab_active_b');
				$('csomagtabext_'+box+'_'+currentCsomagExtTab[box]+'').addClassName('csbluetab');
			}
			
			if(currentCsomagExtTab[box] !== 0) $('csomagbot_cont_'+box+'_'+currentCsomagExtTab[box]+'').style.display = 'none'
			currentCsomagExtTab[box] = 0
		
		}
	}
	
	function csomagtabExtCloser(box){
		for(var n=1; n<currentCsomagExtTab.length; n++){
			if(n !== box){
				try{$('csomagtabext_'+n+'_'+currentCsomagExtTab[n]+'').removeClassName('csbluetab_active_b');}catch(err){}finally{}
				try{$('csomagtabext_'+n+'_'+currentCsomagExtTab[n]+'').addClassName('csbluetab');}catch(err){}finally{}
				try{$('csomagbot_cont_'+n+'_'+currentCsomagExtTab[n]+'').style.display = 'none';}catch(err){}finally{}
				currentCsomagExtTab[n] = 0
			}
		}
	}
	
	function csomagAllFromDate(obj, box){
		//alert('dsadsa');
		for(var n=1; n<currentCsomagExtTab.length; n++){
			try{ $('fromday_'+n).value = obj.value; }catch(err){}finally{}
		}
	}
	
	function csomagAllToDate(obj, box){
		for(var n=1; n<currentCsomagExtTab.length; n++){
			try{ $('today_'+n).value = obj.value; }catch(err){}finally{}
		}
	}
	
	function csomagAllAdult(obj, box){
		//alert('dsadsa');
		if(!isNaN(parseInt(obj.value))){
			for(var n=1; n<currentCsomagExtTab.length; n++){
				try{ $('adults_'+n).value = obj.value; }catch(err){}finally{}
				try{ onlyNumbers($('adults_'+n)); }catch(err){}finally{}
			}
		}else{
			if(obj.value == ''){
				for(var n=1; n<currentCsomagExtTab.length; n++){
					try{ $('adults_'+n).value = ''; }catch(err){}finally{}
					try{ onlyNumbers($('adults_'+n)); }catch(err){}finally{}
				}
			}
		}
	}
	
	function csomagAllChildren(obj, box){
		if(!isNaN(parseInt(obj.value))){
			for(var n=1; n<currentCsomagExtTab.length; n++){
				try{ $('children_'+n).value = obj.value; }catch(err){}finally{}
			}
		}else{
			if(obj.value == ''){
				for(var n=1; n<currentCsomagExtTab.length; n++){
					try{ $('children_'+n).value = ''; }catch(err){}finally{}
				}
			}
		}
	}
	
	function csomagAllAge(obj, box){
		if(!isNaN(parseInt(obj.value))){
			for(var n=1; n<currentCsomagExtTab.length; n++){
				try{ $('age_'+box+'_'+n).value = obj.value; }catch(err){}finally{}
				try{ onlyNumbers($('age_'+box+'_'+n)); }catch(err){}finally{}
			}
		}else{
			if(obj.value == ''){
				for(var n=1; n<currentCsomagExtTab.length; n++){
					try{ $('age_'+box+'_'+n).value = ''; }catch(err){}finally{}
					try{ onlyNumbers($('age_'+box+'_'+n)); }catch(err){}finally{}
				}
			}
		}
	}
	
	function csomagAllRoom(obj, box){
		if(!isNaN(parseInt(obj.value))){
			for(var n=1; n<currentCsomagExtTab.length; n++){
				try{ $('rooms_'+n).value = obj.value; }catch(err){}finally{}
			}
		}else{
			if(obj.value == ''){
				for(var n=1; n<currentCsomagExtTab.length; n++){
					try{ $('rooms_'+n).value = ''; }catch(err){}finally{}
				}
			}
		}
	}
	
	function csomagAllRoomType(obj, box){
		for(var n=1; n<currentCsomagExtTab.length; n++){
			try{ $('roomtype_'+n).value = obj.value; }catch(err){}finally{}
		}
	}
	
	function onlyNumbers(obj, func){
		var chars = obj.value.split("")
		if(isNaN(obj.value) || (chars[1]=='.')){showAlertExtended('Érvénytelen karakter!', '');}
		if(isNaN(parseInt(chars[0]))){chars[0]="";}
		if(isNaN(parseInt(chars[1]))){chars[1]="";}
		obj.value = chars[0]+''+chars[1]
		if(func !== undefined){
		var myFunc = func
		myFunc()
		}
	}
	
	function testFunc(str){
		alert(str)
	}
	
	function onlyNumbersChildren(obj){
		var chars = obj.value.split("")
		if(isNaN(parseInt(chars[0]))){chars[0]="";}
		if(isNaN(parseInt(chars[1]))){chars[1]="";}
		obj.value = chars[0]+''+chars[1]
		
		
		var num = parseInt(obj.value)
		if(obj.value.length < 1){num = 1}
		
		for(var n=1; n<currentCsomagExtTab.length; n++){
			$('childrens_num_cont_'+n).innerHTML = ''
			for(var f=1; f<num+1; f++){
				if(f < (num)){
					new Insertion.Bottom($('childrens_num_cont_'+n), '<div class="csomaginp_small_div" style="width:25px"><input type="text" value="" name="age_'+f+'" class="csomaginp_small" id="age_'+f+'_'+n+'" maxlength="2" onkeypress="onlyNumbers(this, csomagAllAge(this, '+f+'))" onkeydown="onlyNumbers(this, csomagAllAge(this, '+f+'))" onkeyup="onlyNumbers(this, csomagAllAge(this, '+f+'))"/></div>')
				}else{
					new Insertion.Bottom($('childrens_num_cont_'+n), '<div class="csomaginp_small_div" style="width:40px"><input type="text" value="" name="age_'+f+'" class="csomaginp_small" id="age_'+f+'_'+n+'" maxlength="2" onkeypress="onlyNumbers(this, csomagAllAge(this, '+f+'))" onkeydown="onlyNumbers(this, csomagAllAge(this, '+f+'))" onkeyup="onlyNumbers(this, csomagAllAge(this, '+f+'))"/> év</div>')
				}
			}
		}
		
	}
	
	function onlyNumbersChildrenPop(obj){
		var chars = obj.value.split("")
		if(isNaN(parseInt(chars[0]))){chars[0]="";}
		if(isNaN(parseInt(chars[1]))){chars[1]="";}
		obj.value = chars[0]+''+chars[1]
		
		
		var num = parseInt(obj.value)
		if(obj.value.length < 1){num = 1}
			$('childrenContPop').innerHTML = ''
			for(var f=1; f<num+1; f++){
				if(f < (num)){
					new Insertion.Bottom($('childrenContPop'), '<div class="korSz"><input type="text" value="" name="age_'+f+'" id="age_'+f+'" maxlength="2" onchange="csomagAllAge(this, '+f+')" onkeypress="onlyNumbers(this)" onkeydown="onlyNumbers(this)" onkeyup="onlyNumbers(this)"/></div>')
				}else{
					new Insertion.Bottom($('childrenContPop'), '<div class="korSz"><input type="text" value="" name="age_'+f+'" id="age_'+f+'" maxlength="2" onchange="csomagAllAge(this, '+f+')" onkeypress="onlyNumbers(this)" onkeydown="onlyNumbers(this)" onkeyup="onlyNumbers(this)"/></div>')
				}
			}
	}
	
	function onlyNumbersChildrenAj(obj){
		var chars = obj.value.split("")
		if(isNaN(parseInt(chars[0]))){chars[0]="";}
		if(isNaN(parseInt(chars[1]))){chars[1]="";}
		obj.value = chars[0]+''+chars[1]
		
		
		var num = parseInt(obj.value)
		if(obj.value.length < 1){num = 1}
			$('childrenContAj').innerHTML = ''
			for(var f=1; f<num+1; f++){
				if(f < (num)){
					new Insertion.Bottom($('childrenContAj'), '<div class="korSz"><input type="text" value="" name="age_'+f+'" id="age_'+f+'" maxlength="2" onchange="csomagAllAge(this, '+f+')" onkeypress="onlyNumbers(this)" onkeydown="onlyNumbers(this)" onkeyup="onlyNumbers(this)"/></div>')
				}else{
					new Insertion.Bottom($('childrenContAj'), '<div class="korSz"><input type="text" value="" name="age_'+f+'" id="age_'+f+'" maxlength="2" onchange="csomagAllAge(this, '+f+')" onkeypress="onlyNumbers(this)" onkeydown="onlyNumbers(this)" onkeyup="onlyNumbers(this)"/></div>')
				}
			}
	}
	
	function onlyNumbersChildrenFog(obj){
		var chars = obj.value.split("")
		if(isNaN(parseInt(chars[0]))){chars[0]="";}
		if(isNaN(parseInt(chars[1]))){chars[1]="";}
		obj.value = chars[0]+''+chars[1]
		
		
		var num = parseInt(obj.value)
		if(obj.value.length < 1){num = 1}
			$('childrenContFog').innerHTML = ''
			for(var f=1; f<num+1; f++){
				if(f < (num)){
					new Insertion.Bottom($('childrenContFog'), '<div class="korSz"><input type="text" value="" name="age_'+f+'" id="age_'+f+'" maxlength="2" onchange="csomagAllAge(this, '+f+')" onkeypress="onlyNumbers(this)" onkeydown="onlyNumbers(this)" onkeyup="onlyNumbers(this)"/></div>')
				}else{
					new Insertion.Bottom($('childrenContFog'), '<div class="korSz"><input type="text" value="" name="age_'+f+'" id="age_'+f+'" maxlength="2" onchange="csomagAllAge(this, '+f+')" onkeypress="onlyNumbers(this)" onkeydown="onlyNumbers(this)" onkeyup="onlyNumbers(this)"/></div>')
				}
			}
	}
	
	
//// alert

function alertposition(obj, myHeight){
	var myViewWidth = document.viewport.getWidth();
	var scrollOffsets = document.viewport.getScrollOffsets();
	if(myHeight > 0){
		$(obj).style.top = ((document.viewport.getHeight()/2) - (myHeight/2))+ scrollOffsets[1] + 'px';
	}else{
		$(obj).style.top = ((document.viewport.getHeight()/2) - ($(obj).offsetHeight/2))+ scrollOffsets[1] + 'px';
	}
	
	$(obj).style.left = ((myViewWidth/2) - ($(obj).offsetWidth/2)) + 'px';
}


function showAlertExtended(cim, szoveg){
	
	var posVertiExt = 0
	
	for( var a = 2; a < arguments.length; a++ ) {
		if(arguments[a] !== undefined){
			if(arguments[a].title !== undefined && arguments[a].title !== 'positionChange'){
				new Insertion.After('alert_butt_container', '<td align="center" id="alert_funcbutt_'+a+'"><div class="alert_butt_align"><a href="javascript:void(0)" onclick="'+arguments[a].func+'(); return false;" style="cursor:pointer;"><span class="alertbuttleft"><span class="alertbuttright">'+arguments[a].title+'</span></span></a></div></td>')
			}else{
				if(arguments[a].title == 'positionChange'){
					posVertiExt = arguments[a].newpos
				}
				
				
			}
			try{var callfunction = arguments[a].extra; callfunction();}catch(err){}
		}
	}
	
	$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
	$('ajaxmessage_curtain').style.display = 'block';
	try{$('alerttitle').innerHTML=cim;}catch(err){}finally{}
	if(szoveg.indexOf('#') == 0){
		var insertId = szoveg.replace('#', '')
		$('alerttext').innerHTML=$(insertId).innerHTML;
	}else{
		$('alertszoveg').innerHTML=szoveg;
	}
	
	$('ajaxmessage').style.display = 'block'
	
	
	alertposition('ajaxmessage', posVertiExt);

}


function closealert(){
	for( var a = 2; a < 10; a++ ) {
		try{
			$('alert_funcbutt_'+a).remove();
		}catch(err){}
	}
	
	$('ajaxmessage_curtain').style.display = 'none';
	$('ajaxmessage').style.display = 'none';
	
	try{$('loginToImg').remove();}catch(err){}
}

function showTooltip(element){
	$(element).next().style.display = 'block';
}

function hideTooltip(element){
	$(element).next().style.display = 'none';
	
}

function kattable(){
	if($('categoryBox').style.display == 'none'){
		if($('kategoria_inp').value == 'Kérem, válasszon!'){$('kategoria_inp').value = ''}
		$('categoryBox').style.display = 'block';
	}else{
		kattableclose()
	}
}

function katCheckEmpty(){
	var myret = true
	
	var katArray = new Array();
	katArray = $('categoryBox').getElementsByClassName('checkBox');
	
	for(var n=0; n<katArray.length; n++){
		if(katArray[n].checked){myret = false; break;}
	}
	
	return myret;
}

function kattableclose(){
	if(katCheckEmpty()){$('kategoria_inp').value = 'Kérem, válasszon!'}
	$('categoryBox').style.display = 'none';
	//$('myBody').onclick = null
}


function galleryShowPic(url){
	$('hotelKep').innerHTML = ''
	$('hotelKep').innerHTML = '<img src="'+url+'" border="0" alt="" height="300"/>'
}

/* popups */

function popupHotelGaleria(hotelid, type, current){
	new Ajax.Request('/popup_galeria.php', {
		method: 'post',
		parameters: { hotelid: hotelid, type: type, src:current},
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
			
				$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
			}
		}
	});
}


function popupHotelGallery(hotelid, type, current){
	new Ajax.Request('/popup_kepek.php', {
		method: 'post',
		parameters: { hotelid: hotelid, type: type, src:current},
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
			
				$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
			}
		}
	});
}

function popupHotelVelemeny(hotelid){
	new Ajax.Request('/popup_velemenyek.php', {
		method: 'post',
		parameters: { hotelid: hotelid},
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
			
				$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
			}
		}
	});
}

function popupHotelVideo(hotelid){
	new Ajax.Request('/popup_video.php', {
		method: 'post',
		parameters: { hotelid: hotelid},
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
			
				$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
			}
		}
	});
}

function popupHotelUtvonal(hotelid, emptyfrom){
	new Ajax.Request('/popup_utvonal.php', {
		method: 'post',
		parameters: { hotelid: hotelid, from:$('testInp_6').value, to:$('mytoroute').value},
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
				$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
				
				var emptymsg = ''
				var frominstring = '&from='+$('testInp_6').value+''
				if($('testInp_6').value.length == 0 || $('testInp_6').value == 'indulás helye'){emptymsg = emptyfrom; frominstring = ''}
				//alert(emptyfrom)
				var so = new SWFObject('/route.swf?key=ABQIAAAA6KllunmlBOmyyTrzNu7-1xTcjwx1eJTNIREKZwf_4-DjuVUj0BTbKaxsKbLSH49uS5tm-kMF6Q6VQQ'+frominstring+'&to='+$('mytoroute').value+'&msg='+emptymsg+'', 'player', '780', '550', '9', '#FFFFFF');
				so.useExpressInstall('swfobject/expressinstall.swf');
				so.addParam('wmode', 'opaque');
				so.write('routeDiv');
			}
		}
	});
}

function popupHotelAjanlat(hotelid, type){
	new Ajax.Request('/popup_ajanlat.php?t=ajanlat', {
		method: 'post',
		parameters: $('comagform_'+hotelid+'').serialize(true),
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
			
				$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
				
				Sys.Application.add_init(function() {$create(AjaxControlToolkit.CalendarBehavior, {"button":$get("ifromday_pop"),"id":"ifromday_pop"}, null, null, $get("ifromday_pop"));});
				Sys.Application.add_init(function() {$create(AjaxControlToolkit.CalendarBehavior, {"button":$get("itoday_pop"),"id":"itoday_pop"}, null, null, $get("itoday_pop"));});
			}
		}
	});
}

function popupHotelFoglalas(hotelid, type){
	new Ajax.Request('/popup_ajanlat.php?t=foglalas', {
		method: 'post',
		parameters: $('comagform_'+hotelid+'').serialize(true),
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
			
				$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
				
				Sys.Application.add_init(function() {$create(AjaxControlToolkit.CalendarBehavior, {"button":$get("ifromday_pop"),"id":"ifromday_pop"}, null, null, $get("ifromday_pop"));});
				Sys.Application.add_init(function() {$create(AjaxControlToolkit.CalendarBehavior, {"button":$get("itoday_pop"),"id":"itoday_pop"}, null, null, $get("itoday_pop"));});
			}
		}
	});
}

function closeExtLayer(divid){
	$('ajaxmessage_curtain').style.display = 'none';
	$(divid).style.display = 'none';
	$('temoraryDiv').style.display = 'none'
	$('temoraryDiv').innerHTML = ''
	
}

function popupImgChager(url, title){
	$('nagyKep').innerHTML = '';
	$('nagyKep').innerHTML = '<img src="'+url+'" border="0" alt="" />';
	$('imgTitle').innerHTML = '';
	$('imgTitle').innerHTML = title;
	
}

var mouseX = 0
var mouseY = 0
var IE = document.all?true:false;

function getCursorXY(e) {
	if(IE){
		mouseX = event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft)+15;
		mouseY = event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop)-15;
	}else{
		mouseX = e.pageX+15;
		mouseY = e.pageY-15;
	}
	
	$('tooltipBox').style.top = mouseY + 'px'
	$('tooltipBox').style.left = mouseX + 'px'
}

function showTooltip(str){
	if(documentInited){
		if(str.length > 0){
		$('tooltipText').innerHTML = '';
		$('tooltipBox').style.display = 'block';
		$('tooltipText').innerHTML = str;
		}
	}
}

function hideTooltip(){
	$('tooltipBox').style.display = 'none'
	$('tooltipText').innerHTML = ''
}

function popupChat(link){
	//window.open(link,"_blank","toolbar=no, location=yes, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=700, height=600");
	//alert(_C4Online)
	_C4chat(1);
}


function ajanlatEllenorzes(formid, pop){

	var sendable = true;

	var nev = $(formid).getElementsByClassName('input_nev');
	var email = $(formid).getElementsByClassName('input_email');
	var telefon = $(formid).getElementsByClassName('input_telefon');

	if(nev[0].value.length == 0){sendable = false}
	if(email[0].value.length == 0 || !email[0].value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)){sendable = false;}
	if(telefon[0].value.length == 0 || !telefon[0].value.match(/^([0-9_\+\-/ ])+$/)){sendable = false}

	//alert(nev[0].value+' - '+email[0].value+' - '+telefon[0].value);

	if(sendable){

		new Ajax.Request('/foglalas', {
			method: 'post',
			parameters: $(formid).serialize(true),
			onSuccess: function(request) {
				if(request.responseText !== 'error'){

					var result = request.responseText.evalJSON();
					//alert(result.status+" -- "+pop);

					if (!pop && result.status == 'ok') {
						closeExtLayer('foglalasLayer');
						if (result.type == 'foglalas_felso')
							window.location.href = '/sikeres_felsofoglalas';
						if (result.type == 'ajanlat_felso')
							window.location.href = '/sikeres_mutasdazarat';
						//showAlertExtended(result.title, result.content);
					} else if (pop) {
						$('hiddenCaptcha').innerHTML = '<img src="/captcha_reg.php?'+Math.random()+'" border="0" alt=""/>';
						addSimilarCaptcha();

						showAlertExtended(result.title, result.content);
					}

					// ha sikeresen elmentettuk a cuccot akkor uritjuk a formot
					if (pop && result.status == 'ok') {
						$(formid).reset();
						if (result.type == 'foglalas')
							window.location.href = '/sikeres_alsofoglalas';
						if (result.type == 'ajanlat')
							window.location.href = '/sikeres_ajanlat';
					}
				}
			}
		});

		return false;
	}else{
		if(pop){
			showAlertExtended('A kötelező mezők nincsennek helyesen kitöltve', 'Ajánlatkéréshez mindenképp töltse ki a Név, E-mail cím, és Telefon mezőket helyesen.');

			$('hiddenCaptcha').innerHTML = '<img src="/captcha_reg.php?'+Math.random()+'" border="0" alt=""/>';
			addSimilarCaptcha();
		}
		return false;
	}
	
}

function ajanlatKeresKonf(formid){
		
		new Ajax.Request('/foglalas_konferencia', {
			method: 'post',
			parameters: $(formid).serialize(true),
			onSuccess: function(request) {
				if(request.responseText == 'ok'){
					showAlertExtended('A küldés sikeres!', request.responseText);
				}else{
					showAlertExtended('Figyelem!', request.responseText);
					$('captcha_image_ajanlat').src = '/captcha_reg.php?'+Math.random();
					
				}
			}
		});
		return false;

	
}


/*function layerAjanlatSend(formid){
	// ez a szar is a foglalas.php visz!!!
	new Ajax.Request('/ajanlat', {
		method: 'post',
		parameters: $(formid).serialize(true),
		onSuccess: function(request) {
			if(request.responseText !== 'error'){

				//$('ajaxmessage_curtain').style.height = $('mainContent').getHeight() + 'px';
				//$('ajaxmessage_curtain').style.display = 'block';
				$('temoraryDiv').style.display = 'none'
				$('foglalasLayer').style.display = 'none'
				$('temoraryDiv').innerHTML = ''
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
			}
		}
	});
}*/

/*function layerFoglalasSend(formid){

	new Ajax.Request('/foglalas', {
		method: 'post',
		parameters: $(formid).serialize(true),
		onSuccess: function(request) {
			if(request.responseText !== 'error'){
				$('temoraryDiv').style.display = 'none'
				$('foglalasLayer').style.display = 'none'
				$('temoraryDiv').innerHTML = ''
				$('temoraryDiv').innerHTML = request.responseText
				$('temoraryDiv').style.display = 'block'
				$('foglalasLayer').style.display = 'block'
				alertposition('foglalasLayer', 0);
			}
		}
	});
}*/

function setChatOffline(lang){
	//alert(_C4oImg.indexOf('offline')>0)
	var langtag = '';
	if(lang !== 'hu'){langtag = '_'+lang;}
	//alert(_C4oImg);
	if(_C4oImg.indexOf('online') > 0){
		//alert('online')
		try{$('bigheader_chat').style.background = 'url(/images/textimages/header_chat'+langtag+'.png) no-repeat 0 0';}catch(err){}finally{}
		try{$('wChat').style.background = 'url(/images/textimages/wellneschat_bg'+langtag+'.jpg) no-repeat 0 0';}catch(err){}finally{}
		try{$('chatInfok').style.background = 'url(/images/textimages/info_chat'+langtag+'.jpg) no-repeat 0 0';}catch(err){}finally{}
		try{$('programkereso_right').style.background = 'url(/images/programkereso_right'+langtag+'.jpg) no-repeat 0 0';}catch(err){}finally{}
		try{$('programkereso_right_fur').style.background = 'url(/images/programkereso_right2'+langtag+'.jpg) no-repeat 0 0';}catch(err){}finally{}
		try{$('programkereso_right_prog').style.background = 'url(/images/programkereso_right_prog'+langtag+'.jpg) no-repeat 0 0';}catch(err){}finally{}
		
		if(currentCsomagExtTab.length > 0){
		for(var n=1; n<currentCsomagExtTab.length; n++){
			try{$('csomagChatButton_'+n).style.background = 'url(/images/textimages/brn_wellnesschat'+langtag+'.png) no-repeat 0 0';}catch(err){}finally{}
		}
		}
		
		//alert(hotelBoxArray.length)
		
		if(hotelBoxArray.length > 0){
		for(var n=0; n<hotelBoxArray.length+1; n++){
			try{$('hoteldobozChatButton_'+n).style.background = 'url(/images/textimages/konfcsaj'+langtag+'.png) no-repeat 0 0';}catch(err){}finally{}
		}
		}
	}
}


var hotelBoxArray = new Array();

function hotelboxInit(hotelid){
	hotelBoxArray.push(hotelid)
}

function konferenciaClick(hotelid){
	if($('konfclick_'+hotelid).checked){
		$('hotelids').value = $('hotelids').value + hotelid+','
		$('konfclicklabel_'+hotelid).style.fontWeight = 'normal'
		$('konfclicklabel_'+hotelid).innerHTML = 'kiveszem'
	}else{
		$('hotelids').value = $('hotelids').value.split(','+hotelid+',').join(',')
		$('konfclicklabel_'+hotelid).style.fontWeight = 'bold'
		$('konfclicklabel_'+hotelid).innerHTML = 'megtartom'
	}
	//
}

//setChatOffline();





