function findObj(n, d) {  
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} 
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); 
  if(!x && document.getElementById) x=document.getElementById(n); return x; 
} 


function replaceText(node, text)
{
    while (node.hasChildNodes()) {
        node.removeChild(node.firstChild);
    }
    node.appendChild(document.createTextNode(text));
}


function innerXHTML(node, html)
{
    while (node.hasChildNodes()) {
        node.removeChild(node.firstChild);
    }
    
    _doInnerXHTML(node, html)
}


function _doInnerXHTML(node, html)
{
    /* Pokud je v textu značka */
    if ((index = html.indexOf('<')) != -1) {
        /* Pokud je před značkou ještě nějaký text */
        if (index != 0) {
            text = html.substring(0, index);
            node.appendChild(document.createTextNode(text));
            html = html.substr(index);
//            alert('text:"'+text+'" html:"'+html+'"');
        }

        /* Teď by měl text začínat "<" */
        if ((index = html.indexOf('>')) != -1) {            
            /* Do prom. tag si uložim celou značku bez špič. závorek */
            tag = html.substring(1, index);
            /* V textu nechám zbytek po tagu */
            html = html.substr(index + 1);
            
//            alert('tag:"'+tag+'" html:"'+html+'"');
            /* Pokud jde o ukončovací tag */
            if (tag.charAt(0) == '/') {
                endTag = true;
                if (html.length > 0) {
                    _doInnerXHTML(node.parentNode, html);
                }
            } else {
                endTag = false;
                /* Pokud jde o prázdný element */
                if (tag.charAt(tag.length - 1) == '/') {
                    empty = true;
                    tag = tag.substr(0, tag.length - 1);
                /* Pokud jde o počáteční tag */
                } else {
                    empty = false;
                }

                /* Rozdělim na části oddělené mezerou */
                /* Tohle je chyba - mezery můžou být i v hodnotách atributů.
                Ale zatim se mi nedaří to udělat líp.
                */
                tagParts = tag.split(/\s+/);
                
                if (tagParts[tagParts.length - 1] == "") {
                    tagParts.pop();
                }
            
                /* Vytvořím požadovaný element (na atributy zatím dlabu) */
                newElement = node.appendChild(document.createElement(tagParts[0]));
                
                /* Naplním element atributy */
                for (i=1; i<tagParts.length; i++) { // Projdeme všechny prvky kromě názvu
                    attrib = tagParts[i]
                    attrName = attrib.replace(/^([^=]+)(=.+)?$/, "$1");
                    if (attrib.indexOf("=") != -1) {
                        attrValue = attrib.replace(/^[^=]+="?([^"]*)"?$/, "$1");
                    } else {
                        attrValue = "";
                    }
                    newElement.setAttribute(attrName, attrValue);
//                    alert('name:"'+attrName+'" value:"'+attrValue+'"');
                }

                /* Pokud ještě zbývá nějaký text */
                if (html.length > 0) {
                    if (empty) {
                        _doInnerXHTML(node, html);
                    } else {
                        _doInnerXHTML(newElement, html);
                    }
                }
            }
        }
    } else {
        /* Pokud ještě v textu zbyl nějaký text */
        if (html.length > 0) {
            node.appendChild(document.createTextNode(html));
        }
    }

}

function number_format(  number,  laenge, sep, th_sep ) {

  number = Math.round( number * Math.pow(10, laenge) ) / Math.pow(10, laenge);
  str_number = number+"";
  arr_int = str_number.split(" ");
  if(!arr_int[0]) arr_int[0] = "0";
  if(!arr_int[1]) arr_int[1] = "";
  if(arr_int[1].length < laenge){
    nachkomma = arr_int[1];
    for(i=arr_int[1].length+1; i <= laenge; i++){  nachkomma += "0";  }
    arr_int[1] = nachkomma;
  }
  if(th_sep != "" && arr_int[0].length > 3){
    Begriff = arr_int[0];
    arr_int[0] = "";
    for(j = 3; j < Begriff.length ; j+=3){
      Extrakt = Begriff.slice(Begriff.length - j, Begriff.length - j + 3);
      arr_int[0] = th_sep + Extrakt +  arr_int[0] + "";
    }
    str_first = Begriff.substr(0, (Begriff.length % 3 == 0)?3:(Begriff.length % 3));
    arr_int[0] = str_first + arr_int[0];
  }
  return arr_int[0]+sep+arr_int[1];
}




	function get_radio_value (radio_array) {
	
		var i;
		for (i = 0; i < radio_array . length; ++ i)
		if (radio_array [i] . checked)
			return radio_array [i] . value;
			return null;

	}


function searchTest() {
	if (document.vyhledavani.search.value.length<3) {
		alert("Řetězec musí obsahovat alespoň tři znaky");
		document.vyhledavani.search.focus();
		return false;
	}
	if (document.vyhledavani.search.value=="hledané zboí") {
		alert("Do vyhledávacího pole zadejte název hledaného zboí");
		document.vyhledavani.search.focus();
		return false;
	}		
	return true;
}

function openOdkazForm(produkt) {
	window.open("/odkaz.php?produkt="+produkt,"itekodkaz","width=400,height=385,status=no,scrollbars=no,resizable=no,toolbar=no,menubar=no");
}

function openDostupnostForm(produkt) {
	window.open("/dostupnost.php?produkt="+produkt,"itekdostupnost","width=400,height=505,status=no,scrollbars=no,resizable=no,toolbar=no,menubar=no");
}

function openInfoWindow(typ,id) {
	window.open("/infopopup.php?typ="+typ+"&id="+id,"itekinfo","width=400,height=420,status=no,scrollbars=no,resizable=no,toolbar=no,menubar=no");
}

function openPoslatKosik() {
	window.open("/poslatkosik.php","itekposlatkosik","width=400,height=420,status=no,scrollbars=no,resizable=no,toolbar=no,menubar=no");
}


function addBookmark(title,url) { 
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) { 
window.external.AddFavorite( url, title); 
} else if( window.opera && window.print ) { 
return true; 
} 
} 

function addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory){ var msg="Přidání vyhledávacího pluginu selhalo - "; if((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")){ if(engineURL == null || engineURL == ""){ alert(msg + "nebyla zadána jeho URL."); return false; } if(iconURL == null || iconURL == ""){ alert(msg + "nebyla zadána URL ikony."); return false; } if(engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1){ alert(msg + "nebyla zadána platná URL."); return false; } if(iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1){ alert(msg + " nebyla platné URL ikony."); return false; } if(suggestedTitle == null) suggestedTitle = ""; if(suggestedCategory == null) suggestedCategory = ""; window.sidebar.addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory); }else{ alert("Vá prohlíeč nepodporuje tuto funkci. Zkuste Firefox."); } return false; }


function rozbalovatko() {
 	var myStretch = document.getElementsByClassName('db-know-nadpis');
 	var myStretcher = document.getElementsByClassName('db-know-detail');
 	myAccordion = new fx.Accordion(myStretch, myStretcher, {opacity: true});
    myAccordion.showThisHideOpen(myStretcher[5]); 
}

 window.onload = function() {
 



 	 }

function createControl(DivID, CLSID, ObjectID, WIDTH, HEIGHT, URL, WMODE, MENU, QUALITY) {
  var d = document.getElementById(DivID);
  d.innerHTML = '<object classid="' + CLSID + '" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + WIDTH + '" height="' + HEIGHT + '" align="middle">'
	+ '<param name="allowScriptAccess" value=".itek.cz" />'
	+ '<param name="wmode" value="' + WMODE + '" />'
	+ '<param name="menu" value="' + MENU + '" />'
	+ '<param name="movie" value="' + URL + '" /><param name="quality" value="' + QUALITY + '" /><param name="bgcolor" value="#ffffff" /><embed src="' + URL + '" quality="' + QUALITY + '" bgcolor="#ffffff" width="' + WIDTH + '" height="' + HEIGHT + '" align="middle" allowScriptAccess="sameDomain" wmode="' + WMODE + '" menu="' + MENU + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
	+ '</object>';
}

function odeslatDotazTest(formular) {
 if (document.dotaz.dotaz.value=="") {
   alert("Zadejte Vá dotaz!");
   return false;
  } 
  if (document.dotaz.mail.value=="") {
   alert("Zadejte email!");
   return false;
  }
   if (!document.dotaz.mail.value.match(/^[A-Za-z0-9_\.\-]+@[A-Za-z0-9_\.\-]+\.[A-Za-z0-9]+$/)) {
   alert("Zadejte emailovou adresu v PLATNÉM formátu !");
   return false;
  }

}

function hlidacTest(formular) {
  if (document.hlidac.email.value=="") {
   alert("Zadejte email!");
   return false;
  }
   if (!document.hlidac.email.value.match(/^[A-Za-z0-9_\.\-]+@[A-Za-z0-9_\.\-]+\.[A-Za-z0-9]+$/)) {
   alert("Zadejte emailovou adresu v PLATNÉM formátu !");
   return false;
  }
}


var TRKwinsize;
if (document.documentElement && document.documentElement.clientWidth)
	TRKwinsize = document.documentElement.clientWidth;
else if (document.body && document.body.clientWidth)
	TRKwinsize = document.body.clientWidth;
else
	TRKwinsize = window.innerWidth;
	
	
function ShowHide(id) {
 /*   obj = document.getElementsByTagName("div");
    if (obj[id].style.visibility == 'visible'){
    obj[id].style.visibility = 'visible'; // zde mozno skryt
    }
    else {
    obj[id].style.visibility = 'visible';
    } */
}


function zmenaDodaciAdresa() {
  obj = document.getElementsByTagName("div");
  obj2 = document.getElementsByTagName("fieldset");
  if (document.kosikform.stejnajakofakturacni.checked) {
	obj["hideit"].style.visibility = 'visible';
	obj2["sizeit"].style.height = 'auto';
  }
  else {
	obj["hideit"].style.visibility = 'hidden';
	obj2["sizeit"].style.height = '15px';
  }  
}

function zmenaNakupujiJako() {
	obj = document.getElementsByTagName("fieldset");
	if (get_radio_value(document.kosikform.selecttyp)=="nepodnikatel") {
		obj["cust-person"].style.display = 'block';
		obj["cust-firm"].style.display = 'none';
	}
	if (get_radio_value(document.kosikform.selecttyp)=="firma") {
		obj["cust-person"].style.display = 'none';
		obj["cust-firm"].style.display = 'block';
	}
 
}

function openCompare() {
	window.open("/compare.php","itekcompare","width=780, height=680, scrollbars=yes, resizable=yes");
	return false;
}

function openRadce(id) {
	window.open("/radce/"+id,"itekradce","width=780, height=680, scrollbars=yes, resizable=yes");
	return false;
}