function checkrequired(which) {
  var pass=true;
  var goahead=true;
  for (i=0;i<which.length;i++) {
    var tempobj=which.elements[i];
    if (tempobj.name.substring(0,3)=="req") {
      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(3,30).toUpperCase();
    alert("The "+shortFieldName+" field is a required field.");
    goahead = false;
  }   
return goahead;
}

function checkEmail(email) {
var validEmail = /^\w(\.?\w)*@\w(\.?[-\w])*\.([a-z]{3}(\.[a-z]{2})?|[a-z]{2}(\.[a-z]{2})?)$/i;
var isValid = validEmail.test(email);
return isValid;
}

function checkPhone(phone) {
	var validPNum = /^\d{3}-\d{3}-\d{4}$/;
	var isValid = validPNum.test(phone);
	return isValid;
}

function checkForm(able) {
	if (checkrequired(able)) { 	
			if (checkEmail(able.reqemail.value)) {
				return true;
			} else {
				alert("Email is invalid. Please re-enter email address.");
				return false;
			}

	} else {
 		return false;
	}
}

function getMap(mappie) {
	var zip = mappie.zip.value;
	var url = "http://maps.google.com/maps?daddr=20+Country+Estates+Rd,+Greenville,+NY+12083+(KathodeRay+Restaurant)&geocode=15804989792612017279,42.368881,-73.830655&dirflg=&saddr="+zip+"&f=d&hl=en&dq=kathoderay+restaurant+loc:+coxsackie,+ny&sll=42.34806,-73.80015&sspn=0.850242,1.360166&cid=42368881,-73830655,3086051088786471085&ie=UTF8&z=11&om=1";
	
	window.open(url);
}
