//Common javascript functions

//
function OnClick_Cancel()
{
    location.reload(true);
}

//
function SetHiddenFieldAndSubmit(hiddenFieldID1 , hiddenFieldValue1, hiddenFieldID2 , hiddenFieldValue2, hiddenFieldID3 , hiddenFieldValue3, hiddenFieldID4 , hiddenFieldValue4) 
{

    //alert(hiddenFieldID2);
    //alert(hiddenFieldValue2);
    
    // Set the hidden fields first - up to three fields   
    document.getElementById(hiddenFieldID1).value = hiddenFieldValue1;
    if (hiddenFieldID2 != null)
        document.getElementById(hiddenFieldID2).value = hiddenFieldValue2;
    if (hiddenFieldID3 != null)
        document.getElementById(hiddenFieldID3).value = hiddenFieldValue3;
    if (hiddenFieldID4 != null)
        document.getElementById(hiddenFieldID4).value = hiddenFieldValue4;
    //
    document.forms[0].submit();
}


//
function ConfirmCancelUpdate() 
{
    if (confirm('Are you sure you want to cancel the updates?')) 
    {
        location.reload(true);
    }
}

//
function ConfirmSaveUpdate() 
{
    if (confirm('Are you sure you want to save the updates?')) 
    {
        document.forms[0].submit();
    }
}

//
function AnswerTypeChanged(actionClientID, selectedValue) 
{
    document.getElementById(actionClientID).value = selectedValue;
}

//
function setDivBlank(id) {
    if (document.getElementById(id)) {
        document.getElementById(id).innerHTML = '';
    }
}

function setDivValue(id, divText) {
    if (document.getElementById(id)) {
        document.getElementById(id).innerHTML = divText;
    }
}

//
function setElementVisible(id, visible) {
    if (document.getElementById(id)) {
        if (visible) {
            document.getElementById(id).style.visibility = 'visible';
            document.getElementById(id).style.display = '';
        }
        else {
            document.getElementById(id).style.visibility = 'hidden';
            document.getElementById(id).style.display = 'none';
        }
    }
}

//
function RefreshCaptcha(imgId, imgSource) 
{
    var img = document.getElementById(imgId);
    //Math function tricks teh browser to reload the image.
    img.src = imgSource + '?query=' + Math.random();;
}


//
function openChatWindow() 
{
    alert("No online support agent is available at this time. Please try later, or contact our corporate office directly.");
}



