$(document).ready(
  function(){
    $("#new_message_btn").click(
      function(){
        $(this).hide();
        $('#new_message').show();
      }
    );
    $("#new_message_cancel").click(
      function(){
        $("#new_message").hide();
        $("#new_message_btn").show();
      }
    );
    $("#reservation_cancel_btn").click(
      function() {
        $('#mypage_contact').show();
        $('html,body').animate({scrollTop: $('#mypage_contact').offset().top},'slow','swing');
      }
    );
    $("#mypage_contact_cancel").live('click',
      function() {
        $('#mypage_contact').hide();
        $.get('/reservations/'+$('#reservation_id').val()+'/init_cancel_form');
      }
    );
    $("#main_contents form .question table tr td.radio").each(function(){
      $(this).click(function(){
        var chkb = $(this).find("input[type=radio]");
        if(!chkb.attr("checked")) {
        chkb.attr('checked', true);
        }
      });
    });
    $('#main_contents .descriptor_wrapper ul li.first .descriptor textarea').keydown(function(e){
      var counter = $(this).val().length;
      $("#counter").text(counter);
      if (counter == 0) {
        $("#counter").text("0");
      }
    });
    
    $('#main_contents .descriptor_wrapper ul li.first .descriptor textarea').keyup(function(e){
      var counter = $(this).val().length;
      $("#counter").text(counter);
      if (counter == 0) {
        $("#counter").text("0");
      }
    });
  }
);

function chekNum(obj) {
  
}
;

