﻿$(document).ready(function () {
	fixPng();
	prepNav();
	disclaimer();
	loadProfile();
	quiz();
	loadHome();
	loadLabs();
	loadLounge();
	loadProducts();
	loadRegister();
	trackProfileSubmit();
	fixUsernameCookies();
});
	profileRedirect(); //Don't wait for DOM. 

var fixPng = function(){
	var x = '.png, #copy_img, #logo, #handheld, .handheld, .downStageImage, #nav li, #nav ul, .labarrow img, #act_remain, #sidecontent, .patch, .act_remain, .about #packshot, #tub_popup, #faq_puppy, .sm_icon';/*.questions*/
	DD_belatedPNG.fix(x);
}

var prepNav = function(){
	$('#nav').droppy();

	$("#nav > li > a").mouseover(function(){		
		$(this).parent().addClass('selected');
	})
	
	$("#nav > li > a").mouseout(function(){
		$(this).parent().removeClass('selected');
	});
	
	$('a[href$="quiz.aspx"]:not(.quiz_status_box a, #lnk_restart_quiz, .noredirect)').click(function(){
		trackProfile();
		if(!!BGC.cookie('skinType')){
			$(this).attr('href','/profile.aspx')
		}
	})
}

function profileRedirect(){
	if(!BGC.query['cp']){
		return true;
	}
	if(!!BGC.cookie('skinType')){
		window.location="/profile.aspx"
	}
	
}

var disclaimer = function(){
	return true;
/* //Disabled so disclaimer appears universally until specific pages identified.
	if($('body.profile').length < 1){
		$('#disclaimer').remove();
	}
*/
}

var loadProfile = function(){
	if($('body.profile').length < 1){
		return true;
	}
	
	if(!!BGC.query['allbadges']){
		BGC.cookie('badges','wind|food|smells|touchy|additives',365);
	}
	
	//$('body.default #profile_content h2').html('Which sensitive skin type do you have – oily, dry, combination or delicate?')
	
	$('#profile_switch a:not(.noredirect)').click(function(){
		var prefix = "skinType";		
		var x = $(this).attr('id');
		var toSet = x.substring(prefix.length,x.length);
		BGC.cookie('skinType',toSet,365);
		window.location.reload();
		return false;
	})
	
	$('#qa').find('dt').click(function(){
	    var $dt = $(this);
		if($dt.next('dd').css('display') != 'block'){
			$('#qa dt img').removeClass('expand');
			$('#qa dd').hide('fast');
		}
		$dt.find('img').toggleClass('expand');
		$dt.next('dd').toggle('fast');
	});
	
	$('#lnk_qa').click(function(){
		var h = $('#profile_content').height();
		$('#qa_content').css('top',h+'px');

		$('#qa').fadeIn(250,function(){
	        $('#qa_content').animate({top:0},500)
	    });
		return false;
	});
	
	$('#lnk_qa_close').click(function(){
		var h = $('#profile_content').height();
		$('#qa_content').animate({top:h+'px'},500,function(){
			$('#qa').fadeOut(250);
		});
		return false;
	});
	
	loadBadges();
	
	$('#patchStatus').html(badgeCount);
	
	if(!BGC.cookie('skinType')){
	    //$('#sidecontent').removeClass('results').addClass('noresults');
		$('#patchInfo').html('<h2 class="show">Learn something new<br>with every turn</h2><p>The Institute is filled with all kinds of surprises. You can play around in The Labs, where you\'ll learn how to care for your sensitive skin and earn robe patches by finding and completing all the activities.</p><p><a href="/quiz.aspx" onclick="trackProfile();">To get started, discover your Sensitivity Profile!</a></p>');
	}
	else{
	    //$('#sidecontent').removeClass('noresults').addClass('results');
	}
}

var quiz = function(){
	if($('body.quiz').length == 0){
		return true;
	}
	
	if(typeof(BGC.query['type']) != "undefined"){
		var olm = BGC.query['type'];
		if(isNaN(parseInt(olm)) == false){
			$('#q1').toggle();
			$('#q6').toggle();
			BGC.cookie('skinType',olm,365);
			if(!!BGC.cookie('requireProfile')){
				BGC.cookie('requireProfile',0,-1)
			}
		}
	}
	
	showContent('11');
	
	var quizValues = [0,0,0,0]; //oily, dry, combo, delicate
	
	var appendValues = function(x){
		switch(x){
			case('a'):
			quizValues[0]++
			break;
			
			case('b'):
			quizValues[1]++
			break;
			
			case('c'):
			quizValues[2]++
			break;
			
			case('d'):
			quizValues[3]++
			break;
		}
	};
	
	var processValues = function(){
		var l = quizValues.length;
		var q = quizValues[0];
		var w = 0;
		for(i=1;i<quizValues.length;i++){
			if(q<quizValues[i]){
				w=i;
			}
		}
		//BGC.cookie('skinType',w,365);
		//Pointroll tracking to return quiz values for external OLM.
		//$('#trackingFrame').attr('src','/pointroll.html?type='+w)
		if(!!BGC.cookie('requireProfile')){
			BGC.cookie('requireProfile',0,-1)
		}
		document.location='/quiz.aspx?type='+w;//Working around flaky Pointroll bug.
	}
	
	function toggle() {
		if($(this).attr('href').charAt(2) != 6){
			$(this).parents('.questions').toggle().next('.questions').toggle();
		}
		return false;
	}
	
	$('.questions a:not(.quiz_status_box a, #lnk_restart_quiz)').click(
		toggle
	);
	
	$('#q1 a').click(function(){
		showContent(12);
	})
	
	$('#q2 a').click(function(){
		showContent(13);
	})
	$('#q3 a').click(function(){
		showContent(14);
	})
	
	$('#q4 a').click(function(){
		showContent(15);
	})
	$('#q5 a').click(function(){
		processValues();
	})
	
	document.forms[0].onsubmit = function(){
		var regExEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,6})+$/
		var em = $('#txtEmail').attr('value');
		var username = escape($('#txtFirstName').attr('value'))
		BGC.cookie('profileUsername',username, 365);
		if (regExEmail.test(em) || em == '') {
			if(em != ''){
				dcsMultiTrack("www.cottonelleinstitute.com","cottonelleinstitute.com/Completequiz.aspx","SubmitButtonSensitivityprofile","6","COTIN_Conv_7","2","1","","");
			}
			this.submit();
		}
		else{
			$('.error').html('There seems to be a problem with your e-mail address.').toggle();
		}
		return false;
	}
	
	$('.answer a').click(function() {

		var x = $(this).attr('href').charAt(3);
		appendValues(x);
	});
}

var loadHome = function(){
	if($('body.home').length < 1){
		return true;
	}
	
	$('.logo_door').each(function(){
		var path = '/img/'
		var file = $(this).attr('rel');
		if(document.all){
			var ext = '.gif';
		}
		else{
			var ext = '.png';
		}
		$(this).attr('src',path+file+ext);
	});
	
	if(!!BGC.cookie('skinType')){
		var $copy = $('#copy div');
		var cookieName = (!!BGC.cookie('profileUsername')) ? BGC.cookie('profileUsername') : '';
		cookieName = (cookieName != '') ? ', ' + cookieName : '';
		var $nombre = $('#user_name');
		$nombre.text(cookieName);
		$copy.toggle();
	}
	socialNetworking();
	
	//slideDoors(); //Now called via Flash to ensure the sound loads.
}

//$('#home_cta').fadeIn(1000);
function slideDoors(){
	 if(BGC.cookie('visited') != 1){
		BGC.cookie('visited',1,365);
		$('.fauxscreen').hide(1, function(){
			$('#screenLeft').pause().animate({left:"-470px"},3750);
			$('#screenRight').pause().animate({right:"-470px"},3750, function(){
				$('.fauxscreen').show();
			 	$('#screenBox').hide();
				$('#home_sound')[0].callSWFSound('1');
			});
			$('.logo_door').fadeOut(3750);
		})
	}
}

var calculateDimensions = function(){
	
}

var loadLabs = function(){
	if($('body.labs').length < 1){
		return true;
	}
	$('#cards').show();

	var l = $('#cards .card').length;
	var dw = document.body.clientWidth;
	var oldDw = dw;
	var ww = 728;
	var center = Math.floor((dw/2)-(ww/2));
	var oldCenter = center;
	var calcEnds = Math.floor(l/2);
	var calcStart = Math.ceil(l/2);
	var startPos = (ww*calcEnds*-1)+center;
	var endPos = (ww*calcEnds)+center;
	var next = startPos;
	var startPoint = (!parseInt(BGC.query['lab'])) ? 1 : BGC.query['lab']; //calcStart to start @ middle card.
	startPoint = (startPoint <= l) ? startPoint : 1;
	var invStartPoint = startPoint;
	startPoint = (l+1) - startPoint;
	//var count = l;
	var timer = 500;
	var delay = 250;
	var screenOpen = ((parseInt($('#screenBox').css('width'))/2)-20)*-1;
	
	window.onresize = function(){
		dw = document.body.clientWidth;
		center = Math.floor((dw/2)-(ww/2));

		centerDiff = oldCenter-center;
		startPos = (ww*calcEnds*-1)+center;
		endPos = (ww*calcEnds)+center;
		
		$('.lab_mask').css('width',center);
		$('#screenBox').css('left',center);
		$('#screenLeft.open').css('left',screenOpen);
		$('#screenRight.open').css('right',screenOpen);
		$('#screenLeftFaux').css('left',center);
		$('#screenRightFaux').css('right',center);
		$('#lab_left').css('left',center-30);
		$('#lab_right').css('right',center-30);
		
		var dwDiff = (oldDw-dw)/2;
		$('.card').animate({left:'-='+dwDiff},250);
		oldDw = dw;
	}
	
	if($('#maskLeft').length < 1){	
		$('#labstage').prepend('<div class="lab_mask" id="maskLeft">&nbsp;</div>');
		$('#labstage').prepend('<div class="lab_mask" id="maskRight">&nbsp;</div>');
	}
	$('.lab_mask').css('width',center);
	$('#screenBox').css('left',center);
	$('#screenLeft.open').css('left',screenOpen);
	$('#screenRight.open').css('right',screenOpen);
	$('#screenLeftFaux').css('left',center);
	$('#screenRightFaux').css('right',center);
	$('#lab_left').css('left',center-30);
	$('#lab_right').css('right',center-30);
	showContent(invStartPoint);
	
	$('.card').each(function(){
		$(this).css('left',next);
		next += ww;
	})
	
	if(startPoint != calcStart){
		var offset = 0;
		offset = calcStart - startPoint;
		if(startPoint < calcStart){
			while(offset--){
				$('.card').animate({left:'-='+ww},0);
				$('.card:first').animate({left:endPos},0)	
				$('.card:first').insertAfter($('.card:last'))
			}
		}
		else{
			offset = offset*-1;
			while(offset--){
				$('.card').animate({left:'+='+ww},0);
				$('.card:last').animate({left:startPos},0)
				$('.card:last').insertBefore($('.card:first'))
			}
		}
	}
	
	var swapCopy = function(x){
		if(typeof(x) == 'undefined'){
			var i = $('#cards .card')[calcEnds].id;
			x = i.substring(3,i.length);			
		}
		$('#downStageCanvas').html(downStageArray[x])
	}
	
	var reportPosition = function(x){
		var b = $('.card')[2].id;
		var base = b.substring(3,b.length);
		var value = (base*1) + x;

		if(value > 5){
			value = 1
		}
		else if(value == 0){
			value = l
		}
		return value;
	}
	
	var summonSpotlightTag = function(x){
		var generateA = function(){
			var axel = Math.random()+"";
			return axel * 10000000000000;
		}
		var spotlight = [];
		spotlight[1] = 'http://fls.doubleclick.net/activityi;src=1708218;type=cotto797797;cat=windw478;ord='+ generateA() + '?'; //Wind and weather
		spotlight[2] = 'http://fls.doubleclick.net/activityi;src=1708218;type=cotto797;cat=foods374;ord='+ generateA() + '?'; //Food and spices
		spotlight[3] = 'http://fls.doubleclick.net/activityi;src=1708218;type=cotto797;cat=smell671;ord='+ generateA() + '?'; //Smells and scents
		spotlight[4] = 'http://fls.doubleclick.net/activityi;src=1708218;type=cotto797;cat=touch504;ord='+ generateA() + '?'; //Touchy feely
		spotlight[5] = 'http://fls.doubleclick.net/activityi;src=1708218;type=cotto797;cat=addit991;ord='+ generateA() + '?'; //Additives
		$('#dblClk').attr('src',spotlight[x]);
	}

	slideLeft = function(){
		$('.fauxscreen').hide();
		$('#screenBox').show(1,function(){
			$('#screenLeft').animate({left:"0"},250);
			$('#screenRight').animate({right:"0"},250);
			$('.card').pause(delay).animate({left:'-='+ww},timer);
			$('.card:first').animate({left:endPos},0);
			$('.card:first').insertAfter($('.card:last'));
			swapCopy()
			$('#screenLeft').pause(timer+delay).animate({left:screenOpen},delay, function(){
				$('.fauxscreen').show();
				$('#screenBox').hide();				
			});
			$('#screenRight').pause(timer+delay).animate({right:screenOpen},delay,stageIn);		
		});
		summonSpotlightTag(reportPosition(1));
	}
	
	slideRight = function(){
		$('.fauxscreen').hide();
		$('#screenBox').show(1,function(){
			$('#screenLeft').animate({left:"0"},250);
			$('#screenRight').animate({right:"0"},250);
			$('.card').pause(delay).animate({left:'+='+ww},timer);
			$('.card:last').animate({left:startPos},0);
			$('.card:last').insertBefore($('.card:first'));
			swapCopy();
			$('#screenLeft').pause(timer+delay).animate({left:screenOpen},delay,function(){
				$('.fauxscreen').show();
				$('#screenBox').hide();
			});
			$('#screenRight').pause(timer+delay).animate({right:screenOpen},delay,stageIn);
		});
		summonSpotlightTag(reportPosition(-1));
	}
	
	function refreshIntros(){
		/*
			Re-writing array indexes, as the cookie values are pre-set and need to be rewritten for the remaining activity count to be correct.
		*/
		downStageArray[1] = toExplore(6,'wind')+wind_intro;//12
		downStageArray[2] = toExplore(7,'food')+food_intro;//14
		downStageArray[3] = toExplore(9,'smells')+smells_intro;
		downStageArray[4] = toExplore(8,'touchy')+touchy_intro;
		downStageArray[5] = toExplore(9,'additives')+additives_intro;
	}
	
	window.nextLab = function(left){
		left = left || false;
		refreshIntros();
		if(left == true){
			stageOut(slideLeft);
		}
		else{
			stageOut(slideRight);
		}
	}
	
	$('#lab_right').click(function(){
		nextLab(true);
		return false;
	})
	
	$('#lab_left').click(function(){
		nextLab();
		return false;
	})
}

var loadLounge = function(){
	if($('body.lounge').length < 1){
		return true;
	}
	
	var c = $('#socialCanvas').width();
		
	function setStage(){
		var x = $('#nav').offset().left;
		$('#content').css('left',x);
		$('#footer').css('left',x);

		if($('#maskLeft').length < 1){	
			$('#content').prepend('<div class="lab_mask" id="maskLeft">&nbsp;</div>');
			$('#content').prepend('<div class="lab_mask" id="maskRight">&nbsp;</div>');
		}
		$('#maskLeft').css({
			'left':(-1*x),
			'width':x
		})
		$('#maskRight').css({
			'left':(c),
			'width':$(document).width() - (x+c)
		})	
	}
	
	$('.labarrow').click(function(){
		$(this).hide().siblings('.labarrow').show();
		toggleLounge($('#content'));
		socialNetworking();
		return false;
	}).siblings('#lab_right').css('left',c+10).siblings('#lab_left').css({'left':'-30px', 'display':'none'})
	
	$(window).resize(function(){
		setStage();
	})

	setStage();
	if(document.location.hash.length == 0){
		showContent(96);
		socialNetworking();
	}
	else{
		$('.canvas').each(function(){
			var w = $('.canvas').eq(0).width();
			$(this).css('left', parseInt($(this).css('left')) - w);
			showContent(6);
		})
	}
}

function loungeLinks(show, hide){
	var ul = $('.lounge_articles ul');
	ul.eq(show).show();
	ul.eq(hide).hide();
}

function toggleLounge(element){
	var timer = 200//500;
	var delay = 250;
	var screenOpen = ((parseInt($('#screenBox').css('width'))/2)-20)*-1;
    var first = element.children('.canvas').eq(0);
    var travel = (parseInt(first.css('left')) >= 0) ? '-='+first.width() : '+='+first.width();
	var s = $('body').data('stage');
	var toShow = (parseInt(first.css('left')) >= 0) ? (!!s && s != '') ? s : 6 : 96;
	$('.fauxscreen').hide();
	$('#screenBox').show(1,function(){
		showContent(toShow);
		if($('body').data('sm') == 'twitter'){
			var pause = setTimeout(function(){$('#sm_icon_twitter').addClass('select').siblings('.sm_icon').removeClass('select')}, 500)
		}
		$('#screenLeft').animate({left:"0"},250);
		$('#screenRight').animate({right:"0"},250, function(){
			element.children('.canvas').animate({left:travel},250);
		});
		$('#screenLeft').pause(timer+delay).animate({left:screenOpen},delay, function(){
			$('.fauxscreen').show();
			$('#screenBox').hide();				
		});
		$('#screenRight').pause(timer+delay).animate({right:screenOpen},delay,stageIn);		
	});
}

function loadProducts(){
	$('.tub_color').mouseover(function(){
		var pos = $(this).attr('rel');
		popUpShow(pos);
	});

	$('.tub_color').mouseout(popUpHide);
}

	function toSWFBreakfast(value){
		document.getElementById("additiveslab").callSWFBreakfast(value);
	}
	function toSWFFabric(value){
		document.getElementById("touchylab").callSWFFabric(value);
	}
	function toSWFPillows(value){
		document.getElementById("touchylab").callSWFPillows(value);
	}
	function toSWFUndies(value){
		document.getElementById("touchylab").callSWFUndies(value);
	}
	function toSWFJewelry(value){
		document.getElementById("touchylab").callSWFJewelry(value);
	}
	function toSWFSniff(value){
		document.getElementById("smellslab").callSWFSniff(value);
	}
	function toSWFHerbs(value){
		document.getElementById("smellslab").callSWFHerbs(value);
	}
	function toSWFSlippers(value){
		document.getElementById("smellslab").callSWFSlippers(value);
	}	
	function toSWFFish(value){
		document.getElementById("foodlab").callSWFFish(value);
	}
	function toSWFFood(value){
		document.getElementById("foodlab").callSWFFood(value);
	}
	function toSWFHat(value){
		document.getElementById("weatherlab").callSWFHat(value);
	}
	function toSWFPlant(value){
		document.getElementById("weatherlab").callSWFPlant(value);
	}
	function toSWFJar(value){
		document.getElementById("weatherlab").callSWFJar(value);
	}
	
var logActivity = function(lab, activity){
	var x = BGC.cookie('completeActivity'+lab)||'';
	var c = ',';
	var s = x.split(c);
	var sl = s.length;
	if(!activity){
		return x;
	}
	else{
		if(x.length > 0){
			while(sl--){
				if(s[sl] == activity){
					//Activity already set. No need for action.
					return true;
				}
			}
		}
		var y = (x == '') ? activity : x+c+activity;
		BGC.cookie('completeActivity'+lab,y,365);
	}
}

var logActivityCount = function(count,lab){
	BGC.cookie('completeActivityCount'+lab, count, 365);
	var count = BGC.cookie('completeActivityCount'+lab)
	var x = 0;
	switch(lab){
		case 'wind':
		x = 6;//12
		break;
		
		case 'food':
		x = 7;//14
		break;
		
		case 'smells':
		x = 9;
		break;
		
		case 'touchy':
		x = 8;
		break;
		
		case 'additives':
		x = 9;
		break;		
	}
	var a = (x-count)*-45;
	$('#act_remain'+lab).css('backgroundPosition','0 '+a+'px');
}

var next_link = function(linkid, linkstring, category, nextItem){
	var x = '<span id="dsLinkPool"><a href="#" onclick="showContent('+linkid+'); toSWF'+category+'(\''+nextItem+'\');return false;">'+linkstring+'</a></span>';
	return x;
}

var toExplore = function(actStart,lab){
	var c = BGC.cookie('completeActivityCount'+lab) || 0;
	c = (c > actStart) ? actStart : c;
	var a = (actStart-c)*-45;
	var x = '<div class="act_remain" id="act_remain'+lab+'" style="background-position: 0 '+a+'px">&nbsp;</div>';
	return x;
}

var badgeCount = (!!BGC.cookie('badges')) ? BGC.cookie('badges').split('|').length : 0;
var lounge_cta_swap = (badgeCount == 5) ? '<a href="/products.aspx"><img src="img/handheld_products.png" width="127" height="164" alt="" class="downStageImage"></a>' : '<a href="/labs.aspx"><img src="img/handheld_patches.png" width="127" height="164" alt="" class="downStageImage"></a>';

var labs_reminder = '<a href="/register.aspx"><img src="img/handheld_reminder.png" width="127" height="164" alt="" class="downStageImage"></a><img src="/img/handheld.png" class="handheld">';
var profile_cta = '<a href="/quiz.aspx" onclick="trackProfile();"><img src="img/handheld_cta_profile.png" width="127" height="164" alt="" class="downStageImage"></a><img src="/img/handheld.png" class="handheld">';
var lounge_cta = lounge_cta_swap + '<img src="/img/handheld.png" class="handheld">';
var quiz_paper = '<a href="/products.aspx"><img src="img/pack_paper.png" width="118" height="205" alt="" class="downStageImage"></a>';
var quiz_wipes = '<a href="/products.aspx"><img src="img/pack_wipes.png" width="129" height="174" alt="" class="downStageImage"></a>';
var labs_additives_breakfast = '<span id="dsIntro"><strong>Some additives</strong> can actually help your sensitive skin. These products have been fortified with skin-friendly vitamins and nutrients.</span>';
var labs_touchy_fabric = '<span id="dsIntro"><strong>Some fabrics</strong> are kinder to your sensitive skin than others.</span>';
var labs_touchy_undies = '<span id="dsIntro"><strong>A good pair of undies</strong> is essential to keeping your sensitive behind happy.</span>';
var labs_touchy_pillows = '<span id="dsIntro">Where you rest your head at night can affect your <strong>sensitive skin</strong> while you snooze.</span>';
var labs_touchy_jewelry = '<span id="dsIntro">Though it’s pretty, sparkly and fun to wear, some <span class="moreinfo">jewelry</span> can be harsh on your most sensitive parts.</span>';
var labs_smells_sniff = '<span id="dsIntro"><strong>After eating certain foods</strong>, your body can actually give off that food’s scent. It seeps right through your pores! You’ve sniffed out the smelliest culprits - garlic, onion and curry.</span>';
var labs_smells_herbs = '<span id="dsIntro"><strong>Aromatherapy</strong> uses herbal oils massaged into the skin to stimulate your sense of smell and boost your mood. Each herb works in its own way.</span>';
var labs_smells_slippers = '<span id="dsIntro"><strong>The skin on your feet</strong> can be the source of some very embarrassing odors. But there are a few easy ways to keep your toes from offending your nose.</span>';
var labs_food_fish = '<span id="dsIntro"><strong>The protein</strong> and omega-3 fatty acids found in most types of fish are great for helping your skin repair itself and maintain a healthy glow.</span>';
var labs_food_masque = '<span id="dsIntro"><strong>Believe it or not,</strong> your kitchen is a great place to mix up a soothing facial treatment. Using the things you find in your pantry, you can make your very own natural face masque. Click on an ingredient to see what kind of skin-hydrating, wrinkle-fighting, rejuvenating powers it possesses.</span>';
var labs_wind_hats = '<span id="dsIntro"><strong>Hats are great</strong> for helping to block the sun’s harmful rays and helping to prevent skin damage. Keep a variety of hats on hand for different outdoor situations.</span>';
var labs_wind_plants = '<span id="dsIntro"><strong>When you’re camping,</strong> hiking or you just gotta go, be sure to watch where you … um … do your business. Some plants can leave a lasting (and very unwelcome) impression on your bottom. Be sure to bring Cottonelle® Aloe & E Toilet Paper on all your outdoor adventures.</span>';
var labs_wind_jars = '<span id="dsIntro"><strong>All sorts of environmental</strong> factors can affect the way your skin looks and feels, and even how it repairs itself.</span>';

var wind_intro = '<img src="/img/handheld.png" class="handheld"><p id="downStageCopy"><strong>Welcome to the Wind & Weather Lab.</strong> Use your mouse to explore and learn. Be on the lookout for the puppy paw - it’ll let you know when you’ve found an activity.  Find and complete all the lab activities to earn a patch for your robe.</p>'
var food_intro = '<img src="/img/handheld.png" class="handheld"><p id="downStageCopy"><strong>Welcome to the Food & Spices Lab.</strong> Use your mouse to explore and learn. Be on the lookout for the puppy paw – it’ll let you know when you’ve found an activity. Find and complete all the lab activities to earn a patch for your robe.</p>';
var smells_intro = '<img src="/img/handheld.png" class="handheld"><p id="downStageCopy"><strong>Welcome to the Smells & Scents Lab.</strong> Use your mouse to explore and learn. Be on the lookout for the puppy paw – it’ll let you know when you’ve found an activity. Find and complete all the lab activities to earn a patch for your robe.</p>';
var touchy_intro = '<img src="/img/handheld.png" class="handheld"><p id="downStageCopy"><strong>Welcome to the Touchy Feely Lab.</strong> Use your mouse to explore and learn. Be on the lookout for the puppy paw – it’ll let you know when you’ve found an activity. Find and complete all the lab activities to earn a patch for your robe.</p>';
var additives_intro = '<img src="/img/handheld.png" class="handheld"><p id="downStageCopy"><strong>Welcome to the Additives Lab.</strong> Use your mouse to explore and learn. Be on the lookout for the puppy paw – it’ll let you know when you’ve found an activity. Find and complete all the lab activities to earn a patch for your robe.</p>';
var article_intro = "<p><strong>Get expert tips</strong> about how to care for your sensitive skin. Click an article title to download the PDF. </p>";
var article_intro_links = "<p><strong>Get expert tips</strong> about how to care for your sensitive skin. Click a title to view that article. </p>";

var downStageArray = [];

// Labs - Main
downStageArray[52] = '&nbsp;';//12
downStageArray[1] = toExplore(6,'wind')+wind_intro;//12
downStageArray[2] = toExplore(7,'food')+food_intro;//14
downStageArray[3] = toExplore(9,'smells')+smells_intro;
//downStageArray[3] = labs_reminder+'<p id="downStageCopy">Seems the door to the Smells & Scents Lab is locked. But no worries, you’ll be able to sniff around in there soon enough. Until then, keep exploring!</p>';
downStageArray[4] = toExplore(8,'touchy')+touchy_intro;
//downStageArray[4] = labs_reminder+'<p id="downStageCopy">Looks as if the door to the Touchy Feely Lab is locked. But no worries, you’ll be able to get inside and poke around very soon. Until then, keep exploring!</p>';
downStageArray[5] = toExplore(9,'additives')+additives_intro;
//downStageArray[5] = labs_reminder+'<p id="downStageCopy">Seems the door to the Additives Lab is locked. But no worries, before long you’ll be able to discover what’s inside. Until then, keep exploring!</p>';
downStageArray[43] = profile_cta+'<p id="downStageCopy">To keep exploring, head to <a href="/quiz.aspx" onclick="trackProfile();">The Lobby</a> and fill out your Sensitivity Profile. Then come on back to The Labs to complete activities, learn how to gently care for your skin and earn patches for your robe.</p>'; // Purpose

//downStageArray[] = '<p id="downStageCopy"></p>'; // Purpose


// Labs - Additives
downStageArray[81] = '<img src="/img/lab_add_water.png" class="downStageImage" id="dsWater"><p id="downStageCopy">'+labs_additives_breakfast+'There are all kinds of <span class="moreinfo">fortified waters</span> out there that not only keep skin hydrated, but also contain vitamins that can help your skin repair itself.'+next_link(82,'&raquo; Next Product','Breakfast','juice')+'</p>'; // Breakfast - Water 
downStageArray[82] = '<img src="/img/lab_add_oj.png" class="downStageImage" id="dsOj"><p id="downStageCopy">'+labs_additives_breakfast+'<span class="moreinfo">Orange juice</span> is naturally full of vitamin C, but some varieties are fortified with vitamin E. Both vitamins can help counter the effects of sun exposure.'+next_link(83,'&raquo; Next Product','Breakfast','cereal')+'</p>'; // Breakfast - Orange Juice
downStageArray[83] = '<img src="/img/lab_add_cereal.png" class="downStageImage" id="dsCereal"><p id="downStageCopy">'+labs_additives_breakfast+'Many <span class="moreinfo">cereals</span> are now fortified with vitamins that can help you maintain a healthy glow.'+next_link(81,'&raquo; Next Product','Breakfast','water')+'</p>'; // Breakfast - Cereal

downStageArray[84] = '<img src="/img/lab_add_bucket.png" class="downStageImage" id="dsBucket"><p id="downStageCopy">Uh oh. There’s a spill on the floor that needs cleaning up, but harsh chemicals in <strong>cleaning supplies</strong> can really irritate your skin. Click the three things you’ll need to mop up the mess without drying out your hands.</p>'; // Cleaning Supplies

downStageArray[85] = '<img src="/img/lab_add_detergent.png" class="downStageImage" id="dsDetergent"><p id="downStageCopy">The chemicals and fragrances in certain <strong>laundry detergents</strong> can leave some folks with an itchy dilemma. Try washing your clothes with a mild, fragrance-free or natural detergent to stay itch-free.</p>'; // Detergent

downStageArray[86] = '<img src="/img/lab_add_cosmetic.png" class="downStageImage" id="dsCosmetic"><p id="downStageCopy">Preservatives give your <strong>cosmetics</strong> a longer shelf life. But be careful; makeup can still "go bad" and cause skin irritations or infections. Match these cosmetics to the length of time you can safely use them.</p>'; // Cosmetics

downStageArray[87] = '<img src="/img/lab_add_sugar.png" class="downStageImage" id="dsSugar"><p id="downStageCopy">Yikes! Did you know that <strong>foods with added sugars</strong> can actually cause wrinkles? The tricky part is knowing which foods to avoid, because sugar can "hide" in the ingredient list under an unfamiliar name. To keep your skin looking young and fresh, try steering clear of foods that contain high fructose corn syrup, maltose or turbinado.</p>'; // Sugar

downStageArray[88] = '<img src="/img/lab_pack_paper.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>Cottonelle® Aloe & E Toilet Paper</strong> has Aloe and Vitamin E added to each and every roll.</p>'; // Rolls

downStageArray[89] = '<img src="/img/lab_pack_wipes.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>Cottonelle® SoothingClean™ Flushable Moist Wipes</strong> are dermatologist-tested and have Aloe and Vitamin E added to each and every wipe.</p>'; // Wipes

// Labs - Touchy
downStageArray[53] = '<img src="/img/lab_touch_poly.png" class="downStageImage" id="dsPoly"><p id="downStageCopy">'+labs_touchy_fabric+'<span class="moreinfo">Polyester</span> can trap sweat against your body and cause skin to chafe.'+next_link(54,'&raquo; Next Fabric','Fabric','wool')+'</p>'; // Fabric - Polyester 
downStageArray[54] = '<img src="/img/lab_touch_wool.png" class="downStageImage" id="dsWool"><p id="downStageCopy">'+labs_touchy_fabric+'<span class="moreinfo">Wool</span> can cause an itching and sneezing frenzy. Try sticking to wools labeled "hypoallergenic."'+next_link(55,'&raquo; Next Fabric','Fabric','cotton')+'</p>'; // Fabric - Wool
downStageArray[55] = '<img src="/img/lab_touch_cotton.png" class="downStageImage" id="dsCotton"><p id="downStageCopy">'+labs_touchy_fabric+'<span class="moreinfo">Cotton</span> is breathable, soft, and comfy for nearly all types of sensitive skin.'+next_link(53,'&raquo; Next Fabric','Fabric','polyester')+'</p>'; // Fabric - Cotton

downStageArray[56] = '<img src="/img/lab_touch_sink.png" class="downStageImage" id="dsSink"><p id="downStageCopy"><strong>Keeping your hands</strong> germ-free is important. But washing them too often can leave them dry and sore. For smooth hands, moisturize after every wash. And use rubber gloves during household chores - you’ll avoid the sting of chemical cleansers and won’t have to wash your hands as often.</p>'; // Sink

downStageArray[57] = '<img src="/img/lab_touch_boy.png" class="downStageImage" id="dsBoy"><p id="downStageCopy">'+labs_touchy_undies+'<span class="moreinfo">Boy shorts</span> offer the best of both worlds - a close fit with plenty of coverage.'+next_link(58,'&raquo; Next Pair','Undies','briefs')+'</p>'; // Undies - Shorts
downStageArray[58] = '<img src="/img/lab_touch_brief.png" class="downStageImage" id="dsBrief"><p id="downStageCopy">'+labs_touchy_undies+'A breathable pair of cotton <span class="moreinfo">briefs</span> is a classic, comfortable choice.'+next_link(59,'&raquo; Next Pair','Undies','boxers')+'</p>'; // Undies - Briefs
downStageArray[59] = '<img src="/img/lab_touch_boxer.png" class="downStageImage" id="dsBoxer"><p id="downStageCopy">'+labs_touchy_undies+'<span class="moreinfo">Boxers</span> let your rear end relax. They’re comfy without being restricting.'+next_link(57,'&raquo; Next Pair','Undies','shorts')+'</p>'; // Undies - Boxers 

downStageArray[61] = '<img src="/img/lab_pack_wipes.png" class="downStageImage" id="dsProduct"><img src="/img/pack_wipes.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>Cottonelle® SoothingClean™ Flushable Moist Wipes</strong> contain Aloe and Vitamin E. Just one touch and you’ll see, they’re the ultimate in gentle and clean.</p>'; // Wipes

downStageArray[62] = '<img src="/img/lab_pack_paper.png" class="downStageImage" id="dsProduct"><img src="/img/pack_paper.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>Soft and soothing</strong> to the touch, Cottonelle® Aloe & E Toilet Paper is our most gentle ever.</p>'; // Rolls

downStageArray[63] = '<img src="/img/lab_touch_down.png" class="downStageImage" id="dsDown"><p id="downStageCopy">'+labs_touchy_pillows+'<span class="moreinfo">Feather and down pillows</span> can cause an itchy rash for folks with very sensitive skin. Try one that’s labeled hypoallergenic for all the plush comfort without the irritation.'+next_link(64,'&raquo; Next Pillow','Pillows','synthetic')+'</p>'; // Pillows - Feather
downStageArray[64] = '<img src="/img/lab_touch_synth.png" class="downStageImage" id="dsSynth"><p id="downStageCopy">'+labs_touchy_pillows+'<span class="moreinfo">Synthetic pillows</span> tend to hold onto dust and germs more so than feather pillows. Be sure to wash your pillowcase often, and replace your pillows every few years.'+next_link(63,'&raquo; Next Pillow','Pillows','feather')+'</p>'; // Pillows - Synthetic

downStageArray[65] = '<img src="/img/lab_touch_jewel.png" class="downStageImage" id="dsJewel"><p id="downStageCopy">'+labs_touchy_jewelry+'Wearing <span class="moreinfo">heavy earrings</span> or wearing <span class="moreinfo">earrings</span> several days in a row can really irritate your earlobes. Try to steer clear of earrings containing nickel, and give your ears a day’s rest once in a while.'+next_link(66,'&raquo; Next','Jewelry','necklaces')+'</p>'; // Jewelry - Earrings
downStageArray[66] = '<img src="/img/lab_touch_jewel.png" class="downStageImage" id="dsJewel"><p id="downStageCopy">'+labs_touchy_jewelry+'Certain <span class="moreinfo">necklaces</span> can react to the oil on your skin, turning your skin black or green. Unless it’s itchy, it’s nothing to worry about and can be easily washed away with a mild cleanser.'+next_link(67,'&raquo; Next','Jewelry','rings')+'</p>'; // Jewelry - Necklaces
downStageArray[67] = '<img src="/img/lab_touch_jewel.png" class="downStageImage" id="dsJewel"><p id="downStageCopy">'+labs_touchy_jewelry+'<span class="moreinfo">Rings</span> can cause your fingers to develop a callus if they’re worn regularly. To keep your knuckles from over-drying, try using a thick moisturizer on your hands before bedtime.'+next_link(65,'&raquo; Next','Jewelry','earrings')+'</p>'; // Jewelry - Rings

// Labs - Smells
downStageArray[68] = '<img src="/img/lab_smell_onion.png" class="downStageImage" id="dsOnion"><p id="downStageCopy">'+labs_smells_sniff+'<span class="moreinfo">Onion:</span> Great on sandwiches, in salads and for repelling friends.'+next_link(69,'&raquo; Next Item','Sniff','garlic')+'</p>'; // Sniff - Onions 
downStageArray[69] = '<img src="/img/lab_smell_garlic.png" class="downStageImage" id="dsGarlic"><p id="downStageCopy">'+labs_smells_sniff+'<span class="moreinfo">Garlic:</span> An Italian food staple that’s perfect for pasta and bad for breath.'+next_link(70,'&raquo; Next Item','Sniff','curry')+'</p>'; // Sniff - Garlic
downStageArray[70] = '<img src="/img/lab_smell_curry.png" class="downStageImage" id="dsCurry"><p id="downStageCopy">'+labs_smells_sniff+'<span class="moreinfo">Curry:</span> A traditional Indian spice that can create a powerful smelling "aura."'+next_link(68,'&raquo; Next Item','Sniff','onions')+'</p>'; // Sniff - Curry

downStageArray[71] = '<img src="/img/lab_smell_jasmine.png" class="downStageImage" id="dsJasmine"><p id="downStageCopy">'+labs_smells_herbs+'<span class="moreinfo">Jasmine:</span> soothed and uplifted'+next_link(72,'&raquo; Next Herb','Herbs','lemongrass')+'</p>'; // Herbs - Jasmine 
downStageArray[72] = '<img src="/img/lab_smell_lemongrass.png" class="downStageImage" id="dsLemongrass"><p id="downStageCopy">'+labs_smells_herbs+'<span class="moreinfo">Lemongrass:</span> refreshed and rejuvenated'+next_link(73,'&raquo; Next Herb','Herbs','lavender')+'</p>'; // Herbs - Lemongrass
downStageArray[73] = '<img src="/img/lab_smell_lavender.png" class="downStageImage" id="dsLavender"><p id="downStageCopy">'+labs_smells_herbs+'<span class="moreinfo">Lavender:</span> calm and relaxed'+next_link(71,'&raquo; Next Herb','Herbs','jasmine')+'</p>'; // Herbs - Lavender

downStageArray[74] = '<img src="/img/lab_smell_feet.png" class="downStageImage" id="dsFeet"><p id="downStageCopy">'+labs_smells_slippers+'Sprinkling a medicated <span class="moreinfo">foot powder</span> on your feet can help absorb sweat and odors.'+next_link(75,'&raquo; Next Product','Slippers','insoles')+'</p>'; // Slippers - Foot Powder 
downStageArray[75] = '<img src="/img/lab_smell_feet.png" class="downStageImage" id="dsFeet"><p id="downStageCopy">'+labs_smells_slippers+'Sliding odor-absorbing <span class="moreinfo">insoles</span> into your shoes can stop stink and put a spring in your step.'+next_link(76,'&raquo; Next Product','Slippers','antiperspirant')+'</p>'; // Slippers - Insoles
downStageArray[76] = '<img src="/img/lab_smell_feet.png" class="downStageImage" id="dsFeet"><p id="downStageCopy">'+labs_smells_slippers+'Sounds crazy, but applying your underarm <span class="moreinfo">antiperspirant</span> to your feet can actually help them stay dry.'+next_link(74,'&raquo; Next Product','Slippers','foot powder')+'</p>'; // Slippers - Antiperspirant
 
downStageArray[77] = '<img src="/img/lab_smell_perfume.png" class="downStageImage" id="ds"><p id="downStageCopy"><strong>Perfume</strong> can irritate your skin all by itself or by reacting with another product you’ve already applied. Try spraying perfume on your clothing, instead of your skin, to avoid the chance of irritation.</p>'; // Perfume

downStageArray[78] = '<img src="/img/lab_pack_wipes.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>Cottonelle® SoothingClean™ Flushable Moist Wipes</strong> have a light, clean scent, and are dermatologist-tested and extra gentle for a soothing feel.</p>'; // Wipes

downStageArray[79] = '<img src="/img/lab_pack_paper.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>Soft and soothing</strong> to the touch, Cottonelle® Aloe & E Toilet Paper is our most gentle ever.</p>'; // Rolls

downStageArray[80] = '<img src="/img/lab_smell_exercise.png" class="downStageImage" id="dsExercise"><p id="downStageCopy"><strong>It’s important to sweat</strong> during exercise, because it’s your body’s way of keeping cool. So hold off on applying antiperspirant until after your workout, to prevent overheating.</p>'; // Exercise
 
// Labs - Food
downStageArray[17] = '<img src="/img/pack_wipes.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>When spicy foods</strong> leave your bottom down and out, try the gentle comfort of Cottonelle® SoothingClean™ Flushable Moist Wipes. They’re dermatologist-tested.</p>'; // Wipes Tub

downStageArray[18] = '<img src="/img/lab_food_salmon.png" class="downStageImage" id="dsFish"><p id="downStageCopy">'+labs_food_fish+'<span class="moreinfo">Salmon:</span> Great on the grill and super skin-friendly.'+next_link(19,'&raquo; Next Fish','Fish','tuna')+'</p>'; // Fish - Salmon
downStageArray[19] = '<img src="/img/lab_food_tuna.png" class="downStageImage" id="dsFish"><p id="downStageCopy">'+labs_food_fish+'<span class="moreinfo">Tuna Fish:</span> Tasty in a casserole, terrific for your complexion.'+next_link(20,'&raquo; Next Fish','Fish','trout')+'</p>'; // Fish - Tuna
downStageArray[20] = '<img src="/img/lab_food_trout.png" class="downStageImage" id="dsFish"><p id="downStageCopy">'+labs_food_fish+'<span class="moreinfo">Trout:</span> A freshwater favorite for fresh-feeling skin.'+next_link(18,'&raquo; Next Fish','Fish','salmon')+'</p>'; // Fish - Trout

downStageArray[21] = '<img src="/img/lab_food_peppers.jpg" class="downStageImage" id="dsPeppers"><p id="downStageCopy"><strong>Spicy foods, like peppers,</strong> can cause your skin to flush and turn red. Even your hands can be affected if you’re cutting something hot enough. When you’re picking peppers, there’s one thing to remember – the smaller they are, the bigger their spicy bite. With that in mind, <span class="moreinfo">click and drag to put these peppers in order from mild to spicy.</span></p>'; // Peppers

downStageArray[22] = '<img src="/img/lab_food_cucumber.png" class="downStageImage" id="dsMasque"><p id="downStageCopy">'+labs_food_masque+'<strong>Cucumber:</strong> Gives a great cooling sensation. Lay a couple of slices over your eyes to reduce puffiness.'+next_link(23,'&raquo; Next Ingredient','Food','honey')+'</p>'; // Masque-Cucumber
downStageArray[23] = '<img src="/img/lab_food_honey.png" class="downStageImage" id="dsMasque-honey"><p id="downStageCopy">'+labs_food_masque+'<strong>Honey:</strong> Helps draw blemishes and impurities out of the skin. Mix it with another liquid ingredient to decrease the stickiness factor.'+next_link(24,'&raquo; Next Ingredient','Food','lemon')+'</p>'; // Masque-Honey
downStageArray[24] = '<img src="/img/lab_food_lemon.png" class="downStageImage" id="dsMasque"><p id="downStageCopy">'+labs_food_masque+'<strong>Lemon:</strong> Squeeze a tablespoonful into your facial mixture. It\'s great for keeping oil in check, and it smells nice, too!'+next_link(25,'&raquo; Next Ingredient','Food','milk')+'</p>'; // Masque-Lemon
downStageArray[25] = '<img src="/img/lab_food_milk.png" class="downStageImage" id="dsMasque"><p id="downStageCopy">'+labs_food_masque+'<strong>Powdered Milk:</strong> Helps turn any facial mixture into an easy-to-apply paste. Great for soothing irritated or dry skin, too.'+next_link(26,'&raquo; Next Ingredient','Food','oatmeal')+'</p>'; // Masque-Powdered Milk
downStageArray[26] = '<img src="/img/lab_food_oatmeal.png" class="downStageImage" id="dsMasque-oatmeal"><p id="downStageCopy">'+labs_food_masque+'<strong>Oatmeal:</strong> Great for absorbing oil and can also be used as a gentle exfoliant. Just be sure to use the all-natural quick oats, not the flavored versions.'+next_link(27,'&raquo; Next Ingredient','Food','pineapple')+'</p>'; // Masque-Oatmeal
downStageArray[27] = '<img src="/img/lab_food_pineapple.png" class="downStageImage" id="dsMasque-pineapple"><p id="downStageCopy">'+labs_food_masque+'<strong>Pineapple:</strong> The crushed, canned kind in its own juice is easiest to add to your facial mix. It might leave you a bit sticky, but it works great to brighten dull skin.'+next_link(28,'&raquo; Next Ingredient','Food','salt')+'</p>'; // Masque-Pineapple
downStageArray[28] = '<img src="/img/lab_food_salt.png" class="downStageImage" id="dsMasque-salt"><p id="downStageCopy">'+labs_food_masque+'<strong>Salt:</strong> When moistened, it’s a great natural exfoliant. Just be careful around your eyes!'+next_link(29,'&raquo; Next Ingredient','Food','yogurt')+'</p>'; // Masque-Salt
downStageArray[29] = '<img src="/img/lab_food_yogurt.png" class="downStageImage" id="dsMasque-yogurt"><p id="downStageCopy">'+labs_food_masque+'<strong>Yogurt:</strong> A great facial base, it has been known to soothe, cool and moisturize skin all at the same time.'+next_link(22,'&raquo; Next Ingredient','Food','cucumber')+'</p>'; // Masque-Yogurt

downStageArray[30] = '<img src="/img/lab_food_halloffame.png" class="downStageImage" id="dsHOF"><p id="downStageCopy"><strong>Some ethnic and regional cuisines</strong> are famous (or infamous, depending on your preference for spice) for the amount of heat they bring to the table. And we all know spicy foods can sometimes cause problems for our backsides. <span class="moreinfo">Rate each cuisine’s spiciness on a scale of one through four rolls of Cottonelle® Aloe & E Toilet Paper. If you think four rolls just isn’t enough, bump it up to the highest rating – Cottonelle® SoothingClean™ Flushable Moist Wipes.</span></p>'; // Purpose

// Labs - Wind
downStageArray[31] = downStageArray[1]; // Intro - Duplicate of  [1]
downStageArray[32] = '<img src="/img/lab_pack_wipes.png" class="downStageImage" id="dsProduct"><p id="downStageCopy"><strong>When the wind and weather</strong> are really rough on your bottom, try the gentle comfort of Cottonelle® SoothingClean™ Flushable Moist Wipes. They’re dermatologist-tested.</p>'; // Wipes

downStageArray[33] = '<img src="/img/lab_wind_baseball.png" class="downStageImage" id="dsHat"><p id="downStageCopy">'+labs_wind_hats+'<span class="moreinfo">This baseball cap</span> is great for a day at the park or a good workout. It helps block the sun from reaching your face and stops sweat in its tracks.'+next_link(34,'&raquo; Next Hat','Hat','safari')+'</p>'; // Hat - Baseball
downStageArray[34] = '<img src="/img/lab_wind_safari.png" class="downStageImage" id="dsHat"><p id="downStageCopy">'+labs_wind_hats+'<span class="moreinfo">This Sahara hat</span> is perfect for gardening, because it covers the back of your neck while you dig and plant away.'+next_link(35,'&raquo; Next Hat','Hat','floppy')+'</p>'; // Hat - Sahara
downStageArray[35] = '<img src="/img/lab_wind_floppy.png" class="downStageImage" id="dsHat"><p id="downStageCopy">'+labs_wind_hats+'<span class="moreinfo">This floppy hat</span> is perfect for a day at the beach. The wide brim can help block the sun from all angles. Just be sure to wear plenty of sunscreen, too.'+next_link(33,'&raquo; Next Hat','Hat','baseball')+'</p>'; // Hat - Floppy

downStageArray[36] = '<img src="/img/lab_wind_ivy.png" class="downStageImage" id="dsPlants-ivy"><p id="downStageCopy">'+labs_wind_plants+'The toxic sap in <span class="moreinfo">poison ivy</span> can give your tush an itchy rash if you get too close.'+next_link(37,'&raquo; Next Plant','Plant','flowers')+'</p>'; // Plants - Poison Ivy
downStageArray[37] = '<img src="/img/lab_wind_flowers.png" class="downStageImage" id="dsPlants-flowers"><p id="downStageCopy">'+labs_wind_plants+'Certain flowers, like <span class="moreinfo">buttercups and daffodils</span>, though pretty and seemingly harmless, contain toxins that can make skin feel dry and itchy.'+next_link(38,'&raquo; Next Plant','Plant','aloe')+'</p>'; // Plants - Flowers
downStageArray[38] = '<img src="/img/lab_wind_aloe.png" class="downStageImage" id="dsPlants-aloe"><p id="downStageCopy">'+labs_wind_plants+'<span class="moreinfo">Aloe plants</span> with their pokey leaves might look menacing. But the oils inside them are great at relieving what ails your skin – burns, itches, bites and dryness. '+next_link(36,'&raquo; Next Plant','Plant','ivy')+'</p>'; // Plants - Aloe

downStageArray[39] = '<img src="/img/lab_wind_window.png" class="downStageImage" id="dsWindow"><p id="downStageCopy"><strong>Whether you sit</strong> all day in an air-conditioned building or you live somewhere that gets chilly during winter, the cold can be hard on your skin. Cold, dry air can leave you with chapped lips, cracked hands, even a not-so-smooth tush. To stay moisturized any time of year, drink plenty of water, and keep a good body lotion and lip balm on hand.</p>'; // Window

downStageArray[40] = '<img src="/img/lab_wind_pollution.png" class="downStageImage" id="dsJars"><p id="downStageCopy">'+labs_wind_jars+'<span class="moreinfo">Pollution</span> can actually interfere with the way your skin rebuilds and heals itself. A good, sudsy scrub can help keep your skin fresh, clean and clear of pollutants.'+next_link(41,'&raquo; Next Jar','Jar','dust')+'</p>'; // Jars - Pollution
downStageArray[41] = '<img src="/img/lab_wind_dust.png" class="downStageImage" id="dsJars"><p id="downStageCopy">'+labs_wind_jars+'<span class="moreinfo">Dust</span> can clog your pores, leading to blemishes and irritations. Believe it or not, a good vacuuming of your living space is a great way to help keep dust at bay and your skin feeling fine.'+next_link(42,'&raquo; Next Jar','Jar','smoke')+'</p>'; // Jars - Dust
downStageArray[42] = '<img src="/img/lab_wind_smoke.png" class="downStageImage" id="dsJars"><p id="downStageCopy">'+labs_wind_jars+'The skin-damaging and aging effects of <span class="moreinfo">cigarette smoke</span> are second only to those of the sun. Try to limit your exposure to smoke as much as possible.'+next_link(40,'&raquo; Next Jar','Jar','pollution')+'</p>'; // Jars - Smoke

downStageArray[44] = '<img src="/img/lab_wind_computer.png" class="downStageImage" id="dsComputer"><p id="downStageCopy"><strong>Click play</strong> to watch an exclusive video starring the Cottonelle® Puppy.</p>'; // Computer - Hover

// Patches
downStageArray[45] = '<img src="/img/lab_wind_patch.png" class="downStageImage" id="dsPatch"><p id="downStageCopy"><strong>Great job! You’ve earned your Wind & Weather patch.</strong><br><span id="dsLinkPoolAlt"><strong><a href="/profile.aspx">&raquo; View your patch-earning progress in My Profile</a></strong><br><strong><a href="/labs.aspx?lab=2">&raquo; Continue exploring in the Food & Spices Lab</a></strong></span></p>'; // Food Patch
downStageArray[46] = '<img src="/img/lab_food_patch.png" class="downStageImage" id="dsPatch"><p id="downStageCopy"><strong>Way to go! You’ve earned your Food & Spices patch.</strong><br><span id="dsLinkPoolAlt"><strong><a href="/profile.aspx">&raquo; View your patch-earning progress in My Profile</a></strong><br><strong><a href="/labs.aspx?lab=1">&raquo; Continue exploring in the Wind & Weather Lab</a></strong></span></p>'; // Wind Patch
downStageArray[47] = '<p id="downStageCopy"></p>'; //  Patch
downStageArray[48] = '<p id="downStageCopy"></p>'; //  Patch
downStageArray[49] = '<p id="downStageCopy"></p>'; //  Patch


//Lounge
downStageArray[6] = lounge_cta+'<p id="downStageCopy"><strong>Welcome to The Lounge</strong>, where you can relax, play games and let your caboose loose. Use your mouse to explore.  Be on the lookout for the puppy paw - it’ll let you know when you’ve found an activity.</p>'; //Lounge - Home
downStageArray[7] = lounge_cta+'<p id="downStageCopy">Click to watch the Cottonelle Institute television commercial, starring the Cottonelle® Puppy.</p>'; // TV - Hover
downStageArray[50] = lounge_cta+'<p id="downStageCopy"><strong>Click play</strong> to watch the Cottonelle Institute television commercial, starring the Cottonelle® Puppy.</p>'; // TV - Click
downStageArray[8] = lounge_cta+'<p id="downStageCopy">Click to play Sudoku, the addicting game of numbers, logic and deduction.</p>'; // Game Book - Hover
downStageArray[9] = lounge_cta+'<p id="downStageCopy">Nothing is more relaxing than some mellow tunes. Download the full 15-minute compilation. Or choose your favorite laid-back track. Click to check them out.</p>'; // Radio - Hover
downStageArray[10] = lounge_cta+'<p id="downStageCopy">Click to try your hand at a skin-care word search. </p>'; // Newspaper - Hover
downStageArray[51] = lounge_cta+'<p id="downStageCopy">Click to get expert skin-care tips from our trusted editorial partners.</p>'; // Advertorial - Hover

downStageArray[90] = '<img src="img/lounge_articles_womenshealth.gif" width="138" height="29" alt="" class="downStageImage" id="dsArticleLogo"><div id="downStageCopy" class="lounge_articles">' + article_intro + '<ul><li><a href="/pdf/lounge_advert_wh1.pdf" target="_blank">Booty Bulletin #1</a></li><li><a href="/pdf/lounge_advert_wh2.pdf" target="_blank">Booty Bulletin #2</a></li><li><a href="/pdf/lounge_advert_wh3.pdf" target="_blank">Booty Bulletin #3</a></li></ul></div>';
downStageArray[91] = '<img src="img/lounge_articles_prevention.gif" width="107" height="23" alt="" class="downStageImage" id="dsArticleLogo"><div id="downStageCopy" class="lounge_articles">' + article_intro + '<ul><li><a href="/pdf/lounge_advert_pr1.pdf" target="_blank">Facts from the Bottom Up: Part I</a></li><li><a href="/pdf/lounge_advert_pr2.pdf" target="_blank">Facts from the Bottom Up: Part II</a></li><li><a href="/pdf/lounge_advert_pr3.pdf" target="_blank">Facts from the Bottom Up: Part III</a></li></ul></div>';
downStageArray[92] = '<img src="img/lounge_articles_sheknows.gif" width="129" height="23" alt="" class="downStageImage" id="dsArticleLogo"><div id="downStageCopy" class="lounge_articles multi_list">' + article_intro_links;
downStageArray[92] += '<ul id="sheknows_links1"><li><a href="http://www.sheknows.com/quizzes/what-makeup-colors-complement-your-complexion" target="_blank">Quiz: What Makeup Colors Complement Your Complexion?</a></li><li><a href="http://www.sheknows.com/top10/question/skincare-must-haves" target="_blank">Top 10 Skin-Care Must Haves</a></li><li><a href="http://www.sheknows.com/tips/skincare-tips/" target="_blank">Tip of the Week</a></li><li><a href="http://www.sheknows.com/articles/810016.htm" target="_blank">Retin-A: Everything You Need to Know About the Best Anti-Aging Cream</a></li><li class="lnk_nav_article"><a href="#" onclick="loungeLinks(1,0);return false;">&raquo; next 4</a></li></ul>';
downStageArray[92] += '<ul id="sheknows_links2"><li><a href="http://www.sheknows.com/articles/810011.htm" target="_blank">How to Banish Body Breakouts</a></li><li><a href="http://www.sheknows.com/articles/810010.htm" target="_blank">The Importance of Regular Facials</a></li><li><a href="http://www.sheknows.com/articles/810009.htm" target="_blank">How to Apply the Perfect Sunless Tan</a></li><li><a href="http://www.sheknows.com/articles/810008.htm" target="_blank">Homemade Beauty: Home Skin-Care Recipes</a></li><li class="lnk_nav_article"><a href="#" onclick="loungeLinks(2,1);return false;">&raquo; next 4</a> &nbsp; <a href="#" onclick="loungeLinks(0,1);return false;">&laquo; previous 4</a></li></ul>';
downStageArray[92] += '<ul id="sheknows_links3"><li><a href="http://www.sheknows.com/articles/810007.htm" target="_blank">The Importance of Exfoliation</a></li><li><a href="http://www.sheknows.com/articles/810006.htm" target="_blank">7 Expert Tips for a Flawless Face</a></li><li><a href="http://www.sheknows.com/articles/810005.htm" target="_blank">Put Your Best Face Forward</a></li><li><a href="http://www.sheknows.com/articles/810004.htm" target="_blank">The Best At-Home Facials</a></li><li class="lnk_nav_article"><a href="#" onclick="loungeLinks(1,2);return false;">&laquo; previous 4</a></li></ul></div>';
downStageArray[93] = '<img src="img/lounge_articles_cosmopolitan.gif" width="151" height="26" alt="" class="downStageImage" id="dsArticleLogo"><div id="downStageCopy" class="lounge_articles">' + article_intro + '<ul><li><a href="/pdf/lounge_advert_co1.pdf" target="_blank">Winter Skin-Care Necessities</a></li><li><a href="/pdf/lounge_advert_co2.pdf" target="_blank">Tips for Soothing Dry Skin</a></li></ul></div>';
downStageArray[94] = '<img src="img/lounge_articles_marieclaire.gif" width="126" height="20" alt="" class="downStageImage" id="dsArticleLogo"><div id="downStageCopy" class="lounge_articles">' + article_intro + '<ul><li><a href="/pdf/lounge_advert_mc1.pdf" target="_blank">Skin Care A to Z: Part I</a></li><li><a href="/pdf/lounge_advert_mc2.pdf" target="_blank">Skin Care A to Z: Part II</a></li></ul></div>';
downStageArray[95] = '<img src="img/lounge_articles_everydayhealth.gif" width="150" height="47" alt="" class="downStageImage" id="dsArticleLogo"><div id="downStageCopy" class="lounge_articles">' + article_intro + '<ul><li><a href="/pdf/lounge_advert_eh1.pdf" target="_blank">9 Tips to Soothe Dry Skin</a></li><li><a href="/pdf/lounge_advert_eh2.pdf" target="_blank">Keep It Simple &ndash; Skin-Care Basics</a></li><li><a href="/pdf/lounge_advert_eh3.pdf" target="_blank">The Best Skin Care for Your Skin Type</a></li><li><a href="/pdf/lounge_advert_eh4.pdf" target="_blank">Treating Adult Acne Breakouts</a></li></ul></div>';

downStageArray[96] = '<div id="sm_icon_facebook" class="sm_icon select downStageImage"><a href="http://www.facebook.com/cottonelleinstitute" class="png">Facebook</a></div><div id="sm_icon_twitter" class="sm_icon downStageImage"><a href="http://www.twitter.com/institutetips" class="png">Twitter</a></div><p id="downStageCopy" class="dsc_social"><strong>Click an icon</strong> to join the conversation on Facebook or Twitter.</p>';

// Quiz
downStageArray[11] = quiz_wipes+'<p id="downStageCopy">Soothe your sensitive side with Cottonelle® SoothingClean™ Flushable Moist Wipes.</p>';
downStageArray[12] = quiz_paper+'<p id="downStageCopy">Treat your bottom extra gently with Cottonelle® Aloe & E Toilet Paper.</p>';
downStageArray[13] = quiz_wipes+'<p id="downStageCopy">Cottonelle® SoothingClean™ Flushable Moist Wipes are dermatologist-tested.</p>';
downStageArray[14] = quiz_paper+'<p id="downStageCopy">Cottonelle® Aloe & E Toilet Paper is dermatologically tested.</p>';
downStageArray[15] = '<a href="/products.aspx"><img src="img/pack_both.png" width="181" height="205" alt="" class="downStageImage"></a><p id="downStageCopy" style="margin-left:250px;">Extra gentle on sensitive skin.</p>';
downStageArray[16] = '<p id="downStageCopy">Paper</p>';

var stageIn = function(callBack){
	callBack = callBack || function(){return true};
	if(!document.all){
		$('#downStageCanvas').animate( { top:"0" }, { queue:false, duration:500 } ).fadeIn(250,callBack);
	}
	else{
		$('#downStageCanvas').animate( { top:"0" }, { queue:false, duration:500 } ).fadeIn(1,callBack);;
	}
}

var stageOut = function(callBack){
	callBack = callBack || '';
	if(!document.all){
		$('#downStageCanvas').animate( { top:"25px" }, { queue:false, duration:500 } ).fadeOut(250,callBack);
	}
	else{
		$('#downStageCanvas').animate( { top:"25px" }, { queue:false, duration:500 }).fadeIn(1,callBack);
	}   
}

var showContent = function(x){
	var x = x || '';
	stageOut(function(){
		$('#downStageCanvas').html(downStageArray[x]);
		showContentTimer = setTimeout("stageIn()",500);
	});
	
	/*A small function for swapping screens on the lounge, enabling the browser to call the previous content.*/
	if($('body.lounge').length > 0 && x != 96){ //96 is the social media screen, which is taken care of separately.
		$('body').data('stage',x);
	}
}

var badges =['wind','food','touchy','smells','additives'];
badges['wind']='<img src="/img/badge_wind_small.png" id="badge_wind" class="patch">';
badges['food']='<img src="/img/badge_food_small.png" id="badge_food" class="patch">';
badges['touchy']='<img src="/img/badge_touch_small.png" id="badge_touch" class="patch">';
badges['smells']='<img src="/img/badge_smells_small.png" id="badge_smells" class="patch">';
badges['additives']='<img src="/img/badge_additives_small.png" id="badge_additives" class="patch">';

var loadBadges = function(badgeName){
	var x = BGC.cookie('badges')||'';
	var c = '|';
	var a = x.split(c);
	var l = a.length;
	badgeCount = (x != '') ? a.length : 0; //globalized, for reporting badges earned.
	if(!badgeName){
		if($('#robe').length > 0){
			while(l--)
			{
				var bl = badges.length;
				while(bl--){
					if(a[l] == badges[bl]){
						$('#robe').append(badges[badges[bl]]);
						break;
					}
				}
			}
		}
	}
	else{
		if(x.length > 0){
			while(l--){
				if(a[l] == badgeName){
					//Badge already set. No need for action.
					return true;
				}
			}
		}
		var y = (x == '') ? badgeName : x+c+badgeName;
		BGC.cookie('badges',y,365);
		var msgNum = 0;	
		switch(badgeName){
			case 'wind':	dcsMultiTrack("DCS.dcssip","www.cottonelleinstitute.com","DCS.dcsuri","cottonelleinstitute.com/WindandWeatherLabsPatch.aspx","WT.ti","WindandWeatherPatch","WT.dl","6","WT.si_n","COTIN_conv_5","WT.si_x","1","WT.si_cs","","WT.z_videotitle","","WT.z_videopct","");
			break;
			
			case 'food':		dcsMultiTrack("DCS.dcssip","www.cottonelleinstitute.com","DCS.dcsuri","cottonelleinstitute.com/FoodandSpicesLabsPatch.aspx","WT.ti","FoodandSpicesPatch","WT.dl","6","WT.si_n","COTIN_conv_6","WT.si_x","1","WT.si_cs","","WT.z_videotitle","","WT.z_videopct","");
			break;

			case 'touchy':			dcsMultiTrack("DCS.dcssip","www.cottonelleinstitute.com","DCS.dcsuri","cottonelleinstitute.com/TouchyFeelyLabPatch.aspx","WT.ti","TouchyFeelyPatch","WT.dl","6","WT.si_n","COTIN_conv_8","WT.si_x","1","WT.si_cs","","WT.z_videotitle","","WT.z_videopct","");
			break;
			
			case 'smells':			dcsMultiTrack("DCS.dcssip","www.cottonelleinstitute.com","DCS.dcsuri","cottonelleinstitute.com/SmellsandScentsLabPatch.aspx","WT.ti","SmellsandScentsPatch","WT.dl","6","WT.si_n","COTIN_conv_16","WT.si_x","1","WT.si_cs","","WT.z_videotitle","","WT.z_videopct","");
			break;
			
			case 'additives':
dcsMultiTrack("DCS.dcssip","www.cottonelleinstitute.com","DCS.dcsuri","cottonelleinstitute.com/AdditivesLabPatch.aspx","WT.ti","AdditivesLabPatch","WT.dl","6","WT.si_n","COTIN_conv_9","WT.si_x","1","WT.si_cs","","WT.z_videotitle","","WT.z_videopct","");
			break;
		}
		
		/*
		Badge granting is now a function of Flash.
		$('#downStageCanvas').stop();
		showContent(msgNum);
		*/
		
	}
}

function scrapBadge(badge){
	var x = BGC.cookie('badges')||'';
	if(x != ""){
		var i = x.indexOf(badge);
		var pipe = x.lastIndexOf('|');
		if(pipe != -1){
			badge = (i < pipe) ? badge + '|' : '|'+badge;
		}
		var a = x.split(badge);
		var newString = a.join('');
		BGC.cookie('badges',newString,365);
	}
}

var loadRegister = function(){
	if($('body.register').length < 1){
		return true;
	}
	
	$('#subEmail').attr('value','');
	
	document.forms[0].onsubmit = function(){
		var regExEmail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,6})+$/
		var em = $('#txtEmail').attr('value');
		if (regExEmail.test(em)) {
			// Do something amazing.
		};
	}
}

/**
* Tub Overlays/Popups
* Invoked via $(document).ready() at top.
**/
function popUpShow(bgPos){
	bgPos = bgPos || 0;
	var $t = $('#tub_popup');
	var $i = $t.find('img');
	$i.css('backgroundPosition','0 '+bgPos+'px');
	$t.show();
}

function popUpHide(){
	$('#tub_popup').hide();
}

function fixUsernameCookies(){
	return true;
	//if(!readCookie('username'))
}

/**
* Tracking	
**/

function trackProfile(){
	dcsMultiTrack("www.cottonelleinstitute.com","cottonelleinstitute.com/ProfileStart.aspx","OnclickTakethesSensitivityprofile","6","COTIN_Conv_1;COTIN_Conv_7","1;1","","","");
}

function trackProfileSubmit(){
	if(BGC.query.type == null || !document.form1.txtEmail){
		return false;
	}
	/* Note if the email field *has* a value, submitting the form will track that end.*/
	window.onunload = function(){
	    var e = document.form1.txtEmail;
	    if(e.value == ""){
	    	dcsMultiTrack("www.cottonelleinstitute.com","cottonelleinstitute.com/Completequiz.aspx","SubmitButtonSensitivityprofile","6","COTIN_Conv_1","2","1","","");
		}
	}
	return true;
}

/*Social Networking*/
function socialNetworking(){
	$('.sm_icon a').die('click').live('click',function(e){
		$(this).parents('.sm_icon').addClass('select').each(function(){
			var x = ($(this)[0].id.indexOf('facebook') != -1) ? 'facebook' : 'twitter';
			$('.sm[rel='+x+']').show(250).siblings('.sm').hide(250);
			$('body').data('sm',x);
		}).siblings('.sm_icon').removeClass('select');
		e.preventDefault();
	})
}