var obraz=null;
function zvetsi(base,cesta,titul,alt,x,y,jazyk) {
	var sb="no";
	if (x>(screen.width-50)) {
		x=(screen.width-50);
		sb="yes";
	}
	if (y>(screen.height-50)) {
		y=(screen.height-50);
		sb="yes";
	}
	var winl = (screen.width-x)/2;
	var wint = (screen.height-y)/2;
	obraz=window.open("/zvetsi_nav.php?nazev="+titul+"&cesta="+cesta+"&alt="+alt+"&jazyk="+jazyk, "obraz", "width="+(x)+", height="+(y)+", top="+wint+", left="+winl+", menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars="+sb+", resizable=yes");
	obraz.window.focus();
}
var vokno=null;
function okno(prm, x, y) {
	var sb="yes";
	if (!x) var x=500;
	if (!y) var y=600;
	if (x>(screen.width-100)) {
		x=(screen.width-100);
		sb="yes";
	}
	if (y>(screen.height-100)) {
		y=(screen.height-100);
		sb="yes";
	}
	var winl = (screen.width-x)/2;
	var wint = (screen.height-y)/2;
	vokno=window.open("/okno.php"+prm, "vokno", "width="+(x)+", height="+(y)+", top="+wint+", left="+winl+", menubar=no, directories=no, toolbar=no, location=no, status=no, scrollbars="+sb+", resizable=yes");
	vokno.window.focus();
}

function chtext(prm) {
	var ch = document.getElementById(prm);
	ch.innerHTML="Data budou aktualizována po znovu načtení stránky.";
}

function chboxtd(prm) {
	var ch = document.getElementById(prm);
	if (ch.checked) ch.checked=false;
	else ch.checked=true;
}

function pozor() {
	var ch = document.getElementById("pozor");
	if (!ch) return;
	var winW = document.documentElement.clientWidth;
	var winH = document.documentElement.clientHeight;
	var x = winW/2-100;
	var y = winH/2-150;
	ch.style.width = '200px';
	ch.style.padding = '20px';
	ch.style.border = '5px solid Red';
	ch.style.position = 'absolute';
	ch.style.top = y+'px';
	ch.style.left = x+'px';
	ch.onclick='pozoroff();';
	var zavripozor = setTimeout("pozoroff()", 2500);
}
function pozoroff() {
	var ch = document.getElementById("pozor");
	ch.style.display = 'none';
}
function SearchCheck() {
	var ch = document.getElementById("search");
	if (ch.value.length<3) {
		alert('Pro vyhledávání zadejte alespoň 3 znaky.');
		return false;
	}
	if (ch.value=='Hledat') return false;
}

function OrderFormCheck() {
	var chyby='';
	var pro=document.forms['order'];

	if (pro['contname'].value.length<3) {chyby+='Vyplňte své jméno.\n';pozorpole(pro['contname']);}
	else pohovpole(pro['contname']);
	if (pro['conttel'].value.length<9) {chyby+='Vyplňte svůj telefon.\n';pozorpole(pro['conttel']);}
	else pohovpole(pro['conttel']);

	if (chyby=='') return true;

	alert(chyby);
	return false;
}
function pozorpole(prom) {
 	prom.style.backgroundColor='red';
}
function pohovpole(prom) {
 	prom.style.backgroundColor='#ccffcc';
}
function OrderTable(prm) {
	//var frm=document.forms['order'];
	alert(prm);
}
function OrderTableOn(prm) {
	var ch = document.getElementById(prm);
	ch.style.display='inline';
}
function OrderTableOff(prm) {
	var ch = document.getElementById(prm);
	ch.style.display='none';
}
function sendRequest(data,kam,url,method,mode,header){
    var objhttp=(window.XMLHttpRequest)?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
    if(!objhttp){alert('Vas prohlizec nepodporuje pozadovane funkce.');return;}
    if(!url) url='helper.php';
    if(!data) data='';
    if(!method) method='POST';
    if(!mode) mode=true;
    if(!header) header='Content-Type:application/x-www-form-urlencoded; charset=windows-1250';

    objhttp.open(method,url,mode);
    objhttp.setRequestHeader(header.split(':')[0],header.split(':')[1]);
    objhttp.onreadystatechange=function() {
        if (objhttp.readyState==4 && objhttp.status==200) {
			var back=objhttp.responseText;
			writeContents(back, kam);
		}
    }
    objhttp.send(data);
    //loading();
}
function writeContents(co, kam) {
    if (co) kam.innerHTML=co;
	else kam.innerHTML+="Bohužel, problém s daty.";
	//loadingOff();
}
function loading() {
	var ex=document.getElementById('loading');
	if (!ex) {
		var add = "<img src='/files/loader.gif' width='66' height='66' id='loading' alt='nahrávám..' />";
		document.getElementById('cs').innerHTML=add+document.getElementById('cs').innerHTML;
		var ex=document.getElementById('loading');
	}
	var winW = document.documentElement.clientWidth;
	var winH = document.documentElement.clientHeight;
	var x = winW/2-33;
	var y = winH/2-33;
	ex.style.display = 'block';
	ex.style.position = 'absolute';
	ex.style.top = y+'px';
	ex.style.left = x+'px';
}
function loadingOff() {
	var ex=document.getElementById('loading');
	ex.style.display = 'none';
}
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);
}
var dfontsize=12;
function pismoB() {
	dfontsize=dfontsize+1;
	document.body.style.fontSize=dfontsize+'px';
	createCookie('dfont', dfontsize, 7);
}
function pismoS() {
	dfontsize=dfontsize-1;
	document.body.style.fontSize=dfontsize+'px';
	createCookie('dfont', dfontsize, 7);
}
function pismoN() {
	dfontsize=12;
	document.body.style.fontSize=dfontsize+'px';
	createCookie('dfont', dfontsize, 7);
}
function pismoCh() {
	var dfontc=readCookie('dfont');
	if (dfontc) {
		dfontsize=parseInt(dfontc);
		document.body.style.fontSize=dfontsize+'px';
	}
}

if (window.attachEvent) {
	window.attachEvent('onload', pozor);
	window.attachEvent('onload', pismoCh);
}
else {
	window.onload = pozor;
	window.onload = pismoCh;
}

function remN() {
	var prm=document.getElementById("remname");
	var prm2=document.getElementById("j");
	if (prm.checked) {
		if (prm2.value!='') createCookie("aol", prm2.value, 360);
	}
	else eraseCookie("aol");
}
function remH() {
	var prm=document.getElementById("rempass");
	var prm2=document.getElementById("h");
	if (prm.checked) {
		if (prm2.value!='') createCookie("aop", prm2.value, 360);
	}
	else eraseCookie("aop");
}
function remcheck() {
	var a=readCookie("aol");
	if (a) {
		var prm=document.getElementById("j");
		var prm2=document.getElementById("remname");
		prm.value=a;
		prm2.checked=true;
	}
	var b=readCookie("aop");
	if (b) {
		var prm=document.getElementById("h");
		var prm2=document.getElementById("rempass");
		prm.value=b;
		prm2.checked=true;
	}
}
function remgone() {
	remN();
	remH();
}
function vote(anid, anidm) {
	var a=readCookie("kakuno"+anid);
	if (!a) {
		var data="vote="+anid+"&pos="+anidm;//"ProdCheck=1&title="+title+"&category="+category.value+"&id="+id.value;
		sendRequest(data, document.getElementById("anketa"));
		createCookie("kakuno"+anid, "1", 30);
	}
	else {
		alert("Můžete hlasovat pouze jednou.");
	}
}
function ukaz(prm) {
	var mn=prm.childNodes[1];
	if (mn.tagName != 'DIV') mn=prm.childNodes[0];
	mn.style.display='block';
}
function schov(prm) {
	var mn=prm.childNodes[1];
	if (mn.tagName != 'DIV') mn=prm.childNodes[0];
	mn.style.display='none';
}
function WindowResize() {
	var winH;
	var pH;
	pH=screen.height-220;
	if(!(winH = window.innerHeight)) {
	  if(!(winH = document.documentElement.clientHeight)) {
	    winH = document.body.clientHeight;
	  }
	}
	//alert(winH);
	if (winH <= pH) page.style.height = pH+'px';
}
sfHover = function() {
	sfTemplate("menu");
}
sfHover2 = function() {
	sfTemplate("menujr");
}
function sfTemplate(menuname) {
	if (!document.getElementById(menuname)) return;
	var sfEls = document.getElementById(menuname).getElementsByTagName("li");
	for (var i = 0; i < sfEls.length; i++) {
		if (sfEls[i].id == "search") continue;
		sfEls[i].onmouseover = function() {
			this.className += " sfhover";
		}
		sfEls[i].onmouseout = function() {
			this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) { // only supported by IE and only needed by IE!!!!! SERENDIPITY
	window.attachEvent("onload", sfHover);
	window.attachEvent("onload", sfHover2);
}
function selectorWebsiteURL(obj){
	if (obj.selectedIndex>0){
		window.open(obj.options[obj.selectedIndex].value);
	}
	obj.selectedIndex=0;
}
