// JavaScript Document

/**
 * Clears the selected form elements.
 */
$.fn.clearFields = $.fn.clearInputs = function() {
	return this.each(function() {
		var t = this.type, tag = this.tagName.toLowerCase();
		if (t == 'text' || t == 'password' || tag == 'textarea')
			this.value = '';
		else if (t == 'checkbox' || t == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};

// Set the carousel
$(document).ready(function(){ $("form")[0].reset(); });
$("#regStep2").hide();
$("#registerForm input").addClass("radio");
$("#regSubmit").attr({disabled: "disabled"});

// figure out what is happening in step 1
$("#regStep1 label").click(function() {
	$("#regStep2 input").clearFields();
	$("#regStep2 label").removeClass("selected");
	$("#regStep1 label").removeClass("selected");
	$(this).addClass("selected");
	// if "yes" is selected
	if ($("#accessY").hasClass("selected")) {
		$("#regSubmit").attr({disabled: ""});
		$("#regStep2").hide();
	}
	// if "no" is selected
	if ($("#accessN").hasClass("selected")) {
		$("#regStep2").show();
		$("#regSubmit").attr({disabled: "disabled"});
	};
});

