//---------------- MISC

function global() {
	orollover();
	saved_comments(savedComments);
}

//---------------- //





//---------------- 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,3})$/;
	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);
	}
}
//---------------- //