
function loadImages(e, newGT)
{
    imageArray = new Array();
    var gearType = '';
    if (newGT) 
    {
        gearType = newGT;
    }
    else 
    {
        gearType = $('mainGearType').value;
    }
    
    if (document.images) 
    {
        //preload images for pop-ups
        if (!imageArray['SPURPA']) 
        {
            if (gearType == "SPUR") 
            {
                imageArray['SPURHD'] = new Image();
                imageArray['SPURHD'].src = "/images/SPURHD.gif";
                imageArray['SPURFACE'] = new Image();
                imageArray['SPURFACE'].src = "/images/SPURFACE.gif";
                imageArray['SPURBORE'] = new Image();
                imageArray['SPURBORE'].src = "/images/SPURBORE.gif";
                imageArray['SPURHP'] = new Image();
                imageArray['SPURHP'].src = "/images/SPURHP.gif";
                imageArray['SPUROD'] = new Image();
                imageArray['SPUROD'].src = "/images/SPUROD.gif";
                imageArray['SPURPD'] = new Image();
                imageArray['SPURPD'].src = "/images/SPURPD.gif";
                imageArray['SPUROAL'] = new Image();
                imageArray['SPUROAL'].src = "/images/SPUROAL.gif";
                imageArray['SPURSTYLE'] = new Image();
                imageArray['SPURSTYLE'].src = "/images/SPURSTYLE.gif";
                imageArray['SPURPA'] = new Image();
                imageArray['SPURPA'].src = "/images/SPURPA.gif";
                imageArray['SPURCAD'] = new Image();
                imageArray['SPURCAD'].src = "/images/SPURCAD.gif";
                imageArray['SPURQUOTE'] = new Image();
                imageArray['SPURQUOTE'].src = "/images/SPURQUOTE.gif";
                imageArray['SPURCUSTOMIZE'] = new Image();
                imageArray['SPURCUSTOMIZE'].src = "/images/customScreen.gif";
                imageArray['SPURBACKLASH'] = new Image();
                imageArray['SPURBACKLASH'].src = "/images/SPURBACKLASH.gif";
                imageArray['SPURCB'] = new Image();
                imageArray['SPURCB'].src = "/images/SPURCB.gif";
            }
        }
        
        if (!imageArray['HELICALHD']) 
        {
            if (gearType == "HELICAL") 
            {
                imageArray['HELICALHA'] = new Image();
                imageArray['HELICALHA'].src = "/images/HELICALHA.gif";
                imageArray['HELICALKWY'] = new Image();
                imageArray['HELICALKWY'].src = "/images/HELICALKWY.gif";
                imageArray['HELICALHAND'] = new Image();
                imageArray['HELICALHAND'].src = "/images/HELICALHAND.gif";
                imageArray['HELICALPA'] = new Image();
                imageArray['HELICALPA'].src = "/images/HELICALPA.gif";
                imageArray['HELICALOD'] = new Image();
                imageArray['HELICALOD'].src = "/images/HELICALOD.gif";
                imageArray['HELICALBORE'] = new Image();
                imageArray['HELICALBORE'].src = "/images/HELICALBORE.gif";
                imageArray['HELICALFACE'] = new Image();
                imageArray['HELICALFACE'].src = "/images/HELICALFACE.gif";
                imageArray['HELICALSTYLE'] = new Image();
                imageArray['HELICALSTYLE'].src = "/images/HELICALSTYLE.gif";
                imageArray['HELICALHD'] = new Image();
                imageArray['HELICALHD'].src = "/images/HELICALHD.gif";
                imageArray['HELICALHP'] = new Image();
                imageArray['HELICALHP'].src = "/images/HELICALHP.gif";
                imageArray['HELICALOAL'] = new Image();
                imageArray['HELICALOAL'].src = "/images/HELICALOAL.gif";
                imageArray['HELICALPD'] = new Image();
                imageArray['HELICALPD'].src = "/images/HELICALPD.gif";
                imageArray['HELICALCAD'] = new Image();
                imageArray['HELICALCAD'].src = "/images/HELICALCAD.gif";
                imageArray['HELICALQUOTE'] = new Image();
                imageArray['HELICALQUOTE'].src = "/images/HELICALQUOTE.gif";
                imageArray['HELICALCUSTOMIZE'] = new Image();
                imageArray['HELICALCUSTOMIZE'].src = "/images/customScreen.gif";
                imageArray['HELICALBACKLASH'] = new Image();
                imageArray['HELICALBACKLASH'].src = "/images/HELICALBACKLASH.gif";
                imageArray['HELICALCB'] = new Image();
                imageArray['HELICALCB'].src = "/images/HELICALCB.gif";
            }
        }
        
        if (!imageArray['BEVELHD']) 
        {
            if (gearType == "BEVEL/MITER") 
            {
                imageArray['BEVELMD'] = new Image();
                imageArray['BEVELMD'].src = "/images/BEVELMD.gif";
                imageArray['BEVELPA'] = new Image();
                imageArray['BEVELPA'].src = "/images/BEVELPA.gif";
                imageArray['BEVELOD'] = new Image();
                imageArray['BEVELOD'].src = "/images/BEVELOD.gif";
                imageArray['BEVELBORE'] = new Image();
                imageArray['BEVELBORE'].src = "/images/BEVELBORE.gif";
                imageArray['BEVELFACE'] = new Image();
                imageArray['BEVELFACE'].src = "/images/BEVELFACE.gif";
                imageArray['BEVELSTYLE'] = new Image();
                imageArray['BEVELSTYLE'].src = "/images/BEVELSTYLE.gif";
                imageArray['BEVELHD'] = new Image();
                imageArray['BEVELHD'].src = "/images/BEVELHD.gif";
                imageArray['BEVELHP'] = new Image();
                imageArray['BEVELHP'].src = "/images/BEVELHP.gif";
                imageArray['BEVELOAL'] = new Image();
                imageArray['BEVELOAL'].src = "/images/BEVELOAL.gif";
                imageArray['BEVELPD'] = new Image();
                imageArray['BEVELPD'].src = "/images/BEVELPD.gif";
                imageArray['BEVELQUOTE'] = new Image();
                imageArray['BEVELQUOTE'].src = "/images/BEVELQUOTE.gif";
                imageArray['BEVELCAD'] = new Image();
                imageArray['BEVELCAD'].src = "/images/BEVELCAD.gif";
            }
        }
        
        if (!imageArray['WORMGEARHD']) 
        {
            if (gearType == "WORM GEAR") 
            {
                imageArray['WORMGEARPD'] = new Image();
                imageArray['WORMGEARPD'].src = "/images/WORMGEARPD.gif";
                imageArray['WORMGEAROD'] = new Image();
                imageArray['WORMGEAROD'].src = "/images/WORMGEAROD.gif";
                imageArray['WORMGEARHD'] = new Image();
                imageArray['WORMGEARHD'].src = "/images/WORMGEARHD.gif";
                imageArray['WORMGEARSTARTS'] = new Image();
                imageArray['WORMGEARSTARTS'].src = "/images/WORMGEARSTARTS.gif";
                imageArray['WORMGEARLA'] = new Image();
                imageArray['WORMGEARLA'].src = "/images/WORMGEARLA.gif";
                imageArray['WORMGEARWORMLEAD'] = new Image();
                imageArray['WORMGEARWORMLEAD'].src = "/images/WORMGEARWORMLEAD.gif";
                imageArray['WORMGEARHAND'] = new Image();
                imageArray['WORMGEARHAND'].src = "/images/WORMGEARHAND.gif";
                imageArray['WORMGEARBORE'] = new Image();
                imageArray['WORMGEARBORE'].src = "/images/WORMGEARBORE.gif";
                imageArray['WORMGEARFACE'] = new Image();
                imageArray['WORMGEARFACE'].src = "/images/WORMGEARFACE.gif";
                imageArray['WORMGEARCD'] = new Image();
                imageArray['WORMGEARCD'].src = "/images/WORMGEARCD.gif";
                imageArray['WORMGEARHP'] = new Image();
                imageArray['WORMGEARHP'].src = "/images/WORMGEARHP.gif";
                imageArray['WORMGEAROAL'] = new Image();
                imageArray['WORMGEAROAL'].src = "/images/WORMGEAROAL.gif";
                imageArray['WORMGEARKWY'] = new Image();
                imageArray['WORMGEARKWY'].src = "/images/WORMGEARKWY.gif";
                imageArray['WORMGEARSTYLE'] = new Image();
                imageArray['WORMGEARSTYLE'].src = "/images/WORMGEARSTYLE.gif";
                imageArray['WORMGEARCAD'] = new Image();
                imageArray['WORMGEARCAD'].src = "/images/WORMGEARCAD.gif";
                imageArray['WORMGEARQUOTE'] = new Image();
                imageArray['WORMGEARQUOTE'].src = "/images/WORMGEARQUOTE.gif";
            }
        }
        
        if (!imageArray['WORMLEAD']) 
        {
            if (gearType == "WORM") 
            {
                imageArray['WORMLEAD'] = new Image();
                imageArray['WORMLEAD'].src = "/images/WORMLEAD.gif";
                imageArray['WORMSTARTS'] = new Image();
                imageArray['WORMSTARTS'].src = "/images/WORMSTARTS.gif";
                imageArray['WORMLA'] = new Image();
                imageArray['WORMLA'].src = "/images/WORMLA.gif";
                imageArray['WORMHAND'] = new Image();
                imageArray['WORMHAND'].src = "/images/WORMHAND.gif";
                imageArray['WORMKWY'] = new Image();
                imageArray['WORMKWY'].src = "/images/WORMKWY.gif";
                imageArray['WORMOAL'] = new Image();
                imageArray['WORMOAL'].src = "/images/WORMOAL.gif";
                imageArray['WORMHP'] = new Image();
                imageArray['WORMHP'].src = "/images/WORMHP.gif";
                imageArray['WORMHD'] = new Image();
                imageArray['WORMHD'].src = "/images/WORMHD.gif";
                imageArray['WORMSTYLE'] = new Image();
                imageArray['WORMSTYLE'].src = "/images/WORMSTYLE.gif";
                imageArray['WORMFACE'] = new Image();
                imageArray['WORMFACE'].src = "/images/WORMFACE.gif";
                imageArray['WORMBORE'] = new Image();
                imageArray['WORMBORE'].src = "/images/WORMBORE.gif";
                imageArray['WORMOD'] = new Image();
                imageArray['WORMOD'].src = "/images/WORMOD.gif";
                imageArray['WORMPD'] = new Image();
                imageArray['WORMPD'].src = "/images/WORMPD.gif";
                imageArray['WORMPA'] = new Image();
                imageArray['WORMPA'].src = "/images/WORMPA.gif";
                imageArray['WORMCAD'] = new Image();
                imageArray['WORMCAD'].src = "/images/WORMCAD.gif";
                imageArray['WORMQUOTE'] = new Image();
                imageArray['WORMQUOTE'].src = "/images/WORMQUOTE.gif";
            }
        }
        
        if (!imageArray['SPIRALMITERHAND']) 
        {
            if (gearType == "SPIRAL MITER") 
            {
                imageArray['SPIRALMITERHAND'] = new Image();
                imageArray['SPIRALMITERHAND'].src = "/images/SPIRALMITERHAND.gif";
                imageArray['SPIRALMITERQUOTE'] = new Image();
                imageArray['SPIRALMITERQUOTE'].src = "/images/SPIRALMITERQUOTE.gif";
                imageArray['SPIRALMITER3D'] = new Image();
                imageArray['SPIRALMITER3D'].src = "/images/SPIRALMITERQUOTE.gif";
            }
        }
        
        if (!imageArray['RACKCAD']) 
        {
            if (gearType == "RACK") 
            {
                imageArray['RACKCAD'] = new Image();
                imageArray['RACKCAD'].src = "/images/RACKCAD.gif";
                imageArray['RACKQUOTE'] = new Image();
                imageArray['RACKQUOTE'].src = "/images/RACKQUOTE.gif";
            }
        }
        
        if (!imageArray['INTERNALQUOTE']) 
        {
            if (gearType == "INTERNAL") 
            {
                // imageArray['INTERNALCAD'] = new Image();
                //imageArray['INTERNALCAD'].src = "/images/INTERNALCAD.gif";
                imageArray['INTERNALQUOTE'] = new Image();
                imageArray['INTERNALQUOTE'].src = "/images/INTERNALQUOTE.gif";
            }
        }
    }
    change3Dgear();
    $('instImg1').src = '/images/starBurstL.gif';
    $('instImg2').src = '/images/starBurstL.gif';
    $('instLink').innerHTML = 'Instructions';
    /*$('spur3Dicon').src = '/images/spur3Dicon.gif';
     $('spur2Dicon').src = '/images/spur2Dicon.gif';
     $('lockedImg').src = '/images/locked.gif';
     $('qMark1').src = '/images/qMark.gif';
     $('qMark2').src = '/images/qMark.gif';
     $('qMark3').src = '/images/qMark.gif';
     $('cadIframe').src = '/Tech_Tools/'+folder+'progress.php';*/
    //$('ieWarningImg').src = '/images/ieDownloadPrompt.jpg';
    //load the kwy and ss images
    $$('img.cgGearSpecImg').each(function(s)
    {
        var ssID = s.id;
        if (ssID.substr(0, 4) == 'cgss') 
        {
            if (ssID.substr(0, 5) == 'cgsss') 
            {
                $(ssID).src = '/images/ssSpace' + ssID.substr(ssID.length - 1) + '.gif';
            }
            else 
            {
                $(ssID).src = '/images/ss' + ssID.substr(ssID.length - 1) + '.gif';
            }
        }
        if (ssID.substr(0, 7) == 'cgkeyON') 
        {
            $(ssID).src = '/images/key' + ssID.substr(ssID.length - 1) + 'a.gif';
        }
        if (ssID.substr(0, 7) == 'cgkeyOF') 
        {
            $(ssID).src = '/images/key' + ssID.substr(ssID.length - 1) + '.gif';
        }
    })
    
    getPage('Tech_Tools/' + folder + '/cadFormats.php?showPage=false&filledCadFormats=' + filledCadFormats, 'getLink');
    getPage('Tech_Tools/' + folder + '/getBacklash.php?none=none', 'getBacklash');
}

function addListeners(e)
{

    formInfo = document.partSearch;
    var pitchType = $('mainPitchType');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(pitchType, 'focus', changeBackColor, false);
        addEvent(pitchType, 'blur', changeBackColor, false);
    }
    addEvent(pitchType, 'change', changeMenus, false);
    
    gearType = $('mainGearType');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(gearType, 'focus', changeBackColor, false);
        addEvent(gearType, 'blur', changeBackColor, false);
    }
    addEvent(gearType, 'change', change3Dgear, false);
    addEvent(gearType, 'focus', disablePaging, false);
    addEvent(gearType, 'blur', enablePaging, false);
    addEvent(gearType, 'change', changeMenus, false);
    
    var material = $('mainMaterial');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(material, 'focus', changeBackColor, false);
        addEvent(material, 'blur', changeBackColor, false);
    }
    addEvent(material, 'change', changeMenus, false);
    addEvent(material, 'change', change3Dgear, false);
    
    var pitch = $('mainPitch');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(pitch, 'focus', changeBackColor, false);
        addEvent(pitch, 'blur', changeBackColor, false);
    }
    addEvent(pitch, 'change', changeMenus, false);
    
    var teeth = $('mainTeeth');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(teeth, 'focus', changeBackColor, false);
        addEvent(teeth, 'blur', changeBackColor, false);
    }
    addEvent(teeth, 'change', changeMenus, false);
    
    var pa = $('mainPA');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(pa, 'focus', changeBackColor, false);
        addEvent(pa, 'blur', changeBackColor, false);
    }
    addEvent(pa, 'change', changeMenus, false);
    
    var hubStyle = $('mainHubStyle');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(hubStyle, 'focus', changeBackColor, false);
        addEvent(hubStyle, 'blur', changeBackColor, false);
    }
    addEvent(hubStyle, 'change', changeMenus, false);
    
    var hpTitle = $('hpTitle');
    addEvent(hpTitle, 'click', hideHP, false);
    
    var units = $('mainUnits');
    if (browserName != 'msie' && platform == 'windows') 
    {
        addEvent(units, 'focus', changeBackColor, false);
        addEvent(units, 'blur', changeBackColor, false);
    }
    addEvent(units, 'change', changeMenus, false);
    
    var pages = $('pages');
    addEvent(pages, 'mouseout', hideRange, false);
    
    var mainTable = $('mainTable');
    addEvent(mainTable, 'mouseover', hideRange, false);
    
    var blankCol = $('blankCol');
    addEvent(blankCol, 'mouseover', hideRange, false);
    
    var cadClose = $('cadClose');
    addEvent(cadClose, 'mousedown', closeCad, false);
    
    var twoDcell1Obj = $('twoDcell1');
    
    $2DcadFormats = $('t2Dformats');
    addEvent($2DcadFormats, 'change', changeVersion, false);
    
    $cadChoice2Dformats = $('cadChoice2Dformats')
    addEvent($cadChoice2Dformats, 'change', changeVersion, false);
    
    $3DcadFormats = $('t3Dformats');
    addEvent($3DcadFormats, 'change', changeVersion, false);
    
    $cadChoice3Dformats = $('cadChoice3Dformats')
    addEvent($cadChoice3Dformats, 'change', changeVersion, false);
    
    cadChoiceObj = $('cadChoice');
    closeCadChoiceObj = $('closeCadChoice');
    addEvent(closeCadChoiceObj, 'click', closeControl, false);
    cadChoicePartObj = $('cadChoicePart');
    cadChoiceMeterDivObj = $('cadChoiceMeterDiv');
    
    downloadProbObj = $('downloadProb');
    addEvent(downloadProbObj, 'click', showCustomVideo, false);
    ieMediaCloseObj = $('ieMediaClose');
    addEvent(ieMediaCloseObj, 'click', showDownloadProb, false);
    $('ieWarningCloseLabel').observe('click', showCustomVideo);
    
    view2DradObj = $('view2Drad');
    addEvent(view2DradObj, 'click', changeControls, false);
    view3DradObj = $('view3Drad');
    addEvent(view3DradObj, 'click', changeControls, false);
    download2DradObj = $('download2Drad');
    addEvent(download2DradObj, 'click', changeVersion, false);
    download3DradObj = $('download3Drad');
    addEvent(download3DradObj, 'click', changeVersion, false);
    
    cadChoiceVersionsObj = $('cadChoiceVersions');
    cadChoice2DformatsObj = $('cadChoice2Dformats');
    addEvent(cadChoice2DformatsObj, 'mousedown', tickRadio, false);
    cadChoice3DformatsObj = $('cadChoice3Dformats');
    addEvent(cadChoice3DformatsObj, 'mousedown', tickRadio, false);
    cadChoiceGetObj = $('cadChoiceGet');
    addEvent(cadChoiceGetObj, 'click', cadControl, false);
    
    downloadBtn1 = $('downloadBtn');
    addEvent(downloadBtn1, 'click', downloadIt, false);
    
    view2Dbtn1 = $('view2Dbtn');
    addEvent(view2Dbtn1, 'click', viewIt, false);
    addEvent(view2Dbtn1, 'click', changeControls, false);
    
    view3Dbtn1 = $('view3Dbtn');
    addEvent(view3Dbtn1, 'click', viewIt, false);
    addEvent(view3Dbtn1, 'click', changeControls, false);
    
    var instLink = $('instLink');
    addEvent(instLink, 'click', closeControl, false);
    
    var closeInst = $('closeInst');
    addEvent(closeInst, 'click', closeControl, false);
    
    drawingRadio = $('drawingRadio');
    addEvent(drawingRadio, 'click', changeControls, false);
    
    var modelRadio = $('modelRadio');
    addEvent(modelRadio, 'click', changeControls, false);
    
    var sBar = $('sBar');
    addEvent(sBar, 'mouseover', hideRange, false);
    
    var sBar2 = $('sBar2');
    addEvent(sBar2, 'mouseover', hideRange, false);
    
    partnoBtn = $('getPartnoBtn');
    addEvent(partnoBtn, 'click', getPartno, false);
    
    var closeNoViewer = $('closeNoViewer');
    addEvent(closeNoViewer, 'click', closeControl, false);
    
    cadIframe = $('cadIframe');
    
    currentCADview = '3D';
    
    ////////////partno search controls
    partnoInputVal = $('partnoInput');
    addEvent(partnoInputVal, 'focus', setFocusVal, false);
    addEvent(partnoInputVal, 'blur', setFocusVal, false);
    partnoDiv = $('partnoResults');
    numSearchParts = $('numSparts');
    numSearchMaterials = $('numSmaterials');
    searchedMaterialObj = $('searchedMatl');
    addEvent(searchedMaterialObj, 'change', changeSearchTeeth, false);
    addEvent(searchedMaterialObj, 'focus', setFocusVal, false);
    addEvent(searchedMaterialObj, 'blur', setFocusVal, false);
    numSearchGearTypes = $('numGtypes');
    searchedGearTypeObj = $('searchedGtypes');
    addEvent(searchedGearTypeObj, 'change', changeSearchTeeth, false);
    addEvent(searchedGearTypeObj, 'focus', setFocusVal, false);
    addEvent(searchedGearTypeObj, 'blur', setFocusVal, false);
    searchedTeethObj = $('searchedTeeth');
    addEvent(searchedTeethObj, 'focus', setFocusVal, false);
    addEvent(searchedTeethObj, 'blur', setFocusVal, false);
    partNumberSearched = $('partnoSearched');
    searchAgain = $('finishSearch');
    addEvent(searchAgain, 'click', getPartno, false);
    
    ////////////
    
    ////////////quote controls
    $('quoteBin').observe('click', openQuoteBin);
    quotePart = new Array();
    quoteQty = new Array();
    addPart = new Array();
    addFile = new Array();
    addFileCell = new Array();
    fileRow = new Array();
    quoteControlMaxObj = $('quoteControlMax');
    quoteControlRowObj = $('quoteControlRow');
    quoteControlColObj = $('quoteControlCol');
    addEvent(quoteControlMaxObj, 'click', maximizeQC, false);
    minQuoteObj = $('minQuote');
    addEvent(minQuoteObj, 'click', minimizeQC, false);
    quoteControlMaxLabelObj = $('quoteControlMaxLabel');
    
    quoteT = $('quoteTable');
    
    for (x = 1; x < 10; x++) 
    {
        quotePart[x] = $('quotePart' + x);
        quoteQty[x] = $('quoteQty' + x);
        $(quoteQty[x]).observe('keyup', addComments);
        addPart[x] = $('addPart' + x);
        //addEvent(addPart[x], 'click', partRemove, false);
        $(addPart[x]).observe('click', partRemove);
        addFile[x] = $('addFile' + x);
        //addEvent(addFile[x], 'click', addQuoteFile, false);
        $(addFile[x]).observe('click', addQuoteFile);
        addFileCell[x] = $('addFileCell' + x);
        // addEvent(addFileCell[x],'click',showDisabledMsg,false);
        fileRow[x] = $('fileRow' + x);
    }
    
    
    closeQ = $('closeQuote');
    addEvent(closeQ, 'click', closeControl, false);
    //////addEvent(closeQ, 'click', cleanQuote, false);
    //addEvent(closeQ, 'mouseover', closeControl, false);
    //addEvent(closeQ, 'mouseout', closeControl, false);
    
    closeMessage = $('closeMsg');
    
    sendRFQbtn1 = $('sendRFQbtn1');
    addEvent(sendRFQbtn1, 'click', quoteControl, false);
    
    sendRFQbtn2 = $('sendRFQbtn2');
    addEvent(sendRFQbtn2, 'click', quoteControl, false);
    
    country = $('country');
    addEvent(country, 'change', changeStates, false);
    
    fname = $('fname');
    lname = $('lname');
    company = $('company');
    street = $('street');
    city = $('city');
    state = $('states');
    statesAlt = $('statesAlt');
    prov = $('prov');
    zip = $('zip');
    phone = $('phone');
    fax = $('fax');
    emailIt = $('emailIt');
    faxIt = $('faxIt');
    comments = $('comments');
    $('comments').observe('keyup', addComments);
    
    email1 = $('email1');
    email2 = $('email2');
    //addEvent(email2, 'keydown', fillEmail1, false);
    
    regSendMsg = $('rsm');
    regTable = $('registerQuoteTable');
    regSendMeter = $('regSendMeter');
    quoteSendMsg = $('qsm');
    quoteSendMeter = $('quoteSendMeter');
    sendCell = $('sCell');
    
    
    ////////////////tabs////////////////
    tabsError = new Array();
    /*customTabs = new ddtabcontent("customTabsList")
     customTabs.setpersist(false)
     customTabs.setselectedClassTarget("link") //"link" or "linkparent"
     customTabs.init()
     */
    $$('#tabnav li').each(function(s)
    {
        $(s.id).observe('click', showContent);
    });
    
    
    /////////
    
    ///////customGear stuff////////////////////////////////////////////////////////////////////
    var idCookie = readCookie('cgID');
    
    if (idCookie) 
    {
        setEmail(idCookie);
        cgLogin();
    }
    
    var cgPartsCookie = readCookie('cgParts');
    
    if (cgPartsCookie) 
    {
        var cookieParts = cgPartsCookie.split(',');
        viewPrev = new yesNo('You were working on some custom parts the last time you were on this page. <br /> Would you like to view them now?', yesViewPrev, '#3300FF', '#ffffff');
    }
    
    usingCustom = false;
    rmGear = new GearRemoval();
    rmGear.dontPrompt = false;
    $('startCustom').observe('click', justOpenCG);
    $('cgNewPartBtn').observe('click', createGear);
    $('cgGearType').observe('change', changeGearType);
    $('closeCG').observe('click', closeCG);
    $('cgMinimize').observe('click', minimizeCG);
    $('cgMaximize').observe('click', maximizeCG);
    $('cgYesRemove').observe('click', rmGear.removeGear);
    $('cgNoRemove').observe('click', rmGear.closePrompt);
    $('dontPromptRemove').observe('click', rmGear.doNotPrompt);
    $('clearCGcover').observe('click', hasPartno);
    $('clearCGcover2').observe('click', hasPartno);
    $('coverIframe').contentWindow.document.onclick = hasPartno; //observe('click',hasPartno);
    $('coverIframe2').contentWindow.document.onclick = hasPartno; //.observe('click',hasPartno);
    $('showLoginBtn').observe('click', showLogin);
    $('loginBtn').observe('click', cgLogin);
    $('loginEmail').observe('focus', setFocusVal);
    $('topCGlogin').observe('click', showLogin);
    $('loginEmail').observe('blur', setFocusVal);
    $('savePartEmail').observe('focus', setFocusVal);
    $('savePartEmail').observe('blur', setFocusVal);
    $('savePartEmailBtn').observe('click', getNewPartno);
    $('userPartsClose').observe('click', showLogin);
    $('userPartsClose').observe('mouseover', enableDisableLoginDrag);
    $('userPartsClose').observe('mouseout', enableDisableLoginDrag);
    $('email1').observe('focus', setFocusVal);
    $('email1').observe('blur', setFocusVal);
    $('coverIframe').observe('click', hasPartno);
    $('coverIframe2').observe('click', hasPartno);
    $('savePartEmailBtn1').observe('click', saveCurrent);
    $('cgUseStdKwy').observe('change', updateGear);
    $('cgUseStdKwy').observe('click', updateGear);
    $('keepMyPartsOpen').observe('click', keepPartsOpen);
    $('keepMyPartsOpen').observe('mouseover', keepPartsMsg);
    $('keepMyPartsOpen').observe('mouseout', hideMessages);
    $('styleHelp').observe('mouseover', showCGinst);
    $('styleHelp').observe('mouseout', showCGinst);
    $('pitchTypeHelp').observe('mouseover', showCGinst);
    $('pitchTypeHelp').observe('mouseout', showCGinst);
    $('pdHelp').observe('mouseover', showCGinst);
    $('pdHelp').observe('mouseout', showCGinst);
    $('odHelp').observe('mouseover', showCGinst);
    $('odHelp').observe('mouseout', showCGinst);
    $('paHelp').observe('mouseover', showCGinst);
    $('paHelp').observe('mouseout', showCGinst);
    $('backlashHelp').observe('mouseover', showCGinst);
    $('backlashHelp').observe('mouseout', showCGinst);
    $('boreHelp').observe('mouseover', showCGinst);
    $('boreHelp').observe('mouseout', showCGinst);
    $('faceHelp').observe('mouseover', showCGinst);
    $('faceHelp').observe('mouseout', showCGinst);
    $('cbHelp').observe('mouseover', showCGinst);
    $('cbHelp').observe('mouseout', showCGinst);
    $('hdHelp').observe('mouseover', showCGinst);
    $('hdHelp').observe('mouseout', showCGinst);
    $('haHelp').observe('mouseover', showCGinst);
    $('haHelp').observe('mouseout', showCGinst);
    $('handHelp').observe('mouseover', showCGinst);
    $('handHelp').observe('mouseout', showCGinst);
    $('betaBugsBtn').observe('click', launchFunctions);
    $('betaBugs').observe('keypress', launchFunctions);
    //$('betaBugs').observe('focus', setFocusVal);
    //$('betaBugs').observe('blur', setFocusVal);
    $('downloadLinkLink').observe('click', closeControl);
	$('key1cover').observe('click',showHideKey);
	$('key1').observe('click',showHideKey);
	$('key2cover').observe('click',showHideKey);
	$('key2').observe('click',showHideKey);
	$('key3cover').observe('click',showHideKey);
	$('key3').observe('click',showHideKey);
	$('key4cover').observe('click',showHideKey);
	$('key4').observe('click',showHideKey);
	$('key5cover').observe('click',showHideKey);
	$('key5').observe('click',showHideKey);
	$('key6cover').observe('click',showHideKey);
	$('key6').observe('click',showHideKey);
	$('key7cover').observe('click',showHideKey);
	$('key7').observe('click',showHideKey);
	$('key8cover').observe('click',showHideKey);
	$('key8').observe('click',showHideKey);	
	//$('cgKeyPos').observe('change',changePos);
    
    $$('input.cgGearSpec').each(function(s)
    {
        $(s.id).observe('click', checkErrors);
        $(s.id).observe('keyup', updateGear);
        $(s.id).observe('mouseover', checkErrors);
        $(s.id).observe('mouseout', hideErrorMsg);
        
    });
    
    $$('select.cgGearSpec').each(function(s)
    {
        //the gear type needs to trigger the changeGearType function first
        if (s.id != 'cgGearType') 
        {
            $(s.id).observe('change', updateGear);
        }
    });
    xCounter = 0;
    
    $('myPartsWrapper').observe('click', slideOpenParts);
    //$('myPartsArrowDown').observe('click',slideOpenParts);
    $('myPartsArrowUp').observe('click', slideOpenParts);
    
    lastRefNumber = '';
    
    clearAddFiles();
    
    if (!hasViewpoint) 
    {
        //$('noViewer').show();
    }
    
    ////////hide or show geartype images on startup
    if (browserName == "msie") 
    {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    else 
    {
        windowWidth = window.innerWidth;
        windowHeight = window.innerHeight;
    }
    changeMenus();
    //setTimeout("getPage('Tech_Tools/"+folder+"/cadFormats.php?showPage=false','getLink')",20);
    filledCadFormats = false;
    
    
    checkQuoteBin('fill', '', '');
    if (login) 
    {
        showLogin('topCGlogin');
    }
    
    cadHandleToDrag = browserName == 'msie' ? 'cadHandleIE' : 'cadHandle';
    quoteRootToDrag = browserName == 'msie' ? 'quoteControlsIE' : 'quoteControls';
    
    loginDrag = new Draggable('cgLogin', 
    {
        ghosting: true,
        handle: 'userPartsHeader'
    });
    new Draggable('cadIframeBox', 
    {
        ghosting: true,
        handle: cadHandleToDrag
    });
    new Draggable(quoteRootToDrag, 
    {
        ghosting: true,
        handle: 'quoteHandle'
    });
    new Draggable('partSearchInst', 
    {
        ghosting: true
    });
    
}

//*********************************************************************************************************************************************************************
var orderBy = false;
var orderByDir = false;
var rpms = 100;
var svcFactor = 1.25;

function launchFunctions(e)
{
    var elId = getElemID(e) == 'error' ? e : getElemID(e);  
	var c = null;  
    c = document.layers ? e.which : document.all ? event.keyCode : e.keyCode;
    
    if (c == 13) 
    {
        switch (elId)
        {
            case "betaBugs":
                if ($('betaBugs').value.length == 0) 
                {
                    alert('You left the bug report blank.');
                    return;
                }
                bugPrompt = new Mprompt('reportBugs','','');
                bugPrompt.msg('If you would like a reply please provide your email address.');                
                bugPrompt.textInput.value = readCookie('cgID') ? readCookie('cgID') : '';										
                bugPrompt.hideElement(bugPrompt.noBtn);
				bugPrompt.hideElement(bugPrompt.cancelBtn);
                bugPrompt.yesBtn.value = 'Continue';                
                bugPrompt.show();
				bugPrompt.textInput.focus();
                break;
			case "betaBugsBtn":
                if ($('betaBugs').value.length == 0) 
                {
                    alert('You left the bug report blank.');
                    return;
                }
                bugPrompt1 = new Mprompt('reportBugs','','');
                bugPrompt1.msg('If you would like a reply please provide your email address.');                
                bugPrompt1.textInput.value = readCookie('cgID') ? readCookie('cgID') : '';										
                bugPrompt1.hideElement(bugPrompt1.noBtn);
				bugPrompt1.hideElement(bugPrompt1.cancelBtn);
                bugPrompt1.yesBtn.value = 'Continue';                
                bugPrompt1.show();
				bugPrompt1.textInput.focus();
                break;
            case "error":
                break;
        }
    }
    
    if (!c) 
    {
        switch (elId)
        {
            case "betaBugsBtn":
                 if ($('betaBugs').value.length == 0) 
                {
                    alert('You left the bug report blank.');
                    return;
                }
                bugPrompt2 = new Mprompt('reportBugs','','');
                bugPrompt2.msg('If you would like a reply please provide your email address.');                
                bugPrompt2.textInput.value = readCookie('cgID') ? readCookie('cgID') : '';										
                bugPrompt2.hideElement(bugPrompt2.noBtn);
				bugPrompt2.hideElement(bugPrompt2.cancelBtn);
                bugPrompt2.yesBtn.value = 'Continue';                
                bugPrompt2.show();
				bugPrompt2.textInput.focus();            
                break;
        }
    }
}

function setFocusVal(e)
{
    var elId = getElemID(e);
    
    if (e.type == 'blur') 
    {
        switch (elId)
        {
            case ('email1'):
                email1IsFocused = 'false';
                break;
            case 'loadCustomPartno':
                customPisFocused = 'false';
                break;
            case 'partnoInput':
                partnoIsFocused = 'false';
                break;
            case 'loginEmail':
                loginIsFocused = 'false';
                break;
            case 'savePartEmail':
                savePartIsFocused = 'false';
                break;
            case 'betaBugs':
                betaBugsIsFocused = 'false';
                break;
            default:
                partnoIsFocused = 'false';
        }
    }
    else 
    {
        switch (elId)
        {
            case ('email1'):
                email1IsFocused = 'true';
                break;
            case 'loadCustomPartno':
                customPisFocused = 'true';
                break;
            case 'partnoInput':
                partnoIsFocused = 'true';
                break;
            case 'loginEmail':
                loginIsFocused = 'true';
                break;
            case 'savePartEmail':
                savePartIsFocused = 'true';
                break;
            case 'betaBugs':
                betaBugsIsFocused = 'true';
                break;
            default:
                partnoIsFocused = 'true';
        }
    }
}

function changeSearchTeeth(e)
{
    var elId = getElemID(e);
    teethToUse = new Array();
    var gtToUse = '';
    var mtToUse = '';
    var z = 0;
    var searchMsg = $('searchmsg');
    var matMsg = 'Materials available for this gear type: ';
    var showMatMsg = false;
    var gtMsg = 'Gear types available for this material: ';
    var showGtMsg = false;
    for (x = 0; x < gtMatTeeth.length; x++) 
    {
        if (gtMatTeeth[x][0] == searchedGearTypeObj.value && gtMatTeeth[x][1] == searchedMaterialObj.value) 
        {
            if (gtMatTeeth[x][1] == searchedMaterialObj.value) 
            {
                for (y = 2; y < gtMatTeeth[x].length; y++) 
                {
                    teethToUse[z] = gtMatTeeth[x][y];
                    z++;
                }
                break;
            }
            else 
            {
                for (y = 2; y < gtMatTeeth[x].length; y++) 
                {
                    teethToUse[z] = gtMatTeeth[x][y];
                    z++;
                }
                break;
            }
        }
    }
    
    if (teethToUse.length == '0') 
    {
        if (elId == 'searchedGtypes') 
        {
            for (x = 0; x < gtMatTeeth.length; x++) 
            {
                if (gtMatTeeth[x][0] == searchedGearTypeObj.value) 
                {
                    if (gtMatTeeth[x][1] == searchedMaterialObj.value) 
                    {
                        for (y = 2; y < gtMatTeeth[x].length; y++) 
                        {
                            teethToUse[z] = gtMatTeeth[x][y];
                            z++;
                        }
                        
                        break;
                    }
                    else 
                    {
                        for (y = 2; y < gtMatTeeth[x].length; y++) 
                        {
                            if (gtMatTeeth[x][0] == searchedGearTypeObj.value) 
                            {
                                thisGTx = x;
                                teethToUse[z] = gtMatTeeth[x][y];
                            }
                            z++;
                        }
                        
                        mtToUse = gtMatTeeth[x][1];
                        gtToUse = gtMatTeeth[thisGTx][0];
                        break;
                    }
                }
            }
        }
        else 
        {
            for (x = 0; x < gtMatTeeth.length; x++) 
            {
                if (gtMatTeeth[x][1] == searchedMaterialObj.value) 
                {
                    if (gtMatTeeth[x][0] == searchedGearTypeObj.value) 
                    {
                        for (y = 2; y < gtMatTeeth[x].length; y++) 
                        {
                            teethToUse[z] = gtMatTeeth[x][y];
                            z++;
                        }
                        
                        break;
                    }
                    else 
                    {
                        for (y = 2; y < gtMatTeeth[x].length; y++) 
                        {
                            if (gtMatTeeth[x][1] == searchedMaterialObj.value) 
                            {
                                thisMatx = x;
                                teethToUse[z] = gtMatTeeth[x][y];
                            }
                            z++;
                        }
                        
                        mtToUse = gtMatTeeth[thisMatx][1];
                        gtToUse = gtMatTeeth[x][0];
                        break;
                    }
                }
            }
        }
        
        for (x = 0; x < gtMatTeeth.length; x++) 
        {
            if (elId == 'searchedGtypes') 
            {
                if (gtMatTeeth[x][0] == gtToUse) 
                {
                    matMsg += gtMatTeeth[x][1] + ',';
                    showMatMsg = true;
                }
            }
            else 
            {
                if (gtMatTeeth[x][1] == mtToUse) 
                {
                    gtMsg += gtMatTeeth[x][0] + ',';
                    showGtMsg = true;
                }
            }
        }
        
        fillSelects(searchedGearTypeObj, foundGearTypes, gtToUse);
        fillSelects(searchedMaterialObj, foundMaterials, mtToUse);
    }
    
    fillSelects(searchedTeethObj, teethToUse);
    if (showMatMsg) 
    {
        searchMsg.innerHTML = matMsg.substr(0, matMsg.length - 1);
    }
    
    if (showGtMsg) 
    {
        searchMsg.innerHTML = gtMsg.substr(0, gtMsg.length - 1);
    }
    
    return;
}

function getPartno(e)
{
    var elId = getElemID(e);
    var partnoInfo = $('partnoInput');
    var partno = partnoInfo.value;
    sMaterial = searchedMaterialObj.value;
    sGearType = searchedGearTypeObj.value;
    sTeeth = searchedTeethObj.value;
    loadImages('none', sGearType);
    
    
    if (partno) 
    {
        if (elId == 'getPartnoBtn' || elId == 'partnoInput') 
        {
            $('getPartnoBtn').value = "Searching";
            if (partno.length == 9 && partno.substr(4, 1) == '-') 
            {
                getPage('Tech_Tools/' + folder + '/findCustomParts.php?partno=' + partno, 'fillCustomParts');
            }
            else 
            {
                getPage('Tech_Tools/' + folder + '/searchPartnos.php?part=' + partno, 'partSearchMenus');
            }
        }
        else 
        {
            $('finishSearch').value = "Searching";
            if (partno.length == 9 && partno.substr(4, 1) == '-') 
            {
                getPage('Tech_Tools/' + folder + '/findCustomParts.php?partno=' + partno, 'fillCustomParts');
            }
            else 
            {
                getPage('Tech_Tools/' + folder + '/searchPartnos.php?part=' + partno + '&gearType=' + sGearType + '&material=' + sMaterial + '&teeth=' + sTeeth, 'partSearchMenus');
            }
        }
        
        sMaterial = '';
        sGearType = '';
        sTeeth = '';
        for (x = 0; x < searchedMaterialObj.length; x++) 
        {
            searchedMaterialObj.options[x] = new Option('', '');
            searchedGearTypeObj.options[x] = new Option('', '');
            searchedTeethObj.options[x] = new Option('', '');
        }
    }
}

function change3Dgear()
{
    var gtype = $('mainGearType').value;
    var matl = $('mainMaterial').value;
    var image3D = $('Dgear');
    var imageAB = $('ABgear');
    image3D.src = '';
    
    /// remove this when all models are able to be customized
    if (gtype != 'SPUR' && gtype != 'HELICAL') 
    {
        $('customChoice').hide();
    }
    else 
    {
        $('customChoice').show();
    }
    
    switch (gtype)
    {
        case "SPUR":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelSpur3D.gif";
         break;
         case "BRONZE":
         image3D.src = "/images/spur3Dbronze.gif";
         break;
         case "CASTIRON":
         image3D.src = "/images/castIronSpur3D.gif";
         break;
         case "ALUMINUM":
         image3D.src = "/images/aluminumSpur3D.gif";
         break;
         case "DELRIN":
         image3D.src = "/images/spur3Ddelrin.gif";
         break;
         case "PHENOLIC":
         image3D.src = "/images/spur3Dphenolic.gif";
         break;
         case "HARDTEETH":
         image3D.src = "/images/spur3Dhardteeth.gif";
         break;
         case "STAINLESSSTEEL":
         image3D.src = "/images/stainlessSteelSpur3D.gif";
         break;
         default: image3D.src = "/images/steelSpur3D.gif";
         }*/
            image3D.src = "/images/spur3DstandardA.gif";
            imageAB.src = "/images/spur3DstandardB.gif";
            //imageAB.src = "/images/spurAB.gif";
            break;
        case "HELICAL":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelHelical3D.gif";
         break;
         case "ALUMINUM":
         image3D.src = "/images/steelHelical3D.gif";
         break;
         case "BRONZE":
         image3D.src = "/images/steelHelical3D.gif";
         break;
         case "DELRIN":
         image3D.src = "/images/steelHelical3D.gif";
         break;
         case "HARDTEETH":
         image3D.src = "/images/steelHelical3D.gif";
         break;
         case "PHENOLIC":
         image3D.src = "/images/steelHelical3D.gif";
         break;
         case "STAINLESSSTEEL":
         image3D.src = "/images/steelHelical3D.gif";
         break;
         default: image3D.src = "images/steelHelical3D.gif";
         }*/
            image3D.src = "/images/helical3DstandardA.gif";
            imageAB.src = "/images/helical3DstandardB.gif";
            break;
        case "WORM GEAR":
            /*switch(matl)
         {
         case "BRONZE":
         image3D.src = "/images/bronzeWormGear3D.gif";
         break;
         case "CASTIRON":
         image3D.src = "/images/castIronWormGear3D.gif";
         break;
         default: image3D.src = "/images/bronzeWormGear3D.gif";
         }*/
            image3D.src = "/images/wormGear3DstandardA.gif";
            imageAB.src = "/images/wormGear3DstandardB.gif";
            break;
        case "WORM":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelWorm3D.gif";
         break;
         default: image3D.src = "/images/steelWorm3D.gif";
         }*/
            image3D.src = "/images/worm3DstandardA.gif";
            imageAB.src = "/images/worm3DstandardB.gif";
            break;
        case "BEVEL/MITER":
            /*switch(matl)
         {
         case "ALUMINUM":
         image3D.src = "/images/aluminumBevel3D.gif";
         break;
         case "STEEL":
         image3D.src = "/images/steelBevel3D.gif";
         break;
         default: image3D.src = "/images/steelBevel3D.gif";
         }*/
            image3D.src = "/images/bevel3DstandardA.gif";
            imageAB.src = "/images/bevel3DstandardB.gif";
            break;
        case "SPIRAL MITER":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelSpiralMiter3D.gif";
         break;
         default: image3D.src = "/images/steelSpiralMiter3D.gif";
         }*/
            image3D.src = "/images/spiral3DstandardA.gif";
            imageAB.src = "/images/spiral3DstandardB.gif";
            break;
        case "CHANGE":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelChange3D.gif";
         break;
         default: image3D.src = "/images/steelChange3D.gif";
         }*/
            image3D.src = "/images/changeGear3DstandardA.gif";
            imageAB.src = "/images/changeGear3DstandardB.gif";
            break;
        case "INTERNAL":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelInternal3D.gif";
         break;
         default: image3D.src = "/images/steelInternal3D.gif";
         }*/
            image3D.src = "/images/internal3DstandardA.gif";
            imageAB.src = "/images/internal3DstandardB.gif";
            break;
        case "RACK":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelRack3D.gif";
         break;
         default: image3D.src = "/images/steelRack3D.gif";
         }*/
            image3D.src = "/images/rack3Dstandard.gif";
            imageAB.src = "/images/rack3Dstandard.gif";
            break;
        case "PINION WIRE":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/bronzePinionWire3D.gif";
         break;
         default: image3D.src = "/images/bronzePinionWire3D.gif";
         }*/
            image3D.src = "/images/pinionWire3DstandardA.gif";
            imageAB.src = "/images/pinionWire3DstandardB.gif";
            break;
        case "STEM PINION":
            /*switch(matl)
         {
         case "STEEL":
         image3D.src = "/images/steelStemPinion3D.gif";
         break;
         default: image3D.src = "/images/steelStemPinion3D.gif";
         }*/
            image3D.src = "/images/stemPinion3DstandardB.gif";
            imageAB.src = "/images/stemPinion3DstandardB.gif";
            break;
    }
}

function closeControl(e)
{
    var elId = getElemID(e) == 'error' ? e : getElemID(e);
    
    switch (elId)
    {
        case "dLoadLink":
            var thisElement = $('downloadLinkWin');
            break;
        case "closeCG":
            var thisElement = $('customGearDiv');
            var properties = "";
            newGear.boreError = false;
            newGear.hub1Error = false;
            newGear.hub2Error = false;
            newGear.customGearWarn = '';
            cgMessagesObj.style.display = 'none';
            cgWarningsObj.style.display = 'none';
            customCadPromptObj.visualEffect('Shrink');
            break;
        case "cgNoChange":
            var thisElement = $('changePartnoPrompt');
            break;
        case "cgMediaClose":
            var thisElement = $('cgMedia');
            $('cgTutorialLabel').show();
            break;
        case "cgNoRemove":
            var thisElement = $('removePrompt');
            break;
        case "quitCustomBtn":
            var thisElement = customCadPromptObj;
            $('dontPromptCad').checked = false;
            break;
        case "cancelCustomBtn":
            var thisElement = customCadPromptObj;
            break;
        case "closeCadChoice":
            var thisElement = $('cadChoice');
            $('opaqBackCG').hide();
            break;
        case "instLink":
            var thisElement = $('partSearchInst');
            break;
        case "closeInst":
            var thisElement = $('partSearchInst');
            break;
        case "closeNoViewer":
            var thisElement = $('noViewer');
            break;
        case "closeQuote":
            if (e.type == 'mouseover' || e.type == 'mouseout') 
            {
                var thisElement = closeMessage;
                browserName == 'msie' ? thisElement.style.right = 5 + 'px' : thisElement.style.right = 80 + 'px';
                browserName == 'msie' ? thisElement.style.top = 20 + 'px' : thisElement.style.top = 20 + 'px';
            }
            else 
            {
                var thisElement = browserName == 'msie' ? $('quoteControlsIE') : $('quoteControls');
                closeMessage.style.display = 'none';
            }
            break;
        case "registerQuote":
            var thisElement = $('registerQuoteTable');
            break;
        case "sendRFQbtn2":
            var thisElement = $('registerQuoteTable');
            break;
    }
    
    if (thisElement.style.display == 'none') 
    {
        //thisElement.style.display = '';
        thisElement.show();
    }
    else 
    {
        //thisElement.style.display = 'none';
        thisElement.hide();
        if (elId == 'sendRFQbtn2') 
        {
            if (browserName == 'msie') 
            {
                quoteT.filters.alpha.opacity = 100;
            }
            else 
            {
                quoteT.style.MozOpacity = 1;
            }
        }
    }
}

function changeMenus(e, orderBy, orderByDir, gotoPage)
{
    ///control the "loading" text and progress meter image  see xmlresults below 
    $('done').style.display = 'none';
    $('loading').style.display = '';
    //loadDisp = browserName == 'msie' ? $('loadingImg').style.display = '' : bcm = 0;
    $('loadingImg').show();
    $('updateInfo').style.display = '';
    sortHolder = $('sortHolder');
    sortDirHolder = $('sortDirHolder');
    
    if ($('hpTable').style.display == '') 
    {
        hideHP();
    }
    
    orderBy = sortHolder.value == '' ? "TEETH" : sortHolder.value;
    orderByDir = sortDirHolder.value == '' ? "ASC" : sortDirHolder.value;
    
    if (!gotoPage) 
    {
        gotoPage = 0;
    }
    
    gearTypeElem = $('mainGearType');
    materialElem = $('mainMaterial');
    pitchElem = $('mainPitch');
    teethElem = $('mainTeeth');
    paElem = $('mainPA');
    hubStyleElem = $('mainHubStyle');
    pitchTypeElem = $('mainPitchType');
    unitsElem = $('mainUnits');
    
    var gearType = gearTypeElem.value;
    material = materialElem.value;
    pitch = pitchElem.value;
    teeth = teethElem.value;
    pa = paElem.value;
    hubStyle = hubStyleElem.value.toUpperCase();
    pitchType = pitchTypeElem.value;
    units = unitsElem.value;
    
    ///disable menus until xmlresponse is received see xmlResults below
    gearTypeElem.disabled = true;
    materialElem.disabled = true;
    pitchElem.disabled = true;
    teethElem.disabled = true;
    paElem.disabled = true;
    hubStyleElem.disabled = true;
    pitchTypeElem.disabled = true;
    unitsElem.disabled = true;
    
    /*var hpHoverMsg = $('hpHoverMsg');
     if(gearType == 'SPUR' || gearType == 'HELICAL')
     {
     hpHoverMsg.style.display = '';
     }
     else
     {
     hpHoverMsg.style.display = 'none';
     }*/
    if (gearType == 'BEVEL/MITER') 
    {
        gearType = 'BEVEL';
    }
    
    dbToUse = material + gearType;
    
    if (gearType != "SPUR") 
    {
        pitchTypeElem.disabled = true;
        pitchTypeElem.options[0].selected = true;
        pitchType = pitchTypeElem.value;
    }
    
    ///Load the images for each gearType -- since there are so many images it is better to load them once when needed
    //loadImages();
    
    getPage('Tech_Tools/' + folder + '/partSearchDB.php?gearType=' + gearType + '&material=' + material + '&pitch=' + pitch + '&teeth=' + teeth + '&pa=' + pa + '&hubStyle=' + hubStyle + '&dbToUse=' + dbToUse + '&orderBy=' + orderBy + '&orderByDir=' + orderByDir + '&pitchType=' + pitchType + '&units=' + units + '&gotoPage=' + gotoPage, 'partSearchMenus');
}

///fill the select menus
function fillSelects(selectObj, selections, lastOption)
{
    selectObj.options.length = 0;
    for (x = 0; x < selections.length; x++) 
    {
        selectObj.options[x] = new Option(selections[x], selections[x]);
        if (selections[x].replaceWS() == lastOption.replaceWS()) 
        {
            selectObj.options[x].selected = true;
        }
    }
    
    change3Dgear();
}

function fillFormatSelects(whatD, selectObj, selections)
{
    if (whatD == '2D') 
    {
        $2DversionListObj = $('t2Dversions');
        selectObj.options.length = 0;
        for (x = 0; x < selections.length; x++) 
        {
            selectObj.options[x] = new Option(selections[x], selections[x]);
        }
        
        for (x = 0; x < $2Dversions[0].length - 1; x++) 
        {
            $2DversionListObj.options[x] = new Option($2Dversions[0][x], $2Dversions[0][x]);
            cadChoiceVersionsObj.options[x] = new Option($2Dversions[0][x], $2Dversions[0][x]);
        }
    }
    
    if (whatD == '3D') 
    {
        $3DversionListObj = $('t3Dversions');
        selectObj.options.length = 0;
        for (x = 0; x < selections.length; x++) 
        {
            selectObj.options[x] = new Option(selections[x], selections[x]);
        }
        
        for (x = 0; x < $3Dversions[0].length - 1; x++) 
        {
            $3DversionListObj.options[x] = new Option($3Dversions[0][x], $3Dversions[0][x]);
            cadChoiceVersionsObj.options[x] = new Option($2Dversions[0][x], $2Dversions[0][x]);
        }
    }
}

function hideRange()
{
    /*var toothRange1 = $('toothRange');
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     if (toothRange1.style.display == '')
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     {
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     toothRange1.style.display = 'none';
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     
    
     }*/
    
}

function getToothRange(pageId)
{
    sortDirHolder = $('sortDirHolder');
    orderByDir = sortDirHolder.value == '' ? "ASC" : sortDirHolder.value;
    gotoPage2 = pageId.substr(6);
    //var cm = setTimeout("getPage('Tech_Tools/"+folder+"/partSearchDB.php?gearType='+gearType+'&material='+material+'&pitch='+pitch+'&teeth='+teeth+'&pa='+pa+'&hubStyle='+hubStyle+'&dbToUse='+dbToUse+'&orderBy='+orderBy+'&orderByDir='+orderByDir+'&pitchType='+pitchType+'&units='+units+'&gotoPage='+gotoPage2,'partSearchToothRange')",300);
}

function disablePaging(e)
{
    var allLinks = document.links;
    for (l = 0; l < allLinks.length; l++) 
    {
        var eID = allLinks[l].id;
        if (eID.substr(0, 6) == 'dbPage') 
        {
            $(eID).onmouseover = function()
            {
                return false;
            }
        }
    }
    var pages = $('pages');
    //pages.style.display = 'none';
    //pages.disabled = 'true';
}

function enablePaging(e)
{
    var pages = $('pages');
    //pages.style.display = '';
}

function dbPaging(maxPage, pageNum)
{
    /////controls the page numbering for database paging system
    toothRange1 = $('toothRange');
    nextPage = parseInt(pageNum) + 1;
    pageStr = "";
    if (parseInt(pageNum) > 1) 
    {
        prevPage = parseInt(pageNum) - 1;
        pageStr += "<a href=\"javascript:void(0);\" onclick=\"changeMenus('none','','','1');toothRange1.style.display='none';\" id=\"dbPage1\" onmouseover=\"getToothRange(this.id);\" onmouseout=\"toothRange1.style.display='none';\" >&lt;&lt;First</a>&nbsp;&nbsp;";
        pageStr += "<a href=\"javascript:void(0);\" onclick=\"changeMenus('none','',''," + prevPage + ");toothRange1.style.display='none';\" id=\"dbPage" + prevPage + "\" onmouseover=\"getToothRange(this.id);\" onmouseout=\"toothRange1.style.display='none';\">Previous </a>&nbsp;&nbsp;";
    }
    else 
    {
        prevPage = 1;
    }
    
    for (pp = 1; pp < parseInt(maxPage) + 1; pp++) 
    {
        if (pp == pageNum) 
        {
            pageStr += "&nbsp;<label class=\"medyellow\">" + pp + "</label>";
        }
        else 
        {
            pageStr += "&nbsp;<a href=\"javascript:void(0);\" onclick=\"changeMenus('none','',''," + pp + ");toothRange1.style.display='none';\" id=\"dbPage" + pp + "\" onmouseover=\"getToothRange(this.id);\" onmouseout=\"toothRange1.style.display='none';\">" + pp + "</a>";
        }
    }
    
    if (parseInt(pageNum) < maxPage) 
    {
        pageStr += "&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"changeMenus('none','',''," + nextPage + ");toothRange1.style.display='none';\" id=\"dbPage" + nextPage + "\" onmouseover=\"getToothRange(this.id);\" onmouseout=\"toothRange1.style.display='none';\">Next</a>";
        pageStr += "&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"changeMenus('none','',''," + maxPage + ");toothRange1.style.display='none';\" id=\"dbPage" + maxPage + "\" onmouseover=\"getToothRange(this.id);\" onmouseout=\"toothRange1.style.display='none';\">Last&gt;&gt;</a>";
    }
    else 
    {
        pageStr += "";
    }
    
    return pageStr;
}

function currentSearchSettings(pt1, gt1, lm1, u1, p1, lt1, pa1, hub1)
{
    ////controls the current settings status
    currSettingsVal = "<label class=\"medgold\">Current Search:</label>";
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Pitch Type:</label>&nbsp;&nbsp; " + pt1;
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Gear Type:</label>&nbsp;&nbsp;" + gt1;
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Material:</label>&nbsp;&nbsp;" + lm1;
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Units:</label>&nbsp;&nbsp;" + u1;
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Pitch:</label>&nbsp;&nbsp;" + p1;
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Teeth:</label> &nbsp;&nbsp;" + lt1;
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Pressure Angle:</label>&nbsp;&nbsp;" + pa1;
    currSettingsVal += "&nbsp;&nbsp;&nbsp;&nbsp;<label class=\"medsilver\">Style:</label> &nbsp;&nbsp;" + hub1;
    return currSettingsVal;
}

function convertKwy(kwyStr, units, getDim)
{
    var kwyW = '';
    var kwyD = '';
    var convertToMM = true;
    ////if kwy is in #MM form
    if (kwyStr.indexOf('mm') > -1) 
    {
        kwyW = kwyStr.substr(0, kwyStr.length - 2);
        kwyD = kwyW / 2;
        convertToMM = false;
    }
    
    ////if kwy is in w x d form
    if (kwyStr.indexOf('x') > -1) 
    {
        byPos = kwyStr.indexOf('x');
    }
    
    /////if kwy is in decimal form .250 X .125
    if (kwyStr.indexOf('.') > -1) 
    {
        kwyW = kwyStr.substr(0, byPos);
        kwyD = kwyStr.substr(byPos + 1);
    }
    
    ////if kwy is in fractional form #/# x #/#
    if (kwyStr.indexOf('/') > -1) 
    {
        divPos1 = kwyStr.indexOf('/');
        divPos2 = kwyStr.lastIndexOf('/');
        divThis1 = kwyStr.substr(0, divPos1);
        divThis2 = kwyStr.substr(byPos + 1, divPos2 - byPos - 1);
        byThis1 = kwyStr.substr(divPos1 + 1, byPos - 2);
        byThis2 = kwyStr.substr(divPos2 + 1);
        kwyW = parseInt(divThis1) / parseInt(byThis1);
        kwyD = parseInt(divThis2) / parseInt(byThis2);
    }
    
    if (units == 'MM') 
    {
        if (convertToMM) 
        {
            kwyW = Math.round(kwyW * 25.4 * 1000) / 1000;
            kwyD = Math.round(kwyD * 25.4 * 1000) / 1000;
        }
    }
    
    if (getDim == 'width') 
    {
        return kwyW;
    }
    
    if (getDim == 'depth') 
    {
        return kwyD;
    }
}

function doNothing()
{
}

//dynamically create all of the table cells

function createCellWithText(txt, cellType, attrID, orderBy)
{
    if (attrID.charCodeAt(0) == '10') 
    {
        attrID = attrID.substr(1);
    }
    switch (cellType)
    {
        case "th":
            var cell = document.createElement('th');
            cell.setAttribute('id', attrID);
            cell.setAttribute('nowrap', 'nowrap');
            cell.onclick = function()
            {
                sortTable(this.id);
            }
            cell.setAttribute('title', "Click to sort");
            cell.setAttribute(attrClass, "headerTH");
            cell.onmouseover = function()
            {
                popUp(this.id);
            }
            cell.onmouseout = function()
            {
                popOff(this.id);
            }
            
            if (attrID == orderBy) 
            {
                var sImage = document.createElement('img');
                if (orderByDir == 'DESC') 
                {
                    sImage.src = thissite + "/images/arrowDesc.gif"
                }
                else 
                {
                    sImage.src = thissite + "/images/arrowAsc.gif"
                }
                
                cell.appendChild(sImage);
                cell.appendChild(document.createTextNode('  '));
            }
            
            break;
        default:
            var cell = document.createElement('td');
            cell.setAttribute('nowrap', 'nowrap');
            cell.setAttribute('id', attrID);
            if (attrID.substr(0, 9) == 'CUSTOMIZE') 
            {
                var idNUM = attrID.substr(9);
                cell.onclick = function()
                {
                    //createGear(idNUM, false);
                    customize(idNUM);
                }
                cell.setAttribute(attrClass, 'cadLink');
            }
            
            if (attrID.substr(0, 5) == 'QUOTE') 
            {
                var idNUM = attrID.substr(5);
                var quoteBox = document.createElement('input');
                quoteBox.type = "checkBox";
                quoteBox.name = "quote" + attrID;
                quoteBox.value = $('PARTNO' + idNUM).innerHTML;
                quoteBox.setAttribute('id', attrID + 'a');
                quoteBox.onclick = function()
                {
                    addToQuoteFile(this.id, this.value);
                }
                cell.setAttribute(attrClass, 'cadLink');
                cell.appendChild(quoteBox);
            }
            
            gtype = $('mainGearType').value.toLowerCase();
            if (gtype == 'spur' || gtype == 'helical') 
            {
                if (attrID.substr(0, 2) == 'HT') 
                {
                    //cell.onmouseover = function(){getHP(attrID);}
                    cell.onmousedown = function()
                    {
                        getHP(attrID);
                    }
                    cell.setAttribute(attrClass, 'cadLink');
                }
                
                if (attrID.substr(0, 5) == 'PRICE') 
                {
                    cell.onclick = function()
                    {
                        getPricing(attrID);
                    }
                    cell.setAttribute(attrClass, 'cadLink');
                }
            }
            
            if(hasCad.indexOf(gtype) > -1)
			{
                if (attrID.substr(0, 3) == 'CAD') 
                {
                    cell.onclick = function()
                    {
                        showCadChoice(attrID);
                    }
                    cell.setAttribute(attrClass, 'cadLink');
                }
            }
            else 
            {
                if (attrID.substr(0, 3) == 'CAD') 
                {
                    cell.onmouseover = function()
                    {
                        cadLinkD(attrID);
                    }
                    cell.onmouseout = function()
                    {
                        cadLinkD(attrID);
                    }
                    cell.setAttribute(attrClass, 'cadLinkD');
                }
            }
    }
    
    cell.appendChild(document.createTextNode(txt));
    return cell;
}

function sortTable(headerId)
{
    if (orderByDir == 'DESC') 
    {
        orderByDir = 'ASC';
    }
    else 
    {
        orderByDir = 'DESC';
    }
    
    popOff(headerId);
    sortHolder = $('sortHolder');
    sortHolder.value = headerId;
    sortDirHolder = $('sortDirHolder');
    sortDirHolder.value = orderByDir;
    changeMenus('none', headerId, orderByDir);
}

function getPricing(id)
{
    //alert(id);
}

function popOff(headerId)
{
    $('headerMsg').style.width = '';
    $('headerMsg').style.display = 'none';
    hideLoadmsgIframe = browserName == 'msie' ? $('iframeForIE').style.display = 'none' : 0;
}

function popUp(headerId)
{
    if (browserName == 'msie') 
    {
        minusBy = 35;
    }
    else 
    {
        minusBy = 35;
    }
    
    var headerMsg = $('headerMsg');
    var headerCell = $(headerId);
    var cellLeft = findPosX(headerCell);
    var cellTop = findPosY(headerCell);
    
    headerMsg.style.display = '';
    //headerMsg.visualEffect('BlindUp');
    headerMsg.style.top = parseInt(cellTop) - minusBy + 'px';
    headerMsg.style.left = cellLeft + 'px';
    
    imgText = '';
    loadmsgIframe = $('iframeForIE');
    var gearType = $('mainGearType').value.replaceWS();
    if (gearType == 'BEVEL/MITER') 
    {
        gearType = 'BEVEL';
    }
    
    switch (headerId)
    {
        case 'PARTNO':
            msgText = 'Part Number';
            imgName = '';
            imgH = 50;
            imgW = '';
            imgText = '';
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'PA':
            msgText = 'Pressure Angle';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Pressure Angle\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'STYLE':
            msgText = '';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Hub Style A-NONE, B-ONE, C-TWO\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
                msgText = 'Hub Style A-NONE, B-ONE, C-TWO';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'PD':
            msgText = 'Pitch Diameter';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Pitch Diameter\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'BORE':
            msgText = 'Inside Diameter';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Bore Diameter\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'FACE':
            msgText = 'Face Width';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Face Width\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'HD':
            msgText = 'Hub Diameter';
            imgName = imageArray[gearType + headerId];
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Hub Diameter\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'HP':
            msgText = 'Hub Projection';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Hub Projection\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'OAL':
            msgText = 'Overall Length';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Overall Length\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'OD':
            msgText = 'Outside Diameter';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Outside Diameter\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'HAND':
            msgText = 'Direction of Angle (left\/right)';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Direction of Tooth\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'HA':
            if (gearType == "HELICAL") 
            {
                msgText = 'Helix Angle';
            }
            if (gearType == "WORM") 
            {
                msgText = 'Lead Angle';
            }
            if (gearType == "SPIRALMITER") 
            {
                msgText = 'Spiral Angle';
            }
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Angle of the Tooth\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'LA':
            if (gearType == "WORM" || gearType == "WORM GEAR") 
            {
                msgText = 'Lead Angle';
            }
            if (gearType == "SPIRALMITER") 
            {
                msgText = 'Spiral Angle';
            }
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Angle of the Tooth\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'STARTS':
            msgText = '# of threads on a worm';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"# threads on a worm\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'MATEPD':
            msgText = 'Pitch Diamter of Mating Gear';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Pitch Diameter of Mating Part\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'CD':
            msgText = 'Center Distance';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Center Distance\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'NORMP':
            msgText = 'Normal Pitch';
            imgName = '';
            imgH = 50;
            imgW = '';
            imgText = '';
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'KWY':
            msgText = 'Keyway';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Keyway\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'KWY2':
            msgText = '2nd Keyway at 180�';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Keyway2\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'MD':
            msgText = 'Mounting Distance';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Mounting Distance\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'WORMLEAD':
            msgText = 'Lead of Worm';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Lead of Worm\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'LEAD':
            msgText = 'Lead';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Lead\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'PLINE':
            msgText = 'Pitch Line to Back';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Pitch line to back\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'STEMLEN':
            msgText = 'Length of Stem (shaft)';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"stem length\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'STEMOD':
            msgText = 'Outside Diameter of Journal';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"Outside Diameter of Journal\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'CAD':
            msgText = '3D models and 2D drawings';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'CUSTOMIZE':
            msgText = 'Customize these parts';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/customScreen.gif\" alt=\"\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'TEETH':
            msgText = '# of Teeth';
            imgName = '';
            imgH = 50;
            imgW = '';
            imgText = '';
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'MATEPN':
            msgText = 'Mating Part#';
            imgName = '';
            imgH = 50;
            imgW = '';
            imgText = '';
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'RATIO':
            msgText = '# of Teeth in Gear <br />in relation to # of teeth in Pinion';
            imgName = '';
            imgH = 50;
            imgW = '';
            imgText = '';
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'HT':
            msgText = 'Horsepower &amp; Torque';
            imgName = '';
            imgH = 50;
            imgW = '';
            imgText = '';
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'PITCH':
            msgText = 'DIAMETRAL PITCH - STANDARD <BR />MODULE PITCH - METRIC';
            imgName = '';
            imgH = 50;
            imgW = '';
            imgText = '';
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        case 'QUOTE':
            msgText = 'Add to Request-For-Quote';
            imgName = imageArray[gearType + headerId];
            if (imgName) 
            {
                imgH = parseInt(imgName.height) + 50;
                imgW = parseInt(imgName.width);
                imgText = '<img src=\"/images/' + gearType + headerId + '.gif\" alt=\"add to quote\" /><br />';
            }
            else 
            {
                imgH = '50';
                imgW = '25';
                imgText = '';
            }
            imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgName, imgText);
            break;
        default:
            msgText = headerId;
    }
}

function imageCTRL(cellTop, cellLeft, imgH, imgW, headerMsg, imgObj, imgText)
{
    var windowedge = ie4 && !window.opera ? iecompattest().scrollLeft + iecompattest().clientWidth - 15 : window.pageXOffset + window.innerWidth - 15;
    var leftPosImgW = parseInt(cellLeft) + parseInt(imgW);
    
    if (leftPosImgW > windowedge) 
    {
        cellLeft = cellLeft - (leftPosImgW - windowedge + 25);
    }
    
    headerMsg.style.top = parseInt(cellTop) - parseInt(imgH) + 'px';
    headerMsg.style.left = cellLeft + 'px';
    
    headerMsg.innerHTML = imgText + msgText;
    if (imgObj && browserName == 'msie') 
    {
        if (imgW) 
        {
            headerMsg.style.width = parseInt(imgW) + 20 + 'px';
            hWidth = headerMsg.style.width;
        }
        
        loadmsgIframe = $('iframeForIE');
        var loadmsgIframe = browserName == 'msie' ? $('iframeForIE') : 0;
        showLoadmsgIframe = browserName == 'msie' ? loadmsgIframe.style.display = '' : 0;
        loadmsgIframeTop = browserName == 'msie' ? loadmsgIframe.style.top = parseInt(cellTop) - parseInt(imgH) + 'px' : 0;
        loadmsgIframeLeft = browserName == 'msie' ? loadmsgIframe.style.left = cellLeft + 'px' : 0;
        loadmsgIframeWidth = browserName == 'msie' ? loadmsgIframe.style.width = hWidth : 0;
        loadmsgIframeHeight = browserName == 'msie' ? loadmsgIframe.style.height = parseInt(headerMsg.offsetHeight) - 15 + 'px' : 0;
    }
}


