function validate(theForm)
{
 for (var i = 0, n = theForm.elements.length; i < n; i ++)
 {
   currElem = theForm.elements[i];
   if (currElem.type == "text" && currElem.value == "" && currElem.className=="forChecking")
   {
     alert("Please fill in the " + currElem.id + " field");
     currElem.focus();
     return false;
   }
   if (currElem.type == "radio")
   {
	   if(!checkOpt(theForm[currElem.name])) {
		   alert("Please fill in the " + currElem.id + " field");
    	   return false;
	   }
   }
 }
 return true;
}

function checkOpt(theOpt){
  for(var i=0;i<theOpt.length;i++){
    if(theOpt[i].checked==true) return true;
  }
  return false;
}

// DataEntered

function DataEntered(obj) {
// Checks if data has been entered in the field and if not returns False
  if (isEmpty(obj.value)) {
	  alert('You must enter a value in this field.');
	  obj.focus();
  }
  return;
}

// isEmpty

function isEmpty(strng) {
// Returns True if the field is empty otherwise returns false
  if (strng.length == 0) {
     return true;
  }
  return false;	  
}

// email

function checkEmail (strng) {
   // Check if email entered; if not entered, return false;
   if (isEmpty(strng)) {
      return false;
   }

   // Check for valid email format
   var emailFilter=/^.+@.+\..{2,3}$/;
   if (!(emailFilter.test(strng))) { 
      // Not a valid email address
      return false;
   }
   else {
      //test email for illegal characters
      var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
      if (strng.match(illegalChars)) {
         // Not a valid email address
         return false;
      }
   }
   // Email address valid
   return true;    
}

function GetNow() {
d=new Date()
day=d.getDay();
month=d.getMonth();
monthday=d.getDate();
year=d.getYear();

var dayname = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var monthname = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

return(dayname[day] + ", " + monthname[month] + " " + monthday + ", "+year);
}

