function menuSel(ms)
{
    getDataForDIV('../engine/modules/menu_set.php?&id='+ms, 'TmpDiv');
}

function gotoPage(pg, id, sel)
{
    location.href='../?id='+pg+'&catid='+id+'&sel='+sel;
}

function goPage(id, pseo)
{
    getDataForDIV('../engine/modules/menu_set.php?id='+id, 'TmpDiv');
    if (id == '' || id == 0) id = 1;
    location.href='../'+pseo+'/?id='+id+'&from=1';
}

function showProdCateg(id, tento, root)
{   
    if (id == readCookie("active")) 
    {
        for(var i=0; i<3000; i++)
        {
            if (id != i) 
                eraseCookie("itm"+i);
        }
        //createCookie("active", id, 1);
        processCateg(id, root);
        listProductByCtg(id);
        return(0);
    }
    
    if (root == 0)
    {
        if (readCookie("active") != null)
        {   
            var act = readCookie("active")
            var vid = document.getElementById("div"+act+"over");    // over
            var oid = document.getElementById("div"+act);           // orig
            
            if (vid != null) vid.style.display = "none";
            if (oid != null) oid.style.display = "block";
            
            var oid = document.getElementById("itm"+act);           // orig
            if (oid != null) $(oid).hide("slide", { direction: "up" }, 400);
            
            eraseCookie("active");
            eraseCookie("itm"+act);
            listProductByCtg(id);
        }
        setTimeout("processCateg("+id+", "+root+")", 500);
    }
    else
    {
        $("div").removeClass('libold');
        $(tento).addClass('libold');        
        processCateg(id, root);
    }
}

function processCateg(id, root)
{
    if (root == 0) 
    {
        var act = readCookie("active")
        var oid = document.getElementById("div"+id+"over");
        var pid = document.getElementById("div"+id);
        
        if (pid != null) 
        {
            pid.style.display = "none";
            createCookie("active", id, 1);
        }
        if (oid != null) oid.style.display = "block";
        
        var oid = document.getElementById("div"+act+"over");
        var pid = document.getElementById("div"+act);
        
        if (oid != null) oid.style.display = "none";
        if (pid != null) pid.style.display = "block";
    }
    
    if (document.getElementById("itm"+id) != null)
    {
        var obj = document.getElementById("itm"+id);
        
        if (readCookie("itm"+id) == "block")
        {
            opacityoff("itm"+id);
            $(obj).hide("slide", { direction: "up" }, 400);
            eraseCookie("itm"+id);
            //eraseCookie("active");
        }
        else
        {
            document.getElementById("itm"+id).style.display = "block";
            opacityon("itm"+id);
            if (root != 0) listProductByCtg(id);
            $(obj).show("slide", { direction: "up" }, 400);
            createCookie("itm"+id, "block", 1);
            if (root == 0) createCookie("active", id, 1);
        }
        listProductByCtg(id);
    }
    else
        listProductByCtg(id);
}

function gotoProdCateg(id, pgid, pseo)
{
    for(var i=0; i<3000; i++) 
        eraseCookie("itm"+i);
    createCookie("active", id, 1);
    createCookie("itm"+id, "block", 1);
    goPage(pgid, pseo);
}

function gotoFakeProdCateg(id, pgid, root, pseo)
{   
    if (root == 0)
    {
        for(var i=0; i<3000; i++) 
            eraseCookie("itm"+i);
        createCookie("active", id, 1);
    }
    createCookie("itm"+id, "block", 1); 
    goPage(pgid, pseo);
}

