function validatePage(form, password, limit){
	var pass = true;
	var myObj;
	var msg = "";
	var errBackground = "#D0E4FF";
	var errColor = "#111111";
	form = eval("document."+form);
	
	for (var i=0; i<form.length; i++) {
		myObj = form.elements[i]
		if (myObj.name.substring(0,4) == "req_"  && myObj.value == "") {
			change(myObj, errBackground, errColor);
			msg = "Please fill out all required fields\n\n";
			pass = false;
		} else {
			if (myObj.name.substring(0,4) == "req_") { 
				change(myObj, "#ffffff", "#111111");
			}	
		}
	}
	if (password == true) {
		if (form.password.value.length < 6) {
			msg += "Please enter a password of 6 or more characters\n\n";
			change(form.password, errBackground, errColor);
			change(form.confirm_password, "#ffffff", "#111111");
			pass = false;
		} else if (form.password.value != form.confirm_password.value) {
			msg += "Your confirmation password is different to your password\n\n";
			change(form.confirm_password, errBackground, errColor);
			change(form.password, "#ffffff", "#111111");
			pass = false;	
		}
	}
	if (limit == true) {
		alert("test");
		var limitstring = form.results_blurb.value;
		var words = limitstring.split(" ");
		var length = words.length;
		
		if (length > 30) {
			msg += "Your results text must be 30 words or less\n\n";
			change(form.results_blurb, errBackground, errColor);
			pass = false;
		} else {
			change(form.results_blurb, "#ffffff", "#111111");
		}
		
	}
	
	if (!pass) {
		alert(msg);
	}
	return pass;
}
function change(myObj, background, color) {	
	myObj.style.backgroundColor = background;
	myObj.style.color = color;
}

//===================================================================
//the following is jun's code

function validateNotEmpty( strValue ) { 
   var strTemp = strValue;
   strTemp = trimAll(strTemp);
   if(strTemp.length > 0){
     return true;
   }
   return false;
}

function trimAll( strValue ) { 
 var objRegExp = /^(\s*)$/;

    //check for all spaces
    if(objRegExp.test(strValue)) {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }

   //check for leading & trailing spaces
   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
   if(objRegExp.test(strValue)) {
       //remove leading and trailing whitespace characters
       strValue = strValue.replace(objRegExp, '$2');
    }
   return strValue;
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

