$(document).ready(function(){
		$('.menu-nav li').hover(
			function() {
				$(this).addClass("active");
				$(this).find('.ulwrapper').stop(false, true).slideDown();
				$(this).find('.ulwrapper .ulwrapper').stop(false, true).slideUp('fast');
			},
			function() {
				$(this).removeClass("active");        
				$(this).find('div').stop(false, true).slideUp('fast');
			}
		);
		$('.ulwrapper').hover(
			function() {
				$('.parent').addClass("active_tab");
			},
			function() {
				$('.parent').removeClass("active_tab");        
			}
		);
		

		function formReset() {
		$(".success").animate({
				opacity:0
			},500, function(){
				$(this)
					.hide()
					.parent()
					.find("fieldset")
					.animate({
						opacity:1
					},500)
					.find(":input")
					.removeAttr("disabled")
					.parent()
					.find(":input:not(button)")
					.val("");
			})
	}
		// Forms validation script
		$(".form_submit").click(function(){
		form = $(this).parent().parent();
		if (form.find(":input:not(button)[value=]").length > 0 ) {
			missingText = form.find(":input[value=]:first").parent().find("label").text();
			missingText = missingText.substr(0, (missingText.length-1));
			form.find(".form_alert")
				.css("opacity","0")
				.show()
				.html("Введите <strong>" + missingText + "</strong>")
				.animate({
					opacity:1
				},200);
			return false;
		}
		dataString = form.serialize();
		dataString = dataString+"&contact-submit=dfsd";
	
		$.ajax ({
			type:"POST",
			url:"",
			data: dataString,
			success: function() {
				form.find("fieldset").animate({
					opacity:0.2
				},500,function(){
					$(this).find(":input").attr("disabled","disabled");
					$(this).find(".form_alert").replaceWith("");
					if($(this).parent().find(".success").length == 0) {
						$(this).parent().prepend("<p class='success'><span>Спасибо!</span><br/>Ваше сообщение было отправленно!</p>");
					}
					$(this).parent()
							.find(".success")
							.hide()
							.css("opacity","0")
							.show()
							.animate({
								opacity:1
							}, 500, function(){
								var formTimeout = setTimeout(formReset,2000);
							});
				});
			}
		});
		
		return false;
	});
	
	$("form :input:not(button)").focus(function(){
		$(this).parent().parent().find(".form_alert").animate({
			opacity:0
		},200,function(){
			$(this).hide();
		});
	});
	});
