/******************************************************************************
*
*	Pivotal eService 5.0
*
*	File:		error.js 
*	Purpose:	Error message javascript functions. Used to display the error
*				box.
*	Date:		January 1, 2003
*
******************************************************************************/

var ICON_TYPE_ERROR = 1;
var ICON_TYPE_INFO = 2;
var ERROR_ICON = "<img src='images/Dialog_ErrorIco.gif' hspace='24'>\n";
var INFO_ICON = "<img src='images/Dialog_InfoIco.gif'  hspace='24'>\n";

var TITLE_TYPE_CLIENT_ERROR = 1;
var TITLE_TYPE_SERVER_ERROR = 2;
var TITLE_TYPE_LE_ERROR = 3;
var TITLE_TYPE_PARSER_ERROR = 4;
var TITLE_TYPE_PHUB_INFO = 5;
var TITLE_TYPE_VALIDATION_ERROR = 6;

var PAGE_TITLE_ERROR;
var PAGE_TITLE_INFO;
var ERR_DEFAULT_TITLE;

var Netscape = (navigator.appName == "Netscape");
var PivotalInfoWindow = new Object();

function openErrorDialog(returnFunc, nTitleType, strErrorMessage, nIconType)
{
	PivotalInfoWindow.returnFunc = returnFunc;
	PivotalInfoWindow.returnedValue = "";
	PivotalInfoWindow.url = "about:blank";//url
	PivotalInfoWindow.width = 500;
	PivotalInfoWindow.height = 180;
	PivotalInfoWindow.titleType = nTitleType;
	PivotalInfoWindow.errMessage = strErrorMessage;
	PivotalInfoWindow.icon = nIconType;
	PivotalInfoWindow.attr = "status=no,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=yes,fullscreen=0";
	PivotalInfoWindow.name = (new Date()).getSeconds().toString();

	if (Netscape) {
		PivotalInfoWindow.left = window.screenX + ((window.outerWidth - PivotalInfoWindow.width) / 2);
		PivotalInfoWindow.top = window.screenY + ((window.outerHeight - PivotalInfoWindow.height) / 2);
		var attr = "screenX=" + PivotalInfoWindow.left + ",screenY=" + PivotalInfoWindow.top + ",width=" + PivotalInfoWindow.width + ",height=" + PivotalInfoWindow.height + "," + PivotalInfoWindow.attr;
	} else {
		PivotalInfoWindow.left = (screen.width - PivotalInfoWindow.width) / 2;
		PivotalInfoWindow.top = (screen.height - PivotalInfoWindow.height) / 2;
		var attr = "left=" + PivotalInfoWindow.left + ",top=" + PivotalInfoWindow.top + ",width=" + PivotalInfoWindow.width + ",height=" + PivotalInfoWindow.height + "," + PivotalInfoWindow.attr;
	}
	PivotalInfoWindow.strHTML = generateStringValueHTML( PivotalInfoWindow.titleType, strErrorMessage, PivotalInfoWindow.icon )
	PivotalInfoWindow.win=window.open(PivotalInfoWindow.url, PivotalInfoWindow.name, attr);
	PivotalInfoWindow.win.document.open();
	PivotalInfoWindow.win.document.write( PivotalInfoWindow.strHTML );
	PivotalInfoWindow.win.document.close();
	PivotalInfoWindow.win.focus();

	return false;
}


function generateStringValueHTML( nTitleType, strErrorMessage, nIconType )
{
	var strHTML;
	var imgIconType;
	var strTitleType;
	var strPageTitle
	
	switch (nIconType)
	{
		case 1: 
			imgIconType = ERROR_ICON;
			break;
			
		case 2:
			imgIconType = INFO_ICON;
			break;
			
		default:
			imgIconType = ERROR_ICON;
			break;	
	}
	
		if (imgIconType == ERROR_ICON)
	{
		strPageTitle = PAGE_TITLE_ERROR;
	}
	
	if (imgIconType == INFO_ICON)
	{
		strPageTitle = PAGE_TITLE_INFO;
	}
	
	switch (nTitleType)
	{
		case 1:
			strTitleType = g_LDSTRING_HEADER_ERROR_CLIENT_ERROR; //ERR_CLIENT_TITLE;
			break;
	
		case 2:
			strTitleType = g_LDSTRING_HEADER_ERROR_SERVER_ERROR; //ERR_SERVER_TITLE;
			break;
		
		case 3:
			strTitleType = g_LDSTRING_HEADER_ERROR_LCS_ERROR; //ERR_LE_TITLE;
			break;
			
		case 4:
			strTitleType = g_LDSTRING_HEADER_ERROR_PARSE_ERROR; //ERR_PARSER_TITLE;
			break;

		case 5:
			strTitleType = g_LDSTRING_HEADER_ERROR_HEADER_INFORMATION; //INFO_ESERVICE_TITLE;
			break;
		
		case 6:
			strTitleType = g_LDSTRING_HEADER_ERROR_VALIDATION_ERROR; //ERR_VALIDATION_TITLE;
			break;
			
		case 7: 
			strTitleType = g_LDSTRING_HEADER_ERROR_ESERVICE_ERROR; //ERR_DEFAULT_TITLE;
			break;
		
		default:
			strTitleType = g_LDSTRING_HEADER_ERROR_ESERVICE_ERROR; //ERR_DEFAULT_TITLE;
			break;
	}
	
	strHTML = "";
	strHTML = strHTML + "<HTML>\n";
	strHTML = strHTML + "<HEAD>\n";
	strHTML = strHTML + "<LINK href='css/error.css' rel='STYLESHEET' type='text/css'>\n";
	strHTML = strHTML + "<script language='javascript'>\n";
	strHTML = strHTML + "var Netscape = (navigator.appName == 'Netscape')\n";
	strHTML = strHTML + "function onLoadDialog() {\n";
	strHTML = strHTML + "window.resizeBy(0, document.body.scrollHeight-document.body.offsetHeight+5);\n";
	strHTML = strHTML + "}\n";
	strHTML = strHTML + "function closeInfo() {\n";
	strHTML = strHTML + "window.close();\n";
	strHTML = strHTML + "}\n";
	strHTML = strHTML + "function buttonCancelClick() {\n";
	strHTML = strHTML + "closeInfo();\n";
	strHTML = strHTML + "return false;\n";
	strHTML = strHTML + "}\n";
	strHTML = strHTML + "</script>\n";
	strHTML = strHTML + "</HEAD>\n";
	strHTML = strHTML + "<BODY onLoad='onLoadDialog()'>\n";
	strHTML = strHTML + "<TABLE id='contentTable' bgcolor='#CCCCCC' cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'>\n";
	strHTML = strHTML + "<TR><TD colSpan='3' valign='top'>\n";
	strHTML = strHTML + "<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'>\n";
	strHTML = strHTML + "<TR><TD class='loginTabHeader'  width='35%'><img src='images/spacer.gif' border=0 alt=''></TD>\n";
	strHTML = strHTML + "<TD class='loginTab'><IMG src='images/login_UpperTab.gif' border='0'></TD>\n";
	strHTML = strHTML + "<TD class='loginHeader'><img src='images/spacer.gif' border=0 alt=''></TD></TR>\n";
	strHTML = strHTML + "</TABLE>\n";
	strHTML = strHTML + "</TD></TR>\n";
	strHTML = strHTML + "<TR><TD colSpan='3'><img src='images/spacer.gif' border=0 alt=''></TD></TR>\n";
	strHTML = strHTML + "<TR><TD colSpan='3'class='errorTitle'>" + strTitleType + "</TD></TR>\n";
	strHTML = strHTML + "<TR><TD colSpan='3'><img src='images/spacer.gif' border=0 alt=''></TD></TR>\n";
	strHTML = strHTML + "<TR><TD colSpan='3'>\n";
	strHTML = strHTML + "<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'>\n";
	strHTML = strHTML + "<TR><TD><img src='images/spacer.gif' border=0 alt='' height=1 width=1></TD>\n";
	strHTML = strHTML + "<TD width=100%><img src='images/spacer.gif' border=0 alt='' height=1 width=1></TD>\n";
	strHTML = strHTML + "<TD><img src='images/spacer.gif' border=0 alt='' height=1 width=70></TD></TR>\n";
	strHTML = strHTML + "<TR><TD rowspan='2' valign='top'>"+ imgIconType +"</TD>\n";
	strHTML = strHTML + "<TD colspan=2 valign='top'class='normalSmallText'>"+ strErrorMessage +"</TD></TR>\n";
	strHTML = strHTML + "<TR><TD valign='top' align='center'><form name='errorButton' style='margin:0;padding:0;'><input type='button' value='ok' onclick='buttonCancelClick()' class='errorButton' style='margin-top:25'/></form></TD>\n";
	strHTML = strHTML + "<TD class='normalSmallText'>&nbsp;</TD></TR>\n";
	strHTML = strHTML + "</TABLE>\n";
	strHTML = strHTML + "</TD></TR>\n";
	strHTML = strHTML + "<TR><TD colSpan='3'>\n";
	strHTML = strHTML + "<TABLE cellSpacing='0' cellPadding='0' width='100%' border='0'>\n";
	strHTML = strHTML + "<TR><TD class='loginBottom' width='10%'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>\n";
	strHTML = strHTML + "<TD class='loginBottom' valign='bottom' align='right'><IMG src='images/logonCorner1.gif' border='0'></TD>\n";
	strHTML = strHTML + "<TD class='loginBottomBack' valign='bottom' align='right' width='35%'><IMG src='images/logonCorner2.gif' border='0'></TD></TR>\n";
	strHTML = strHTML + "</TABLE>\n";
	strHTML = strHTML + "</TD></TR>\n";

	strHTML = strHTML + "</TABLE>\n";
	strHTML = strHTML + "</BODY>\n";
	strHTML = strHTML + "</HTML>\n";
	
	return strHTML;

}

