jQuery(function() {

	

	//if submit button is clicked

	$('#submit_cables').click(function () {		

		

		//Get the data from all the fields

		var name_cables = $('input[name=name_cables]');

		var email_cables = $('input[name=email_cables]');

		var phone_cables = $('input[name=phone_cables]');

		var model_cables = $('input[name=model_cables]');

		var make_cables = $('input[name=make_cables]');

		var coname_cables = $('input[name=coname_cables]');

		var comment_cables = $('textarea[name=comment_cables]');



		//Simple validation to make sure user entered something

		//If error found, add hightlight class to the text field

		if (name_cables.val()=='') {

			name_cables.addClass('hightlight');

			return false;

		} else name_cables.removeClass('hightlight');

		

		if (email_cables.val()=='') {

			email_cables.addClass('hightlight');

			return false;

		} else email_cables.removeClass('hightlight');

		

		if (phone_cables.val()=='') {

			phone_cables.addClass('hightlight');

			return false;

		} else phone_cables.removeClass('hightlight');

		

		//organize the data properly

		var data = '&name_cables=' + name_cables.val() + '&coname_cables=' + coname_cables.val() +  '&email_cables=' + email_cables.val() + '&phone_cables=' + phone_cables.val() + '&model_cables=' + model_cables.val() + '&make_cables=' + make_cables.val() +'&comment_cables='  + encodeURIComponent(comment_cables.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_cables.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

					$('#cables').fadeOut('slow');		

						

									

					//show the success message

					$('.done_cables').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;

	});	

});	