// JavaScript Document

function loadList(list, listVintQty){
    var lo = document.VintQty[listVintQty];
    var option;
    for (i = 0 ; i < list.length; i++){
        option = new Option(
                list[i].VintQty, //VintQty
                i, //value
                false, //The default selected property
                false); //The selected property
        lo.options.add(option);
    } // end for
    return;
}

function loadStuff(){
    loadList(itemvintListOne, "vintList_One");
    loadList(itemvintListTwo, "vintList_Two");
    loadList(itemvintListThree, "vintList_Three");
    loadList(itemvintListFour, "vintList_Four");
    addFunc(); //Default Added Items
    return;
}

function addFunc(){
    var select1Index = document.VintQty.vintList_One.selectedIndex;
    var select2Index = document.VintQty.vintList_Two.selectedIndex;
    var select3Index = document.VintQty.vintList_Three.selectedIndex;
    var select4Index = document.VintQty.vintList_Four.selectedIndex;
    var divEl = document.getElementById("update_fields");
    while (divEl.lastChild) divEl.removeChild(divEl.lastChild);
    var inHTML;
    //alert("Called add Function:" + itemvintListThree[select3Index].type);
    if( select3Index > -1 && select1Index > -1 && select2Index > -1 && select4Index > -1){
        if (itemvintListThree[select3Index].type == 'len'){
            var value= itemvintListThree[select3Index].len + itemvintListOne[select1Index].len + itemvintListTwo[select2Index].len + itemvintListFour[select4Index].len;
            //alert("value:" + value);
            inHTML = "<hr/>height: <span>";
            inHTML += value;
            inHTML += "</span>"
        } else {
            var min=itemvintListThree[select3Index].min + itemvintListOne[select1Index].len + itemvintListTwo[select2Index].len + itemvintListFour[select4Index].len;
            var max=itemvintListThree[select3Index].max + itemvintListOne[select1Index].len + itemvintListTwo[select2Index].len + itemvintListFour[select4Index].len;                          
            inHTML = "<hr/>min. height: <span>";
            inHTML += min;
            inHTML += "</span> max. height: <span>";
            inHTML += max;
            inHTML += "</span>";
        }
    }
    divEl.innerHTML = inHTML;
    divEl.visible = true;
        
    return;
}
var itemvintListOne = [
    { 'VintQty':'0', 'len':0.0},
    { 'VintQty':'1', 'len':35.9375},
    { 'VintQty':'2', 'len':71.875},
    { 'VintQty':'3', 'len':107.8125}
];

var itemvintListTwo = [
    { 'VintQty':'0', 'len':0.0},
    { 'VintQty':'1', 'len':47.1875},
    { 'VintQty':'2', 'len':94.375},
    { 'VintQty':'3', 'len':141.5625}
];

var itemvintListThree = [
    { 'VintQty':'none', 'type':'len', 'len':0.0 },
    { 'VintQty':'2 1/16 Ogee', 'type':'max', 'min':.625, 'max':1.1875 },
    { 'VintQty':'JD', 'type':'max', 'min':0.0, 'max':.8125 },
    { 'VintQty':'Beaded',  'type':'max', 'min':1.8125, 'max':2.5625 },
    { 'VintQty':'Beaded w/ JD', 'type':'max', 'min':1.8125, 'max':3.375 },
    { 'VintQty':'Grande', 'type':'max', 'min':2.1875, 'max':2.875 },
    { 'VintQty':'Beaded w/ Grande', 'type':'max', 'min':3.625, 'max':5.4375 }
             
];

var itemvintListFour = [
    { 'VintQty':'none', 'len':0.0},
    { 'VintQty':'1 7/16', 'len':0},
    { 'VintQty':'5 1/4', 'len':3.8125}
];
