$(document).ready(function(){
	
	$(".rounded").corners("4px");
	var visible = false;
	
	$("#event_search").submit(function() {
		
		var state = $("#state").attr("value");
		var zip = $("#zip").attr("value");
		
		if (visible == false) {
			$("#loader img").fadeIn("fast");
			$("#search_results").load("events.php", {
				"zip": zip,
				"state": state
			}, function () {
				$(".rounded").corners("8px");
				$("#results_title").hide();
				$(".hiddendesc").hide();
				$(".lesslink").hide();
				$(".morelink").click(function () {
					$(this).hide();
					$(this).parent().find(".hiddendesc").show("blind", {}, "slow", function() {
						$(this).parent().find(".lesslink").show();
					});
					return false;
				});
				$(".lesslink").click(function () {
					$(this).hide();
					$(this).parent().find(".hiddendesc").hide("blind", {}, "slow", function() {						
						$(this).parent().find(".morelink").show();
					});
					return false;
				});
				$("#events_container").show("scale", {width: 238, height: 300}, 300, function() {
					$("#results_title").show("bounce", {}, "normal");
				});
				$("#loader img").fadeOut("slow");
			});
			visible = true;
		} else {
			$("#loader img").fadeIn("fast");
			$("#events_container").hide("scale", {percent: 0}, 300, function(){
			$("#search_results").load("events.php", {
				"zip": zip,
				"state": state
			}, function () {
				$(".rounded").corners("8px");
				$(".hiddendesc").hide();
				$(".lesslink").hide();
				$(".morelink").click(function () {
					$(this).hide();
					$(this).parent().find(".hiddendesc").show("blind", {}, "slow", function() {
						$(this).parent().find(".lesslink").show();
					});
					return false;
				});
				$(".lesslink").click(function () {
					$(this).hide();
					$(this).parent().find(".hiddendesc").hide("blind", {}, "slow", function() {						
						$(this).parent().find(".morelink").show();
					});
					return false;
				});
				$("#events_container").show("scale", {width: 238, height: 300}, 300);
				$("#loader img").fadeOut("slow");
			});
			
		});
		}
		
	return false;
	});
});