//global array of Product Lines
var productlinesArray = new Array();
var productlinesArrayCounter = 0;
//end

//global array of Products
var productsArray = new Array();
var productsArrayCounter = 0;
//end

//global array of Checkboxes
var checkboxArray = new Array(); 
var checkboxArrayCounter = 0;
//end

//checks to see if any of the Product Line or Product checkboxes are selected
function reviewCheckboxSelection() {
    for(i=0; i<checkboxArray.length; i++) {
        checkedStatus=document.getElementById(checkboxArray[i]).checked;
        if (checkedStatus==true) break;
    }
    if(checkedStatus==true) return true;
    else return false;
}
//end

function openProdList(DivID) {
    document.getElementById('productlist_'+DivID).style.display='block';
    document.getElementById('openlist_'+DivID).style.display='none';
    document.getElementById('closelist_'+DivID).style.display='block';
}

function closeProdList(DivID) {
    document.getElementById('productlist_'+DivID).style.display='none';
    document.getElementById('openlist_'+DivID).style.display='block';
    document.getElementById('closelist_'+DivID).style.display='none';
}

//selects the specified Product Area checkbox when user selects a product checkbox
function selectAreaCheckbox (AreaCheckboxID,ProdCheckboxID) {
    document.getElementById(AreaCheckboxID).checked = 'checked';
    for(i=0; i<productlinesArray.length; i++){
        document.getElementById('checkbox_'+productlinesArray[i]+'_1').style.background = '';
        document.getElementById('hdg_'+productlinesArray[i]).style.color = '#666666';
    }
}
//end

function deselectAllCheckboxes() {
    for(i=0; i<productlinesArray.length; i++){
        document.getElementById('checkbox_'+productlinesArray[i]+'_1').style.background = '';
        document.getElementById('hdg_'+productlinesArray[i]).style.color = '#666666';
    }
}
//selects the specified Product Area checkbox when user selects a product description
function textselectAreaCheckbox (AreaCheckboxID,ProdCheckboxID) {
    checkedStatus=document.getElementById(ProdCheckboxID).checked;
    if(checkedStatus==false){
        document.getElementById(AreaCheckboxID).checked = 'checked';
    }
    for(i=0; i<productlinesArray.length; i++){
        document.getElementById('checkbox_'+productlinesArray[i]+'_1').style.background = '';
        document.getElementById('hdg_'+productlinesArray[i]).style.color = '#666666';
    }
}
//end

//toggles the specified checkbox on/off when user selects related text label
function toggleCheckbox (CheckboxID) {
    checkedStatus=document.getElementById(CheckboxID).checked;
    if (checkedStatus==false) {
        document.getElementById(CheckboxID).checked = 'checked';
    }
    else {
        document.getElementById(CheckboxID).checked = '';
    }
    for(i=0; i<productlinesArray.length; i++){
        document.getElementById('checkbox_'+productlinesArray[i]+'_1').style.background = '';
        document.getElementById('hdg_'+productlinesArray[i]).style.color = '#666666';
    }
}
//end

// parses all the Product Line checkboxes and populates the hidden "Selected Product Lines" field with the values of the selected items for Eloqua form processing
function findSelectedProductLines() {
    var selectedProductLines = document.forms['form1'].elements['00N60000001TjOd'].value;
    for(i=0; i<productlinesArray.length; i++){
        currentProductAreaCheckbox = 'checkbox_' + productlinesArray[i] + '_1';
        if(document.getElementById(currentProductAreaCheckbox).checked==true){
            if(selectedProductLines == '') {
                selectedProductLines = selectedProductLines + document.getElementById(currentProductAreaCheckbox).value;
            }
            else {
                selectedProductLines = selectedProductLines + "," + document.getElementById(currentProductAreaCheckbox).value;
            }
        }
    }
    document.forms['form1'].elements['00N60000001TjOd'].value = selectedProductLines;
}
//end

//parses all the Product checkboxes on the page and populates the hidden "Selected Products" field with the values of selected items for Eloqua form processing
function findSelectedProducts() {
    var selectedProducts = document.forms['form1'].elements['product_interest'].value;
    for(i=0; i<productsArray.length; i++) {
        if(document.getElementById(productsArray[i]).checked==true){
            if(selectedProducts == '') {
                selectedProducts = selectedProducts + document.getElementById(productsArray[i]).value;
            }
            else {
                selectedProducts = selectedProducts + "," + document.getElementById(productsArray[i]).value;
            }
        }
    }
    document.forms['form1'].elements['product_interest'].value = selectedProducts;
}
//end