function SetSearch()
{	
	var inputFilter = document.getElementById('quickFilter');
	if (inputFilter == 'undefined' || inputFilter == null)
		return;
	
	inputFilter.focus();
		
	var buttonSearch = document.getElementById('odeslanoFiltr');
	
	inputFilter.onkeypress = function(e) 
	{
		e = e || window.event;
		var code = e.keyCode || e.which;

		if (code == 13)
		{
            buttonSearch.click();
            return false;            
        }	
    }
}

function DotazConfirm()
{
	email = document.getElementById('dotazEmail').value;
	
	if (email == '')
	{
		alert('Email musí být vyplněn!.');
		return false;
	}
	return true;
}

function Countprice(idPrice, idDiscount, idLabel, idDph, spocitej75)
{	
	var price = Number(document.getElementById(idPrice).value);	
	var discount = Number(document.getElementById(idDiscount).value);	
	var ret = Math.round(price/100*(100-discount));
	var dph = Number(document.getElementById(idDph).value);
	
	var s75 = '';
	if (spocitej75) 
		s75 = ', 75% - ' + Math.round(price*0.75/(100+dph)*100);
		
	document.getElementById(idLabel).innerHTML = ret + s75; 
}

function ObrOpen(id)
{
	myopen=window.open("/modules/eshop/ShowObr.php?uid="+id,"Gallery", "left=0,top=0,scrollbars=1,menubar=0,titlebar=0,location=0,directories=0,width=200,height=30");
}

function DotazProduktOpen(id, jazyk, id_user, id_dotazTyp)
{
	myopen=window.open("/modules/eshop/DotazProdukt.php?id_varianta="+id+"&languageAbbr="+jazyk+"&id_user="+id_user+"&id_dotazTyp="+id_dotazTyp,"DotazProdukt", "left=0,top=0,scrollbars=0,menubar=0,titlebar=0,location=0,directories=0,width=640,height=700");
}

function ObrResize()
{
	var pPic = document.getElementById("picture");
	
	//zjistime si velikosti obrazovky
	var sX = screen.width;
	var sY = screen.height-30;//windows programs bar
	
	var pX = pPic.width+35;
	var pY = pPic.height+90;
	
	if (pY>sY)
		pY = sY;
		
	if (pX>sX)
		pX = sX;
		
	window.resizeTo(pX, pY);
}

function potvrzeni()
{
	if (confirm('Opravdu smazat?')) {
		return(true);
	} else { return(false); }
}


function produktVariantaUpozorneni()
{
	window.alert('Pozor! tento produkt má¡ varianty, ujistěte se, že provedené změny nepotřebují­ upravit i jinde.');
}

function httpRequest(url, htmlId, textBoxId)
{

	//puceno od php.vrana :o)
	
	var OHttpRequest = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));

	var hledanyRetezec = document.getElementById(textBoxId).value;
	
    OHttpRequest.open('GET', url+'?wantedProduct='+hledanyRetezec, true);
    OHttpRequest.onreadystatechange= function () {processRequest(OHttpRequest, htmlId); } ;
    OHttpRequest.send(null);
    
}

function processRequest(OHttpRequest, htmlId)
{
    if (OHttpRequest.readyState == 4) 
    {
       if (OHttpRequest.status == 200) 
       {
       		var xmldoc = OHttpRequest.responseXML;
          	var root = xmldoc.documentElement;
      
          	var htmlElement = document.getElementById(htmlId);
          	var htmlKod ='';
          	
          	for (var iNode = 0; iNode < root.childNodes.length; iNode++) 
          	{
          		//tywe IE sux uplne nejvic... 5 let stara chyba stale neopravena http://support.microsoft.com/kb/276228, naprosta tragedie...
          		//htmlKod += '<option value="'+root.childNodes[iNode].getAttribute("uid")+'">'+root.childNodes[iNode].getAttribute("nazev")+'</option>';
          		htmlElement.options[iNode] = new Option(root.childNodes[iNode].getAttribute("nazev"), root.childNodes[iNode].getAttribute("uid"));
            }
            //alert(htmlKod);
            //htmlElement.innerHTML = ' ' + htmlKod;           
            //alert (htmlElement.innerHTML);
       }
       else
          alert('Nastal nějaký problém. Je to rozbitý. Zapsat si v jaké situaci toto nastalo a poslat mail tomu moulovi, co to naprogramoval!');
    }
}