//begin_lib
<!-- This document created by WebScripter 3.1 copyright© Code Generation® 2000 -->
/* This script file contains all the general methods that handle errors and debuging

  CopyRight (C) Micro-Phyla Systems 2002, All Rights Reserved
  Developed by John B. Moore

Code conventions
function prefixes
   cvq - Crimeview functions found in this file
var prefixes:
	 g_  - global to this file
	 s    - string
	 n    - number
	 v   - anytype
	 b   - boolean
	 ar - array
	 the - object
	 arg_ - argument param of that function
	 <none> local to that function
function suffixes:
      _s - returns string
	  _n - returns number
	  _b - returns boolean
	  _r - returns array
	  _v - returns anytype
	  _obj - returns object reference
	  <none> - returns nothing (void)

Dependencies;
        <none>
  */

// Global reference vars
var g_mapF = parent.MapFrame;

var g_ConsoleWin = null;
var g_cvdebug = true
var g_delayclose = true;

var g_errorflag = false;
var g_errormsg = "Missing Error Response, Please Report!";

function setDebug(arg_lDebug) {
      g_debug = arg_IDebug;
}

function erPrintToConsole(arg_msg) {
   /* Writing to the console window the first time would fail because the objects were not initialized
       This is fixed by using "setTimeout()" on the calls.  This would not be needed on subsequent
	   calls when some time has passed, but if the first call was in a tight loop it would crash on
	   all calls.  Therefore it was determined that the current delay of 100 ms was sufficient to
	   allow object init, but not delay the writing to the console in subsequent calls.
	*/

       arg_msg =  g_mapF.untag(arg_msg);
	   //Check for odd number of quotes
	   arg_msg = parent.RoutineFrame.uBalanceQuotes(arg_msg);

       //open window if not already open
       if ((g_ConsoleWin == null) || (g_ConsoleWin.closed)) {
	      g_ConsoleWin = window.open("","JSConsole","width=600,height=400,resizable=yes,scrollbars=yes");
    	   erConsoleMain(g_ConsoleWin);
		   setTimeout('g_ConsoleWin.ConsoleFrm.document.writeln("'+arg_msg+'")',100);
	   } else {
	      //write to console
		  g_ConsoleWin.ConsoleFrm.document.writeln(arg_msg)
		   //setTimeout("g_ConsoleWin.ConsoleFrm.document.writeln('"+arg_msg+"')",100);
		   //setTimeout('g_ConsoleWin.ConsoleFrm.document.writeln("'+arg_msg+'")',100);
	   }
}

function erConsoleMain(arg_W) {

		 arg_W.document.write('<HTML>');
		 arg_W.document.write('  <HEAD>');
		 arg_W.document.write('	 <TITLE>Javascript Console</TITLE>');
		 arg_W.document.write('  <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="javascript/cv_errors.js"></SCRIPT>');
		 arg_W.document.write('	 <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">');
		 arg_W.document.write('	 function cleartxt() {');
		 arg_W.document.write('	       top.ConsoleFrm.document.open("text/plain");');
		 arg_W.document.write('		   top.ConsoleFrm.document.open("text/plain");');
		 arg_W.document.write('	 }');
		 arg_W.document.write('	function loadtxt() {');
		 arg_W.document.write('	       top.ConsoleFrm.document.close();');
		 arg_W.document.write('		   top.ConsoleFrm.document.open("text/plain");');
		 arg_W.document.write('	 }');
		 arg_W.document.write('	 </SCRIPT>');
		 arg_W.document.write('  </HEAD> ');
		 arg_W.document.write('  <FRAMESET ROWS="*,90">');
		 arg_W.document.write('    <FRAME NAME="ConsoleFrm" SRC="javascript:top.loadtxt()" SCROLLING="YES">');
		 arg_W.document.write('    <FRAME NAME="ControlFrm" SRC="javascript:top.cverConsoleCtrl()">');
		 arg_W.document.write('    <NOFRAMES>');
		 arg_W.document.write('    <BODY>');
		 arg_W.document.write('    </BODY>');
		 arg_W.document.write('     </NOFRAMES>');
		 arg_W.document.write('  </FRAMESET>');
		 arg_W.document.write('</HTML>');
		 arg_W.document.close();

}

function erConsoleCtrl() {

     var W = parent.ControlFrm

     W.document.write('<HTML>');
     W.document.write('  <HEAD>');
     W.document.write('	 <TITLE>Console Control Panel</TITLE>');
     W.document.write('  </HEAD> ');
     W.document.write('  <BODY BGCOLOR="Silver">');
     W.document.write('	 <TABLE WIDTH="100%" BGCOLOR="Silver" BORDER="2"');
     W.document.write('	  CELLPADDING="1" CELLSPACING="1"> ');
     W.document.write('		<TR VALIGN="MIDDLE"> ');
     W.document.write('		  <TD VALIGN="MIDDLE" ALIGN="CENTER">');
     W.document.write('			 <FORM> ');
     W.document.write('				<TABLE WIDTH="100%" BGCOLOR="Silver" CELLPADDING="1"');
     W.document.write('				 CELLSPACING="1" VALIGN="MIDDLE"> ');
     W.document.write('				  <TR> ');
     W.document.write('					 <TD VALIGN="MIDDLE" ALIGN="CENTER">&nbsp;<INPUT TYPE="BUTTON"');
     W.document.write('						NAME="ClearBtn" VALUE="Clear Console" ONCLICK="top.cleartxt()"></TD>');
     W.document.write('					 <TD VALIGN="MIDDLE" ALIGN="CENTER">&nbsp;<INPUT TYPE="BUTTON"');
     W.document.write('						NAME="CloseBtn" VALUE="Close Console" ONCLICK="javascript:top.close()"></TD>');
     W.document.write('					 <TD VALIGN="MIDDLE" ALIGN="CENTER">&nbsp;<INPUT TYPE="BUTTON"');
     W.document.write('						NAME="PrintBtn" VALUE="Print Console" ONCLICK="javascript: top.ConsoleFrm.document.close();top.ConsoleFrm.print();"></TD>');
	 W.document.write('				  </TR> ');
     W.document.write('				</TABLE></FORM></TD>');
     W.document.write('		  <TD ALIGN="CENTER" VALIGN="MIDDLE"><B>JavaScript Console </B></TD>');
     W.document.write('		</TR> ');
     W.document.write('	 </TABLE> </BODY>');
     W.document.write('</HTML>');
     W.document.close();

}



// A variable we use to ensure that each error window we create is unique.
var g_error_count = 0;

// Set this variable to an email address.
var g_email = "jbm@microps.com";

function erSuggestion() {
   var w = window.open("","SuggestionBox","resizable=no,width=600,height=575");
   //var w = window.open("","SuggestionBox","resizable=no,width=550,height=525");
   var d = w.document;    // We use this variable to save typing!

   // Output an HTML document, including a form, into the new window.
	d.write('   <HTML>');
	d.write('  <HEAD>');
	d.write('	 <TITLE></TITLE> ');
	d.write('  </HEAD> ');
	d.write('  <BODY BGCOLOR="#66FFFF">');
	d.write('	 <DIV ALIGN="CENTER"><B><FONT SIZE="+2">The Omega Suggestion');
	d.write('		Box</FONT></B><BR><IMG SRC="images/cv_fountainpen.gif" ALT="Make a suggestion!"');
	d.write('		ALIGN="MIDDLE" WIDTH="50" HEIGHT="48" BORDER="0"><BR><B>Fill in any of the text');
	d.write('		areas below and your suggestion goes directly to the developer.</B>');
	d.write('		<FORM  ACTION="mailto:' + g_email + '" METHOD="post" ENCTYPE="text/plain">');
	d.write('		  <TABLE WIDTH="100%" BGCOLOR="#66FFFF" CELLPADDING="1" CELLSPACING="1">');
	d.write('			 <TR>');
	d.write('				<TD ALIGN="RIGHT" WIDTH="90">&nbsp;Name:</TD>');
	d.write('				<TD ALIGN="LEFT" WIDTH="418">&nbsp;<INPUT TYPE="TEXT" NAME="Name"');
	d.write('				  SIZE="45"></TD>');
	d.write('			 </TR>');
	d.write('			 <TR>');
	d.write('				<TD ALIGN="RIGHT" WIDTH="90">&nbsp;Email:</TD>');
	d.write('				<TD ALIGN="LEFT" WIDTH="418">&nbsp;<INPUT TYPE="TEXT" NAME="Email"');
	d.write('				  SIZE="45"></TD>');
	d.write('			 </TR>');
	d.write('		  </TABLE>');
	d.write('		  <TABLE WIDTH="100%" BGCOLOR="#66FFFF" BORDER="2" CELLPADDING="1"');
	d.write('			CELLSPACING="1">');
	d.write('			 <TR>');
	d.write('				<TD ALIGN="CENTER">&nbsp;<B><I>Your Feeback</I></B></TD>');
	d.write('			 </TR>');
	d.write('			 <TR>');
	d.write('				<TD ALIGN="CENTER"><TEXTAREA NAME="Suggestion" ROWS="13" COLS="60"></TEXTAREA></TD>');
	d.write('			 </TR>');
	d.write('			 <TR>');
	d.write('				<TD ALIGN="CENTER">&nbsp;<INPUT TYPE="SUBMIT" NAME="Email"');
	d.write('				  VALUE="Email Feedback"><INPUT TYPE="BUTTON" NAME="Dismiss"');
	d.write('				  VALUE="   Cancel   "  ONCLICK="javascript:self.close()"></TD>');
	d.write('			 </TR>');
	d.write('		  </TABLE></FORM></DIV> </BODY>');
	d.write('   </HTML>');

   // Remember to close the document when we're done.
   d.close();
   return true;
}


// Define the error handler. It generates an HTML form so
// the user can report the error to the author.
function erReport_error(msg, url, line) {
   var w = window.open("",                    // URL (none specified)
                       "error"+g_error_count++, // Name (force it to be unique)
                       "resizable,width=650,height=400"); // Features
   var d = w.document;    // We use this variable to save typing!

   // Output an HTML document, including a form, into the new window.
   d.write('   <HTML>');
   d.write('  <HEAD>');
   d.write('	 <TITLE>Error Form</TITLE> ');
   d.write('  </HEAD> ');
   d.write('  <BODY BGCOLOR="#FFFF00">');
   d.write('<DIV ALIGN="CENTER"> <FONT SIZE="5" FACE="helvetica"><B>');
   d.write('Sorry.... A JavaScript Error Has Occurred!  </B></FONT>');
   d.write('<BR> <HR SIZE="4" WIDTH="80%">');
   d.write('<B><FONT SIZE="3"> <I>Click the "Report Error" button to send a bug report.</I>');
   d.write('</FONT></B> ');
   d.write('<FORM ACTION="mailto:' + g_email + '" METHOD="post" ENCTYPE="text/plain">');
   d.write('<BR> <INPUT TYPE="submit" VALUE="Email Error" >');
   d.write('<INPUT TYPE="button" VALUE="Cancel" ONCLICK="self.close()"> ');
   d.write('<DIV ALIGN="RIGHT"> <BR>Your name <I>(optional)</I>:');
   d.write('<INPUT SIZE="55" NAME="username" VALUE=""> <BR>');
   d.write('What were you doing?: <TEXTAREA NAME="Description" ROWS="2" COLS="47" WRAP="Physical">');
   d.write('Describe what you were doing right before this error occured (optional)');
   d.write('</TEXTAREA><BR> Error Message:');
   d.write('<INPUT SIZE="55" NAME="message" VALUE="' + msg + '"> <BR>Document:');
   d.write('<INPUT SIZE="55" NAME="url" VALUE="' + url + '"> <BR>Line Number:');
   d.write('<INPUT SIZE="55" NAME="line" VALUE="' + line +'"> <BR>Browser Version:');
   d.write('<INPUT SIZE="55" NAME="version" VALUE="'+navigator.userAgent + '"> </DIV>');
   d.write('</FORM> </DIV>');
   d.write('   </BODY></HTML>');
   // Remember to close the document when we're done.
   d.close();

   // Return true from this error handler, so that JavaScript does not
   // display its own error dialog.
   return true;
}

//This error handler allows the passage of non critical errors that requires
// Information be passed to user.
function erOn_error(msg, url, line) {
     alert(g_errormsg);
     g_errorflag = true;
    return true;
}

function erToggleDebug() {
    if (g_mapF._debug == false) {
        g_mapF._debug = true;
		erPrintToConsole("Opening Debuging Session")
	} else {
	    g_mapF._debug = false;
		erPrintToConsole("====================================")
		erPrintToConsole(" \\n Closing Debuging Session")
	}
}

// Before the event handler can take effect, we have to register it
// for a particular window.
self.onerror = erReport_error;

//end_lib
