var toltanim_szov;
var toltanim;

function tolt_start(){
	/*if(toltanim==null){
		toltanim_szov=document.createElement('div');
		toltanim_szov.className='toltanim_szov';
		toltanim_szov.innerHTML='Oldal betöltése';
		toltanim=document.createElement('div');
		toltanim.className='toltanim';
		document.getElementById('toltdiv').appendChild(toltanim_szov);
		document.getElementById('toltdiv').appendChild(toltanim);
	}*/
}

function tolt_stop(){
	/*if(toltanim!=null){
		document.getElementById('toltdiv').removeChild(toltanim_szov);
		document.getElementById('toltdiv').removeChild(toltanim);
		toltanim_szov=null;
		toltanim=null;
	}*/
	meretet_allit();
	latogatast_ujratolt();
	//google hírdetést újratölti
	document.getElementById('adsense').contentDocument.location.reload(true);
	//Csak a főoldalon kell, és csak akkor kell elindítani, ha épp nincs folyamatban lévő
	if(!kepvaltas) kepetvalt();
}


var aktkep=1;
var kepvaltas=false;

/*Képet csak a főoldalon kell váltani a bemutató sávon, így leellenőrizzük, hogy léteznek-e a képkockák*/
function kepetvalt(){
		//alert('fut');
	//clearTimeout(kepvaltas);
	if(document.getElementById('bem_toltokocka')){
		dl('bemutatottolt.php','bem_toltokocka','get',new Array('tip='+aktkep,'kepcsere=1'),kepetcserel);
		//if(!kepvaltas) kepvaltas=setInterval("kepetvalt()",3000);
	}else{
		//clearInterval(kepvaltas);
		kepvaltas=false;
	}
}


/*Az ideiglenes helyére töltött képet beteszi a véleges helyére*/
function kepetcserel(){
	if(document.getElementById('bemutatokep_'+aktkep) && document.getElementById('bemutatokep_csere') && document.getElementById('bemutatolink_'+aktkep) && document.getElementById('bemutatolink_csere')){
		if (document.all)
		{
			document.getElementById('bemutatokep_'+aktkep).style.filter="blendTrans(duration=3)"
			document.getElementById('bemutatokep_'+aktkep).style.filter="blendTrans(duration=3)"
			document.getElementById('bemutatokep_'+aktkep).filters.blendTrans.Apply()
		}
		document.getElementById('bemutatokep_'+aktkep).src= document.getElementById('bemutatokep_csere').src;
		//kicserésljük a hivatkozást is
		document.getElementById('bemutatolink_'+aktkep).href= document.getElementById('bemutatolink_csere').href;
		document.getElementById('bemutatolink_'+aktkep).onclick= document.getElementById('bemutatolink_csere').onclick;
		if (document.all)
		{
			document.getElementById('bemutatokep_'+aktkep).filters.blendTrans.Play();
		}
	}
	if(aktkep<4) aktkep++; else aktkep=1;
	//if(!kepvaltas) 
	kepvaltas=setTimeout("kepetvalt()",3000);
}

//Ha az akciósáv és kosár mérete együtt nagyobb lenne, mint a tartalom, akkor megnöveli a tartalmat
function meretet_allit(){
	document.getElementById("tartalom").style.height='';
	if(document.getElementById("tartalom")&&document.getElementById("bevkosar")&&document.getElementById("akciosav")){
		if(document.getElementById("tartalom").clientHeight<document.getElementById("bevkosar").clientHeight+document.getElementById("akciosav").clientHeight)
			document.getElementById("tartalom").style.cssText="height:"+(document.getElementById("bevkosar").clientHeight+document.getElementById("akciosav").clientHeight)+"px !important";	
	}
}

//Újratölti a látogatások panelt
function latogatast_ujratolt(){
	dl('latogatasok.php','lat_div','GET',new Array(''),null,null,null,0);
}

dl_init(1,'tartalom',tolt_start,tolt_stop,true,0);

function elsokatturit(mit){
	if (mit.getAttribute('elsokatt')!=1){
		mit.value="";
		mit.setAttribute('elsokatt',1);
	}
}

function frissit(){
	/*dl('menu.php','menusav','GET',new Array());*/
	location.reload();
}

//Frissíti a kiskosarat
function frissit_kk(){
	dl('kiskosar.php','kiskosar');
}

function paneltnyitcsuk(panelid){
	if (document.getElementById(panelid).style.height!="0px")
		document.getElementById(panelid).style.height="0px";
	else
		document.getElementById(panelid).style.height="";
}

var t;
function regellenor(mit,ido){
	clearTimeout(t);
	t=setTimeout("dl('regellenor.php','"+mit+"ellenor','POST',new Array('"+mit+"'))",ido);
}

/*Szerkeszto használja*/
function tombot(mibol){
	return mibol.split(',');
}

function kepetnyit(kepnev){
	window.open('termekek/'+kepnev,'','toolbar=0,status=1,resizable=1,scrollbars=1,location=0,menubar=0,directories=0,copyhistory=0,top=0','');
}

//villogtatja az ajánlat gombot
var ajanlatvillogas=setInterval("ajanlatvillog()",1000);

function ajanlatvillog(){
	
	//Villogtartja a menü ajánlat gombját
	if(document.getElementById('mg_ajanlat')){
		if(document.getElementById('mg_ajanlat').className=="mg_ajanlat_norm")
			document.getElementById('mg_ajanlat').className="mg_ajanlat_le";
		else
			document.getElementById('mg_ajanlat').className="mg_ajanlat_norm";
	}
	
	//Villogtatja a főoldalon lévő ajánlat szöveget
	if(document.getElementById('bem_ajanlatlink')){
		if(document.getElementById('bem_ajanlatlink').className=="bem_ajanlatlink_1")
			document.getElementById('bem_ajanlatlink').className="bem_ajanlatlink_2";
		else
			document.getElementById('bem_ajanlatlink').className="bem_ajanlatlink_1";
	}
}


/*hova:melyik oldalon van (php fájl neve) mihez:objektum id-je az oldaoln*/
function ugorj(mihez){
	/*if(hova!=""){//új oldalon (kezelve a dl.js-ben)
		if(ujoldal)
		dl(hova,'tartalom','GET',new Array('ugorj='+mihez));
	}
	else{*///oldalon belül
		ugrik(document.getElementById(mihez));
	//}
}

/*Objektumhoz ugrik az adott oldalon*/
function ugrik(mihez){
	if(mihez && (mihez=mihez.parentElement)){
      document.body.scrollTop=mihez.offsetTop-100;
	  if(document.documentElement) document.documentElement.scrollTop=mihez.offsetTop-100;		
	  
	}
	//gorget(document.documentElement,document.getElementById(location.href.split('ugorj=')[1].split('&')[0]).offsetTop-100,10,1000);*/	
}