$.preloadImages=function(){
	for(var i=0;i<arguments.length;i++){
		$("<img />").attr("src",arguments[i]);
	}
};








$.fn.enhanceBGOver=function(){
	return $(this).each(function(){
		var me=$(this);
		me.bind("mouseenter focus",function(e){
			me.css("background-position","left bottom");
		}).bind("mouseleave blur",function(e){
			me.css("background-position","left top");
		});
	});
};






$.fn.enhanceRollOver=function(){
	return $(this).each(function(){
		var me=$(this);
		me.bind("mouseenter focus",function(e){
			var src=me.attr("src");
			if(src.lastIndexOf("_on")==-1){
				var len=src.length;
				me.attr("src",src.substring(0,len-4)+"_on"+src.substring(len-4,len));
			}
		}).bind("mouseleave blur",function(e){
			var src=me.attr("src");
			if(src.lastIndexOf("_on")!=-1){
				var len=src.length;
				me.attr("src",src.substring(0,len-7)+src.substring(len-4,len));
			}
		});
	});
};











$(document).ready(function(){
	$(".bgOver").enhanceBGOver();
	$(".rollover").enhanceRollOver();

	if( !$("body").hasClass("top") ){
		var h=$("#main").height();
		var newh=parseInt(1+(h-1)/100)*100;
		$("#main").height(newh);
		$("#buttons").css("bottom",newh-h);
	}
	
	$("a[href^='http://']")
        .add("a[href*='.pdf']")
        .attr('target','_blank');
    
    var $tableBody = $('#right div.tableColumns > div.tableBody');
    if ($tableBody.length > 0) {
        $tableBody.each(function (i, e) {
            var h = 0;
            $(e).children('div.tableColumn').each(function (i, e) {
                h = Math.max(h, $(e).height());
            }).css({'height': h + 'px'}).filter(':last-child').addClass('last-child');
        });
    }
});


