// JavaScript Document

//Activate Immediately
$(document).ready(function(){
	$("#request_form").show();	
});

$(function() {
		   
	$("#submit").click(function() {
									
		// validate and process form here
		var error = 'The following fields are required:\n\n';
		var invalid = 0;
		
		var name = $("input#name").val();
		if (name == "" || name == "Name") {
		error += '- Name\n';
		invalid = 1;
		}
		var email = $("input#email").val();
		if (email == "" || email == "Email Address") {
		error += '- Email Address\n';
		invalid = 1;
		}
		var phone = $("input#phone").val();
		if (phone == "" || phone == "Phone Number") {
		error += '- Phone Number\n';
		invalid = 1;
		}
		var company = $("input#company").val();
		if (company == "" || company == "Company Name") {
		var company = "";
		}
		var website = $("input#website").val();
		if (website == "" || website == "Current Website") {
		var website = "";
		}
		var industry = $("input#industry").val();
		if (industry == "" || industry == "Industry") {
		var industry = "";
		}
		var services = "";
		if ($("input#services_web").attr('checked')){services = "Web Design";}
		if ($("input#services_print").attr('checked')){services += ", Print Design";}
		if ($("input#services_logo").attr('checked')){services += ", Logo Design";}
		if ($("input#services_photo").attr('checked')){services += ", Photography";}
		if ($("input#services_seo").attr('checked')){services += ", SEO";}
		if (services == "") {
		error += '- Services Required\n';
		invalid = 1;
		}
		var budget = "";
		if ($("input#budget1").attr('checked')){budget = "Less than $1,000";}
		if ($("input#budget2").attr('checked')){budget = "$1,000-$3,000";}
		if ($("input#budget3").attr('checked')){budget += "$3,000-$5,000";}
		if ($("input#budget4").attr('checked')){budget += "$5,000-$10,000";}
		if ($("input#budget5").attr('checked')){budget += "More than $10,000";}
		if (budget == "") {
		error += '- Projected Budget\n';
		invalid = 1;
		}
		var message = $("textarea#message").val();
		if (message == "" || message == "Describe Your Project (Give as much detail as possible):") {
		error += '- Project Description\n';
		invalid = 1;
		}
	
		if(invalid == 1){
		alert (error);
		return false;
		}
		
		$("#request_form").fadeOut("fast");
		$("#request_human").fadeIn("fast");
		window.dataString = 'Name='+ name + '&Email=' + email + '&Phone=' + phone + '&Company=' + company + '&Website=' + website + '&Industry=' + industry + '&Services=' + services + '&Budget=' + budget + '&Message=' + message;
		return false;
  
	});
	
	$("#submit2").click(function() {
		
		var error = 'Please answer the question to submit your email.';
		var invalid = 0;
		
		var human = $("input#human").val();
		if (human != "blue" && human != "BLUE" && human != "Blue") {
		invalid = 1;
		}
		
		if(invalid == 1){
		alert (error);
		return false;
		}
		
		$("#request_loader").fadeIn('fast');
		
		//AJAX for Form Submission
		$.ajax({
		type: "POST",
		url: "php/process2.php",
		data: window.dataString,
		success: function() {
		$("#request_human").hide("fast");
		$("#request_loader").hide("fast");
		$("#request_thanks").fadeIn("fast");
		}
		});
		return false;
	});
	
});
 



	