/*
##############################################################################
## <SOURCE
## Company  = "Four J's Development Tools"
## Project  = "Four J's Web Front End"
## Type     = "Module"
## Name     = "fgldebug.js"
## Comment  = "API to launch the debugger"
## Version  = "1.1.00.00"
## Language = "Javascript"
## />
##############################################################################
## <UPDATE Version="1.0.00.00" Date="2002/06/07" Author="tb">
##   <DESCRIPTION>
##      Creation. 
##   </DESCRIPTION>
## </UPDATE>
##############################################################################
## <DESCRIPTION> <![CDATA[ 
## ]]></DESCRIPTION>
##############################################################################
## <CVS_INFO><![CDATA[
## ]]></CVS_INFO>
##############################################################################
*/
//////////////////////////////////////////////////////////////////////////////
//                        GLOBAL VARIABLES
//////////////////////////////////////////////////////////////////////////////

var body_onload =null; //function pointer
var strWinName; //name of the debugger window

/////////////////////////////////////////////////////////////////
// Function:  fjsRunDebugger
//
// Parameter: none
//
// Returning: none
//
// Comments: enables you to use body.onload
///////////////////////////////////////////////////////////////// 

function fjsPrepareToRunDebugger() {

    if (navigator.appName== "Netscape") {
    	//this is a trick to be sure the page is loaded
    	window.setTimeout(fjsRunDebugger, 500);
    }
    else { //for internet explorer
        body_onload = document.body.onload;
	document.body.onload = fjsRunDebugger; // prepares the window to start the debugger
    }
}


/////////////////////////////////////////////////////////////////
// Function:  fjsRunDebugger
//
// Parameter: none
//
// Returning: none
//
// Comments: runs the debugger
///////////////////////////////////////////////////////////////// 
  function fjsRunDebugger() {
  	
  	strWinName = "fjs_debug_win_";
  	if (window.opener && window.opener.name.substr(0,14) == strWinName) {
  		
  		strWinName=window.opener.name;
  	}
  	else {
  		strWinName = "fjs_debug_win_" + document.forms[0].action.replace(/.*=|.*@|\//g,"");
  	}

	if (body_onload) body_onload(); //call to the body onload function
	  	
	if (window.opener == null || window.opener.name != strWinName) {
		//opens the debugger
		window.opener=window.open("/fjs/fglwd/fglwdui.htm", strWinName, "height=590,width=750,directories=0,hotkeys=0,location=0,personalbar=0,toolbar=0,menubar=0,resizable=yes");
	        window.onunload=notifyDebuggerWindowUnload;
	}
	else {
		window.opener.update(); //asks for the update of the debugger window
	}
  }
  
/////////////////////////////////////////////////////////////////
// Function:  notifyDebuggerWindowUnload
//
// Parameter: none
//
// Returning: none
//
// Comments: notifies the debugger window that the unload event
//	     has happened on the application window
///////////////////////////////////////////////////////////////// 
  function notifyDebuggerWindowUnload() {
  	
	if (window.opener != null && !window.opener.closed && window.opener.name == strWinName) {

	  	window.opener.prepareForTestingIfParentIsClosed();
	}
	
  }




