// Mouseover function for menu images

if (document.images)
{    
	
		menson = new Image;
		menson.src = "/images/navigation/mens-on.gif";
		mensoff = new Image;
		mensoff.src = "/images/navigation/mens.gif";
		menspress = new Image;
		menspress.src = "/images/navigation/mens-on.gif";
		
		womenson = new Image;
		womenson.src = "/images/navigation/womens-on.gif";
		womensoff = new Image;
		womensoff.src = "/images/navigation/womens.gif";
		womenspress = new Image;
		womenspress.src = "/images/navigation/womens-on.gif";
		
		technologieson = new Image;
		technologieson.src = "/images/navigation/technology-on.gif";
		technologiesoff = new Image;
		technologiesoff.src = "/images/navigation/technology.gif";
		technologiespress = new Image;
		technologiespress.src = "/images/navigation/technology-on.gif";
		
		wheretobuyon = new Image;
		wheretobuyon.src = "/images/navigation/wheretobuy-on.gif";
		wheretobuyoff = new Image;
		wheretobuyoff.src = "/images/navigation/wheretobuy.gif";
		wheretobuypress = new Image;
		wheretobuypress.src = "/images/navigation/wheretobuy-on.gif";
		
		athletes_eventson = new Image;
		athletes_eventson.src = "/images/navigation/athletes-events-on.gif";
		athletes_eventsoff = new Image;
		athletes_eventsoff.src = "/images/navigation/athletes-events.gif";
		athletes_eventspress = new Image;
		athletes_eventspress.src = "/images/navigation/athletes-events-on.gif";
		
		abouton = new Image;
		abouton.src = "/images/navigation/about-on.gif";
		aboutoff = new Image;
		aboutoff.src = "/images/navigation/about.gif";
		aboutpress = new Image;
		aboutpress.src = "/images/navigation/about-on.gif";
		
		blogon = new Image;
		blogon.src = "/images/navigation/blog-on.gif";
		blogoff = new Image;
		blogoff.src = "/images/navigation/blog.gif";
		blogpress = new Image;
		blogpress.src = "/images/navigation/blog-on.gif";
		
 }
		
		
		
var thisPage = "";

function setCurrent(page)
{
    img_press(page);
	thisPage = page;
	
}

function img_act(imgName)
{
    if (document.images)
    {
        imgOn = eval(imgName + "on.src");
		imgPress = eval(imgName + "press.src");
		imgSrc = document [imgName].src;
		if (imgSrc != imgPress && imgName != thisPage){
			document [imgName].src = imgOn;
		}
        
    }
}

function img_inact(imgName)
{
    if (document.images && imgName != thisPage)
    {
        imgOff = eval(imgName + "off.src");
        document [imgName].src = imgOff;
    }
}

function img_press(imgName)
{
    if (document.images && imgName != thisPage)
    {
        imgPress = eval(imgName + "press.src");
        document [imgName].src = imgPress;
    }
}

function leftTrim(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    return sString;
}

function rightTrim(sString) 
{
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function trimAll(sString) 
{
    while (sString.substring(0,1) == ' ')
    {
        sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
        sString = sString.substring(0,sString.length-1);
    }
    return sString;
}

function showHideCheckBoxes(formCheckBox)
{
    compHref = getObj("compareHref");
    compSpan = getObj("compareSpan");
    chosenProductIdsHidden = document.getElementById("ctl00_MainContent_ProductChooser1_chosenProductIdsHidden");
//    chosenProductsIdsTextBox = document.getElementById("ctl00_MainContent_ProductChooser1_chosenProductIdsTextBox");
    var hiddenStr;
    frm = document.getElementById("aspnetForm");
  
    if(formCheckBox.checked)
    {
        id = 0;
        if(chosenIds[0] != null)
        {
            id = getNextUnchosen();
        }
        
        chosenIds[id] = formCheckBox.value;
    }
    else
    {
         for(i = 0;i < 4;i++)
         {
            if(chosenIds[i] == formCheckBox.value)
            {
                chosenIds[i] = 0;
            }
         }
    }
    
    checkedCheckBoxCount = getCheckedCount();
    
    if(checkedCheckBoxCount > 1)
    {
 //     compHref.disabled = '';
      compHref.style.display = "inline";
      compSpan.style.display = "none";
      compHref.href = '#';
      
    }
    else
    {
 //      compHref.disabled = 'disabled';
       compHref.style.display = "none";
       compSpan.style.display = "inline";
       compHref.href = document.location.toString();
    }
    
    if(checkedCheckBoxCount == 4)
    {
        for(i = 0; i < frm.elements.length; i++)
        {
            if(frm.elements[i].type == "checkbox")
            {
                if(!frm.elements[i].checked)
                {
                    
                    frm.elements[i].disabled = 'disabled';
                }
            }
        }
    }
    else
    {
        for(i = 0; i < frm.elements.length; i++)
        {
            if(frm.elements[i].type == "checkbox")
            {
                frm.elements[i].style.display = 'inline';
                frm.elements[i].disabled = ''; 
            }
        }
    }
    
    hiddenStr = chosenIds.join(",");
    
    chosenProductIdsHidden.value = hiddenStr;
    //chosenProductsIdsTextBox.value = hiddenStr;
}

function URLDecode(psEncodeString) 
{
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " ")); 
}

function swapInnerHTML(str, objName)
{
    var divObj = getObj(objName);
    divObj.innerHTML = str;
}

function getObj(id)
{
    if(document.layers)	   //NN4+
    {
       if (document.layers[id])
          return document.layers[id];
       else
          return null;  
    }
    else if (document.getElementById)	  //gecko(NN6) + IE 5+
    {
        if (document.getElementById(id)) 
            return document.getElementById(id);
        else
            return null;
    }
    else if (document.all)	// IE 4
    {
        if (document.all[id].style) 
            return document.all[id].style;
        else
            return null;
    }
}

function toggleDivVisibility(divId)
{
    var divObj = getObj(divId);
    var isVisible = (divObj.style.visibility == "visible") ? true : false;
    if (isVisible) divObj.style.visibility = "hidden";
    else divObj.style.visibility = "visible";
}

// larger view for products
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if (document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if (document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if (document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}

function getMedOriginal()
{
    var obj = document.getElementById("originalMediumImage");
    return obj.value;
}

function swapImage(parentId,imageSource)
{
    var image = document.getElementById(parentId);
    image.src =  imageSource;
}
function processAthletesUnderlining(id)
{
   // link id's are link1, link2, link3, link4
    var linkObj = getObj("link1");
    if (linkObj != null)
    { 
        linkObj.style.textDecoration = "underline";
    }
    
    var linkObj = getObj("link2");
    if (linkObj != null) linkObj.style.textDecoration = "underline";
    var linkObj = getObj("link3");
    if (linkObj != null) linkObj.style.textDecoration = "underline";
    var linkObj = getObj("link4");
    if (linkObj != null) linkObj.style.textDecoration = "underline";
    var linkObj = getObj("link5");
    if (linkObj != null) linkObj.style.textDecoration = "underline";
    var linkObj = getObj("link6");
    if (linkObj != null) linkObj.style.textDecoration = "underline";
    var linkObj = getObj("link7");
    if (linkObj != null) linkObj.style.textDecoration = "underline";
    var linkObj = getObj("link8");
    if (linkObj != null) linkObj.style.textDecoration = "underline";
    linkObj = getObj(id);
    if (linkObj != null) linkObj.style.textDecoration = "none";
}

// resizes Iframe according to content
function resizeMe(obj){ 
    docHeight = mainContent.document.body.scrollHeight;
    docWidth = mainContent.document.body.scrollWidth;
    obj.style.height = docHeight + 'px';
    obj.style.width = docWidth + 'px';
 } 
 
 function FireKeyDownEvent(myevent, buttonToClick)
{
   if (myevent.keyCode == 13)
   {
      document.getElementById(buttonToClick).click();
      myevent.returnValue = false;
   }
}

function clearDefault(el)
{
   if (el.value == el.defaultValue)
   {
      el.value = "";
   }
}
function resetDefault(el)
{
   if (el.value == "")
   {
      el.value = el.defaultValue;
   }
}
