(function($){$.fn.hoverIntent=function(f,g,i){var cfg={sensitivity:7,interval:i,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
	
$(document).ready(function () {
				
	gradientText.set();
	
	// Make both sides same height in 2 columns layout
	if ($('.bg_left_mid').height() < ($('#page_content_right').height())) {		
		$('.bg_left_mid').css("height", $('#page_content_right').height()+"px");
		$('.bg_left_mid').css("overflow", 'auto');
	}
	
	// Category hovers
	$('#categories').children("li").children("span").children("a").hoverIntent(roll_over,roll_out,10);			
	function roll_over(){$(this).fadeTo("fast", 0.85);}			
	function roll_out(){$(this).fadeTo("normal", 1);}
	
	// Related blocks hovers and click
	$('.row').hoverIntent(roll_over_post,roll_out_post,10);			
	function roll_over_post(){$(this).fadeTo("fast", 0.85);}			
	function roll_out_post(){$(this).fadeTo("normal", 1);}			
	$('.row').click(function(){window.location = ($(this).children(".titles").children("span").children("a").attr("href"));});				
	
	// To top easing animation
	$('.backtotop').click(function(){$('html, body').animate({scrollTop:0}, 'slow');});	
	
	$(".primary-links li").hover(function(){
		$(this).fadeTo("fast", 0.7);
	},function(){
		$(this).fadeTo("normal", 1);
	});			
	
	$('.photos_text').css("margin-top",(388-$('.photos_text').height())+"px");	
	$('.photos_text').css("margin-left","0px");	
	$('body.story div.photo_credit').appendTo('.photos-image:first');
	$(".field-field-caption").appendTo('.photos-image:first');
	$("input[name$='\[credit\]']").css('width','80px');
	$("select.form-select[name$='\[pid\]']").css('max-width','440px');
	
	
	//////////////////////////
	// BREAKING NEWS BLURBS //
if ($("#breaking_news > h1 > a").get(0)) {
	var element = $("#breaking_news > h1 > a").get(0);
	var message = element.innerHTML.split(":")[0];
	if( message.toUpperCase() == message ) {
		var arr = new Array('<span style="background:transparent url(themes/radaronline/images/titles/breaking-bg.jpg) top left repeat-x;padding-left:10px;padding-right:6px;font-style:italic;color:#FFFF00;">',
							'</span><span style="background:transparent url(themes/radaronline/images/titles/breaking-bg-right.jpg) top left no-repeat;padding-left:10px;"></span>');
		element.innerHTML = element.innerHTML.split(message+":").join(arr[0]+message+arr[1]);
	}
}
	//////////////////////////
	
	/*
	var messages = new Array("EXCLUSIVE",
							 "EXCLUSIVE INTERVIEW",
							 "FIRST PHOTO",
							 "BREAKING NEWS",
							 "VIDEO",
							 "NEW PICS",
							 "NEW PIC",
							 "BREAKING NEWS",
							 "BREAKING NEWS",
							 "BREAKING NEWS",
							 */
							 
	
});