function displayDiv(divName) {

    if (document.getElementById(divName).style.display != 'block') {
        document.getElementById(divName).style.display = 'block';
    }
}


function hideDiv(divName) {

    if (document.getElementById(divName).style.display != 'none') {
        document.getElementById(divName).style.display = 'none';
    }
}

function supportIssueActions(issueSelect){
    
    selectedIndex = issueSelect.selectedIndex;

    selectedValue = issueSelect.options[selectedIndex].value;
    //alert ('selected value '+ selectedValue);
    
    if (selectedValue == '0') {
        
        hideDiv("sfuserinfo");
        hideDiv("sfphoneinfo");
        hideDiv("sffaq");
    
    // if phones charges get selected
    }else if (selectedValue == 'PHONE_CHARGES') {
    
        hideDiv("sfuserinfo");
        hideDiv("sfphoneinfo");
        displayDiv("sffaq");
        
    // everything else is should be form    
    } else {

        displayDiv("sfuserinfo");
        displayDiv("sfphoneinfo");
        hideDiv("sffaq");     
    }
}

function updatePhoneModelList (selectedVendorId) {
    // Pre check to make sure the vendor id is not empty
    if(selectedVendorId != '0') {
        // Grab phone model list from server
        YAHOO.util.Connect.asyncRequest('POST', 
                                           'DeviceList/req_alldevices.htm',
                                           phoneListCallback,
                                           'phoneVendor=' + selectedVendorId);
    }
    else {
        // TODO: Do JavaScript messageSource populated from properties file.
        alert('Invalid vendor');
    }
}
   
var phoneListCallback = {
    success: function(response) {
        var phoneSelect = $('phoneModel');
        GSUtil.clearAllChildren(phoneSelect);
        
        //alert(response.responseText);
        try {
            var deviceList = eval('(' + response.responseText + ')');
            this.phoneElementList = new Array();
            // Iterate through the response list, each entry contains the same detail as
            // DeviceDetails Java class.
            
            for(var i = 0; i < deviceList.length; i++) {

                var deviceString = deviceList[i].model;
                var elmOption = document.createElement('option');

                elmOption.value = deviceString;
                elmOption.appendChild(document.createTextNode(deviceString));
                phoneSelect.appendChild(elmOption);
            }
          
        }
        catch(exception) {
            alert(exception.message);
            this.displayEmptyPhoneListMessage('Unabled to find any phones');
        }
    },
    failure: function() {
        this.displayEmptyPhoneListMessage('Unabled to contact server for phones');
    }
}
