$(document).ready(
	function(){	
	//if submit button is clicked  
    $('.submit').click(function () {          
          
        //Get the data from all the fields  
        var name = $('input[name=name]');  
        var email = $('input[name=email]');  
        var interest = $('select[name=interest]');
		var newsletter = $('input[name=newsletter]:checked');
		var valid_email = true;
		//var docroot = $('input[name=docroot]');
		//var docrootData = docroot.val();
		email_value = email.val();
		//Check email is in a valid format
		apos = email_value.indexOf("@");
		dotpos = email_value.lastIndexOf(".");
		
		if(apos<1||dotpos-apos<2) {
		  valid_email = false;
		}
  
        //Simple validation to make sure user entered something  
        //If error found, add hightlight class to the text field
		if(name.val()=='' || email.val()=='' || valid_email==false) {
			if (name.val()=='') { name.addClass('highlight'); } else name.removeClass('highlight');  
			if (email.val()=='' || valid_email==false) { email.addClass('highlight'); } else email.removeClass('highlight');
			return false; 
		}
          
        //organize the data properly  
        var data = 'name=' + name.val() + '&email=' + email.val() + '&interest=' + interest.val() + '&newsletter=' + newsletter.val();
        //show the loading sign  
        $('.loading').show();  

	$.ajax({
		type: "GET",
		url: "http://www.logicom.com/wp-content/themes/whiteone/send.php",
		data: ""+data,
		cache: false,
		success: function(html) {
			$("#response").fadeIn("slow");
			$("#response").html(html);
			//setTimeout('$("#response").fadeOut("slow")',2000);

			if (html==1) {
				//fade out form and fade in sent
				$('.quick_form').fadeOut(500, function () {
				$('.sent').fadeIn(500);
				});
			} else {
				$('.loading').hide(); 
				alert('Sorry, unexpected error; please try again later.');
			}         

		}
	});
	return false;
    });   
});
