/* GLOBAL SCRIPT FILE INCLUDES */
document.write('\x3Cscript type="text/javascript" src="http://content.worldnow.com/global/interface/httprequest/httprequest.js">\x3C/script>');
/* END GLOBAL SCRIPT FILE INCLUDES */

/* CONTENT CLASSIFICATION & AFFILIATE INFO */
var wncc = "";
var wnaffName = "";

try {
	wncc = wng_pageInfo.contentClassification;
} catch(e) {
}

try {
	wnaffName = wng_pageInfo.affiliateName;
} catch(e) {
}

/* FIX WNDATE */
function fixDate($el){
	var tDate = $el;
	$wn(tDate).find("script").remove();
	$wn(tDate).find("noscript").remove();
	$wn(tDate).html($wn(tDate).text());
}

/* DYNAMIC STATIC NAV */
var navTx;
function wnNavReset(){
	clearTimeout(navTx);
	$wn(".wnLevel2:visible").hide();
	$wn(".cur").show();
}

function launchDynamicNav(){
	var h = 26;
	var t = 27;
	$wn(".wnMainMenu .wnHorizontal .wnStatic .wnSublevel").css({"z-index": "1000"});

	$wn(".wnStatic .wnLevel1 li:first").attr("rel", "1");
	$wn(".wnStatic .wnLevel1 li:first").siblings("li").each(function(){
		$wn(this).attr("rel", "1");
		if(!$wn(this).find("ul").length){
			$wn(this).append("<ul class='wnLevel2 wnSublevel' style='height: "+ h +"px; top: "+ t +"px; display: none;'><li class='wnFirstNode wnOn'><span><a href=''>&nbsp;</a></span></li></ul>");
		}
	});
	$wn(".wnStatic .wnLevel2 li:first").attr("rel", "2");
	$wn(".wnStatic .wnLevel2 li:first").siblings("li").each(function(){
		$wn(this).attr("rel", "2");
	});
	
	var subnavPos = $wn(".wnMenuSpacer").offset();
	if($wn(".wnLevel2:visible").attr("class") != null){
		//IF A SUB NAV IS PRESENT FOR THE CURRENT CATEGORY
		$wn(".wnLevel2:visible").addClass("cur");
		$wn(".wnLevel2").css({"height": h + "px", "top": t +"px"});
	}else{
		//IF A SUB NAV IS NOT PRESENT FOR THE CURRENT CATEGORY
		$wn("#WNMenuCol1 .wnMenuSpacer").height(h);
		$wn(".wnLevel2").css({"height": h +"px", "top": subnavPos.top +"px", "left": subnavPos.left +"px", "width": ($wn(".wnMenuSpacer").width()-2) +"px", "overflow": "hidden"});
	}
	//$wn("ul.wnLevel1 li.wnFirstNode .wnLeft").css("padding-left","3px");
	$wn("ul.wnLevel1 li[rel='1']").bind("mouseenter", function(){
		clearTimeout(navTx);
		$wn(".wnLevel2:visible").hide();
		$wn(this).find(".wnLevel2").addClass("wnOn").css({"display": "block"});
	});
	$wn("ul.wnLevel1 li[rel='2']").bind("mouseenter", function(){
		clearTimeout(navTx);
	});
	
	$wn("#WNMenuCol1").bind("mouseleave", function(){
		clearTimeout(navTx);
		navTx = setTimeout(function(){
			wnNavReset();
		}, 500);
	});	
}

// Forms
function formRestyle(){
	$wn(".wnDVQuickForm, .wnDVQuickSignup").each(function(){
		$wn(this).find("h4:first").addClass("wnDSHeader").wrapInner("<h3><span style='display:inline;'></span></h3>");
	});
}

// More Link Text Change
function summaryLinkText(){
	if($wn(".wnSummaryLink").length){
		$wn(".wnSummaryLink").text("Read More >>");
	}
}

// Branding Social Tools
function setSocialBranding(){
	if($wn("#WNBranding").length){
	  	$wn("#WNDS70").hide();
		var socialInfoHolder = "<div id='csSocialBranding'><div id='csConnect'><div class='csHeader'><span class='csText'>Connect</span></div><div class='csContent'><a class='csIcon' style='background-position:0 0;' href='http://www.facebook.com/10NewsKTEN'></a><a class='csIcon' style='background-position:-30px 0;' href='/story/8869184/kten-rss-feeds'></a><a class='csIcon' style='background-position:-60px 0;' href='http://www.twitter.com/10NewsKTEN'></a><a class='csIcon' style='background-position:-90px 0;' href='http://feedburner.google.com/fb/a/mailverify?uri=ktenlocalnews'></a><div class='wnClear'></div></div></div><div id='csStations'><div class='csHeader'><span class='csText'>Our Stations</span></div><div class='csContent'><a class='csStIcon' style='margin-left: 6px;width:49px;background-position:0 0;' href='http://www.kten.com'></a><a class='csStIcon' style='width:83px;background-position:-49px 0;' href='http://texomacw.com'></a><a class='csStIcon' style='width:44px;background-position:-132px 0;' href='/category/185144/abc-texoma'></a><div class='wnClear'></div></div></div></div>";
	  $wn("#WNBranding").prepend(socialInfoHolder);
	}
}

$wn(document).ready(function(){
	launchDynamicNav();
	formRestyle();
	summaryLinkText();
	setSocialBranding();
});
