var panels = new Object();

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

google.load('search', '1.0', {"nocss" : true});
     
$(function()
{
    $("#nav0").menu();

    if($(".popup").length > 0)
    {
        $(".popup").overlay({
            target: '#gallery',
            expose: '#f1f1f1' 
        }).gallery({
            speed: 800
        });
    }

    $(".state-default").mouseover(function() {
        $(this).addClass("state-hover");
    }).mouseout(function() {
        $(this).removeClass("state-hover");
    }); 

    $("#nav0 .state-default").mouseover(function() {
        $(this).addClass("state-active");
    }).mouseout(function() {
        $(this).removeClass("state-active");
    }); 
    
    $("a img").parent().css("border", "none");
    
    $("#searchClose").click(function(){
    		$("#searchBox").hide();
      	$("#siteContent").show();
    });   

    // create a search control
    var searchControl = new google.search.SearchControl();
	searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);

    // create a draw options object so that we
    // can position the search form root
    var drawOptions = new google.search.DrawOptions();
    drawOptions.setSearchFormRoot(document.getElementById("searchForm"));

    // populate with searchers
    var siteSearch = new google.search.WebSearch();
    siteSearch.setSiteRestriction("gale.cengage.co.uk");
    
	var searcherOptions = new google.search.SearcherOptions();
	searcherOptions.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
	
    searchControl.addSearcher(siteSearch, searcherOptions);

    searchControl.draw(document.getElementById("searchResults"), drawOptions);
    
    searchControl.setSearchCompleteCallback(this, OnSearchComplete);
});


function OnSearchComplete(sc, searcher) {
  	$("#searchBox").show();
  	$("#siteContent").hide();
  	if ( searcher.results && searcher.results.length > 0) {
  		$("#noSearchResults").hide();
  	} else {
  		$("#noSearchResults").show();
  	}
}

      
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});

}


