// JavaScript Document
//Global js for Moffat Centre Microsite

$(document).ready(function() {
    //Set column height
    stabliseColumnHeight();

    //dropdown navigation
    $("#topNav").children("ul").children("li").hoverIntent(function() {
        $(this).children("a").addClass("hover");
        $(this).children("ul").slideDown("fast");
    },
	function() {
	    $(this).children("ul").slideUp("fast");
	    $(this).children("a").removeClass("hover");
	});
    //Image Panel fade
    $('ul#slides').innerfade({
        speed: 1000,
        timeout: 5000,
        type: 'sequence',
        containerheight: '353px'
    });

    // site search
    $("#siteSearch").focus(function() {
        if ($(this).val() == "Search Site")
            $(this).val("");
    });
    $("#siteSearch").blur(function() {
        if ($(this).val() == "")
            $(this).val("Search Site");
    });

//    $('div.showhide.closed:first').removeClass('closed');
    $('div.showhide.closed .collapsible').hide();
    $('div.showhide h2').click(function(){
	$(this).parents('.showhide').toggleClass('closed').find('.collapsible').slideToggle("slow");
    });
    

});

$(function(){
	//news and events tabs
		$('#tabs').tabs();	
	});

/**
* Used to ensure the nav column and the the content column are the same 
* height 
**/
function stabliseColumnHeight() {

    var heightCols = $(".setHeight");
    var maxHeight = 0;
    for (i = 0; i < heightCols.length; i++) {
        if ($(heightCols[i]).height() > maxHeight)
            maxHeight = $(heightCols[i]).height();
    }
    $(".setHeight").each(function() { $(this).height(maxHeight) });
}