function AddContent(entity, publishType)
{
	windowOpen("../Newsroom/ContentEdit.aspx?SiteName=" + escape(document.getElementById('hidSiteName').value) + "&Entity=" + entity + "&PublishType=" + publishType, "",  true, 2, 0);
};
function AddContentJuris(entity, publishType, juris)
{
	windowOpen("../Newsroom/ContentEdit.aspx?SiteName=" + escape(document.getElementById('hidSiteName').value) + "&Entity=" + entity + "&PublishType=" + publishType + "&Jurisdiction=" + juris, "",  true, 1, 0);
};
function EditContent(entity, entityId)
{
	windowOpen("../Newsroom/ContentEdit.aspx?SiteName=" + escape(document.getElementById('hidSiteName').value) + "&Entity=" + entity + "&EntityId=" + entityId, "", true, 2, 0);
};
function UnpublishContent(entity, entityId)
{
	windowOpen("../Newsroom/ContentEdit.aspx?SiteName=" + escape(document.getElementById('hidSiteName').value) + "&Entity=" + entity + "&EntityId=" + entityId + "&Unpublish=True", "", true, 1, 0);
};
function DeleteContent(entity, entityId)
{
	windowOpen("../Newsroom/ContentEdit.aspx?SiteName=" + escape(document.getElementById('hidSiteName').value) + "&Entity=" + entity + "&EntityId=" + entityId + "&Delete=True", "", true, 1, 0);
};
function ChangeView()
{
	location.href = "ChangeView.aspx?SiteName=" + escape(document.getElementById('hidSiteName').value) + "&ReturnURL=" + escape(location.href);
};
function windowOpen(strURL, strWindowName, blnIncludeToolbars, intWindowType, intWindowAlign)
{
		
	var intWINDOWTYPE_SMALL = 0;
	var intWINDOWTYPE_MEDIUM = 1;
	var intWINDOWTYPE_LARGE = 2;

	var intWINDOWALIGN_LEFT = 0;
	var intWINDOWALIGN_CENTER = 1;
	var intWINDOWALIGN_RIGHT = 2;

	var dblDivFactor;
	var lngLeft;
	var lngHeight;
	var lngTop;	
	var lngWidth;
	var strFeatures;
	var objWnd;
	
	
	if (strWindowName == null || strWindowName == '') 
	{
		strWindowName = 'wnd' + Math.floor(30000*Math.random() + 1);
	}

	if (intWindowType == intWINDOWTYPE_SMALL)
	{				
		dblDivFactor = 2;					
	}
	else if (intWindowType == intWINDOWTYPE_MEDIUM)
	{
		dblDivFactor = 1.4;					
	}	
	else
	{
		dblDivFactor = 1.05;
	}

	lngWidth = Math.floor(screen.width/dblDivFactor);
	lngHeight = Math.floor(screen.height/dblDivFactor);

	if ((screen.height - lngHeight) < 170)
	{
		lngHeight = screen.height - 170;
	}

	// CALCULATE TOP
	if (intWindowType == intWINDOWTYPE_SMALL)
	{		
		lngTop = Math.floor((screen.height - (lngHeight - 15))/2) - 100;	
	}
	else if (intWindowType == intWINDOWTYPE_MEDIUM)
	{
		lngTop =  Math.floor((screen.height - (lngHeight - 15))/2) - 100;				
	}	
	else
	{
		lngTop =  0;
	}
	
	// CALCULATE LEFT
	if (intWindowAlign==intWINDOWALIGN_RIGHT)
	{
		lngLeft = screen.width - lngWidth - 15;
	}	
	else if (intWindowAlign==intWINDOWALIGN_CENTER)
	{
		lngLeft = Math.floor((screen.width - (lngWidth - 15))/2)
	}
	else
	{
		lngLeft = 0;	
	}	
	
	
	if (lngTop < 0)
	{
		lngTop = 0;	
	}

	if (blnIncludeToolbars == true)	
	{
		strFeatures = 'toolbar=yes,location=no,status=yes,menubar=yes,resizable=yes,scrollbars=yes';		
	}
	else
	{
		strFeatures = 'toolbar=no,location=no,status=yes,menubar=no,resizable=yes';		
	}			
		
	strFeatures = strFeatures + ',left='+ lngLeft + ',width=' + lngWidth + ',top=' + lngTop + ',height=' + lngHeight;	
	
	objWnd = window.open(strURL, strWindowName, strFeatures, false);
  if (!objWnd)
  {
    try 
    { 
      showPopUpBlockerMessage(); 
      return;
    }
    catch (e) {}     
  }
	objWnd.focus();
	
	return objWnd;
	
};

function VerifyEditMode()
{
	var anchors = document.getElementsByTagName("A");

	if (parent != null && parent.name != null && (parent.name == "frameBody" || parent.name == "bodyFrame"))
	{
		for (i=0; i<=anchors.length-1; i++)
		{
			var anchor = anchors[i];		
			
			if (anchor.style.display == 'none')
			{
				if (anchor.href.indexOf("AddContent(") != -1 || anchor.href.indexOf("AddContentJuris(") != -1  || anchor.href.indexOf("EditContent(") != -1  || anchor.href.indexOf("DeleteContent(") != -1  || anchor.href.indexOf("ChangeView(") != -1)
				{
					anchor.style.display = '';
				}
			}
		}	
	}
}