// JavaScript Document
$(document).ready(function(){

	$("#categories_submenu li:odd").css("background-color", "#f0f0f0");
	$("#memberRegistrationFormTable tr:odd").css("background-color", "#f0f0f0");

	$(".signin").click(function(e) {          
		e.preventDefault();
		$("fieldset#signin_menu").toggle();
		$(".signin").toggleClass("menu-open");
	});

	$("fieldset#signin_menu").mouseup(function() {
		return false
	});

	$(document).mouseup(function(e) {
		if($(e.target).parent("a.signin").length==0) {
			$(".signin").removeClass("menu-open");
			$("fieldset#signin_menu").hide();
		}
	});			

	if($('#forgot_username_link').tipsy){
		$('#forgot_username_link').tipsy({gravity: 'w'});   
	}else{}

	
	if($("a.modalInput").overlay){
		var triggers = $("a.modalInput").overlay({ 
			// some expose tweaks suitable for modal dialogs 
			expose: { 
				color: '#333', 
				loadSpeed: 200, 
				opacity: 0.9 
			}, 
			closeOnClick: false 
		});
	} else {}
	
	$("#prompt1 form").submit(function(e) { 
		// get user input 
		var input = $("#txtLUser").val(); 

		// verify e-mail 
		jQuery.get("/ajax/forgotpass.php", { user: input }, function(data){
			if (data == "OK") {
				alert("Your new password has been generated and sent to the email associated with your account.");
				// close the overlay 
				for(x=0; x<25; x++) {
					triggers.eq(x).overlay().close(); 
				}
			} else {
				// display error
				alert(data);
			}
		});
	
		// do not submit the form 
		return e.preventDefault(); 
	});

	$("#prompt2 form").submit(function(e) { 
		// get user input 
		var input = $("#txtLEmail").val(); 

		// verify e-mail 
		jQuery.get("/ajax/forgotuser.php", { email: input }, function(data){
			if (data == "OK") {
				alert("Your username and new password has been generated and sent to the email associated with your account.");
				// close the overlay 
				for(x=0; x<25; x++) {
					triggers.eq(x).overlay().close(); 
				}
			} else {
				// display error
				alert(data);
			}
		});
	
		// do not submit the form 
		return e.preventDefault(); 
	});

});
