$(function() {
	$("#find").click(function(){
		if ( $("#s").val() == '') 
			$("#phone, #phone2").toggle();
		else
			$('#searchform').submit();

	});
	$("#s").keypress(function() {
	  $("#please").fadeIn(500);
	});

  		$("#free_audit label").parent().hide();  	
		  $('input#si_contact_email1').each(function(){
          if(this.value==''){this.value='E-mail для связи'}
        });
        $('input#si_contact_email1').focus(function(){
          if(this.value=='E-mail для связи'){this.value=''}
        });
        $('input#si_contact_email1').blur(function(){
          if(this.value==''){this.value='E-mail для связи'}
        });
        
        
		  $('input#si_contact_name1').each(function(){
          if(this.value==''){this.value='Ваше имя'}
        });
        $('input#si_contact_name1').focus(function(){
          if(this.value=='Ваше имя'){this.value=''}
        });
        $('input#si_contact_name1').blur(function(){
          if(this.value==''){this.value='Ваше имя'}
        });

		  $('input#si_contact_ex_field1_1').each(function(){
          if(this.value==''){this.value='Адрес Вашего сайта'}
        });
        $('input#si_contact_ex_field1_1').focus(function(){
          if(this.value=='Адрес Вашего сайта'){this.value='http://'}
        });
        $('input#si_contact_ex_field1_1').blur(function(){
          if(this.value=='http://'){this.value='Адрес Вашего сайта'}
        });




 
  $("#si_contact_form1").validate({

    focusInvalid: false,
    focusCleanup: true,
    rules: {
      si_contact_name: {
         required: true
      },
      si_contact_email: {
         required: true,
         email: true

      },
      si_contact_ex_field1: {
         required: true,
         url: true
      }
    },
    messages: {
      si_contact_name: {
        required: "Введите Ваше имя<br>"
      },
      si_contact_email: {
        required: "Введите Ваш email<br>",
        email: 'Введите корректный e-mail<br>'
      },
      si_contact_ex_field1: {
        required: "Укажите URL Вашего сайта<br>",
         url: 'Введите корректный URL<br>'
      }
    },
    errorPlacement: function(error, element) {
        error.appendTo("#output4" );
    }
  });  

  $("#si_contact_form2").validate({

    focusInvalid: false,
    focusCleanup: true,
    rules: {
      si_contact_name: {
         required: true
      },
      si_contact_ex_field1: {
         required: true
      },
      si_contact_ex_field2: {
         required: true
      }
    },
    messages: {
      si_contact_name: {
        required: "Введите Ваше имя<br>"
      },
      si_contact_ex_field1: {
        required: "Укажите Ваш номер телефона<br>"
      },
      si_contact_ex_field2: {
        required: "Выберите удобное Вам время для звонка<br>"
      }
    },
    errorPlacement: function(error, element) {
        error.appendTo("#output5" );
    }
  });  

  
  $("#output4").appendTo("#si_contact_form1 div:eq(6)");
  $("#output5").appendTo("#si_contact_form2 div:eq(6)");
  $("#form_call").colorbox({inline: true, href:"#form_call_show", transition:"none", width:"300px", height:"400px"});
  

});

