var $j = jQuery.noConflict();

$j(document).ready(function(){

		//Get Page section - Display default subnav
		var section = $j('body').attr('class').split(" ")[0];
		$j('#'+section).find('ul').addClass('on');

		//active state of the tab and sub nav 
		$j("li.mainnav").hoverIntent({
				sensitivity: 1, 
				interval: 5, 
				over: subnavOver, 
				timeout: 0, 
				out: subnavOut
			});

		//Display current tab and sub nav 
  		function subnavOver() {
			$j('a.navitem').removeClass('on');
			$j(this).find('a.navitem').addClass('on');
			$j('ul.subnav').removeClass('on');
			$j(this).find('ul').addClass('on');
		}

		//Hide tab and sub nav
		function subnavOut() {
			$j(this).find('a.navitem').removeClass('on');
			$j(this).find('ul').removeClass('on');
		}	

		//Active state fro the nav area
		$j("#navcontent").hoverIntent({
				sensitivity: 1, 
				interval: 5, 
				over: sectionOver, 
				timeout: 0, 
				out: sectionOut
			});

		function sectionOver() {
		}

		//Display only the default
		function sectionOut() {
			var status = $j('body').attr('class').split(" ")[0];
			$j('#'+status).find('ul').addClass('on');
		}	
		
		//Feature Box - Homes Travel and Cars
		$j("a.featureitem").hoverIntent({
				sensitivity: 1, 
				interval: 5, 
				over: sliderOver, 
				timeout: 0, 
				out: sliderOut
			});

		function sliderOver() {
			$j('a.featureitem').removeClass('active');
			$j(this).addClass('active');
			$j('#slidercontent').removeClass();
			if( $j(this).is(".featureitem01") ) {
				$j(this).parents('#featureslider').find('#slidercontent').addClass('content01');
			}; 
			if( $j(this).is(".featureitem02") ) {
				$j(this).parents('#featureslider').find('#slidercontent').addClass('content02');
			};
			if( $j(this).is(".featureitem03") ) {
				$j(this).parents('#featureslider').find('#slidercontent').addClass('content03');
			};
			if( $j(this).is(".featureitem04") ) {
				$j(this).parents('#featureslider').find('#slidercontent').addClass('content04');
			};
			if( $j(this).is(".featureitem05") ) {
				$j(this).parents('#featureslider').find('#slidercontent').addClass('content05');
			};
		}

		function sliderOut() {
		}	
	
		//Feature Box - Homes Travel and Cars
		$j("a.headlinetab").hoverIntent({
				sensitivity: 1, 
				interval: 5, 
				over: featureOver, 
				timeout: 0, 
				out: featureOut
			});

		function featureOver() {
			$j('a.headlinetab').removeClass('on');
			$j(this).addClass('on');
			$j('#featurebox').removeClass();
			if( $j(this).is(".headlinetab01") ) {
				$j(this).parents('#featurebox').addClass('content01');
			}; 
			if( $j(this).is(".headlinetab02") ) {
				$j(this).parents('#featurebox').addClass('content02');
			}; 
			if( $j(this).is(".headlinetab03") ) {
				$j(this).parents('#featurebox').addClass('content03');
			}; 
		}

		function featureOut() {
		}	

		//Photo section
		$j("a.sectionopen").click(function() {
		$j(this).hide();
    	$j(this).parent(".newssection").find(".newsblocks").slideDown("slow");
		$j(this).parent(".newssection").find("a.sectionclose").show("slow");
    	return false;
  		})

	 $j("a.sectionclose").click(function() {
		$j(this).hide();
		$j(this).parent(".newssection").find(".newsblocks").slideUp("fast");
		$j(this).parent(".newssection").find("a.sectionopen").show("slow");
    	return false;
  		});

		//Breaking News
	 	$j(".breakingnews .morelink li a").mouseover(function() {
		$j(this).parent("li").parent(".morelink").parent(".featurecontent").parent("#featurewidget").slideUp("fast");
    	return false;
  		});

		//Breaking News hide 
		//if ($j(".breakingnewsbox #cns_breakingnews").height() == 0 ){
			//if ($j(".breakingnewsbox #breakingnews").height() != 0 ){
				//$j(".breakingnewsbox #breakingnews").css("position","relative");
			//}
		//};
	
	});

//header dropdown
/* VERSION ONE
function redirect(selectObj) {
	document.location = selectObj.options[selectObj.selectedIndex].value;
}
*/
function redirect(selectObj, selectTrgt) {
	switch(selectTrgt) {
		case "popup":
			window.open(selectObj.options[selectObj.selectedIndex].value,'Broadcast','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
			break;    
		default:
			top.document.location = selectObj.options[selectObj.selectedIndex].value;
	}
}

//Set Class
function setClass(objectID,newClass) {
	var object = document.getElementById(objectID);
	object.className = newClass;
}

//Index Page Breaking News Alert
function breakingNews()
{
	var bn = document.getElementById('breakingnews');
	var cbn = document.getElementById('cns_breakingnews');
	
	var bnh = bn.offsetHeight;
	var cbnh = cbn.offsetHeight;

	if( bnh > 0 )
		cbn.style.display ='none';
}
