
	Windows = new WindowsLib();
	
	function WindowsLib() {
		this.childWindows = new Array();
		this.open 	= WDWSOpen;
		this.fix 	= WDWSFix;
		this.set 	= WDWSSet;
		this.max 	= WDWSMax;
		this.parseOptions 	= WDWSParseOptions;
		this.getDim 		= WDWSGetDim;
		
	}
	
	function WDWSOpen(url,name,options) {
	
		//add your name / settings prefs below
		
		if (name=="extern") {
			options = "toolbar=yes,location=yes,directories=no,menubar=yes";
			options += ",status=yes,scrollbars=yes,resizable=yes";
			options += ",top=20,left=20,width=600,height=400";
			// explorer opts
			options += ",channelmode=no,fullscreen=no,titlebar=yes";
			// mozilla opts
			options += ",copyhistory=no";
		}
		if (!options) {
			options = "toolbar=yes,location=yes,directories=no,menubar=yes";
			options += ",status=yes,scrollbars=yes,resizable=yes";
			options += ",top=20,left=20,width=500,height=300";
			// explorer opts
			options += ",channelmode=no,fullscreen=no,titlebar=yes";
			// mozilla opts
			options += ",copyhistory=no";
		}	
		
		// ie5 bugs on the line below
		//if (this.childWindows[name] && this.childWindows[name].close) this.childWindows[name].close();
		
		this.childWindows[name] = self.open(url, name, options); 
		if (this.childWindows[name]) {
			// below is for IE5/mac - weird prop access bug
			if (!this.childWindows[name].closed &&
				this.childWindows[name].focus ) {
				this.childWindows[name].focus() 
			}
		}
	}

	function WDWSFix(options) {
		
		// this will only apply that part of the options
		// that the browser supports. for ie, thats not much
		
		var optarr = this.parseOptions(options);
		
		if (window.scrollbars && optarr["scrollbars"]) 		window.scrollbars.visible 	= optarr["scrollbars"];
		if (window.personalbar && optarr["personalbar"]) 	window.personalbar.visible 	= optarr["personalbar"];
		if (window.menubar && optarr["visible"]) 			window.menubar.visible 		= optarr["visible"];
		if (window.locationbar && optarr["locationbar"]) 	window.locationbar.visible 	= optarr["locationbar"];
		if (window.statusbar && optarr["statusbar"]) 		window.statusbar.visible 	= optarr["statusbar"];
		if (window.toolbar && optarr["toolbar"]) 			window.toolbar.visible 		= optarr["toolbar"];
		if (optarr["left"] || optarr["top"]) {
			if (window.moveTo) 		window.moveTo(optarr["left"],optarr["top"]);
		}
		if (optarr["width"] && optarr["height"]) {
			if (window.resizeTo) 	window.resizeTo(optarr["width"],optarr["height"]);
		}

	}
	
	function WDWSFixx(options) {
		
		// for ie, this will open a new window with these
		// options and close the current one. this is the ugly
		// popup trick that ruins the web
		
		if (window.toolbar) {
			// moz
			this.fix(options);
		} else {
			// ie
			if(document.location.search.indexOf('fixWindow=done')==-1) {
				var newurl = document.location.href;
				var sep = (document.location.search=="")?"?":"&";
				newurl += sep+"fixWindow=done";
				var newwin = self.open(newurl,self.name+"fixed",options);
				newwin.opener = self.opener;
        		self.close();  
			}
		}
	}
	
	//moz & ie >5
	function WDWSSet(whandle,w,h,x,y) {
		if (!whandle) whandle = top;
		if (whandle.moveTo && whandle.resizeTo) {
			whandle.resizeTo(w,h);
			whandle.moveTo(x,y);
		}
	}
	
	// moz & ie > 5
	function WDWSMax(whandle) {
		if (!whandle) whandle = top;
		if (whandle.moveTo && whandle.resizeTo && screen.availWidth && screen.availHeight) {
			whandle.moveTo(-4,-4);
			whandle.resizeTo(screen.availWidth+8,screen.availHeight+8);
		}
	}
	
	function WDWSParseOptions(options) {
		// splits an options string in an array
		var optarr = new Array();
		var nexttok = 0;
		while (options.length) {
			nexttok = options.indexOf(",");
			if (nexttok==-1) nexttok = options.length;
			var elm = options.substring(0,nexttok);
			options = options.substring(elm.length+1,options.length);
			var key = elm.substring(0,elm.indexOf("="));
			var val = elm.substring(elm.indexOf("=")+1,elm.length);
			optarr[key]=(val=="yes"||val =="1");
			if (!optarr[key]) optarr[key]=(val=="no"||val=="0")?false:val;
		}
		//alert(key+":"+optarr[key]);
		return optarr;		
	}

	// http://www.evolt.org/article/document_body_doctype_switching_and_more
	
	function WDWSGetDim(whandle) {
		var w; var h; var handle;
		
		if (window.innerWidth) {
			w = window.innerWidth;
			h = window.innerHeight;
			
		// moz & ie compat mode
		} else if (whandle.document.documentElement) 
			handle =  whandle.document.documentElement;
		
		// ie standard
		else if (whandle.document.body) 
			handle =  whandle.document.body;
		
		if (handle) {
			w = handle.clientWidth;
			h = handle.clientHeight
		} 
		return new Array(w,h);
	}
