function calculateBoardFeet()
{
    for(x=0;x<=17;x++){
    var isChecked = document.forms["boardfoot"].elements["dimension"].item(x).checked
        if(isChecked)break;
        else{
        alert("Please select a dimension for your lumber");
        break;
        }
    }
    var boardLength = document.getElementById("length");
}

// ---------------End Board Foot Calculator----------Begin Span Calculator----------------------
function setFields() {
            var myurl = document.URL;
            vars = myurl.split("?");
            if(vars[1] != null) {
                vars = vars[1];
                properties = vars.split("&");
                for(i=0;i<properties.length-1;i++) {
                    myvar = properties[i].split("=");
                    setIndex = eval("document.form1." + myvar[0] + ".length");
                    if(myvar[1] != "") {
                        if(myvar[0] == "snowload" && myvar[1] != "-1") {
                                if(!isNaN(Number(myvar[1]))) {
                                    document.form1.snowloadtext.value = myvar[1];
                                    document.getElementById("hiddentextSpan").style.display = "block";
                                    document.getElementById("hiddenselectSpan").style.display = "none";
                                    document.getElementById("hiddenheadingSpan").innerHTML = "Snow Load (psf)";
                                    document.getElementById("hiddenheadingSpan").title = "Code-specified snow load on roof system";
                                }
                        }
                        else {
                            myvar[1] = unescape(myvar[1]);
                            someVar = myvar[1].split("+");
                            myvar[1] = someVar[0];
                            for(k=1;k<someVar.length;k++)
                                myvar[1] = myvar[1] + " " + someVar[k];
                            for(j=0;j<setIndex;j++) {
                                    if(myvar[1] == eval("document.form1." + myvar[0] + "[" + j + "].value")) {
                                        //alert("FOUND IT!\nmyvar[1]: " + myvar[1] + "\nvalue: " + eval("document.form1." + myvar[0] + "[" + j + "].value"));
                                        eval("document.form1." + myvar[0] + ".selectedIndex = " + j);
                                        break;
                                    }
                            }
                        }
                    }
                }
            }
        }
    function adjust() {
        var sel = document.form1.grade;
        var spec = document.form1.species;
        var siz = document.form1.size;

        // delete all options
        tempvalue = sel.value;
        sel.length = 0
        
        if(spec.value == "Douglas Fir-Larch" || spec.value == "Hem-Fir" || spec.value == "Spruce-Pine-Fir") {
            sel.options[sel.options.length] = new Option('Select Structural', 'Select Structural');
            if(spec.value == "Douglas Fir-Larch" || spec.value == "Hem-Fir") {
                sel.options[sel.options.length] = new Option('No. 1 & Btr', 'No. 1 & Btr');
            }
            sel.options[sel.options.length] = new Option('No. 1', 'No. 1');
            sel.options[sel.options.length] = new Option('No. 2', 'No. 2');
            sel.options[sel.options.length] = new Option('No. 3', 'No. 3');
            sel.options[sel.options.length] = new Option('Stud', 'Stud');
            if (siz.value == "2x4") {
                sel.options[sel.options.length] = new Option('Construction', 'Construction');
                sel.options[sel.options.length] = new Option('Standard', 'Standard');
                sel.options[sel.options.length] = new Option('Utility', 'Utility');
            }
            sel.options[sel.options.length] = new Option('1450f-1.3E (MSR)', '1450f-1.3E (MSR)');
            sel.options[sel.options.length] = new Option('1650f-1.5E (MSR)', '1650f-1.5E (MSR)');
            sel.options[sel.options.length] = new Option('1800f-1.6E (MSR)', '1800f-1.6E (MSR)');
            sel.options[sel.options.length] = new Option('1950f-1.7E (MSR)', '1950f-1.7E (MSR)');
            sel.options[sel.options.length] = new Option('2100f-1.8E (MSR)', '2100f-1.8E (MSR)');
            sel.options[sel.options.length] = new Option('2250f-1.9E (MSR)', '2250f-1.9E (MSR)');
            sel.options[sel.options.length] = new Option('2400f-2.0E (MSR)', '2400f-2.0E (MSR)');
            sel.options[sel.options.length] = new Option('2850f-2.3E (MSR)', '2850f-2.3E (MSR)');
            sel.options[sel.options.length] = new Option('M-10 (MEL)', 'M-10 (MEL)');
            sel.options[sel.options.length] = new Option('M-12 (MEL)', 'M-12 (MEL)');
            sel.options[sel.options.length] = new Option('M-19 (MEL)', 'M-19 (MEL)');
            sel.options[sel.options.length] = new Option('M-23 (MEL)', 'M-23 (MEL)');
            sel.options[sel.options.length] = new Option('M-29 (MEL)', 'M-29 (MEL)');
            sel.options[sel.options.length] = new Option('M-30 (MEL)', 'M-30 (MEL)');
            sel.options[sel.options.length] = new Option('M-31 (MEL)', 'M-31 (MEL)');
        }
        //else if (spec.value == "Douglas Fir-Larch" || spec.value == "Hem-Fir" || spec.value == "Douglas Fir-Larch (North)" || spec.value == "Hem-Fir (North)") {
        else if (spec.value == "Douglas Fir-Larch (North)" || spec.value == "Hem-Fir (North)") {
            sel.options[sel.options.length] = new Option('Select Structural', 'Select Structural');
            sel.options[sel.options.length] = new Option('No. 1 & Btr', 'No. 1 & Btr');
            sel.options[sel.options.length] = new Option('No. 1', 'No. 1');
            sel.options[sel.options.length] = new Option('No. 2', 'No. 2');
            sel.options[sel.options.length] = new Option('No. 3', 'No. 3');
            sel.options[sel.options.length] = new Option('Stud', 'Stud');
            if (siz.value == "2x4") {
                sel.options[sel.options.length] = new Option('Construction', 'Construction');
                sel.options[sel.options.length] = new Option('Standard', 'Standard');
                sel.options[sel.options.length] = new Option('Utility', 'Utility');
            }
        }
        else if (spec.value == "Redwood") {
            sel.options[sel.options.length] = new Option('Clear Structural', 'Clear Structural');
            sel.options[sel.options.length] = new Option('Select Structural, open grain', 'Select Structural, open grain');
            sel.options[sel.options.length] = new Option('Select Structural', 'Select Structural');
            sel.options[sel.options.length] = new Option('No. 1, open grain', 'No. 1, open grain');
            sel.options[sel.options.length] = new Option('No. 1', 'No. 1');
            sel.options[sel.options.length] = new Option('No. 2, open grain', 'No. 2, open grain');
            sel.options[sel.options.length] = new Option('No. 2', 'No. 2');
            sel.options[sel.options.length] = new Option('No. 3, open grain', 'No. 3, open grain');
            sel.options[sel.options.length] = new Option('No. 3', 'No. 3');
            sel.options[sel.options.length] = new Option('Stud', 'Stud');
            if (siz.value == "2x4") {
                sel.options[sel.options.length] = new Option('Construction', 'Construction');
                sel.options[sel.options.length] = new Option('Standard', 'Standard');
                sel.options[sel.options.length] = new Option('Utility', 'Utility');
            }
        }
        /*
        else if (spec.value == "MSR Southern Pine" || spec.value == "MSR Hem-Fir" || spec.value == "MSR Spruce-Pine-Fir" || spec.value == "MSR Douglas Fir-Larch") {
            sel.options[sel.options.length] = new Option('1450f-1.3E', '1450f-1.3E');
            sel.options[sel.options.length] = new Option('1650f-1.5E', '1650f-1.5E');
            sel.options[sel.options.length] = new Option('1800f-1.6E', '1800f-1.6E');
            sel.options[sel.options.length] = new Option('1950f-1.7E', '1950f-1.7E');
            sel.options[sel.options.length] = new Option('2100f-1.8E', '2100f-1.8E');
            sel.options[sel.options.length] = new Option('2250f-1.9E', '2250f-1.9E');
            sel.options[sel.options.length] = new Option('2400f-2.0E', '2400f-2.0E');
            sel.options[sel.options.length] = new Option('2850f-2.3E', '2850f-2.3E');
        }
        else if (spec.value == "MEL Southern Pine" || spec.value == "MEL Hem-Fir" || spec.value == "MEL Spruce-Pine-Fir" || spec.value == "MEL Douglas Fir-Larch") {
            sel.options[sel.options.length] = new Option('M-10', 'M-10');
            sel.options[sel.options.length] = new Option('M-12', 'M-12');
            sel.options[sel.options.length] = new Option('M-19', 'M-19');
            sel.options[sel.options.length] = new Option('M-23', 'M-23');
            sel.options[sel.options.length] = new Option('M-29', 'M-29');
            sel.options[sel.options.length] = new Option('M-30', 'M-30');
            sel.options[sel.options.length] = new Option('M-31', 'M-31');
        }
        */
        else if (spec.value == "Southern Pine") {
            sel.options[sel.options.length] = new Option('Dense Select Structural', 'Dense Select Structural');
            sel.options[sel.options.length] = new Option('Select Structural', 'Select Structural');
            sel.options[sel.options.length] = new Option('Non-Dense Select Structural', 'Non-Dense Select Structural');
            sel.options[sel.options.length] = new Option('No. 1 Dense', 'No. 1 Dense');
            sel.options[sel.options.length] = new Option('No. 1', 'No. 1');
            sel.options[sel.options.length] = new Option('No. 1 Non-Dense', 'No. 1 Non-Dense');
            sel.options[sel.options.length] = new Option('No. 2 Dense', 'No. 2 Dense');
            sel.options[sel.options.length] = new Option('No. 2', 'No. 2');
            sel.options[sel.options.length] = new Option('No. 2 Non-Dense', 'No. 2 Non-Dense');
            sel.options[sel.options.length] = new Option('No. 3', 'No. 3');
            sel.options[sel.options.length] = new Option('Stud', 'Stud');
            if (siz.value == "2x4") {
                sel.options[sel.options.length] = new Option('Construction', 'Construction');
                sel.options[sel.options.length] = new Option('Standard', 'Standard');
                sel.options[sel.options.length] = new Option('Utility', 'Utility');
            }
            sel.options[sel.options.length] = new Option('1450f-1.3E (MSR)', '1450f-1.3E (MSR)');
            sel.options[sel.options.length] = new Option('1650f-1.5E (MSR)', '1650f-1.5E (MSR)');
            sel.options[sel.options.length] = new Option('1800f-1.6E (MSR)', '1800f-1.6E (MSR)');
            sel.options[sel.options.length] = new Option('1950f-1.7E (MSR)', '1950f-1.7E (MSR)');
            sel.options[sel.options.length] = new Option('2100f-1.8E (MSR)', '2100f-1.8E (MSR)');
            sel.options[sel.options.length] = new Option('2250f-1.9E (MSR)', '2250f-1.9E (MSR)');
            sel.options[sel.options.length] = new Option('2400f-2.0E (MSR)', '2400f-2.0E (MSR)');
            sel.options[sel.options.length] = new Option('2850f-2.3E (MSR)', '2850f-2.3E (MSR)');
            sel.options[sel.options.length] = new Option('M-10 (MEL)', 'M-10 (MEL)');
            sel.options[sel.options.length] = new Option('M-12 (MEL)', 'M-12 (MEL)');
            sel.options[sel.options.length] = new Option('M-19 (MEL)', 'M-19 (MEL)');
            sel.options[sel.options.length] = new Option('M-23 (MEL)', 'M-23 (MEL)');
            sel.options[sel.options.length] = new Option('M-29 (MEL)', 'M-29 (MEL)');
            sel.options[sel.options.length] = new Option('M-30 (MEL)', 'M-30 (MEL)');
            sel.options[sel.options.length] = new Option('M-31 (MEL)', 'M-31 (MEL)');
        }
        else {
            sel.options[sel.options.length] = new Option('Select Structural', 'Select Structural');
            sel.options[sel.options.length] = new Option('No. 1', 'No. 1');
            sel.options[sel.options.length] = new Option('No. 2', 'No. 2');
            sel.options[sel.options.length] = new Option('No. 3', 'No. 3');
            sel.options[sel.options.length] = new Option('Stud', 'Stud');
            if (siz.value == "2x4") {
                sel.options[sel.options.length] = new Option('Construction', 'Construction');
                sel.options[sel.options.length] = new Option('Standard', 'Standard');
                sel.options[sel.options.length] = new Option('Utility', 'Utility');
            }
        }
        
        // sets the grade value back to what it was prior to the drop-down wipe
        var found = 0;
        for(i=0;i<sel.length;i++) {
            if(sel.options[i].value == tempvalue) {
                sel.selectedIndex = i;
                found = 1;
                break;
            }
        }
        if(found == 0) {
            //alert("The previously selected Grade is not available for the new Species and/or Size selection. Please select another Grade.");
            notice.innerHTML = "Select a new grade. The previously selected value is not available for this size/species combination."
            notice.style.visibility = "visible";
        }
            
        if (navigator.appName == 'Netscape' &&
            (navigator.appVersion.indexOf('Win') != -1 ||
            navigator.appVersion.indexOf('Mac') != -1)) {
            window.resizeBy(-1,-1);
            window.resizeBy(1,1);
        }
    }
    
    function setdefaults()
    {
        var spacing = document.form1.spacing;
        var liveload = document.form1.liveload;
        var deadload = document.form1.deadload;
        var index = document.form1.member.selectedIndex;
        
        if(index == 0) { //floor joists
            liveload.length = 0;
            liveload.options[liveload.options.length] = new Option('30','30');
            liveload.options[liveload.options.length] = new Option('40','40');
            liveload.options[liveload.options.length] = new Option('50','50');
            liveload.options[liveload.options.length] = new Option('60','60');
            liveload.options[liveload.options.length] = new Option('70','70');
            liveload.options[liveload.options.length] = new Option('80','80');
            liveload.options[liveload.options.length] = new Option('90','90');
            liveload.options[liveload.options.length] = new Option('100','100');
            
            //set to the default values            
            spacing.selectedIndex = 1;
            liveload.selectedIndex = 1;
            deadload.selectedIndex = 2;
            
            //show the correct display (either live load select or snow load textbox
            if (document.layers) {
                if(document.layers["hiddentextSpan"])
                    document.layers["hiddentextSpan"].visibility = "hidden";
                if(document.form1.snowloadtext)
                    document.form1.snowloadtext.value = "-1";
                if(document.layers["hiddenselectSpan"])
                    document.layers["hiddentextSpan"].visibility = "visible";
                if(document.layers["hiddenheadingSpan"])
                    document.layers["hiddenheadingSpan"].innerHTML = "Live Load (psf)";
                if(document.layers["hiddenheadingSpan"])
                    document.layers["hiddenheadingSpan"].title = "Code-specified live load on floor, ceiling, or roof systems";
                    
            }
            else {
                document.getElementById("hiddentextSpan").style.display = "none";
                document.form1.snowloadtext.value = "-1";
                document.getElementById("hiddenselectSpan").style.display = "block";
                document.getElementById("hiddenheadingSpan").innerHTML = "Live Load (psf)";
                document.getElementById("hiddenheadingSpan").title = "Code-specified live load on floor, ceiling, or roof systems";
            }            
        }
        else if(index == 2){
            liveload.length = 0;
            liveload.options[liveload.options.length] = new Option('10','10');
            liveload.options[liveload.options.length] = new Option('20','20');
            liveload.options[liveload.options.length] = new Option('30','30');
            liveload.options[liveload.options.length] = new Option('40','40');
            liveload.options[liveload.options.length] = new Option('50','50');
            liveload.options[liveload.options.length] = new Option('60','60');
            liveload.options[liveload.options.length] = new Option('70','70');
            liveload.options[liveload.options.length] = new Option('80','80');
            liveload.options[liveload.options.length] = new Option('90','90');
            liveload.options[liveload.options.length] = new Option('100','100');
            
            //set to default values
            spacing.selectedIndex = 3;
            liveload.selectedIndex = 1;
            deadload.selectedIndex = 2;
            
            if (document.layers) {
                if(document.layers["hiddentextSpan"])
                    document.layers["hiddentextSpan"].visibility = "visible";
                if(document.form1.snowloadtext)
                    document.form1.snowloadtext.value = "20";
                if(document.layers["hiddenselectSpan"])
                    document.layers["hiddentextSpan"].visibility = "hidden";
                if(document.layers["hiddenheadingSpan"])
                    document.layers["hiddenheadingSpan"].innerHTML = "Snow Load (psf)";
                if(document.layers["hiddenheadingSpan"])
                    document.layers["hiddenheadingSpan"].title = "Code-specified snow load on roof system";
                    
            }
            else {
                document.getElementById("hiddentextSpan").style.display = "block";
                document.form1.snowloadtext.value = "20";
                document.getElementById("hiddenselectSpan").style.display = "none";
                document.getElementById("hiddenheadingSpan").innerHTML = "Snow Load (psf)";
                document.getElementById("hiddenheadingSpan").title = "Code-specified snow load on roof system";
            }
        }
        else{
            liveload.length = 0;
            liveload.options[liveload.options.length] = new Option('10','10');
            liveload.options[liveload.options.length] = new Option('20','20');
            liveload.options[liveload.options.length] = new Option('30','30');
            liveload.options[liveload.options.length] = new Option('40','40');
            liveload.options[liveload.options.length] = new Option('50','50');
            liveload.options[liveload.options.length] = new Option('60','60');
            liveload.options[liveload.options.length] = new Option('70','70');
            liveload.options[liveload.options.length] = new Option('80','80');
            liveload.options[liveload.options.length] = new Option('90','90');
            liveload.options[liveload.options.length] = new Option('100','100');
            
            //set to default values
            spacing.selectedIndex = 3;
            liveload.selectedIndex = 1;
            deadload.selectedIndex = 2;
            
            if (document.layers) {
                if(document.layers["hiddentextSpan"])
                    document.layers["hiddentextSpan"].visibility = "hidden";
                if(document.form1.snowloadtext)
                    document.form1.snowloadtext.value = "-1";
                if(document.layers["hiddenselectSpan"])
                    document.layers["hiddentextSpan"].visibility = "visible";
                if(document.layers["hiddenheadingSpan"])
                    document.layers["hiddenheadingSpan"].innerHTML = "Live Load (psf)";
                if(document.layers["hiddenheadingSpan"])
                    document.layers["hiddenheadingSpan"].title = "Code-specified live load on floor, ceiling, or roof systems";
                    
            }
            else {
                document.getElementById("hiddentextSpan").style.display = "none";
                document.form1.snowloadtext.value = "-1";
                document.getElementById("hiddenselectSpan").style.display = "block";
                document.getElementById("hiddenheadingSpan").innerHTML = "Live Load (psf)";
                document.getElementById("hiddenheadingSpan").title = "Code-specified live load on floor, ceiling, or roof systems";
            }    
        }
    }
    function popup(spanArg)
    {
        myarg = document.getElementById(spanArg.id);
        var str = '';
        var title = myarg.innerHTML;
        
        if(myarg.innerHTML == "Species")
            str = title + "\n\nSelect the species combination (indicated on lumber grade stamp) for lumber joists or rafters.";
        else if(myarg.innerHTML == "Size")
            str = title + "\n\nSelect the nominal size of lumber joists or rafters. NOTE: Selection is limited to 2x4, 2x6, 2x8, 2x10 or 2x12."
        else if(myarg.innerHTML == "Grade")
            str = title + "\n\nSelect the grade of lumber to be used as joists or rafters. NOTE: 2x4 lumber is the only selection available for Construction, Standard, and Utility grades.";
        else if(myarg.innerHTML == "Member Type")
            str = title + "\n\nSelect either floor joists, ceiling joists, rafters supporting snow load, or rafters supporting roof live load.";
        else if(myarg.innerHTML == "Deflection Limit")
            str = title + "\n\nSelect the code-specified deflection limit for joists or rafters. NOTE: Only the deflection due to live load or snow load is considered.";
        else if(myarg.innerHTML == "Spacing (in)")
            str = title + "\n\nSelect the center-to-center spacing between joists or rafters.";
        else if(myarg.innerHTML == "Exterior Exposure")
            str = title + "\n\nIndicate whether the lumber joists or rafters will be exposed to wet service conditions. Also indicate whether the joists or rafters will be incised, preservative-treated lumber.";
        else if(myarg.innerHTML == "Live Load (psf)")
            str = title + "\n\nSelect the code-specified maximum live load (in units of pounds per square foot) for the floor, ceiling, or roof system.";
        else if(myarg.innerHTML == "Snow Load (psf)")
            str = title + "\n\nIndicate the code-specified maximum snow load (in units of pounds per square foot) for the roof system.";
        else if(myarg.innerHTML == "Dead Load (psf)")
            str = title + "\n\nSelect the dead load (including self-weight of lumber and sheathing) of the floor, ceiling, or roof system (in units of pounds per square foot).";
        alert(str);
    }

    var isIE=document.all?true:false;
    var isNS4=document.layers?true:false;
    var isNS6=navigator.userAgent.indexOf("Gecko")!=-1?true:false;

    function clearResults()
    {
        var _obj = null;
        //_obj = document.getElementById("answerDiv");
        //alert(_obj);
        if(isIE||isNS6)
            _obj = document.getElementById("answerDiv");
        else if(isNS4) {
            //alert("Make sure you Calculate the results again before printing the page.");
            document.layers["answerDiv"].visibility = "hidden";
            //_obj = answerDiv;
        }
        if(_obj)
        {
        _obj.innerHTML="";
      }
    }
    
    function clearNotice()
    {
        if(notice) {
            notice.style.visibility = "hidden";
        }
    }
// ---------------End Span Calculator----------Begin Stud Length Calculator----------------------
