$(document).ready(function() {

 $(".t_up").click(function() {
  var cidval = $(this).parent().attr('id');
  var now_count = $(this).val;
  var caval = 1;
  $.getJSON(
  "../../vote.cgi",
  {"cid":cidval,"ca":caval},
  function(data) {
   $("div#response_message_vote").html('<div id="response_message_body">' + data.response + '</div>');
  }
  );

  return false;

 });

 $(".t_down").click(function() {
  var cidval = $(this).parent().attr('id')
  var caval = -1;
  $.getJSON(
  "../../vote.cgi",
  {"cid":cidval,"ca":caval},
  function(data) {
   $("div#response_message_vote").html('<div id="response_message_body">' + data.response + '</div>');
  }
  );

  return false;

 });

 $("a.aw").click(function() {
  $(this).parent().parent().parent("div.open_link").next("div.action_window").slideToggle();
  $(this).hide();
  return false;
 });

 $("a.close").click(function() {
  $(this).parent("div.action_window").prev("div.open_link").children("div.reviewbt").children("p.btlink").children("a.aw").show();
  $(this).parent("div.action_window").slideUp();

  return false;
 });

 $("a.more").click(function() {
  $(this).parent("div.open_link").next("div.action_window").slideToggle();
  return false;
 });

 $("#wc").click(function() {
 var mdval = 'comment';
 var uidval = $("#uid").val();
 var yearval = $("#year").val();
 var relationval = $("#relation").val();
 var periodval = $("#period").val();
 var titleval = $("#comment_title").val();
 var bodyval = $("#comment_body").val();

 $("div#response_message_comment").html('<div id="response_message_body">' + '投稿しています...' + '</div>');

  $.getJSON(
  "../../write_comment.cgi",
  {"md":mdval,"uid":uidval,"year":yearval,"relation":relationval,"period":periodval,"title":titleval,"body":bodyval},
  function(data) {
   $("div#response_message_comment").html('<div id="response_message_body">' + data.response + '</div>');
  }
  );

 $("#year").val('');
 $("#relation").val('');
 $("#period").val('');
 $("#comment_title").val('');
 $("#comment_body").val('');

 return false;

 });

 $("#wi").click(function() {
 var mdval = 'industry';
 var uidval = $("#uid").val();
 var industryval = $("#industry").val();
 var typeval = $("#type").val();

 $("div#response_message_industry").html('<div id="response_message_body">' + '投稿しています...' + '</div>');
 
 $.getJSON(
  "../../write_comment.cgi",
  {"md":mdval,"uid":uidval,"industry":industryval,"type":typeval},
  function(data) {
   $("div#response_message_industry").html('<div id="response_message_body">' + data.response + '</div>');
  }
  );

 $("div.action_window").hide();
 $("#industry").val('');
 $("#type").val('');

 return false;

 });

 $("#wt").click(function() {
 var mdval = 'tag';
 var uidval = $("#uid").val();
 var tagval = $("input:checkbox:checked[@name^='tag']").map(function() {
  return this.value;
} ).get();

  $("div#response_message_tag").html('<div id="response_message_body">' + '投稿しています...' + '</div>');

  $.getJSON(
  "../../write_comment.cgi",
  {"md":mdval,"uid":uidval,"tag":tagval},
  function(data) {
   $("div#response_message_tag").html('<div id="response_message_body">' + data.response + '</div>');
  }
  );

 $("div.action_window").hide();
 $("#tag").val('');
 var tagval = $("input:checkbox:checked[@name^='tag']").map(function() {
  this.checked = false;
} ).get();

 return false;

 });

 $("a.close_t").click(function() {
  $(this).parent().parent().parent("div.action_window").prev("div.open_link").children("div.reviewbt").children("p.btlink").children("a.aw").show();
  $(this).parent("div.open_link").parent("form").parent("div.action_window").slideUp();

  return false;
 });


});
