$(document).ready(function() {
	function mycarousel_initCallback(carousel)
	{
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
	 
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});
	 
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};
	 
	jQuery('#slider').jcarousel({
		scroll: 1,
		auto: 5,			
		wrap: 'circular',
		initCallback: mycarousel_initCallback
	});


	var use_ajax=true;
	$.validationEngine.settings={};
	/* initialize the settings object for the formValidation plugin */

	$("#contact-form").validationEngine({	/* create the form validation */
		inlineValidation: false,
		promptPosition: "centerRight",
		success :  function(){use_ajax=true},	/* if everything is OK enable AJAX */
		failure : function(){use_ajax=false}	/* in case of validation failure disable AJAX */
	 })

	var dataString = '';
		dataString += 'address='+$("#hidden-address").val()
		dataString += '&subject='+$("#hidden-subject").val();
		dataString += '&message='+$("#fio").val()+'';
		dataString += ''+$("#email").val()+'';
		dataString += ''+$("#phone").val()+'';
	$("#contact-form").submit(function(e){
		$.ajax({
			type: "POST",
			url: window.location+"/submit.php",
			data: dataString,
			success: function() {
				alert('done');
			}
		});
		e.preventDefault();	/* stop the default form submit */
	})

	
});	
