/* ********************** */
/*   LAUNDRY 101 GLOBAL   */      
/* ********************** */

var global = function() {
	
	var termList;
	
	return {
				
		init : function () {
			
			global.navigation.init();
					
			$('span.print').click( function() {
				openPopup(window.location.href + '?view=print', 'popwin', 700, 700, 'yes', 'yes', 400, 400, 'yes');
		      	return false;
			});
			
			if (typeof breadCrumbObj !== 'undefined') 
				global.breadCrumb.init(breadCrumbObj);
			
			global.ratings.init();
			global.locator.init();
			global.tips.init();
			global.tracking.init();
		},
		
		tracking : {
			
			init : function () {
			
			$('INPUT[rel*="event"]').blur( function() {			
				//alert("tracking input id:"+ this.id);
				if (this.id == 'location')
				{
				//	alert("tracking locator:"+'Zip Enter '+ $("#laudromatSearchForm input").val());					
					trackEvent('Zip Results', 'Zip Enter', 'Zip Enter '+ $("#laudromatSearchForm input").val());
				}		        
			});
			
			
			
			$("span").click(function (){
				
				var href = this.href;				
				var trackValue;
				//var source = $(this).attr('rel') !== undefined ? $(this).attr('rel') : "";
				//var remoteTarget = $(this).attr('target') !== undefined && $(this).attr('target') === "_blank" ? true : false;
				
				// TODO: use the 'rel' attr to determine the source of a clicked link, since links exist in mulitple places.
				
				
				var trackElementId = this.id;		
				var clickTag = getClickTagValue(trackElementId);
				
				if (clickTag != '')
				{	
					//alert("span trackValueChk: " + clickTag);
					trackPage(clickTag);			
				}	
			});
			
				// standard link tracking
				$("a").click(function (){
					
					var href = this.href;					
					var trackValue;
					var source = $(this).attr('rel') !== undefined ? $(this).attr('rel') : "";
					var remoteTarget = $(this).attr('target') !== undefined && $(this).attr('target') === "_blank" ? true : false;
					
					// TODO: use the 'rel' attr to determine the source of a clicked link, since links exist in mulitple places.
					
					if (!remoteTarget)
						trackValue = href.split("/en-US/")[1].replace(".jspx","");
					else 
						trackValue = href.replace(/http:\/\//,"");
								
					var trackElementId = this.id;
				
					//alert("trackElementId: " + trackElementId);
					var clickTag = '';

					
					clickTag = getClickTagValue(trackElementId);
					if (clickTag != '')
					{	
						//alert("trackValueChk: " + clickTag);
						trackPage(clickTag);
					}
					/* This was default click tag
					else
					{					
						alert("trackValue: " + trackValue);
						trackPage("click/"+trackValue);
					}*/	
				});

			
				// site search tracking
				$("form#gaSearch").submit(function(){
					/*Commenting the click tag of tide.com and implementing new tag for laundry.com*/
					//trackPage("click/site-search/"+$("input#searchTerm").val());
					trackPage("/click/en-us/Search_start");					
				});	
				
				// find-a-laundromat tracking
				$("form#laudromatSearchForm").submit(function(){
					
					/*Commenting the click tag of tide.com and implementing new tag for laundry.com*/
					//trackPage("click/laudromat-search-submnission");
					var href = location.href.split("/en-US/")[1].replace(".jspx","");
					//alert("laudromatSearchForm id:" + this.id);
					//alert("laudromatSearchForm href:" + location.href.replace(/http:\/\//,""));
					//alert("laudromatSearchForm href:" + href);
					
					if(href.match('tips'))
					{
						//alert("laudromatSearchForm tips");
						trackPage("/click/en-us/tips/GO");
					}
					else if(href.match('locator'))
					{
						//alert("laudromatSearchForm locator");
						trackPage("/click/en-us/locator/GO");
					}	
				});	
					
			
			}
		},	
		
		navigation : {
			
			init : function () {
			
				if((section == "home") || (section == "high-efficiency") || (section == "tips")) {
					$("#"+section+"Link a").addClass("currentPage");
					$("#"+section+"Link a.dd").addClass("ddCurrentPage");
				}
				else {
					$("#how-toLink a").addClass("currentPage");
					$("#how-toLink a.dd").addClass("ddCurrentPage");
					$("#nav").addClass("how-to");
				}
								
				/*$("ul#nav a.dd").hoverIntent(
						
					function () {
						
						var elmId = $(this).parent("li")[0].id.split("Link")[0];
						
						$("ul#nav a").addClass("toFront");
						$(this).removeClass("toFront");
										
						$("#subNav div").hide();
						$("#subNav div#subNavBg").attr("class","").addClass("subNavBg-"+elmId).show();
						
						$("#subNavMenu-"+elmId).show();
						
						$("#subNavMenu-"+elmId).hover(
							function () {},
							function () {
								$("#subNav div").hide();	
								$("ul#nav a").addClass("toFront");
							}
						)
					},
					
					function () {
						$(this).addClass("standby");
					}
				)*/
			}
		},	
		
		locator : {
		
			init : function () {
			
				$("input#location").click(function(){
					if ($.trim($(this).val()) == "Enter City & State or ZIP")
					$(this).val("");
					$("form#laudromatSearchForm").removeClass("error");
				});
				
				$("form#laudromatSearchForm").submit(function(event) {
					
					var error = false;
					var formVal = $.trim($("input#location").val()); 
					
					if (formVal == "Enter City & State or ZIP")
						error = true;
					
					if (formVal == "")
						error = true;
					
					if (error == true){
						$("input#location").val("Enter City & State or ZIP")
						$("form#laudromatSearchForm").addClass("error");
						event.preventDefault();
					}	
				});
			}
		},		
		
		ratings : {
			
			init : function (){
			
				$("div.unrated img").click(function() {
					$('#ratingContainer').empty();
					var detailID = this.className;
					var rating = this.title;
					dwrService.setRating(localeName, detailID, type, rating, global.ratings.viewUpdatedRating);
				});
			},
			
			viewUpdatedRating : function (){
				
				var url = '/en-US/laundry/rating.jspx?objectId='+detailId+'&type='+type+'&enableUserRating=yes';
				$('#ratingContainer').load(url);
			}
		},	
		
		glossary : {
			
			init : function () {
				global.glossary.makeRequest();
				global.glossary.setTermEvents();	
			},
		
			makeRequest : function () {
					
				$.ajax({
					type: "GET",
					url: "/en-US/glossaryData.jspx", 
					dataType: "xml", 
					async:false,
					complete: function(data) {
						global.glossary.processData($.xmlToJSON(data.responseXML))
					}
				});
				
			},
			
			processData : function (jsonData) {
				
				try {
					termList = jsonData.p;
					for (var i=0; i<termList.length; i++) {
						var term = termList[i].strong[0].Text;
						var regex = new RegExp(term, "i");
						$("#detailDescription").each(function () {
					        this.innerHTML = this.innerHTML.replace(regex, function(matched) {return "<span id=\"term"+i + "\" class=\"term\">" + matched + "</span>";});
					    });
					}
	            }
	            catch (e) {
	                alert("There was a problem fetching the terms for this page");
	            }
			},
			
			setTermEvents : function (){
				
				$(".term").click(function(){
					
					// when a term is clicked, get the term info from the json object
					var termIdx = parseInt(this.id.split("term")[1]);
					var termName = termList[termIdx].strong[0].Text;
					var termDefinition = termList[termIdx].span[0].Text;
					
					// render the view
					$("#glossaryItem h2").html(termName);
					$("#glossaryItem p").html(termDefinition);
					$("#glossaryItem").show();
					$("#glossaryItem").center();
					$("#glossaryItem span").click(function(){
						$("#glossaryItem").hide();
					});
				})
			}
		},
		
		tips : {
			
			init : 	function() {
			
				var tipCount = $("#tipsModule .leadIn").length;
				
				if (tipCount > 0){
					$("#tipsModule .leadIn").hide();
					var randomIdx = Math.floor(tipCount * Math.random());
					var trickNumber = randomIdx + 1; 
					var header = $("#tipsModule .leadIn:eq("+randomIdx+") span").text();
					$("#tipsModule .leadIn:eq("+randomIdx+") span").html("Tip #" + trickNumber + ": " + header);
					$("#tipsModule .leadIn:eq("+randomIdx+")").show();
				}
			}	
		},
		
		breadCrumb : {
			
			init : function (breadCrumbObj){
			
				var items = breadCrumbObj.items;
				var crumbs = "";
				
				for(key in items) {
				    
					var elm = "";
					if (items[key].target != '')
						elm = '/ <a href="'+items[key].target+'">'+items[key].title+'</a> '	
					else 
						elm = '/ <span>'+items[key].title+'</span> ';
	
					crumbs = crumbs + elm;
				}
				
				$('#breadsection').empty();
				$('#breadsection').html(crumbs);
				$("#breadcrumb").css("visibility", "visible");
			}
		}	
		
	};
}();

/* ********************** */
/*   PAGE: HOME           */      
/* ********************** */

var home = function() {
	
	return {
		
		init : function () {
		
			// sorry - no bubbles for ie6.	
			var isIe6 = ($.browser.msie + $.browser.version).indexOf("true6") == -1 ? false : true;
			if (!isIe6) {
				var to =  setTimeout(function() {$("img#bubble1").show("scale", { percent: 100 }, 300);}, 500);
				var to =  setTimeout(function() {$("img#bubble2").show("scale", { percent: 100 }, 500);}, 800);
				var to =  setTimeout(function() {$("img#bubble3").show("scale", { percent: 100 }, 500);}, 1000);	
			}
			
			var to =  setTimeout(function() {
				var params = { allowScriptAccess: "always","wmode":"transparent"};
				var atts = { id: "myytplayer" };
				swfobject.embedSWF("http://www.youtube.com/v/RNVVGvPFjB0&enablejsapi=1&playerapiid=ytplayer&autoplay=0", "ytapiplayer", "296", "191", "8", null, null, params, atts);
			}, 1200);
		}
	};
}();

/* ********************** */
/* PAGE: SEARCH           */      
/* ********************** */

var locator = function() {
	
	return {
		
		init : function () {
			$("a#searchLink").addClass("active");
		}
	};
}();

/* ************************** */
/* PAGE: WASH SYMBOL GUIDE    */      
/* ************************** */

var guide = function() {
	
	return {
		
		init : function () {
			$("a#guideLink").addClass("active");
			
			$("div#toggle span").click(function(){
				$("div#toggle span").removeClass("on");
				$(this).addClass("on")
				
				var elmId = this.id;
				if (elmId === "all"){
					$("div.contentType").show();
				}
				else {
					$("div.contentType").hide();
					$("div#"+this.id+"Content").show();
				}	
			});
		}
	};
}();

/* *************************** */
/* GLOBAL: DOCUMENT READY      */      
/* *************************** */


$(document).ready(function() {
	


	
	if (window.location.href.indexOf('view=print') == -1){
		global.init();
		
		if ($("#home").length > 0) home.init();
		if ($("#contentDetail").length > 0)	global.glossary.init();
		if ($("#locator").length > 0)locator.init();
		if ($("#guide").length > 0)	guide.init();
	}	
	else {
		var to =  setTimeout(function() {window.print();}, 1000);	
	}	
	
	// remove the last dotted line from the category list on home and how-to pages
	$(".catlist li:last-child").css("border-bottom","none 0");
	
	//nav rollovers
	$("#how-toLink").mouseover(function() {
		$("#subNav_howto").css("display","block");
		$("#how-toLink a").removeClass("toFront");
		$("#high-efficiencyLink a").addClass("toFront");
	});
	$("#subNav_howto").hover(function() {}, function() {
		$("#subNav_howto").css("display","none");
	});
	$("#high-efficiencyLink").mouseover(function() {
		$("#subNav_he").css("display","block");
		$("#high-efficiencyLink a").removeClass("toFront");
		$("#how-toLink a").addClass("toFront");
	});
	$("#subNav_he").hover(function() {}, function() {
		$("#subNav_he").css("display","none");
	});
	
	//remove extra dotted lines in how-to dropdown
	//declare number of categories
	var numofcat = $(".subcatNavList").length;
	//determine number of rows of categories
	var numofcatrow = Math.ceil(numofcat/3);
	//determine how many categories are on the last line
	var numofcathang = numofcat%3;
	if (numofcathang == 0) numofcathang = 3;
	//remove bottom border from the last row
	for (x = numofcathang; x > 0; x--) {
		$(".subcatNavList").eq(numofcat - x).parent("li").css("border-bottom","none 0");
	}
	//remove right border from right-most category in each row
	for (y = 1; y < numofcatrow; y++) {
		$(".subcatNavList").eq(y*3-1).parent("li").css("border-right","none 0");
	}
	//$(".subcatNavList").last().parent("li").css("border-right","none 0");
	
	//remove glossary highlighting from headline items
	$("h1 .term, h2 .term, h3 .term, h4 .term, h5 .term, h6 .term").removeClass("term");
	
	//dynamic footer styling
	$("#footer li a[target='_blank']").addClass("remote");
	$("#footer li a[href*='tide.com']:first").parent().before('<li class="footerdot"><span>&#149;</span></li>');
});


/* *************************** */
/* GLOBAL: HELPER FUNCTIONS    */      
/* *************************** */

function onYouTubePlayerReady(playerId) {
	ytplayer = document.getElementById("myytplayer");
}

jQuery.fn.center = function(options) {
	var pos = {
		sTop : function() {
			return window.pageYOffset || document.documentElement && document.documentElement.scrollTop ||  document.body.scrollTop;
		},
		sLeft : function() {
			return window.pageXOffset || document.documentElement && document.documentElement.scrollLeft ||  document.body.scrollLeft;
		},
		wHeight : function() {
			return window.innerHeight || document.documentElement && document.documentElement.clientHeight || document.body.clientHeight;
		},
		wWidth : function() {
			return window.innerWidth || document.documentElement && document.documentElement.clientWidth || document.body.clientWidth;
		}
	};

	return this.each(function(index) {

		if (index == 0) {
			
			var $this = $(this);
			var elHeight = $this.height();
			var elWidth = $this.width();
			var elTop = pos.sTop() + (pos.wHeight() / 2) - (elHeight / 2);
			var elLeft = pos.sLeft() + (pos.wWidth() / 2) - (elWidth / 2);
			
			$this.css({
				position: 'absolute',
				marginTop: '0',
				marginLeft: '0',
				top: elTop,
				left: elLeft
			});
		}
	});
};

function openPopup( pageToLoad, winName, width, height, center, scroll, winXpos, winYpos, resize) {

	xposition = 0;
	xposition = winXpos;
	yposition = 0;
	yposition = winYpos;
	resizable = 0;
	resizable = resize;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)) {
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	args = "width=" + width + ","     + "height=" + height + ","
	+ "location=0," + "menubar=0,"  + "resizable=" + resizable + "," + "scrollbars=" + scroll + ","
	+ "status=0,"   + "titlebar=0," + "toolbar=0," +                   "hotkeys=0,"
	+ "screenx=" + xposition + ","  //NN Only
	+ "screeny=" + yposition + ","  //NN Only
	+ "left=" + xposition + ","     //IE Only
	+ "top=" + yposition;           //IE Only
	
	return window.open( pageToLoad,winName,args );
}

function trackPage(pageName){
	//alert("Tracking: " + pageName);
	pageTracker._trackPageview(pageName);
}



function trackEvent(section, subsection, event){
	if(section == undefined)
		section = "";
	if(subsection == undefined)
		subsection = "";
	if(event == undefined)
		event = "";
	
	//alert("Event: " + section + " : " + subsection + " : " + event);
	pageTracker._trackEvent(section, subsection, event);
}

var clickTagList = new Object();

clickTagList.tips			= '/click/en-us/laundrytips';
clickTagList.guideLink 		= '/click/en-us/Symbolguide';
clickTagList.searchLink 	= '/click/en-us/findlaundromat';
clickTagList.footerLink1 	= '/click/en-us/Glossary';
clickTagList.footerLink2 	= '/click/en-us/termsconditions';
clickTagList.footerLink4 	= '/click/en-us/sitemap';
clickTagList.footerLink5 	= '/click/en-us/Tide';
clickTagList.footerLink6 	= '/click/en-us/Downy';
clickTagList.footerLink7 	= '/click/en-us/Bounce';
clickTagList.howtoLink 	= '/click/en-us/TopNav/How-To/how-toLink';
clickTagList.sortWashNDry = '/click/en-us/Sortwashdry';
clickTagList.washWithHighEfficiency = '/click/en-us/washHE';
clickTagList.solveLaundryProblems = '/click/en-us/LaundryProblems';
clickTagList.careForClothesAndLinens = '/click/en-us/Careclotheslinens';
clickTagList.foldPackNStoreClothes = '/click/en-us/foldpackstore';
clickTagList.chooseTheRightProducts = '/click/en-us/chooseproducts';


clickTagList.sortwashdry = '/clicks/en-US/how-to/cat_sortwashdry';
clickTagList.solvelaundryproblems = '/clicks/en-US/how-to/cat_laundryproblems';
clickTagList.clothinglinencare = '/clicks/en-US/how-to/cat_clothingcare';
clickTagList.foldpackstore = '/clicks/en-US/how-to/cat_foldpackstore';
clickTagList.chooseproducts = '/clicks/en-US/how-to/cat_chooseproducts';

clickTagList.sortwashdrysorting = '/clicks/en-US/how-to/sortinglaundry';
clickTagList.sortwashdryloading = '/clicks/en-US/how-to/LoadingLaundry';
clickTagList.sortwashdryhowmuchdetergent = '/clicks/en-US/how-to/HowmuchDetergent';
clickTagList.sortwashdrychoosingwashcycles = '/clicks/en-US/how-to/ChoosingWashcycle';
clickTagList.sortwashdryfabricsoftener = '/clicks/en-US/how-to/HowuseFabricSoftener';
clickTagList.sortwashdrydryingclothes = '/clicks/en-US/how-to/dryclothes';
clickTagList.sortwashdrywashingmachinebuildup = '/clicks/en-US/how-to/WashMachineBuildup';

clickTagList.solvelaundryproblemsstains = '/clicks/en-US/how-to/stainremoval';
clickTagList.solvelaundryproblemsstaticcling = '/clicks/en-US/how-to/staticcling';
clickTagList.solvelaundryproblemscolorrelatedissues = '/clicks/en-US/how-to/colorissues';
clickTagList.solvelaundryproblemsdetergentresidue = '/clicks/en-US/how-to/laundrydetergentresidue';
clickTagList.solvelaundryproblemsodorremoval = '/clicks/en-US/how-to/laundryodor';

clickTagList.clothinglinencaresensitiveskin = '/clicks/en-US/how-to/sensitiveskin';
clickTagList.clothinglinencarelaundryforbabies = '/clicks/en-US/how-to/laundrybabies';
clickTagList.clothinglinencaredamagedclothing = '/clicks/en-US/how-to/damagedclothing';
clickTagList.foldpackstorestoring = '/clicks/en-US/how-to/storingclothes';
clickTagList.chooseproductschooseadetergent = '/clicks/en-US/how-to/choosingdetergent';
clickTagList.chooseproductswashingmachinecare = '/clicks/en-US/how-to/washingmachinecare';

clickTagList.all = '/click/en-us/wash-symbol-guide/viewall';
clickTagList.wash = '/click/en-us/wash-symbol-guide/Wash';
clickTagList.bleach = '/click/en-us/wash-symbol-guide/Bleach';
clickTagList.dry = '/click/en-us/wash-symbol-guide/Dry';
clickTagList.wring = '/click/en-us/wash-symbol-guide/Wring';
clickTagList.iron = '/click/en-us/wash-symbol-guide/Iron';
clickTagList.dryClean = '/click/en-us/wash-symbol-guide/Dryclean';
clickTagList.printTips = '/click/en-us/tips/printfriend';

/*
clickTagList.highefficiencyhevstraditional = '/click/en-us/high-efficiency/HEvTrad';
clickTagList.highefficiencyhescience = '/click/en-us/high-efficiency/HEScience';
clickTagList.highefficiencyhedetergents = '/click/en-us/high-efficiency/Hedetergent';
clickTagList.highefficiencyhemachinecare = '/click/en-us/high-efficiency/HEWashmachine';
clickTagList.highefficiencyhemanufacturers = '/click/en-us/high-efficiency/HEManufacturers';
*/

/* Click tags for How-To Category Landing page*/
var clickTagListDetails = new Object();

clickTagListDetails.detailsortwashdrysorting = '/clicks/en-US/how-to/sortwashdry/sortinglaundry';
clickTagListDetails.detailsortwashdryloading = '/clicks/en-US/how-to/sortwashdry/loadinglaundry';                    
clickTagListDetails.detailsortwashdryhowmuchdetergent = '/clicks/en-US/how-to/sortwashdry/howmuchdetergent';
clickTagListDetails.detailsortwashdrychoosingwashcycles = '/clicks/en-US/how-to/sortwashdry/choosingwashcycles';
clickTagListDetails.detailsortwashdryfabricsoftener = '/clicks/en-US/how-to/sortwashdry/fabricsoftener';
clickTagListDetails.detailsortwashdrydryingclothes ='/clicks/en-US/how-to/sortwashdry/dryingclothes';
clickTagListDetails.detailsortwashdrywashingmachinebuildup = '/clicks/en-US/how-to/sortwashdry/washingmachinebuildup';

clickTagListDetails.detailstains = '/clicks/en-US/how-to/laundryproblems/stains';
clickTagListDetails.detailsolvelaundryproblemsstaticcling = '/clicks/en-US/how-to/laundryproblems/staticcling';
clickTagListDetails.detailsolvelaundryproblemscolorrelatedissues = '/clicks/en-US/how-to/laundryproblems/colorrelatedissues';
clickTagListDetails.detailsolvelaundryproblemsdetergentresidue = '/clicks/en-US/how-to/laundryproblems/laundrydetergentresidue';
clickTagListDetails.detailsolvelaundryproblemsodorremoval = '/clicks/en-US/how-to/laundryproblems/laundryodorremoval';

clickTagListDetails.detailclothinglinencaresensitiveskin = '/clicks/en-US/how-to/Clothingcare/sensitiveskin';
clickTagListDetails.detailclothinglinencarelaundryforbabies = '/clicks/en-US/how-to/Clothingcare/laundryforbabies';
clickTagListDetails.detailclothinglinencaredamagedclothing = '/clicks/en-US/how-to/Clothingcare/damagedclothing';

clickTagListDetails.detailfoldpackstorestoring = '/clicks/en-US/how-to/foldpackstore/storingclothes';

clickTagListDetails.detailchooseproductschooseadetergent = '/clicks/en-US/how-to/chooseproducts/chooseadetergent';
clickTagListDetails.detailchooseproductswashingmachinecare = '/clicks/en-US/how-to/chooseproducts/washingmachinecare';

clickTagListDetails.detailhighefficiencyhevstraditional = '/click/en-us/high-efficiency/HEvTrad';
clickTagListDetails.detailhighefficiencyhescience = '/click/en-us/high-efficiency/HEScience';
clickTagListDetails.detailhighefficiencyhedetergents = '/click/en-us/high-efficiency/Hedetergent';
clickTagListDetails.detailhighefficiencyhemachinecare = '/click/en-us/high-efficiency/HEWashmachine';
clickTagListDetails.detailhighefficiencyhemanufacturers = '/click/en-us/high-efficiency/HEManufacturers';


/* Click tags for Adlobs*/
var clickTagListAdlobs = new Object();

	clickTagListAdlobs.tips = '/click/en-us/tips/adlob';
	clickTagListAdlobs.locator = '/click/en-us/locator/adlob';
	clickTagListAdlobs.washsymbolguide = '/click/en-us/wash-symbol-guide/adlob';
	clickTagListAdlobs.highefficiencyhevstraditional = '/click/en-us/High-Efficiency/HEvTrad/adlob';
	clickTagListAdlobs.highefficiencyhescience = '/click/en-us/High-Efficiency/HEScience/adlob';
	clickTagListAdlobs.highefficiencyhedetergents = '/click/en-us/High-Efficiency/Hedetergent/adlob';
	clickTagListAdlobs.highefficiencyhemachinecare = '/click/en-us/High-Efficiency/HEWashmachine/adlob';
	clickTagListAdlobs.highefficiencyhemanufacturers = '/click/en-us/High-Efficiency/HEManufacturers/adlob';	
	clickTagListAdlobs.iAd	 = '/click/en-us/High-efficiency/adlob'
	clickTagListAdlobs.iAdSearch ='/click/en-us/search/adlob'
	clickTagListAdlobs.iAd1 ='/click/en-us/index/adlob'


	clickTagListAdlobs.howtosortwashdrysorting = '/clicks/en-US/how-to/sortinglaundry/adlob';
	clickTagListAdlobs.howtosolvelaundryproblemscolorrelatedissues = '/clicks/en-US/how-to/colorrelatedissues/adlob';
	clickTagListAdlobs.howtosortwashdryfabricsoftener = '/clicks/en-US/how-to/howtousefabricsoftener/adlob';
	clickTagListAdlobs.howtosolvelaundryproblemsstaticcling = '/clicks/en-US/how-to/sortinglaundry/adlob';

	clickTagListAdlobs.howtosortwashdryloading = '/clicks/en-US/how-to/loadinglaundry/adlob';
	clickTagListAdlobs.howtochooseproductswashingmachinecare = '/clicks/en-US/how-to/washingmachinecare/adlob';
	clickTagListAdlobs.howtosortwashdrywashingmachinebuildup = '/clicks/en-US/how-to/washingmachinebuildup/adlob';
	clickTagListAdlobs.howtosolvelaundryproblemsdetergentresidue = '/clicks/en-US/how-to/laundrydetergentresidue/adlob';
	clickTagListAdlobs.howtosortwashdryhowmuchdetergent = '/clicks/en-US/how-to/howmuchdetergenttouse/adlob';
	clickTagListAdlobs.howtosortwashdrychoosingwashcycles = '/clicks/en-US/how-to/choosingawashcycle/adlob';
	clickTagListAdlobs.howtochooseproductschooseadetergent = '/clicks/en-US/how-to/choosingadetergent/adlob';
	clickTagListAdlobs.howtosortwashdrydryingclothes = '/clicks/en-US/how-to/dryingclothes/adlob';
	clickTagListAdlobs.stains = '/clicks/en-US/how-to/stains/adlob';
	clickTagListAdlobs.howtosolvelaundryproblemsodorremoval = '/clicks/en-US/how-to/laundryodorremoval/adlob';
	clickTagListAdlobs.howtoclothinglinencaresensitiveskin = '/clicks/en-US/how-to/sensitiveskin/adlob';
	clickTagListAdlobs.howtoclothinglinencarelaundryforbabies = '/clicks/en-US/how-to/laundryforbabies/adlob';
	clickTagListAdlobs.howtoclothinglinencaredamagedclothing = '/clicks/en-US/how-to/damagedclothing/adlob';
	clickTagListAdlobs.howtofoldpackstorestoring = '/clicks/en-US/how-to/foldpackstore/adlob';
	
	
	clickTagListAdlobs.howtosortwashdry	 = '/clicks/en-US/how-to/sortwashdry/adlob';
	clickTagListAdlobs.howtosolvelaundryproblems	 = '/clicks/en-US/how-to/laundryproblems/adlob';
	clickTagListAdlobs.howtoclothinglinencare	 = '/clicks/en-US/how-to/clothingcare/adlob';
	clickTagListAdlobs.howtofoldpackstore	 = '/clicks/en-US/how-to/foldpackstore/adlob';
	clickTagListAdlobs.howtochooseproducts	 = '/clicks/en-US/how-to/chooseproducts/adlob';
	clickTagListAdlobs.highefficiency	 = '/click/en-us/High-efficiency/adlob';


/* Click tags for related contents in High-Efficiency and How-to detail pages */
var clickTagListRelatedContent = new Object();

	clickTagListRelatedContent.highefficiencyhevstraditional = '/click/en-us/High-Efficiency/HEvTrad/HEScience';
	clickTagListRelatedContent.highefficiencyhescience = '/click/en-us/High-Efficiency/HEScience/HEvTrad';
	clickTagListRelatedContent.highefficiencyhedetergents = '/click/en-us/High-Efficiency/Hedetergent/HEScience';
	clickTagListRelatedContent.highefficiencyhemachinecare = '/click/en-us/High-Efficiency/HEWashmachine/HEManufacturers';
	clickTagListRelatedContent.highefficiencyhemanufacturers = '/click/en-us/High-Efficiency/HEManufacturers/HEvTrad';

	clickTagListRelatedContent.howtosortwashdrysorting = '/click/en-us/how-to/sortinglaundry/colorrelatedissues';
	clickTagListRelatedContent.howtosolvelaundryproblemscolorrelatedissues = '/click/en-us/how-to/colorrelatedissues/howtousefabricsoftener';
	clickTagListRelatedContent.howtosortwashdryfabricsoftener = '/clicks/en-US/how-to/howtousefabricsoftener/staticcling';
	clickTagListRelatedContent.howtosolvelaundryproblemsstaticcling = '/clicks/en-US/how-to/staticcling/howtousefabricsoftener';
	clickTagListRelatedContent.howtosortwashdryloading = '/clicks/en-US/how-to/loadinglaundry/washingmachinecare';
	clickTagListRelatedContent.howtochooseproductswashingmachinecare = '/clicks/en-US/how-to/washingmachinecare/washingmachinebuildup';
	clickTagListRelatedContent.howtosortwashdrywashingmachinebuildup = '/clicks/en-US/how-to/washingmachinecare/laundrydetergentresidue';
	clickTagListRelatedContent.howtosolvelaundryproblemsdetergentresidue = '/clicks/en-US/how-to/laundrydetergentresidue/howmuchdetergenttouse';
	clickTagListRelatedContent.howtosortwashdryhowmuchdetergent = '/clicks/en-US/how-to/howmuchdetergenttouse/laundrydetergentresidue';
	clickTagListRelatedContent.howtosortwashdrychoosingwashcycles = '/clicks/en-US/how-to/choosingawashcycle/choosingadetergent';
	clickTagListRelatedContent.howtochooseproductschooseadetergent = '/clicks/en-US/how-to/choosingadetergent/howmuchdetergenttouse';
	clickTagListRelatedContent.howtosortwashdrydryingclothes = '/clicks/en-US/how-to/dryingclothes/staticcling';
	clickTagListRelatedContent.howtosolvelaundryproblemsodorremoval = '/clicks/en-US/how-to/laundryodorremoval/washingmachinecare';
	clickTagListRelatedContent.howtoclothinglinencaresensitiveskin = '/clicks/en-US/how-to/sensitiveskin/choosingadetergent';
	clickTagListRelatedContent.howtoclothinglinencarelaundryforbabies = '/clicks/en-US/how-to/laundryforbabies/sensitiveskin';
	clickTagListRelatedContent.howtoclothinglinencaredamagedclothing = '/clicks/en-US/how-to/damagedclothing/foldpackstore';
	clickTagListRelatedContent.howtofoldpackstorestoring = '/clicks/en-US/how-to/foldpackstore/damagedclothing';


function getClickTagValue(key){	
	//alert("getClickTagValue key:" + key);
	
	/* replacing spaces, '-', '/'*/	
	var key = key.replace(/ /g,"").replace('%',"").replace(/-/g,"");
	key = key.replace('%',"").replace(/-/g,"").replace(/\//g,"");
	//alert("getClickTagValue updated key:" + key);
	
	var href = location.href.split("/en-US/")[1].replace(".jspx","").replace(/ /g,"").replace('%',"").replace(/-/g,"").replace(/\//g,"");
		
	//alert(" getClickTagValue href:" + href);
	
	var click_tag = '';

	if (key.match("relatedcontent"))
	{	
		/* Click tags for related contents in High-Efficiency and How-to detail pages */
	//	alert("getClickTagValue : relatedcontent :" + href);		
		click_tag = clickTagListRelatedContent[href];
	}
	else if (key.match("detail"))
	{	
		/* Click tags for related contents in High-Efficiency and How-to detail pages */
		//alert("getClickTagValue : detail :" + key);		
		click_tag = clickTagListDetails[key];
		//alert("getClickTagValue : click_tag  :" + click_tag );	
	}	
	else if (key.match("iAd"))
	{		
		/* Click tags for Adlobs. Here the key is href*/
		
		//alert("getClickTagValue : iAd :" + href);
		click_tag = clickTagListAdlobs[href];
	}
	else
	{
	//	alert("getClickTagValue :" + key);
		click_tag = clickTagList[key];
	}
		
	if (click_tag == null)
	{
		click_tag = '';
	}
	//alert("getClickTagValue value:" + click_tag);
	return click_tag;
	
}
