function buttonOn(carry)
    {    document[carry].src="/natures-best/images/cssImages/btn_wheretobuyOn_en.gif";    }
        
function buttonOff(carry)
    { document[carry].src="/natures-best/images/cssImages/btn_wheretobuy_en.gif"; }
function buttonEmailOn(carry)
    {    document[carry].src="/natures-best/images/cssImages/btn_emailsignupOn_en.jpg";    }
        
function buttonEmailOff(carry)
    { document[carry].src="/natures-best/images/cssImages/btn_emailsignup_en.jpg"; }
    
function buttonShareOn(carry)
    {    document[carry].src="/natures-best/images/cssImages/btn_nb_share_on.gif";    }
        
function buttonShareOff(carry)
    { document[carry].src="/natures-best/images/cssImages/btn_nb_share_off.gif"; }
    
function buttonCouponFelineOn(carry)
    {    document[carry].src="/natures-best/images/cssImages/btn_catfood_on_en.png";    }
        
function buttonCouponFelineOff(carry)
    { document[carry].src="/natures-best/images/cssImages/btn_catfood_en.png"; }
    
function buttonCouponCanineOn(carry)
    {    document[carry].src="/natures-best/images/cssImages/btn_dogfood_on_en.png";    }
        
function buttonCouponCanineOff(carry)
    { document[carry].src="/natures-best/images/cssImages/btn_dogfood_en.png"; }
function buttonCouponOn(carry)
    {    document[carry].src="/natures-best/images/cssImages/btn_COUPON__on_en_CA.png";    }
         
function buttonCouponOff(carry)
    { document[carry].src="/natures-best/images/cssImages/btn_COUPON_en_CA.png"; }    
    
function buttonCouponfrCAOn(carry)
    {    document[carry].src="/natures-best/images/cssImages/btn_COUPON_on_fr_CA.png";    }
        
function buttonCouponfrCAOff(carry)
    { document[carry].src="/natures-best/images/cssImages/btn_COUPON_fr_CA.png"; }

function changeDiscBox(carry, toSet)
    {
        updateDiscBox(carry)
        
        //make AJAX call to set product in session
        if (toSet)
        {
          setNBProduct(carry);
        }
    }
    
function updateDiscBox(carry)
    {
        //for mouseover
         
        document.getElementById('AdultChickenOGBoxes').style.display = "none";
        document.getElementById('AdultChickenBoxes').style.display = "none";
        document.getElementById('AdultChickenSmBoxes').style.display = "none";
        document.getElementById('AdultLambBoxes').style.display = "none";
        document.getElementById('AdultLambSmBoxes').style.display = "none";
        document.getElementById('PuppyChickenBoxes').style.display = "none";
        document.getElementById('PuppyLambBoxes').style.display = "none";
        document.getElementById('AdultChickenbagbottom').style.display = "none";
        document.getElementById('AdultChickenSmbagbottom').style.display = "none";
        document.getElementById('AdultLambbagbottom').style.display = "none";
        document.getElementById('AdultLambSmbagbottom').style.display = "none";
        document.getElementById('PuppyChickenbagbottom').style.display = "none";
        document.getElementById('PuppyLambbagbottom').style.display = "none";
        
        //REMOVED 06-06-08
        //document.getElementById(carry+"Boxes").style.display = "block";
        //document.getElementById(carry+"bagbottom").style.display = "block";
        
        if (document.getElementById(carry+"Boxes") != null) {
            document.getElementById(carry+"Boxes").style.display = "block";
        } else {
            //set boxes to OG view
            document.getElementById("AdultChickenOGBoxes").style.display = "block";
        }
        
        if (document.getElementById(carry+"bagbottom") != null) {
            document.getElementById(carry+"bagbottom").style.display = "block";
        } else {
            //set first to visible
            document.getElementById('AdultChickenbagbottom').style.display = "block";
        }
    }
            
function changeDrop(carry, toSet)
    {    
        document.getElementById('AdultChicken').style.display = "none";
        document.getElementById('AdultChickenSm').style.display = "none";
        document.getElementById('AdultLamb').style.display = "none";
        document.getElementById('AdultLambSm').style.display = "none";
        document.getElementById('PuppyChicken').style.display = "none";
        document.getElementById('PuppyLamb').style.display = "none";
        document.getElementById('footer').style.display = "none";
        document.getElementById(carry).style.display = "block";
        document.getElementById('footer').style.display = "block";
        
        //make AJAX call to set product in session
        if (toSet)
        {
          setNBProduct(carry);
        }
    }

    
function displayProductInfo(productName, toSet)
{
  var selectOptions = document.getElementById('nbDrop');
  if (selectOptions != null)
  {
    for (var x = 0; x < selectOptions.length; x++)
    {
      if (productName == selectOptions.options[x].value)
      {
        selectOptions.options[x].selected = true;
        changeDrop(productName, toSet);
      }
    }
  }
}


function setNBProduct(carry)
{
    try
    {
      //using random number on request query string to prevent caching
      var params = "productName=" + carry + "&r=" + Math.random();
      new Ajax.Request( '/hillspet/minisite/naturesBest/ajax/naturesBestAjaxSetProduct.hjsp', {method: 'get', parameters: params} );
    }
    catch(e)
    {
      alert(e.lineNumber + ' : ' + e.message);
    }
}


function getNBProductDiscover()
{
  try
  {
    //using random number on request query string to prevent caching
    var params = "r=" + Math.random();
    new Ajax.Request( '/hillspet/minisite/naturesBest/ajax/naturesBestAjaxSetDiscoverProduct.hjsp', {method: 'get', parameters: params, onComplete: function(response) { handleGetNBProductResponse(response, "discoverHome"); } } );
  }
  catch(e)
  {
    alert(e.lineNumber + ' : ' + e.message);
  }
}


function getNBProductOther()
{
  try
  {
    //using random number on request query string to prevent caching
    var params = "r=" + Math.random();
    new Ajax.Request( '/hillspet/minisite/naturesBest/ajax/naturesBestAjaxSetDiscoverProduct.hjsp', {method: 'get', parameters: params, onComplete: function(response) { handleGetNBProductResponse(response, "other"); } } );
  }
  catch(e)
  {
    alert(e.lineNumber + ' : ' + e.message);
  }
}


function handleGetNBProductResponse(response, page)
{
    try
    {
        startXMLtag = '<productname>';
        endXMLtag = '</productname>';
        
        //get response text/xml
        var xmlText = response.responseText;
        
        //get product name from XML - e.g. <?xml version="1.0" ?><response><productname>AdultLambSm</productname></response>
        var startIndex = xmlText.indexOf(startXMLtag) + startXMLtag.length;
        var endIndex = xmlText.indexOf(endXMLtag);
        var productName = xmlText.substring(startIndex, endIndex);

        //only attempt to set active product on page if one previously selected
        if (productName.length > 0 && page == 'discoverHome')
        {
            changeDiscBox(productName, false);
        }
        else if (productName.length > 0 && page == 'other')
        {
            displayProductInfo(productName, false);
        }
    } 
    catch (e)
    {
        alert(e.lineNumber + ' : ' + e.message);
    }
}//end handleGetNBProductResponse function