$j(document).ready(function() {
    $j("#login-button").css({
        marginLeft: "106px"
    });

    $j("#loginSlider").css({
        marginTop: "-174px"
    });
    $j("#nodSlider").css({
        marginTop: "-245px"
    });
    // $j("#topMenuImage").html('<img src="images/lang-button-en.jpg" alt="Select your language - open" />');
    $j("#loginOpenCloseIdentifier").show();

    $j(".topMenuAction").click( function() {
        if ($j("#openCloseIdentifier").is(":hidden")) {
            $j("#slider").animate({
                marginTop: "-160px"
            }, 500 );
            $j("#topMenuImage").html('<img src="images/lang-button-en.jpg" alt="Select your language - open" />');
            $j("#openCloseIdentifier").show();
        } else {
            $j("#slider").animate({
                marginTop: "0px"
            }, 500 );
            $j("#topMenuImage").html('<img src="images/lang-button-en.jpg" 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="images/lang-button-en.jpg" alt="Select your language - open" />');
            $j("#loginOpenCloseIdentifier").show();
        } else {
            $j("#loginSlider").animate({
                marginTop: "0px"
            }, 500 );
            // $j("#topMenuImage").html('<img src="images/lang-button-en.jpg" alt="Close" />');
            $j("#loginOpenCloseIdentifier").hide();
        }
    });


    $j(".nodTopMenuAction").click( function() {
        if ($j("#nodOpenCloseIdentifier").is(":hidden")) {
            $j("#nodSlider").animate({
                marginTop: "-245px"
            }, 500 );
            // $j("#topMenuImage").html('<img src="images/lang-button-en.jpg" alt="Select your language - open" />');
            $j("#nodOpenCloseIdentifier").show();
        } else {
            $j("#nodSlider").animate({
                marginTop: "0px"
            }, 500 );
            // $j("#topMenuImage").html('<img src="images/lang-button-en.jpg" 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");
    });

   
    /////////set 1
    /*
    var temp;
    var subtemp;
    var curr;
    var prev;
    var next;
    var items=$j(".menuitems");
    items.each(function(){
        temp=$j(this).attr("id");
        if(temp/10<1){
            $j(this).show();
        }else{
            $j(this).hide();
        }
    });
    items.click(function(){
        temp=$j(this).attr("id");
        curr=temp;
        prev=temp-1;
        next=parseInt(temp)+1;
        if(temp/10<temp){
            items.each(function(){
                subtemp=$j(this).attr("id");
               // alert(subtemp + " " + curr + " " + next + " " + prev);
                if(subtemp/10>curr&&subtemp/10<next){
                    $j(this).slideToggle();
                }
            });
        }
    });*/
    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();
            }
        });
    }
});

