


		// globals

		var innerWidth	= 0;
		var innerHeight = 0;
		var top			= 0;
		var left		= 0;
		var calculated_height = 0;
		var showroomNeedDetails;
		var eric_window = 'undefined';
		
		function setDimension(){
			if (screen.width == 800) {
				this.innerWidth = screen.width - 10;
				this.innerHeight = screen.height - 58;
				
				calculated_height = this.innerHeight;		
			} else {		
				this.innerWidth = 1014;  
				this.innerHeight = 740;  
		
				var browser = navigator.userAgent.toLowerCase(); 
				var isMS_IE = (browser.indexOf("msie") != -1); 		
				
				if (isMS_IE) 
					calculated_height = 705;
			}
		}
		
		function setPosition() {
			setDimension();
			if (screen.width > 1024) {
				this.top  = ( screen.height - this.innerHeight ) / 2;
				this.left = ( screen.width - this.innerWidth ) / 2;
			}
		}
		
		function setSmallDimension(){
			this.innerWidth = 400;
			this.innerHeight = 300;
		}
		
		function openPopup(controllerURIPath, parameter) {
			openNamedPopup(controllerURIPath, parameter, "popup");
		}
		
		function openNamedPopup( controllerURIPath, parameter, name ) {
			setPosition();	
			openParamPopup(controllerURIPath, parameter, name, this.left, this.top, 'no');
		}
		
		function openPopupWithScrollbar( controllerURIPath, parameter, name ) {
			setPosition();	
			openParamPopup(controllerURIPath, parameter, name, this.left, this.top, 'yes');
		}
		
		function openParamPopup( controllerURIPath, parameter, name, left, top, scrollbars ) {
			window.open(
				controllerURIPath + "?" + parameter,
				name, // "_blank"
				"toolbar=no,location=no,directories=no," + 
				"status=no," +
				"menubar=no,scrollbars=" + scrollbars +
				", resizable=no,copyhistory=no,dependent=yes," +
				"top=" + top + 
				",left=" + left + ", width="+this.innerWidth+ ", height=" + calculated_height);
				
		//		+ ",screenX=0,screenY=0,fullscreen=1"
		}
		
		function newWindow( controllerURIPath, parameter, name) {		
			if (this.eric_window == 'undefined') {			
				this.eric_window = openPopupWithScrollbar( controllerURIPath, parameter, name);
				this.eric_window = 'undefined'; //reset the var.
			}
			else {
				this.eric_window.location.href=controllerURIPath + "?" + parameter;
			}
		}
		
		/*
		http://www.faqts.com/knowledge_base/view.phtml/aid/844/fid/124
		
		NN4 has a undocumented modal feature for the window.open function but 
		this requires trusted script:
		  netscape.security.PrivilegeManager.enablePrivilege
		('UniversalBrowserWrite');
		  var w = open ('http://www.faqts.com', 'faqts', 
			  'modal=1,width=300,height=300,rezisable=1,scrollbars=1');
		
		The given goodman url has a cross browser modal window simulation.
		
		It seems that NN6 has
		  openDialog('url', 'windowName', 'modal=1,width=300,height=300')
		
		*/
		
		function openModalWindow (parentForm, parameter, url, width, height ) {
			var	features =	
		//		"status:yes" +
				"status:no" +
		//		";scrollbars:no" +
				";resizable:no"+
				";center:yes"+
				";dialogWidth:" + width + "px" +
				";dialogHeight:" + height + "px";
		
			var argumentsObject = new Object();
			argumentsObject.parentForm = parentForm;
			argumentsObject.parameter = parameter;
			return showModalDialog(url, argumentsObject, features);
		}
		
		function openParamModalWindow (parameterElement, parentForm, parameter, url, width, height ) {
			var	features =	
		//		"status:yes" +
				"status:no" +
		//		";scrollbars:no" +
				";resizable:no"+
				";center:yes"+
				";dialogWidth:" + width + "px" +
				";dialogHeight:" + height + "px";
		
			var argumentsObject = new Object();
			argumentsObject.parameterElement = parameterElement;
			argumentsObject.parentForm = parentForm;
			argumentsObject.parameter = parameter;
			return showModalDialog(url, argumentsObject, features);
		}
		
		function openTipWindowWithContent (evt, title, htmlContent, width, height) {
			var w = openTipWindow(evt, '', title, width, height)
			writeInWindow( w, htmlContent );
		}
		
		function openTipWindowFromUrl (evt, url, title, width, height) {
			return openTipWindow (evt, url, title, width, height);
		}
		
		function openTipWindow (evt, url, title, width, height) {
			var x = evt.screenX - width + 3;
			var y = evt.screenY - 10;
			var w = open ( url, title, 
				'width=' + width + ',height=' + height
				 + ',screenX=' + x + ',left=' + x
				 + ',screenY=' + y + ',top=' + y 
				 + ',toolbar=no,location=no,directories=no,resizable=no,status=no,menubar=no,scrollbars=yes,dependent=yes');
		//	w.document.onMouseout = close();
			return w;
		}
		
		function writeInWindow (w, htmlContent) {
			w.document.open();
			w.document.write( wrapContent( htmlContent ) );
			w.document.close();
		}
		
		function wrapContent (htmlContent) {
			return '<HTML><BODY SCROLL="auto" ONBLUR="window.close();"' 
				+ ' BGCOLOR="lightyellow">' 
				+ '<TABLE WIDTH="100%" HEIGHT="100%"><TR>' 
				+ '<TD ALIGN="center" VALIGN="middle">' 
				+ '<B>' + htmlContent + '<\/B>' 
				+ '<\/TD><\/TR><\/TABLE><\/BODY><\/HTML>';
		}
		
		function getPopup(){
			return document.getElementById("popup");
		}
		
		function centerPopup(){
			alert("centerPopup" );
			
			var popup = getPopup();
			
			popup.style.left = (window.innerWidth - popup.offsetWidth) / 2;
			popup.style.top = (window.innerHeight - popup.offsetHeight) / 2;
		}
		
		function setPopupVisibility( visibility ){
			getPopup().style.visibility = ( visibility ? "visible" : "hidden" );
		}

