//<!---------------------------------+
//  Developed by Roshan Bhattarai
//  Visit http://roshanbh.com.np for this script and more.
//  This notice MUST stay intact for legal use
// --------------------------------->
$(document).ready(function()
{
	$("#domain_name").blur(function()
	{
		document.myForm.submitButton.disabled = true;	// Disable the submit button unless approved.
		//remove all the class add the messagebox classes and start fading
		$("#domainmsgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
		//check the domain exists or not from ajax
		$.post("/includes/check_domain_availability.php",{ domain_name:$(this).val() } ,function(data)
        {
		  if(data=='no') //if domain not avaiable
		  {
		  	$("#domainmsgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{
			  //add message and change the class of the box and start fading
			  $(this).html('This Domain Name is already in use').addClass('messageboxerror').fadeTo(900,1);
			});
          }
		  else if(data=='yes')
		  {
		  	$("#domainmsgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{
			  //add message and change the class of the box and start fading
			  $(this).html('domain name available to register').addClass('messageboxok').fadeTo(900,1);
			  document.myForm.submitButton.disabled = false;
			});
		  }else
		  {
		  	$("#domainmsgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{
			  //add message and change the class of the box and start fading
			  $(this).html('Must enter a domain name').addClass('messageboxerror').fadeTo(900,1);
			});
		  }

        });

	});
});
