// .............................................................................

function CookieHandler() {
	/*  Javascript cookies - http://www.webtoolkit.info/   */
	/*
	<script type="text/javascript">
		var Cookies = new CookieHandler();
		var counter = Cookies.getCookie('counter'); // get cookie 'name'
		if (typeof(counter) == 'undefined') counter = 0;
		Cookies.setCookie('counter', ++counter, 365*60*60); // set cookie 'counter' for 1 year
	</script>
	<script type="text/javascript">
	document.write('How many times did you visit this page ? - ' + counter);
	</script>
	*/

	this.setCookie = function (name, value, seconds) {
		if (typeof(seconds) != 'undefined') {
			var date = new Date();
			date.setTime(date.getTime() + (seconds*1000));
			var expires = "; expires=" + date.toGMTString();
		}
		else {
			var expires = "";
		}
		document.cookie = name+"="+value+expires+"; path=/";
	}
	
	this.getCookie = function (name) {
		name = name + "=";
		var carray = document.cookie.split(';');
		for(var i=0;i < carray.length;i++) {
			var c = carray[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(name) == 0) return unescape(c.substring(name.length,c.length).replace(/\+/g,' '));
		}
		return ''; //null;
	}
	
	this.deleteCookie = function (name) {
		this.setCookie(name, "", -1);
	}
}

// .............................................................................

function toggleLayer (whichLayer, action) {
	var elem, vis;
	if (document.getElementById) // this is the way the standards work
		elem = document.getElementById( whichLayer );
	else if (document.all) // this is the way old msie versions work
		elem = document.all[whichLayer];
	else if(document.layers) // this is the way nn4 works
		elem = document.layers[whichLayer];
	vis = elem.style;

	if (action=='show') {
		vis.display = 'block';
	} else if (action=='hide') {
		vis.display = 'none';
	} else { 
		// if the style.display value is blank we try to figure it out here
		if ((vis.display=='') && (elem.offsetWidth!=undefined) && (elem.offsetHeight!=undefined))
			vis.display = (elem.offsetWidth!=0 && elem.offsetHeight!=0)?'block':'none';
		vis.display = (vis.display==''||vis.display=='block')?'none':'block';
	}
}

// .............................................................................