/******************************************************************************/
/*  CLASS: 		Browser									*/
/*  DESCRIPTION:	"Sniffs" user browser name and version to populate 		*/
/*			cross-browser common characteristics, DOM switch variables	*/
/*			and window manipulation methods.					*/
/*  PROPERTIES:	User browser identification						*/
/*			majorVer - user browser major version (float)			*/
/*			minorVer - user browser minor version (float)			*/
/*			ns	   - Netscape user browser boolean				*/
/*			ns4	   - Netscape 4.04+ user browser boolean			*/
/*			ie	   - Internet Explorer user browser boolean		*/
/*			ie4	   - Internet Explorer 4+ user browser boolean		*/
/*													*/
/*			User browser client area						*/
/*			NOTE: for IE4 these properties are valid when the document	*/
/*			      has been loaded, hence they are useful only when the	*/
/*				object has been instantiated within an "onload" event	*/
/*				of the <BODY> tag; this implies that extending this	*/
/*				class will set these properties invalid (i.e. -1)	*/
/*			clientWidth	 - browser client width in pixels (int)		*/
/*			clientHeight - browser client height in pixels (int)		*/
/*													*/
/*			User browser DOM switch variables					*/
/*			sDoc - document object reference (string)				*/
/*			sHtm - inner HTML object reference (string)			*/
/*			sSty - style object reference (string)				*/
/*  METHODS:	OpenWindow									*/
/*  NOTE:		NN4.04+, IE4+ Implementation (JavaScript 1.2)			*/
/******************************************************************************/

////////////////////////////////////////////////////////////////////////////////
//  CONSTRUCTOR: 	Browser									//
//  DESCRIPTION: 	Instantiates the browser object					//
////////////////////////////////////////////////////////////////////////////////

function Browser() {

	// Local variable
	var sBrowser = navigator.userAgent.toLowerCase();	// browser string 
    
	// Object properties
	
	// browser type specifics: major and minor version
	//			   	   Netscape or Internet Explorer
	//			   	   versions NN4.04+ and IE4+
	this.majorVer	= parseInt(navigator.appVersion);
	this.minorVer	= parseFloat(navigator.appVersion);
    	this.ns		= ((sBrowser.indexOf('mozilla') != -1) && 
			   	  (sBrowser.indexOf('spoofer')== -1) && 
			   	  (sBrowser.indexOf('compatible') == -1));
    	this.ns4     	= (this.ns && (this.majorVer >= 4) && 
				  (this.minorVer > 4.04));
    	this.ie      	= sBrowser.indexOf("msie") != -1;
	this.ie4     	= this.ie && (this.majorVer >= 4);

	// browser window client area: client width
	//					 client height
	this.clientWidth	= this.ns ? innerWidth : 
				  (document.body ? document.body.clientWidth : -1);
	this.clientHeight	= this.ns ? innerHeight : 
				  (document.body ? document.body.clientHeight : -1);

	// browser DOM references: document objects
	//				   style sheet objects
	//				   inner HTML objects
	this.sDoc		= this.ns ? "document" : "document.all";
	this.sSty		= this.ns ? "" : ".style";
	this.sHtm		= this.ns ? ".document" : "";
	
	// Object methods
	this.OpenWindow = OpenWindow;
}

////////////////////////////////////////////////////////////////////////////////
//  METHOD: 	OpenWindow									//
//  PARAMETERS:	sURL 	    - URL to display in bowser window (string)		//
//			sName	    - name of the window (string)				//
//			iLeft     - x-position with respect to screen in pixels(int)//
//			iTop	    - y-position with respect to screen in pixels(int)//
//			iWidth    - window width in pixels (int)				//
//			iHeight   - window height in pixels (int)				//
//			sOptFtres - comma separated window optional features 		//
//					(string), which may be:					//
//					  toolbar     - toolbar visibility 			//
//					  location    - location text field visibility	//
//					  directories - directory buttons visibility	//
//					  status      - status bar visibility		//
//					  menubar     - menubar visibility   		//
//					  scrollbars  - scrollbars visibility		//
//					  resizable   - resize allowance			//
//					e.g. "toolbar,menubar,status"				//
//  RETURNS:	Window object handler							//
//  DESCRIPTION: 	Opens a browser window according to the dimensions and	//
//			features specified in the above parameters.			//
////////////////////////////////////////////////////////////////////////////////

function OpenWindow(sURL, sName, iLeft, iTop, iWidth, iHeight, sOptFtres) {

	// Local variables
	var oWnd 	     = null;
	var sWndFeatures = "";

	// Form window position and dimensions string if set
	if(iLeft && iTop && iWidth && iHeight) {
		sWndFeatures = "left=" + iLeft + ",top=" + iTop + 
				   ",width=" + iWidth + ",height=" + iHeight;
	}

	// Trim any spaces found in the optional window features string
	sOptFtres = sOptFtres.replace(/\s*/g, "");

	// Concatenate the optional features string
	if (sOptFtres) {
		if(sWndFeatures) {
			sWndFeatures += ",";
		}
		sWndFeatures += sOptFtres;
	}

	// Open the browser widnow as specified and give focus
	if (this.ns4 || this.ie4) {
		oWnd = window.open(sURL, sName, sWndFeatures);
		oWnd.focus();
	}

	// Return the window object
	return (oWnd);
}