/*	

	Copyright 2002 [c] Artlogic Media Limited and its licensors.
	All rights reserved. (http://www.artlogic.net/)
	
	Some portions ('MM SCRIPTS') [c] Macromedia Inc.

*/

// INIT VARS

	var pathToImages='/images/';

// BROWSER AND PLATFORM 020130

	var bName = navigator.appName;
	var bVer = parseInt(navigator.appVersion);
	var agt=navigator.userAgent.toLowerCase();  

	var OPERA = (agt.indexOf("opera")!=-1); // must be above IE4 as Opera users can set Opera to 'identify' as IE in preferences
	var NS4 = (bName=="Netscape"&&bVer>=4&&bVer<5);
	var NS6 = (bName=="Netscape"&&bVer>=5);
	var IE4 = (bName=="Microsoft Internet Explorer"&&bVer>=4&&!OPERA);
	var NS3 = (bName=="Netscape" && bVer < 4);
	var IE3 = (bName=="Microsoft Internet Explorer"&&bVer<4&&!OPERA);

	var menuActive = 0
	var menuOn = 0
	var onLayer
	var timeOn = null
	
	var thePlatform;
	var MAC = (agt.indexOf("mac") != -1);
	var WIN = (agt.indexOf("win") != -1);
	var X11 = (agt.indexOf("x11") != -1);
	var IE4WIN=(IE4&&WIN);
	var IEWIN = (IE4&&WIN);
	var IE4MAC=(IE4&&MAC);
	var NS4MAC=(NS4&&MAC);
	var OPERAWIN=(OPERA&&WIN);
	var OPERAMAC=(OPERA&&MAC);
	
	var browserOK=(NS4||NS6||IE4||OPERAWIN) // supported browser for some functions
	var dropMenuOK=(NS4||NS6||IE4) // supported browsers for drop down menu function
	
	if (browserOK) { // support for layer style objects is different in IE and NS
		if (navigator.appName == "Netscape") {
			layerStyleRef="layer.";
			layerRef="document.layers";
			styleSwitch="";
		}else{
			layerStyleRef="layer.style.";
			layerRef="document.all";
			styleSwitch=".style";
		}
	}

// BROWSER & PLATFORM SPECIFIC CSS

	if(1==2) { // D I S A B L E D !
		if (IE4MAC) {
			document.write("\<link rel=\"stylesheet\" href=\"/styles/ie4_mac.css\">");
		} else if (NS4MAC) {
			document.write("\<link rel=\"stylesheet\" href=\"/styles/ns4_mac.css\">");
		} else if (IE4WIN) {
			document.write("\<link rel=\"stylesheet\" href=\"/styles/ie4_win.css\">");
		} else if (OPERAMAC) {
			document.write("\<link rel=\"stylesheet\" href=\"/styles/opera_mac.css\">");
		}
	}

// FLASH DETECT 020130
	
	// settable vars
	var flashVersionRequired = 4;

	// init vars
	var hasFlash=false;
	var flashVersion=0;	

	// flashDetected flags - must be declared globally as they are used by the 'document' object in the IE VBScript
	var flash2Detected=false;
	var flash3Detected=false;
	var flash4Detected=false;
	var flash5Detected=false;
	var flash6Detected=false;
	var flashDetectProcessed=false;

	function flashDetect() {

		var maxpluginsFlashVersion = 6; //	settable - the maximum version of Flash - set one version ahead. 
		
		flashDetectProcessed=true;
		
		// get detected version on IE4 win which requires a VBScript to detect Flash plugin (requires var IE4WIN, set in BROWSER AND PLATFORM section, above)
		if(IE4WIN){
			document.write("<scr"+"ipt language=\"VBScript\"\>\n");
			document.write("on error resume next\n");
			document.write("flash2Detected=(IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.2\")))\n");
			document.write("flash3Detected=(IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.3\")))\n");
			document.write("flash4Detected=(IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.4\")))\n");
			document.write("flash5Detected=(IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.5\")))\n");  
			document.write("flash6Detected=(IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.6\")))\n");  
			document.write("\</scr"+"ipt\>\n"); // break up end tag so it doesn't terminate the script
		}	

		// get detected version on browsers which have the navigator.plugins array object
		if (navigator.plugins) { 
			if (navigator.plugins["Shockwave Flash 2.0"]|| navigator.plugins["Shockwave Flash"]) {
				var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
				var pluginsFlashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
				// the following two lines rewritten 081204 as the previous version broke at version 10
				var pluginsFlashVersionSplit = pluginsFlashDescription.split(".")[0].split(" ");
				var pluginsFlashVersion = parseInt(pluginsFlashVersionSplit[pluginsFlashVersionSplit.length - 1]);
				flash2Detected=(pluginsFlashVersion==2);    
				flash3Detected=(pluginsFlashVersion==3);
				flash4Detected=(pluginsFlashVersion==4);
				flash5Detected=(pluginsFlashVersion==5);
				flash6Detected=(pluginsFlashVersion==6);
				flash7Detected=(pluginsFlashVersion>=7); // use >= on highest version so it will detect future versions
			}
		}
		for (i=2;i<=maxpluginsFlashVersion;i++) {  
			if (eval("flash" + i + "Detected") == true) flashVersion = i;
		}
		if(navigator.userAgent.indexOf("WebTV") != -1) flashVersion = 3; // webtv support (version 3)
		if (flashVersion >= flashVersionRequired)  hasFlash = true;                
	}
		
	flashDetect();  // call flashDetect function to set vars 'hasFlash' (true,false) and flashVersion (num)

	function placeFlash(flashMovieURL,fVersion,flashBackgroundColor,flashMovieWidth,flashMovieHeight,altImageURL,altImageAltText,altImageLink,altImageName,altCode) { 
		
		// 	Copyright 2002-2003 [c] Arlogic Media Limited - Version 2.1 January 28, 2003
		
		//	SYNTAX: placeFlash("flashMovieName",flashVersion,"backgroundColor",width,height,"altImageURL","altImageAltText","altImageLink","altImageName","altCode")
		//	EXAMPLE: placeFlash("/images/fcident.swf",6,"#000000",200,77,"/images/333399.gif","Alternative text","pluginspage","imgName","Alternative code")
		//	set the param - 'altImageLink' - to "pluginspage" to make the image click to the Flash downloads page)
		//	give the image a name using 'altImageName' so you can use an image map for the alternative image
		
		//	Jan 28, 2003 - added 'altCode' (non-flash html code; if present, supercedes altImage)
		
		if (!flashDetectProcessed) flashDetect(); // requires the function flashDetect(), above, to have been run - if it hasn't it is called here
		
		if (flashVersion>=fVersion) {
			var t="";
			t+="\<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\""+flashMovieWidth+"\" height=\""+flashMovieHeight+"\">";
			t+="\<param name=\"movie\" value=\""+flashMovieURL+"\">\<param name=\"quality\" value=best>\<param name=\"bgcolor\" value=\""+flashBackgroundColor+"\">";
			t+="\<embed src=\""+flashMovieURL+"\" quality=best bgcolor=\""+flashBackgroundColor+"\" width=\""+flashMovieWidth+"\" height=\""+flashMovieHeight+"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\">\</embed>";
			t+="\</object>";
			document.write(t);
		} else {
			if (altCode != '') {
				document.write(altCode);
			} else {
				if (altImageLink=="pluginspage") altImageLink="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";
				if (altImageLink!="") {
					var faOn="\<a href=\""+altImageLink+"\">";
					var faOff="\</a>";
				}
				document.write(faOn+"\<img src=\""+altImageURL+"\" width=\""+flashMovieWidth+"\" height=\""+flashMovieHeight+"\" alt=\""+altImageAltText+"\" border=\"0\" />"+faOff);
			}
		}
	}

	function getFlash(fVers,fMsg) { 
	
		// display 'Get Flash Player' image - params: flashVersion, message
		// define a css style '.getFlashBox' to style the surrounding box
		
		if(flashVersion<fVers) {
			var t="";
			t+="\<br>\<br>\<img src=\""+pathToImages+"333399.gif\" width=\"170\" height=\"1\">\<br>\<br>";
			t+="\<div class=\"getFlashBox\">";
			t+="\<a href=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" target=\"_blank\">";
			t+="\<img src=\""+pathToImages+"get_flashplayer.gif\" border=\"0\">\<br>\<br>";
			t+="\</a>";
			t+=fMsg;
			t+="\</div>";
			document.write(t)
		}
	}


// MISC

	function setStatus(theMsg) {
		window.status=theMsg;
		return true;
	}
	
	function returnClientDateLong() {
		// this function returns the date on the client's computer in the form 'Friday October 12, 2001'
		var t="";
		var today=new Date();
		var cdlMonthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
		var cdlDayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; 
		cdl=cdlDayNames[(today.getDay())]+" "+cdlMonthNames[(today.getMonth())]+" "+today.getDate()+", "+today.getYear();
		return(cdl);
	}
	
	function clientDateLong() {
		// this function uses the function 'returnClientDateLong()' to return 
		// the date on the client's computer in the form 'Friday October 12, 2001'
		// to call this function, place the following code on your page: 
		// <script>clientDateLong()<script>
		document.write(returnClientDateLong());
	}
	
	function shim(w,h) {
		document.write("<img src=\""+pathToImages+"shim.gif\" width=\""+w+"\" height=\""+h+"\" border=\"0\">");
	}

	function img(n,a,w,h) { // images must be in the /usr/images/ directory (on the main server, not the image server)
		var pathToFile="/usr/images/", sString="";
		if (typeof a=="undefined"||aString=="") {var a=""} else {var aString=" align=\""+a+"\""};
		if (typeof w=="undefined"||wString=="") {var w=""} else {var wString=" width=\""+w+"\""};
		if (typeof h=="undefined"||hString=="") {var h=""} else {var hString=" height=\""+h+"\""};
		if (a=='left') {sString=" style=\"margin-right:15px;margin-bottom:10px;\""};
		if (a=='right') {sString=" style=\"margin-left:15px;margin-bottom:10px;\""};
		var t="\<img src=\""+pathToFile+n+"\""+wString+hString+aString+sString+">";
		document.write(t);
	}
	
	function download(t,l) {
		// SYNTAX: <script>download("text","filename")</script>
		document.write("\<a href=\""+pathToDownloads+t+"\" target=\"_blank\">"+l+"\</a>");
	}

// MM SCRIPTS

	function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}
	MM_reloadPage(true);
	
	function MM_setTextOfLayer(objName,x,newText) { //v4.01
	  if ((obj=MM_findObj(objName))!=null) with (obj)
		if (document.layers) {document.write(unescape(newText)); document.close();}
		else innerHTML = unescape(newText);
	}
	
	function MM_showHideLayers() { //v3.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
		obj.visibility=v; }
	}

	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	/* Functions that swaps images. */
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	/* Functions that handle preload. */
	function MM_preloadImages() { //v3.0
	 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}


//	SCRIPTS TO RETAIN SCROLL POSITIONS OF DIVS AND STORE COOKIES (050819)

		
	var scrollObjectsExist=true; // so we can test for these scripts before using them
	var scrollObjects=new Array();
	
	function setScroll(objName,cookieName) {
		var scrollObjectsInd=scrollObjects.length;
		var scrollSettings=readCookie(cookieName);
		if (scrollSettings.indexOf(",") != -1) {
			var obj=document.getElementById(objName)
			var s=scrollSettings.split(",");
			scrollObjects[scrollObjectsInd]=[objName,s[0],s[1]];
			obj.scrollTop=s[0];
			obj.scrollLeft=s[1];
			window.setTimeout("setScrolls()", (WIN) ? 100 : 10);
		}		
	}
	
	function setScrolls(n) {
		for (var i in scrollObjects) {
			var obj=document.getElementById(scrollObjects[i][0]);
			if (obj) {
				obj.scrollTop=scrollObjects[i][1];
				obj.scrollLeft=scrollObjects[i][2];
			}
		}
	}
	
	function saveScroll(obj,cookieName) {
		setCookie(cookieName,obj.scrollTop+","+obj.scrollLeft,1);
	}

	function setCookie(cookieName,cookieValue,nDays,path) {
		var today = new Date();
		var expire = new Date();
		if (nDays==null || nDays==0) {
			nDays=1;
		}
		expire.setTime(today.getTime() + 3600000*24*nDays);
		if (typeof path=="undefined") {
			document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();
		} else {
			document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString()+";path="+escape(path);
		}
	}

	function readCookie(cookieName) {
		var theCookie=""+document.cookie;
		var ind=theCookie.indexOf(cookieName);
		if (ind==-1 || cookieName=="") {
			return ""; 
		}
		var ind1=theCookie.indexOf(';',ind);
		if (ind1==-1) {
			ind1=theCookie.length;
		}
		return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
	}

	function listProperties(obj) {
		var t="";
		for (var item in obj) {
			t += "\<tr>\<td bgcolor=\"#FFFFFF\">"+item+"\</td>\<td bgcolor=\"#FFFFFF\">"+obj[item]+"&nbsp;\</td>\</tr>";
		}
		var win=window.open("about:blank");
		win.document.write("\<html>\<head>\<title>Object Properties\</title>\<style type=\"text/css\">body,td {font-family:verdana;font-size:11px;}\rbody {margin:20px;}\</style>\</head>\<body>\<b>Object properties ("+obj["id"]+"):\</b>\<br>\<br>\<table cellspacing=\"1\" border=\"0\" bgcolor=\"#CCCCCC\">"+t+"\</table>\</body>\</html>")
	}



//	MISC FL


	function fl_displayDate(inputDate,shortMonthNames) { 
		
		if (inputDate == "" || parseInt(inputDate) == 0) { 
			
			return "";
		
		} else {
			
			var t="";
			
			var dt = "";
			var tm = "";
			
			if (shortMonthNames) {
				var monthNames=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
			} else {
				var monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
			}
			
			var inputArray = inputDate.split(" ")[0].split("-");
			
			var y = parseInt(inputArray[0], 10);	//	JAVASCRIPT BUG: 
													//	parseInt("09") returns 0 not 9, and parseInt("08") returns 0
													//	not 8, whereas all other numbers are returned correctly. This 
													//	is because parseInt incorrectly thinks they are invalid octal 
													//	numbers. The workaround is to force parseInt to base 10, eg. 
													//	parseInt("09", 10) returns 9. See article at 
													//	http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256C85006A6604
			var m = (parseInt(inputArray[1], 10)>0) ? monthNames[inputArray[1]-1] : "";
			var d = parseInt(inputArray[2], 10);
			
			t += (m != "") ? m+" " : "";
			t += (d>0) ? d+", " : "";
			t += y;
			
			return t;
		
		}
	}
	
	function fl_concatWS() {
		if (arguments.length>1) {
			var a=arguments;
			var t="";
			var x=a[0]; // the separator character
			for (var i=1;i<a.length;i++) {
				if (a[i]+"" != "") {
					if (t != "") {
						t += x;
					}
					t += a[i]+"";
				}
			}
			return t;
		}
	}


	function fl_formatDecimal(v,bool) {
		if (v == undefined) {
			return "";
		} else {
			var inputArray=((Math.round(v*100)/100)+"").split(".");
			var input=parseInt(inputArray[0]);
			if (inputArray.length>1) {
				var remainder=("."+inputArray[1]+"00").substring(0,3);
			} else {
				var remainder=".00";
			}
			var output="";
			var chars=inputArray[0].split("").reverse();
			var repetition=1;
			for (var i=0;i<chars.length;i++) {
				output=chars[i]+output;
				if (repetition==3 && i<(chars.length-1)) {
					output=","+output;
					repetition=0;
				}
				repetition++;
			}
			if (bool) { // integer
				return output;
			} else {
				return output+remainder;
			}
		}
	}

	function fl_formatInteger(v) {
		if (v == undefined) {
			return "";
		} else {
			return fl_formatDecimal(Math.round(v),true);
		}
	}

	var fl_formatCurrency = function(currID, num, args) {
		/*
			Returns a number as a formatted decimal, with a currency, eg. $ 10,500
			
			AUTHOR: Peter Chater, Artlogic Media Limited - http://www.artlogic.net/
			
			CREATED: 070614
			
			LAST REVISION: 070614
			
			EXAMPLE:
			
				var currencies = {"1": "£", "2": "$", "3": "Û"};
				fl_formatCurrency(2, 30500));
				// returns => $ 30,500

			
			OPTIONAL PARAMS EXAMPLE:
			
				fl_formatCurrency(2, 30500, {trim: false});
				// returns => $ 30,500.00
			
			
			OPTIONAL PARAMS:
			
				trim				-	(true/false)	trims trailing zeros from the result (default is true)
				ignoreZero			-	(true/false)	if the number is zero, an empty string is returned (eg. "" rather than "$ 0.00") (default is true)
				plusRed				-	(true/false)	if the result is positive, the result is returned with an html span surrounding it which turns the text red (default is false)
				minusRed			-	(true/false)	if the result is negative, the result is returned with an html span surrounding it which turns the text red (default is false)
				alignRight			-	(true/false)	if true, the result is returned in an html '<div>' element which aligns the text right (for table cells, etc.) (default is false)
				currencyLeading		-	(true/false)	if false, the currency is placed AFTER the number (default is true)
				currencyMap			-	(var name)		This function assumes a variable called 'currencies' exists on the current page, 
														containing a 'map' of currency IDs to currency symbols, eg:
															var currencies = {"1": "£", "2": "$"}
														... however, you can override the variable name using the 'currencyMap' param.
			
		*/
		var settings = (args) ? args : {};
		leading = (settings.currencyLeading) ? settings.currencyLeading : true;
		trim = (settings.trim) ? settings.trim : true;
		ignoreZero = (settings.ignoreZero) ? settings.ignoreZero : true;
		plusRed = (settings.plusRed) ? settings.plusRed : false;
		minusRed = (settings.minusRed) ? settings.minusRed : false;
		alignRight = (settings.alignRight) ? settings.alignRight : false;
		currencyMap = (settings.currencyMap) ? settings.currencyMap : currencies; // an object containing the currencies, eg. {"1": "£", etc.}
		if (plusRed) minusRed = false;
		var currency = currencyMap[currID + ""];
		var t = "";
		if (ignoreZero && (parseFloat(num) == parseFloat("0"))) {
			return ""
		}
		var n = fl_formatDecimal(num);
		if (trim) {
			var tmp = n.split(".")
			if (tmp[1] == "00") {
				n = tmp[0];
			}
		}
		if (leading) {
			t += currency + " " + n;
		} else {
			t += n + " " + currency;
		}
		if ((plusRed && parseFloat(num) > 0) || (minusRed && parseFloat(num) < 0)) {
			t = '<span style="color: red;">' + t + '<\/span>';
		}
		return t;
	}







//	STRIP ILLEGAL CHARACTERS FROM NUMBER FIELDS


	function setNumeric(obj) {
		// <input ... onchange="setNumeric(this)" ...>
		var a=obj.value.toString().split(''),t="",v="";
		for (var i=0;i<a.length;i++) {
			v=a[i];
			if (v=='0'||v=='1'||v=='2'||v=='3'||v=='4'||v=='5'||v=='6'||v=='7'||v=='8'||v=='9'||v=='.') t+=v;
		}
		obj.value=t;
	}
	


//	WINDOW SIZE 060618

	var winW,winH;
	function getWinSize() {
		winW=0,winH=0;
		if (typeof(window.innerWidth) == "number") { // Non-IE
			winW=window.innerWidth;
			winH=window.innerHeight;
		} else if (document.documentElement && (document.documentElement.clientWidth||document.documentElement.clientHeight)) { // IE 6+ in 'standards compliant mode'
			winW=document.documentElement.clientWidth;
			winH=document.documentElement.clientHeight;
		} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) { // IE 4 compatible
			winW=document.body.clientWidth;
			winH=document.body.clientHeight;
		}
	}
	getWinSize();


//	JAVASCRIPTS WHICH OPERATE WITH NEW WEB STANDARDS GUI METHODS

	function mtActivate(n,n0) {
		col = document.getElementsByTagName("div");
		mtCol = new Array();
		for ( var i=0; i<col.length; i++ ) {
			if ( col[i].id.indexOf("mtdiv_") == 0 ) {
				mtCol[mtCol.length] = col[i];
			}
		}
		for ( var i=0; i<mtCol.length; i++ ) {
			mtCol[i].className = "mtContentHidden"; // hide all
		}
		col = document.getElementsByTagName("li");
		mtCol = new Array();
		for ( var i=0; i<col.length; i++ ) {
			if ( col[i].id.indexOf("mtli_") == 0 ) {
				mtCol[mtCol.length] = col[i];
			}
		}
		for ( var i=0; i<mtCol.length; i++ ) {
			mtCol[i].className = ""; // hide all
		}
		document.getElementById("mtdiv_"+n+"_"+n0).className = "mtContent";
		document.getElementById("mtli_"+n+"_"+n0).className = "active";
	}	



//	SHOW, HIDE OR TOGGLE ELEMENTS ON THE PAGE 061028

	/*
		
		//	Removed 070605 - two new functions 'Class' and '$'
		//	have been added which provide minimal functionality
		//	as per the same functions in the 'prototype' library.
		
		//	You may override these with 'prototype' and 'scriptaculous'.
		
		//	Functions 'addClass' and 'removeClass' have been extended
		//	so that they accept both an element ID and the element
		//	itself as the first parameter.
	
		
		function addClass(id,className) {
			var el=document.getElementById(id);
			var classes=el.className.toString();
			var newClasses = (classes == "") ? className : classes + " " + className;
			el.className=newClasses;
		}
	
		function removeClass(id,className) {
			var el=document.getElementById(id);
			var classes=el.className.toString().split(" ");
			var newClasses = new Array();
			for (var i=0; i<classes.length; i++) {
				if (classes[i] != className) {
					newClasses[newClasses.length] = classes[i];
				}
			}
			el.className=newClasses.join(" ");
		}
	
	*/

	var Class = {
		create: function() {
			return function() {
				this.initialize.apply(this, arguments);
			}
		}
	}

	var $ = function(el) {
		if (typeof el == 'string') {
			return document.getElementById(el);
		} else {
			return el;
		}
	}

	var addClass = function(el, className) {
		var el=$(el);
		var classes=el.className.toString();
		var newClasses = (classes == "") ? className : classes + " " + className;
		el.className=newClasses;
	}

	var  removeClass = function(el, className) {
		var el=$(el);
		var classes=el.className.toString().split(" ");
		var newClasses = new Array();
		for (var i = 0; i < classes.length; i++) {
			if (classes[i] != className) {
				newClasses[newClasses.length] = classes[i];
			}
		}
		el.className = newClasses.join(" ");
	}

	function hideElement(el) {
		var el = $(el);
		addClass(el,"hidden")
	}

	function showElement(el) {
		var el = $(el);
		removeClass(el,"hidden")
	}
	
	function toggleElement(el) {
		var el = $(el);
		var classes=" "+el.className+" ";
		if (classes.indexOf("hidden") > -1) {
			showElement(el);
		} else {
			hideElement(el);
		}
	}




//	ACCESSIBILITY
//	To be used in conjunction with /flgui/styles/accessibility.css.
//	See /flgui/styles/examples/accessibility.html for an example.
	
	
	function accessibilityIncreaseFont() {
		var newSize = (parseFloat(document.body.style.fontSize) * 1.2) + "em";
		document.body.style.fontSize = newSize;
		setCookie("CurrentFontSize",newSize,365,"/");
	}

	function accessibilityResetFont() {
		var newSize = "1em";
		document.body.style.fontSize = newSize;
		setCookie("CurrentFontSize",newSize,-1,"/");
	}

	function accessibilityInit(v) {
		if ( readCookie("CurrentFontSize").indexOf( "em" ) > -1 && readCookie("CurrentFontSize").indexOf( "NaN" ) == -1 ) {
			document.body.style.fontSize = readCookie("CurrentFontSize");
		} else {
			initSize = "1em";
			document.body.style.fontSize = initSize;
		}
	}


//	FINE TUNE xhtml ADMIN ELEMENTS

	function fadeIn() {
					
		
		//	CENTER SQUARE BTNS ENCLOSED IN AN ELEMENT OF CLASS "centered"

			var b, p, nodes = document.getElementsByClassName("squarebtns");
			for (var i=0; i<nodes.length; i++) {
				p = nodes[i].parentNode
				if ((" "+p.className+" ").indexOf(" centered ") > -1) {
					p.style.width=nodes[i].offsetWidth+"px";
				}
			}
		
		
		//	CENTER HEADINGS OF CLASS "pen"
		
			var n, w, nodes = document.getElementsByClassName("pen");
			for (var i=0; i<nodes.length; i++) {
				n=nodes[i]
				n.style.display="inline";	// turn headings into an inline object
				w=n.offsetWidth;			// get width
				n.style.display="block";	// turn it back into a block object
				n.style.width=w+"px";		// set width
				n.style.left="0";			// set left
				n.style.margin="0 auto";	// center using margin
			}
			
			
		//	FADE IN BODY
		
			document.body.style.display = "none";
			document.body.style.visibility = "visible";
			new Effect.Appear('body');
		
		
	
	}
	

//	ONLOAD (depricated)

	function doOnLoad() {
	
		var b = document.getElementById("body");
		if ( (" "+b.className+" ").indexOf(" fadeIn ") > -1 ) {
			fadeIn();
		}
	
	}


//	ONLOAD FUNCTION FOR xhtml EDIT PAGES

	function fl_initEditPage() {
		fl_initHints();
	}

	function fl_initHints() {
		var els=document.getElementsByClassName('fhint');
		var html;
		for (var i=0; i<els.length; i++) {
			html=els[i].innerHTML;
			els[i].innerHTML='<a id="hint_'+i+'_link" href="JavaScript:hideAllElementsExcept(\'hintpanel\', \'hint_'+i+'\'); toggleElement(\'hint_'+i+'\'); document.getElementById(\'hint_'+i+'_link\').blur();" class="hint"><img src="/flgui/images/hint_icon.gif" width="13" height="13" border="0" alt=" Click here for help... " title="Click here for help...">\</a><div id="hint_'+i+'" class="hintpanel hidden" onmouseup="toggleElement(\'hint_'+i+'\')"><div>'+html+'\</div>\</div>';
		}
	}



//	POP-UP WINDOWS FOR GENERAL USE

	var fl_win = function(params) {
		return fl_popUpWin(params);
	}

	var fl_popUpWins = [];
	
	function fl_popUpWin(url, name, w, h, scrollbars, resizable, menubar, status) {
		if (typeof url == 'object') {
			/*
				As of Nov 2007, you may use the shorter alias to this function, 'fl_win',
				and may specify parameters as an object, using only the first argument, e.g.:
					
					fl_win({
						url: '/my_popup.html'
					});
					
					fl_win({
						url: '/my_popup.html',
						name: 'PopUp',
						width: 500,
						height: 400,
						scrollbars: true,
						resizable: true,
						menubar: true,
						status: true
					});
					
				No parameters are required, however 'url' is highly recommended!
				When using the 'params' method, 'fl_win' is an alias for 'fl_popUpWin', e.g.:
				fl_popUpWin({...params...}) will work in the same manner
			*/
			// set up defaults
			var params = url;
			var url = (params.url) ? params.url : "http://www.artlogic.net/flgui/images/shim.gif";
			var name = (params.name) ? params.name : "Window_" + fl_popUpWins.length;
			var w = (params.width) ? params.width : 550;
			var h = (params.height) ? params.height : 550;
			var scrollbars = (params.scrollbars) ? "yes" : "no"
			var resizable = (params.resizable) ? "yes" : "no"
			var resizable = (params.resizable) ? "yes" : "no"
			var menubar = (params.menubar) ? "yes" : "no"
			var status = (params.status) ? "yes" : "no"
		} else {
			var w = (w) ? w : 550;
			var h = (h) ? h : 550;
			var scrollbars = (scrollbars) ? "yes" : "no";
			var resizable = (resizable) ? "yes" : "no";
			var menubar = (menubar) ? "yes" : "no";
			var status = (status) ? "yes" : "no";
		}
		var l=(screen.availWidth-w)/2;
		var t=((screen.availHeight-h)/3)-40;
		if (!fl_popUpWins[name] || fl_popUpWins[name].closed) {
			fl_popUpWins[name] = window.open(url,name,'width=' + w + ',height=' + h + ',top=' + t + ',left=' + l + ',scrollbars=' + scrollbars + ',resizable=' + resizable + ',menubar=' + menubar + ',status=' + status);
			if (fl_popUpWins[name]) { // the window may have been blocked by a pop-up blocker
				fl_popUpWins[name].focus();
			} else {
				alert("Please ensure that you allow pop-up windows for this application as they may contain important messages or functionality. Please update your browser preferences and reload this page.");
			}
		} else if (fl_popUpWins[name]) { // the window may have been blocked by a pop-up blocker
			fl_popUpWins[name].focus();
		}
	}
	


//	SCRIPTS FOR FL_EditableImage AND FL_EditableObject...

	var fledit_popUpWin;
	function fledit_openPopUpWin(url,name,w,h) {
		var l=(screen.availWidth-w)/2;
		var t=((screen.availHeight-h)/3)-40;
		if (!fledit_popUpWin||fledit_popUpWin.closed) {
			fledit_popUpWin=window.open(url,name,'width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=no,resizable=no,menubar=no,status=no');
			fledit_popUpWin.focus();
		} else {
			fledit_popUpWin.focus();
		}
	}
	
	function fledit(type,objID,fieldID,pathToImages,w,h,allowMultiple,stylesheet,thumbWidths) {
		var t;
		if (fieldID!="") {
			if (type=="html") {
				fledit_openPopUpWin("/flgui/modules/FL_Editable/html/?objID="+objID+"&fieldID="+fieldID+"&stylesheet="+stylesheet,objID,650,400);
			} else if (type=="image") {
				var w=parseInt(w);
				var h=parseInt(0+h);
				var allowMultiple=parseInt(allowMultiple);
				var mult=(allowMultiple) ? 1 : 0;
				var allowW=330;
				var winW=((w+allowW)>768) ? 768 : w+allowW;
				var winH=520;
				var horiz=((w+allowW)>768) ? 1 : 0;
				fledit_openPopUpWin("/flgui/modules/FL_Editable/image/?objID="+objID+"&fieldID="+fieldID+"&path="+pathToImages+"&w="+w+"&h="+h+"&winW="+winW+"&winH="+winH+"&horiz="+horiz+"&mult="+mult+"&thumbWidths="+thumbWidths,objID,winW,winH);
			} else if (type=="image_bk") {
				t=(prompt("Enter the URL of the image file, eg. '/usr/images/.../myfile.jpg'",document.getElementById(fieldID).value));
				if (t!="" && t!=null) {
					document.getElementById(fieldID).value=t;
					document.getElementById(objID).src=t;
				}
			}
		} else {
			alert("Sorry, you cannot edit this element.");
		}
	}
	
	function fledit_getText(fieldID) {
		return unescape(document.getElementById(fieldID).value);
	}

	function fledit_setText(n,fn,t) {
		document.getElementById(n).innerHTML=unescape(t);
		document.getElementById(fn).value=unescape(t);
		fledit_dontForgetToSave();
	}
	
	function fledit_dontForgetToSave() {
		alert("Don't forget to save if you are happy with the result...");
	}






//	MISC


	function hideAllElementsExcept(classname, id) {
		// hides all elements of class 'classname', except the specified 'id'
		var els = document.getElementsByClassName(classname);
		for (i=0; i<els.length; i++) {
			if (els[i].id != id) {
				els[i].addClassName("hidden");
			}
		}
	}


	function newWin(url) { // equivalent to <a ... target="blank"> - simple method for opening a new window in Firefox 2+
		window.open(url,"_blank","location=yes,toolbar=yes,scrollbars=yes,menubar=yes,status=yes,resizable=yes,directories=yes,");
	}


	function blur_me() {
		// blurs the current object if focussed, without unfocussing the window
		if (!document.getElementById('fl_blurMe')) {
			var el = document.createElement('a');
			el.setAttribute('style', 'position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden;')
			document.body.appendChild(el);
		} else {
			el = document.getElementById('fl_blurMe');
		}
		el.style.display = "block";
		el.focus();
		el.style.display = "none";
	}



//	LOAD 'FL' JAVASCRIPT LIBRARY

	var FL_JSLib = {
	  Version: '1.0.1',
	  load: function() {
		document.write('<script type="text/javascript" src="/flgui/scripts/fl_lib.js"></script>');
	  }
	}
	
	FL_JSLib.load();



