//###   Add custom method - this requires the value to be the same as the first parameter   ###
$.validator.methods.notequal = function(value, element, param) {
	return value != param;
};

$(document).ready(function() {
	$("#site-search-form").validate();

	$("#job-posting-form").validate();

	$("#contest_entry").validate();

	$("#trayless-form").validate();

	$("#sustainability_initiatives").validate();

	$("#contact").validate();

	$("#travel-grants-form").validate();

	$("#good-cents-form").validate();

	$("#sustainability-contest-form").validate();

	$("#program-proposal-form").validate();

	$("#executive-director-form").validate();

	$("#twmds-nomination-form").validate();

	$("#dlm-nomination-form2").validate();

	$("#dvhi-nomination-form").validate();

	$("#northeast-officer-nomination").validate();

	$("#southern-officer-nomination").validate();

	$("#student-employee-of-the-year").validate();

	$("#four-o-four").validate();

	$("#institutes-form").validate();

	if ($("#internship-application-form").length) {
	$("#internship-application-form").validate();
	$('#internship-application-form input[name="cover-letter"]').rules("add", {
		required: true,
		messages: "File upload required"
	});
	$('#internship-application-form input[name="resume"]').rules("add", {
		required: true,
		messages: "File upload required"
	});
	$('#internship-application-form input[name="personal-statement"]').rules("add", {
		required: true,
		messages: "File upload required"
	});
	}

	

	$("#intern-recommendation-form").validate();

	$("#host-school-application-form").validate();

	$("#officer-nomination").validate();

});

$(document).ready(function() {
	if ($("#program-proposal-form").length) {
/*		//###   Set maximum amount of co-presenters available   ###
		totalOptions = $("#total-co-presenters option").length - 2;
		for (loopNum = 0; loopNum < totalOptions; loopNum++) {
			//###   Duplicate the first group of Co-presenter fields   ###
			$("#total-co-presenters").parent().next().after( $("#program-proposal-form .co-presenter-questions:first").clone() );
		}
		for (loopNum = 0; loopNum <= totalOptions; loopNum++) {
			//###   Rename the title to reflect the number of the co-presenter   ###
			$("#program-proposal-form .co-presenter-questions:eq("+loopNum+")").find("p:first strong").replaceWith("<strong>Co-Presenter "+(loopNum+1)+"</strong>");
		}*/

		//###   Now disable and hide all the co-presenter fields   ###
		$("#program-proposal-form").find(".co-presenter-questions").hide().find("input,textarea").attr("disabled","true");

		//###   Now add interaction to the presenters dropdown   ###
		$("#total-co-presenters").change(function () {
			//###   Disable and hide all the co-presenter fields   ###
			$("#program-proposal-form").find(".co-presenter-questions").hide().find("input,textarea").attr("disabled","true");
			//###   If a co-presenter has been selected show and activate the fields   ###
			if ($(this).val() >= 1)
				$("#program-proposal-form .co-presenter-questions:lt("+$(this).val()+")").show().find("input,textarea").removeAttr("disabled");
		});
	}



	if ( $("#executive-director-form").length ) {
		//###   Hide the contents of the form, except the initial question (What type of member)   ###
		$("#executive-director-form").children(":not(#member-type-question)").hide();
		//###   Disable all inputs   ###
		$("#executive-director-form input, #executive-director-form select:not(#member-type-question select)").attr("disabled","true");

		$("#member_type").change(function () {
			$("#executive-director-form input, #executive-director-form select").removeAttr("disabled");
			$("#executive-director-form").children().show();
			if ($("#member_type option:selected").val() == "Industry") {
				
				$("#executive-director-form .institution").hide();
				$("#executive-director-form .institution input, #executive-director-form .institution select").attr("disabled","true");
			} else if ($("#member_type option:selected").val() == "Institutional") {
				$("#executive-director-form .company").hide();
				$("#executive-director-form .company input, #executive-director-form .company select").attr("disabled","true");
			} else {
				//###   Hide the contents of the form, except the initial question (What type of member)   ###
				$("#executive-director-form").children(":not(#member-type-question)").hide();
				//###   Disable all inputs   ###
				$("#executive-director-form input, #executive-director-form select:not(#member-type-question select)").attr("disabled","true");
			}
		});
	}
});



$(document).ready(function() {
	if ($("#internship-application-form").length) {
		//###   Interaction - show or hide group   ###
		$("#internship-application-form #permanent-address-same").bind(($.browser.msie ? "click" : "change"), function () {
			if ( $(this).attr("checked") && $(this).val() == "Yes") {
				//###   Disable and hide the fields   ###
				$("form#internship-application-form #permanent-address-holder").find("input, select").attr("disabled","disabled");
				$("form#internship-application-form #permanent-address-holder").slideUp("slow");
			} else {
				//###   Enable the fields and show them   ###
				$("form#internship-application-form #permanent-address-holder").find("input, select").removeAttr("disabled");
				$("form#internship-application-form #permanent-address-holder").slideDown("slow");
			}
		});
		//###   Initially hide on page load (do not hide via CSS as not accessible)   ###
		$("form#internship-application-form #permanent-address-holder").find("input, select").attr("disabled","disabled");
		$("form#internship-application-form #permanent-address-holder").slideUp("slow");
	}
});

