var gRefresherId=0;

function refreshWorkflow(extraqs, id)
{

    gRefresherId = id;
	var MessageURL = applicationRoot + "admin/message.aspx" + extraqs;
	var WorkflowURL = applicationRoot + "admin/workflow.aspx" + extraqs;
	//launchWorkflow(MessageURL);
	launchWorkflow(WorkflowURL);
}
    
function workflowDone(c)
{
    document.getElementById("workflowContainer" + gRefresherId).outerHTML = c;
}

function showLargePopup(obj, menu)
{
	initializeLargeWebeasyPopup(obj, menu); 
	
	var offsetLeft = 0;
	var offsetTop =0;
	var currentElement = obj;  
	while(currentElement != window.document.body) 
	{
		offsetTop += currentElement.offsetTop;
		offsetLeft += currentElement.offsetLeft;
		offsetTop -= currentElement.scrollTop;
		offsetLeft -= currentElement.scrollLeft;
		currentElement = currentElement.offsetParent;
	}					
	
	document.getElementById("WebeasyLargePopup").style.top = offsetTop;
	document.getElementById("WebeasyLargePopup").style.left = offsetLeft;
}

function initializeLargeWebeasyPopup(obj, displayObjID)
{
	//args: 
	//	obj: the caller obj, this is to position the popup at the caller
	//	onclickEvent: the onclick event handler to attach
	//	displayObjID: the id of the div to display (the popup div)
	//	attachClassName: The class name of the inner divs ons which the event will be attached
	if(document.getElementById(displayObjID))
	{
		var displayDiv = document.getElementById(displayObjID);
		inDiv = displayDiv;
		var oGenericPopup = document.getElementById("WebeasyLargePopup");
		oGenericPopup.style.display = "block";
		var oGenericPlacHolder = document.getElementById("WebeasyLargePopPlaceHolder");
		oGenericPlacHolder.innerHTML = "";
		
		var clone =  displayDiv.cloneNode(true);
		clone.style.display = "block";
		cloneDiv = clone;
		oGenericPlacHolder.appendChild(clone);
	}	
}

function launchWorkflow(url, windowName,NeverOpenInScreen)
{

    if ((windowName==null)||(windowName==""))
        windowName="RadWindow1";
    var ContextMenuOpenInScreen=document.getElementById("ContextMenuOpenInScreen");        
    if ((ContextMenuOpenInScreen == null)||(NeverOpenInScreen==true))
    {   
        windowName = windowName + "";
        
        if (windowName == "undefined")
            windowName = "RadWindow1";

        var oManager = GetRadWindowManager();
        
        //Success. Getting existing window DialogWindow using GetWindowByName
        var oWnd = oManager.GetWindowByName(windowName);
        
        if (oWnd == null)
        {
            oManager = window.parent.GetRadWindowManager();
            oWnd = oManager.GetWindowByName(windowName);
        }
        
        if (oWnd != null)
        {
            oWnd.SetTitle("Processing... please allow the page to reload.");
            oWnd.WrapperElement.style.zIndex='60000';
            
            //oWnd.MoveTo(250,220);
            oWnd.SetSize(250,100);
            oWnd.SetUrl(url);
            
            //Success. Opening window
            oWnd.Show();
            
            //oWnd.Reload();
            oManager = null;
            oWnd = null;
            return false;
        }
    }
    else
    {
        if (url.indexOf("?")==-1)
        {
           url+="?"; 
        }
        else
        {
            url+="&";
        }
        url+="contentOnPage=true";
        setUrl(url);
    }    
} 