function volunteer_Validator(theForm)
{
  if (!ValidName(theForm)) {return (false);}
  if (!ValidEmail(theForm)) {return (false);}
  if (!ValidVolType(theForm)) {return (false);}
}

function comment_Validator(theForm)
{
  if (!ValidName(theForm)) {return (false);}
  if (!ValidEmail(theForm)) {return (false);}
}

function contribute_Validator(theForm)
{
  if (!ValidFirstName(theForm)) {return (false);}
  if (!ValidLastName(theForm)) {return (false);}
  if (!ValidAddress(theForm)) {return (false);}
  if (!ValidCity(theForm)) {return (false);}
  if (!ValidState(theForm)) {return (false);}
  if (!ValidZip(theForm)) {return (false);}
  if (!ValidEmail(theForm)) {return (false);}
  if (!ValidEmployer(theForm)) {return (false);}
  if (!ValidOccupation(theForm)) {return (false);}
  if (!ValidAmount(theForm)) {return (false);}
  if (!ValidConfirmElig(theForm)) {return (false);}
}

function jake_Validator(theForm)
{
  if (!ValidRespic(theForm)) {return (false);}
  if (!ValidFirstName(theForm)) {return (false);}
  if (!ValidLastName(theForm)) {return (false);}
  if (!ValidAddress(theForm)) {return (false);}
  if (!ValidCity(theForm)) {return (false);}
  if (!ValidState(theForm)) {return (false);}
  if (!ValidZip(theForm)) {return (false);}
  if (!ValidEmail(theForm)) {return (false);}
  if (!ValidEmployer(theForm)) {return (false);}
  if (!ValidOccupation(theForm)) {return (false);}
  if (!ValidAmount2(theForm)) {return (false);}
}

function ValidName(theForm)
{
  if (theForm.sName.value == "")
  {
    alert("Please enter Your Name.");
    theForm.sName.focus();
    return (false);
  } else { return (true); }
}
function ValidFirstName(theForm)
{
  if (theForm.first_name.value == "")
  {
    alert("Please enter Your First Name.");
    theForm.first_name.focus();
    return (false);
  } else { return (true); }
}
function ValidLastName(theForm)
{
  if (theForm.last_name.value == "")
  {
    alert("Please enter Your Last Name.");
    theForm.last_name.focus();
    return (false);
  } else { return (true); }
}
function ValidAddress(theForm)
{
  if (theForm.address1.value == "")
  {
    alert("Please enter Your Street Address.");
    theForm.address1.focus();
    return (false);
  } else { return (true); }
}
function ValidCity(theForm)
{
  if (theForm.city.value == "")
  {
    alert("Please enter Your City.");
    theForm.city.focus();
    return (false);
  } else { return (true); }
}
function ValidState(theForm)
{
  if (theForm.state.value == "")
  {
    alert("Please enter a valid State Abbreviation.");
    theForm.state.focus();
    return (false);
  } else { return (true); }
}
function ValidZip(theForm)
{
  if (theForm.zip.value == "")
  {
    alert("Please enter Your Zip Code.");
    theForm.zip.focus();
    return (false);
  } else { return (true); }
}
function ValidEmployer(theForm)
{
  if (theForm.os0.value == "")
  {
    alert("Please enter Your Employer.");
    theForm.os0.focus();
    return (false);
  } else { return (true); }
}
function ValidOccupation(theForm)
{
  if (theForm.os1.value == "")
  {
    alert("Please enter Your Occupation.");
    theForm.os1.focus();
    return (false);
  } else { return (true); }
}
function ValidAmount(theForm) {
    var cnt = -1;
    for (var i=theForm.amount.length-1; i > -1; i--) {
        if (theForm.amount[i].checked) {cnt = i; i = -1;}
    }
	if (cnt > -1)
	{
		return (true);
	} else {
    	alert("Please select the amount you would like to contribute.");
    	return (false);
  	} 
}
function ValidRespic(theForm) {
    var cnt = -1;
    for (var i=theForm.respic.length-1; i > -1; i--) {
        if (theForm.respic[i].checked) {cnt = i; i = -1;}
    }
	if (cnt > -1)
	{
		return (true);
	} else {
    	alert("Please select a reservation option.");
    	return (false);
  	} 
}
function ValidAmount2(theForm) {
	if (theForm.respic[0].checked) {
		theForm.amount.value = 1000
		theForm.item_name.value = "Jake's Night Out / Sponsor 2 tables / $1,000"
	}
	if (theForm.respic[1].checked) {
		theForm.amount.value = 500
		theForm.item_name.value = "Jake's Night Out / Sponsor 1 table / $500"
	}
	if (theForm.respic[2].checked) {
		theForm.amount.value = theForm.persons.value * 25
		theForm.item_name.value = "Jake's Night Out / Reserve " + theForm.persons.value + " seats / $" + theForm.amount.value
	}
	if (theForm.respic[3].checked) {
		theForm.amount.value = theForm.donateamt.value
		theForm.item_name.value = "Jake's Night Out / Contribution / $" + theForm.donateamt.value
	}

	if (theForm.amount.value > 0)
	{
		return (true);
	} else {
    	alert("Please enter the number of seats or amount that you would like to contribute.");
    	return (false);
  	} 
}


function ValidConfirmElig(theForm) {
	if (theForm.sConfirmElig.checked)
	{
		return (true);
	} else {
    	alert("Please Confirm Your Eligibility.");
    	return (false);
  	} 
}

function ValidVolType(theForm) {
    var cnt = -1;
    for (var i=theForm.sVolType.length-1; i > -1; i--) {
        if (theForm.sVolType[i].checked) {cnt = i; i = -1;}
    }
	if (cnt > -1)
	{
		return (true);
	} else {
    	alert("Please select the type of volunteer work you would like to do.");
    	return (false);
  	} 
}
function ValidPhone(theForm)
{
  if (theForm.sPhone.value == "")
  {
    alert("Please enter Your Telephone Number.");
    theForm.sphone.focus();
    return (false);
  } else { return (true); }
}
function ValidEmail(theForm)
{
  if (theForm.email.value == "" || theForm.email.value < 7 || !EmailChrs(theForm.email.value) || !echeck(theForm.email.value) )
  {
    alert("Please enter a valid Email Address.");
    theForm.email.focus();
    return (false);
  } else { return (true); }
}

function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
	    return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
	    return false
	}
	if (str.indexOf(" ")!=-1){
	   return false
	}
	
	var last3 = str.split(".");
	var llc = last3[1].toLowerCase();
	if (llc == "com") {
		return true
	}
	if (llc == "net") {
		return true
	}
	if (llc == "org") {
		return true
	}
	if (llc == "gov") {
		return true
	}
	if (llc == "edu") {
		return true
	}

	return false					
}

function ValChars(checkStr)
{
  var checkOK = ".,-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f";
  var status = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      status = false;
      break;
    }
  }
  return (status);
}

function EmailChrs(checkStr)
{
	var chr1 = /@/;
	var chr2 = /./;
	var matchPos1 = checkStr.search(chr1);

	if(checkStr.search(chr1) != -1 && checkStr.search(chr2) != -1)
	{
		return (true); 
	}
	else
	{
		return (false);	
	}
}

function Numeric(checkStr)
{
  var checkOK = "0123456789";
  var status = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      status = false;
      break;
    }
  }
  return (status);
}
