﻿// archive dropdown menu
function FP_jumpMenu(el,frm,sel) {//v1.0
 var href=el.options[el.selectedIndex].value; if(sel) el.selectedIndex=0;
 '_new'==frm ? open(href) : eval(frm+".location='"+href+"'");
}

// used for channels pages
function disImage(){
	var sImage = document.getElementById("ctl00_ctl10_g_1986fcb4_1481_4086_bf83_c1af520b08b6");
	if(sImage == null){return false;}
	else {
		var sImage2 = sImage.getElementsByTagName("iframe")[0],
		sImage3 = sImage.getElementsByTagName("image")[0];
		if(sImage3 == null && sImage == null){
			sImage.style.display = "none";
			return false;
		}
		else if(sImage2 != null && sImage3 == null){
			document.getElementById("sponsoredBy").style.display = "block";
		}
		else if(sImage2 == null && sImage3 != null){
			document.getElementById("sponsoredBy").style.display = "block";
		}		
	}
}

// used for articles pages
function hideAdBodyDiv(){
	var adDiv = document.getElementById("bodyAd");
	if(adDiv == null || adDiv2 == null){return false;}
	else {
		var adDiv2 = adDiv.getElementsByTagName("img")[0];
		if(adDiv2.height > 1){
			adDiv.style.display = "block";
		}
	}
}

//search and form field hints
function fieldTip(fieldHint) {
	$.each(fieldHint, function(el, text){
		$(el).val(text).focus(function() {
			$(this).val('');
		});
	});
}

//fix top ad flash for small screen resolution
function smallScreen(el){
	$(this).css({
		'position' : 'relative',
		'z-index' : '0'
	});
}

//Override the AutoFocus function
function WebForm_AutoFocus(focusId) {} 

// dropdown nav
function montre(id) {
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
	if (d) {d.style.display='block';}
}

$(function(){
	var fieldHint = {
		'#SearchTerms' : 'Begin Search'
	}, h1 = $("h1:first"), trimh1 = h1.html();
		
	//pagination enhancement
	$('.articleNewPaging').clone().insertBefore('#pageHolder');
	
	/* trims leading nbsp if inserted */
	if (trimh1) {
		trimh1 = trimh1.replace(/^(&nbsp;)/, "");
		h1.html(trimh1);
	}
	
	/* call fxns */
	fieldTip(fieldHint);
	smallScreen($('#topAd object'));
	
	//elements to hide					
	var arr = ['.ms-navframe','.ms-bannerframe','.ms-sbtable','.ms-searchform','.ms-sbtopcorner','#TopAds','.ms-sblbcorner','#ColumnTwo','#MagazineSearch','#MagazineFooter','#ArticleComments','#Pagination','.article-topic','#Byline','#nav-menu-container','.printButton','#Button','#page-content br'];
	
	//hide the items	
	$(".printButton").click(function(){
		$.grep(arr, function(x){$(x).hide();
			$(".print-article").css("font-size","12pt").show();
		});
		//shows the print change link and shows the items of the array		
		$(".returnButton").show().css("cursor","pointer").click(function(){
			$.grep(arr, function(x){
				$(x).show();
			});
			$(this, ".print-article").hide();
		});
		print();
	});
});