function pageLoaded() {
//add a onclick event for any a that have target=_blank in a certain div   
checkTarget('sideMenuHolder');
checkTarget('topMenuHolder');
//
if (document.location.href.toLowerCase().indexOf('careers.aspx') != -1)     
    loadFlash();

}

function pageLoadedSide() {
    if (document.location.href.toLowerCase().indexOf('parts') != -1)
        loadVEMap(true, new Array('parts'));
    if (document.location.href.toLowerCase().indexOf('find') != -1)       
        loadVEMap(false);    
    if (document.location.href.toLowerCase().indexOf('locator.aspx') != -1)       
        loadVEMap(true, new Array('industrial', 'elite', 'wholesale'));

    debugDiv = document.getElementById('debugDiv');
}

function searchClick() {
    var newZip = document.getElementById('newZip').value
    var newZipLen = newZip.length;
    if (newZipLen > 0 && newZipLen <= 5) {
        document._zip = document.getElementById('newZip').value;
        var radSel = document.getElementById('usaRadius')
        document._radius = radSel[radSel.selectedIndex].value;
    }
    
    
    loadVEMap(true, new Array('industrial', 'elite', 'wholesale'));
}

function changeView(refObj) {
    //alert('changed view');
    refObj.focus = false;
    refObj.selected = false;
    document.getElementById('newZip').focus();
    //document.getElementById('newZip').blur();
    
    document.getElementById('internationalSearchTable').className = 'tab_unselected';
    document.getElementById('usSearch').style.display = 'none';
    
}

function tabClick(refObj) {
    clearTabs('searchTabs');
    
    refObj.className = 'selectedTabA';
    //debug(refObj.getElementsByTagName('span').length);
    refObj.getElementsByTagName('span')[0].className = 'selectedTabS';
    
    var us = document.getElementById('usSearch');
    var international = document.getElementById('internationalSearch');
    
    if (refObj.id == 'usa') {
        us.style.display = 'block';
        international.style.display = 'none';
        document.getElementById('newZip').focus();
    }
    else {
        us.style.display = 'none';
        international.style.display = 'block';
        document.getElementById('internationalRadius').focus();
    }
        
    
}

function clearTabs(divName) {
    var allTabs = document.getElementById(divName).getElementsByTagName('li');
    
    for (var i in allTabs) {
        if (allTabs[i].children) {
            allTabs[i].children[0].className = '';
            allTabs[i].children[0].children[0].className = '';
        }
    }
}

/**************************
///highlights the active sub-menu
******************************/
function highlightActiveSlide(cName) {
    cObj = document.getElementById(cName);
    allA = cObj.getElementsByTagName('a');
    for (var i=0; i<allA.length; i++) {
        var an = allA[i];
        //highlight the left link of the slide we are on
        //there are multiple links on the page with the same page name, so see if it has sideMenu in the id
        //then make sure there is no '?' in the href because that means it is a heading.
        //this is all 'hackish' because it can change if the .net SS id's change, or the structure changes, but it is quick
        if (getPageName(an.href) == pageName && an.id.indexOf('sideMenu') != -1 && an.href.indexOf('?') == -1) {
            allA[i].className = 'selected_slide';
         }
            
    }
 }

function getPageName(href) {
    var pageToken = '.aspx';
    var segments = href.split('/');
    var page = segments[segments.length -1];
    page = page.substring(0, page.indexOf(pageToken) + pageToken.length);
    return page;
}

//props to http://simonwillison.net/2004/May/26/addLoadEvent/ for this function
//This adds a function to the onload from anywhere
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
        
        
        
