
//zobrazeni obrazku v novem okne
var newWindow = null
function makeNewWindow(name,width,height) {
    var rozmery = null

    rozmery = "HEIGHT=" + height + ",WIDTH=" + width
    newWindow = window.open("","",rozmery)
    if (newWindow != null) {

        var newContent = "<HTML><HEAD><TITLE>Veselyklaun.cz - kliknutim na obrazek okno zavrete</TITLE></HEAD>"
        newContent += "<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 BGCOLOR='#C0C0CC'>"
        newContent += "<IMG SRC=" + name + " BORDER=0 ALIGN='CENTER' TITLE='Kliknutim na obrazek okno zavrete' VSPACE=0 onclick='self.close()'>"


        newContent += "</BODY></HTML>"
        newWindow.document.write(newContent)
        newWindow.document.close()
    }
}


//schova element podle id a zapise hodnotu do cookie
function schovatCook(i,name){
    if (i.style.display=='none'){
        i.style.display='';
        nastavCookie(name);
    }
    else {
        i.style.display='none'
        nastavCookie(name);
    }
}

//pro inicializaci, precte cookie a nastavi podle ni styl
function schovat(i,name){
    var hodnota = readCookie(name);
    if (hodnota =='on') {
        document.getElementById(name).style.display = "none";
    }
}

//cteni cookie
function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}
//nastavi cookie podle hodnoty, kdyz on -> smaze ji, jinak nastavi expires date na 2010 ==> predelat!
function nastavCookie(name){
    //nacteni
    var hodnota = readCookie(name);
    if (hodnota=='on') {
        document.cookie = name+'=mazu to tu; expires=Fri, 27 Jul 2010 02:47:11 UTC';

    } else {
        var vyprs=new Date();
        vyprs.setDate(vyprs.getDate() - 365);
        document.cookie = name+'=on; expires=Fri, 27 Jul 2010 02:47:11 UTC';
    }
}

//vymaze hodnotu elementu (napr. onfocus="clearInput('mujinput','text');")
function clearInput(id, value) {
    if (document.getElementById(id).value == value) {
        document.getElementById(id).value = "";
    }
}

//nastavi hodnotu elementu (napr. onblur="fillInput('mujinput','text');")
function fillInput(id, value) {
    if (document.getElementById(id).value == "") {
        document.getElementById(id).value = value;
    }
}

// schovavani elementu a zobrazeni pri přesunuti na odkazovaný element (url../#element), viditelny bez javascriptu
function show_hide(el) {
    //var url = '/_images/';
    //var url = 'http://localhost/al-svicky/eshop/_images/';
    //var url = 'http://localhost/home/alcandles/_images/';
    //var url = 'http://alcandles.cz/eshop/_images/';
    var url = 'http://www.inet-servis.cz/alcandles/_images/';

    elem = document.getElementById(el);
    li   = document.getElementById('li_'+el);
    pic  = document.getElementById('img_'+el);
    o_open=document.getElementById('openMenu');
    var open = o_open.value;

    if (/(^| )closed( |$)/.test(elem.className)) {
        elem.className = elem.className.replace(/(^| )closed( |$)/, '$2');
        li.className = 'li_open';
        pic.src = url+'li_open.gif';
        o_open.value = el;
        if (open!=0) {
            document.getElementById(open).className += ' closed';
            document.getElementById('li_'+open).className = 'li_closed';
            document.getElementById('img_'+open).src = url+'li_closed.gif';
        }
    } else {
        elem.className += ' closed';
        li.className = 'li_closed';
        pic.src = url+'li_closed.gif'
        o_open.value = 0;
    }
    return true;
}

function formCheck()
{
    if (document.getElementById('fPopis').value =="" || document.getElementById('focus').value =="")
    {
        alert('Nejsou vyplněny všechny položky!');
        return false;
    }
    else return true;
}
function getCenaSDph(x) {
    var z = x.replace(',','.');
    var y = Math.round(z*10 * 1.19)/10;
    document.getElementById('cenaDPH').value = y;
}
function getCenaBezDph(x) {
    var z = x.replace(',','.');
    var y = Math.round(z*10 / 1.19)/10;
    document.getElementById('cena').value = y;
}



function zachyt(ace,x,event) {
    var idcheck = document.getElementById('idcheck');
    var vcheck = document.getElementById('vcheck');
    var id = idcheck.value;
    var lace = vcheck.value;

    if (!event.shiftKey) {
        idcheck.value = x; vcheck.value=ace;
    }
    else if (lace==ace) oznac(id,x,ace);
}

// oznacit checkbox zachyceny z fce zachyt
function oznac(x,y,ace) {
    var pole = document.getElementById('acheck').value.split(",");
    var aktivuj = -1;
    var apole = new Array();
    var akce = false;

    if (document.getElementById(ace+'['+y+']').checked) akce = true;

    for(i=0;i<pole.length;i++) {
        if (pole[i]==y || pole[i]==x) {
            apole[i] = pole[i];
            aktivuj *= -1;
        }
        if (aktivuj>0) apole[i] = pole[i];
    }
    if (aktivuj<0) {
        for(i=0;i<apole.length;i++) {
            if (apole[i])
                document.getElementById(ace+'['+apole[i]+']').checked = akce;
        }
    }
}
function checkVyhledavani() {
    if (document.getElementById('vyhledavani').value =='Vyhledávání') {
        alert('Zapište nejdříve hledané slovo.');
        return false;
    }
    return true;
}

function setFocus(id){
    var xfocus = document.getElementById(id);
    if(xfocus) xfocus.focus();
}
