//	==========================================================================
//			Global variable definitions
//	==========================================================================
	var ns6up =				(document.getElementById && !document.all) ? 1 : 0;

	var agent =				navigator.userAgent;
	var opera =				agent.indexOf("Opera") > 0;
	var menu =				"display:''"
	var submnu =			'';
	var debug =				false;

	function expandMenu(selObj)  {
	//	This function turns on/off text in the browser window
	//		<span style="display:none" onclick='expandMenu(this)'> ... stuff ... </span>
		if (ns6up || opera)
			submnu =		selObj.nextSibling.nextSibling.style;
		else
			submnu =		document.all[selObj.sourceIndex+1].style;
			
		submnu.display =	submnu.display == "none" ? "" : "none";
	}

//	Remove ?, & and # from a text that will be passed as part of a URL
	function encode(text) {
		return text.replace(/\?/g,":1").replace(/\&/g,":2").replace(/\#/g,":3").replace(/'/g,":4").replace(/"/g,":5");
	}

//	Replace the ?, & and # from a text that were removed from a text
	function decode(text) {
		return text.replace(/:5/g,"\"").replace(/:4/g,"'").replace(/:3/g,"#").replace(/:2/g,"&").replace(/:1/g,"?");
	}

//	Utility to open a new window
	function openWindow(url,type) {
		var wdo;
		switch (type) {
			case 'INFO':
				wdo = window.open(url,type,'menuBar=yes,location=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=1000,height=800,screenX=32,screenY=32,top=32,left=32');
				break;
			case 'HELP':
				wdo = window.open(url,type,'scrollbars=yes,resizable=yes,height=900,width=640,screenX=32,screenY=32,top=32,left=32').focus();
				break;
			case 'MAIL':
				wdo = window.open("MailTo.asp?code=URL&data=" + encode(url) + "&title=" + encode(document.title),type,"width=420,height=400,screenX=32,screenY=32,top=32,left=32");
				break;
			case 'SHOP':
				wdo = window.open(url,type,'location=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=380,height=450,screenX=32,screenY=32,top=32,left=32');
				break;
			case 'XCPT':
				var wdth = Math.min(window.screen.width - 16,860);
				var hght = window.screen.height - 96;
				wdo = window.open("Excerpt.asp?url=" + url + "&width=" + wdth + "&height=" + hght,type,'resizable=yes,width=' + wdth + ',height=' + hght + ',screenX=4,screenY=4,top=4,left=4');
				break;
			default:
				break;
		}
		if (wdo)
			wdo.focus();
		return;
	}

	function setPswd(pswd) {
		var expire = new Date();
		expire.setTime(expire.getTime() + 5*365*24*3600*1000);
		document.cookie = "PassWd="+escape(pswd)+";Expires="+expire.toUTCString()+";path=/";
		return true;
	}

	function deBlank(text) {
		return text.replace(/(^\s*)|(\s*$)/g,"");
	}
	
	function mailPage(level) {
		window.open(level+"../cgi-bin/MailTo.asp?code=URL&data=" + encode(document.URL) + "&title=" + encode(document.title),'MAIL',"width=420,height=400,screenX=32,screenY=32,top=32,left=32").focus();
	}

	function checkMailPage(URL,title) {
		try {
			var phase =			"recipients";
			var recipient =		checkEmailList(document.Mailer.toMail.value);
			if (recipient == "") {
				alert			("Please enter a valid recipient e-mail address");
				return false;
			} else
				document.Mailer.toMail.value = recipient;

			phase =				"sender";
			var sender =		checkEmail(document.Mailer.fromMail.value);
			if (sender == "") {
				alert			("Please enter a valid sender e-mail address");
				return false;
			} else
				document.Mailer.fromMail.value = sender;

			phase =				"body";
			if (document.Mailer.bodyText.value.search(/\[Link will be inserted here\]/) < 0) {
				alert			("Please do not modify the marker '[Link will be inserted here]'.");
				return false;
			}
			document.Mailer.bodyHTML.value =
								encode("<a href=\"" + decode(URL) + "\">" + decode(title) + "</a>");
				
			if (debug) {
				alert			(	"From:\t"+document.Mailer.fromMail.value+
									"\r\nTo:\t"+document.Mailer.toMail.value+
									"\r\nSb:\t"+document.Mailer.subjText.value+
									"\r\nTx:\t"+document.Mailer.bodyText.value+
									"\r\nBd:\t"+document.Mailer.bodyHTML.value);
				return			false;
			}
			return				true;
		} catch (exc) {
			alert				("Error checking the e-mail parameters while checking " + phase + "; message is '" + exc.description + "'");
			return false;
		}
	}
	
	function userInfo(email) {
		var expire =		new Date();
		expire.setYear(expire.getYear() + 2);
		document.cookie =	"Email=" + escape(email) + ";Expires=" + expire.toUTCString() + ";path=/";
		return true;
	}
	
	var eMailTemplate = "([\\w\\.-]+@[\\w\\.-]+)";

	function checkEmailList(text) {
		var mailFmt = new RegExp("^\\s*" + eMailTemplate + "(\\s*,\\s*" + eMailTemplate + "\\s*)*$");
		var recipient = "";
		if (text.length > 0) {
			var result = mailFmt.exec(text.replace(/;/g,","));
			if (result)
				recipient = text;
		}
		return recipient;
	}
	
	function checkEmail(text) {
		var mailFmt = new RegExp("^\\s*" + eMailTemplate + "\\s*$");
		var sender = "";
		if (text.length > 0) {
			var result = mailFmt.exec(text);
			if (result != null)
				sender = RegExp.$1;
			}
		return sender;
	}

//	Floating window

	var yLocation =					"Bottom";
	var offset =					5;
	var steps =						8;
	var speed =						10;

	function MakeFloater(objectName,location,objWidth,objHeight)
	{
		yLocation =					location;
		var ns =					navigator.appName.indexOf("Netscape") != -1;
		var fltObj =				document.getElementById ?	document.getElementById(objectName) :
																document.all ?	document.all[objectName]:
																				document.layers[objectName];
		if (document.layers)
			fltObj.style =			fltObj;
		fltObj.Track =				function(x,y) {
										this.style.left =		x;
										this.style.top =		y;
									};
		fltObj.x =					document.body.clientWidth - offset - (ns ? objWidth : fltObj.clientWidth);
		fltObj.y =					offset + (yLocation == "Top" ? ns ? 0 : fltObj.clientHeight : ns ? objHeight : fltObj.clientHeight);
		var running =				window.Tracker;
		window.Tracker =			function() {
										var startX =		document.body.clientWidth - offset - (ns ? objWidth : fltObj.clientWidth),
											startY =		offset + (yLocation == "Top" ? ns ? 0 : fltObj.clientHeight : ns ? objHeight : fltObj.clientHeight);
										if (yLocation == "Top") {
											var pX =		ns ?	pageXOffset :
																	document.body.scrollLeft;
											fltObj.x +=		(pX + startX - fltObj.x) / steps;
											var pY =		ns ?	pageYOffset :
																	document.body.scrollTop - fltObj.clientHeight;
											fltObj.y +=		(pY + startY - fltObj.y) / steps;
										} else {
											var pX =		ns ?	pageXOffset :
																	document.body.scrollLeft;
											fltObj.x +=		(pX + startX - fltObj.x) / steps;
											var pY =		ns ?	pageYOffset + innerHeight :
																	document.body.scrollTop + document.body.clientHeight;
											fltObj.y +=		(pY - startY - fltObj.y) / steps;
										}
										fltObj.Track		(fltObj.x, fltObj.y);
										setTimeout			("Tracker()", speed);
									}
		if (!running)
			Tracker();
	}