
// When the DOM is ready...

	
$(function(){
	$("#submit_button").attr("disabled",true);
	$("[class^=validate]").attr("disabled",true);
	$(".modul").attr("disabled",true);
	$("radio[name='sposob']").attr("disabled",true);
	$("textarea[name='comment']").attr("disabled",true); 
	// Fade out steps 2 and 3 until ready 
	$("#step_2").css({ opacity: 0.3 });
	$("#step_3").css({ opacity: 0.3 });
	$(".my_select").hide();
	$(".modulsel").hide();
	$("#step_2").css({ opacity: 0.3 });
$("#dev1").click(function(){
	$("#step_2").css({ opacity: 0.3 });
        if ($("#dev1:checked").val() == 'u1') {
        $(".my_select").show();}
        $("#step_1").css({"background-image": ""});
      });
$("#dev2").click(function(){
	$("#step_2").css({ opacity: 0.3 });
        $("#step_1").css({"background-image": ""});
        if ($("#dev2:checked").val() == 'u2') {
        $(".my_select").hide();}
      });
     $("#nextto2").click(function(){
      if (($("#dev1:checked").val() == 'u1'|| $("#dev2:checked").val() == 'u2') && ($("#text_kol").val()!='')) {
			$("#step_1")
			.animate({
				paddingBottom: "120px"
			})
			.css({
				"background-image": "url(images/check.png)",
				"background-position": "bottom center",
				"background-repeat": "no-repeat"
			});
			$("#step_2").css({
				opacity: 1.0
			});
			$("#step_2 legend").css({
				opacity: 1.0 // For dumb Internet Explorer
			});
	    $(".modul").attr("disabled",false);
		$("textarea[name='comment']").attr("disabled",false); 
		$("radio[name='sposob']").attr("disabled",false);
		}
	});		
$("#arenda").click(function(){
        if ($("#arenda:checked").val() == 'arenda') {
        $(".modulsel").show();
		$(".modul_arenda").show();
		$(".modul_start").hide();}
      });
$("#start").click(function(){
        if ($("#start:checked").val() == 'start'){
		$(".modulsel").show();
		$(".modul_arenda").hide();
		$(".modul_start").show();}
      });
	


$("#nextto3").click(function(){
		var completemod = false;
		if (($("#start:checked").val() == 'start'|| $("#arenda:checked").val() == 'arenda') ) {
			completemod = true;
			};
		if (completemod) {
		$("#step_2")
			.animate({
				paddingBottom: "120px"
			})
			.css({
				"background-image": "url(images/check.png)",
				"background-position": "bottom center",
				"background-repeat": "no-repeat"
			});
			$("#step_3").css({
				opacity: 1.0
			});
			$("#step_3 legend").css({
				opacity: 1.0 // For dumb Internet Explorer
			});
			$("[class^=validate]").attr("disabled",false);
		};
	});
$("#nextto5").click(function(){
		if (($("#dev1:checked").val() == 'u1'|| $("#dev2:checked").val() == 'u2')) {
			$("#step_1")
			.animate({
				paddingBottom: "120px"
			})
			.css({
				"background-image": "url(images/check.png)",
				"background-position": "bottom center",
				"background-repeat": "no-repeat"
			});
			$("#step_3").css({
				opacity: 1.0
			});
			$("#step_3 legend").css({
				opacity: 1.0 // For dumb Internet Explorer
			});
	    $("[class^=validate]").attr("disabled",false);
		}
	});
	

   	$("#nextto4").click(function(){
		var data_complete = true;
		$("[class^=validate]").each(function(){
			if ($(this).val() == '')  {
				data_complete = false;
			}else{
			if (isValidtel($('#tel').val())) {
			}else{
			data_complete = false;};
			if (isValidEmail($('#email').val())) {
			}else{
			data_complete = false;};
			//if (isValidpole($('#contact').val())) {
			//}else{
			//data_complete = false;};
			//if (isValidpole($('#nameorg').val())) {
			//}else{
			//data_complete = false;}
			};
		});
	if(data_complete) $("form").submit();
	});
});

	function isValidEmail (email){
		return (/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i).test(email);
	}
	function isValidtel (tel){
		return (/^([0-9_\-_\+_(_)])*$/).test(tel);
	}
	//function isValidpole (pole){
	//	return (/^([а-яА-Я]+)$/).test(pole);
	//}
