function popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=320,height=240,screenX=150,screenY=150,top=150,left=150');
}

function TextWindow(url, w, h) {
  window.open(url,'TextWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=' + w + ',height=' + h + ',screenX=150,screenY=150,top=150,left=150');
}


function tree_zmena(objLI, objIMG){
	objLI = document.getElementById(objLI);
	objIMG = document.getElementById(objIMG);
	if (objIMG.className == 'plus') {
		objIMG.className = 'minus';
		objLI.style.display = 'block';
	} else {
		objIMG.className = 'plus'
		objLI.style.display = 'none';
	}
}

function vyrobce(formular){
	window.location.href = document.form2.search.options[formular.selectedIndex].value;
}

function popupCalc(url) {
	window.open(url,'popupCalc','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=650,height=500,screenX=100,screenY=100,top=100,left=100');
}

function popupSplatky(url) {
	window.open(url,'popupSplatky','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=500,screenX=50,screenY=50,top=50,left=50');
}


var request = null;

function createRequest(){
	try{
		request = new XMLHttpRequest();
	}catch (trymicrosoft){
		try{
			request = new ActiveXObject("Msxml2.XMLHTTP");
		}catch (othermicrosoft){
			try{
				request = new ActiveXObject("Microsoft.XMLHTTP");
			}catch (failed){
				request = null;
			}
		}
	}
	if (request == null){
		alert("Váš prohlížeč nepodporuje technologii AJAX!");
	}
}

function setHodnoceni(hod, produkt){
	var url = "/hodnoceni-hlas.php?hod=" + hod + "&id=" + produkt;
	url = url + "&time=" + new Date().getTime();
	createRequest();
	request.open("GET", url, true);
	request.onreadystatechange = updHodnoceni;
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=Windows-1250');
	request.send(null);
}

function updHodnoceni(){
	if (request.readyState == 4){
		if(request.status == 200) {
			var html = request.responseText;
			document.getElementById("hodnoceni").innerHTML = html;
		}
	}
}


function setCena(id){
	var url = "/changecena.php?id=" + id;
	url = url + "&time=" + new Date().getTime();
	createRequest();
	request.open("GET", url, true);
	request.onreadystatechange = updCena;
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=Windows-1250');
	request.send(null);
}

function updCena(){
	if (request.readyState == 4){
		if(request.status == 200) {
			var html = request.responseText;
			if (html != '')	{
				var cena = html.split("|");
				document.getElementById("cena").innerHTML = cena[0];
				document.getElementById("cenabezdph").innerHTML = cena[1];
			}
		}
	}
}


function closepopup(){
	var obj = document.getElementById('zoom');
	obj.style.display = 'none';
	var bigimg = document.getElementById('zoomimg');
	bigimg.src = '/images/loading.gif';
}

function zoompopupWindow(img, w, h){
	var scrWidth = document.body.clientWidth;
	var scrHeight = document.body.clientHeight + 35;
	var brWidth = document.documentElement.clientWidth;
	var brHeight = document.documentElement.clientHeight;
	if (scrHeight < brHeight) scrHeight = brHeight;

	var zoom = document.getElementById('zoom');
	zoom.style.width = scrWidth + 'px';
	zoom.style.height = scrHeight + 'px';

	var bigimg = document.getElementById('zoomimg');
	bigimg.src = img;

	var div = document.getElementById('zoomdiv');
	div.style.width = w + 'px';
	div.style.height = (h + 20) + 'px';

	var obj = document.getElementById('zoom');
	obj.style.display = 'block';

	if (typeof(window.pageXOffset) == 'number'){
		var scrollX = window.pageXOffset;
		var scrollY = window.pageYOffset;
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
		var scrollX = document.body.scrollLeft;
		var scrollY = document.body.scrollTop;
	} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)){
		var scrollX = document.documentElement.scrollLeft;
		var scrollY = document.documentElement.scrollTop;
	}
	if (typeof(scrollX) != 'number') scrollX = 0;
	if (typeof(scrollY) != 'number') scrollY = 0;

	var x = (brWidth - div.offsetWidth) / 2;
	var y = (brHeight - div.offsetHeight) / 2;
	if (x < 0) x = 0;
	if (y < 0) y = 0;

	div.style.left = scrollX + x + 'px';
	div.style.top = scrollY + y + 'px';
}

function addzoom(){
	document.getElementById('zoom-block').innerHTML =
	'<div id="zoom" onclick="closepopup(); return false;">' +
	'<div id="zoomdiv" class="detail">' +
	'<img id="zoomimg" src="/images/loading.gif" alt="loading" />' +
	'<div class="close"><a href="#" onclick="closepopup(); return false;">Zavřít</a></div>' +
	'</div>' +
	'</div>';
}

function addzoom18(){
	document.getElementById('zoom-block').innerHTML =
	'<div id="zoom">' +
	'<div id="zoomdiv">' +
	'<img id="zoomimg" src="/images/loading.gif" />' +
	'<div class="text">' +
	'<h4>Upozornění!</h4>' +
	'<p><strong>Chystáte se vstoupit na stránky obsahující materiály s erotickou nebo sexuálně orientovanou tématikou.</strong></p>' +
	'<p>Jsem dospělý ve věku 18 let nebo starší.</p>' +
	'<p>Sexuálně orientované materiály mne neurážejí, nepohoršují ani mne nijak nohrožují a na tyto stránky vstupuji dobrovolně.</p>' +
	'<p>Neposkytnu ani svým chováním přímo či nepřímo neumožním přístup k obsahu těchto stránek osobám mladším 18 let.</p>' +
	'<a href="#" onclick="closepopup18(); return false;" class="svstup" title="Vstoupit na stránky"><img src="/images/18-vstup.gif" width="160" height="50" alt="Vstoupit na stránky" /></a>' +
	'<a href="http://www.google.com" class="odejit" title="Opustit stránky"><img src="/images/18-odejit.gif" width="160" height="50" alt="Opustit stránky" /></a>' +
	'</div>' +
	'</div>' +
	'</div>';
	zoompopupWindow('/images/18.gif', 580, 290);
}

function closepopup18(){
	addzoom();
	closepopup();
	request = null;
	createRequest();
	request.open("GET", '/vstup18.php', true);
	request.send(null);
}


function box_show(objname){
	var obj = document.getElementById(objname);
	if ((obj.style.display == 'block') || (obj.style.display == '')){
		obj.style.display = 'none';
		var stav = 1;
	} else {
		obj.style.display = 'block';
		var stav = 0;
	}

	var url = "/setshowbox.php?obj=" + objname + "&stav=" + stav + "&time=" + new Date().getTime();
	createRequest();
	request.open("GET", url, true);
	request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=Windows-1250');
	request.send(null);
}


function setmnozstvi(objname, zmena){
	var obj = document.getElementById(objname);
	var pocet = (obj.value * 1);
	pocet = pocet + zmena;
	if (pocet <= 0) pocet = 1;
	if (pocet > 100000) pocet = 100000;
	obj.value = pocet;
}


function kom_check(){
	var s1 = 'form' + 'uláře';
	var s2 = 'potv' + 'rzení';
	return(s1 + ' ' + s2);
}

