var panels = new Object();

document.write("<style>.noscript { display: none }</style>");

$(function()
{
    $("#nav0").menu();

    getCategories(1);
    getCategories(2);
    getCategories(3);
    getCategories(4);
    getCategories(5);

    $("#category1Item, #category1").mouseover(function() {
        $("#category1").show();
        $("#category1Item").addClass("state-hover");
    }).mouseout(function() {
        $("#category1").hide();
        $("#category1Item").removeClass("state-hover");
    }); 
   
    $("#category2Item, #category2").mouseover(function() {
        $("#category2").show();
        $("#category2Item").addClass("state-hover");
    }).mouseout(function() {
        $("#category2").hide();
        $("#category2Item").removeClass("state-hover");
    }); 
   
    $("#category3Item, #category3").mouseover(function() {
        $("#category3").show();
        $("#category3Item").addClass("state-hover");
    }).mouseout(function() {
        $("#category3").hide();
        $("#category3Item").removeClass("state-hover");
    }); 
   
    $("#category4Item, #category4").mouseover(function() {
        $("#category4").show();
        $("#category4Item").addClass("state-hover");
    }).mouseout(function() {
        $("#category4").hide();
        $("#category4Item").removeClass("state-hover");
    }); 
   
    $("#category5Item, #category5").mouseover(function() {
        $("#category5").show();
        $("#category5Item").addClass("state-hover");
    }).mouseout(function() {
        $("#category5").hide();
        $("#category5Item").removeClass("state-hover");
    }); 

    $("#navCatalogue li").mouseover(function() {
        $(this).addClass("state-hover");
    }).mouseout(function() {
        $(this).removeClass("state-hover");
    }); 
/*
    $(".state-default").mouseover(function() {
        $(this).addClass("state-hover");
    }).mouseout(function() {
        $(this).removeClass("state-hover");
    }); 
*/
    $("#nav0 > li ul li.state-default").mouseover(function() {
        $(this).addClass("state-active");
    }).mouseout(function() {
        $(this).removeClass("state-active");
    }); 

    $(".resultsPages li").mousedown(function() {
        $("#pageNo").val($(this).html());
        $(".resultsPages li").removeClass("state-active");
        $(".resultsPages li").each(function() 
        {
            if($(this).html() == $("#pageNo").val())
                $(this).addClass("state-active");
        });
        updateResults();
    });

    $("#orderBy").change(function() {
        updateResults();
    });
    
    $("#searchGo").click(function() {
        if($("#searchBox").val().length > 0)
            $("#siteSearch").submit();
    });
    
    if($(".popup").length > 0)
    {
        $(".popup").overlay({

            target: '#gallery',

            expose: '#f1f1f1' 

        }).gallery({
            speed: 800
        });
    }
		
});

function activateAccordion(bannerID)
{
	$("#accordion" + bannerID).tabs("#accordion" + bannerID + " div.pane", {
		tabs: 'h2', 
		effect: 'slide'
	});
}

function activateBanner(bannerID, myInterval)
{
    $("#banner" + bannerID + "Frame").html($("#banner" + bannerID + "Content").html());
    $("#banner" + bannerID + "Content").html("");
    
	$("#banner" + bannerID + " .tabs").tabs("#banner" + bannerID + " .images > div", {
		effect: 'fade',
		fadeOutSpeed: "slow",
		rotate: true
	}).slideshow({autoplay: true, interval: myInterval});

}

function getCategories(categoryID)
{
	$.ajax(
	{
		type: "POST",
		url: "/includes/data.aspx",
		data: { 
			"action": "getCategories",
			"categoryID": categoryID
		},
		success: function(html) 
		{
			$("#category" + categoryID + "List").html(html);
		}
		
	});
}

function updateResults(pageNo)
{
 //   $("#catalogueResults").html("");
    $(".loading").show();
	$.ajax(
	{
		type: "POST",
		url: "/includes/data.aspx",
		data: { 
			"action": "updateResults",
			"pageNo": $("#pageNo").val(), 
			"searchKey": $("#searchKey").val(),
			"searchVal": $("#searchVal").val(),
			"orderBy": $("#orderBy").val(),
			"resultTemplate": $("#resultTemplate").val()
		},
		success: function(html) 
		{
			$("#results").html(html);
            $("#resultsCover").hide();
            $(".loading").hide();
		}
		
	});
}

