var currentfeat=1;var playStatus=true;function overLi(color,object){var elid=$(object).attr("id");if(elid){var featnum=parseInt(elid.substr(8,1))}currentfeat=featnum;var next=featnum+1;var prev=featnum-1;var total=$("#featureClick li").length;if(next>total){next=1}if(prev<1){prev=total}if($("#"+elid+" a").attr("class")!="cur"){autoTransition();$("#featureClick a").removeClass("cur");$("#"+elid+" a").addClass("cur");for(var i=0;i<=total;i++){if(i==total){$("#"+elid+"a").stop().css({display:"block",opacity:"0"}).animate({opacity:"1"},"slow");$("#"+elid+"b").stop().css({display:"block",opacity:"0"}).animate({opacity:"1"},"slow")}else{$("#feature-"+(i+1)+"a").stop().hide();$("#feature-"+(i+1)+"b").stop().hide()}}}}function offLi(color,object,curSelected){var elid=$(object).attr("id");if(curSelected!=""){$("#"+curSelected+" a").addClass("cur")}}var t;function autoTransition(){clearTimeout(t);if(playStatus){t=setTimeout("feature_go()",4000)}}function pause(){if(playStatus){playStatus=false;$("#play_pause img").attr("src","/themes/cc_main/images/rotating_features/play.gif")}else{playStatus=true;$("#play_pause img").attr("src","/themes/cc_main/images/rotating_features/pause.gif")}autoTransition()}function feature_go(){var next=currentfeat+1;var total=$("div#featureClick li").length;if(next>total){next=1}var nextobj=$("#feature-"+next);overLi("#576B8A",nextobj)}$(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")}}}};
