/*
	Dialogs.js
	
	Functions which are used to confirm user action (such as deletes) or gather user input
	via java popup windows.
*/
/*
	Confirm the clicked link is really to be followed.
*/
/*
function ConfirmHyperlinkClick()
{
	return confirm('Are you sure?');
}
*/
// AUTHOR:			Scott MacDonald
// DATE:			Oct. 22, 2003
// DESCRIPTION:		Pop up a confirmation box for deletion of content.
// PARAMETERS:		- frm is the form being submitted...
//					- strSiteType is the type of site... one of:
//						BASIC - content isn't shared between pages
//					- hiddenElement is the hidden element to write the Content Id to
//					- contentId is the Id to write to hiddenElement
// RETURNS:			void, if confirmed, the specified form is posted.
function ConfirmDeleteContent( frm, strSiteType, hiddenElement, contentId )
{
	if( strSiteType == "BASIC" )
	{
		if( confirm( "Are you sure you want to delete this item? This content will be deleted for ALL languages." ) )
		{
			// Write the Id of the Content to delete
			// to the hidden element. This can be
			// retrieved in the post code...
			hiddenElement.value = contentId;
			// Submit the specified form...
			frm.submit();
		}
	}
}
// AUTHOR:			Scott MacDonald
// DATE:			Jan 15, 2004
// DESCRIPTION:		Pop up a confirmation box for publication of content.
// PARAMETERS:		- frm is the form being submitted...
//					- strSiteType is the type of site... one of:
//						BASIC - content isn't shared between pages
//					- hiddenElement is the hidden element to write the Content Id to
//					- contentId is the Id to write to hiddenElement
// RETURNS:			void, if confirmed, the specified form is posted.
function ConfirmPublishContent( frm, strSiteType, hiddenElement, contentId )
{
	if( strSiteType == "BASIC" )
	{
		if( confirm( "Are you sure you want to publish this item?" ) )
		{
			// Write the Id of the Content to delete
			// to the hidden element. This can be
			// retrieved in the post code...
			hiddenElement.value = contentId;
			// Submit the specified form...
			frm.submit();
		}
	}
}
// AUTHOR:			Leigh Wetmore
// As above, but for the special case of dated content.
function ConfirmPublishContentDated( frm, strSiteType, hiddenElement, hiddenStart, hiddenEnd, contentId )
{
	var start = "";
	var end = "";
	eval( "start = frm.sd" + contentId + ".value;" );
	eval( "end = frm.ed" + contentId + ".value;" );
	
	if( strSiteType == "BASIC" )
	{
		if( confirm( "Are you sure you wish to publish this item?" ) )
		{
			if( start.length > 0 || end.length > 0 )
			{
			
				if( confirm( "Do you wish to use the entered date(s) to date this content?" ) )
				{
					var nowDate = new Date();
					var sDate = new Date(start);
					var eDate = new Date(end);
					var nowDateSeconds = Date.parse( nowDate );
					var sDateSeconds = Date.parse( sDate );
					var eDateSeconds = Date.parse( eDate );
				
					if( (start.length > 0 && end.length > 0) && sDateSeconds >= eDateSeconds )
					{
						alert( "The publish end date must be after the publish start date." );
						return;
					}
					if( start.length > 0 && (sDateSeconds <= nowDateSeconds) )
					{
						alert( "The publish start date must be after the current date." );
						return;
					}
					if( end.length > 0 && (eDateSeconds <= nowDateSeconds) )
					{
						alert( "The publish end date must be after the current date." );
						return;
					}
					// set the dates as hiddens as well
					hiddenElement.value = contentId;
					hiddenStart.value = start;
					hiddenEnd.value = end;
					// Submit the specified form...
					frm.submit();
				}
				else
				{
					eval( "frm.sd" + contentId + ".value = '';" );
					eval( "frm.ed" + contentId + ".value = '';" );
				}
			}
			else
			{
				// set content id to hidden
				hiddenElement.value = contentId;
				// Submit the specified form...
				frm.submit();
			}
		}
	}
}
// AUTHOR:			Scott MacDonald
// DATE:			Jan 15, 2004
// DESCRIPTION:		Pop up a confirmation box for reverting of content to the live version, abandoning edits.
// PARAMETERS:		- frm is the form being submitted...
//					- strSiteType is the type of site... one of:
//						BASIC - content isn't shared between pages
//					- hiddenElement is the hidden element to write the Content Id to
//					- contentId is the Id to write to hiddenElement
// RETURNS:			void, if confirmed, the specified form is posted.
function ConfirmRevertContent( frm, strSiteType, hiddenElement, contentId )
{
	if( strSiteType == "BASIC" )
	{
		if( confirm( "Are you sure you want to revert this item to the live version and abandon your edits?" ) )
		{
			// Write the Id of the Content to delete
			// to the hidden element. This can be
			// retrieved in the post code...
			hiddenElement.value = contentId;
			// Submit the specified form...
			frm.submit();
		}
	}
}
// AUTHOR:			Adam Nickerson
// DATE:			May 25, 2004
// DESCRIPTION:		Pop up a confirmation box for mirroring a piece of content.
// PARAMETERS:		- frm is the form being submitted...
//					- strSiteType is the type of site... one of:
//						BASIC - content isn't shared between pages
//					- hiddenElement is the hidden element to write the Content Id to
//					- contentId is the Id to write to hiddenElement
// RETURNS:			void, if confirmed, the specified form is posted.
function ConfirmMirrorContent( frm, strSiteType, hiddenElement, contentId )
{
	if( strSiteType == "BASIC" )
	{
		if( confirm( "Are you sure you want to mirror this item?" ) )
		{
			// Write the Id of the Content to delete
			// to the hidden element. This can be
			// retrieved in the post code...
			hiddenElement.value = contentId;
			// Submit the specified form...
			frm.submit();
		}
	}
}
