var GetRichPanel = null;
var popwin;
function OpenRPWindow(sPrmUrl)
{
	BlogOpenSubWindow(sPrmUrl,700,600);
}
function BlogOpenSubWindow(sPrmUrl, prmwidth, prmheight)
{
	var attributes = 'width=' + prmwidth + ',height=' + prmheight + ',scrollbars=1,resizable=1';
	popwin = open(sPrmUrl, "_blank", attributes);
	if(popwin == null)
	{
		//default width and height if they weren't passed in
		if (!prmwidth) { prmwidth = 700; }
		if (!prmheight) { prmheight = 600; }
		rpwReusableBlogs.Navigate(sPrmUrl);
		rpwReusableBlogs.Show(true, prmwidth, prmheight);
	}
} 
function OnClientExit(richPanel)
{
	var oValue = richPanel.Message;
	
	if(oValue == "EmailFriends")
	{
		//Right now, Do nothing. Just Close the RichPanel
	}
	else if(oValue == "Settings")
	{
		window.location = window.location;
	}
	else if(oValue == "EditPost")
	{
		window.location = window.location;
	}
	else if(oValue == "CreatePost")
	{
		window.location = window.location;
	}
	else if(AjaxClientId && oValue && oValue != "")
	{
		setTimeout(function (){ window[AjaxClientId].AjaxRequest(oValue); } ,1);
	}
	
	richPanel.Message = null;	
}
function CloseAndRefresh(strErr)
{
	if(opener)
	{
		ActiveObj = null;
		LookAtCell = null;
		opener.location.reload(true);
		self.close();
	}
	else
	{
		if (!GetRichPanel)
		{
			//not ready, delay
			setTimeout( function() { CloseAndRefresh(strErr); },1);
		}
		else
		{
			//GetRadWindow().Close();
			GetRichPanel().Message = strErr;
			GetRichPanel().Close();
		}
	}
}
function CloseNoRefresh()
{
	if(opener)
	{
		self.close();
	}
	else
	{
		if (!GetRichPanel)
		{
			//not ready, delay
			setTimeout( function() { CloseNoRefresh(); },1);
		}
		else
		{
			//GetRadWindow().Close();
			GetRichPanel().Message = "";
			GetRichPanel().Close();
		}
	}
}
function OnClientClose(richPanel)
{        
	var oValue = richPanel.Argument;
	if ((oValue == -2) && (richPanel.RefreshGFID))  // if -2, reload window (not panel) with argument's GFID
	{
		var CurrentUrl = GetCurrentUrlWithoutGFID() + '&gfid=' + richPanel.RefreshGFID;
		window.location = CurrentUrl;
	}
	else if (oValue == -1) //if -1, reload using CONST_CURRENTGFID
	{
		RadAjaxPanel_Reload(CONST_CURRENTGFID);
	}
	else if ((oValue != null) && (oValue.length > 0))
	{
		RadAjaxPanel_Reload(oValue);
	}
	richPanel.Argument = null; // clearing this out because richPanel is persisted (if it gets closed again it may redo same action)
} 

function onClientGridClose(richPanel)
{
    var oValue = richPanel.Message;
	if(oValue && oValue != "")
	{	
	    window.location = window.location;	
	}
	
	richPanel.Message = null;	
}
