/**********************************************************************************************
 * JAFFA - Java Application Framework For All - Copyright (C) 2002 JAFFA Development Group
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License (version 2.1 any later).
 * 
 * See http://jaffa.sourceforge.net/site/legal.html for more details.
 *********************************************************************************************/

var objects = new Array(), x = null, expanded = null;
// begin objects array with the document
objects[0] = new Array(document, "_document", false);
var messageList = new Array();
function addMessage(ermsg) {
  messageList[messageList.length] = ermsg;
}

function openDOMBrowser(activeElement){
  var errorTop = (self.screen.availHeight /2) - 100;
  var errorLeft = (self.screen.availWidth /2) - 150 ;
  // opens/reopens the window
  args = "width=500,height=200,left=20,top=20,,resizable,top=" + errorTop + ",left=" + errorLeft;
  x = window.open('',"DOMBrowser",args);
  x.focus();
  // clears the expanded array (to avoid infinate loops in the DOM)
  expanded = new Array();
  // document is about to be expanded
  expanded["_document"] = true;
  // writes HTML to the window
  x.document.open("text/html","replace");
  x.document.writeln("<HTML><HEAD><TITLE>Error Screen</TITLE>");
  x.document.writeln("<STYLE TYPE=\"text/css\">");
  x.document.writeln("<!--");
  x.document.writeln("A{text-decoration:none}");
  x.document.writeln("a:hover { color: #efcf73; text-decoration: none; }");
  x.document.writeln("-->");
  x.document.writeln("</STYLE>");
  x.document.writeln("<script>");
  x.document.writeln("var messageList = new Array();");
  x.document.writeln("var index = 0;");
  x.document.writeln("function init() {");
  x.document.writeln("	if (messageList.length > 0) {");
  x.document.writeln("	    if (messageList.length < 2) {");
  x.document.writeln("       document.getElementById('previous').style.visibility = \"hidden\";");
  x.document.writeln("       document.getElementById('next').style.visibility = \"hidden\";");
  x.document.writeln("       }");
  x.document.writeln("    showMessages(0);");
  x.document.writeln("  }");
  x.document.writeln("}");
  x.document.writeln("// Display Error Messages");
  x.document.writeln("function showMessages(i) {");
  x.document.writeln("if (i < messageList.length) {");
  x.document.writeln("        document.getElementById('msg').innerHTML = messageList[i];");
  x.document.writeln("		if ((i + 1) == messageList.length) {");
  x.document.writeln("			document.getElementById('next').style.visibility = \"hidden\";");
  x.document.writeln("		} else {");
  x.document.writeln("			document.getElementById('next').style.visibility = \"\";");
  x.document.writeln("		}");
  x.document.writeln("		if (i  == 0) {");
  x.document.writeln("			document.getElementById('previous').style.visibility = \"hidden\";");
  x.document.writeln("		} else {");
  x.document.writeln("			document.getElementById('previous').style.visibility = \"\";");
  x.document.writeln("		}");
  x.document.writeln("    }");
  x.document.writeln("}");
  x.document.writeln("function previous() {");
  x.document.writeln("    if (index != 0) {");
  x.document.writeln("    index--;");
  x.document.writeln("    showMessages(index);");
  x.document.writeln("	  if (document.getElementById(\"calendardd\") != null) {");
  x.document.writeln("        document.getElementById('calendardd').disabled = false;");
  x.document.writeln("    }");
  x.document.writeln("    }");
  x.document.writeln("}");
  x.document.writeln("function next() {");
  x.document.writeln("  if (index < messageList.length - 1) {");
  x.document.writeln("    index++;");
  x.document.writeln("    showMessages(index);");
  x.document.writeln("       if (document.getElementById(\"calendardd\") != null) {");
  x.document.writeln("       document.getElementById('calendardd').disabled = false;");
  x.document.writeln("    }");
  x.document.writeln("    }");
  x.document.writeln("}");
  x.document.writeln("function okerror() {");
  x.document.writeln("	document.getElementById('errorBox').style.display = \"none\" ;");
  x.document.writeln("   if (document.getElementById(\"calendardd\") != null) {");
  x.document.writeln("        document.getElementById('calendardd').disabled = true;");
  x.document.writeln("    }");
  x.document.writeln("}");
  x.document.writeln("// Add an Error Message to the variable");
  x.document.writeln("function addMessage(ermsg) {");
  x.document.writeln("    messageList[messageList.length] = ermsg; }");
  x.document.writeln("\</script\>");
  // finishes writing HTML and closes
  for (var pi=0 ; pi < messageList.length ; pi++) {
    index++;	
    x.document.writeln("<script>addMessage(\"" + messageList[pi] + "\");\</script\>");
  }
  x.document.writeln("\</HEAD\>");
  x.document.writeln("<BODY BGCOLOR=#FFFFFF onLoad=\"init();\">");
  x.document.writeln("<h1 style=\"font-family: Verdana; Arial; Helvetica; sans-serif; margin-bottom: -15; margin-left: 10; color:#840000\">Error</h1>");
  x.document.writeln("<table style=\"width: 100%;\" cellspacing=0 cellpadding=10>")
  x.document.writeln("<tr><td height=\"25\"></td></tr><tr><td><table><tr><td>"); 
  x.document.writeln("<p style=\"font-family: tahoma, arial, helvitica; font-size: 12px; margin-left: 10px; margin-right: 10px;\">Message:</p>");
  x.document.writeln("</td><td><p style=\"font-family: tahoma, arial, helvitica; font-size: 12px; margin-left: 10px; margin-right: 10px;\" id=\"msg\"></p></td>");	          
  x.document.writeln("</tr></table></td></tr><tr><td align=\"RIGHT\"><table><tr><td>");
  x.document.writeln("<font face=\"Verdana, Arial, Helvetica, sans-serif\"><b><font size=\"2\" color=\"AA4612\"><a href=\"javascript:previous()\"><span id=\"previous\">previous</span></a></font></b></font>");
  x.document.writeln("</td><td width=\"10\"></td><td><font face=\"Verdana, Arial, Helvetica, sans-serif\"><b><font size=\"2\" color=\"AA4612\"><a href=\"javascript:next()\"><span id=\"next\"   >next</span></a></font></b></font>");
  x.document.writeln("</td><td width=\"10\"></td><td>");
  x.document.writeln("</td></tr></table></td></tr></table>");
  x.document.writeln("<script>window.onload(init())</script>");
  x.document.writeln("\</ul\>");
  x.document.writeln("\</body\>\</html\>");
}
