﻿$(document).ready(function(){
    $("#Menu").find("div").click(function(){
        var rel = $(this).attr("rel");
   
        var Hid = $("#" + rel).css("display");
        if ( Hid == "none" ) {
            $("#" + rel).slideToggle("fast");
            $("#" + rel).animate({marginLeft: "15px"},100);
            $("#" + rel).animate({marginLeft: "20px"},200);
            $("#" + rel).find(".ProductSubMenuSub").hide();
        }
        else {
            $("#" + rel).animate({marginLeft: "0px"},100);
            $("#" + rel).slideToggle("fast");
            $("#" + rel).find(".ProductSubMenuSub").hide();
        }
        
        
        var href = $(this).attr("href");
        if ( href != null ) {
            Redirect(href);
        } 
        
    });
    

    
    
    $(".Product_s_galery").find("img").click(function(){
        
        var src = $(this).attr("src");
        var src = src.replace("sendbinary.aspx?path=","")
        var src = src.replace("&width=60&height=60","")
        $("#big_pic_img").attr("src",src);
        $("#big_pic_a").attr("href",src);
       
        
    });
    
    
    $('.Product_s_pic a').lightBox();
    $('#kroki a').lightBox();
    
    
    
    
    
});


function Popup(URL,Name,W) {
window.open(URL,name,W);
}
function Redirect(Url) {
window.location = Url;
}

function ShowMenu(ID) {
    $("#Menu").find("div").each(function(){
        var href = $(this).attr("href");
        var s = "Product.aspx?ID=" + ID
        if ( href == s ) {
            var uID = $(this).attr("uID");
            $(this).css("font-weight","bold")
            CollopseAll(uID)
        }
    });
}


function CollopseAll(ID) {
    if ( ID != 0 ) {
        $("#" + ID).show()
        $("#" + ID).css("margin-left","20px")
           $("#Menu").find("div").each(function(){
               var rel = $(this).attr("rel");
               if ( rel == ID ) {
                    var uID = $(this).attr("id");
                    CollopseAll(uID)
               } 
          });
        
    }
    
}
