function CheckEditForms() {
	var ProblemField = false;
	for (a=0;a<arguments.length;a++) {//cycle through passed arguments
		var thisField = document.getElementById(arguments[a]);
		
		var cleanText = thisField.name.replace(/_/g," ");//show text box name cleanly (greedy)
		
		if ( thisField.value == '' ) {//if empty
			ProblemField = true;
		}
		//if email field and no '.' or '@'
		if ( thisField.name == 'Email' && ( thisField.value.indexOf('@') == -1 || thisField.value.indexOf('.') == -1 || thisField.value.indexOf(' ') != -1 ) ) {
			ProblemField = true;
		}
		if ( thisField.type == 'checkbox' && !thisField.checked ) {
			ProblemField = true;
		}
		
		if ( ProblemField ) {
			thisField.style.backgroundColor = '#FFC';
		}
	}//end for
	
	if ( ProblemField ) {
		alert( MSG_ERRORFIELD );//display warning
		return false;//fail
	} else {
		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( MSG_INT );//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( MSG_FP );//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';
	}
}

function attachEvents( ElementID , Event , FunctionName ) {
	if ( !document.getElementById( ElementID ) ) return false;
	var el = document.getElementById( ElementID );

	if ( el.addEventListener ){
		el.addEventListener( Event , FunctionName , false);
		return true;
	} else if ( el.attachEvent ){
		var r = el.attachEvent( 'on' + Event , FunctionName );
		return r;
	} else {
		eval( "el.on" + Event + " = " + FunctionName + ";" );
		return true;
	}
	return false;
}
function attachEventByName( ElementID , Event , FunctionName ) {
	el = document.getElementsByName( ElementID );

	for ( e=0; e<el.length; e++ ) {
		if ( el[e].addEventListener ){
			el[e].addEventListener( Event , FunctionName , false);
			return true;
		} else if ( el[e].attachEvent ){
			var r = el[e].attachEvent( 'on' + Event , FunctionName );
			return r;
		} else {
			eval( "el[e].on" + Event + " = " + FunctionName + ";" );
			return true;
		}
	}
	return false;
}