
/* cm popups blocked to partenr sites added Vasu 6/11/09 */
/* Google, Yahoo, Primosearch.com, Righthealth.com, Alot.com, Digg.com, Facebook.com, Reddit.com, Twitter.com, Stumbleupon.com
CNN.com, MSN.com, Huffingtonpost.com, AOLHealth.com, Thatsfit.com, Lilsugar.com, Fitsugar.com, Caring.com, Glamour.com
Vitaljuice.com vitaljuicedaily Getmarried.com  */
if (document.referrer.indexOf("google") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("yahoo") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("primosearch") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("righthealth") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("alot") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("digg") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("facebook") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("reddit") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("twitter") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("stumbleupon") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("cnn") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("msn") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("huffingtonpost") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("aolhealth") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("thatsfit") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("lilsugar") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("fitsugar") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("caring") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("glamour") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("vitaljuice") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("vitaljuidedaily") >= 0) { adConfig.setPopups(false); }
if (document.referrer.indexOf("getmarried") >= 0) { adConfig.setPopups(false); }



function showCenteredPopup(name, url, features, width, height) {
	var top = (window.screen.height / 2) - height / 2;
	var left = (window.screen.width / 2) - width / 2;
	if (features == null || features == '') {
		features = "scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
	}
	window.open (url, name.replace (' ', '_'), features + ",top=" + top + ",left=" + left + ",width=" + width + ",height=" + height);
}

function validateHealthJourneyForm(form) {
	if (form.journey.selectedIndex == 0) {
		alert("You must select a Journey.");
		return false;
	}
	form.action=form.journey.options[form.journey.selectedIndex].value;
	return true;
}

function validate_scribble_form() {
	if (top.document.getElementById("your_comment").value == "") {
		alert("Please include your comment"); 
		return false;
	}
	if (top.document.getElementById("scribbleUser").value == "") {
		top.document.getElementById("scribbleUser").value = "Anonymous";
	}
	return true;	
}

if (typeof TIMEINC!='object'||!TIMEINC) {
	window.TI=window.TIMEINC={};
}
if (typeof TIMEINC.NAV_WIDGET!='object'||!TIMEINC.NAV_WIDGET) {
	var tinw=TIMEINC.NAV_WIDGET={
		topnav:function() {
			$("#nav li").hover(
				function() {
					var secondNav=$(this).find("ul");
					$(secondNav).show();
					$(this).addClass("selected");
				}, 
				function() {
					var secondNav=$(this).find("ul");
					$(secondNav).hide();
					$(this).removeClass("selected");
			});
		},
		toggler:function() {
			var togglerContent=$('h6.toggler').siblings().get(0);
			var parentDiv=$('h6.toggler').parent().get(0);
			$('h6.toggler').click(function() {
				if($(parentDiv).hasClass("toggle_on")) {
					$(parentDiv).removeClass("toggle_on");
					$(togglerContent).hide();
				} else {
					$(parentDiv).addClass("toggle_on");
					$(togglerContent).show();
				}
			});
		},
		callFunctionOnWindowLoad:function(functionToCall) {
			if(typeof window.addEventListener!='undefined') {
				window.addEventListener('load',functionToCall,false);
			} 
			else if(typeof document.addEventListener!='undefined') {
				document.addEventListener('load',functionToCall,false);
			}
			else if(typeof window.attachEvent!='undefined') {
				window.attachEvent('onload',functionToCall);
			}
			else {
				var oldFunctionToCall=window.onload;
				if(typeof window.onload!='function') {
					window.onload=functionToCall;
				}
				else {
					window.onload=function() {
						oldFunctionToCall();
						functionToCall();
					};
				}
			}
		},
		EnableTopNavOnElementLoad:function(targetId) {
			var myArguments=arguments;tinw.callFunctionOnWindowLoad(function() {
				window.loaded=true;
			});
			var targetElement=document.getElementById(targetId);
			if (targetElement==null&&!window.loaded) {
				var pollingInterval=setInterval(function() {
					if(window.loaded) {
						clearInterval(pollingInterval);
					}
					targetElement=document.getElementById(targetId);
					if(targetElement!=null) {
						clearInterval(pollingInterval);tinw.topnav();tinw.toggler();
					}
				},
				250);
			}
		}
	};
}
TIMEINC.NAV_WIDGET.EnableTopNavOnElementLoad("topnav"); 
$(document).ready(function() {
	function getElementsByClass(searchClass,node,tag) {
		var classElements=new Array();
		if(node==null)node=document;
		if(tag==null)tag='*';
		var els=node.getElementsByTagName(tag);
		var elsLen=els.length;
            var pattern=new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
		for(i=0,j=0;i<elsLen;i++) {
			if(pattern.test(els[i].className)){
				classElements[j]=els[i];
				j++;
			}
		}
		return classElements;
	}
	if (getElementsByClass("CollapsAd")) {
		var foo=getElementsByClass("CollapsAd");
		for (var i=0;i<foo.length;i++) {
			var e=foo[i];
			e.parentNode.setAttribute("id","noAdSlug");
		}
	}
	// Outbrain omnitoolToolTrack
	$("#outbrain-org .outbrain_rec_li a").click(
		function() {
			omniToolTrack('outbrain|recirc');
	})
	$("#outbrain-paid .outbrain_ad_li a").click(
		function() {
			omniToolTrack('outbrain|sponsored');
	})		

	// Search Filter Show/Hide
	$("#more-topics").click(
		function() { 
			$("#by-topic-all").show();
			return(false);
		});

	$("#less-topics").click(
		function() { 
			$("#by-topic-all").hide();
			return(false);			
		});


});




