/* RIGHT CLICK CONTEXT MENU INCLUDE */

(function($){var menu,shadow,trigger,content,hash,currentTarget;var defaults={menuStyle:{listStyle:'none',padding:'1px',margin:'0px',backgroundColor:'#fff',border:'1px solid #999',width:'100px'},itemStyle:{margin:'0px',color:'#000',display:'block',cursor:'default',padding:'3px',border:'1px solid #fff',backgroundColor:'transparent'},itemHoverStyle:{border:'1px solid #0a246a',backgroundColor:'#b6bdd2'},eventPosX:'pageX',eventPosY:'pageY',shadow:true,onContextMenu:null,onShowMenu:null};$.fn.contextMenu=function(id,options){if(!menu){menu=$('<div id="jqContextMenu"></div>').hide().css({position:'absolute',zIndex:'500'}).appendTo('body').bind('click',function(e){e.stopPropagation()})}if(!shadow){shadow=$('<div></div>').css({backgroundColor:'#000',position:'absolute',opacity:0.2,zIndex:499}).appendTo('body').hide()}hash=hash||[];hash.push({id:id,menuStyle:$.extend({},defaults.menuStyle,options.menuStyle||{}),itemStyle:$.extend({},defaults.itemStyle,options.itemStyle||{}),itemHoverStyle:$.extend({},defaults.itemHoverStyle,options.itemHoverStyle||{}),bindings:options.bindings||{},shadow:options.shadow||options.shadow===false?options.shadow:defaults.shadow,onContextMenu:options.onContextMenu||defaults.onContextMenu,onShowMenu:options.onShowMenu||defaults.onShowMenu,eventPosX:options.eventPosX||defaults.eventPosX,eventPosY:options.eventPosY||defaults.eventPosY});var index=hash.length-1;$(this).bind('contextmenu',function(e){var bShowContext=(!!hash[index].onContextMenu)?hash[index].onContextMenu(e):true;if(bShowContext)display(index,this,e,options);return false});return this};function display(index,trigger,e,options){var cur=hash[index];content=$('#'+cur.id).find('ul:first').clone(true);content.css(cur.menuStyle).find('li').css(cur.itemStyle).hover(function(){$(this).css(cur.itemHoverStyle)},function(){$(this).css(cur.itemStyle)}).find('img').css({verticalAlign:'middle',paddingRight:'2px'});menu.html(content);if(!!cur.onShowMenu)menu=cur.onShowMenu(e,menu);$.each(cur.bindings,function(id,func){$('#'+id,menu).bind('click',function(e){hide();func(trigger,currentTarget)})});menu.css({'left':e[cur.eventPosX],'top':e[cur.eventPosY]}).show();if(cur.shadow)shadow.css({width:menu.width(),height:menu.height(),left:e.pageX+2,top:e.pageY+2}).show();$(document).one('click',hide)}function hide(){menu.hide();shadow.hide()}$.contextMenu={defaults:function(userDefaults){$.each(userDefaults,function(i,val){if(typeof val=='object'&&defaults[i]){$.extend(defaults[i],val)}else defaults[i]=val})}}})(jQuery);$(function(){$('div.contextMenu').hide()});


$(document).ready(function () {
		
	$(".pager-next").click( function() {top.location.href=($(this).children('a').attr('href')); } );
	$(".pager-next").hover(function(){
		$(this).fadeTo("fast", 0.8);
	},function(){
		$(this).fadeTo("normal", 1);
	});	
	$(".pager-previous").click( function() {top.location.href=($(this).children('a').attr('href')); } );
	$(".pager-previous").hover(function(){
		$(this).fadeTo("fast", 0.8);
	},function(){
		$(this).fadeTo("normal", 1);
	});	
	$(".pager-item").click( function() {top.location.href=($(this).children('a').attr('href')); } );
	$(".pager-item").hover(function(){
		$(this).fadeTo("fast", 0.8);
	},function(){
		$(this).fadeTo("normal", 1);
	});	
	$(".view_all").hover(function(){
		$(this).fadeTo("fast", 0.8);
	},function(){
		$(this).fadeTo("normal", 1);
	});
		
	$('.item-list').append('<ul class="pagers"></ul>');
	$('#home_pagination').append($(".pager-next"));
	$('#home_pagination').prepend($(".pager-previous"));	
	$('.pager-first').remove();
	$('.pager-last').remove();
	
	// Browser and version detection
	var browser='';
	$.each($.browser, function(i, val) {
	   if (i=='safari' && val==true){browser='safari';}
	   if (i=='opera' && val==true){browser='opera';}
	   if (i=='msie' && val==true){browser='msie';}
	   if (i=='mozilla' && val==true){browser='mozilla';}
	});
	var version=jQuery.browser.version;
	/*function read_more(){ 
		$(this).animate({ 
			height: "359px"
		}, 500 );
		$(this).children('.box_blurb').animate({ 
			height: "326px"
		}, 500 );
		$(this).children('.box_meta').animate({
			marginTop: "326px"
		}, 500 ,function() {
			$(this).parent().children('.terms').fadeTo(100, 1);		
			$(this).parent().children('.terms').css({'display' : 'inline'}); 
		});					
	}		
	function read_less(){ 			
		$(this).children('.terms').fadeTo(100, 0);		
		$(this).children('.terms').css({'display' : 'none'});			
		$(this).animate({ 
			height: "236px"
		}, 500 );
		$(this).children('.box_blurb').animate({ 
			height: "236px"
		}, 500 );				
		$(this).children('.box_meta').animate({
			marginTop: "203px"
		}, 500 ,function() {	
			$(this).parent().children('.terms').fadeTo(100, 0);
			$(this).parent().children('.terms').css({'display' : 'none'}); 
		});							
	}	
	
	function read_more2(){ 
		$(this).animate({ 
			height: "359px"
		}, 500 );
		$(this).children('.box_blurb').animate({ 
			height: "326px"
		}, 500 );
		$(this).children('.box_meta').animate({
			marginTop: "0px"
		}, 500 ,function() {
			$(this).parent().children('.terms').fadeTo(100, 1);		
			$(this).parent().children('.terms').css({'display' : 'inline'}); 
		});	
	
	}			
	function read_less2(){ 				
		$(this).children('.terms').fadeTo(100, 0);		
		$(this).children('.terms').css({'display' : 'none'});			
		$(this).animate({ 
			height: "236px"
		}, 500 );
		$(this).children('.box_blurb').animate({ 
			height: "236px"
		}, 500 );				
		$(this).children('.box_meta').animate({
			marginTop: "-35px"
		}, 500 ,function() {	
			$(this).parent().children('.terms').fadeTo(100, 0);
			$(this).parent().children('.terms').css({'display' : 'none'}); 
		});		 
	}	
		
	if ((version<7) && (browser=='msie')) {
		$(".content_box").hoverIntent( read_more2, read_less2,400);	
		
	} else {
		$(".content_box").hoverIntent( read_more, read_less,400);				
	}*/
	
	$(".content_box").click( function() {top.location.href=($(this).attr('rel')); } );
	
	$("#breaking_news").click( function() {top.location.href=($(this).attr('rel')); } );
	
	/* JQUERY CONTEXT MENU */
	$(".content_box").contextMenu('contextMenuDiv', {
      bindings: {
        'context_open': function(t) {
         window.open($(t).attr('rel'),'_blank');
        }
      }

    });
    $("#breaking_news").contextMenu('contextMenuDiv', {
      bindings: {
        'context_open': function(t) {
         window.open($(t).attr('rel'),'_blank');
        }
      }

    });
	
});