jQuery(function() {

	

	//if submit button is clicked

	$('#submit_ribbons').click(function () {		

		

		//Get the data from all the fields

		var name_ribbons = $('input[name=name_ribbons]');

		var email_ribbons = $('input[name=email_ribbons]');

		var phone_ribbons = $('input[name=phone_ribbons]');

		var model_ribbons = $('input[name=model_ribbons]');

		var make_ribbons = $('input[name=make_ribbons]');

		var coname_ribbons = $('input[name=coname_ribbons]');

		var comment_ribbons = $('textarea[name=comment_ribbons]');



		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (name_ribbons.val()=='') {

			name_ribbons.addClass('hightlight');

			return false;

		} else name_ribbons.removeClass('hightlight');

		

		if (email_ribbons.val()=='') {

			email_ribbons.addClass('hightlight');

			return false;

		} else email_ribbons.removeClass('hightlight');

		

		if (phone_ribbons.val()=='') {

			phone_ribbons.addClass('hightlight');

			return false;

		} else phone_ribbons.removeClass('hightlight');

		

		//organize the data properly

		var data = '&name_ribbons=' + name_ribbons.val() + '&coname_ribbons=' + coname_ribbons.val() + '&email_ribbons=' + email_ribbons.val() + '&phone_ribbons=' + phone_ribbons.val() + '&model_ribbons=' + model_ribbons.val() + '&make_ribbons=' + make_ribbons.val() +'&comment_ribbons='  + encodeURIComponent(comment_ribbons.val()) ;

		



		

		//show the loading sign

		$('.loading').show();

		

		//start the ajax

		$.ajax({

			//this is the php file that processes the data and send mail

			url: "../js/process_ribbons.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) {					

					//hide the form

					$('#ribbons').fadeOut('slow');		

						

									

					//show the success message

					$('.done_ribbons').fadeIn('slow');

					

				//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;

	});	

});	