// W2 Helper java script functions / objects

/* w2HelperObj is an object set by the base clay page - it has the following
** properties
** context - the root context of the application e.g. /MyWebApp
*/

//w2HelperObject = new Object();

// Context will be set by base clay page
//w2HelperObj.context = "";

function __w2disableActions(theAction)
{
	setTimeout(__w2disableTheActions,1);
}

function __w2disableTheActions()
{
    var prog = document.getElementById("civicaprogress");
    if (prog != null)
    {
        prog.style.display = '';
        prog.src=prog.src; // this may be a silly assignment but ie will only continue to show animated
                       // gifs if the src property is set again after the post starts.
    }
    
    var buttons = document.getElementsByTagName("input");
	for (var i=0;i<buttons.length;i++)
	{
		if (buttons[i].type == "submit")
		{
			buttons[i].disabled = true;

            if (buttons[i].className.indexOf("standardbutton") > -1)
            {
                buttons[i].className = "standardbuttondisabled";
            }
            else
            {
                buttons[i].className = buttons[i].className + "disabled";
            }

        }
        else if (buttons[i].type == "image")
        {
            buttons[i].disabled = true;
        }
	}
}

var w2HelperFunctions = {

        documentLoaded: function()
        {
        }


}

function __w2enableAllActions()
{
    setTimeout(__w2enableTheActions,1);
}

function __w2enableTheActions()
{
    var buttons = document.getElementsByTagName("input");
	for (var i=0;i<buttons.length;i++)
	{
		if (buttons[i].type == "submit")
		{
			buttons[i].disabled = false;

            if (buttons[i].className.indexOf("standardbuttondisabled") > -1)
            {
                buttons[i].className = "standardbutton";
            }
            else
            {
                buttons[i].className = buttons[i].className.replace("disabled", "");
            }

        }
        else if (buttons[i].type == "image")
        {
            buttons[i].disabled = false;
        }
	}

    var prog = document.getElementById("civicaprogress");
    if (prog != null) prog.style.display = 'none';
}

function __w2IsPotentialFileName(fname)
{
    return (fname.indexOf(":") == 1 || fname.substring(0,2) == "\\\\");
}
