$(document).ready(function() {

 /*  FANCYBOXOTZIV */
$("a.fancy-otzivi-call").fancybox({'padding':0})

/* CONTACT FORM */
  $(".testform").submit(function(){
    ok = 1
    $(".req", this).each(function(){
      if(!ok) return false
      if(!$(this).val()){
        alert('Вы заполнили не все поля')
        $(this).focus()
        ok = 0
      } else {
        //
      }
    })
    if(!ok) return false
  })

/*  GALLERY*/
  $("a.tofancygal").fancybox({
    'cyclic': true,
    'titleShow':false,
    'transitionIn':'elastic',
    'transitionOut':'elastic',
    'padding':20
  })
  $(".galThumb").fadeTo(0, 0.6 );
  $(".galThumb").mouseover(function() {
    $(this).stop(true,false).fadeTo('fast',1 );
  });
  $(".galThumb").mouseout(function() {
    $(this).fadeTo('fast',0.6 );
  });

/* PLACEHOLDER */
  if (!$.browser.webkit) {
    $('INPUT[placeholder], TEXTAREA[placeholder]').blur(function(){ 
      if ($(this).val()=='') {
        $(this).val($(this).attr('placeholder'));
        $(this).addClass('m-placeholder');
      }
    }).focus(function(){
      $(this).removeClass('m-placeholder');
      if ($(this).val()==$(this).attr('placeholder'))
        $(this).val('');
    }).each(function(){
      if ( ($(this).val()=='') || ($(this).val()==$(this).attr('placeholder')) ) {
        $(this).val( $(this).attr('placeholder') );
        $(this).addClass('m-placeholder');
      }
      var form = $(this).closest('FORM');
      if (form.length)
        form.submit(function(){
          if ($(this).val()==$(this).attr('placeholder'))
            $(this).val('');
        });
    });
  }
});
