	///////////////////////////////// New Jquery Initiation and events ///////////////////////////////////////
	
/* 
Appended 10.4.2010
By Jay Pilgreen
copyright River City Studio
*/

var SPLURGE = {};

SPLURGE.init = function() {
	
	$("input[name=radioFilter]").click(function() {
		var parentForm = $(this).parents("form");
		
		$.ajax({
			type: "GET",
			url: parentForm.attr("action"),
			data: parentForm.serialize(),
			beforeSend: function() {
				$("#main").animate({
					"height": 0,
					"opacity": 0
				}, 450);
			},
			success: function(result) {
				$("#main").html($(result).find("#main").html());
				$("#main")
					.stop()
					.animate({
						"height": 540,
						"opacity": 1
					}, 450);
			}
		});
		
		return false;
	});
	
	$("#searchForm").submit(function() {
		$.ajax({
			type: "GET",
			url: $(this).attr("action"),
			data: $(this).serialize(),
			beforeSend: function() {
				$("#main").animate({
					"height": 0,
					"opacity": 0
				}, 450);
			},
			success: function(result) {
				$("#main").html($(result).find("#main").html());
				$("#main")
					.stop()
					.animate({
						"height": 540,
						"opacity": 1
					}, 450);
			}
		});
		
		return false;
	});
};



var ENROLL = {};

ENROLL.init = function() {
	
	$("#usernameInput").keyup(function() {
		$("#userValidBox").load("/admin/customers/validators/dupUserName.php?username=" + $(this).val());
	});
	
	$("input[name=password2]").keyup(function() {
		if($(this).val() == $("#passwordVal").val()) {
			$("#passwordMatchValidBox").html("<strong style='color: green;'>Match</strong>");
		} else {
			$("#passwordMatchValidBox").html("<strong style='color: red;'>No Match</strong>");
		}
	});
	
	$("input[name=email2]").keyup(function() {
		if($(this).val() == $("input[name=email]").val()) {
			$("#emailMatchValidBox").html("<strong style='color: green;'>Match</strong>");
		} else {
			$("#emailMatchValidBox").html("<strong style='color: red;'>No Match</strong>");
		}
	});
	
	$("form[name=addAccountForm]").submit(function() {
		return ENROLL.validateAccountCreationForm($(this));
	});
};


	// Validator

ENROLL.validateAccountCreationForm = function(e) {
	var alertText = "";
	
// 	alert(document.getElementById("userValidBox").innerHTML.indexOf("Available"));
	
	if(document.getElementById("userValidBox").innerHTML.indexOf("Not") > -1) {
		alertText += "Your chosen user name is already taken\r\n";
	}
	
	if(alertText != "") {
		alert(alertText);
		return false;
	}
	
	// General Catch Alls
	if(e.username.value == "" || e.emailAddress == "" || e.password == "") {
		alert("Please choose a user name, a password, and submit your email address");
		return false;
	}
	
	return true;
}
