
	// http://www.elated.com/tutorials/programming/javascript/cookies/
	function getCookie ( cookie_name ) {
		// below regexp barfs on a mac ie5 :-((
		var re = new RegExp(cookie_name+"=(.*?)(;|$)");
		var results = document.cookie.match(re);
		//var results = document.cookie.match(cookie_name + '=(.*?)(;|$)' );
		if ( results ) return ( unescape ( results[1] ) );
		else  return null;
	}
	
	function setCookie  ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) {
	
		var cookie_string = name + "=" + escape ( value );
		if ( exp_y )   {
			var expires = new Date ( exp_y, exp_m, exp_d );
			cookie_string += "; expires=" + expires.toGMTString();
		}
		if ( path ) cookie_string += "; path=" + escape ( path );
		if ( domain ) cookie_string += "; domain=" + escape ( domain );
		if ( secure ) cookie_string += "; secure";
		document.cookie = cookie_string;
	}
	
	/*
		use 
			<a href="hier.html" target="_blank"
				onclick="getWindow('viewer','hier.html'); return false">hier</a>
		will follow the link if for some reason the window does not open
		like, if you dont have javascript
		
	*/

	function getWindow(name,url,options) {
	
		// some (named) windows always have the same options,
		if (name=="extern") {
			if (!options) {
				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 (name=="showcase") {
			if (!options) {
				options = "toolbar=yes,location=yes,directories=no,menubar=yes";
				options += ",status=yes,scrollbars=yes,resizable=yes";
				options += ",top=100,left=100,width=600,height=600";
				// explorer opts
				options += ",channelmode=no,fullscreen=no,titlebar=yes";
				// mozilla opts
				options += ",copyhistory=no";
			}
		}
		
		if (name=="viewer") {
			if (!options) {
				options = "toolbar=no,location=no,directories=no,menubar=no";
				options += ",status=yes,scrollbars=yes,resizable=yes";
				options += ",top=100,left=100,width=500,height=500";
				// explorer opts
				options += ",channelmode=no,fullscreen=no,titlebar=yes";
				// mozilla opts
				options += ",copyhistory=no";
			}
		}
		
		// other windows use defaults
		if (!options) {
			options = "toolbar=yes,location=yes,directories=no,menubar=yes";
			options += ",status=yes,scrollbars=yes,resizable=yes";
			options += ",top=100,left=100,width=500,height=400";
			// explorer opts
			options += ",channelmode=no,fullscreen=no,titlebar=yes";
			// mozilla opts
			options += ",copyhistory=no";
		}	
		
		// remember the window and focus it
		if (!top.popups) top.popups = new Array();
		top.popups[name] = self.open(url, name, options); 
		// ie4 bug
		if (!top.popups[name].focus) top.popups[name].focus = false;
		if (top.popups[name].focus) top.popups[name].focus();
		
		return top.popups[name];
	}
	
	
