$(window).load( function(){

	// Related Code is in: /views/elements/header.ctp

	// about menu
	$('#about-links').hover( function(){
		$('#about-links').show();
	}, function(){
		$('#about-links').slideUp('fast');
	});
	$('#about-atc').mouseover( function(){
		$('#about-links').show();
	});

	// big-nav menu
	$('ul.sf-menu').superfish({
		speed:'fast',
		autoArrows:false,
		dropShadows:false
	});

	$("#search-submit").click( function(){
		$(this).parents("form").submit();
		return false;
	});

	// search form
	$("#PageSearchForm").bind('submit', function(){
		keyword = $("#PageKeyword").val();
		if( keyword.length > 2 ){
			window.location = '/pages/search/keyword:'+encodeURI(keyword);
		}else{
			$.jGrowl('Searches must contain at least 3 characters');
		}
		return false;
	});

	fixHeights();

	$("#content").resize( function(){
			fixHeights();
	});

});

function damnIE6(){
	$("#footer").css({"top":"-60px","backgroundColor":"black"});
	// fix css style issues in footer
   	$("#content-bg-mid").css({'height': ($("#content").height()-40)+"px", 'overflow' : 'visible'});
}

function fixHeights(){

	// balance right col w/ left if the left is longer
	if( $(".left-tiny").length && $(".right-large").length ){
		lheight = $(".left-tiny").height();
		rheight = $(".right-large").height();

		if( lheight > rheight ){
			diff = lheight-rheight;
			$(".right-large .box-large-mid").height(
											$(".right-large .box-large-mid").height() + diff );
		}
	}


	// fix css style issues in footer
	$("#content-bg-mid").height( $("#content").height()-40 );

	if( $.browser.msie && $.browser.version == 7 ){
		$("#footer").css({"top":"0px"});
	}

	// if ie6/7, fix footer
	if( $.browser.msie && $.browser.version < 7 ){
		setTimeout('damnIE6();', 200);		
	}
}

