//---------------- MISC

function global() {
	orollover();
	saved_comments(savedComments);
	if (is.get_ok) flyouts();
}

//---------------- //





//---------------- FORM VALIDATION
/*
[OVERVIEW]
Simple validation. After submitting, it alerts the user
with a list of missing elements, at the same time colours the
form fields needing attention.

[CALL]
This function takes two arguments. Firstly, the form object.
Secondly, an array of information needing validating. The format
for the array is simple.

var myArray = new Array ("myEmail,eml,Please enter your email address")
if (myvalidate(objForm,myArray)) objForm.submit();

1. Field Name
2. Validation Type*
3. Alert Message

*The validation type has a few pre set types to make life easy.

1. Required:	req		(Forces something to be entered)
2. Email:		eml		(Forces the '@' and '.' characters)
3. Number:		num		(Forces an integar type)

If some more custom needs validating, you can put that code in instead.
Example: "myPostcode,f.myPostcode.length!=4,You must have a 4 digit password"

[WRITTEN]
David Tsuji
*/
function myvalidate(f,vAr) {
	var errorColor = "#FF9900";
	var error='';
	for (i=0;(obj=vAr[i]);i++) {
		con='';arg='';objAr='';objAr=obj.split(",");
		if(objAr[0])obj=eval('document.'+f.name+'.'+objAr[0]);
		arg=objAr[1];alt=objAr[2];
		if(obj.style&&!obj.n) {
			objbc = obj.style.backgroundColor;
			if (objbc) obj.n=objbc;
			else obj.n="#FFFFFF";
			obj.e=errorColor; }else if(obj.style&&obj.n) obj.style.backgroundColor=obj.n;
		myerror=function(){error+='- '+alt+'\n';if(obj.style)obj.style.backgroundColor=obj.e;}
		if(arg.length>3) con=eval(objAr[1]);
		if(con) myerror();
		if(arg=='req') if(!obj.value) myerror();
		if(arg=='eml') if(!isMyEmail(obj.value)) myerror();
		if(arg=='num') if(isNaN(obj.value)||!obj.value) myerror();
	}if(error) {alert('Please correct the following fields:\n\n'+error);return false}
	else return true;
}

/*
[WRITTEN]
David Peterson
*/
function isMyEmail(eml) {
	var emailPat = /^(\".*\"|[A-Za-z0-9\_][A-Za-z0-9\.\-\_]*)@(\[\d{1,3}(\.\d{1,3}){3}]|([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,4})$/;
	var matchArray = eml.match(emailPat);
	if (matchArray == null) return false;
	var IPArray = matchArray[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/);
	if (IPArray != null) for(i=1;i<=4;i++) if (IPArray[i]>255) return false;
	return true;
}
//---------------- //





//---------------- OTHER ROLLOVERS
function orollover() {
	if (getPlatform!="PC"||getBrowser!="IE") {
		for (i=0;(img=document.images[i]);i++) {
		if(img.getAttribute){
		if(img.stickonurl) if (location.href.match(img.stickonurl)) img.src=img.rollover;
		if(img.getAttribute("rollover")) {
		img.o=new Image();img.n=new Image();
		img.o.src=img.getAttribute("rollover");img.n.src=img.src;
		img.onmouseover=function(){this.src=this.o.src;}
		img.onmouseout=function(){this.src=this.n.src;}} }	}
	}
}
//---------------- //





//---------------- DETECTION

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up  = (is_ie && (is_major >= 4));
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6    = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up  = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

var getBrowser = null;
if (is_ie) getBrowser = "IE";
else getBrowser = "NN";
var getPlatform = null;
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);
if (is_win) getPlatform = "PC";
else getPlatform = "MAC";

//---------------- //





//---------------- SAVED COMMENTS
function saved_comments(sc) {
	if (sc) {
		if (is_ie5_5up) {
			document.body.insertAdjacentHTML("beforeEnd", "<span id=my_sc style=\"display:none\">"+sc+"</span>");
		}else alert(sc);
	}
}
//---------------- //





//---------------- FLYOUTS
var current_flyout_o = null;
var flyout_over_bln = false;
var hide_flyout_interval = null;
function flyouts() {
	var menu_o = new get_o("menu");
	if (menu_o.length)
		for (var i=0;i<=(menu_o.length-1);i++) init_menu(menu_o[i]);
	else init_menu(menu_o);
	window.attachEvent ? window.attachEvent("onresize", emulateonresizeend) : window.onresize = emulateonresizeend;
}

var emulateonresizeendiid;
function emulateonresizeend() {
	if (parseInt(emulateonresizeendiid)) clearInterval(emulateonresizeendiid);
	emulateonresizeendiid = setInterval("flyouts();clearInterval(emulateonresizeendiid)" ,100);
}

function init_menu(o) {
	var mpos, target_o, screencenter, sticky_bln = false;
	if (o.getAttribute("stickonurl")) if (location.href.match(o.getAttribute("stickonurl"))) sticky_bln = true;
	if (o.getAttribute("submenu") && !sticky_bln) {
		p = new get_o(o.getAttribute("submenu"));
		if (p.style) {
			mpos = o.getAttribute("submenuposition").split(",");
			if (!parseInt(mpos[0])) {
				if (mpos[0].indexOf("this") != -1) mpos[0] = mpos[0].replace("this", "getposition(o,\"x\")");
				mpos[0] = eval(mpos[0]);
			}
			if (!parseInt(mpos[1])) {
				if (mpos[1].indexOf("this") != -1) mpos[1] = mpos[1].replace("this", "getposition(o,\"y\")");
				mpos[1] = eval(mpos[1]);
			}
			p.style.display = "block";
			p.style.left = mpos[0];
			p.style.top = mpos[1];
		}
		
		o.parentNode.mytc = o;
		
		o.parentNode.onmouseover = function() {
			var o = new get_o(this.mytc.getAttribute("submenu"));
			if (current_flyout_o) {
				current_flyout_o.style.visibility = "hidden";
			}
			if (o.style) o.style.visibility = "visible";
			current_flyout_o = o;
			flyout_over_bln = true;
			if (parseInt(hide_flyout_interval)) clearInterval(hide_flyout_interval);
			hide_flyout_interval = setInterval("hide_flyout()", 1500);
		}

		o.parentNode.onmouseout = function() {
			getposition(this.mytc, "x");
			flyout_over_bln = false;
		}
		
		target_o = new get_o(o.getAttribute("submenu"));
		target_o.myparent = o;

		target_o.onmouseover = function() {
			flyout_over_bln = true;
		}
		
		target_o.onmouseout = function() {
			flyout_over_bln = false;
		}
	}
}

function hide_flyout() {
	var o = current_flyout_o;
	if (!flyout_over_bln) {
		if (hide_flyout_interval != null) clearInterval(hide_flyout_interval);
		hide_flyout_interval = null;
		if (o.style) {
			o.style.visibility = "hidden";
		}
	}
}

function get_o(v) {
	var p = null;
	if (is.ie5up && is.mac) p = eval("document.all."+v);
	else p = document.getElementsByName(v);

	if (p.length==1) p = document.getElementsByName(v)[0];
	else if (p.length==0) p = null;

	return p;
}

function getposition(o, t) {
	var p=0;
	while (o.tagName != "BODY") {
		if (is.mac && is.ie5up) t == "x" ? p += o.offsetLeft : p += o.offsetTop;
		else if (o.tagName != "TR" && o.tagName != "TBODY") t == "x" ? p += o.offsetLeft : p += o.offsetTop;
		o = o.parentNode;
	}
	return p;
}

	//---- DETECTION
	function Is ()
	{   // convert all characters to lowercase to simplify testing
		var agt=navigator.userAgent.toLowerCase();
	
		// *** BROWSER VERSION ***
		// Note: On IE5, these return 4, so use is.ie5up to detect IE5.
	
		this.major = parseInt(navigator.appVersion);
		this.minor = parseFloat(navigator.appVersion);
	
		// Note: Opera and WebTV spoof Navigator.  We do strict client detection.
		// If you want to allow spoofing, take out the tests for opera and webtv.
		this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
					&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
					&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
		this.nav2 = (this.nav && (this.major == 2));
		this.nav3 = (this.nav && (this.major == 3));
		this.nav4 = (this.nav && (this.major == 4));
		this.nav4up = (this.nav && (this.major >= 4));
		this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) ||
							  (agt.indexOf("; nav") != -1)) );
		this.nav6 = (this.nav && (this.major == 5));
		this.nav6up = (this.nav && (this.major >= 5));
		this.gecko = (agt.indexOf('gecko') != -1);
	
	
		this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
		this.ie3    = (this.ie && (this.major < 4));
		this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
		this.ie4up  = (this.ie  && (this.major >= 4));
		this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
		this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
		this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
		this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
		this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
		this.ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
	
		// KNOWN BUG: On AOL4, returns false if IE3 is embedded browser
		// or if this is the first browser window opened.  Thus the
		// variables is.aol, is.aol3, and is.aol4 aren't 100% reliable.
		this.aol   = (agt.indexOf("aol") != -1);
		this.aol3  = (this.aol && this.ie3);
		this.aol4  = (this.aol && this.ie4);
		this.aol5  = (agt.indexOf("aol 5") != -1);
		this.aol6  = (agt.indexOf("aol 6") != -1);
	
		this.opera = (agt.indexOf("opera") != -1);
		this.opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
		this.opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
		this.opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
		this.opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
		this.opera5up = (this.opera && !this.opera2 && !this.opera3 && !this.opera4);
	
		this.webtv = (agt.indexOf("webtv") != -1); 
	
		this.TVNavigator = ((agt.indexOf("navio") != -1) || (agt.indexOf("navio_aoltv") != -1)); 
		this.AOLTV = this.TVNavigator;
	
		this.hotjava = (agt.indexOf("hotjava") != -1);
		this.hotjava3 = (this.hotjava && (this.major == 3));
		this.hotjava3up = (this.hotjava && (this.major >= 3));
	
		// *** JAVASCRIPT VERSION CHECK ***
		if (this.nav2 || this.ie3) this.js = 1.0;
		else if (this.nav3) this.js = 1.1;
		else if (this.opera5up) this.js = 1.3;
		else if (this.opera) this.js = 1.1;
		else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2;
		else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3;
		else if (this.hotjava3up) this.js = 1.4;
		else if (this.nav6 || this.gecko) this.js = 1.5;
		// NOTE: In the future, update this code when newer versions of JS
		// are released. For now, we try to provide some upward compatibility
		// so that future versions of Nav and IE will show they are at
		// *least* JS 1.x capable. Always check for JS version compatibility
		// with > or >=.
		else if (this.nav6up) this.js = 1.5;
		// note ie5up on mac is 1.4
	
	
		else if (this.ie5up) this.js = 1.3
	
		// HACK: no idea for other browsers; always check for JS version with > or >=
		else this.js = 0.0;
	
		// *** PLATFORM ***
		this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
		// NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
		//        Win32, so you can't distinguish between Win95 and WinNT.
		this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
	
		// is this a 16 bit compiled version?
		this.win16 = ((agt.indexOf("win16")!=-1) || 
				   (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
				   (agt.indexOf("windows 16-bit")!=-1) );  
	
		this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
						(agt.indexOf("windows 16-bit")!=-1));
	
		// NOTE: Reliable detection of Win98 may not be possible. It appears that:
		//       - On Nav 4.x and before you'll get plain "Windows" in userAgent.
		//       - On Mercury client, the 32-bit version will return "Win98", but
		//         the 16-bit version running on Win98 will still return "Win95".
		this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
		this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
		this.win32 = (this.win95 || this.winnt || this.win98 || 
						((this.major >= 4) && (navigator.platform == "Win32")) ||
						(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
	
		this.winme = ((agt.indexOf("win 9x 4.90")!=-1));
		this.win2k = ((agt.indexOf("windows nt 5.0")!=-1));
	
		this.os2   = ((agt.indexOf("os/2")!=-1) || 
						(navigator.appVersion.indexOf("OS/2")!=-1) ||   
						(agt.indexOf("ibm-webexplorer")!=-1));
	
		this.mac    = (agt.indexOf("mac")!=-1);
		// hack ie5 js version for mac
		if (this.mac && this.ie5up) this.js = 1.4;
		this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) || 
								   (agt.indexOf("68000")!=-1)));
		this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || 
									(agt.indexOf("powerpc")!=-1)));
	
		this.sun   = (agt.indexOf("sunos")!=-1);
		this.sun4  = (agt.indexOf("sunos 4")!=-1);
		this.sun5  = (agt.indexOf("sunos 5")!=-1);
		this.suni86= (this.sun && (agt.indexOf("i86")!=-1));
		this.irix  = (agt.indexOf("irix") !=-1);    // SGI
		this.irix5 = (agt.indexOf("irix 5") !=-1);
		this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
		this.hpux  = (agt.indexOf("hp-ux")!=-1);
		this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1));
		this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1));
		this.aix   = (agt.indexOf("aix") !=-1);      // IBM
		this.aix1  = (agt.indexOf("aix 1") !=-1);    
		this.aix2  = (agt.indexOf("aix 2") !=-1);    
		this.aix3  = (agt.indexOf("aix 3") !=-1);    
		this.aix4  = (agt.indexOf("aix 4") !=-1);    
		this.linux = (agt.indexOf("inux")!=-1);
		this.sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
		this.unixware = (agt.indexOf("unix_system_v")!=-1); 
		this.mpras    = (agt.indexOf("ncr")!=-1); 
		this.reliant  = (agt.indexOf("reliantunix")!=-1);
		this.dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
					  (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
					  (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
		this.sinix = (agt.indexOf("sinix")!=-1);
		this.freebsd = (agt.indexOf("freebsd")!=-1);
		this.bsd = (agt.indexOf("bsd")!=-1);
		this.unix  = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux || 
					 this.sco ||this.unixware || this.mpras || this.reliant || 
					 this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);
	
		this.vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
		
		// *** PRESET JSA VARS ***
		this.get_ok		= this.nav6up || (this.ie && this.win) || this.opera5up;
		this.get_good	= this.win && this.ie5up;
		
	}
	var is;
	is = new Is(); 
	
	//---------------- // DETECTION END

//---------------- //




