$(document).ready(function() {
	$("#domain").keyup(function(e) {
		var code = (e.keyCode ? e.keyCode : e.which);
		if (code == 13) {
			$("#perform_search").click();
		}
	});
						   
	$("#perform_search").click(function() {
		$(this).attr("disabled", true);
		$("#results").html('<p class="loading_bar centred">Searching...</p>').hide().slideDown("slow", function() {
			var domain = $("#domain").val();
			
			if (domain != "") {
				$.get("/domains/search/results_template.ajax.php", {domain: domain}, function(response) {
					// Show the results template table
					$("#results").html(response);
				}, "html")
			} else {
				$("#results").html('<p class="error message">Please enter a domain name</p>');
			}
			
			$("#perform_search").attr("disabled", false);
		});
	});
	
	$("form input[type=checkbox]").live("click", function() {
		if ($("form input[type=checkbox]:checked").length > 0) {
			$("button#next_step").attr("disabled", false);
		} else {
			$("button#next_step").attr("disabled", true);
		}
	});
});