$(document).ready(function() {
						   			   
$('a#select_all').click( function() {
$('input:checkbox').each( function() {
this.checked = !this.checked;
});
return false;
});
	


	
			var c_value = "";
	
	function get_check_value()
{ for (var i=0; i < document.sendContact.aj.length; i++)
   {
   if (document.sendContact.aj[i].checked)
      {
      c_value = c_value + document.sendContact.aj[i].value + "*";
      }
   }
}







	

	//if submit button is clicked
	$('#submit').click(function () {		
		
		//Get the data from all the fields
	
		var name = $('input[name=name]');
		var ab = $('input[name=ab]');
		var email = $('input[name=email]');
		var company = $('input[name=company]');
		var ac = $('input[name=ac]');
		var ad = $('input[name=ad]');
		var phone = $('input[name=phone]');

			var ae = $('select[name=ae]');
			var af = $('select[name=af]');
			
			var ag = $('textarea[name=ag]');
			

			var ah = $('select[name=ah]');
			var ai = $('select[name=ai]');
			
		 

			var aj = $('input[name=aj]');
			var human = $('input[name=human]');
			
	
	 			get_check_value();
 

			
		
		

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (phone.val()=='') {
			phone.addClass('hightlight');
			return false;
		} else phone.removeClass('hightlight');
		
		
 
		
		
		
		//organize the data properly
		var data = 
		'name=' + name.val()
		+ '&ab=' + ab.val() 
		+ '&email=' + email.val()
		+ '&company=' + company.val()
		+ '&ac=' + ac.val()
		+ '&ad=' + ad.val()
		+ '&phone=' + phone.val() 
		
		+ '&ae=' + ae.val()
		+ '&af=' + af.val()
		
		+ '&ag=' + encodeURIComponent(ag.val())
		
		+ '&ah=' + ah.val()
		+ '&ai=' + ai.val()
	
		+ '&aj=' + c_value;
		+ '&human=' + human.val();
		
		
		//disabled all the text fields
		$('.text').attr('disabled','true');

		//show the loading sign
		$('.loading-form').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "http://www.j9leadingsolutions.com/about-you-process.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			




			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {		
				
					
					setTimeout (function(){
					$('.loading-form').fadeOut(200); },2800);
				 
				 
					
					//hide the form
					$('.myform').fadeOut('fast');			
					
					
					setTimeout (function(){
					//show the success message
					$('.done').fadeIn(1000); },2800);
					
					
					
					//show the loading sign
					$('#start-now-submit-btn').hide('fast');
					
				 
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
});	





