// JavaScript Document

var Core = {};

// function is changed for getting faster performance especaialy in ie
Core.getElementsByClass = function(theClass, tag)
{
  var elementArray = [];
      if (document.getElementsByTagName(tag)) {
        elementArray = document.getElementsByTagName(tag);
    }
    else {
        elementArray = document.all;        
    }


  var matchedArray = [];
  var pattern = new RegExp("(^| )" + theClass + "( |$)");

  for (var i = 0; i < elementArray.length; i++)
  {
    if (pattern.test(elementArray[i].className))
    {
      matchedArray[matchedArray.length] = elementArray[i];
    }
  }

  return matchedArray;
};

function showRo(id) {
    resetRo();
    document.getElementById('ro' + id + 'L').style.background = '#d6dfe9 url(/images/arrow_left.gif) 11px 13px no-repeat';
    document.getElementById('ro' + id).style.display = 'block';
}

function resetRo() {
    var list = Core.getElementsByClass('mainLink', 'a');
    for (var i = 0; i < list.length; i++) {
    list[i].style.background = 'url(/images/arrow_left.gif) 11px 13px no-repeat';
    }    
    var list = Core.getElementsByClass('mainImgInfo', 'div');
    for (var i = 0; i < list.length; i++) {
    list[i].style.display = 'none';
    }
}

function showSearch(id) {
    resetSearch();
    document.getElementById(id).style.background = '#6c6c6c';
    document.getElementById(id+ 'L').style.background = 'url(/images/search_arrow_top.gif) no-repeat right top';
    document.getElementById(id+ 'L').style.color = '#fff';
    if (id == 'prod') {
        document.getElementById('searchSelect').style.display='none';
        document.getElementById('headerSearchField').value='Product name';
        document.getElementById('searchtype').value='Search Products';
    } else if (id == 'dist') {
        document.getElementById('searchSelect').style.display='inline';
        document.getElementById('headerSearchField').value='Zip code';
        document.getElementById('searchtype').value='Search Distributors';
    } else if (id == 'tech') {
        document.getElementById('searchSelect').style.display='none';
        document.getElementById('headerSearchField').value='Product name';
        document.getElementById('searchtype').value='Search Tech Data';
    }
    document.getElementById('prodF').style.display = 'block';
}

function resetSearch() {
    var list = Core.getElementsByClass('searchLink', 'span');
    for (var i = 0; i < list.length; i++) {
    list[i].style.background = 'none';
    }    
    var list = Core.getElementsByClass('searchLinkL', 'a');
    for (var i = 0; i < list.length; i++) {
    list[i].style.background = 'url(/images/search_arrow_bot.gif) no-repeat right top';
    list[i].style.color = '#6c6c6c';
    }    
    var list = Core.getElementsByClass('searchForm', 'form');
    for (var i = 0; i < list.length; i++) {
    list[i].style.background = '#fff';
    }
}

function showOption(id, id1) {
    if (document.getElementById('leftNavUl' + id).style.display != 'block') {
    document.getElementById('leftNavUl' + id).style.display = 'block';    
    document.getElementById('options' + id).style.background = '#35485f url(/images/option_bg_minus.gif) top right no-repeat';
    document.getElementById('options' + id).style.color = '#ff9c00';
    } else {
        document.getElementById('leftNavUl' + id).style.display = 'none';    
        document.getElementById('options' + id).style.background = '#6988ac url(/images/option_bg_plus.gif) top right no-repeat';
        document.getElementById('options' + id).style.color = '#fff';
        
    }
}

function changeDetail(id) {
    resetDetail();
    document.getElementById(id).style.background = '#fff';
    document.getElementById(id).style.borderRight = '1px solid #869aad';
    document.getElementById(id).style.borderTop = '1px solid #869aad';
    
    document.getElementById(id + 'L').style.borderLeft = '1px solid #869aad';
    document.getElementById(id + 'L').style.borderTop = '1px solid #869aad';
    document.getElementById(id + 'L').style.borderBottom = '1px solid #fff';
    
    document.getElementById(id + 'B').style.display = 'block';
}

function resetDetail() {
    var list = Core.getElementsByClass('tab', 'span');
    for (var i = 0; i < list.length; i++) {
    list[i].style.background = 'none';
    list[i].style.borderRight = '1px solid #c8d1dd';
    list[i].style.borderTop = '1px solid #c8d1dd';
    }    
    
    var list = Core.getElementsByClass('tabL', 'a');
    for (var i = 0; i < list.length; i++) {
    list[i].style.borderLeft = 'none';
    list[i].style.borderTop = 'none';
    list[i].style.borderBottom = 'none';
    }    
    
    var list = Core.getElementsByClass('prodDetails', 'div');
    for (var i = 0; i < list.length; i++) {
    list[i].style.display = 'none';
    }    
}

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("leftNavUl1");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
  navRoot = document.getElementById("leftNavUl2");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;
