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 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=600,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;

	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';
}