$j(document).ready(function() {
    $j("#login-button").css({
        marginLeft: "106px"
    });

    $j("#loginSlider").css({
        marginTop: "-174px"
    });
    $j("#nodSlider").css({
        marginTop: "-385px"
    });
    // $j("#topMenuImage").html('<img src="/app_themes/kipuk_theme/images/lang-button-en.png" alt="Select your language - open" />');
    $j("#loginOpenCloseIdentifier").show();
    // $j("#advanced-news-filter").hide();

    $j("#advanced-news-search").click(function(){
        $j("#advanced-news-filter").slideToggle("slow");
    });
    $j(".topMenuAction").click( function() {
        if ($j("#openCloseIdentifier").is(":hidden")) {
            $j("#slider").animate({
                marginTop: "-160px"
            }, 500 );
            $j("#topMenuImage").html('<img src="/app_themes/kipuk_theme/images/lang-button-en.png" alt="Select your language - open" />');
            $j("#openCloseIdentifier").show();
        } else {
            $j("#slider").animate({
                marginTop: "0px"
            }, 500 );
            $j("#topMenuImage").html('<img src="/app_themes/kipuk_theme/images/lang-button-en-up.png" alt="Close" />');
            $j("#openCloseIdentifier").hide();
        }
    });

    
    $j(".loginTopMenuAction").click( function() {
        if ($j("#loginOpenCloseIdentifier").is(":hidden")) {
            $j("#loginSlider").animate({
                marginTop: "-174px"
            }, 500 );
            // $j("#topMenuImage").html('<img src="/app_themes/kipuk_theme/images/lang-button-en.png" alt="Select your language - open" />');
            $j("#loginOpenCloseIdentifier").show();
            
        } else {
            $j("#loginSlider").animate({
                marginTop: "0px"
            }, 500 );
            // $j("#topMenuImage").html('<img src="/app_themes/kipuk_theme/images/lang-button-en-up.png" alt="Close" />');
            $j("#loginOpenCloseIdentifier").hide();
            
        }
    });


    $j(".nodTopMenuAction").click( function() {
        if ($j("#nodOpenCloseIdentifier").is(":hidden")) {
            $j("#nodSlider").animate({
                marginTop: "-385px"
            }, 500 );
            // $j("#topMenuImage").html('<img src="/app_themes/kipuk_theme/images/lang-button-en.png" alt="Select your language - open" />');
            $j("#nodOpenCloseIdentifier").show();
        } else {
            $j("#nodSlider").animate({
                marginTop: "0px"
            }, 500 );
            // $j("#topMenuImage").html('<img src="/app_themes/kipuk_theme/images/lang-button-en-up.png" alt="Close" />');
            $j("#nodOpenCloseIdentifier").hide();
        }
    });

    
    $j("#btn-commercial").click( function() {
        $j("#subnav").css({
            "background-image":"url(images/water/banner-landing.gif)"
        });
        $j(".homebox").html("rainwater <br />harvesting by Kingspan");
        $j(".homeintrotext").html("Kingspan has spearheaded the development of sustainable <br />water technology. We offer the most innovative range of <br />products for rainwater harvesting & greywater recycling to <br />meet the demands of modern building projects.")
        $j("#btn-commercial").attr("src","images/water/btn-commercial-selected.gif");
        $j("#btn-domestic").attr("src","images/water/btn-domestic.gif");
    });
    
	
    $j("#btn-domestic").click( function() {
        $j("#subnav").css({
            "background-image":"url(images/water/banner-landing1.gif)"
        });
        $j(".homebox").html("Economic solutions <br /> for water conservation");
        $j(".homeintrotext").html("Rainwater Harvesting works by taking the rain from your roof <br /> gutters , filtering out leaves and debris and storing the water in a <br /> tank. This water can then be used for non-potable applications such <br /> as vehicle washing, irrigation, toilet flushing and wasing machines.")
        $j("#btn-domestic").attr("src","images/water/btn-domesticselect.gif");
        $j("#btn-commercial").attr("src","images/water/btn-commercial.gif");
    });
    
    $j("#test1").click(function(){
        $j(".jump-straight-to").show();
        $j("#jstheader").html("Header1");
        $j("#jstcontent").html("This is dummy text. This is dummy text.This is dummy text.This is dummy text.This is dummy text. ");
    });

    $j("#test2").click(function(){
        $j(".jump-straight-to").show();
        $j("#jstheader").html("Header2");
        $j("#jstcontent").html("This is dummy text1. This is dummy text1.This is dummy text.This is dummy text.This is dummy text. ");
    });

    $j("#test3").click(function(){
        $j(".jump-straight-to").show();
        $j("#jstheader").html("Header3");
        $j("#jstcontent").html("This is dummy text2. This is dummy text2.This is dummy text.This is dummy text.This is dummy text. ");
    });




    $j("#closeme").click(function(){
        $j(".jump-straight-to").hide();
    });

    $j("#content-block").click(function(){
        $j("#menu-items").slideToggle("slow");
    });
   
    var temp=true;
    
    $j("#layerbox1").mouseover(function(){
        temp=false;
        console.log("layerbox1 mouse in");
    //temp=false;

    });
    /*mouseout(function(){
        console.log("layerbox1 moving out");
        $j("#layerbox1").fadeOut("slow");
    });*/
    var openbox=0;
    $j("#li1").click(function(){
        if(openbox!=1)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox1").slideToggle(1000);
        openbox=1;
    });
    $j("#li2").click(function(){
        if(openbox!=2)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox2").slideToggle(1000);
        openbox=2;
    });
    $j("#li3").click(function(){
        if(openbox!=3)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox3").slideToggle(1000);
        openbox=3;
    });
    $j("#li4").click(function(){
        if(openbox!=4)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox4").slideToggle(1000);
        openbox=4;
    });
    $j("#li5").click(function(){
        if(openbox!=5)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox5").slideToggle(1000);
        openbox=5;
    });
    $j("#li6").click(function(){
        if(openbox!=6)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox6").slideToggle(1000);
        openbox=6;
    });
    $j("#li7").click(function(){
        if(openbox!=7)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox7").slideToggle(1000);
        openbox=7;
    });
    $j("#li8").click(function(){
        if(openbox!=8)
        $j("#layerbox"+openbox).hide("fast");
        $j("#layerbox8").slideToggle(1000);
        openbox=8;
    });


    var temp;
    var subtemp;
    var curr;
    var prev=0;
    var next;
    var items=$j(".menuitems");
    function hideMenu(){
        items.each(function(){
            temp=$j(this).attr("id");
            // alert(temp);
            $j("."+temp).hide();
            if(temp/10<1){
                $j(this).show();
            // $j("."+temp).hide();
            }
        });
    }

    hideMenu();
    $(".cbox").attr("checked",false);
    
    items.click(function(){
        temp=$j(this).attr("id");
        $j("."+temp).slideToggle();


        if(temp/10>10){
            hideSubMenu();
            if($("#"+temp + "  .cbox").attr("checked")){
                $(".s"+temp).show();
            }
        }
    });

    $("#on-img").click(function(){
        if($(this).attr("name")=="open") {
            $(".cbox").attr("checked",false);
            hideSubMenu();
        }
    });
    function hideSubMenu(){
        $("div[id^='slide-content']").each(function() {
            if(!($(this).hasClass("mainbox"))){
                $(this).hide();
            }
        });
    }

   
});

