//----------------  NYOMTATHATÓ VERZIÓ ---------------------------------------------------------------------
var gAutoPrint = true; 
function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML><HEAD>';
		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		html += '</HE' + 'AD><BOD' + 'Y class=feher>';
		var printReadyElem = document.getElementById("printReady");
		
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Az oldalnak nem létezik nyomtatható verziója! Could not find the print version of this page!");
			return;
		}
			
		html += '</BO' + 'DY></HT' + 'ML>';
		
		var printWin = window.open("","printSpecial","width=600, height=400, menubar=0, toolbar=1, location=0,status=0,scrollbars=1");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Az Ön böngészője sajnos nem támogatja a nyomtatási funkciót! Sorry, the print ready feature is not available in your browser.");
	}
}

//----------------  POPUP KÉPEK ---------------------------------------------------------------------
function PopUpImage(imageURL,imageWidth,imageHeight) 
{  
	var posLeft=window.screen.width/2 - imageWidth/2;
	var posTop=window.screen.height/2 - imageHeight/2;   

	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<htm'+'l><t'+'itle>Bella Porta</t'+'itle><bo'+'dy bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	newWindow.document.write('<img src="'+imageURL+'" width='+imageWidth+' height='+imageHeight+'>'); 	
	newWindow.document.write('</b'+'ody></ht'+'ml>');
	newWindow.document.close();
	newWindow.focus();
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650, height=600,left = 30,top = 0');");
}
//----------------  KOSÁR TARTALMA, COOKIE-K ---------------------------------------------------------------------
var cartsCounter = 0;
var arrCart1 = new Array();
var arrCart2 = new Array();
var arrCart3 = new Array();

function WriteCartsCounter()
{
	cartContent1 = GetCookie("objectsCart300");
	cartContent2 = GetCookie("destinationsCart300");
	cartContent3 = GetCookie("programsCart300");

	if (cartContent1) arrCart1 = cartContent1.split("+");
	if (cartContent2) arrCart2 = cartContent2.split("+");
	if (cartContent3) arrCart3 = cartContent3.split("+");

	cartsCounter = arrCart1.length + arrCart2.length + arrCart3.length;
	if (cartsCounter>0) document.write(" (" + cartsCounter + ")");
}

function GetCookie(name) 
{
    var index = document.cookie.indexOf(name + "=");
    if (index == -1) return null;
    index = document.cookie.indexOf("=", index) + 1; 
    var endstr = document.cookie.indexOf(";", index);
    if (endstr == -1) endstr = document.cookie.length; 
    return unescape(document.cookie.substring(index, endstr));
}

function SetCookie(cookieName,cookieValue,nDays)
{
 var today = new Date();
 var expire = new Date();
 if (nDays==null || nDays==0) nDays=1;
 expire.setTime(today.getTime() + 3600000*24*nDays);
 document.cookie = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();
}
//-------- HONLAPMEGNYITÁS ----------------------------------------------------

function LocationHomePage(id,language){
	var timeObj = new Date();
	var pageURL = homePageSystemRoot+"objektum.php";
	pageURL+= '?sablon=' + templateNumber;
	pageURL+= '&id=' + id;
	pageURL+= '&nyelv=' + language;
	homePageWin = open(pageURL,'','top=5,left=5,width=785,height=430 scrollbars=1 resizable=1 status=1 menubar=1 toolbar=1 location=1');
}

function LocationHomePage2(id){
	var timeObj = new Date();
	var pageURL = homePageSystemRoot+"objektum.php";
	pageURL+= '?sablon=' + templateNumber;
	pageURL+= '&id=' + id;
	pageURL+= '&nyelv=' + language;
	this.location = pageURL;
}

function HomePage(id,language){
	var timeObj = new Date();
	var pageURL = homePageSystemRoot+"objektum.php";
	pageURL+= '?sablon=441';
	pageURL+= '&id=' + id;
	pageURL+= '&nyelv=' + language;
	homePageWin = open(pageURL,'','top=5,left=5,width=780,height=440,scrollbars=1,resizable=1');
}

//------------- KERESŐK -------------------------------------------------------
/*Enter ütés észlelése a szabad szavas keresésnél*/
function KeyIsEnter(evt) 
{
    evt = (evt) ? evt : event;
    var target = (evt.target) ? evt.target : evt.srcElement;
    var form = target.form;
    var charCode = (evt.charCode) ? evt.charCode :
        ((evt.which) ? evt.which : evt.keyCode);
    if (charCode == 13 || charCode == 3) return true;
	return false;
}

function TextSearch()
{
	document.f.action = homePageSystemRoot + "hp-szkereso.php";
	document.f.submit();
}

function SendEmailToNewsLetter()
{
	document.f.btnNewsLetter1.value='1';document.f.submit();
	document.f.hdnPageId.value = '418';
	document.f.submit();
}

function MapObjWin(argX,argY)
{
	var URL =  homePageSystemRoot + "hp-terkepobjektumok.php?language="+language+"&template="+templateNumber;
	URL+=  "&serviceId=" + selectedServiceId+"&objectId=" + objectId + "&objectType=" + objectType;
	URL+=  "&r=" + objectSignSizeInEOV + "&x=" + argX + "&y=" + argY;
	OpenDialogWindow(560,350,URL,'1');
}

/* --------------------------  KÉPTÁR ----------------------------------*/

var arrPictures

function GetPictureIndex()
{
	if (document.f.hdnPictureIds.value)
	{
		arrPictures = document.f.hdnPictureIds.value.split('+');
		var cntPictures = arrPictures.length;
		for (i=0;i<cntPictures;i++)
		{
			if (arrPictures[i]==document.f.hdnSelectedPictureId.value) return i;
		}
	}
	return -1; 
}

function NextPic()
{
	var pictureIndex = GetPictureIndex();
	if ((pictureIndex>=0) && (arrPictures.length>pictureIndex+1))
	{
		pictureIndex++;
		document.f.hdnSelectedPictureId.value = arrPictures[pictureIndex];
		document.f.submit();
	} 
}

function PrevPic()
{
	var pictureIndex = GetPictureIndex();
	if (pictureIndex>0)
	{
		pictureIndex--;
		document.f.hdnSelectedPictureId.value = arrPictures[pictureIndex];
		document.f.submit();
	} 
}

var objDialogWindow = null;

function OpenDialogWindow(iWidth,iHeight,URL,scrollbars)
{
	var fClosed=false;   
	var iLeft=window.screen.width/2 - iWidth/2;
	var iTop=window.screen.height/2 - iHeight/2 - 25;   
  
  	if (iWidth>790) iWidth = 790;
  	if (iHeight>500) iHeight = 500;
	   
	if (objDialogWindow != null)
	{
		if (!objDialogWindow.closed)
		{
			objDialogWindow.close(); 
			while (fClosed != objDialogWindow.closed)
			{
				fClosed = objDialogWindow.closed;
			}     
		}
	}       
	objDialogWindow=window.open(URL,"_blank",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scrollbars+',resizable=1,width=' + iWidth + ',height=' + iHeight + ',screenX=' + iLeft + ',screenY=' + iTop + ',left=' + iLeft + ',top=' + iTop);   
}

/* --------------------------  VIRTUÁLIS BARANGOLÁS ----------------------------------*/

var whichlink;
var whichimage = 0;
var timelayers = new Array();
var pause;
var interval1;
var interval2;
var roamingOperation = "changeImage";
var slideWaiting = 4000;
var counter = 0;
var alpha = 0;

function MM_swapImgRestore() 
{ 
  var i,x,a=document.MM_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{ 
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) 
{ 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() 
{ 
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function CacheImage(ImageSource) 
{ 
//window.alert("CacheImage("+ImageSource+")");
   var ImageObject = new Image();
   ImageObject.src = ImageSource;
   return ImageObject;
}

function CacheImage(ImageSource) 
{ 
   var ImageObject = new Image();
   ImageObject.src = ImageSource;
   return ImageObject;
}

function DownloadCompleted() 
{
//   window.alert("Download()");
   if (slideimages[whichimage].complete) 
   {
   		slideReady = true;
        self.defaultStatus = '';
		return true;
   } 
   else return false;
}

function CacheNextSlide() 
{
   if ((whichimage < slideimages.length) && (typeof slideimages[whichimage] == 'string'))
	{ 
      self.defaultStatus = 'Downloading next picture...';
      slideimages[whichimage] = CacheImage(slideimages[whichimage]);
   }
   return true;
}


function gotoshow()
{
	HomePage(slidelinks[whichlink],document.f.hdnLanguage.value);
	Stop();
}

function StartSlideShow() 
{
//window.alert("StartSlideShow()");
   if (!document.getElementById)
   {
 		window.alert("Az Ön böngészője nem támogatja az oldalon futó vetítő alkalmazást!\nYour browser does not support the slide show application of this site!");
  		return;
   }

   whichlink=0;
   whichimage = 0;
   slideimages[0] = CacheImage(slideimages[0]);
   pause = false;
   ShowLayer("divStopButton","visible");
   ShowLayer("divPrevButton","visible");
   ShowLayer("divNextButton","visible");
   SlideIt();
   ShowTimeRemained();
}

function ShowLayer(name,visibility)
{
  if (document.getElementById)  document.getElementById(name).style.visibility = visibility;
  else if (document.all) document.all[name].style.visibility = visibility;
  else if (document.layers) document.layers[name].visibility = visibility;
}

function Previous()
{
	Stop();
	if (whichimage==0) whichimage = slideimages.length-2;
	else if (whichimage == 1) return;
	else whichimage-=2;
	pause = false;
    roamingOperation = "changeImage";
	SlideIt();
	Stop();
}

function Next()
{
	Stop();
	pause = false;
    roamingOperation = "changeImage";
	SlideIt();
	Stop();
}

function Stop()
{
	pause = true;
	counter = 0;
	clearTimeout(interval1);
	clearTimeout(interval2);
	for (i=0;i<15;i++) ShowLayer("divTime"+i,"hidden");	
	ShowLayer("divStopButton","hidden");
	ShowLayer("divStartButton","visible");
	var sliderLayer = document.getElementById("divSlider");
	sliderLayer.style.filter = "Alpha(Opacity=100)";
	sliderLayer.style.MozOpacity = 1;
}

function Restart()
{
//   if (whichimage==0) whichimage = slideimages.length-1;
//   else whichimage-=1;
   roamingOperation = "fadeIn";
   pause = false;
   SlideIt();
   ShowTimeRemained();
   ShowLayer("divStartButton","hidden");
   ShowLayer("divStopButton","visible");
}

function SlideIt()
{
	if (roamingOperation=="waitForDownload")
	{
		if (DownloadCompleted()) roamingOperation="fadeOut";
		interval2 = setTimeout("SlideIt()",10);
	}
	else if (roamingOperation=="fadeIn")
	{
		var sliderLayer = document.getElementById("divSlider");
		sliderLayer.style.filter = "Alpha(Opacity="+alpha+")";
		sliderLayer.style.MozOpacity = alpha/100;
		if (alpha<100)
		{
			alpha+=10;
			interval2 = setTimeout("SlideIt()",20);
		}
		else
		{
			sliderLayer.style.filter = "Alpha(Opacity=100)";
			sliderLayer.style.MozOpacity = 1;
			roamingOperation = "waitForDownload";
			interval2 = setTimeout("SlideIt()",slideWaiting);
		}
	}
	else if (roamingOperation=="changeImage")
	{
		document.images.slide.src=slideimages[whichimage].src;
		document.getElementById('divText').innerHTML = "<table cellpadding=7 width=250><tr><td class=feher><a href=javascript:gotoshow()>"+slidenames[whichimage]+"</a><div class=k>"+slidetowns[whichimage]+"</div></td></tr></table>";
		whichlink=whichimage;
		whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0;
		CacheNextSlide();
		ShowTimeRemained();
		roamingOperation = "fadeIn";
		if (!pause) interval2 = setTimeout("SlideIt()",10);
	}
	else if (roamingOperation=="fadeOut")
	{
		clearTimeout(interval1);
		for (i=0;i<15;i++) ShowLayer("divTime"+i,"hidden");
		document.getElementById('divText').innerHTML = "&nbsp;";
		counter = 0;
		var sliderLayer = document.getElementById("divSlider");
		sliderLayer.style.filter = "Alpha(Opacity="+alpha+")";
		sliderLayer.style.MozOpacity = alpha/100;
		if (alpha>0) alpha-=10;
		else
		{
			sliderLayer.style.filter = "Alpha(Opacity=0)";
			sliderLayer.style.MozOpacity = 0;
			roamingOperation = "changeImage";
		}
		interval2 = setTimeout("SlideIt()",10);
	}
}

function ShowTimeRemained()
{
	if (counter==0) for (i=0;i<15;i++) ShowLayer("divTime"+i,"hidden");
	if (!pause) for (i=0;i<counter;i++) ShowLayer("divTime"+i,"visible");
	if (!pause && (counter<15))
	{
		counter++;
		interval1 = setTimeout("ShowTimeRemained()",(slideWaiting/16));
	}
}
//Ez a honlapok megnyitása miatt kell
function GetObjectIndex()
{
}



/** IDŐJÁRÁS OLDAL ******************************/
var metWindow = null;
var metWindowClosed=false;   

function ShowMetPage()
{
	optionName = "oplTowns";
	var options = eval("document.f." + optionName+ ".options");
	for (var i=0; i<options.length; i++) 
	{
		if (options[i].selected){
			value = options[i].value;
		}
	}
	if (metWindow != null)
	{
		if (!metWindow.closed)
		{
			metWindow.close(); 
			while (metWindowClosed != metWindow.closed)
			{
				metWindowClosed = metWindow.closed;
			}     
		}
	}       
	if (value!='') metWindow = open(value,'','top=5,left=5,scrollbars=1,menubar=1,toolbar=1,status=1,width=770,height=500,resizable=1,location=1');
}


function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

function NewWin(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

//----------------  FOTOGALERAIA ---------------------------------------------------------------------

function wclose() {
self.close();
}

var rotate_delay = 4000; // delay in milliseconds (4000 = 4 secs)
current = 0;
function next() {
if (document.slideform.slide[current+1]) {
document.images.show.src = document.slideform.slide[current+1].value;
document.slideform.slide.selectedIndex = ++current;
   }
else first();
}
function previous() {
if (current-1 >= 0) {
document.images.show.src = document.slideform.slide[current-1].value;
document.slideform.slide.selectedIndex = --current;
   }
else last();
}
function first() {
current = 0;
document.images.show.src = document.slideform.slide[0].value;
document.slideform.slide.selectedIndex = 0;
}
function last() {
current = document.slideform.slide.length-1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
}
function ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
rotate();
}
function change() {
current = document.slideform.slide.selectedIndex;
document.images.show.src = document.slideform.slide[current].value;
}
function rotate() {
if (document.slideform.slidebutton.value == "Stop") {
current = (current == document.slideform.slide.length-1) ? 0 : current+1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
window.setTimeout("rotate()", rotate_delay);
   }
}


//----------------  popup ---------------------------------------------------------------------



function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=650, height=600,left = 30,top = 0');");
}

function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

function popUp3d(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=430, height=330,left = 50,top = 0');");
}

function popUproom(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=300, height=500,left = 50,top = 0');");
}

function popUpemail(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=430, height=400,left = 50,top = 20');");
}

function popUpguest(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0, width=550, height=480,left = 50,top = 50');");
}

//------------------ close --------------------------------------------------

function wclose() {
self.close();
}

//------------------ slideform ------------------------------------------------


var rotate_delay = 4000; // delay in milliseconds (4000 = 4 secs)
current = 0;
function next() {
if (document.slideform.slide[current+1]) {
document.images.show.src = document.slideform.slide[current+1].value;
document.slideform.slide.selectedIndex = ++current;
   }
else first();
}
function previous() {
if (current-1 >= 0) {
document.images.show.src = document.slideform.slide[current-1].value;
document.slideform.slide.selectedIndex = --current;
   }
else last();
}
function first() {
current = 0;
document.images.show.src = document.slideform.slide[0].value;
document.slideform.slide.selectedIndex = 0;
}
function last() {
current = document.slideform.slide.length-1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
}
function ap(text) {
document.slideform.slidebutton.value = (text == "Stop") ? "Start" : "Stop";
rotate();
}
function change() {
current = document.slideform.slide.selectedIndex;
document.images.show.src = document.slideform.slide[current].value;
}
function rotate() {
if (document.slideform.slidebutton.value == "Stop") {
current = (current == document.slideform.slide.length-1) ? 0 : current+1;
document.images.show.src = document.slideform.slide[current].value;
document.slideform.slide.selectedIndex = current;
window.setTimeout("rotate()", rotate_delay);
   }
}

