var topkepek=8;
var currentkep="img_top_kepek1";
var oldkep="img_top_kepek2";
var oldmmout="";
var onmmouseoverid=0;
var aktivDir="";
var aktivMenu="";
var menu="";
var dbg;
var top7id=0;
var top7visible=0;
var firsttime=true;
var szMenuheight=460;
var scrolld;
var szlogin=-1;
var initializeRun=0;
var lfooldal;
var topKepek = new Array();

function top7fadein(kepid){

var img = document.getElementById(currentkep);

if (topKepek[kepid].opacity==0) img.src=topKepek[kepid].src;

if (topKepek[kepid].opacity < 1.0) topKepek[kepid].opacity = Math.round( (topKepek[kepid].opacity + 0.02)*100)/100;

img.style.opacity=topKepek[kepid].opacity+"";
img.style.filter='alpha(opacity=' + topKepek[kepid].opacity*100 + ')';

if (img.width<topKepek[kepid].maxw && img.height<topKepek[kepid].maxh) {
	img.width=parseInt(img.width+topKepek[kepid].inc);
	img.height=parseInt(img.width * topKepek[kepid].ar); 

	img.style.width=String(parseInt(parseInt(img.style.width)+topKepek[kepid].inc))+"px";
	img.style.height=String(parseInt(parseInt(img.style.width) * topKepek[kepid].ar))+"px";

	img.style.top = parseInt(227 - img.height / 2) +"px";
	img.style.left = parseInt(400 - img.width / 2) + "px";
}

var nextkep = kepid < (topkepek - 1) ? kepid + 1 : 0;

if (topKepek[kepid].opacity < 1.0) top7timer=setTimeout("top7fadein("+kepid+")", 50);
else {
	var tk=oldkep;
	oldkep=currentkep;
	currentkep=tk;
	top7timer=setTimeout("top7fadeout("+kepid+")", 1000);
	tm2=setTimeout("top7fadein("+nextkep+")", 1000);
	}
}

function top7fadeout(kepid)
{
var img = document.getElementById(oldkep);

if (topKepek[kepid].opacity > 0) topKepek[kepid].opacity = Math.round( (topKepek[kepid].opacity - 0.02)*100)/100;
img.style.opacity=topKepek[kepid].opacity+"";
img.style.filter='alpha(opacity=' + topKepek[kepid].opacity*100 + ')';
img.width=parseInt(img.width-topKepek[kepid].inc);
img.height=parseInt(img.width * topKepek[kepid].ar);

img.style.width=String(parseInt(img.style.width)-topKepek[kepid].inc >= 0 ? parseInt(img.style.width)-parseInt(topKepek[kepid].inc) : "0")+"px";
img.style.height=String(parseInt(img.style.width) * topKepek[kepid].ar)+"px";

img.style.top = parseInt(227 - img.height / 2) +"px";
img.style.left = parseInt(400 - img.width / 2) + "px";

var nextkep = kepid < (topkepek - 1) ? kepid + 1 : 0;
if (topKepek[kepid].opacity > 0) top7timer=setTimeout("top7fadeout("+kepid+")",50);
}


function getWH() {
var myWidth = 0, myHeight = 0;

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

winW=myWidth;
winH=myHeight;
}

function hideLoading() {
var a=document.getElementById('img_loading');
a.style.display='none';
var fl=document.getElementById('lfooldal');
if (aktivMenu == "") fl.style.display='block';

}

function hideFooldal() {
var a=document.getElementById('fooldal');
var m=document.getElementById('bmain');
var fl=document.getElementById('lfooldal');
var main=document.getElementById('main');

a.style.display='none';
/*fl.style.display='none';*/

main.style.display='block';

m.style.display='none';
m.style.width='0px';
m.style.height='0px';
}

function center_fooldal() {
var a=document.getElementById('fooldal');
var m=document.getElementById('bmain');
var l=document.getElementById('img_loading');
var fi=document.getElementById('img_fooldal');
var fl=document.getElementById('lfooldal');
            
a.style.left=winW/2-190+'px';
a.style.display='block';

l.style.left='120px';
l.style.top="300px";
l.style.display='block';

fl.style.left='0px';
fl.style.top="0px";
/*fl.style.display='none';*/

m.style.width=winW+'px';
m.style.height=winH+'px';

}

function onMMOver(kid) {
k=document.getElementById(kid);
if (k == null) return;
k.style.background="url('img/menuk_bg.jpg')";
k.style.opacity="0.5"; 
k.style.filter="alpha(opacity='50')";
onmmouseoverid=kid;
if (oldmmout != "" && oldmmout != kid) {
	ko=document.getElementById(oldmmout);
	}
}

function onMMOut(kid) {
oldmmout=kid;
k=document.getElementById(kid);
k.style.opacity="1"; 
k.style.filter="alpha(opacity='100')";
k.style.background="";
}

function findPicnum(picname) {
	for (k in galeryA[gdir]){
		var s=galeryA[gdir][k].src;
		if (s.search(picname) >= 0) return k;
	}
return -1;
}


function findPos(obj){
var curleft = curtop = 0;

if (obj.offsetParent) {
	do {
	curleft += obj.offsetLeft;
	curtop += obj.offsetTop;
	} while (obj = obj.offsetParent);
return [curleft,curtop];
}
return [0,0];
}


function initialize() {

$(".divszthumbs a").lightBox();

//if (! initializeRun++) {
if (true) {

	var main=document.getElementById("main");
//	dbg=document.getElementById("debugdiv");
	var content=document.getElementById("content");
	var md=document.getElementById("md");
	var showlogin=document.getElementById("showlogin");
	var thumbs=document.getElementById("galeria_thumbsor");
	var ghter=document.getElementById("galeria_hatter");
	lfooldal=document.getElementById("lfooldal");

	getWH();

	if (!IE) document.captureEvents(Event.MOUSEMOVE)
	document.onmousemove = getMouseXY;

	if (aktivMenu == "") center_fooldal();
	else {
		main.style.display="block";
		md.style.display="block";
	}

	cacheImages(fkImages);

	if (aktivMenu == "") cacheImages(miscImages);

	if (aktivMenu == "galeria") {
		if (aktivDir != "" && gdir != "") {
			cacheImages(galeriaImages);
			ghter.style.display="none";
			content.style.height="500px";
			thumbs.style.display="block";
			var rt=setTimeout('roller_timer()', 1000);
			var fit=setTimeout('changePic(0)',500);
		} else {
			ghter.style.display="block";
			content.style.height="500px";
			onmouseoverid=gdir;
			firsttime=true;
	//		var picnum=findPicnum(galeryMainA[gdir]);
			var kt=setTimeout('bgPicChange()', 500);
		}
	}

	if (aktivMenu == "szemelyes") {
		content.style.height=szMenuheight+"px";
		if (szlogin>0) {
			showlogin.style.width="100%";
			showlogin.style.backgroundColor="#F1E2F0";
			showlogin.style.opacity=1;
			showlogin.style.filter="alpha(opacity=100)";
		}
	}

	if (aktivMenu == "arak") {
	//	content.style.height="570px";
	}

	if (aktivMenu == "home") {
		cacheImages(topImages);
		var top7timer=setTimeout('top7fadein(0)', 1000);
	}

	if (aktivMenu == "fotozas" || aktivMenu == "arak" || aktivMenu == "ajandekutalvany") {
		scr=document.getElementById('arak_szoveg');
		scrollerH=containerH / parseInt(scr.offsetHeight) * containerH;
		scrolld=document.getElementById('scrolldiv');
		scrolld.style.height=scrollerH+"px";
	//dbg.innerHTML="containerH="+containerH+" scr.offsetHeight="+parseInt(scr.offsetHeight)+" scrollerH="+scrollerH;
		var tr=setTimeout("txtScroller()", 500);
	}
}
}

function closePopup() {
	document.getElementById("popupmain").style.display="none";
}


