
Cufon.replace("h1");
Cufon.replace("h2");
Cufon.replace("h3");
Cufon.replace("h4");
Cufon.replace("strong.subHeader",{fontWeight:300});
Cufon.replace(".cufon", {hover: true});
Cufon.replace("#experts li")
Cufon.replace("#faqCategories a");
Cufon.replace("#faqGroups strong");
Cufon.replace("#productList a");
Cufon.replace('#topNav a', { hover: true });
Cufon.replace('#features p')
Cufon.replace('.cta', {hover: true});
Cufon.replace('.productLinks a', { hover: true, fontWeight: 600 });
Cufon.replace('#foCompareLink', { hover: true, fontWeight: 600 });
Cufon.replace('.largeNumber', {fontWeight: 600});
Cufon.replace('.source', {hover: true});
Cufon.replace('.sharethis', {hover: true});

var floodlightVals = new Array();

floodlightVals.push(['http://www.naturemade.com/retailer/ret_region.asp?tab=Products','store232']);
floodlightVals.push(['http://www.vitaminherbuniversity.com','forhe240']);
floodlightVals.push(['http://www.naturemade.com/UserAccount/uar_reward.asp?tab=Rewards&section=','welln972']);
floodlightVals.push(['http://www.naturemade.com/ProductDatabase/prd_main.asp?tab=Products&section=','natur996']);
floodlightVals.push(['http://blog.naturemade.com/hearthealth/','heart162']);
floodlightVals.push(['http://www.naturemade.com/bonusoffers/bo_main.asp?bid=fishoilHH','saveo433']);
floodlightVals.push(['http://www.naturemade.com/bonusoffers/bo_main.asp?bid=cholestoffHH','saveo964']);
floodlightVals.push(['http://www.naturemade.com/bonusoffers/bo_main.asp?bid=coq10HH','saveo806']);
floodlightVals.push(['http://www.naturemade.com/bonusoffers/bo_main.asp?bid=HHprds','saveo213']);
floodlightVals.push(['http://www.sam-e.com','sam-e808']);
floodlightVals.push(['http://www.tripleflex.com','tripl476']);
floodlightVals.push(['http://www.naturemade.com','natur519']);
floodlightVals.push(['http://www.naturemade.com/immunehealth','nmimm740']);

var floodlight = function(cat) {
	var axel = Math.random() + "";
	var a = axel * 10000000000000;
	$('body').append('<iframe src="http://fls.doubleclick.net/activityi;src=1659706;type=heart006;cat=' + cat + ';ord=' + a + '?" width="1" height="1" frameborder="0"></iframe>');
}

$(document).ready(function(){
	
	$('#foCompareLink').click(function(){
      $(this).toggleClass('active');
      $('#foCompareContainer').toggle();
      $('#productInformation').toggle();
      Cufon.refresh("#foCompareLink");
      return false;
    });

	$('#closeCompare').click(function(){
      $('#foCompareLink').removeClass('active');
      $('#foCompareContainer').hide();
      $('#productInformation').show();
      Cufon.refresh("#foCompareLink");
      return false;
    });
	
	$('a[rel=external]').live('click', function(){
		
		for(var i=0; i<floodlightVals.length; i++) {
			if(floodlightVals[i][0] == $(this).attr('href') || floodlightVals[i][0]+'/' == $(this).attr('href')) {
				try{console.log('track: '+floodlightVals[i][1]);}catch(e){}
				floodlight(floodlightVals[i][1]);
				break;
			}
		}
		
		if($(this).attr('href').indexOf('naturemade') > -1 || $(this).hasClass('nmLink')) {
			// nm link, no message
		} else {
			alert('You are now leaving the Nature Made Website.');
		}
		$(this).attr('target','_blank');
	
	});
	
	$('#mainNav>li').hover(function(){
		$('#mainNav>li').removeClass('active');
		$(this).addClass('active');
		if($(this).find('.subMenu').length && $(this).attr('setSubMenu') != 1) {
			$(this).find('.subMenu').css('left', -800);
			$(this).find('.subMenu').css('width',800);
			var menuItemWidth = $(this).width() / 2;
			var subMenuWidth = $(this).find('.subMenu ul').width() + 10;
			var subMenuLeft = menuItemWidth - (subMenuWidth / 2);
			try{console.log('subMenuWidth: '+subMenuWidth+', subMenuLeft:'+subMenuLeft)}catch(e){}3;
			$(this).find('.subMenu').css('left', subMenuLeft).css('width', subMenuWidth+20);
			$(this).attr('setSubMenu',1); // only do all of this math once...
		}
	}, function(){
		if(!$(this).hasClass('sectionActive')) {
			$(this).removeClass('active');
			$('.sectionActive').addClass('active');
		}
	});
	
	$('.sectionActive').hover();
	
	$('.subMenu a').each(function(){
		
		var path = document.location.pathname;
		if (path.charAt(path.length - 1) == "/") //remove trailing slash
		{
		  path = path.substring(0, path.length - 1);
		}
				
		if(path == $(this).attr('href')) {
			$(this).css('font-weight','bold').css('color','#333');
			$(this).addClass('noHover');
		}
		
	});
	
	$('.subMenu').each(function(){
		$(this).find('li:first').css('background','none');
	});

	$("#productSectionsScroll").scrollable({size: 1, globalNav: false}).navigator({navi: "#productList",naviItem: 'a',activeClass: 'active'});  
	Cufon.refresh('#productList a');
	$("#productList a").click(function(){
		Cufon.refresh('#productList a');
	});
	
	$('#healthyLivingHeader .getStarted').click(function(){
		pageTracker._trackEvent('Engagement Tool', 'Get Started');
	});
			
});