/*<script>*/
/*****************************************************************************
'*                                                                           *
'*  Name:        messageBox.js                                               *
'*	Description: Global javascipt message box library.                       *
'*                                                                           *
'*	VSS Header: $$Header: $                                                  *
'*                                                                           *
'*****************************************************************************
'*	          (c) Copyright Main Roads Western Australia                     *
'*****************************************************************************
'*                                                                           *
'*	Modification History:										             *
'*	Name:        config.js                                                   *
'*	•When			•Who			•Bug#			•What                    *
'*	-------------------------------------------------------------------------*
'*	•16-Dec-2000	•Wilson Wampers •				•Initial Version		 *
'*	•08-Mar-2003	•Wilson Wampers •				•Timer functionality     *
'****************************************************************************/
// Global vars
var gbMB_FirstParameter; // boolean indicating first QueryString parameter
var gsURL;				 // URL

// Message Box Button Constants
var MB_None   = 0;
var MB_Ok     = 1;
var MB_Cancel = 2;
var MB_Abort  = 3;
var MB_Retry  = 4;
var MB_Ignore = 5;
var MB_Yes    = 6;
var MB_No     = 7;
var MB_Submit = 8;
	 
// Message Box Icon Constants
var MB_Critical    = 1;
var MB_Question    = 2;
var MB_Exclamation = 3;
var MB_Information = 4;
	 
// Standard Message Box Button Layouts
var MB_OkCancel         = new Array( MB_Ok, MB_Cancel );
var MB_SubmitCancel     = new Array( MB_Submit, MB_Cancel );
var MB_YesNo            = new Array( MB_Yes, MB_No );
var MB_YesNoCancel      = new Array( MB_Yes, MB_No, MB_Cancel );
var MB_AbortRetryIgnore = new Array( MB_Abort, MB_Retry, MB_Ignore );

var gsUC  = "<div style=\"border:1px solid black;font-family:Lucida Hand;height:14px;width:222px;\">";
    gsUC += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"table-layout:fixed;height:14px;width:222px;overflow:hidden;\"><tr>";
    gsUC += "<td bgcolor=\"yellow\">&nbsp;</td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">U</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">N</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">D</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">E</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">R</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\">&nbsp;</td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">C</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">O</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">N</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">S</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">T</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">R</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">U</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">C</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">T</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">I</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">O</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\"><b><em style=\"color:black\">N</em></b></td>";
    gsUC += "<td bgcolor=\"black\"><b><em style=\"color:white\">&nbsp;!</em></b></td>";
    gsUC += "<td bgcolor=\"yellow\">&nbsp;</td>";
    gsUC += "</tr></table></div>";

//*****************************************************************************
// Name:			messageBox                                                *
// Parameters:		pnIconID - the message box icon id                        *
//					paButtonID - an array of message box button ids           *
//					psTitle - the message box title text                      *
//					psMessage - the message box message text                  *
// Return Value:	The selected button id.                                   *
// Pre-Conditions:	None                                                      *
// Post-Conditions:	None                                                      *
// Description:		Displays the standard system message box                  *
//*****************************************************************************
function messageBox( pnIconID, paButtonID, psTitle, psMessage, pnTimeOut )
{
	// Initialise Array
	gsURL = "/NR/mrwa/scripts/messageBox.asp"; 
	gbMB_FirstParameter = true;

	// Confirm the button id is an array
	if ( typeof( paButtonID ) == "object" )
	{ 
		// Add the buttons
		for ( var i=0; i < paButtonID.length; i++ )
		{
			// Calculate the button id URL parameter
			MB_AddQueryString( "b", paButtonID[i] );
		}
	}
	else
	{
		MB_AddQueryString( "b", paButtonID );
	}

	MB_AddQueryString( "i", pnIconID );
	MB_AddQueryString( "t", psTitle );
	if( pnTimeOut != null )
	{
	    MB_AddQueryString( "e", pnTimeOut );
	}
	// Display the date input dialog and return the result
	if( window.navigator.appName == "Microsoft Internet Explorer" )
	{
		return( window.showModalDialog(	gsURL, 
										escape( String( psMessage )),	
										"status:0; center:1; help:0; dialogHeight=125px; dialogWidth=300px; resizable:yes;" ) );
	}
	else
	{   // All other browsers use an alert box (for the time being at least)
		alert( "MESSAGE BOX: " + psMessage );
	}
}

//***************************************************************************
// Name:			MB_AddQueryString                                       *
// Parameters:		sAttribute	- QueryString Attribute name                *
//					sValue		- Value of QueryString Attribute            *
// Return Value:	The new URL string                                      *
// Pre-Conditions:	None                                                    *
// Post-Conditions:	None                                                    *
// Description:		Adds a parameter to the query string                    *
//***************************************************************************
function MB_AddQueryString( sAttribute, sValue )
{
	if( !gbMB_FirstParameter )
	{
		gsURL += "&";
	}
	else
	{
		gsURL += "?";
		gbMB_FirstParameter = false;
	}
	
	gsURL += ( sAttribute + "=" + escape(sValue) );
	
	return( gsURL );
}

//***************************************************************************
// Name:            underConstruction                                       *
// Parameters:      NONE                                                    *
// Return Value:    NONE                                                    *
// Pre-Conditions:  NONE                                                    *
// Post-Conditions: NONE                                                    *
// Description:     Displays a under construction message                   *
//***************************************************************************

function underConstruction()
{
    messageBox( MB_Exclamation, 
                MB_Ok, 
                "UNDER-CONSTRUCTION DIALOG: ",
                "This features is still <br/><br/>" + gsUC, 2 
              );
    return( false );
}

//***************************************************************************

