var service_shown = false;
var anitime = 500;

$(document).ready(function(){

$('.tab_1').click(function(){
  $('.tab').removeClass('active');
  $(this).addClass('active');
  $('.block_2').hide();
  $('.block_1').show();
return false;
});

$('.tab_2').click(function(){
  $('.tab').removeClass('active');
  $(this).addClass('active');
  $('.block_1').hide();
  $('.block_2').show();
return false;
});

$("#menu_top ul.sf-menu").supersubs({ 

        }).superfish({
//speed: 300,
//animation: {height:'show'},   // slide-down effect without fade-in 
        });  // call supersubs first, then superfish, so that subs are 
                         // not display:none when measuring. Call before initialising 
                         // containing tabs for same reason.

$('#lb a').lightBox();

$('#dialog').jqm({
  onShow: function(h) { 
h.o.fadeIn(anitime);//, function(){h.o.remove();});
    h.w.fadeIn(anitime);
  },
  onHide: function(h) { 
    h.o.fadeOut(anitime, function(){h.o.remove();}); // remove overlay
    h.w.fadeOut(anitime); // hide window
  }
}); 

  $('a.master').click(function(){
    slave = $(this).parent().next();
    if (slave.is(':visible')){
slave.slideUp(anitime);
//slave.hide(anitime);
      $(this).html('Подробно');
    }
    else{
      slave.slideDown(anitime);
      $(this).html('Скрыть');
    }
    return false;
  });
         
  $('#dialog').find('input[type="button"]').click(function(){
    if($('#dialog').find('input[name="phone"]').val() != ''){
      $('#dialog').find('input[name="page"]').val(document.location.href);
      $request = $('#dialog').find('form').serialize();
      $.ajax({
        type: "POST",
        beforeSend: function(){
        },
        complete: function(){
        },
        url: "/manager/templates/site/ajax/mailto.php",
        data: $request,
        success: function(msg){
          $('#dialog').find('.answer').show();
          $('#dialog').find('.order_form').hide();
          setTimeout(function(){
            $('#dialog').jqmHide();
          },2500);
        }
      });
    }
    else $('#dialog').find('span.phone_text').css('color','red');
  });

  $('a.show_order').click(function(){
      $('#dialog').jqmShow();
          $('div.ord_send').hide();
          $('div.ord').show();
          $('#dialog').find('.answer').hide();
          $('#dialog').find('.order_form').show();
      return false;
  });

  $('a.note_order').click(function(){
      $('#dialog').jqmShow();
          $('div.ord_send').hide();
          $('div.ord').show();
          $('#dialog').find('.answer').hide();
          $('#dialog').find('.order_form').show();
      return false;
  });

  $('div.ord').find('input[type="button"]').click(function(){
    if($('div.ord').find('input[name="phone"]').val() != ''){
      $('div.ord').find('input[name="page"]').val(document.location.href);
      $request = $('div.ord').find('form').serialize();
      $.ajax({
        type: "POST",
        beforeSend: function(){
        },
        complete: function(){
        },
        url: "/manager/templates/site/ajax/mailto.php",
        data: $request,
        success: function(msg){
          $('div.ord_send').show();
          $('div.ord').hide();
        }
      });
    }
    else $('div.ord').find('span.phone_text').css('color','red');
  });

});

