//====================================================================================
//====================================================================================
//== EEM6Common.js
//====================================================================================
//== JavaScript file that contains the common (general) functions, variables, etc...
//==		used by the EEM6 files
//== This file should be included/referenced by almost all of the EEM6 HTML files
//====================================================================================
//== PROPERTY OF:
//==		Enerwise Global Technologies
//==		www.enerwise.com
//== AUTHOR:
//==		Dave Hile, Tranquility Base Consulting, Inc.
//==		(919) 345-6906
//==		dave.hile@tbc-i.com
//== MAJOR REVISIONS:
//==		
//====================================================================================
//====================================================================================

//====================================================================================
//== Server Path "Constants"
//====================================================================================
var PATH_HTML								= "/html/";
var PATH_IMAGES 						= "/html/images/";
var PATH_DLL 								= "/isapi/";
var FILE_DLL								= "dataminer.dll";
var PATH_CSS								= "/html/css/";
var PATH_JS									= "/html/js/";
var PATH_DEV								= "/html/dev/";

//====================================================================================
//== Server timeouts
//====================================================================================
//== TIMEOUT_SERVER					number of seconds to timeout on for a normal request to the server
var TIMEOUT_SERVER					= 100;
//== TIMEOUT_SERVER_LONG		number of seconds to timeout on for longer requests such as "Graph"
var TIMEOUT_SERVER_LONG			= 5 * 60;

//====================================================================================
//== Menu actions
//== 		These "constants" should match those defined in the udmSideMenuBarData.pas file
//====================================================================================
//== Button grouping/subgrouping
var MENU_ACTION_GROUP         = 1;
var MENU_ACTION_CATEGORY      = 2;
//== Types of reports to run
var MENU_ACTION_RPT_LOWEST    = 10;   //== The lowest a regular report button should be
var MENU_ACTION_RPT_STANDARD  = 10;
var MENU_ACTION_RPT_CUST      = 11;
var MENU_ACTION_RPT_PROFILE   = 12;
var MENU_ACTION_RPT_THRESH    = 13;
var MENU_ACTION_RPT_BENCH     = 14;
var MENU_ACTION_RPT_SAVED     = 15;
var MENU_ACTION_RPT_CALENDAR  = 17;
var MENU_ACTION_RPT_HIGHEST   = 99;   //== The highest a regular report button should be
//== Alarms
var MENU_ACTION_ALARM_VIEW    = 100;
var MENU_ACTION_ALARM_ADD     = 101;
var MENU_ACTION_ALARM_DETECTED= 102;
//== External links
var MENU_ACTION_LINK_COSTEST  = 200;
var MENU_ACTION_LINK_URL      = 201;
//== Generic call
var MENU_ACTION_GENERIC       = 1000;

//====================================================================================
//== Report Tab "constants"
//====================================================================================
//== Static TabPage ID's
var TABPAGE_SITE_DETAIL 			= 1;
var TABPAGE_REPORT_SETTINGS 	= 2;
var TABPAGE_GRAPH_MAIN 				= 10;
var TABPAGE_TABLE							= 11;
//== Starting tab ID for drilldowns and other dynamic tabs
var TAB_DYNAMIC_BEGIN					= 100;


//====================================================================================
//== Alarm "constants"
//====================================================================================
//== Window values represent the different distinct windows/screens for Alarms/Events functionality
var ALARM_WINDOW_LIST								= 1;
var ALARM_WINDOW_NEW								= 2;
var ALARM_WINDOW_MODIFY							= 3;
var ALARM_WINDOW_RECIPIENT_MODIFY		= 4;
var ALARM_WINDOW_RECIPIENT_ADD			= 5;
var ALARM_WINDOW_EVENTS							= 6;


//====================================================================================
//== Generic Functions
//====================================================================================

//== GetCookie											get a cookie value
function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  // a cookie with the requested name does not exist
  return null;
}

//== max														returns the max value of any parameters passed in
function max(){
	var vRet													= arguments[0];
	for (var iLoop = 0; iLoop < arguments.length; iLoop++ ){
		if ( arguments[iLoop] > vRet ){
			vRet													= arguments[iLoop]
		}
	}
	return vRet;
}

//== min														returns the min value of any parameters passed in
function min(){
	var vRet													= arguments[0];
	for (var iLoop = 0; iLoop < arguments.length; iLoop++ ){
		if ( arguments[iLoop] < vRet ){
			vRet													= arguments[iLoop]
		}
	}
	return vRet;
}

//== Bound													returns a "bounded" value
//==																	if varToLimit is too low or too high, returns the low or high value respectively
function Bound(varToLimit, lowVal, highVal){
	var retVal												= varToLimit;
	if (retVal < lowVal){
		retVal													= lowVal;
	}
	if (retVal > highVal){
		retVal													= highVal;
	}
	return retVal;
}

//== IsBetween											returns whether or not one value is between a high and low
function IsBetween(VarToCheck, low, high){
	var bRet						= false;
	if (IsDefined(VarToCheck)){
		if (IsDefined(low)){
			if (IsDefined(high)){
				try{
					if (VarToCheck >= low){
						if (VarToCheck <= high){
							bRet	= true;
						}
					}
				}catch(err){
				}
			}
		}
	}
	return bRet;
}


//====================================================================================
//== Parameter/Variable functions
//====================================================================================

//== IsDefined											Is the variable defined?
function IsDefined(varToTest){
	var bRet;
	if (varToTest == null) {
		bRet 														= false;
	}else{
		bRet 														= true;
	}
	return bRet;
}

//== NotNull												Is the variable defined AND not null? (does it have a value)
function NotNull(varToTest){
	//== First see if the variable is defined
	if (IsDefined(varToTest)){
		//== Variable is defined, but is it NOT null?
		return (varToTest != null);
	}else{
		//== Variable is not defined, so return "false" even though it is technically "not null" (it is undefined)
		//==		we do this because the real intention of this function is to see if a value has been assigned to the variable
		return false;
	}
}

//== DefaultValue										returns a default value if the value passed in is null or undefined
function DefaultValue(varToCheck, def){
	//== default the return value to "false"
	var vRet 													= false;
	//== Has the variable been assigned a value?
	if (NotNull(varToCheck)){
		//== There is a value assigned to the variable, return it
		vRet														= varToCheck;
	}else{
		//== There is not a value assigned to the variable, return the default value
		vRet														= def;
	}
	return vRet;
}


//====================================================================================
//== Message functions
//====================================================================================

//== NotImplemented									call when a feature has not been implemented yet
//==																	we will provide a common message, and it is easier to search through
//==																	code to find all of the "NotImplemented" calls when we are checking
//==																	to see what is still not implemented
function NotImplemented(sText){
	alert("NOT IMPLEMENTED: " + sText);
}

//== ToDo														simlar to "NotImplemented", but used more for a "to-do" list
function ToDo(sText){
	alert("TODO: " + sText);
}

//== Prototype											indicate that the user is in functionality that is still in "prototype" phase
//==																	this helps QA know not to test this functionality
function Prototype(sText){
	alert("PROTOTYPE SCREEN ONLY: " + sText);
}

//== AskYesNo												ask the user a "Yes/No" question using IE's "OK" and "Cancel" confirmation message
function AskYesNo(sText){
	sText									= sText + "\n\nClick OK to accept.";
	return (confirm(sText));
}

//====================================================================================
//== Window functions
//====================================================================================

//== AppWindow:											Finds the main EEM6 frameset window, even if the window you
//==																	are calling this from is in a pop-up window
function AppWindow(sWindowName, bDebug){
	bDebug														= DefaultValue(bDebug, false);
	var winNew 												= self;
	var winOld 												= self;
	var bTryAgain 										= true;
	try{
		winNew													= winOld.dialogArguments.TopWindow;
		bTryAgain												= false;
	}
	catch(err){
		winNew													= winOld;
	}
	while (bTryAgain){
		if (bDebug){
			DebugText("Finding window, current = " + winNew.name);
		}
		if (NotNull(sWindowName)){
			try{
				if (winNew.name == sWindowName){
					bTryAgain 								= false;
				}
			}catch(err){
				bTryAgain										= true;
			}
		}
		if (bTryAgain){
			try{
				winNew 											= winOld.top;
			}
			catch(er1){
				winNew 											= winOld;
			}
			if (winNew == winOld){
				try{
					winNew 										= winOld.opener;
				}
				catch(er2){
					winNew 										= winOld;
				}
			}
		}
		if (winNew == null){
			winNew 												= winOld;
		}
		if (winNew != winOld){
			bTryAgain 										= true;
			winOld 												= winNew;
		}else{
			bTryAgain 										= false;
		}
	}
	return winNew;
}	

//== EEM6															returns the main EEM6 window, where all of the main functions and variables live
var winEEM6 = null;
function EEM6(bDebug){
	bDebug															= DefaultValue(bDebug, false);
	if (winEEM6 == null){
		winEEM6 													= AppWindow("eem6", bDebug);
	}
	try{
		if (winEEM6.name == "eem6"){
			//== Found it
		}else{
			alert("Top window found was " + winEEM6.name);
		}
	}
	catch(er){
		alert("Could not find top window");
	}
	if (bDebug){
		DebugText("EEM6() window found was " + winEEM6.name);
	}
	return winEEM6;
}

function WindowOpen(sURL, sOptions){
    var oWin								= window.open(sURL, "_blank", sOptions);
}

function WindowOpenModal(sURL, sOptions){				
	var oArgs = new Object();
	oArgs.TopWindow = EEM6();
	self.showModalDialog(sURL, oArgs, sOptions);
}

function _WindowEnabler(win, bEnable){
	//== Have to use the .getElementsByTagName("frame") rather than
	//==	the win.frames collection, which does not accurately represent
	//==	frames that are added dynamically
	var aFrames						= win.document.getElementsByTagName("frame");
	for (var iLoop=0; iLoop < aFrames.length; iLoop++){
		try{
			_WindowEnabler(aFrames[iLoop].contentWindow, bEnable);
		}catch(err){
			//
		}
	}
	try{
		var oDoc						= win.document;
		if (NotNull(oDoc.body)){
			if ((win.IgnoreDisable == true) && (!bEnable)){
				return false;
			}
			var oDIV						= oDoc.getElementById("DIV_disable");
			if (oDIV == null){
				if (bEnable){
					oDoc.body.style.cursor			= "auto";
					//== nothing else to do
				}else{
					var oDIV						= oDoc.createElement("div");
					oDIV.id							= "DIV_disable";
	//				oDIV.style.backgroundImage		= "url(images/disabled.gif)";
	//				oDIV.style.backgroundRepeat		= "repeat";
					oDIV.style.height				= "100%";
					oDIV.style.left					= "0";
					oDIV.style.position				= "absolute";
					oDIV.style.top 					= "0";
					oDIV.style.width				= "100%";
					oDIV.style.zIndex				= "999";
					oDoc.body.appendChild(oDIV);
					oDoc.body.style.cursor			= "wait";
				}
			}else{
				if (bEnable){
					oDIV.style.zIndex				= "-999";
					oDoc.body.style.cursor			= "auto";
				}else{
					//== Move back on top
					oDIV.style.zIndex				= "999";
					oDoc.body.style.cursor			= "wait";
				}
			}
			oDoc.body.disabled						= !(bEnable);
		}
	}catch(err){
		DebugError("WindowEnabler", err);
	}
}

function WindowEnable(win){
	win = DefaultValue(win, self);
	_WindowEnabler(win, true);
}

function WindowDisable(win){
	win = DefaultValue(win, self);
	_WindowEnabler(win, false);
}

function WindowLaunched(win){
	return (win.parent.TabLaunch == true);
}

function WindowFit(win, el){
	try{
		win.dialogHeight			= (el.clientHeight+30) + "px";
	}catch(err){
		//
	}
}


//====================================================================================
//== Debugging functions
//====================================================================================

//== Debugging												checks to see if we are in debugging mode
function Debugging(){
	return (GetCookie("debugging") == 'true');
}

//== DebugCheck												is the "debugging" cooking turned on?
//==																		use Debug.html and NoDebug.html to control this
function DebugCheck(){
	if (Debugging()){
		if (NotNull(winDebugger)){
			winDebugger.close();
		}
		winDebugger = window.open(PATH_DEV + "debugger.html", "debugger");
		DebugText("Starting debugging...");
	}
}

//== DebugText												output debugging information to the debugging window
function DebugText(sText){
	if (EEM6().winDebugger != null){
		try{
			EEM6().winDebugger.document.write("&nbsp;"+sText, '<BR>');
		}catch(err){
		}
	}
}

//== DebugVar												debug a variable
function DebugVar(sName, v){
	if (IsDefined(v)){
		if (NotNull(v)){
			DebugText(sName + " exists: " + v);
		}else{
			DebugText(sName + " is null");
		}
	}else{
		DebugText(sName + " is not defined.");
	}
}

//== DebugObject										debug an object and all of its properties
function DebugObject(sName, obj){
	if (IsDefined(obj)){
		DebugText("Object " + sName + ":");
		DebugText("========================");
		try{
			for (var item in obj) {
				DebugText("&nbsp;&nbsp;&nbsp;&nbsp;" + item + "=" + obj[item]);
			}
		}
		catch(err){
			DebugError("Error examining '" + sName + "." + item + "'", err);
		}
	}else{
		DebugVar(sName, obj);
	}
}

//== DebugError											debug an error we "catch"ed
function DebugError(sMsg, e){
	DebugText("*** ERROR *************************************************");
	DebugText(sMsg);
	DebugText("Number = " + e.number);
	DebugText("Description = " + e.description);
	DebugText("Name = " + e.name);
	DebugText("Message = " + e.message);
	DebugText("***********************************************************");
}

//== ShowError											show an error to the user
function ShowError(sMsg, e){
	alert(	"*** ERROR *************************************************"
				+ "\n" + sMsg
				+ "\nNumber = " + e.number
				+ "\nDescription = " + e.description
				+ "\nName = " + e.name
				+ "\nMessage = " + e.message
				+ "\n***********************************************************");
}


//====================================================================================
//== String functions
//====================================================================================

//== TrimString												trims a string of trailing spaces
function TrimString (str) {
  return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}


//====================================================================================
//== Image functions
//====================================================================================

//== imageFile												returns a full filename for an image, must provide extension
function imageFile(img){
	return PATH_IMAGES + img;
}

//== GIF															returns the full path to a GIF file, do NOT pass the .gif extenstion
function GIF(img){
	return imageFile(img) + ".gif";
}

//== imageLoad												loads an image from the server
function imageLoad(arg, bUseDefaultPath) {
	bUseDefaultPath											= DefaultValue(bUseDefaultPath, true);
	oImg 																= new Image();
	if (bUseDefaultPath){
		oImg.src 													= imageFile(arg);
	}else{
		oImg.src													= arg;
	}
	DebugText("loaded image = " + oImg.src);
	return oImg;
}

//== imagesPreload									call this function and pass in the list of images (w/o path info)
//==																	that you want preloaded
//==																place the call in the <HEAD> section, but outside of any "eventOnLoad"
//==																	(put it "in-line" so it gets executed as IE parses the HTML file)
function imagesPreload(){
	for(var iLoop = 0; iLoop < arguments.length; iLoop++){
		imageLoad(arguments[iLoop]);
	}
}

//== chartsPreload							call this function and pass in the list of charts (with path info)
//==											that you want preloaded
//==										Very similar to imagesPreload, but different in that when preloading charts
//==											the server supplies the full path
function chartsPreload(){
	for(var iLoop = 0; iLoop < arguments.length; iLoop++){
		imageLoad(arguments[iLoop], false);
	}
}

//== imgChangeGIF						use on events onmouseover and onmouseout for IMG's representing buttons
function imgChangeGIF(newGIF){
	window.event.srcElement.src				= GIF(newGIF);
}

//== imgMouseovers						sets two images for a IMG element, one regular one, and one when you are over it
function imgMouseovers(oIMG, mainGIF, overGIF){
	oIMG.src							= GIF(mainGIF);
	oIMG.onmouseover					= new Function("this.src='" + GIF(overGIF) + "';");
	oIMG.onmouseout						= new Function("this.src='" + GIF(mainGIF) + "';");
}

function AnchorSetStatus(oA, sText){
	oA.onmouseover				= new Function("window.status='" + HTMLEncode(sText) + "';return true;");
	oA.onmouseout				= new Function("window.status=window.defaultStatus;return true;");
	oA.title					= sText;
}
function AnchorSetAction(oA, sJavaScript, sText){
	//== Use "href" instead of "onclick"
	//==	using "href" can sometimes give you an error "Access is Denied" when examining
	//==	the frame/window's properties where the <A> exists
	//==	it can also confuse IE's progress bar at the bottom of the browser window
	oA.href						= "#";
	//== Make sure there is a ";" at the end of the code
	if (sJavaScript.length > 0){
		if (sJavaScript.substr(sJavaScript.length-1,1) != ";"){
			sJavaScript			= sJavaScript + ";";
		}
	}
	//== Add code to set the returnValue to false, so the browser doesn't do weird stuff
	//==	to the window/frame this link is in (such as reset the display, scrolling to the left)
	sJavaScript					= sJavaScript + " try{window.event.returnValue=false;}catch(err){}";
	oA.onclick					= new Function("JavaScript:"+sJavaScript);
	//== Now set the anchor's descriptive information
	AnchorSetStatus(oA, sText);
}

function ButtonCreate(doc, sCaption, sDesc, sJavaScript){
	var oButton									= doc.createElement("input");
	oButton.type 							= "button";
	oButton.className						= "button";
	oButton.value							= sCaption;
	oButton.title							= sDesc;
	oButton.onmouseover						= new Function("window.status='" + HTMLEncode(sDesc) + "';return true;");
	oButton.onmouseleave					= new Function("window.status=window.defaultStatus;return true;");
	oButton.onclick							= new Function("JavaScript:" + sJavaScript);
	return oButton;
}


function RequestResult(fra, sName){
	var oA;
	var sRet						= new String();
	try{
		oA							= fra.document.getElementById(sName);
	}catch(err){
		oA							= null;
	}
	if (oA == null){
		sRet 						= "";
	}else{
		sRet						= oA.innerText;
	}
	return sRet;
}

//== HTMLEncode						take a text string and replace quotes and such with their 
//==									"escape characters".
//==								use when doing stuff like :
//==									sCode = "alert('The object name is " + HTMLEncode(o.name) + ");";
function HTMLEncode(sText){
	var sRet						= sText;
	//== Backslash (make sure to do this first!)
	sRet							= sRet.replace(/\\/g, "\\\\");
	//== Single Quote
	sRet							= sRet.replace(/'/g, "\\\'");
	//== Double Quote
	sRet							= sRet.replace(/"/g, '\\\"'); 		
	//== New Line
	sRet							= sRet.replace(/\n/g, "\\n");
	//== Carriage Return
	sRet							= sRet.replace(/\r/g, "\\r");
	//== Form Feed
	sRet							= sRet.replace(/\f/g, "\\f");
	return sRet;
}

//== HTMLToDB						use this to pass the value of a <input> control to the database via
//==									the URL request string
function HTMLToDB(sValue){
	var sRet						= sValue;
	//== Convert actual <CR><LF> characters to a simple "\n" string
	sRet							= sRet.replace(/\r\n/g, "\\n");
	return sRet;
}

//== DBToHTML						take a value originating from the database and convert it to something we
//==									can display in HTML
function DBToHTML(sValue){
	var sRet						= sValue;
	//== Convert the /n stored in Oracle to a \n escape character
	sRet							= sRet.replace(new RegExp("/n", "g"), "\n");
	return sRet;
}
	
	

//====================================================================================
//== Request "constants"
//====================================================================================
//== Status codes
var REQUEST_STATUS_NONE			= 0;
var REQUEST_STATUS_WAITING		= 1;
var REQUEST_STATUS_DONE			= 10;
var REQUEST_STATUS_ERROR		= 11;
var REQUEST_STATUS_TIMEOUT		= 12;
var REQUEST_STATUS_ABORTED		= 13;

//== Error codes
var REQUEST_ERROR_ACCESS		= 1;		//== "Access Denied"
var REQUEST_ERROR_NOTFOUND		= 2;		//== "Resource Not Found"
var REQUEST_ERROR_TIMEOUT		= 3;		//== we timed out waiting
var REQUEST_ERROR_SESSION		= 4;		//== dataminer.dll told us we were missing session
var REQUEST_ERROR_NOT_RECEIVED	= 10;		//== fEmptyResult.html was not sent back
var REQUEST_ERROR_FOUND_MSG		= 11;		//== fEmptyResult.html contained a "ErrorMsg" anchor
var REQUEST_ERROR_DOCACCESS		= 12;		//== IE/JavaScript error: could not access document
var REQUEST_ERROR_NODATA		= 13;		//== No Data Available returned from server

//== Actions to perform on errors
var REQUEST_ACTION_NONE			= 0;		//== Do nothing on an error
var REQUEST_ACTION_DELETE		= 1;		//== Delete all outstanding requests

var REQUEST_TYPE_NORMAL			= 0;
var REQUEST_TYPE_WINDOW			= 1;
var REQUEST_TYPE_POPUP			= 2;

function RequestResultObj(sName, sValue){
	this.Name									= sName;
	this.Value									= sValue;
	this.ArrayIndex								= null;
}

//====================================================================================
//== Request object, used for adding new requests to the SessionObj 
//==	see EEM6Session.js for info on SessionObj
//====================================================================================
function RequestObj(dest, sRequest, sParams, bWait){
	//== RequestID                  Unique (for this session) request ID
	this.RequestID                   = null;
	//== Destination                Window, frame or iframe to load (or even a "Popup=..." string
	this.Destination                 = dest;
	//== DestName                   The name of the window/frame we are loading into
	this.DestName                    = "";
	this.RequestType                 = REQUEST_TYPE_NORMAL;
	this.WindowParams                = "";
	//== Request                    Dataminer request path, such as "/HierRoot"
	this.Request                     = sRequest;
	//== Params                     Parameters that the request needs, excluding SID
	this.Params                      = sParams;
	//== EncodeParams		Encode the parameters?  Translate spaces to %20 and such
	this.EncodeParams                = false;
	//== URL                        Actual URL that is dynamically generated from 
	//==                             this.Request, this.Params, Session.SessionParam and the actual dataminer.dll
	this.URL                         = "";
	//== onLoad                     Code to execute after a successful load
	this.onLoad                       = "";
	//== onError                    Code to execute after an error occurs
	this.onError                      = "";
	//== Status                     Indicates the status of the request
	this.Status                       = REQUEST_STATUS_NONE;
	//== WaitForResponse            Boolean of whether or not this request must be completed before any
	//==                            additional requests after it in the queue can be called
	this.WaitForResponse             = bWait;
	//== WaitForever                Should we wait forever, or can we timeout?
	this.WaitForever                 = false;
	//== TimeRequested              The date/time the request was made
	this.TimeRequested               = null;
	//== TimeCompleted              The date/time the request was completed
	this.TimeCompleted               = null;
	//== TimeoutSeconds             number of seconds before timeout of this request
	this.TimeoutSeconds              = TIMEOUT_SERVER;
	//== Results                    An array of values loaded in if the "CheckResults" is true (fEmptyResult.html)
	//==                            Reads in all of the <a> elements
	this.Results                     = [];
	//== ErrorCode                  Error code, if any
	this.ErrorCode                   = 0;
	//== ErrorText                  Any error information
	this.ErrorText                   = "";
	//== CheckResults               if returning a version of fEmptyResult.html into fraResults
	//==                            set this to true so we will automatically look for
	//==                            the <a> object with id="received" to verify that it came back
	//==                            as well as a <a> object with id="ErrorMessage"
	this.CheckResults                = false;
	//== NoResult                   if the request does not return any result at all, set this to true
	this.NoResult                    = false;
	//== ErrorHandled               whether or not the system handled the error for this request automatically
	this.ErrorHandled                = false;
	//== ErrorAction                What to do when an error occurs
	//==                            default to deleting all outstanding requests
	this.ErrorAction                 = REQUEST_ACTION_DELETE;
	//== ResultValue                given a result name, returns the corresponding value (if any)
	this.ResultValue                 = function(sName){
                                             var sRet = "";
                                             for (var iLoop=0; iLoop < this.Results.length; iLoop++){	
                                               if (this.Results[iLoop].Name.toUpperCase() == sName.toUpperCase()){
                                                 sRet = this.Results[iLoop].Value;
                                                 break;
                                                 }
                                               }
                                             return sRet;
                                           }
                                           
	//== Description                used for debugging and such
	this.Description                 = function(){
                                             return ("["+this.RequestID+"] " + this.Destination.name + "=" + this.URL);
                                           }
	//== Loaded                     did this request load OK?
	this.Loaded                      = function(){
                                             return (this.Status == REQUEST_STATUS_DONE);
                                           }
	//== init                       called when a new instance is created
	this.init                        = function(){
                                             if (this.Destination == null){
                                             //== Send the results to the hidden frame "fraResults"
                                               this.Destination	         = EEM6().fraResults;
                                             //== Indicate that this is a
                                               this.CheckResults         = true;
                                             }
                                             try{
                                               var sText	= this.Destination;
                                               sText	= sText.toLowerCase();
                                               var aVals;
                                               switch (true){
                                                 case (sText.search("popup")==0):
                                                   aVals	            = sText.split("popup=",2);
                                                   this.DestName	    = "Popup";
                                                   this.RequestType  = REQUEST_TYPE_POPUP;
                                                   this.WindowParams = aVals[1];
                                                   this.Destination  = null;
                                                   break;
                                                 case (sText.search("window")==0):
                                                   aVals             = sText.split("window=",2);
                                                   this.DestName     = "Window";
                                                   this.RequestType  = REQUEST_TYPE_WINDOW;
                                                   this.WindowParams = aVals[1];
                                                   this.Destination  = null;
                                                   break;
                                                 default:
                                               }
                                             }catch(err){
                                               //== Not a bad error, this probably just means that this.Destination is a real frame/window
                                               try{
                                                 this.DestName       = this.Destination.name;
                                               }catch(err){
                                                 this.DestName       = "unknown";
                                               }
                                             }
                                           }
        this.init();
}
	
