function CheckEditForms() {
	for (a=0;a<arguments.length;a++) {//cycle through passed arguments
		var ProblemField=AlertMessage=false;
		cleanText=arguments[a].name.replace(/_/g," ");//show text box name cleanly (greedy)
		
		if ( arguments[a].value=='' ) {//if empty
			AlertMessage="Please complete the '"+cleanText+"' Field.";
			ProblemField=true;
		}
		//if email field and no '.' or '@'
		if (arguments[a].name=='Email' && (arguments[a].value.indexOf('@')==-1 || arguments[a].value.indexOf('.')==-1 || arguments[a].value.indexOf(' ')!=-1)) {
			AlertMessage="Please enter a valid Email Address.";
			ProblemField=true;
		}
		if (arguments[a].name=='Email_Verification' && (arguments[a].value.indexOf('@')==-1 || arguments[a].value.indexOf('.')==-1 || arguments[a].value.indexOf(' ')!=-1 || arguments[a].value!=document.getElementById('Email').value) ) {
			AlertMessage="Your email addresses do not match.";
			ProblemField=true;
		}
		if (arguments[a].name=='Password_Verification' && arguments[a].value!=document.getElementById('Password').value ) {
			AlertMessage="Your passwords do not match.";
			ProblemField=true;
		}
		if (arguments[a].type=='checkbox' && !arguments[a].checked) {
			AlertMessage="You must tick the '"+cleanText+"' box.";
			ProblemField=true;
		}
		
		if (ProblemField) {
			alert(AlertMessage);//display warning
			arguments[a].focus();//go to field
			return false;//fail
		}
	}//end for
	return true;//if all ok exec
}//end CheckEditForms

function SelectAllCheckboxes(Boxes2Check,FormName) {
	for (a=0;a<document.forms[FormName].length;a++) {//cycle through passed arguments
        if (document.forms[FormName].elements[a].name==Boxes2Check && document.forms[FormName].elements[a].type=='checkbox') {
			document.forms[FormName].elements[a].checked=true;//only using form[1] because the search form exists already
		}
	}
}

function validateIntegerNumbers(textBox) {//Allow only integers
	string=textBox.value;//get value of passed field
    if (!string) return false;//if nothing fail
    var Chars = "0123456789";//allowable characters
	SLength=string.length;//get field length

    for (i=0;i<SLength;i++) {//go through chars one at a time
       	if (Chars.indexOf(string.charAt(i)) == -1) {//if character not found in allowable characters
		  textBox.value=string.substring(0,SLength-1);//delete the last entered character
          alert("Please use ONLY integers.\n12,500 should be entered as 12500.\nExamples: 5, 94, 54327");//warning
		  return false;//fail
		}
    }
    return true;//if all ok exec
}

function validateFPNumbers(textBox) {//Allow only floating point numbers
	string=textBox.value;//get value of passed field
    if (!string) return false;//if nothing fail
    var Chars = "0123456789.";//allowable characters '.' for floating point numbers
	SLength=string.length;//get field length

    for (i=0;i<SLength;i++) {//go through chars one at a time
       	if (Chars.indexOf(string.charAt(i)) == -1) {//if character not found in allowable characters
		  textBox.value=string.substring(0,SLength-1);//delete the last entered character
          alert("Please use ONLY floating point numbers.\nExamples: 1.3, 5, 29.34");//warning
		  return false;//fail
		}
    }
    return true;//if all ok exec
}

function PopWin(URL,H,W) {
	window.open(URL,'Popped',"Height="+H+",Width="+W+",scrollbars,resizable,status");
}

function Expand(Did) {
	if (document.getElementById) {
		document.getElementById(Did).style.display=(document.getElementById(Did).style.display=='none')?'block':'none';
	}
	else if (document.all) {
		document.all[Did].style.display=(document.all[Did].style.display=='none')?'block':'none';
	}
}

//MM_preloadImages('/incs/images/background.jpg','')
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];}}
}