function toggleInput() {
    var speed = 200;
    var cate = $('input[name=category]:checked').val();
    var junior = $('input[name=junior]:checked').val();
    if (parseInt(junior) == 1) {
      if (cate != 'still') {
        $('input[name=category]').val(['animation']);
      }
       for (i = 1;i < 5; i++) {
       s = 'input:[name=category]:eq(' + i + ')';
       $(s).attr('disabled', 'disabled');
       }
       $('input:[name=category]:eq(5)').removeAttr('disabled');
       $('#require_tools').hide(0);
       $('#other_tools').hide(0);
    } else {
       if (cate == 'still') {
         $('input[name=category]').val(['photoreal']);
       }
         $('input:[name=category]:eq(5)').attr('disabled', 'disabled');
         $('input:[name=category]:lt(5)').removeAttr('disabled');
         $('#require_tools').show(0);
         $('#other_tools').show(0);
    }
    cate = $('input[name=category]:checked').val();
    if(cate == 'animation' || cate == 'pv') { 
        $('#digesturl').show(speed);
        $('#subcategory').hide(speed);
        $('#thumbnail').show(speed);
        $('#imgfile').hide(0);
        $('#workurl').show(speed);
    } else if(cate == 'design') {
        //$('#subcategory').show(speed);
        $('#digesturl').hide(speed);
        $('#thumbnail').show(speed);
        $('#imgfile').hide(0);
        $('#workurl').show(speed);
    /*
    } else if(cate == 'interactive') {
        $('#subcategory').hide(speed);
        $('#digesturl').hide(speed);
        $('#thumbnail').show(speed);
        $('#still_caution').hide(0);
    */
    } else {
        $('#subcategory').hide(speed);
        $('#digesturl').hide(speed);
        $('#thumbnail').hide(speed);
        $('#imgfile').show(speed);
        $('#workurl').hide(0);
        //$('#still_caution').show(0);
    }
}

$(function() {
    toggleInput();
    $('input.category').click(function(){toggleInput();});
    $('input.junior').click(function(){toggleInput();});
});

// for vote
$(document).ready(function() {
    $("#vote").sexyVote({fn: function(e, score) {
        var $this = $(this);
        var data_id = $('input[name=work_data_id]').val();
        var ottkn = $('input[name=ottkn]').val();
        $.ajax({
        type: "GET",
//        url: "http://172.20.20.18/award/",
        url:location.protocol + "//" + location.hostname + location.pathname,
        data: "action_vote_do=true&data_id="+data_id+"&score="+score+"&ottkn="+ottkn,
        success: function(msg){
          var fullmsg = "";
          if (msg == "Success") {
            fullmsg = "投票を受け付けました：" + score + "点";// +":"+ msg;
          } else {
            if (msg == "End") {
              fullmsg = "一般審査終了のため、";
            }
            fullmsg += "投票は受け付けられませんでした。";
          }
          //alert(fullmsg);
          $('#vote_message').text(fullmsg);
        }
      });
    }});
});

