
function PopupAnketa() {
       winOpen("anketa.asp", 300, 300, "Anketa", "no");
}

function getFocus(){
	if (document.forms[0] != null){	for (i=0;i<document.forms[0].elements.length;i++){	if (document.forms[0].elements[i].type!='hidden') {document.forms[0].elements[i].focus(); break;}}}
}

function winOpen(url,w,h, winname,scroll) {
	if (scroll!='no')scroll='yes';
	window.open(url, winname, "toolbar=no,location=no,scrollbars="+scroll+",directories=no,status=no,menubar=no,resizable=yes,width="+w+",height="+h+",left=100,top=100");
}

function closeAndOpenerHref(url){
	window.opener.location.href=url;
	self.close();
}


function vlozText(val){
	if (val == 'Hledej zboží') document.HledejZbozi.search.value = '';
	if (val == '') document.HledejZbozi.search.value = 'Hledej zboží';
}

function submitFormSearch(){
	thisForm = eval("document.HledejZbozi")
	if(thisForm.search.value!='Hledej zboží'){
		if (thisForm.search.value.length<3){
			alert("Minimální počet znaků pro hledání jsou 3!")
		}else{
			thisForm.submit()
		}
	}
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}


kusu=0
function doKosiku(idzbozi){
	thisForm = eval("document.zbozi")
	kusu = eval("thisForm.ks"+idzbozi+".value")
	vazene = eval("thisForm.vazene"+idzbozi+".value")
	kusu = replace(kusu,',','.')
	if (parseFloat(kusu)){ 
		if (kusu>0){
			if (vazene==1){
				kusu = Math.round(kusu*10)/10
			}else{
				kusu = Math.round(kusu)
			}
			winOpen('addkosik.asp?add='+idzbozi+'&kusu1='+kusu+'&idZbozi1='+idzbozi+'&PocetPolozek=1',200,200, 'addkosik','no')
		}
	}
}

specKusu=0
function doSpecKosiku(idzbozi){
	thisForm = eval("document.zbozi");
	specKusu = eval("thisForm.ks"+idzbozi+".value");
	specKusu = replace(specKusu,',','.');
	if (parseFloat(specKusu)){ 
		if (specKusu>0) {
			specKusu = Math.round(specKusu);
			winOpen('addSpecKosik.asp?add='+idzbozi+'&kusu1='+specKusu+'&idZbozi1='+idzbozi+'&PocetPolozek=1',200,200, 'addSpecKosik','no');
		}
			
	}
}


function Oblibene(idzbozi,akce){
	winOpen('addoblibene.asp?'+akce+'='+idzbozi,200,200,'oblibene','no')
}
