<!--
/*
var Email = new validation('Email Address', 'sEmail', 'text', 'isEmail(str)', null);

var elts = new Array(Email);
*/
//alert ("who knew 1");

var beginRequestAlertForText = "Please include ";
var beginRequestAlertGeneric = "Please choose ";
var endRequestAlert = ".";
var beginInvalidAlert = " is an invalid ";
var endInvalidAlert = "!";
var beginFormatAlert = "  Use this format: ";

var BorderColor="red";

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}  //String.prototype.trim = function ()


function checkType(el) {
	//check if this is a type in a group
	var rtn = "";
	
	if (el.length>1) rtn=el[0].type;
	//alert("this is "+error);
	return rtn;
}  //function checkType(el)

//alert ("who knew 2");

	// email
	function checkEmail (strng,name) {
		var error="";
		var emailFilter=/^.+@.+\..{2,3}$/;
		var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/;

		if (strng == "") 
			error = "You didn't enter an email address";
		
		else{
			if (!(emailFilter.test(strng))) 
			    error = "Please enter a valid email address";
			
			else {
				//test email for illegal characters
				 if (strng.match(illegalChars))
					error = "The email address contains illegal characters";
			
			}
		}	//if (strng == "") else
		
		if (error!=""){error+=" ["+name+" field].\n";}
		
		return error;
	}  //function checkEmail (strng,name)


    // phone number - strip out delimiters and check for 10 digits
	function checkPhone (strng,name) {
		var error = "";
		
		if (strng == "")
		   error = "You didn't enter a phone number.\n";
		
		var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
		
		if (isNaN(parseInt(stripped)))
		   error = name+" contains illegal characters ["+name+"].";
	  
		if (!(stripped.length == 10))
			error = "The "+name+" number is the wrong length. Make sure you included an area code ["+name+"].\n";
		
		return error;
	}  //function checkPhone (strng,name)


	// password - between 6-8 chars, uppercase, lowercase, and numeral
	
	function checkPassword (strng,name) {
		var error = "";
		var illegalChars = /[\W_]/; // allow only letters and numbers
		
		if (strng == "")
		    error = "You didn't enter a password ["+name+"].\n";
		
		
		if ((strng.length < 6) || (strng.length > 8))
		   error = name+" must be between 6-8 characters in length.\n";
		
		else if (illegalChars.test(strng))
		    error = "Your "+name+" contains illegal characters [no spaces].\n";
		 
		else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
		   error = "The "+name+" must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
		} 
		
		return error;    
	}  //function checkPassword (strng,name)  


    // username - 4-10 chars, uc, lc, and underscore only.
	function checkUsername (strng,name) {
		var error = "";
		
		if (strng == "")
			error = "You didn't enter a username ["+name+"].\n";
		
		var illegalChars = /\W/; // allow letters, numbers, and underscores
		if ((strng.length < 4) || (strng.length > 10))
		   error = name+" must be 4-10 characters in length.\n";

		else if (illegalChars.test(strng))
		error = "The "+name+" contains illegal characters \n(Be sure there are no spaces).\n\n";
		
		return error;
	}  //function checkUsername (strng,name)


	// non-empty textbox
	function isEmpty(strng,name) {
		var error = "";
	
		if (strng.length == 0)
			error = "The mandatory text area has not been filled in ["+name+"].\n"
		
		return error;	  
	}  //function isEmpty(strng,name)

	// are two string equal
	function isDifferent(strng,chkstrng,name) {
		var error = ""; 
		if (strng != chkstrng)
			error = "The text you entered for "+name+" does not match!\n";

		return error;
	}  //function isDifferent(strng,chkstrng,name)

    // exactly one radio button is chosen
	function checkRadio(el) {
		var error = "";
		
		rtn="";
		
		for (i=0;i<el.length;i++){
			if (el[i].checked==true)
				rtn=rtn+i;
		}  //for (i=0;i<el.length;i++)
		
		if (!(rtn))
		   error = "Please check a radio button ["+name+"].\n";
		
		return error;
	}  //function checkRadio(el)


	// valid selector from dropdown list
	function dropDownMenu(el)  {
		var myindex=el.selectedIndex;
		if (myindex==0) {
			//alert("\nYou must make a selection from the drop-down menu.");
			el.focus();
			return false;
		} //if (myindex==0)
		else {
			menu_selection=el.options[myindex].value;
			return true;
		}
	} //function dropDownMenu(el)

	function validateForm(frm){
	  rtn=true;
	  
	  var elment=frm.elements.ReqName.value;
	  elments=elment.split(",");
	  var elNm=frm.elements.Required.value;
	  elNames=elNm.split(",");

	  msg=" ";
	  
	  if(BorderColor.length<=0) BorderColor="red";

	  for(i=0; i<elNames.length;i++){
          myEl=elNames[i].trim();
		  elValue=frm[myEl].value;
		  if(frm[myEl].type==undefined) checkType(frm[myEl]);
		  
//alert(elValue +" is " + frm[myEl].type);		  
		  switch(frm[myEl].type) {
			case "text":
				if(frm[myEl].style.borderColor.indexOf("red")==0)
				    frm[myEl].style.borderColor="Blue";
					
				$nothing=true;
				if (elValue.length == 0) {
					if(msg!=" ") msg+=", \r\n\t";
					msg+=elments[i]+" is a required field and cannot be empty  ";
					frm[myEl].style.borderColor=BorderColor; 
				}  //if (elValue.length == 0)
				else if(elNames[i].indexOf("mail")>0){

					message=checkEmail(elValue, elNames[i]);
					if(!message==""){
						if(msg!=" ") msg+=", \r\n\t";
						msg+=message.replace(elNames[i],elments[i]);
						frm[myEl].style.borderColor=BorderColor; 
					}  //if(!isEmail(elValue))
				} //else if(elNames[i].indexOf("mail"))
				else if(elNames[i].indexOf("phone")>0){
					message=checkPhone(elValue, elNames[i]);
					if(!message==""){
						if(msg!=" ") msg+=", \r\n\t";
						msg+=message;
						frm[myEl].style.borderColor=BorderColor; 
					}  //if(!isEmail(elValue))
				} //else if(elNames[i].indexOf("mail"))
				
				else if(elNames[i].indexOf("user")>0){
					message=checkUsername(elValue, elNames[i]);
					if(!message==""){
						if(msg!=" ") msg+=", \r\n\t";
						msg+=message;
						frm[myEl].style.borderColor=BorderColor; 
					}  //if(!isEmail(elValue))
				} //else if(elNames[i].indexOf("mail"))
				
				break;

			case "textarea":
				elValue=frm[myEl].value;

				if(frm[myEl].style.borderColor.indexOf("red")==0)
				    frm[myEl].style.borderColor="Blue";
					
				if (elValue.length == 0) {
					if(msg!=" ") msg+=", ";
					msg+=elNames[i]+"  is a required field and cannot be empty";
					frm[myEl].style.borderColor=BorderColor; 
				}  //if (elValue.length == 0)
				
				break;
			case "checkbox":
				break;
			case "select-one":
				if(dropDownMenu(frm[myEl])){
				}
				else {
					if(msg!=" ") msg+=", \r\n\t";
					msg+=elNames[i]+"  is a required field and cannot be empty";
					frm[myEl].style.borderColor=BorderColor; 
				}
				break;
			case "select-multiple":
				break;
			case "password":
				message=checkPassword(elValue, elNames[i]);
				if(!message==""){
					if(msg!=" ") msg+=", \r\n\t";
					msg+=message;
					frm[myEl].style.borderColor=BorderColor; 
				}  //if(!isEmail(elValue))
				
				break;
			case "file":
				break;
			case "radio":
				rslt=checkRadio(frm[myEl]);
				if(rslt!=""){
					if(msg!=" ") msg+=", ";
				    msg+=rslt;
					frm[myEl].style.borderColor=BorderColor; 
				}
				break;
			case "undefined":
				break;
		  }	//switch(frm[myEl].type)*/
	  }	//for(var i=0; i<elments.length;i++)

      if(msg!=" ") {
	  	//document.getElementById(ErrmsgId).innerHTML=rtnMessage +msg+")";
		alert("Note the following Errors:\r\n\t"+msg+".\r\n\r\nThe items to correct are in "+BorderColor+".");
	  	rtn=false;
	  }	//if(msg!=" ") 

	  return rtn;
	}	//function validateForm(frm, elments, elNames)
	
-->
