function rx(){
	if (!window.XMLHttpRequest){
		try{ return new ActiveXObject("MSXML3.XMLHTTP") }catch(e){}
		try{ return new ActiveXObject("MSXML2.XMLHTTP.3.0") }catch(e){}
		try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
		try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
		throw new Error("Could not find an XMLHttpRequest alternative.")
	}else{
		return new XMLHttpRequest();
	}
}

function u_so(a){
	$("i_text").style.display="block";
	$("i_text").innerHTML=a;
	//$("lightboxImage").style.display="none";
}

function X(a,b){
	$("_0"+a).style.textDecoration=$("_1"+a).style.textDecoration=(!b?"none":"underline");
}

function u_s(id){
	try{
		light_glob.start({"href":"dat", "title":"", "rel":"lightbox"});
		req("/_uinfo.php?id="+id,u_so);
		$("outerImageContainer").style.width="350px";
		$("outerImageContainer").style.height="170px";
		$("loading").style.display="none";
	}catch (e){
		alert(e);
	}
}

function req(url,callbackFunction){
	req(url,callbackFunction,"");
}

function req(url,callbackFunction,post){
	try{
		var request=rx();
		if (request==null)
			return false;
		
		if (post==null || post==undefined)
			post='';
		
		request.open((post==""?"GET":"POST"),url,true);
		
		request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		if (post!=''){
			request.setRequestHeader("Content-length", post.length);
			request.setRequestHeader("Connection", "close");
		}
		
		request.onreadystatechange=function(){
			if (request.readyState==4 && request.status==200)
				if (request.responseText)
					callbackFunction(request.responseText);
		};
		
		request.send(post);
		/*
		if (post==''){
			request.send(\"\");
		}else{
			request.send(post);
		}
		*/
	  return true;
	}catch (e){
		alert('req: '+e);
	}
	return false;
}

function rel(a){
	if (a==0)
		req("/_zob.php?rel",rel);
	else
		setTimeout("rel(0)",20000);
}

function trim(a){
	return a.replace(/^\s\s*/,'').replace(/\s\s*$/,'');
}

window.onload=function(){
	//program
	if (typeof(r_w)!="undefined" && r_w){
		var io=(""+document.location).indexOf("#");
		if (io>0){
			try{
				io=parseInt((""+document.location).substring(io+4),10);
				zob(io);
			}catch (e){
			}
		}
	}
	
	setTimeout("rel(0)",20000);
}

function pridat_cm(a){
	if (a==0){
		var a=_$("new_cm"),
			b=_$("p_but");
		a.className=(a.className=="no"?"t_div":"no");
		if (a.className=="no"){
			b.style.width="auto";
			b.value="pridať";
			b.style.background="#FFFFFF";
		}else{
			b.style.width="20px";
			b.value="";
			b.style.background="#ffffff url(/i/close.gif) center center no-repeat";
		}
	}else{
		var a=_$("novy_komentar");
		a.value=trim(a.value);
		if (a.value.length<4){
			alert("Komentár nemôže byť prázdny");
			return;
		}else if (a.value.length>2000){
			alert("Komentár nemôže mať viac ako 2000 znakov (teraz "+a.value.length+")");
			return;
		}
		
		a.disabled=true;
		a.style.backgroundColor='#F0F0F0';
		a.style.color='#101010';
		_$("p_but").disabled=true;
		_$("s_but").disabled=true;
		_$("load_s").style.display="inline";
		
		req("/_zob.php?id="+last_zob,pridat_ok,"add="+pe(a.value));
		//req("/zob.php?id="+last_zob,zob_ok);
	}
}

//escape
function pe(a){
	a=a.replace(/%/g,"%25");
	a=a.replace(/&/g,"%26");
	return a;
}

function pridat_ok(a){
	zob_ok(a);
	/*
	pridat skok na poskedny komentar
	*/
}

//zobrazenie programu
var last_zob=0;
			
function zob_ok(a){
	a=a.split("|***|");
	_$("o_b"+a[0]).innerHTML=a[1];
	last_zob=a[0];
	
	document.location='#loc'+a[0];
	//alert(1);
	try{
		Lightbox.updateImageList();
	}catch (e){
	}
}

function zob(a){
	zob_(a,true);
}

function zob_(a, load){
	if (last_zob==a)
		a=-1;
				
	for (var i=0;i<r_w.length;i++){
		_$("o_r"+r_w[i]).className=(r_w[i]==a?"tr":"no");
		try{
			_$("o_f"+r_w[i]).className=(r_w[i]==a?"no":"dic");
		}catch (e){
		}
		_$("o_b"+r_w[i]).innerHTML="";
	}
					
	if (a==-1){
		last_zob=0;
		return;
	}
	last_zob=a;
				
	if (load)
		_$("o_b"+a).innerHTML="<img src='/i/22-0.gif' style='float: none; margin: auto; display: block;' alt='' />";
	
	//document.location='#loc'+a;
	req('/_zob.php?id='+a,zob_ok);
}

//music
var orig_mp3="";
function m(a){
/*
	try{
		var x=window.parent.hore.document.obj;
		alert(x);
		if (a)
			x.Play();
		else
			x.Stop();
	}catch (e){
		alert(e);
	}
*/
	if (orig_mp3=="")
		orig_mp3=window.parent.hore.document.location;
		
	var url=(a?orig_mp3:"about:blank");
	window.parent.hore.document.location=url;
}

function html(a){
	a=a.replace(/</g,"&lt;");
	a=a.replace(/>/g,"&gt;");
	a=a.replace(/"/g,"&quot;");
	a=a.replace(/'/g,"&#39;");
	return a;
}

//stratene heslo
function lost_ok(a){
	a=a.split("*");
	_$("lost_msg").innerHTML=a[1];
	if (a[0]=="1")
		_$("lost_in").innerHTML="";
}

function lb(a){
	var x=[_$("log_b"),_$("lost_pwd")];
	if (a==1)
		x=x.reverse();
	
	x[0].style.display="none";
	x[1].style.display="block";
}

function _$(a){
	var tmp=document.getElementById(a);
	return (tmp?tmp:document.getElementsByName(a)[0]);
}