// JavaScript Document

	$(document).ready(function(){
	
		$("div#loader").hide();
		$("tr#sentFeedback").hide();

	
		// Hide the hosting and nameserver DIV
		$('div.hostingType').hide();
		$('div.nameservers').hide();
		$('div.bigHosting').hide();
		$('div.smallHosting').hide();
		
		$("input#submitx").click(function (){ // If the submit button is clicked...
		
			if($("input#fullName").val() == '') { 
			
				alert("The Full Name Field is blank!");
				$("input#fullName").focus();
			
			}	else if($("input#email").val() == '')	{
			
				alert("The Email Address Field is blank!");
				$("input#email").focus();
			
			} else if($("#email").val().indexOf("@") &&  $("#email").val().indexOf(".") == -1) {
			
				alert("The Email Address Field is invalid!");
				$("#email").focus();

			} else if($("input#telephone").val() == '') {
			
				alert("The Telephone Field is blank!");
				$("#telephone").focus();
			
			} else if($("#address").val() == '') {
			
				alert("The Contact Address Field is blank!");
				$("#address").focus();
				
			} else if($("#state").val() == 'Select your state') {
			
				alert("The State Field is blank!");
				$("#state").focus();
				
			} else if($("input#domainName").val() == '') {
			
				alert("The Domain Name Field is blank!");
				$("#domainName").focus();
			
			} else if($("#tld").val() == 'Select Extension') {
			
				alert("Select an extension for your domain name!");
				$("#tld").focus();
				
			} else if(document.getElementById('yes').checked == false && document.getElementById('no').checked == false) {
			
				alert("You must select whether or not you want to host with us!\nSelect \'Yes\' or \'No\' to proceed");
			
			} else {
			
			
				if(document.getElementById('no').checked == true){
					
				
					if($("#primaryNameserver").val() == ''){ // Check if the nameservers field are filled...
					
						alert("The Primary Nameserver field is blank!");
						$("#primaryNameserver").focus();
						
					
					} else if($("#secondaryNameserver").val() == '') {
					
						alert("The Secondary Nameserver field is blank!");
						$("#secondaryNameserver").focus();
						
					} else {
					
					$("div#loader").slideDown(2000);
						$("#form2").submit();

					
/*						$.ajax({ 
						
						   type: "POST", 
						   url: "domain-name-registration-script.php", // The Script it should post to...
						   data: {fullName: $("#fullName").val(), email: $("#email").val(), telephone: $("#telephone").val(), address: $("#address").val(), state: $("#state").val(), domainName: $("#domainName").val(), tld: $("#tld").val(), duration: $("#duration").val(), yes: $("#yes").val(), no: $("#no").val(), chooseHosting: $("#chooseHosting").val(), smallHostingSize: $("#smallHostingSize").val(), bigHostingSize: $("#bigHostingSize").val(), primaryNameserver: $("#primaryNameserver").val(), secondaryNameserver: $("#secondaryNameserver").val()},
						   success: function(){ 
							 
							  
							  $("#tableForm").slideUp(3000, function(){
							  
								  $("div#loader").hide();
								  $("tr#sentFeedback").fadeIn(1000);
								 
							 });
							 
						   },
						   error: function(){
						   
						   		//alert("Error");
						   }
						   
						 });
*/					
					}
				
				
				} else { // Check if he hosting fields are filled...
				
				
					if($("#chooseHosting").val() == 'Choose A Hosting Type'){ // Check if the nameservers field are filled...
					
						alert("Select Hosting Type to proceed!");
						$("#chooseHosting").focus();
						
					
					} else if($("#smallHostingSize").val() == 'Select Hosting Size' && $("#bigHostingSize").val() == 'Select Hosting Size'){
						
							alert("Select a Hosting Size to proceed!");
							
						} else {
						
						$("div#loader").slideDown(2000);

						$("#form2").submit();
/*						$.ajax({ 
						
						   type: "POST", 
						   url: "domain-name-registration-script.php", // The Script it should post to...
						   data: {fullName: $("#fullName").val(), email: $("#email").val(), telephone: $("#telephone").val(), address: $("#address").val(), state: $("#state").val(), domainName: $("#domainName").val(), tld: $("#tld").val(), duration: $("#duration").val(), yes: $("#yes").val(), no: $("#no").val(), chooseHosting: $("#chooseHosting").val(), smallHostingSize: $("#smallHostingSize").val(), bigHostingSize: $("#bigHostingSize").val(), primaryNameserver: $("#primaryNameserver").val(), secondaryNameserver: $("#secondaryNameserver").val()},
						   success: function(){ 
							 
							  $("#tableForm").slideUp(3000, function(){
							  
								  $("div#loader").hide();
								  $("tr#sentFeedback").fadeIn(1000);
								 
							 });
							 
						   },
						   error: function(){
						   
						   		alert("Error");
						   }
						   
						 });
*/							
						}
				
				}
			
			}
			

		});
	
	
	});
	
	
	$(document).ready(function (){
	
		$("select").change(function (){
		
			if($("select#chooseHosting").val() == 'Small Windows Hosting'){
				
				$("div#smallHosting").show();
				$("div#bigHosting").hide();
				$("div#bigHosting").val() = 'Select Hosting Size';
				
				
			
			} else if($("select#chooseHosting").val() == 'Big Windows Hosting') {
			
				$("div#bigHosting").show();
				$("div#smallHosting").hide();
				$("div#smallHosting").val() = 'Select Hosting Size';
				
				
			} else {
			
				$("div#bigHosting").hide();
				$("div#smallHosting").hide();
			}
		
		
		});
			
	});
	
	
	jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox();
    })

