function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
	return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else{
   		return false;
 	}
}

(function(){
 /*Use Object Detection to detect IE6*/
	var  m = document.uniqueID /*IE*/
	&& document.compatMode  /*>=IE6*/
	&& !window.XMLHttpRequest /*<=IE6*/
	&& document.execCommand;
	try{
		if(!!m){
			m("BackgroundImageCache", false, true) /* = IE6 only */
		}
	}
	catch(oh){};
})();

function jsemail(email) {
	for(i=email.length-1; i>=0; i--)
		document.write(email.charAt(i));
}

function jsemaillink(email, link, classname) {
	document.write('<a href="'+link+'"'+(classname!=undefined&&classname!='' ? ' class="'+classname+'"' : '')+'>');
	for(i=email.length-1; i>=0; i--)
		document.write(email.charAt(i));
	document.write('</a>');
}

function jsmailto(emailto, email, classname) {
	document.write('<a href="');
	for(i=emailto.length-1; i>=0; i--)
		document.write(emailto.charAt(i));
	document.write('"'+(classname!=undefined&&classname!='' ? ' class="'+classname+'"' : '')+'>');
	for(i=email.length-1; i>=0; i--)
		document.write(email.charAt(i));
	document.write('</a>');
}

function jsmailtolink(email, cim, classname) {
	document.write('<a href="');
	for(i=email.length-1; i>=0; i--)
		document.write(email.charAt(i));
	document.write('"'+(classname!=undefined&&classname!='' ? ' class="'+classname+'"' : '')+'>'+cim+'</a>');
}

function chr(c) {
	var h = c.toString(16);
	if (h.length==1)
		h = '0'+h;
	h = unescape('%'+h);
	return h;
}

function mind(stat) {
	var c=mind.arguments&&mind.arguments.length>1 ? mind.arguments[1] : '';
	inputs = document.getElementsByTagName("input");
	for (i=0; i<inputs.length; i++)
		if (inputs[i].type=="checkbox" && (c=='' || (' '+inputs[i].className+' ').indexOf(' '+c+' ')!=-1))
			inputs[i].checked = stat==1 ? true : (stat==0 ? false : !inputs[i].checked);
}


function katfocus(nev) {
	document.getElementById('katnev_'+nev).style.display = 'none';
	document.getElementById('katselect_'+nev).style.display = '';
	document.getElementById('katselect_'+nev).focus();
}
function katblur(nev) {
	document.getElementById('katnev_'+nev).style.display = '';
	document.getElementById('katselect_'+nev).style.display = 'none';
}
function katload(nev) {
	katblur(nev);
	document.getElementById('katnev_'+nev).innerHTML = document.getElementById('katselect_'+nev).options[document.getElementById('katselect_'+nev).selectedIndex].text+' <b> - Betöltés folyamatban...</b>';
}
function katload2(nev) {
	katblur(nev);
	document.getElementById('katnev_'+nev).innerHTML = document.getElementById('katselect_'+nev).value+' <b> - Betöltés folyamatban...</b>';
}
txtop_i=-1;
txtop_j=-1;
txtop_tim=0;
txtop_int=undefined;
txtop_d=0;
txtop_ms=500;
txtop_spd=10;
txtop_wait=250;
txtop_over=undefined;
txtop_out=undefined;
txtop_omax = 0.9;
function txtopacity() {
	if (txtop_i==-1 && txtop_j!=-1) {
		txtop_i=txtop_j;
	}
	var dat=new Date();
	var tim=dat.getTime();
	var d=0;
	if (txtop_i!=-1 && txtop_j!=txtop_i)
		d=-1;
	else if (txtop_i!=-1 && txtop_j==txtop_i)
		d=1;
	if (txtop_d!=0 && d!=0 && txtop_d!=d) {
		var x=txtop_ms-(tim-txtop_tim);
		if (x>0 && x<txtop_ms)
			txtop_tim=tim-x;
	}
	var e=document.getElementById('filmtxt'+txtop_i);
	if (txtop_i!=-1 && txtop_j!=txtop_i) {
		var v=(1-(tim-txtop_tim)/txtop_ms)*txtop_omax;
		if (v<0)
			v=0;
		setopacity(e, v);
		txtop_d=-1;
		if (v==0) {
			if (e.style.display!='none')
				e.style.display='none';
			txtop_i=txtop_j;
			if (txtop_i!=-1) {
				txtop_tim=tim;
				e=document.getElementById('filmtxt'+txtop_i);
			} else {
				txtop_d=0;
				clearInterval(txtop_int);
				txtop_int=undefined;
			}
		}
	}
	if (txtop_i!=-1 && txtop_j==txtop_i) {
		var v=(tim-txtop_tim)/txtop_ms;
		if (v>txtop_omax)
			v=txtop_omax;
		setopacity(e, v);
		txtop_d=1;
		if (e.style.display!='block')
			e.style.display='block';
		if (v==txtop_omax) {
			txtop_d=0;
			clearInterval(txtop_int);
			txtop_int=undefined;
		}
	}
}
function txtload(i, kod) {
	var nyelv=document.getElementById('nyelv') ? document.getElementById('nyelv').value : 'hun';
	var e=document.getElementById('filmleiras'+i);
	e.innerHTML='<span style="font-weight: bold; color: #fff;">'+(nyelv=='eng' ? 'Loading...' : 'Betöltés...')+'</span>';
	var xmlHttpReq = false;
	if (window.XMLHttpRequest)
		xmlHttpReq = new XMLHttpRequest();
	// IE
	else if (window.ActiveXObject)
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpReq.open("POST", "filmleiras_ajax.php", true);
	xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				e.innerHTML=xmlHttpReq.responseText;
			} else {
				e.innerHTML='';
			}
        	}
	}
	xmlHttpReq.send('kod='+kod+'&nyelv='+nyelv);
}
/* Compiled from X 4.18 by XC 1.07 on 26Jul07 */
function txtover(i, alap, kod, e) {
	var csillaghck=false
	if (window.txtovertilt!=undefined && window.txtovertilt==true) {
		window.txtovertilt=false;
		csillaghck=true;
	}
	document.getElementById('filmblokk'+i).className=alap+' '+alap+'_blokkover';
	if (e!=undefined) {
		var x=e.layerX ? e.layerX : e.clientX;
		if (x<document.getElementById('filmblokk'+i).offsetWidth/2 && !csillaghck) {
			document.getElementById('atxt'+i).className='txtright';
			document.getElementById('filmtxt'+i).style.left=Math.round(document.getElementById('filmblokk'+i).offsetWidth-300)+'px';
		} else {
			document.getElementById('atxt'+i).className='txtleft';
			document.getElementById('filmtxt'+i).style.left='0px';
		}
	}
	if (document.getElementById('filmtxt'+i)) {
		if (txtop_out!=undefined) {
			clearTimeout(txtop_out);
			txtop_out=undefined;
		}
		if (txtop_over==undefined) {
			if (document.getElementById('filmleiras'+i).innerHTML=='')
				txtload(i, kod);
			txtop_over=setTimeout('txtover2('+i+')', txtop_wait);
		}
	}
}
function txtover2(i) {
	if (txtop_j!=i) {
		txtop_j=i;
		if (txtop_int==undefined) {
			var dat=new Date();
			txtop_tim=dat.getTime();
			txtop_int=setInterval('txtopacity()', txtop_spd);
		}
	}
	txtop_over=undefined;
}
function txtout(i, alap) {
	document.getElementById('filmblokk'+i).className=alap;
	if (document.getElementById('filmtxt'+i)) {
		if (txtop_over!=undefined) {
			clearTimeout(txtop_over);
			txtop_over=undefined;
		}
		if (txtop_out==undefined)
			txtop_out=setTimeout('txtout2()', txtop_wait);
	}
}
function txtout2() {
	txtop_j=-1;
	if (txtop_int==undefined) {
		var dat=new Date();
		txtop_tim=dat.getTime();
		txtop_int=setInterval('txtopacity()', txtop_spd);
	}
	txtop_out=undefined;
}
function setopacity(e, opacity) {
	if (e.style.opacity!=undefined)
		e.style.opacity = opacity;
	else
		e.style.filter = 'Alpha(Opacity='+(opacity*100)+', Style=0)';
}
function iconload(e, tipus, kod, kep) {
	var xmlHttpReq = false;
	if (window.XMLHttpRequest)
		xmlHttpReq = new XMLHttpRequest();
	// IE
	else if (window.ActiveXObject)
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpReq.open("POST", "iconload_ajax.php", true);
	xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpReq.onreadystatechange = function() {
		if (xmlHttpReq.readyState == 4) {
			if (xmlHttpReq.status == 200) {
				e.onload=function(){this.className='';};
				e.src=xmlHttpReq.responseText;
			}
        }
	}
	xmlHttpReq.send('tipus='+tipus+'&kod='+kod+'&kep='+kep);
}

szavaz_id=false;
szavaz_w=0;
szavaz_txt=false;
szavaz_o=0;
szavaz_k=0;
szavaz_maxp=0;
sz_out=[];
szavaz_out_ev=false;
function szavaz_on(i, e, k, w, h, maxp) {
	if (szavaz_id===false) {
		if (sz_out[i]) {
			window.clearTimeout(sz_out[i]);
			sz_out[i]=false;
		}
		if (szavaz_txt===false && document.getElementById('szavaz_txt')) {
			szavaz_txt=document.getElementById('szavaz_txt').value.split('|');
		}
		szavaz_p=0;
		document.getElementById('e1_'+i).style.backgroundPosition='0 '+h+'px';
		document.getElementById('e2_'+i).style.backgroundPosition='0 '+h+'px';
		szavaz_o=document.getElementById('e2_'+i).style.width;
		szavaz_id=i;
		szavaz_w=w;
		szavaz_k=k;
		szavaz_maxp=maxp;
		e.onmousemove=szavaz;
		e.onclick=szavaz_click;
	}
}
function szavaz_on2(i) {
	if (szavaz_id==i) {
		if (sz_out[i]) {
			window.clearTimeout(sz_out[i]);
			sz_out[i]=false;
		}
	}
}
function szavaz_out() {
	if (szavaz_id!==false) {
		if (sz_out[szavaz_id]) {
			window.clearTimeout(sz_out[szavaz_id]);
		}
		sz_out[szavaz_id]=window.setTimeout("szavaz_out2("+szavaz_id+")", 200);
	}
}
function szavaz_out2(i) {
	var v;
	if (szavaz_out_ev===false) {
		szavaz_out_ev=document.getElementById('e1_'+i).onmouseover;
		document.getElementById('e1_'+i).onmouseover=null;
		v=true;
	} else {
		v=false;
	}

	document.getElementById('e1_'+i).onmousemove=null;
	document.getElementById('e1_'+i).onclick=null;
	document.getElementById('e1_'+i).style.backgroundPosition='0 0';
	document.getElementById('e2_'+i).style.backgroundPosition='0 0';
	document.getElementById('e3_'+i).style.display='none';
	document.getElementById('e2_'+i).style.width=szavaz_o;

	if (v) {
		window.setTimeout("document.getElementById('e1_"+i+"').onmouseover=szavaz_out_ev;szavaz_out_ev=false;", 100);
	}

	sz_out[i]=false;
	if (szavaz_id==i)
		szavaz_id=false;
}
function szavaz(event) {
	if (szavaz_id!==false) {
		if (!event)
			event = window.event;
		var x = event ? (event.offsetX ? event.offsetX : (event.layerX ? event.layerX : 0)) : 0;
		var p = Math.ceil(x/szavaz_w*szavaz_maxp);
		document.getElementById('e2_'+szavaz_id).style.width=Math.round(p*szavaz_w/szavaz_maxp)+'px';
		if (szavaz_p!=p) {
			szavaz_p=p;
			var v=szavaz_txt[szavaz_p-1]!=undefined;
			if (v!=(document.getElementById('e3_'+szavaz_id).style.display=='block'))
				document.getElementById('e3_'+szavaz_id).style.display=v ? 'block' : 'none';
			document.getElementById('e3_'+szavaz_id).innerHTML=szavaz_txt[szavaz_p-1];
			document.getElementById('e3_'+szavaz_id).style.left=Math.round((szavaz_p-1)*szavaz_w/szavaz_maxp - document.getElementById('e3_'+szavaz_id).clientWidth + szavaz_w/szavaz_maxp/2-1)+'px';
		}
	}
}
function szavaz_click() {
	if (szavaz_id!==false) {
		var xmlHttpReq = false;
		if (window.XMLHttpRequest)
			xmlHttpReq = new XMLHttpRequest();
		// IE
		else if (window.ActiveXObject)
			xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
		xmlHttpReq.open("POST", "ertekeles_ajax.php", true);
		xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttpReq.onreadystatechange = function() {
			if (xmlHttpReq.readyState == 4) {
				if (xmlHttpReq.status == 200) {
					var a=xmlHttpReq.responseText.split('|');
					if (a.length==6) {
						var tags=document.getElementsByTagName("div");
						var x, w, ww, p;
						var nyelv=document.getElementById('nyelv').value;
						for(var i=0; i<tags.length; i++) {
							if ((' '+tags[i].className+' ').indexOf(' sz_'+a[1])!=-1) {
								x=tags[i].id.substr(3);
								w=parseInt(document.getElementById('e1_'+x).style.width);
								ww=(a[2]!=0&&a[4]!=0 ? Math.round(a[3]/a[2]/a[4]*w) : 0)+'px';
								document.getElementById('e2_'+x).style.width=ww;
								document.getElementById('e4_'+x).innerHTML=(nyelv=='eng' ? 'Average: ' : 'Átlag: ')+(a[2]!=0 ? Math.round(a[3]/a[2]*10)/10 : 0)+' ('+a[2]+' '+(nyelv=='eng' ? (a[2]>1 ? 'votes' : 'vote') : 'szavazat')+')';
								if (szavaz_id==x) {
									szavaz_o=ww;
									szavaz_out2(szavaz_id);
								}
							}
						}
					}
				}
        		}
		}
		xmlHttpReq.send('kod='+szavaz_k+'&pont='+szavaz_p);
	}
}

function allapotinterval(id) {
	var v=document.getElementById('valaszto_'+id);
	var c=document.getElementById('valasztoc_'+id);
	var spd=2;
	var tol=10;
	if (eval('valasztoa_'+id)) {
		var vh=v.offsetHeight+tol;
		if (vh>300) {
			vh=300;
		}
		var ch=parseInt(c.style.height);
		if (Math.round(ch)<vh) {
			c.style.height=ch+(vh+tol-ch)/spd+'px';
		} else if (ch<vh) {
			c.style.height=vh+'px';
		}
		if (ch==vh && c.style.overflow!='auto') {
			c.style.overflow='auto';
		}
		if (c.style.display=='none') {
			c.style.display='';
		}
	} else {
		var ch=parseInt(c.style.height);
		if (Math.round(ch)>0) {
			c.style.height=ch-ch/spd+'px';
		} else if (ch>0) {
			c.style.height='0px';
		} else if (c.style.display!='none') {
			c.style.display='none';
		}
		if (c.style.overflow!='hidden') {
			c.style.overflow='hidden';
		}
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}

function kedvenclista(kod) {
	var s=readCookie('kedvenclista');
	if (s==null || s==undefined) {
		s = '';
	}
	if ((','+s+',').indexOf(','+kod+',')==-1) {
		s += (s!=''&&s.substr(-1)!=',' ? ',' : '')+kod;
		createCookie('kedvenclista', s);
		ajaxload({get:'ajax_kedvenclista.php',post:'nyelv='+$('nyelv').value,
			onstart:function() {
				$('pageindicator').style.display='block';
			},
			onload:function(xmlHttpReq) {
				$('kedvenclistacontent').innerHTML=xmlHttpReq.responseText;
				$('pageindicator').style.display='none';
			},
			onerror:function() {
				$('pageindicator').style.display='none';
			}
		});
	}
}
function kedvenclistaeltavolit(kod) {
	var s=readCookie('kedvenclista');
	if (s==null || s==undefined) {
		s = '';
	}
	if ((','+s+',').indexOf(','+kod+',')!=-1) {
		var a=s.split(',');
		s='';
		for (var i=0; i<a.length; i++)
			if (a[i]>0 && a[i]!=kod) {
				s += (s!='' ? ',' : '')+a[i];
			}
		createCookie('kedvenclista', s);
		ajaxload({get:'ajax_kedvenclista.php',post:'nyelv='+$('nyelv').value,
			onstart:function() {
				$('pageindicator').style.display='block';
			},
			onload:function(xmlHttpReq) {
				$('kedvenclistacontent').innerHTML=xmlHttpReq.responseText;
				$('pageindicator').style.display='none';
			},
			onerror:function() {
				$('pageindicator').style.display='none';
			}
		});
	}
}

/* használat:
ajaxload({get:'ajax.php',post:'valtozo1=ertek1&valtozo2=ertek2',
	onload:function(xmlHttpReq) {
		document.getElementById('content').innerHTML=xmlHttpReq.responseText;
	}
});
ajaxload({get:'ajax.php',post:'valtozo1=ertek1&valtozo2=ertek2',content:'tartalom'});
*/
function ajaxload(obj) {
	var xmlHttpReq=false;
	if (window.XMLHttpRequest) xmlHttpReq=new XMLHttpRequest();
	// IE
	else if (window.ActiveXObject) xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
	xmlHttpReq.open("POST", obj.get ? obj.get : 'ajax.php', true);
	xmlHttpReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpReq.onreadystatechange=function() {
		if (xmlHttpReq.readyState==4) {
			if (xmlHttpReq.status==200) {
				if (obj.onload)	obj.onload(xmlHttpReq);
				if (obj.contentelement) obj.contentelement.innerHTML=xmlHttpReq.responseText;
			}
			else {
				if (obj.onerror) obj.onerror(xmlHttpReq);
				if (obj.contentelement) obj.contentelement.innerHTML='Hiba a kapcsolatban!';
			}
        }
	}
	if (obj.onstart) obj.onstart();
	if (obj.content) obj.contentelement = document.getElementById(obj.content);
	if (obj.contentelement) obj.contentelement.innerHTML='<img src="art/indicator.gif" alt="" />';
	xmlHttpReq.send(obj.post ? obj.post : '');
}

function $(id) {
	return document.getElementById(id);
}



vidt=[];
vid_init_t=[];
function vid_inditas(obj) {
	if (vidt[obj.id]!==true) {
		ajaxload({get:'vidstat.php',post:'vid='+vidt[obj.id]});
		vidt[obj.id]=true;
	}
}

oplitem=-1;
oplid=-1;
plitempsto=0;
plitempsgo=false;
plitempsv=0
function vid_item(obj) {
	var i=document.getElementById(obj.id).getConfig().item;
	var pl=document.getElementById(obj.id).getPlaylist()
	var pln=pl.length;
	var j;
	if (i!=oplitem) {
		if (oplid!=-1) {
			document.getElementById('plitem'+oplid).className='';
		}
		for (j=i; j<pln; j++) {
			if (document.getElementById('plitem'+j)) {
				plitempsto=plitemps[j+1]*61;
				plitempsgo=true;
				plitempsv=document.getElementById('pldiv').scrollTop;
				document.getElementById('plitem'+j).className='plsel';
				oplid=j;
				break;
			}
		}
		oplitem=i;
	}
}
function plscroll() {
	if (plitempsgo && document.getElementById('pldiv')) {
		plitempsv=plitempsv+(plitempsto-plitempsv)/4;
		if (Math.abs(plitempsto-plitempsv)<1) {
			plitempsv=plitempsto;
			plitempsgo=false;
		}
		document.getElementById('pldiv').scrollTop=plitempsv;
	}
}
setInterval("plscroll()", 25);

function vid_init2(id, pars) {
	if (document.getElementById(id).getConfig) {
		clearInterval(vid_init_t[id]);
		vidt[id]=pars;
		document.getElementById(id).addModelListener('LOADED', 'vid_inditas');
		document.getElementById(id).addModelListener('STATE', 'vid_item');
	}
}
function vid_init(id, pars) {
	vid_init_t[id]=setInterval("vid_init2('"+id+"', '"+pars+"')", 10);
}

function myescape(s) {
	return s.replace(/%/g, '%25').replace(/\n/g, '%0A').replace(/\r/g, '%0D').replace(/\t/g, '%09').replace(/'/g, '%27').replace(/"/g, '%22').replace(/&/g, '%26');
}
kommnev='';
kommemail='';
kommtxt='';
function kommload(id, kod, kezd) {
	var e=document.getElementById(id);
	var nyelv=document.getElementById('nyelv').value;
	if (e.offsetHeight<10) {
		e.innerHTML='<div style="height: 40px;"></div>';
	}
	e.style.background='url(art/indicator-film.gif)';
	e.style.backgroundRepeat='no-repeat';
	e.style.backgroundPosition='right 7px';
	e.style.display='block';
	ajaxload({get:'ajax_komm.php',post:'id='+id+'&nyelv='+nyelv+'&webtv='+kod+'&kezd='+kezd+'&nev='+myescape(kommnev)+'&email='+myescape(kommemail)+'&txt='+myescape(kommtxt),
		onload:function(xmlHttpReq) {
			var x=xmlHttpReq.responseText.split('|');
			if (x.length==3) {
				if (x[1]=='') {
					e.innerHTML=x[0];
				} else {
					alert(x[1]);
				}
			} else {
				e.innerHTML='';
			}
			e.style.background='none';
		},
		onerror:function(){
			e.innerHTML='';
			e.style.display='none';
			e.style.background='none';
		}
	});
}

function szavaz(sz, ny) {
	var a=sz.split(':');
	if (a.length==3 && parseInt(a[1])>0 && parseInt(a[2])>=1 && parseInt(a[2])<=5) {
		ajaxload({get:'mod_szavaz.php?nyelv='+ny,post:'ajax='+sz,
			onload:function(xmlHttpReq) {
				var res=xmlHttpReq.responseText.split('|');
				if (res.length==4) {
					if (res[2]=='OK') {
						var tags=document.getElementsByTagName("div");
						for (var i=0; i<tags.length; i++) {
							if ((' '+tags[i].className+' ').indexOf('szavaz_'+a[0]+'_'+parseInt(a[1]))!=-1){
								tags[i].innerHTML = res[1];
							}
						}
					} else {
						alert(res[1]);
					}
				}
			}
		});
	}
}