sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
         if (document.getElementById("sermonLists")) {
            document.getElementById("sermonLists").style.visibility="hidden";
         }
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			if (document.getElementById("sermonLists")) {
            document.getElementById("sermonLists").style.visibility="visible";
			}
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

$(document).ready(function(){
  $(".navigation ul li:last-child").css("border-right","none");

  // Form Reset
  $("#clinicSearch #agree").removeAttr('checked');
  $("#clinicSearch input[id=search_by_zip_go]").attr('disabled',true);
  $("#clinicSearch input[name=zip]").attr("value","");

  $("#clinicSearch #agree").click(function(){
    if ($(this).is(":checked")) {
      $("#clinicSearch input[id=search_by_zip_go]").attr('disabled',false);
    }
    else {$("#clinicSearch input[id=search_by_zip_go]").attr('disabled',true);}
  });

  //zip validation
  var isZip = function(s){
      var reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
      if (!reZip.test(s)) {
          return false;
      }
      return true;
  }

  $("#clinicSearch form#search_by_zip, #clinicSearch form#draw_site").submit(function(){
    var zip = $(this).parent().find("input[name=zip]");
    var zipVal = isZip(zip.val());
    if (zipVal == "" ){
      zip.css("border","2px solid red");
      zip.attr("value","Please enter a zip code");
      return false;
    }
  });

  $("#clinicSearch input[name=zip]").focus(function(){
    $(this).attr("value","");
  });
});