var text_flag = false;

function reset(){
  cur=0;
  $('.full-group').css('left',-695).hide();
}


function sendForm( form, container_id )
{
  $.post(
    $(form).attr( 'action' ),
    $(form).serialize(),
    function ( html ){
      $('#' + container_id).html( html );
      if(text_flag) $('#service_order_comment').show();
      $('#service_order_service_id').val($('#service_order_form_contaner').attr('rel'));
      //$.scrollTo($('#form2').offset().top);
    }
  );
}

function checkEnableForm(){
  
}

function showFormByRenew(){
  $('.success_message').hide();
  $('#form2 > fieldset').show();
 
  s_y=getClientHeight();
  y=parseInt(s_y/2) - parseInt($('#box-layer').height()/2) + parseInt(getBodyScrollTop());
  
  if ($('#box-layer').height() > getClientHeight() )
    y = getBodyScrollTop() +20 + $('#support .layer').height();
    
  $('#box-layer').css('top',y+'px').show();
}

function toggle_text(){
  if (text_flag == true){
    $('#service_order_comment').slideUp();
    text_flag = false;
  } else {
    $('#service_order_comment').slideDown();
    text_flag = true;
  }
}

function initFormTariff(){
  
}

$(function(){
  //$('#service_order_phone').mask('(999)9999999');
  
  $('h5 > a').click(function(){
    $(this).parent().parent().parent().parent().children('map').click();
  })
  
  $('map').click(function(){
      var f_map = $(this);
      
      f_title = f_map.prev().children('div').children('h5').children('a').html();
      $('#service_title').html(f_title);
      
      var p = $('#service_destiption').next();
      if(p.attr('rel')=='desc') p.remove();
      
      $('#service_destiption').html($('#tariff_desc_'+f_map.attr('rel')).html()).after($('#tariff_other_desc_'+f_map.attr('rel')).html());
      
      $('#service_order_tariff').val(f_map.attr('rel'));
      
      showFormByRenew();
  })
})
