
/**
*	Document.ready
*/
$(function() {
	$('body').addClass('js-enabled');	
	
	
	//Expanding/collapsing
	$('.expandor').expandor(); 
        	
	
	
	/**
	*	Init the dropdown menus
	*	The built in drop shadows only cover the right/bottom, so we're making custom dropshadows
	*/
	$('ul#primary-nav').superfish({
		onBeforeShow: function() {

			 
			if ( !$(this).hasClass('submenu-processed') ) { 
				//Create the drop shadow
				var height = $(this).height();
				var width = $(this).width(); 
				var left = $(this).offset().left; 
				$(this).addClass('submenu-processed');
				$(this).wrap('<div style="height:'+height+'px;left:'+left+'px;" class="sf-shadow-div-wrap-left sf-shadow-wrap" />');
				$(this).wrap('<div style="height:'+height+'px;" class="sf-shadow-div-wrap-right" />');
				$(this).wrap('<div style="height:'+height+'px;" class="sf-shadow-div-wrap-bottom" />');
			} else { 
				//Dropshadow already created, show the drop shadow
				$(this).parents('.sf-shadow-wrap').show();
			}
		}, 
		onHide: function() {
			if ( $(this).hasClass('submenu-processed') ) { 
				//Hide the drop shadow
				$(this).parents('.sf-shadow-wrap').hide();
			}
		}
		
	});
	
	
	/**
	*	Set a height for the content-area-header-image.
	*	We use width:100% to fill the container, but on IE this makes the images degraded (slightly)
	*	the height is already calculated correcty by the DOM once the images is loaded, 
	*	just grab it & hard set the image dimensions
	*/
	$('#content-area-header-image img').bind('load',function() {
		hardset_dimensions(this);
	}); 
	

	
	/**
	*	Init the Cluetip for the QuickLinks box
	*/
	$('#quick-links-container #quick-links-title').cluetip({
		showTitle: false, 
		sticky: true, 
		local: true, 
		activation: 'hover',
		closeText: '<img src="img/cluetip/close.png" alt="Close" />',
		width: 200
	}); 
	
	
	
	
	
	/**
	 *	Add PDF class to pdf files
	*/
//	$('a[href$=.pdf]').not('.pdf').addClass('pdf');
	
	

}); //End document.ready



function bind_expandors() { 
	$('.expandor').expandor(); 
}

/**
*	Get get width/height of THAT & hard set it
*/
function hardset_dimensions(that) { 
	var w = $(that).width(); 
	var h = $(that).height(); 

	$(that).css({ width: w+'px', height: h+'px' });

}


/**
*	Column switching
*/
function toggle_column_layout() { 
	$('.single-column-layout').removeClass('single-column-layout');
	$('.minimal-page-layout').removeClass('minimal-page-layout');
	
	$('#content-area-header-image img').css({width:'100%',height:'auto'}); 
	$('#column-container').toggleClass('two-column-layout'); 
	hardset_dimensions( $('#content-area-header-image img') );
}

function toggle_single_column_layout() { 
	$('.two-column-layout').removeClass('two-column-layout');
	$('.minimal-page-layout').removeClass('minimal-page-layout');
	
	$('#column-container').toggleClass('single-column-layout'); 
}

function toggle_minimum_page_layout() { 
	$('.single-column-layout').removeClass('single-column-layout');
	toggle_single_column_layout();
	$('body').toggleClass('minimal-page-layout'); 
}