// JavaScript Document

$(document).ready(function () {
							
	$("#loading").hide();
	
	$("#loading").ajaxStart(function (){	// fires the loader when ajax call is started					  
		$(this).fadeIn(1000);
	});
	$("#loading").ajaxStop(function (){		// ends the loader when ajax call is started		  
		$(this).slideUp(1000);
	});
	
					
	$("#imageField").click(function (e) {
				
			//$("#loading").fadeIn(1000);
			e.preventDefault();
			
			if($("#domainSearch").val() == 'Search for domain name...') {
				
				$("#dresult").text("No domain name provided!").css("color", "red"); 
				
			} else if($("#domainSearch").val().indexOf(".") == -1) {
				
				$("#dresult").text("Invalid domain! No extention specified.").css("color", "red"); 
				$("#domainSearch").focus();
				
			} else {
				
				$("#dresult").text("");
			
				$.ajax({
					   
					  type: "POST",
					  url: "whois.php",
					  data: {domainSearch: $("#domainSearch").val()},
					  success: function (a) {
						  //alert(a);
						  
						  if(a == 'Available!') {
							  $("#dresult").text($("#domainSearch").val() + " is available!").css("color", "green");
							  
						  } else {
							  $("#dresult").text($("#domainSearch").val() + " is not available!").css("color", "red");
						  }
						  $("#domainSearch").val('');
					  },
					  error: function () {
						  //alert("Error in sending");
					  }
					   
					   
					   
				});
			}

	});
	
	
	

});