function checkrequired(which) {
  var pass=true;

  for (i=0;i<which.length;i++)
   {
    var tempobj=which.elements[i];

	 if (tempobj.name.substring(0,8)=="required")
	{
      	if (((tempobj.type=="text"||tempobj.type=="textarea")&&
          	tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
          	tempobj.selectedIndex==0))
			{
		        pass=false;
		        break;
		      }
    	}
  }

  if (!pass) {
    shortFieldName=tempobj.name.substring(8,30).toUpperCase();
    alert("Fields marked with (*) are required and cannot be left emtpy.");
    return false;
  }
else
{
  	return true;
  }
}

function check(FormName, FieldName)
{
	if(!document.forms[FormName])
		return;
	var objCheckBoxes = document.forms[FormName].elements[FieldName];
	if(!objCheckBoxes)
		return;

	var countCheckBoxes = objCheckBoxes.length;
	if(!countCheckBoxes)
		objCheckBoxes.checked = !objCheckBoxes.checked;
	else
		// set the check value for all check boxes
		for(var i = 0; i < countCheckBoxes; i++)
			objCheckBoxes[i].checked = !objCheckBoxes[i].checked;
}

function validate(which,mailid)
{
	if (checkrequired(which))
	{
		return emailCheck(mailid);
	}
	else
	{return false;}
}

