$(document).ready(
	function() {
		$("p.expand_research").click(
			function () {
				if ($(this).next().is(":hidden")) {
					$(this).next().slideDown("fast");
					$(this).css("background-image", "url(/themes/cc_main/images/arrow_up.png)")
					$(this).text("Hide research findings and policy recommendations")
				} else {
					$(this).next().hide();
					$(this).css("background-image", "url(/themes/cc_main/images/arrow_right.png)")
					$(this).text("Show research findings and policy recommendations")
				}
			}
		);
		var startobj= $("#feature-1");
		overLi("#576B8A", startobj);
		$("li.hoverli").hover(
			function(){
				overLi("#576B8A", this);
			}, 
			function(){}
		);
	}
);
$(window).load(function(){for(var i= 0;i<$("#bannerImages img").length;i++){featureImageAdjust($("#bannerImages img")[i],308,217);}})
function imgLoad(img, completeCallback, errorCallback){
	if(img!=null && completeCallback!=null){
		var loadWatch = setInterval(watch, 100);
		function watch(){if(img.complete){clearInterval(loadWatch);completeCallback(img);}}
	}else{if(typeof errorCallback=="function") errorCallback();}
}
function featureImageAdjust(image,box_w,box_h){
	if(!box_w || !box_h) var box_h = 0;
	var div= 0;
	if(image.width > 50){
		var orig_w= image.width;
		var orig_h= image.height;
		if(box_h == 0){image.width = "100%";}
		else{
			div= (orig_w > orig_h)? orig_h / box_h : orig_w / box_w;
			var new_w= Math.ceil(orig_w / div);
			var new_h= Math.ceil(orig_h / div);
			$(image).css({"width" : new_w+"px","height" : new_h+"px"});
			var h_marg= Math.ceil((box_w - new_w) / 2);
			var v_marg= Math.ceil((box_h - new_h) / 2);
			if(h_marg != 1) $(image).css("margin-left",h_marg+"px");
			if(v_marg != 1) $(image).css("margin-top",v_marg+"px");
		}
	}
}
