var defText = [2];
defText[0] = "Enter Item Number or Keyword";
defText[1] = "Description";
defText[2] = "0";
var tabDivId = [5];
var tabDivzIndex = [5];
tabDivId[0] = "hmetab";
tabDivId[1] = "prdtab";
tabDivId[2] = "rprtab";
tabDivId[3] = "fldtab";
tabDivId[4] = "engtab";
tabDivzIndex[0] = 97;
tabDivzIndex[1] = 96;
tabDivzIndex[2] = 95;
tabDivzIndex[3] = 94;
tabDivzIndex[4] = 93;
var showTimeoutId = 0;
var hideTimeoutId = 0;
var evt;
var fcall;
var recCnt;
var accCount = 0;
var is_ie6 = document.all && 
             (navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1);
var e = new Object();

function ie6iframe (divid,state) {
   var thediv = document.getElementById(divid);
   var sizestyle;
   if (divid.indexOf("family") == 0) {
      sizestyle = "WIDTH: 220px; HEIGHT: 160px; ";
   }
   else if (divid.indexOf("tablines") != -1) {
      sizestyle = "WIDTH: 200px; HEIGHT: 180px; ";
   }
   else {
      sizestyle = "WIDTH: 100%; HEIGHT: 100%; ";
   }
   if (thediv.innerHTML.indexOf("<IFRAME") == -1) {
      var html = 
          "<IFRAME STYLE=\"DISPLAY: block; Z-INDEX: -1; FILTER: mask(); " +
          "POSITION: absolute; TOP: -1px; LEFT: -1px; " + sizestyle +
          "BACKGROUND-COLOR: #ffffff\"></IFRAME>";
      thediv.innerHTML += html;
   }
}
function displayDflt (obj, idx) {
   if (obj.value == "") {
      obj.value = defText[idx];
   }
}
function clearDflt (obj, idx) {
   if (obj.value == defText[idx]) {
      obj.value = "";
   }
}
function displayAll (theForm) {
   displayDflt(theForm.searchbox,0);
}
function clearAll (theForm) {
   clearDflt(theForm.searchbox,0);
}
function toggleDiv (divid) {
   var thestyle;
   if (document.getElementById) { 
      thestyle = document.getElementById(divid).style;
      thestyle.display = (thestyle.display == "block") ? "none" : "block";   

   }
}
function hideAllDivisions () {
   var divname;
   var i;
   for (i = 1; i < 5; i++) {
      divname = tabDivId[i] + 'lines';
      if (document.getElementById(divname)) {
         document.getElementById(divname).style.display = 'none';
      }
   }
}
function hideAllAlpha () {
   var divname;
   var i;
   for (i = 'a'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
       divname = String.fromCharCode(i) + "index";
       if (document.getElementById(divname)) {
          document.getElementById(divname).style.display = 'none';
       }
   }
}

function hideAllBrands () {
   var divname;
   var i;
   for (i = 'a'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
       divname = String.fromCharCode(i) + "index2";
       if (document.getElementById(divname)) {
          document.getElementById(divname).style.display = 'none';		 
       }
   }
}

function hideAllFamilies () {
   var divname;
   var i;
   for (i = 1; i < 50; i++) {
      divname = 'family' + i;
      if (document.getElementById(divname)) {
         document.getElementById(divname).style.display = 'none';
      } else {
         break;
      }
   }
   for (i = 1; i < 50; i++) {
      divname = 'rfamily' + i;
      if (document.getElementById(divname)) {
         document.getElementById(divname).style.display = 'none';
      } else {
         break;
      }
   }
}   
function changeDiv (divid,state) {  
   
   hideAllDivisions();
   hideAllAlpha();
   hideAllBrands();
   hideAllFamilies();
   if (document.getElementById && document.getElementById(divid)) {
      if (is_ie6) {
         ie6iframe(divid,state);
      }
      var d = document.getElementById(divid);      
      d.style.display = state;      
   }
   if (state == 'none') {
      hideTimeoutId = 0;
   } else {
      showTimeoutId = 0;
   }
}
function showDivDelay (divid) { 
   fcall = "changeDiv('" + divid + "','block')";
  
   if (showTimeoutId !== 0) {
     clearTimeout(showTimeoutId);
   }
   if (hideTimeoutId !== 0) {
     clearTimeout(hideTimeoutId);
   }
   showTimeoutId = setTimeout(fcall,300);
   /*document.getElementById(divid).style.visibility = 'visible';
   document.getElementById(divid).style.display = 'block';*/
}
function hideDivDelay (divid) {
   fcall = "changeDiv('" + divid + "','none')";
   if (showTimeoutId !== 0) {
     clearTimeout(showTimeoutId);
   }
   if (hideTimeoutId !== 0) {
     clearTimeout(hideTimeoutId);
   }
   hideTimeoutId = setTimeout(fcall,300);
   /*document.getElementById(divid).style.visibility = 'hidden';
   document.getElementById(divid).style.display = 'none';*/
}
function toggleDivNP (divid,evt) {
   if (!evt) { evt = window.event; }
   toggleDiv(divid);
   evt.cancelBubble = true;
   if (evt.stopPropagation) { evt.stopPropagation(); }
}
function divTabToFront (divid) {
   var i;
   if (document.getElementById) {
      // Set all tabs back to default z-index
      for (i = 0; i < 5; i++) {
         document.getElementById(tabDivId[i]).style.zIndex = tabDivzIndex[i];
      }
      // Bring selected div to front
      document.getElementById(divid).style.zIndex = 98;
   }
}
function alphaImageOn (divid) {
   if (document.getElementById) {
      /*if (divid == "abut") {
         document.getElementById(divid).style.backgroundImage="url('/images/template/tab_index_a_white.jpg')";
      } 
      else if (divid == "zbut") {
         document.getElementById(divid).style.backgroundImage="url('/images/template/tab_index_z_white.jpg')";
      }
      else*/ {    
         document.getElementById(divid).style.backgroundImage="url('/images/template/alpha_index_blue_blue2.jpg')";
      }
   }
}
function alphaImageOff (divid) {
   if (document.getElementById) {
      /*if (divid == "abut") {
         document.getElementById(divid).style.backgroundImage="url('/images/template/tab_index_a.jpg')";
      } 
      else if (divid == "zbut") {
         document.getElementById(divid).style.backgroundImage="url('/images/template/tab_index_z.jpg')";
      }
      else*/ {  
         document.getElementById(divid).style.backgroundImage="url('/images/template/alpha_index_white_blue.jpg')";
      }
   }
}
function moveToCursor (evt,divid) {
   if (!evt) { evt = window.event; }
   if (document.getElementById) {
      if (evt.pageX || evt.pageY) {
         document.getElementById(divid).style.left = evt.pageX + 2;
         document.getElementById(divid).style.top = evt.pageY - 2;
      }
      else if (evt.clientX || evt.clientY) {
         document.getElementById(divid).style.left = evt.clientX +
                                                    (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
         document.getElementById(divid).style.top = evt.clientY + 
                                                    (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
      }
   }
}
function moveToCursorY (evt,divid) {
   if (!evt) { evt = window.event; }
   if (document.getElementById) {
      if (evt.pageY) {
            (document.getElementById(divid).style.top = evt.pageY - 8);
      } else if (evt.clientY) {
         (document.getElementById(divid).style.top = evt.clientY + 
            (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) - 8);
      }
   }
}

function setBackground (divid) {
   if (document.getElementById) {
      document.getElementById(divid).style.backgroundColor="#E8E8E8";
   } 
}
function clearBackground (divid) {
   if (document.getElementById) {
      document.getElementById(divid).style.backgroundColor="#FFFFFF";
   } 
}
function lessSeriesText (divid) {
   if (document.getElementById) {
      document.getElementById(divid + '_parent').style.zIndex = 1;
      document.getElementById(divid).className = "seriestxt serless";
      document.getElementById(divid + '_mlnk').style.display='block';
      document.getElementById(divid + '_llnk').style.display='none';
   }
}
function hideAllSeriesText () {
   var i;
   var divid;
   for (i = 1; i <= recCnt; i++) {
      divid = 'seriestext' + i;
      if (document.getElementById(divid)) {
         lessSeriesText(divid);
      }
   }
}
function moreSeriesText (divid) {
   hideAllSeriesText();
   if (document.getElementById) {
      document.getElementById(divid + '_parent').style.zIndex = 2;
      document.getElementById(divid).className = "seriestxt sermore";
      document.getElementById(divid + '_mlnk').style.display='none';
      document.getElementById(divid + '_llnk').style.display='block';
   }
}

// Function gup taken from http://www.netlobo.com/url_query_string_javascript.html
function gup( name ){  
   name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
   var regexS = "[\\?&]"+name+"=([^&#]*)";
   var regex = new RegExp( regexS );  
   var results = regex.exec( window.location.href );
   if( results == null )    
      return "";
   else    
      return results[1];
}

function addToCart (qty,theform,partnum) {
   if (isNaN(parseInt(qty)) || parseInt(qty) < 1) {
      alert("Please enter a positive number before clicking add to cart");
      return false;
   }
   theform.pnum.value = partnum;
   theform.addqty.value = qty;  
   // Insure we redirect to same content position in browse window
   //alert(theform.redirURL.value + " " + theform.redirURL.value.indexOf("scrollx"));
   if (theform.redirURL.value.indexOf("scrollx") == -1 && theform.redirURL.value.indexOf("scrolly") == -1) {
      if (theform.redirURL.value.indexOf("?") == -1) {
         theform.redirURL.value = theform.redirURL.value + "?scrollx=" + document.body.scrollLeft + "&scrolly=" + document.body.scrollTop;
      } else {
         theform.redirURL.value = theform.redirURL.value + "&scrollx=" + document.body.scrollLeft + "&scrolly=" + document.body.scrollTop;
      }
   }
   if (theform.tabid && theform.redirURL.value.indexOf("tabid") == -1) theform.redirURL.value = theform.redirURL.value + "&tabid=" + theform.tabid.value;   
   return true;
}   
function resetScrollPosition() {
   var hidx, hidy;
   hidx = gup("scrollx");
   hidy = gup("scrolly");
   if (hidx != '' && hidy != '') {
      window.scrollTo(hidx, hidy);
   }
}

var tabDtlId = [10];
tabDtlId[0] = "ovr";
tabDtlId[1] = "spc";
tabDtlId[2] = "doc";
tabDtlId[3] = "acc";
tabDtlId[4] = "rep";
tabDtlId[5] = "war";
tabDtlId[6] = "tar";
tabDtlId[7] = "opt";
tabDtlId[8] = "lin";
tabDtlId[9] = "sub";
function deactivateAll () {
   var i;
   for (i = 0; i < 10; i++) {
      if (document.getElementById(tabDtlId[i] + "tab") && document.getElementById(tabDtlId[i] + "div")) {
         document.getElementById(tabDtlId[i] + "tab").className = "tab dtl small bold";
         document.getElementById(tabDtlId[i] + "div").style.display = "none";
      }
   }
}   
function makeActive (tabid) {
   if (document.getElementById) {
      deactivateAll();
      document.getElementById(tabid + "tab").className = "tab dtlactive small bold";
      document.getElementById(tabid + "div").style.display = "block";
      document.forms["itemdtlform"].tabid.value = tabid;
   }
}

function selectAccessory (qty, checked) {
   if (checked) {
      accCount = (+accCount) + (+qty);
   } else {
      accCount = accCount - qty;
   } 
}
function addAccessories (theform,partnum) {
   if (accCount <= 0) {
      alert('Please select one or more accessories before adding to cart.');
      return false;
   } else {
      return addToCart(accCount,theform,partnum);
   }
}
function addSubstitute (theform,partnum) {
   if (accCount <= 0) {
      alert('Please select a substitute before adding to cart.');
      return false;
   } else {
      return addToCart(accCount,theform,partnum);
   }
}
function changeCssClass(objDivID,divID,rowID) {
   if (document.getElementById(objDivID).className=='descr1')
   {
                
      document.getElementById(objDivID).className = 'descr2';
      document.getElementById(divID).className = 'info2';
      document.getElementById(rowID).innerText = "[Less ...] ";
      document.getElementById(rowID).textContent = "[Less ...] ";
   }
   else
   {
      document.getElementById(objDivID).className = 'descr1';
      document.getElementById(divID).className = 'info1';
      document.getElementById(rowID).innerText ="[More ...] "
      document.getElementById(rowID).textContent = "[More ...] ";
   }
}


function mouseX(evt) {
   if (evt.pageX) 
      return evt.pageX;
   else 
      if (evt.clientX)
         return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
      else return null;
}

function mouseY(evt) {
   if (evt.pageY) return evt.pageY;
   else 
      if (evt.clientY)
         return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
      else return null;
}

function getYOffset() {
   if (window.pageYOffset)
      return window.pageYOffset;
   if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
   if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
   return 0;
}

function getWinHeight() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement && (document.documentElement.clientHeight ) ) {   
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {    
    myHeight = document.body.clientHeight;    
  }
    return myHeight;
    return 0;
}

function getwinWidth() {
   var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth ) ) {
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    myWidth = document.body.clientWidth;
  }
    return myWidth;
    return 0;   
}

function moveDivtoCursor ( hgt,divid,evt) {
   var thestyle = document.getElementById(divid).style; 
   var ypos = mouseY(evt) ;  
   var yoff = getYOffset();
   var height = (hgt);
   var winheight = getWinHeight(); 
   var winwidth = getwinWidth();     
   
   var xpos = (winwidth/2)-(560/2);
   var ypos = ((winheight/2) + yoff) - (height/2);
    
   if (ypos < yoff ) 
      ypos = yoff;
   else
      if (winheight < height)
         ypos = mouseY(evt) - 15; 
   
   if (ypos <= 0)
          ypos = 1;
       
   thestyle.display = "block";
   thestyle.top = ypos + "px";
   thestyle.left = xpos + "px";    
   return true;   
}

function showNeedSooner (hgt,divid,e) {
   /*if (document.getElementById("shipmsgcust"))
      document.getElementById("shipmsgcust").style.display = "none";
   if (document.getElementById("shipmsgemergency"))
      document.getElementById("shipmsgemergency").style.display = "none";*/   
   if (window.event)
      return moveDivtoCursor (hgt, divid, window.event);
   else
      return moveDivtoCursor (hgt, divid, e);
}

function changeClass(objDivID,divID,rowID) {
   if (document.getElementById(objDivID).className=='manuf1')
   {
                
      document.getElementById(objDivID).className = 'manuf2';
      document.getElementById(divID).className = 'less';
      document.getElementById(rowID).innerText = "[Less ...] ";
      document.getElementById(rowID).textContent = "[Less ...] ";          
      
   }
   else
   {
      document.getElementById(objDivID).className = 'manuf1';
      document.getElementById(divID).className = 'more';
      document.getElementById(rowID).innerText ="[More ...] "
      document.getElementById(rowID).textContent = "[More ...] ";
   }
}

function changeInfo(objDivID,divID,linkID,rowID,link) {   
   if (document.getElementById(objDivID).className=='moreInfo1')
   {
                
      document.getElementById(objDivID).className = 'moreInfo2';
      document.getElementById(divID).className = 'linfo';
	  document.getElementById(linkID).className = 'linkinfo';
      document.getElementById(rowID).innerText = "[Less ...] ";
      document.getElementById(rowID).textContent = "[Less ...] ";
      document.getElementById(link).innerText = "[Read More ...] ";
      document.getElementById(link).textContent = "[Read More ...] ";     
            
   }
   else
   {
      document.getElementById(objDivID).className = 'moreInfo1';
      document.getElementById(divID).className = 'minfo';
	  document.getElementById(linkID).className = 'linkinfo';
      document.getElementById(rowID).innerText ="[More ...] "
      document.getElementById(rowID).textContent = "[More ...]";
      document.getElementById(link).innerText = "";
      document.getElementById(link).textContent = "";       
   }    
 }   

 function updateTab (atabid,natabid) {
   if (document.getElementById(atabid).className=='atab' || document.getElementById(atabid).className=='atab bold')     
   {
      document.getElementById(atabid).className = 'atab bold';	  
      document.getElementById(natabid).className = 'natab';	      
   }  	  
   else
   {
      document.getElementById(atabid).className = 'natab bold';
	  document.getElementById(natabid).className = 'atab'; 
   }
}

function updateAlpha (activeid,nactiveid) {
   if (document.getElementById(activeid).className=='active')     
   {
      document.getElementById(activeid).className = 'active';	  
      document.getElementById(nactiveid).className = 'nonactive';	      
   }  	  
   else
   {
      document.getElementById(activeid).className = 'active';
	  document.getElementById(nactiveid).className = 'nonactive'; 
   }
}

function updateMenu (activeid,nactiveid) {   
   if (document.getElementById(activeid).className=='active')     
   {
      document.getElementById(activeid).className = 'active';	  
      document.getElementById(nactiveid).className = 'nonactive';	      
   }  	  
   else
   {
      document.getElementById(activeid).className = 'active';
	  document.getElementById(nactiveid).className = 'nonactive'; 
   }
}

function brandImageOn (divid) {
   if (document.getElementById) {
      {    
         document.getElementById(divid).style.backgroundImage="url('/images/template/alpha_index_yellow_gold3.jpg')";
      }
   }
}

function brandImageOff (divid) {
   if (document.getElementById) {
      {  
         document.getElementById(divid).style.backgroundImage="url('/images/template/alpha_index_white_gold3.jpg')";
      }
   }
}


