	// To inculde this script paste e.g.
	// <script src="includes/general.js" type="text/javascript" language="javascript"></script>
	// into the HEAD section of your HTML document. Relative paths (../etc) are OK.
	// MUST be placed after window.onload script - see ImageSwap.

	// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
	// ImageSwap - Simple image rollovers (and pre-load).
	// Only requires a link to the two images - e.g. paste this code into the BODY section of your HTML document
	// <img src="st_next.gif" oversrc="st_next_over.gif">
	// IMPORTANT: window.onload (which is used here) and BODY onload="..." are equivalent. In most browsers
	// window.onload will win and BODY onload="..." will be ignored. Therefore if you include this script
	// you should ONLY use window.onload and NOT use BODY onload="...". This script will take care of running
	// your window.onload function as well the one used here.
	// NB: Quote from web forum - When you call a function with window.onload, you don't use the parentheses, 
	//		 so that the script runs the function, instead of assigining it.
	// e.g.
	// <script>window.onload = function() { myFunction('myParam'); myOtherFunction(); };</script>
	//   or
	// <script>
	//	window.onload = myFunction; // Note: no () therefore no params.
	//  // Note: myFunction MUST be in the same <script> block.
	//	function myFunction() {
  //		alert("doing myFunction");
	//	}
	// </script>
	//   or
	// <script>
	//	window.onload = new Function("myFunction('x', 'y', 'z');");
	//  // Note: myFunction does NOT have to be in the same <script> block.
	//	function myFunction(a, b, c) {
  //		alert(a + b + c);
	//	}
	// </script>

	// This will ensure that any existing window.onload function in the page will still be executed
	// PROVIDED that the include for this file is placed AFTER the window.onload script in the page
	// AND that the rules for defining window.onload - outlined above - are observed.
	var PreImageSwapOnload = (window.onload)? window.onload : function(){};
	window.onload = function(){PreImageSwapOnload(); ImageSwapSetup();}

	function ImageSwapSetup() {
	  var x = document.getElementsByTagName("img");
	  for (var i = 0; i < x.length; i++){
	    var oversrc = x[i].getAttribute("oversrc");
	    if (!oversrc) continue;
		      
	    // Preload image - comment the next two lines to disable image pre-loading
	    x[i].oversrc_img = new Image();
	    x[i].oversrc_img.src = oversrc;

	    // set event handlers
	    x[i].onmouseover = new Function("ImageSwap(this, 'oversrc');");
	    x[i].onmouseout = new Function("ImageSwap(this);");

	    // save original src
	    x[i].setAttribute("origsrc", x[i].src);
	  }
	}

	function ImageSwap(elem, which) {
	  elem.src = elem.getAttribute(which || "origsrc");
	}
	// ImageSwap -End
	// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /

	// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
	// Email Address Obfuscation

	function obscureAddress(sEmailName, sDomain, sSubject, sLinkText, sPopupText) {
		// Useage e.g. obscureAddress('enquiries', 'cbt-solutions.co.uk', 'Enquiry', 'click here', 'Email an enquiry');
		var first = '<';
		var second = 'a h';
		var third = 'ref';
		var forth = '=\"';
		var fifth = 'ma';
		var sixth = 'il';
		var seventh = 'to:';
	  var txt = first + second + third + forth + fifth + sixth + seventh;

	  txt += sEmailName;
	  txt += '@';
	  txt += sDomain;
		txt += '?subject=' + sSubject + '\"'
		txt += 'title=\"' + sPopupText + '\"'
		txt += '>' + sLinkText + '<' + '\/a' + '>'

		return txt;
	}

	function mangle_email(user, domain, subject, prompt) {
		// Deprecated - use obscureAddress instead
		// e.g. "Sales", "cbt-solutions.co.uk", "Sales Enquiry", "email me"
		//	 or "Sales", "cbt-solutions.co.uk", "", "email me"
	  txt =   ''
	  address = user + "@" + domain
	  for (j=0; j<address.length; j++) {
			txt += '%' + Dec2Hex(address.charCodeAt(j))
		}
	  txt = '<a href = \"mailto:' + txt
	  if (subject.length)
			txt += '?subject=' + subject
		txt += '\">' + prompt + '<' + '/a>'
	  return txt
	}
	// End of Email Address Obfuscation
	// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /

	// / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
	// General Functions
		
	function Dec2Hex(Decimal) {
		var hexChars = "0123456789ABCDEF";
		var a = Decimal % 16;
		var b = (Decimal - a)/16;
		hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
		return hex;
	}

	function defeatSubmitOnEnterKey(e, oEl) {
		// Stop the data being submitted if the Enter key is pressed in an Input field
		// E.g. <input... onkeypress="return defeatSubmitOnEnterKey(arguments[0], this)">
		if (!e) e = window.event;
		return (!e || !( e.keyCode == 13 || e.which == 13 || e.charCode == 13));
	}

	function GetElapsedYearsStr(intStartYear) {
		// Returns the difference between intStartYear and the current year
		//	e.g. if the current year is 2008 and intStartYear is 1991, the returned value will be 17
		// Inputs: intStartYear - start year e.g. 1991
		var dt = new Date();
		var curYear = dt.getFullYear();
		return (curYear - intStartYear)
	}

	function GetCopyrightYearStr(intStartYear) {
		// Returns a string:
		//		intStartYear-thisyear - if intStartYear <> current year (e.g. 2006-2008)
		//			or
		//		year - if intStartYear = current year (e.g. 2008)
		// Inputs: intStartYear - copyright start year e.g. 2006
		var dt = new Date();
		var curYear = dt.getFullYear();		
		if (curYear != intStartYear) curYear = intStartYear + "-" + curYear
		return curYear;
	}

	function isNumeric(sText) {
		var ValidChars = "0123456789.";
		var IsNumber = true;
		var Char, i;

		for (i = 0; i < sText.length && IsNumber == true; i++) { 
			Char = sText.charAt(i); 
			if (ValidChars.indexOf(Char) == -1) IsNumber = false;
		}
		if (sText == ".") IsNumber = false;
		return IsNumber;
	}

	function openNewWindow(url, name, w, h, nav, loc, sts, menu, scroll, resize) {
		// Example: <a href="javascript:openNewWindow('message.asp', 'Message', 600, 600)">click here</a>
		//	You should always supply url, name, w and h
		//	If the other parameters aren't specified they will default to 'undefined' [e.g. if (sts == undefined) ...]
		//	and will set the corresponding property to 'yes'.
		var windowProperties = '';

		if (nav			== false)	windowProperties += 'toolbar=no,';		else windowProperties += 'toolbar=yes,';
		if (loc			== false)	windowProperties += 'location=no,';		else windowProperties += 'location=yes,';
		if (sts			== false)	windowProperties += 'status=no,';			else windowProperties += 'status=yes,';
		if (menu		== false)	windowProperties += 'menubar=no,';		else windowProperties += 'menubar=yes,';
		if (scroll	== false)	windowProperties += 'scrollbars=no,';	else windowProperties += 'scrollbars=yes,';
		if (resize	== false)	windowProperties += 'resizable=no,';	else windowProperties += 'resizable=yes,';
		if (w				!= "")		windowProperties += 'width='+w+',';
		if (h				!= "")		windowProperties += 'height='+h;
		if (windowProperties != "") { 
			if (windowProperties.charAt(windowProperties.length-1) == ',') 
				windowProperties = windowProperties.substring(0,windowProperties.length-1);
		} 
		window.open(url, name, windowProperties);
	}

	function embedVideo(sID, sURL, iWidth, iHeight, sAutoStart, suiMode) {
		// Custom settings. Also look for 'Check Me' for addtional player-sepcific settings (if required)
		// sID:					HTML Id or Name of the element e.g. "Video001".
		// sURL:				URL/Path to media e.g. "media/VHS Accident Cut.mpg".
		// iWidth:			number. NB: Min width appears to be 150 for mini and 200 for full.
		// iHeight:			number. NB: If you want the user to see a control panel (uiMode = "mini" or "full") you should add 64 
		//													to your required video height. Add only 40 if you don't want them to see the progress bar. 
		// sAutoStart:	"true" or "false";
		// suiMode:			"none", "invisible", "full" or "mini". "invisible" reserves the screen space so still needs a width 
		//													and height. NB: Also dictates sShowControls value for older versions.

		sShowControls = "true";
		if (suiMode.toLowerCase == "none" || suiMode.toLowerCase == "invisible") sShowControls = "false";

		// Check the Media Player Version
		var WMP7to10;
		try { 
			if(window.ActiveXObject) {
				WMP7to10 = new ActiveXObject("WMPlayer.OCX.7");
			}	else if (window.GeckoActiveXObject)	{
				WMP7to10 = new GeckoActiveXObject("WMPlayer.OCX.7");
			}
		} catch(e) { 
			// Can't instantiate ActiveXObject or GeckoActiveXObject for WMP - fall through anyway to use default code (esp. required for Firefox) 
		  //// Handle error -- no WMP control 
		  //// Download: http://www.microsoft.com/windows/windowsmedia/download/default.asp 
			//// alert("Problem: Window Media Player is not installed. You will not be able to play the media files on this page. you can download Window Media Player from here http://www.microsoft.com/windows/windowsmedia/download/default.asp"); 
		} 
		document.write ('<object');
		document.write (' id="' + sID + '"');
		document.write (' name="' + sID + '"');
		document.write (' width="' + iWidth + '" height="' + iHeight + '"');
		//document.write (' style="position: absolute; left: 103px; top: 50px; /*z-index: 0;*/"'); // Check Me.
		document.write (' standby="Loading Microsoft Windows Media Player components..."');
		document.write (' type="application/x-oleobject"');
		if (WMP7to10)	{
			// Windows Media Player 7 and Nescape Navigator 7.1 Code
			//	Can be as simple as this for an invisible sound control that does not autostart:
			//	<object id="MyID" height="0" width="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"></object>
			document.write (' classid=clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6>');
			document.write ('<param name="url" value="' + sURL + '" />'); // Do not call this method (change the URL) from event handler code - it may yield unexpected results.
			// uiMode : This property specifies the appearance of the embedded Windows Media Player. When uiMode is set 
			// to "none", "mini", or "full", a window is present for the display of video clips and audio visualizations.
			// This window can be hidden in mini or full mode by setting the height attribute of the OBJECT tag to 40,
			// which is measured from the bottom, and leaves the controls portion of the user interface visible.
			// If uiMode is set to "mini" or "full" add 64 to the video height to allow for the control panel.
			// If no embedded interface is desired, set both the width and height attributes to zero. 
			// If uiMode is set to "invisible", no user interface is displayed, but space is still reserved on the
			// page as specified by width and height. This is useful for retaining page layout when uiMode can change.
			// Additionally, the reserved space is transparent, so any elements layered behind the control will be visible.
			// If uiMode is set to "full" or "mini", Windows Media Player displays transport controls in full-screen mode.
			// If uiMode is set to "none", no controls are displayed in full-screen mode. 
			// If the window is visible and audio content is being played, the visualization displayed will be the one
			// most recently used in Windows Media Player.
			document.write ('<param name="uiMode" value="' + suiMode + '" />'); // Options: none, invisible, full, mini
		}	else {
			document.write (' codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715');
			document.write (' classid=clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95>');
			document.write ('<param name="ShowControls" value="' + sShowControls + '" />');
			document.write ('<param name="FileName" value="' + sURL + '" />');
		}
		document.write ('<param name="AutoStart" value="' + sAutoStart + '" />'); // Default=false
		if (WMP7to10)	{
			// WMP 7 to 10 PARAM tags (full list) = autoStart, balance, baseURL, captioningID, currentPosition, currentMarker,
			//	defaultFrame, enableContextMenu, enabled, fullScreen, invokeURLs, mute, playCount, rate, SAMIFileName,
			//	SAMILang, SAMIStyle, stretchToFit, uiMode, URL, volume, windowlessVideo
			// See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/paramtags.asp for documentation
			document.write ('<param name="enableContextMenu"  value="false" />'); // Check Me. Default=true
			//document.write ('<param name="Mute"							value="false" />'); // Check Me. Default=false
			//document.write ('<param name="stretchToFit"			value="false" />'); // Check Me. Default=false
			//document.write ('<param name="volume"						value="50" />');		// Check Me. Value 0 to 100
			//document.write ('<param name="enabled"					value="true" />');	// Check Me. Are player and its controls enabled? Default=true
			//document.write ('<param name="PlayCount"				value="1" />');			// Check Me. Number of repeats. Default=1 
			//document.write ('<param name="balance"					value="0" />');			// Check Me. Value -100 (left) to 0 to 100 (righT)
			//document.write ('<param name="rate"							value="1.0" />');		// Check Me. Playback rate; 1.0 is normal speed, 0.5 is half and 3 is three times normal.
			//document.write ('<param name="fullScreen"				value="false" />');	// Check Me. Default=false
		}	else {
			// Windows Media Player 6.4 and Nescape Navigator pre-7.1 Code
			// IE Code
			document.write ('<param name="animationatStart"    value="false" />'); // Check Me.
			document.write ('<param name="transparentatStart"  value="false" />'); // Check Me. Equiv for WMP7 = use script to specify the height and width values to make the player visible or invisible.
			document.write ('<param name="loop"                value="false" />'); // Check Me.
			//document.write ('<param name="volume"		         value="300" />');		// Check Me. Value range unknown
			// Netscape code
			document.write ('<embed type="application/x-mplayer2"');
			document.write (' pluginspage="http://www.microsoft.com/windows/windowsmedia/"'); // The browser will check if you have the proper Plugin, and, if you don't, will change its location to the given URL for downloading it.
			document.write (' id="' + sID + '"');			// Object ID - Used by Internet Explorer for object referencing.
			document.write (' name="' + sID + '"');		// Object Name - Used by Netscape Navigator for object referencing
			document.write (' src="' + sURL + '"');		// Specifies streaming media file. Can be either ASX, ASF, or any other media format.
			document.write (' width=' + iWidth);
			document.write (' height=' + iHeight);
			document.write (' autostart      = "' + sAutoStart + '"');			// Start the media automatically upon loading. 0 is false, non-zero is true.
			document.write (' ShowControls   = "' + sShowControls + '"');	// Display the streaming media controls below the media window. 0 is false, non-zero is true.
			document.write (' ShowDisplay    = "' + sShowControls + '"');	// Display the show information portion, including the author name, the clip name, and the copyright information. 0 is false, non-zero is true.
			document.write (' showTracker    = "' + sShowControls + '"');	// Display the tracking marker that shows the current status of the player: opening, buffering, displaying, etc.
			document.write (' ShowStatusBar  = "' + sShowControls + '"');	// Display the bar showing the pointer along the stream where the player is currently at. 0 is false, non-zero is true.
			//document.write (' volume				= 300');
			//document.write (' displaysize		= 0');							// Relative size of the Plugin on the page. 0 is normal size, 1 is smaller than normal, 2 is larger than normal, 3 is even larger, and so on.
			//document.write (' autosize			= -1');							// Automatically size the Plugin window according to the streaming media display size. 0 is false, non-zero is true.
			//document.write (' videoborder3d	= -1');							// Display a 3-D border around the player. 0 is false, non-zero is true.
			//document.write (' bgcolor				= darkblue');				// Background color of the streaming media window
			//document.write (' designtimesp	= 5311');						// A specical ID number. Can be ignored.
			//document.write (' filename			= "' + sURL + '"');	// Unknown function
			//document.write (' loop					= false');					// Repeat true/false - may not work in Firefox
			//document.write (' PlayCount			= 999');						// Repeat count - try if 'loop' doesn't work
			document.write ('></embed>');
			//document.write ('Your browser does not support the ActiveX Windows Media Player');
			// End of Netscape code
		}
		//document.write ('Your browser does not support the ActiveX Windows Media Player');
		document.write ('</object>');
	}

	function fnReveal(sElementId, bReveal) {
		if (bReveal) {
			document.getElementById(sElementId).style.visibility="visible"
		} else {
			document.getElementById(sElementId).style.visibility="hidden"
		}
	}

	function fnRevealHideById(sRevealId, sHideId)	{
		var iCnt, oElements;

		if (sRevealId.length || sHideId.length) {
			oElements = document.getElementsByTagName("DIV");
			for (iCnt = 0; iCnt < oElements.length; iCnt++) {
				if (sRevealId.length && oElements[iCnt].id.toLowerCase() == sRevealId.toLowerCase())
					oElements[iCnt].style.display = "";
				else if (sHideId.length && oElements[iCnt].id.toLowerCase() == sHideId.toLowerCase())
					oElements[iCnt].style.display = "none";
			}
		}
	}

	function fnFlashElement(sElementId, iInterval, iRepeats, bVisibleAtEnd) {
		// Toggle visible/hidden style for element sElementId
		// iInterval = milliseconds. iRepeats are for each on OR off operation
		var obj = document.getElementById(sElementId);
		if (obj.style.visibility == 'hidden') {
			// Not visible - make it visible
			obj.style.visibility = "visible";
		} else {
			obj.style.visibility ="hidden";
		}
		if (iRepeats-- > 0) {
			setTimeout("fnFlashElement('" + sElementId + "', " + iInterval + ", " + iRepeats + ", '" + bVisibleAtEnd + "')", iInterval);
		} else {
			if (bVisibleAtEnd)
				obj.style.visibility = "visible";
			else
				obj.style.visibility = "hidden";
		}
	}
