﻿// ** Function to display flash **

function showFlashLogo(path, name, width, height)
{
   var MM_contentVersion = 6;
   var MM_FlashCanPlay = false;
   var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
   if ( plugin ) {
		   var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	      for (var i = 0; i < words.length; ++i)
	      {
		      if (isNaN(parseInt(words[i])))
		      continue;
		      var MM_PluginVersion = words[i]; 
	      }
	   MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
   }
   else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
	   var flash;
	   try
	   {
	      flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + MM_contentVersion);
	      MM_FlashCanPlay = (flash != null); 
	   }
	   catch(exception)
	   {
	      MM_FlashCanPlay = false;
	   }
   }
   if ( MM_FlashCanPlay ) {
	   document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	   document.write('  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	   document.write(' ID="' + name + '" width="' + width + '" height="' + height + '" align="">');
	   document.write(' <param name="movie" value="' + path + name + '.swf" /> <param name="wmode" value="transparent" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" />  '); 
	   document.write(' <embed src="' + path + name + '.swf" menu="false" wmode="transparent" quality="high" bgcolor="#FFFFFF"  ');
	   document.write(' swLiveConnect="FALSE" width="' + width + '" height="' + height + '" name="' + name + '" align=""');
	   document.write(' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
	   document.write(' </embed>');
	   document.write(' </object>');
   }
   else {
	   document.write('<img src="/' + path + name + '.jpg" width="'+ width + '" height="' + height + '" usemap="#' + name + '" border="0" />');
   }
}

function mo(object)
{
   // if on, turn off
   if (object.src.lastIndexOf("-on") > 0) object.src = object.src.replace("-on", "");
   else
   {
      //if off, turn on
      if (object.src.lastIndexOf(".es") > 0) object.src = object.src.replace(".es.gif", "-on.es.gif"); //Spanish
      else object.src = object.src.replace(".gif", "-on.gif"); //English
   }
}


// **Start: Live text nav menu **
function navMo(obj)
{
   if (obj.className == "On") obj.className = "";
   else obj.className = "On";
}
// **End: Live text nav menu **


// **Start: SectionNavigation control **
function buildSub(index)  // builds the links dropdown list
{
   if (!isNaN(index)) // make sure a number was passed in
   {
      dropdownList.disabled = false;
      dropdownList.options.length = 0;  // clears the links drop down list

	   var selArray = eval("a" + index);
	   for (var i=0; i < selArray.length; i++)
	   {
		   eval("dropdownList.options[i]=" + "new Option" + selArray[i]);  // build the drop down list options from an array
		   if ((window.location.pathname.toLowerCase() + window.location.search.toLowerCase()) == dropdownList.options[i].value.toLowerCase()) dropdownList.options[i].selected = true;
		   else if (normalizedHrefPage(window.location.pathname) == normalizedHrefPage(dropdownList.options[i].value)) dropdownList.options[i].selected = true;
		   dropdownList.options[i].text = dropdownList.options[i].text.replace("#39;", "'"); // make ' work
	   }
	   
	   // Automatically navigate to page if there is only one option
	   if (dropdownList.options.length == 2 && dropdownList.selectedIndex == 0)
	   {
	      dropdownList.options[1].selected = true;
	      navigateToTopic(dropdownList);
	   }
	}
}

function normalizedHrefPage(href)
{
   href = href.toLowerCase();
   var slash = href.lastIndexOf("/");
   if (slash != -1) 
   {
      var filename = href.substr(slash + 1);
      if ("default.htm" == filename || "default.asp" == filename || "default.aspx" == filename)
         href = href.substr(0, slash + 1);
   }
   return href;
}

function navigateToTopic(object)
{
   var page = object.options[object.selectedIndex].value;
   if (page == "/Corporate/B2B/Logistics/")
   {
      // open these 2 links in a new window
      object.style.cursor = "wait";
      window.open(page, "_blank");
   }
   else if (page != "")
   {
      object.style.cursor = "wait";
      window.open(page, "_self");
   }
}
// **End: SectionNavigation control **

// **Start: ViewDonations control **
function viewDonations(object)
{
   var category = object.options[object.selectedIndex].value;
   if (category != "")
   {
      var url = "/Controls/ViewDonations.aspx?cat=" + category;
      document.getElementById("ifDonations").src = url;
   }
}
// **End: ViewDonations control **

function openRecipeMailSignup()
{
   window.open('/Recipes/Newsletter/RecipeMailSignup.aspx', 'RecipeMailSignup', 'height=340, width=530, location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no');
}
function openOrderForm()
{
   window.open('/Recipes/Promotions/RIM_OrderForm.aspx', 'DVDOrderForm', 'height=389, width=486, location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no');
}
function openHealthyLiving()
{
   window.open('/Recipes/Promotions/RIM_HealthyLiving.aspx', 'HealthyLiving', 'height=550, width=760, location=no, menubar=no, resizable=no, scrollbars=yes, status=no, titlebar=no, toolbar=no');
}
function readyTextBox(object)
{
   if (object.value == object.title)
      object.value = "";
}
function resetTextBox(object)
{
   if (object.value == "")
      object.value = object.title;
}

// **Start Consumer recipes **
function navigateToProduct(object)
{
   var productId = object.options[object.selectedIndex].value;
   object.selectedIndex = 0;
   if (productId != "")
   {
      var url = "ViewProduct.aspx?id=" + productId;
      window.open(url, "_self");
   }
}
// **End Consumer recipes