/*

*/
$(document).ready (function ()
{
	// Match columns
	equalize ();
	
	// Make sure height is always larger than browser window
    $(window).resize (function()
    {
    	//resize ();
    });
    //resize ();
    
    // Delay resize attempt to cater for slow-loading images
    //setInterval ("resize ();", 1000);
    
    // Stripes   
    $("table tr").mouseover(function(){$(this).addClass("over");}).mouseout(function(){$(this).removeClass("over");});
	$("table tr:even").addClass("alt");
	
	$("a[href^='http']").each(function()
	{
		if (this.href.indexOf(location.hostname) == -1)
		{
			$(this).attr('target', '_blank');
		}
	});
});

function resize ()
{
	var buffer = 			$('#header-background').height () + $('#footer').height () + $('#footer-menu').height ();
	
	var offset =			0;
	var contents_height =	$('#contents').height();
    var window_height =		$(window).height();
    
    if (contents_height + buffer < window_height)
    {
        $("#contents").css('height', window_height - buffer + offset);
	}
	
	
	if ($("#contents").height () > $("#contents .column-1").height ())
	{
		$("#contents .column-1").height ($("#contents").height ());
		equalize ();
	}
}

function equalize ()
{			
	// Equalize column heights
	var height1=$("#contents .column-1").height ();
	var height2=$("#contents .column-2").height ();
	
	if (height1 > height2)
	{
		$("#contents .column-2").height (height1);
	}
	if (height2 > height1)
	{
		$("#contents .column-1").height (height2);
	}
}
