// JavaScript Document
var marked_row = new Array;
var highlight_row = new Array;
var theDefaultColor = "white";
var thePointerColor = "#ff6600";
var theMarkColor = "#e46c0b";
var poradi=1;
var i = 1;
var sURL = unescape(window.location.pathname);
var Url = {
    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}
function dominnerText(node, text) {
while (node.hasChildNodes()) {
node.removeChild(node.firstChild);
}
node.appendChild(document.createTextNode(text));
}
function testRadio(){
document.getElementById("obj_mo").disabled = !(document.getElementById("obj_zd").checked)
}
function test2Radio(){
document.getElementById("obj_ud").disabled = !(document.getElementById("obj_stejna").checked)
document.getElementById("obj_um").disabled = !(document.getElementById("obj_stejna").checked)
document.getElementById("obj_up").disabled = !(document.getElementById("obj_stejna").checked)
}
function Toggle_info(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   if (visible) {
     obj.style.display="none";
   } else {
     obj.style.display="inline";
   }
}
function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   plusko=document.getElementById("plus" + item);
   if (visible) {
     obj.style.display="none";

     dominnerText(plusko, "zobrazit kolekce");
   } else {
     obj.style.display="inline";

     dominnerText(plusko, "srolovat zpět");
   }
}
function Toggle2(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   if (visible) {
     obj.style.display="none";
     eraseCookie("upresneni");
     document.getElementById("upr_t").value="Upřesnit";
   } else {
     obj.style.display="inline";
     createCookie("upresneni","1","365");
     document.getElementById("upr_t").value="Zavřít upřesnění";
   }
}
function Expand() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="block";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='grafika/left/zobrazeno.png' width='16' height='16' hspace='0' vspace='0' border='0'>";
   }
}

function Collapse() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     divs[i].style.display="none";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='grafika/left/zobrazit.png' width='16' height='16' hspace='0' vspace='0' border='0'>";
   }
}
function submitform()
{
document.zkosik.submit();
}
function submitform2()
{
  document.obj.submit();
}
function submitform3()
{
  document.abc.submit();
}
function submitform4()
{
  document.Odhlaseni.submit();
}
function ukas()
{
  document.ukaskosa.submit();
}
function klik(theAction,theZN,theKolek){
    if( theAction == 'click' ) {
window.parent.location="katalog/"+theZN+"/"+theKolek+".htm";
    }
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}
function createCookie(name,value,days,cesta) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function vypis(nazev,typ,cesta){
eraseCookie(nazev);
createCookie(nazev,typ,'10',cesta);
}
function prejditam(zn,druh,sex,pouziti){
window.parent.location="http://www.cfp.cz/dle-parametru/"+zn+"/"+druh+"/"+sex+"/"+pouziti+".htm";
}
function prejditam2(zn,druh,sex,pouziti,hledat){
   obj=document.getElementById(zn);
   obj2=document.getElementById(druh);
   obj3=document.getElementById(sex);
   obj4=document.getElementById(pouziti);
   obj5=document.getElementById(hledat)
   if (document.getElementById(hledat).value=="zadejte klíčové slovo"){
window.parent.location="http://www.cfp.cz/vyhledavani/"+obj.value+"/"+obj2.value+"/"+obj3.value+"/"+obj4.value+"/vse.htm";
   }
   else{
   vyhled=Url.encode(obj5.value);
window.parent.location="http://www.cfp.cz/vyhledavani/"+obj.value+"/"+obj2.value+"/"+obj3.value+"/"+obj4.value+"/"+vyhled+".htm";
   } 

}
function roll () {
document.forms.nasFormular.nasText.value = message.substring (i , message.length);
if (i != message.length) {
i++;
setTimeout ("roll()" , 50);
}
else {
i = 1;
setTimeout ("move()" , 500);
}
}
function zobraz_obr(idPrvku, adresa){
var el = document.getElementById ? document.getElementById(idPrvku) : false;
if(!el) return(false);
// adresa='./images/'<?echo $prod['Obr'];?>+poradi+'.jpg';
el.src = adresa;
poradi=poradi+1;
} 
function start (msg) {
message = msg;
document.write ('<form name="nasFormular" onSubmit="return false;"><input type="text" size=' + message.length + ' name="nasText" readonly></form>');
move();
}
function move () {
document.forms.nasFormular.nasText.value = message.substring (0 , i);
if (i != message.length) {
i++;
setTimeout ("move()" , 50);
}
else {
i = 1;
setTimeout ("roll()" , 500);
}
}
function zmenapozadi(idCko){
var bunka = document.getElementsByTagName(idCko);
bunka.style.backgroundimage='';
}
function setPointer(theRow, theRowNum, theAction, theCode,theZnacka,theKolek,theNazev) {
    if ( (typeof(theRow.style) == 'undefined')
    || (typeof(document.getElementsByTagName) == 'undefined') ) {
            return false;
    }

    var theCells = null;
    theCells = theRow.getElementsByTagName('td');
    var rowCellsCnt = theCells.length;
    var newColor = null;

    if( theAction == 'over' ) {
        if ( (typeof(highlight_row[theRowNum]) == 'undefined') || (!highlight_row[theRowNum]) ) {
            newColor = thePointerColor;
        }
        highlight_row[theRowNum] = true;
    }

    if( theAction == 'out' ) {
        if ( highlight_row[theRowNum] ) {
            if ( marked_row[theRowNum] ) {
                newColor = theMarkColor;
            } else {
                newColor = theDefaultColor;
            }
        }
        highlight_row[theRowNum] = null;
    }

    if( theAction == 'click' ) {
window.parent.location="http://www.cfp.cz/katalog/"+theZnacka+"/"+theKolek+"/"+theCode+".htm";
    }

    if (newColor) {
        var c = null;
        for (c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        }
    }
    }

