var gRefresherId=0;

function refreshWorkflow(extraqs, id)
{
    gRefresherId = id;
	//extraqs=extraqs+"Title=Processing... please allow the page to reload";	
	var MessageURL="admin/message.aspx" + extraqs ;
	var WorkflowURL="admin/workflow.aspx" + extraqs ;
	//alert(WorkflowURL)
	//window.open(MessageURL,"workflowpopup","directories=no,height=100,width=100,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,scrollbars=no");
	//window.open(WorkflowURL,"workflowpopup","directories=no,height=100,width=100,location=no,menubar=no,resizable=yes,status=no,titlebar=no,toolbar=no,scrollbars=no");
	//alert(MessageURL + "\n\n" + WorkflowURL);
	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);
        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);
    }    
} 
