﻿if (document.images) 
{
    preload_image_object = new Image();
    // set image url
    image_url = new Array();
    image_url[0] = "/img/rightpanel/SideBar_Got_An_Idea_On.png";
    image_url[1] = "/img/rightpanel/SideBar_Sign_Up_On.png";
    image_url[2] = "/img/rightpanel/SideBar_Set_Us_To_Work_On.png";
    image_url[3] = "/img/rightpanel/SideBar_Proceed_On.png";

    var i = 0;
    for (i = 0; i <= 3; i++)
        preload_image_object.src = image_url[i];
}

function ChangeImage(strElementId, strOnOff) 
{
    document.getElementById(strElementId).src = '/img/rightpanel/SideBar_Proceed_' + strOnOff + '.png';
}

function changeActionAndMethodOnFormAndSubmit(newAction, newMethod) 
{
    var theForm = document.forms['aspnetForm'];
    if (!theForm) 
    {
        theForm = document.aspnetForm;
    }
    theForm.action = newAction;
    theForm.method = newMethod;
    theForm.submit();
}

function ChangeColor(strElementId, strOnOff) 
{
    if (strOnOff == 'on')
        document.getElementById(strElementId).style.color = '#FFFFFF';
    else
        document.getElementById(strElementId).style.color = 'Gray';
}

function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);

    for (i = 0; i < document.forms[0].elements.length; i++) {

        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}


var strCurrentlySelected = 'app1';

function fnc_ChangeImage(oElement) {
    // Turn all of the buttons off
    document.getElementById('app1').src = document.getElementById('app1').src.replace('on', 'off');
    document.getElementById('app2').src = document.getElementById('app2').src.replace('on', 'off');
    document.getElementById('app3').src = document.getElementById('app3').src.replace('on', 'off');
    document.getElementById('app4').src = document.getElementById('app4').src.replace('on', 'off');

    // Turn the clicked element on
    oElement.src = oElement.src.replace('off', 'on');

    // Update our global variable so we know what element is currently selected
    strCurrentlySelected = oElement.id;

}

function fnc_RollOverImage(oElement, strFlag) {
    // Check that the currently rolled over icon is NOT the one currently selected
    if (oElement.id != strCurrentlySelected) {
        var strOppositeFlag = ''

        if (strFlag == 'on')
            strOppositeFlag = 'off';
        else
            strOppositeFlag = 'on';

        // Change the image of the element
        oElement.src = oElement.src.replace(strOppositeFlag, strFlag);
    }

}


function fncButtonClick(strElementId)
{
    document.getElementById(strElementId).click();
}

function fncDisableIfEmpty(strElementId, strElementToDisable) 
{
    var oElementToDisable = document.getElementById(strElementToDisable);
    
    // Disable the element if there is no text entered
    oElementToDisable.disabled = (document.getElementById(strElementId).value.length == 0);
}
