// CONTENTS ====================================================================
/*
- DEFAULT 							- common code that runs on every page.
- UTILS 							- util functions
*/

// DEFAULT --------------------------------------------------------------
function InitDefault(){
	
	// call other Init functions
	SetExternalLinks();
	
	if($(window).height() < ( $('#page').height() + 90) ){
		$('#flash').height( $('#page').height() + 90 );
	}

	//$(window).resize(DoResize);
	
}

function DoResize(){
}

// UTILS --------------------------------------------------------------
jQuery.fn.eqByRow = function(){
	/*
	Purpose: equalise the heights of li's in a list by row
	usage: $('#eq-this-list').eqByRow();
	*/
	var inRow 	= Math.floor( $(this).width() / $(this).children("li:first").width() );
	var items 	= $(this).children('li');
	for (var i = 0; i < ($(items).length / inRow); i++){
		var max 	= 0;
		var start 	= (i * inRow);
		for (var j = start; j < start + inRow; j++){
			if(items[j]){
				if( $($(items)[j]).height() > max ) max = $($(items)[j]).height();
			}
		};
		for (var k = start; k < start + inRow; k++){
			if(items[k]){
				$($(items)[k]).height(max);
			}
		};
	};
}

jQuery.fn.biggerClick = function(){
	/*
	Purpose: makes a container 'hot', and binds it click event to go to the location of the first <a>'s href it finds within it
	usage: $('#make-these-hot ul li').biggerClick();
	*/
	$(this).hover(
		function(){
			$(this).addClass("hover");
		},function(){
			$(this).removeClass("hover");
		}
	)
	$(this).click(function(){
		window.location = $(this).find("a:first").attr("href");
	})
}

function SetExternalLinks(){
	/*
	Purpose: checks all <a>'s in the doc, if it has a rel attribute of 'external', sets to open in new window
	usage: <a href="http://www.google.com" rel="external">Google</a>
	*/
	$('a[rel=external]').click(function(){ window.open(this.href); return false; });
}

// ======================================================================

