$(document).ready(function(){
	function fixDate($el){
		var tDate = $el;
		$(tDate).find("script").remove();
		$(tDate).find("noscript").remove();
		$el.html($(tDate).text());
	}
	$("#WNCols234-5 #WNCols23-4 #WNCol23 #WNCol2 .wnDS80 .wnDVSummary").each(function(){
		fixDate($(this).find(".wnDate"));
		$(this).find(".wnDate").insertAfter($(this).find(".wnRole-STORY"));
	});
	$("#WNCols234-5 #WNCols23-4 #WNCol23 #WNCol2 .wnDS82 .wnDVSummary").each(function(){
		fixDate($(this).find(".wnDate"));
		$(this).find(".wnDate").insertAfter($(this).find(".wnRole-STORY"));
	});
});

// BEGIN DYNAMIC STATIC NAV //
var navTx;
function wnNavReset(){
	clearTimeout(navTx);
	$(".wnLevel2:visible").hide();
	$(".cur").show();
}
$(document).ready(function(){
	$(".wnMainMenu .wnHorizontal .wnStatic .wnSublevel").css({"z-index": "1000"});

	$(".wnStatic .wnLevel1 li:first").attr("rel", "1")
	$(".wnStatic .wnLevel1 li:first").siblings("li").each(function(){
		$(this).attr("rel", "1");
		if(!$(this).find("ul").length){
			$(this).append("<ul class='wnLevel2 wnSublevel' style='height: 27px; top: 41px; display: none;'><li class='wnFirstNode wnOn'><span></span></li></ul>");
		}
	});	$(".wnStatic .wnLevel2 li:first").attr("rel", "2")
	$(".wnStatic .wnLevel2 li:first").siblings("li").each(function(){
		$(this).attr("rel", "2");
	});
	
	var subnavPos = $(".wnMenuSpacer").offset();
	if($(".wnLevel2:visible").attr("class") != null){
		//IF A SUB NAV IS PRESENT FOR THE CURRENT CATEGORY
		$(".wnLevel2:visible").addClass("cur");
		$(".wnLevel2").css({"height": "27px", "top": "41px"});
	}else{
		//IF A SUB NAV IS NOT PRESENT FOR THE CURRENT CATEGORY
		$(".wnLevel1 li").height($(".wnLevel1 li").height() + 29);
		$(".wnLevel1 .wnFirstNode").append("<ul class='wnLevel2 wnSublevel' rel='cur'><li class='wnFirstNode'><span><a href=''>&nbsp;</a></span></li></ul>");
		$(".wnLevel2").css({"height": "27px", "top": subnavPos.top+"px", "left": (subnavPos.left+2) +"px", "width": ($(".wnMenuSpacer").width()-2) +"px", "overflow": "hidden"});
	}	$("ul.wnLevel1 li[rel='1']").bind("mouseenter", function(){
		clearTimeout(navTx);
		$(".wnLevel2:visible").hide();
		$(this).find(".wnLevel2").addClass("wnOn").css({"display": "block"});
	});
	
	$("ul.wnLevel1 li[rel='2']").bind("mouseenter", function(){
		clearTimeout(navTx);
	});
	
	$("#WNMenuCol1").bind("mouseleave", function(){
		clearTimeout(navTx);
		navTx = setTimeout(function(){
			wnNavReset();
		}, 500);
	});
	
});
// END DYNAMIC STATIC NAV //

// SECONDARY NAV
$(document).ready(function(){
	//CATCH LINKS+
	if($("#WNBrandingImage").attr("src").toString().indexOf("station_id.gif")!=-1){
		return false;
	}
	//CATCH PRINTABLE PAGE
	if($("#WNHeader img").attr("src").toString().indexOf("hdr_607x37.gif")!= -1){
		return false;
	}
	
	$("#WNBranding").css("position", "relative");
	$("#WNBranding").append(secNav);
	$("#sec_nav").css({"font":"bold 11px Arial", "width":"auto",  "height":"12px",  "overflow":"hidden",  "background-color":"transparent",  "padding":"2px 0px",  "display":"none",  "font-weight":"bold",  "position":"absolute", "bottom":"4px", "left":"2px"});

	var secNavContents = "<div style='float:left'>";
	for(ii=0;ii<secNavArray.length;ii++){
		secNavContents += secNavArray[ii];
	}
	secNavContents += "</div>";
	$("#sec_nav").append(secNavContents);
	$("#sec_nav a").css("display", "inline-block").css("height", "9px").css("color","#000000").css("text-decoration","none").css("padding","0px 5px").css("border-right", "1px solid #c0bbbb");
	$("#sec_nav a").mouseover(function(){
		$(this).attr("title",$(this).html())
		$(this).css("text-decoration","underline");
	});
	$("#sec_nav a").mouseout(function(){
		$(this).css("text-decoration","none");
	});
	if($.browser.msie){
		//$("#sec_nav").css("top","-5px");
	}
	$("#sec_nav").show();
});
var secNav = "<div id='sec_nav'></div>";
var secNavArray = new Array();
secNavArray[0] = "<a href='http://www.diamondcertified.org/' target='_blank'>Diamond Certified</a>";
secNavArray[1] = "<a href='http://www.centralcoastdeals.com/' target='_blank'>Central Coast Deals</a>";
secNavArray[2] = "<a href='http://www.kionrightnow.com/Global/category.asp?C=167487'>Contests</a>";
secNavArray[3] = "<a href='/Global/link.asp?L=422557'>Get Coupons</a>";
secNavArray[4] = "<a href='http://salinaslawline.com/' target=_blank>Law Line</a>";
secNavArray[5] = "<a href='/global/category.asp?c=164811'>Operation Jobs</a>";
secNavArray[6] = "<a href='/global/Category.asp?C=193337'>Perfect Health</a>";
// END SECONDARY NAV

// BEGIN WN LIFESTYLE PROMO RESTYLE //
$wn(document).ready(function(){
	if($wn("#WNAd44 table").length){
		var $wnAd44 = $wn("#WNAd44");
		var $wnAd44_t = $wnAd44.find("table");
		$wnAd44_t.find("td:first").html("<div>"+ $wnAd44_t.find("td:first").html() +"</div>");
		$wnAd44_t.find("td:last").css({"width": "190px"});
		$wnAd44.find("table.main img").wrap("<div class='lsImg'></div>");
		$wnAd44_t.find("tr:eq(1) td:first").css({"padding-left": "7px", "padding-top": "7px"});
		$wnAd44_t.find("tr:eq(1) td:first div:first").css({"border": "none"});
		$wnAd44_t.find("tr:eq(1) td:last").css({"padding-top": "7px"});
		$wnAd44_t.find("li").css({"margin-bottom":"5px","font-size":"10px","background-image":"url('http://kion.images.worldnow.com/images/static/gfx/blt_headline.gif')","background-repeat":"no-repeat","padding-left":"12px"});
	}	
});
// END WN LIFESTYLE PROMO RESTYLE //
