today=new Date(); // Initialize Date in raw form
date=today.getDate(); // Get the numerical date
year=today.getFullYear(); // Get the year
day = today.getDay(); // Get the day in number form (0,1,2,3,etc.)
month=today.getMonth()+1; // Get the month

// Make day number value correspond to actual day name
var dayName=new Array(7)
dayName[0]="Sunday";
dayName[1]="Monday";
dayName[2]="Tuesday";
dayName[3]="Wednesday";
dayName[4]="Thursday";
dayName[5]="Friday";
dayName[6]="Saturday";

// Add suffix to date (1st, 2nd, 4th, etc.)
if (date==1) suffix=("st");
else if (date==2) suffix=("nd");
else if (date==3) suffix=("rd");
else if (date==21) suffix=("st");
else if (date==22) suffix=("nd");
else if (date==23) suffix=("rd");
else if (date==31) suffix=("st");
else suffix=("th");

// Make month number correspond to month name
if (month==1) monthName=("January");
else if (month==2) monthName=("February");
else if (month==3) monthName=("March");
else if (month==4) monthName=("April");
else if (month==5) monthName=("May");
else if (month==6) monthName=("June");
else if (month==7) monthName=("July");
else if (month==8) monthName=("August");
else if (month==9) monthName=("September");
else if (month==10) monthName=("October");
else if (month==11) monthName=("November");
else monthName=("December");



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:
			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';
}