<!--
// If any subheading is showing, it is named here. Otherwise, it is 0.
visibleSubheading = 0;
// If any heading has been hidden, it is named here. Otherwise, it is 0.
hiddenHeading = 0;

// If any secondary nav subheading is showing, it is named here. Otherwise, it is 0.
visibleSubheadingTwo = 0;
// If any secondary nav heading has been hidden, it is named here. Otherwise, it is 0.
hiddenHeadingTwo = 0;

$VERSION$ = 1.0;

var colorCode;
var colorHex;
var tabBgHex;

function inFolder(folder)
{ 
	if (document.location.href.indexOf('/' + folder) != -1)
	{
		return true;
	} else 
	{
		return false;
	}
}

function setColor()
{
	if (document.location.href.indexOf('/products/index') != -1)
	{
	  colorCode = "orange";
	  colorHex = "#ffaa2c";
	  tabBgHex = "#fbce7e";
	} 
	else if (inFolder('upgrade') || inFolder('linerspecial') || inFolder('kioskoffer') || inFolder('brewersurvey') || inFolder('white') || inFolder('testimonials'))
	{
	  colorCode = "blue";
	  colorHex = "#5fc1d8";
	  tabBgHex = "#d0e1e5";
	} 
	else if (inFolder('as-seen-in') || inFolder('grocery-bag-solutions') )
	{
	  colorCode = "grey";
	  colorHex = "#808285";
	} 
	else if (inFolder('pod-brewer') || inFolder('coffee') || inFolder('survey-thanks.html') )
	{
	  colorCode = "yellow";
	  colorHex = "#ffcc00";
	  tabBgHex = "#f8eb92";
	} 
	else if (inFolder('plastic-lid-series') || inFolder('sale') || inFolder('bathroom-organization') || inFolder('soap-pumps') || inFolder('sensor-soap-pumps') )
	{
	  colorCode = "blue";
	  colorHex = "#5fc1d8";
	  tabBgHex = "#afdce0";
	} 
	else if (inFolder('accessories') || inFolder('simplehuman-can-liners') || inFolder('laundry-tools'))
	{
	  colorCode = "purple";
	  colorHex = "#a568af";
	  tabBgHex = "#d7bbdc";
	} 
	else if (inFolder('dishracks') || inFolder('paper-towel-holders') || inFolder('grocery-bag-holders') || inFolder('organizer') || inFolder('cabinet-organizers') || inFolder('utensil-holder') || inFolder('recycling-solutions') || inFolder('kitchen-organization') || inFolder('whats-new') || inFolder('canister'))
	{
	  colorCode = "green";
	  colorHex = "#acc500";
	  tabBgHex = "#d7e785";
	}
	else if (inFolder('kitchen') || inFolder('bathroom') || inFolder('desk') || inFolder('laundry-hampers') || inFolder('products') || inFolder('trash-cans'))
	{
	  colorCode = "orange";
	  colorHex = "#ffaa2c";
	  tabBgHex = "#fbce7e";
	}
	else
	{
	  colorCode = "grey";
	  colorHex = "#808285";
	}
}

setColor();

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function getRandom() {
  var ranNum= Math.round(Math.random()*2);
  return ranNum;
}

popupWins = new Array();

function windowOpener(url, name, args) {
/*******************************
http://www.codestore.net/store.nsf/
the popupWins array stores an object reference for
each separate window that is called, based upon
the name attribute that is supplied as an argument
*******************************/
  if ( (typeof( popupWins[name] ) != "object") || (popupWins[name].closed) ){
    popupWins[name] = window.open(url,name,args);
  } 
  else {
    popupWins[name].location.href = url;
  } 
  popupWins[name].focus();
}

function popMovie(url) {
  newwindow=window.open(url,'single cup pod brewer','height=270,width=334,top=200,left=280,location=no,titlebar=0,scrollbars=0,statusbar=0,resizable=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popMovieNew(url,winName,winHeight,winWidth,winX,winY) {
  var winFeatures = 'height='+winHeight+',width='+winWidth+',top='+winX+',left='+winY+',location=no,titlebar=0,scrollbars=0,statusbar=0,resizable=1';
  newwindow=window.open(url,winName,winFeatures);
  if (window.focus) {newwindow.focus()}
  return false;
}

function popMovieMac(url) {
  newwindow=window.open(url,'single cup pod brewer','height=270,width=334,top=200,left=280,location=no,titlebar=0,scrollbars=0,statusbar=0,resizable=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popMovieWin(url) {
  newwindow=window.open(url,'','height=395,width=462,top=200,left=280,location=no,titlebar=0,scrollbars=0,statusbar=0,resizable=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popFeatures(url) {
  newwindow=window.open(url,'popFeatures','height=600,width=550,top=60,left=80');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popBrewer(url) {
  newwindow=window.open(url,'popBrewer','height=600,width=600,top=60,left=80');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popAltView(url) {
  newwindow=window.open(url,'popAltView','height=570,width=600,top=60,left=80');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popOther(url) {
  newwindow=window.open(url,'popOther','height=500,width=600,top=60,left=80,scrollbars=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popShopping(url) {
//  newwindow=window.open(url,'popShopping','height=544,width=704,top=60,left=80,scrollbars=1');
//	if (window.focus) {newwindow.focus()}
	windowOpener(url,'popShopping','height=544,width=704,top=60,left=80,scrollbars=1');
	return false;
}

function popEmailFriend(url) {
  newwindow=window.open(url,'popEmailFriend','height=750,width=704,top=60,left=80,scrollbars=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popPromoPods(url) {
  newwindow=window.open(url,'popPromoPods','height=250,width=340,top=250,left=250,scrollbars=0');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popShippingRates(url) {
  newwindow=window.open(url,'popShippingRates','height=200,width=210,top=60,left=80');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popWarrantyPromise(url) {
  newwindow=window.open(url,'popWarrantyPromise','height=400,width=400,top=250,left=250');
	if (window.focus) {newwindow.focus()}
	return false;
}

function popWindow(url) {
  newwindow=window.open(url,'popWindow','height=800,width=850,top=60,left=80,scrollbars=1');
	if (window.focus) {newwindow.focus()}
	return false;
}

// http://www.sitepoint.com/article/perfect-pop-up/

// pop-up function
var newWin = null;
function closeWin(){
	if (newWin != null){
		if(!newWin.closed)
			newWin.close();
	}
}
function popUp(strURL,strType,strHeight,strWidth) {
	closeWin();
	var strOptions="";
	if (strType=="label") strOptions="resizable=no,status=no,location=no,directories=no,menubar=1,copyhistory=no,toolbar=no,scrollbars=no,height="+strHeight+",width="+strWidth;
	if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
	return false;
}

function popUp2(strURL,strType,strHeight,strWidth,strPosition) {
	closeWin();
	var strPos;
	if (strPosition == "center"){
		winLeft = (screen.width-strWidth)/2;
		winTop = (screen.height-(strHeight+110))/2;
		strPos = ",left=" + winLeft + ",top=" + winTop; 
	}
	else {
		strPos = "";
	}
	var strOptions="";
	if (strType=="label") strOptions="resizable=no,status=no,location=no,directories=no,menubar=1,copyhistory=no,toolbar=no,scrollbars=no,height="+strHeight+",width="+strWidth+strPos;
	if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth+strPos;
	if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth+strPos;
	if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth+strPos;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();
}

function popUpLabel(strURL,strType,strHeight,strWidth,strPosition) {
	closeWin();
	var strPos;
	if (strPosition == "center"){
		winLeft = (screen.width-strWidth)/2;
		winTop = (screen.height-(strHeight))/2 - 100;
		strPos = ",left=" + winLeft + ",top=" + winTop; 
	}

	strOptions="resizable=no,status=no,location=no,directories=no,menubar=1,copyhistory=no,toolbar=no,scrollbars=no,height="+strHeight+",width="+strWidth+strPos;
	newWin = window.open(strURL, 'newWin', strOptions);
	newWin.focus();

}
function show(pageElement) {  
  document.getElementById(pageElement).style.visibility = "visible"; 
}

function hide(pageElement) {  
  document.getElementById(pageElement).style.visibility = "hidden"; 
}

function showSubmenu(pageElement) {  
  document.getElementById(pageElement).style.visibility = "visible"; 
  document.getElementById(pageElement).style.display = "inline";
}

function showError(pageElement) {  
  document.getElementById(pageElement).style.visibility = "visible"; 
  document.getElementById(pageElement).style.display = "inline";
}

function hideSubmenu(pageElement) {  
  document.getElementById(pageElement).style.visibility = "hidden"; 
  document.getElementById(pageElement).style.display = "none";
}

function showHeading(heading) {  
  document.getElementById(heading).style.visibility = "visible"; 
  document.getElementById(heading).style.display = "inline";
}

function hideHeading(heading) {
  document.getElementById(heading).style.visibility = "hidden"; 
  document.getElementById(heading).style.display = "none";
  hiddenHeading = heading;
}

function showSubheading(subheading) {
  document.getElementById(subheading).style.visibility = "visible"; 
  document.getElementById(subheading).style.display = "block";
  visibleSubheading = subheading;
}

function hideSubheading(subheading) {
  document.getElementById(subheading).style.visibility = "hidden"; 
  document.getElementById(subheading).style.display = "none";
  visibleSubheading = 0;
}

function changeHeading(subheading) {
	// If the heading's subheading is not visible, show it...
	if (document.getElementById(subheading).style.visibility != "visible") {
		// If any other subheading is showing, hide it (old version also showed the old subheading's heading)...
		if (visibleSubheading != 0) {
			hideSubheading(visibleSubheading);
			// showHeading(hiddenHeading);
		}
		// ...then show the new heading's subheading (and hide its heading).
		showSubheading(subheading);
		// hideHeading(heading);
	// ...or else hide the heading's subheading (and show the heading).
	} else {
		hideSubheading(subheading);
		// showHeading(heading);
	}
}

function showHeadingTwo(heading) {  
  document.getElementById(heading).style.visibility = "visible"; 
  document.getElementById(heading).style.display = "inline";
}

function hideHeadingTwo(heading) {
  document.getElementById(heading).style.visibility = "hidden"; 
  document.getElementById(heading).style.display = "none";
  hiddenHeadingTwo = heading;
}

function showSubheadingTwo(subheading) {
  document.getElementById(subheading).style.visibility = "visible"; 
  document.getElementById(subheading).style.display = "inline";
  visibleSubheadingTwo = subheading;
}

function hideSubheadingTwo(subheading) {
  document.getElementById(subheading).style.visibility = "hidden"; 
  document.getElementById(subheading).style.display = "none";
	visibleSubheadingTwo = 0;
}

function changeHeadingTwo(heading, subheading) {
	// If the heading's subheading is not visible, show it...
	if (document.getElementById(subheading).style.visibility != "visible") {
		// If any other subheading is showing, hide it (in the old site, we would also show the old subheading's heading)...
		if (visibleSubheadingTwo != 0) {
			hideSubheadingTwo(visibleSubheadingTwo);
			// showHeadingTwo(hiddenHeadingTwo);
		}
		// ...then show the new heading's subheading (in the old site, we would also hide the new heading).
		showSubheadingTwo(subheading);
		// hideHeadingTwo(heading);
	// ...or else hide the heading's subheading (in the old site, we would also show the heading).
	} else {
		hideSubheadingTwo(subheading);
		// showHeadingTwo(heading);
	}
}

function searchSubmit() {
	if((document.searchFormBox.query.value == "Search keyword, item#") || (document.searchFormBox.query.value == "")) { 
		return false;
	}
	else {
		document.searchFormBox.submit();
	}
}

function WM_preloadImages() {

/*
WM_preloadImages()
Loads images into the browser's cache for later use.

Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)

Author: Nadav Savio
Author Email: nadav@wired.com

Usage: WM_preloadImages('image 1 URL', 'image 2 URL', 'image 3 URL', ...);
*/

  // Don't bother if there's no document.images
  if (document.images) {
    if (typeof(document.WM) == 'undefined'){
      document.WM = new Object();
    }
    document.WM.loadedImages = new Array();
    // Loop through all the arguments.
    var argLength = WM_preloadImages.arguments.length;
    for(arg=0;arg<argLength;arg++) {
      // For each arg, create a new image.
      document.WM.loadedImages[arg] = new Image();
      // Then set the source of that image to the current argument.
      document.WM.loadedImages[arg].src = WM_preloadImages.arguments[arg];
    }
  }
}

function updateHotspot(num){
	arrOff = arrNum[currentNum].split("#");
	WM_imageSwap(document.getElementById(arrOff[0]), arrOff[1]);
	WM_imageSwap(document.getElementById(arrOff[3]), arrOff[4]);
	hideSubmenu(arrOff[6]);
	arrOn = arrNum[num].split("#");
	WM_imageSwap(document.getElementById(arrOn[0]), arrOn[2]);
	WM_imageSwap(document.getElementById(arrOn[3]), arrOn[5]);
	showSubmenu(arrOn[6]);
	currentNum = num;
}

function updateHotspotBrewer(num){
	arrOff = arrNum[currentNum].split("#");
	WM_imageSwap(document.getElementById(arrOff[0]), arrOff[1]);
	hideSubmenu(arrOff[3]);
	arrOn = arrNum[num].split("#");
	WM_imageSwap(document.getElementById(arrOn[0]), arrOn[2]);
	showSubmenu(arrOn[3]);
	currentNum = num;
}

function WM_imageSwap(daImage, daSrc){
  var objStr,obj;
  /*
    WM_imageSwap()
    Changes the source of an image.

    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Shvatz
    Author Email: shvatz@wired.com

    Usage: WM_imageSwap(originalImage, 'newSourceUrl');

    Requires: WM_preloadImages() (optional, but recommended)
    Thanks to Ken Sundermeyer (ksundermeyer@macromedia.com) for his help
    with variables in ie3 for the mac. 
    */

  // Check to make sure that images are supported in the DOM.
  if(document.images){

    // Check to see whether you are using a name, number, or object
    if (typeof(daImage) == 'string') {
      // This whole objStr nonesense is here solely to gain compatability
      // with ie3 for the mac.
        objStr = 'document.getElementById("' + daImage + '")';
      obj = eval(objStr);
      obj.src = daSrc;
    } else if ((typeof(daImage) == 'object') || daImage || daImage.src) {
      daImage.src = daSrc;
    }
  }
}

function init() {
	// If the current page is a subpage of a heading, show the heading's subheading.
  if ((document.URL.indexOf("http://www.simplehuman.com/products/") != -1) || (document.URL.indexOf("\\products\\") != -1)) {
    showSubheading('prod_subheading');
    hideHeading('products_heading');
    if ((document.URL.indexOf("http://www.simplehuman.com/IamSteel") != -1) || (document.URL.indexOf("\\IamSteel") != -1)) {
      showSubheadingTwo('IamSteel_subheading');
      hideHeadingTwo('IamSteel_heading');
    } else if ((document.URL.indexOf("http://www.simplehuman.com/CanWorks") != -1) || (document.URL.indexOf("\\CanWorks") != -1)) {
      showSubheadingTwo('CanWorks_subheading');
      hideHeadingTwo('CanWorks_heading');
    }      
  } else if ((document.URL.indexOf("http://www.simplehuman.com/about_simplehuman/") != -1) || (document.URL.indexOf("\\about_simplehuman\\") != -1) || (document.URL.indexOf("simplehuman.typepad.com") != -1)) {
    showSubheading('about_subheading');
    hideHeading('about_heading');
  } else if ((document.URL.indexOf("http://www.simplehuman.com/retailer_locator/") != -1) || (document.URL.indexOf("\\retailer_locator\\") != -1)) {
    showSubheading('wherebuy_subheading');
    hideHeading('wherebuy_heading');
  } else if ((document.URL.indexOf("http://www.simplehuman.com/efficient_living/") != -1) || (document.URL.indexOf("\\efficient_living\\") != -1)) {
    showSubheading('effic_subheading');
    hideHeading('effic_heading');
  } else if ((document.URL.indexOf("http://www.simplehuman.com/customer_service/") != -1) || (document.URL.indexOf("\\customer_service\\") != -1)) {
    showSubheading('support_subheading');
    hideHeading('support_heading');
  } else if ((document.URL.indexOf("http://www.simplehuman.com/register/") != -1) || (document.URL.indexOf("\\register\\") != -1)) {
    showSubheading('support_subheading');
    hideHeading('support_heading');
  } else {
  	return;
  }
}

function isCompleteIdeasForm() {
  if ( 
    (document.ideasForm.firstName.value != "") && 
    (document.ideasForm.lastName.value != "") && 
    (document.ideasForm.email.value != "") && 
    (document.ideasForm.phoneArea.value != "select") && 
    (document.ideasForm.phonePrefix.value != "") && 
    (document.ideasForm.phoneLast4.value != "") && 
    (document.ideasForm.ideaTitle.value != "") && 
    (document.ideasForm.ideaDescr.value != "select") && 
    (document.ideasForm.readGuidelines.checked) 
  )
  {
    return true;
  } 
  else
  {
    showError('incompleteFormError');
    return false;
  }
}

function isCompleteKioskOfferForm() {
  if ( 
    (document.kioskOfferForm.firstName.value != "") && 
    (document.kioskOfferForm.lastName.value != "") && 
    (document.kioskOfferForm.email.value != "")
  )
  {
    return true;
  } 
  else
  {
    showError('incompleteFormError');
    return false;
  }
}

function isCompleteEmailFriendForm() {
  if ( 
    (document.emailFriendForm.yourName.value != "") && 
    (document.emailFriendForm.friendEmailAddress.value != "") &&
    (document.emailFriendForm.yourEmailAddress.value != "")
  )
  {
    return true;
  } 
  else
  {
    showError('incompleteFormError');
    return false;
  }
}

function isCompleteContactForm() {
  if ( 
    (document.contactForm.name.value != "") && 
    (document.contactForm.email.value != "") && 
    (document.contactForm.phone.value != "") && 
    (document.contactForm.subject.value != "") && 
    (document.contactForm.description.value != "") 
  )
  {
    return true;
  } 
  else
  {
    showError('incompleteFormError');
    if (document.contactForm.name.value == "")
    {
      showError('fullNameError');
    }
    if (document.contactForm.email.value == "")
    {
      showError('emailError');
    }
    if (document.contactForm.phone.value == "")
    {
      showError('phoneError');
    }
    if (document.contactForm.subject.value == "")
    {
      showError('subjectError');
    }
    if (document.contactForm.description.value == "")
    {
      showError('descriptionError');
    }
    return false;
  }
}

function isCompleteContactFormUk() {
  if ( 
    (document.contactFormUk.forename.value != "") && 
    (document.contactFormUk.surname.value != "") && 
    (document.contactFormUk.emailUk.value != "") && 
    (document.contactFormUk.phoneUk.value != "") && 
    (document.contactFormUk.note.value != "") 
  )
  {
    return true;
  } 
  else
  {
    showError('incompleteFormUkError');
    if (document.contactFormUk.forename.value == "")
    {
      showError('forenameError');
    }
    if (document.contactFormUk.surname.value == "")
    {
      showError('surnameError');
    }
    if (document.contactFormUk.emailUk.value == "")
    {
      showError('emailUkError');
    }
    if (document.contactFormUk.phoneUk.value == "")
    {
      showError('phoneUkError');
    }
    if (document.contactFormUk.note.value == "")
    {
      showError('noteError');
    }
    return false;
  }
}

function isCompleteRegForm() {
  if ( 
    (document.regForm.firstName.value != "") && 
    (document.regForm.lastName.value != "") && 
    (document.regForm.addr1.value != "") && 
    (document.regForm.city.value != "") && 
    (document.regForm.state.value != "select") && 
    (document.regForm.zip.value != "") && 
    (document.regForm.email.value != "") && 
    (document.regForm.product.value != "select") && 
    (document.regForm.retailer.value != "") && 
    (document.regForm.purchaseDateMM.value != "") && 
    (document.regForm.purchaseDateDD.value != "") && 
    (document.regForm.whereUse.value != "select")
/*
    (document.regForm.householdCount.value != "") && 
    (document.regForm.styling.value != "select") && 
    (document.regForm.priceValue.value != "select") && 
    (document.regForm.functionality.value != "select") && 
    (document.regForm.brand.value != "select") && 
    (document.regForm.ownedOtherProducts.value != "") && 
    (document.regForm.prevTrashcan.value != "select") && 
    (document.regForm.triedSurefit.value != "") && 
    (document.regForm.useDeodorizer.value != "") && 
    (document.regForm.useDishrack.value != "") && 
    (document.regForm.internetPurchaseFreq != "select") && 
    (document.regForm.whereHeard.value != "") && 
    (document.regForm.likelyToRecommend.value != "select") 
*/
  )
  {
    return true;
  } 
  else
  {
    showError('incompleteFormError');
    return false;
  }
}

function isCompleteLinerSpecialForm() {
  var optionWherePurchased = -1, optionHowResearchedPurchase = -1, optionStoreMostVisited = -1, optionStore2ndMostVisited = -1;
  var valueWherePurchased, valueStoreMostVisited, valueStore2ndMostVisited;

  for (i = 0; i < document.linerSpecialForm.wherePurchased.length; i++) {
    if (document.linerSpecialForm.wherePurchased[i].checked) {
      optionWherePurchased = i;
      valueWherePurchased = document.linerSpecialForm.wherePurchased[i].value;
    }
  }

  for (i = 0; i < document.linerSpecialForm.howResearchedPurchase.length; i++) {
    if (document.linerSpecialForm.howResearchedPurchase[i].checked) {
      optionHowResearchedPurchase = i;
    }
  }

  for (i = 0; i < document.linerSpecialForm.storeMostVisited.length; i++) {
    if (document.linerSpecialForm.storeMostVisited[i].checked) {
      optionStoreMostVisited = i;
      valueStoreMostVisited = document.linerSpecialForm.storeMostVisited[i].value;
    }
  }

  for (i = 0; i < document.linerSpecialForm.store2ndMostVisited.length; i++) {
    if (document.linerSpecialForm.store2ndMostVisited[i].checked) {
      optionStore2ndMostVisited = i;
      valueStore2ndMostVisited = document.linerSpecialForm.store2ndMostVisited[i].value;
    }
  }

  if ((optionWherePurchased == -1) || (optionHowResearchedPurchase == -1) || (optionStoreMostVisited == -1) || (optionStore2ndMostVisited == -1) ) {
    showError('incompleteFormError');
    return false;
  } else if (  ((valueStoreMostVisited == "other") && (document.linerSpecialForm.storeMostVisitedOther.value == "")) || 
              ((valueWherePurchased == "other") && (document.linerSpecialForm.wherePurchasedOther.value == "")) || 
              ((valueStore2ndMostVisited == "other") && (document.linerSpecialForm.store2ndMostVisitedOther.value == "")) ) {
    showError('incompleteFormError');
    return false;
  } else if (document.linerSpecialForm.email.value == "") {
    showError('incompleteFormError');
    return false;
  } else {
    return true;
  }
}
  
function isCompleteCouponForm() {
  var optionWhereHeard = -1;
  var valueWhereHeard = "unchecked";

  for (i = 0; i < document.emailCouponForm.whereHeard.length; i++) {
    if (document.emailCouponForm.whereHeard[i].checked) {
      optionWhereHeard = i;
      valueWhereHeard = document.emailCouponForm.whereHeard[i].value;
    }
  }

  if (optionWhereHeard == -1) {
    showError('incompleteFormError');
    return false;
  } else if ( (valueWhereHeard != "unchecked") && (valueWhereHeard != "word of mouth") && (document.emailCouponForm.whereHeardSpecify.value == "") ) {
    showError('incompleteFormError');
    return false;
  } else if (document.emailCouponForm.email.value == "") {
    showError('incompleteFormError');
    return false;
  } else {
    return true;
  }
}
  
function isCompleteUpgradeFormOld() {
  var optionEverPurchased = -1;
  var valueEverPurchased = "unchecked";

  for (i = 0; i < document.upgradeForm.everPurchased.length; i++) {
    if (document.upgradeForm.everPurchased[i].checked) {
      optionEverPurchased = i;
      valueEverPurchased = document.upgradeForm.everPurchased[i].value;
    }
  }
  if ( (valueEverPurchased == "yes") && (document.upgradeForm.nameOfStore.value == "") ) {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.upgradeForm.bagOverhang.checked) || (document.upgradeForm.doesntFitSpace.checked) || (document.upgradeForm.doesntMatchKitchen.checked) || (document.upgradeForm.flimsyPedal.checked) || (document.upgradeForm.hardToRemoveBag.checked) || (document.upgradeForm.otherCurrentProblem.checked) || (document.upgradeForm.noCurrentProblem.checked) ) {
    ;
  } else {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.upgradeForm.otherCurrentProblem.checked) && (document.upgradeForm.otherCurrentProblemSpecify.value == "") ) {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.upgradeForm.quality.checked) || (document.upgradeForm.price.checked) || (document.upgradeForm.spaceEfficient.checked) || (document.upgradeForm.easyToUse.checked) || (document.upgradeForm.practicalFeatures.checked) || (document.upgradeForm.appearance.checked) || (document.upgradeForm.warranty.checked) || (document.upgradeForm.otherImportantFactor.checked) ) {
    ;
  } else {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.upgradeForm.otherImportantFactor.checked) && (document.upgradeForm.otherImportantFactorSpecify.value == "") ) {
    showError('incompleteFormError');
    return false;
  }
  if (document.upgradeForm.email.value == "") {
    showError('incompleteFormError');
    return false;
  } else {
    return true;
  }
}
  
function isCompleteUpgradeForm() {
  var optionEverPurchased = -1;
  var valueEverPurchased = "unchecked";

  for (i = 0; i < document.upgradeForm["00N30000000tkNk"].length; i++) {
    if (document.upgradeForm["00N30000000tkNk"][i].checked) {
      optionEverPurchased = i;
      valueEverPurchased = document.upgradeForm["00N30000000tkNk"][i].value;
    }
  }
  if ( (valueEverPurchased == "yes") && (document.upgradeForm["00N30000000sAiC"].value == "") ) {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.upgradeForm["00N30000000tkJe"].checked) || (document.upgradeForm["00N30000000tkQK"].checked) || (document.upgradeForm["00N30000000tkQP"].checked) || (document.upgradeForm["00N30000000tkQe"].checked) || (document.upgradeForm["00N30000000tkQj"].checked) || (document.upgradeForm["00N30000000tkdA"].checked) || (document.upgradeForm["00N30000000tkQt"].checked) ) {
    ;
  } else {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.upgradeForm["00N30000000tkdA"].checked) && (document.upgradeForm["00N30000000tkPq"].value == "") ) {
    showError('incompleteFormError');
    return false;
  }

  if ( (document.upgradeForm["00N30000000tkR3"].checked) || (document.upgradeForm["00N30000000tkRD"].checked) || (document.upgradeForm["00N30000000tkRN"].checked) || (document.upgradeForm["00N30000000tkRc"].checked) || (document.upgradeForm["00N30000000tkRr"].checked) || (document.upgradeForm["00N30000000tkSa"].checked) || (document.upgradeForm["00N30000000tkSp"].checked) || (document.upgradeForm["00N30000000tkqw"].checked) ) {
    ;
  } else {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.upgradeForm["00N30000000tkqw"].checked) && (document.upgradeForm["00N30000000tkQ0"].value == "") ) {
    showError('incompleteFormError');
    return false;
  }
  if (document.upgradeForm.email.value == "") {
    showError('incompleteFormError');
    return false;
  } else {
    return true;
  }
}
  
/*
function isCompleteBrewerSurveyOld() {
  var optionEverPurchasedCoffeeMaker = -1;
  var valueEverPurchasedCoffeeMaker = "unchecked";
  var optionEverPurchasedSingleServBrewer = -1;
  var valueEverPurchasedSingleServBrewer = "unchecked";

  for (i = 0; i < document.brewerSurvey["00N300000010VkO"].length; i++) {
    if (document.brewerSurvey["00N300000010VkO"][i].checked) {
      optionEverPurchasedCoffeeMaker = i;
      valueEverPurchasedCoffeeMaker = document.brewerSurvey["00N300000010VkO"][i].value;
    }
  }
  for (i = 0; i < document.brewerSurvey["00N300000010Vog"].length; i++) {
    if (document.brewerSurvey["00N300000010Vog"][i].checked) {
      optionEverPurchasedSingleServBrewer = i;
      valueEverPurchasedSingleServBrewer = document.brewerSurvey["00N300000010Vog"][i].value;
    }
  }
  if ( (valueEverPurchasedCoffeeMaker == "yes") && ((document.brewerSurvey["00N300000010VkF"].value == "") || (document.brewerSurvey["00N300000010Vof"].value =="")) ) {
    showError('incompleteFormError');
    return false;
  }
  if ( (valueEverPurchasedSingleServBrewer == "yes") && ((document.brewerSurvey["00N300000010VpO"].value == "") || (document.brewerSurvey["00N300000010VUb"].value =="")) ) {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.brewerSurvey["00N30000000sAiC"].value == "") || (document.brewerSurvey["00N300000010VuE"].value == "") || (document.brewerSurvey.name.value == "") || (document.brewerSurvey["00N30000000lQ55"].value == "") || (document.brewerSurvey.email.value == "") ) {
    showError('incompleteFormError');
    return false;
  } else {
    return true;
  }
}
*/
function isCompleteBrewerSurvey() {
  var optionGender = -1;
  var optionAge = -1;
  var optionDecision = -1;
  var optionKnowledgeable = -1;
  var valueKnowledgeable = "unchecked";
  var optionLikeTaste = -1;
  var valueLikeTaste = "unchecked";
  var optionRecommend = -1;
  var valueRecommend = "unchecked";

  for (i = 0; i < document.brewerSurvey["00N60000001MXU2"].length; i++) {
    if (document.brewerSurvey["00N60000001MXU2"][i].checked) {
      optionGender = i;
    }
  }
  for (i = 0; i < document.brewerSurvey["00N60000001MXUb"].length; i++) {
    if (document.brewerSurvey["00N60000001MXUb"][i].checked) {
      optionAge = i;
    }
  }
  for (i = 0; i < document.brewerSurvey["00N60000001MXUc"].length; i++) {
    if (document.brewerSurvey["00N60000001MXUc"][i].checked) {
      optionDecision = i;
    }
  }
  for (i = 0; i < document.brewerSurvey["00N60000001MXY1"].length; i++) {
    if (document.brewerSurvey["00N60000001MXY1"][i].checked) {
      optionKnowledgeable = i;
      valueKnowledgeable = document.brewerSurvey["00N60000001MXY1"][i].value;
   }
  }
  for (i = 0; i < document.brewerSurvey["00N60000001MXY2"].length; i++) {
    if (document.brewerSurvey["00N60000001MXY2"][i].checked) {
      optionLikeTaste = i;
      valueLikeTaste = document.brewerSurvey["00N60000001MXY2"][i].value;
    }
  }
  for (i = 0; i < document.brewerSurvey["00N60000001MXYo"].length; i++) {
    if (document.brewerSurvey["00N60000001MXYo"][i].checked) {
      optionRecommend = i;
      valueRecommend = document.brewerSurvey["00N60000001MXYo"][i].value;
    }
  }
  if( ((valueKnowledgeable == "Other") && (document.brewerSurvey["00N60000001MXYn"].value == "")) || ((valueLikeTaste == "Other") && (document.brewerSurvey["00N60000001MXZ2"].value == "")) || ((valueRecommend == "Other") && (document.brewerSurvey["00N60000001MXZ3"].value == "")) ) {
    showError('incompleteFormError');
    return false;
  }

  if ( (optionGender == -1) || (optionAge == -1) || (optionDecision == -1) || (optionKnowledgeable == -1) || (optionLikeTaste == -1) || (optionRecommend == -1)) {
    showError('incompleteFormError');
    return false;
  }
  if ( (document.brewerSurvey["00N60000001MXY0"].value == "") ) {
    showError('incompleteFormError');
    return false;
  } else {
    return true;
  }
}

function isCompleteSupportForm() {
  if ( 
    (document.supportForm.name.value != "") && 
    (document.supportForm.email.value != "") && 
    (document.supportForm.phone.value != "") && 
    (document.supportForm["00N30000000sAnf"].value != "")     //question or problem
  )
  {
    return true;
  } 
  else
  {
    showError('incompleteFormError');
    if (document.getElementById("fullNameError") && (document.supportForm.name.value == ""))
    {
      showError('fullNameError');
    }
    if (document.getElementById("emailError") && (document.supportForm.email.value == ""))
    {
      showError('emailError');
    }
    if (document.getElementById("phoneError") && (document.supportForm.phone.value == ""))
    {
      showError('phoneError');
    }
    if (document.getElementById("questionError") && (document.supportForm["00N30000000sAnf"].value == ""))
    {
      showError('questionError');
    }
    return false;
  }

}
  
function setAction(selectObject)
  {
    var selSizeAndFinish = document.getElementById('sizeAndFinish');
    var orderItem = selSizeAndFinish.options[selSizeAndFinish.selectedIndex].value;
    
    document.getElementById('orderForm').action='http://order.store.yahoo.com/cgi-bin/wg-order?simplehuman+' + orderItem;
  }

function writeAltViewLinkCode(itemName, linksAmount, columns)
{
	var result = "<div class=\"altviews\">\n";
	result = result + "<h3>alternate views:</h3>\n";
	for(var i = 1; i<=linksAmount; i++){
		result = result + "<a href=\"http://www.simplehuman.com/products/alternate-views.html?";
		result = result + itemName + "," + i + "," + linksAmount + "\" ";
		result = result + "onclick=\"return popAltView('http://www.simplehuman.com/products/alternate-views.html?";
		result = result + itemName + "," + i + "," + linksAmount + "');\">";
		result = result + "<img src=\"http://www.simplehuman.com/images/altthumbs/th-";
		result = result + itemName + "-" + i + ".jpg\" alt=\"\" ";
		if (i % columns == 0)
			result = result + "class=\"thumbAltviewEnd\" /></a><br /\n>";
		else
			result = result + "class=\"thumbAltview\" /></a\n>";
	}
	result = result + "</div>\n";
	document.write(result);
}

function writeAltViewLinkCode2(itemName, linksAmount, columns, mainImageSrc)
{
	var result = "<div class=\"altviews\">\n";
	result = result + "<h3>alternate views:</h3>\n";
	for(var i = 1; i<=linksAmount; i++){
		result = result + "<a href=\"#\" style=\"cursor:hand\" ";
		result = result + "onmouseover=\"hideVideoIconDiv('videoPopup');WM_imageSwap('mainImg','http://www.simplehuman.com/images/altviews/";
		result = result + itemName + "-" + i + ".jpg')\" ";
		result = result + "onmouseout=\"showVideoIconDiv('videoPopup');WM_imageSwap('mainImg','" + mainImageSrc + "')\"  alt=\"\" onclick=\"return false;\" >";
		result = result + "<div style=\"float:left;\"><img src=\"http://www.simplehuman.com/images/altthumbs/th-";
		result = result + itemName + "-" + i + ".jpg\" alt=\"\" ";
		if (i % columns == 0){
			result = result + "class=\"thumbAltviewEnd\" /></div></a><br /\n>";
		}
		else {
			result = result + "class=\"thumbAltview\" /></div></a\n>";
		}
	}
	result = result + "</div>\n";
	document.write(result);
}

var myimages = new Array();
function preloading(){
	for (x=0; x<preloading.arguments.length; x++){
		myimages[x] = new Image();
		myimages[x].src = preloading.arguments[x];
	}
}

function popFeedbackThanks() {
	var strHref = 'feedback-thanks.html';
	window.open(strHref, 'feedback-thanks', 'width=400, height=170, top=300, left=250, scrollbars=0');
}

function validation(formElement){
	// took out spam bot code for autofillers 1/1/2008
	//put back spam bot code 8/11/2009
  if (formElement.EmailAddress.value != ""){
	return false;
  }
  else {
  	try{formElement.elements["00N60000001Ok9v"].value = formElement.elements["name"].value;}catch(err){}
	try{formElement.elements["00N60000001Ok9q"].value = formElement.elements["phone"].value;}catch(err){}
	try{formElement.elements["00N60000001OkA5"].value = formElement.elements["email"].value;}catch(err){}
	
	var objPageName;
	objPageName = formElement['pageName'];
    strPage = objPageName.value;
	if (strPage == 'websiteFeedbackForm')
	{
	  if (formElement.elements["00N60000001MXvm"].value == ""){
		return false;
	  }
	  else if((formElement.elements["pageType"]) && (formElement.elements["pageType"].value == "popUp")){
		//do nothing;
	  }
	  else {
		popFeedbackThanks();
	  }
	}
	if (strPage == 'supportForm')
	{
		return isCompleteSupportForm();
	}
	else if (strPage == 'regForm')
	{
		return isCompleteRegForm();
	}
	else if (strPage == 'contactForm')
	{
		return isCompleteContactForm();
	}
	else if (strPage == 'brewerSurvey')
	{
		return isCompleteBrewerSurvey();
	}
	return true;
  }
}
  function checkAvailable(strProducts){
	var arrProducts = strProducts.split(",");
	for(var i=0;i<arrProducts.length;i++){
	  if(arrAvailable[arrProducts[i]] == 'Yes'){
		if(document.getElementById('shipTime_'+arrProducts[i])){
			shipTimeElement = document.getElementById('shipTime_'+arrProducts[i]);
			shipTimeElement.style.visibility = "visible";
			shipTimeElement.style.display = "block";
		}
		if(document.getElementById('shipFree_'+arrProducts[i])){
			shipFreeElement = document.getElementById('shipFree_'+arrProducts[i]);
			shipFreeElement.style.visibility = "visible";
			shipFreeElement.style.display = "block";
		}
		if(document.getElementById('outStock_'+arrProducts[i])){
			outStockElement = document.getElementById('outStock_'+arrProducts[i]);
			outStockElement.style.visibility = "hidden";
			outStockElement.style.display = "none";
		}
		addToCartElement = document.getElementById('addtocart_'+arrProducts[i]);
		if(addToCartElement){
			addToCartElement.style.visibility = "visible";
			addToCartElement.style.display = "inline";
		}
		outStockImgElement = document.getElementById('outStockImg_'+arrProducts[i]);
		if(outStockImgElement){
			outStockImgElement.style.visibility = "hidden";
			outStockImgElement.style.display = "none";
		}

      }
	  else if(arrAvailable[arrProducts[i]] == 'No'){
		if(document.getElementById('shipTime_'+arrProducts[i])){
			shipTimeElement = document.getElementById('shipTime_'+arrProducts[i]);
			shipTimeElement.style.visibility = "hidden";
			shipTimeElement.style.display = "none";
		}
		if(document.getElementById('shipFree_'+arrProducts[i])){
			shipFreeElement = document.getElementById('shipFree_'+arrProducts[i]);
			shipFreeElement.style.visibility = "hidden";
			shipFreeElement.style.display = "none";
		}
		if(document.getElementById('outStock_'+arrProducts[i])){
			outStockElement = document.getElementById('outStock_'+arrProducts[i]);
			outStockElement.style.visibility = "visible";
			outStockElement.style.display = "block";
		}
		addToCartElement = document.getElementById('addtocart_'+arrProducts[i]);
		if(addToCartElement){
			addToCartElement.style.visibility = "hidden";
			addToCartElement.style.display = "none";
		}
		outStockImgElement = document.getElementById('outStockImg_'+arrProducts[i]);
		if(outStockImgElement){
			outStockImgElement.style.visibility = "visible";
			outStockImgElement.style.display = "inline";
		}
	  }
	}
  }

// ==================================================================================================
// ====================================== For For State Dependency List =============================
// Create arrays containing country states
// Note: These arrays could be created dynamically
var arrCountries, arrCountriesName
var arrUS, arrCA
arrUS = ["AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FL",
         "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA",
         "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV",
         "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA",
         "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA",
         "WA", "WV", "WI", "WY",
         "", "--Arm--", "AA", "AE", "AP"]
arrCA = ["AB", "BC", "MB", "NB", "NL", "NT", "NS", "NU", "ON", "PE", "QC", "SK", "YT"]
arrCountries =[arrUS, arrCA]
arrCountriesName = ["US", "CA"]

// Function to handle dynamically altering the contents of the State List box
function updateStateList(theForm, newDisplay)
{   var CountrySelect, StateSelect, NumEntries, i
    CountrySelect = theForm.Countries
    StateSelect = theForm.States

  // Delete all entries in the cities list box
  for (i = StateSelect.length; i > 0; i--){
    StateSelect.options[i-1] = null
  }

  // Add comment option to City List box
  StateSelect.options[0] = new Option("select", "select")

  // If state is selected add its cities to the City List box
  if (newDisplay >= 0) {
    NumEntries = arrCountries[newDisplay].length
    for (i = 0; i < NumEntries; i++) {
      StateSelect.options[i+1] = new Option((arrCountries[newDisplay])[i],(arrCountries[newDisplay])[i])
    }
  }
  StateSelect.selectedIndex = 0;
}

function updateState(theForm)
{   var CountrySelect, StateSelect
    CountrySelect = theForm.Countries
    StateSelect = theForm.States
	if (StateSelect.value.length != 2)
		StateSelect.selectedIndex = 0;

	theForm.elements["00N60000001Oj4W"].value = arrCountriesName[CountrySelect.value];
	theForm.elements["00N30000000lQ6r"].value = StateSelect.value
	//alert(theForm.elements["00N60000001Oj4W"].value);
	//alert(theForm.elements["00N30000000lQ6r"].value);
}
// ====================================== For For State Dependency List End =============================
// ======================================================================================================


  
var arrNameValuePairs = new Array();
function getNameValuePairs(strURL){
	for(var i=0; i<strURL.split("&").length; i++) {
		arrNameValuePairs[i] = strURL.split("&")[i];
	}
}
function getURLValue(strKey){
	for(var j=0; j < arrNameValuePairs.length; j++) {
		if(arrNameValuePairs[j].split("=")[0] == strKey) {
			return (arrNameValuePairs[j].split("=")[1]).replace(/\+/g, " ");
		}
	}
	return "";
}

function urlDecode(theString) {
	if (typeof theString != "undefined" && theString != "") {
		var returnString = new String();
		returnString = theString;
		return unescape(returnString.replace(/[+]/g,"%20"));
	}
	return "";
}

function in_array(val,arr) { 
	var bool = false; 
	for (var i=0; i<arr.length; i++) { 
		if (arr[i]==val) { 
			bool=true; 
		} 
	} 
	return bool; 
} 

function array_keys(arr) { 
	var arrKeys = new Array();
	var i = 0;
	for (var keyName in arr)
		{
		arrKeys[i] = keyName;
		i+=1
		}
	return arrKeys;
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
// -->