// JavaScript Document

$("document").ready(function() {

$(".dropdown").css({ visibility:"visible" });
$(".dropdown").hide();


$("#ubergo").hover(function() {
    $(this).attr("src", $(this).attr("src").split(".jpg").join("_over.jpg"));
	  }, function() {
	$(this).attr("src", $(this).attr("src").split("_over.jpg").join(".jpg"));
  });

$("#uber211").hover(function() {
    $(this).attr("src", $(this).attr("src").split(".jpg").join("_over.jpg"));
	  }, function() {
	$(this).attr("src", $(this).attr("src").split("_over.jpg").join(".jpg"));
  });
$("#ubermha").hover(function() {
    $(this).attr("src", $(this).attr("src").split(".jpg").join("_over.jpg"));
	  }, function() {
	$(this).attr("src", $(this).attr("src").split("_over.jpg").join(".jpg"));
  });


$("#user_pass").hide();


$("#passshow").click(function() {
    $("#user_pass").show();
	$("#user_null").hide();
	$("#passshow").hide();
  });

//generateSprites(".nav", "current-", true, 200, "fade");


$("#calendarmain").datepicker(); 

$("#mailinglistform").validate();
$("#employmentform").validate({
            rules: {
				Comments: {
					required:false,
					minlength:0,
					maxlength:200,
					validChars:true
					}
		}
   });
$("#eventregform").validate({
            rules: {
				Comments: {
					required:false,
					minlength:0,
					maxlength:200,
					validChars:true
					}	
		}
   });
$("#volunteerform").validate();
$("#asistform").validate({
            rules: {
				Comments: {
					required:false,
					minlength:0,
					maxlength:200,
					validChars:true
					}	
		}
   });
$("#outreachform").validate({
            rules: {
				Comments: {
					required:false,
					minlength:0,
					maxlength:200,
					validChars:true
					}	
		}
   });
$("#form").validate({
            rules: {
				Message: {
					required:false,
					minlength:0,
					maxlength:200,
					validChars:true
					}	
		}
   });


$("#quicklinks").change(function () {
	  var quick = "";
	  $("#quicklinks option:selected").each(function () {
			quick = $(this).attr("value");
			window.location = quick;
			var quick = "";
		  });
	})

$("#mhi").change(function () {
	  var mhi = "";
	  $("#mhi option:selected").each(function () {
			mhi = $(this).attr("value");
			window.location = mhi;
			var mhi = "";
		  });
	})

$("#fac").change(function () {
	  var fac = "";
	  $("#fac option:selected").each(function () {
			fac = $(this).attr("value");
			window.location = fac;
		  });
	})

var currentbg = $(".programs a").css("background");

$("#programs").hover(function() {
   $(".dropdown").show();
    var currentbg = $(".programs a").css("background");
   $(".programs a").css("background","url(../images/navsprite.gif) no-repeat -89px -46px");
	  }, function() {
	$(".dropdown").hide();
	$(".programs a").css("background",currentbg);
  });


$(".dropdown").hover(function() {
   $(".dropdown").show();
   $(".programs a").css("background","url(../images/navsprite.gif) no-repeat -89px -46px");

	  }, function() {
	$(".dropdown").hide();
	$(".programs a").css("background","url(../images/navsprite.gif) no-repeat -89px 0px");
  });


$('#homeimages').cycle({ 
    fx:    'fade', 
    speed:  6000 ,
	pause: 4
 });



});

 $.validator.addMethod('validChars', function (value) {

 	var result = true;
   	var iChars = "@#$%^&*()+=-[]\\\';/{}|\":<>?";

    for (var i = 0; i < value.length; i++) {
      if (iChars.indexOf(value.charAt(i)) != -1) {
          return false;
        }
      }

     return result;
     
 }, '');
