// JavaScript Document

$().ready(function() {

            // validate the comment form when it is submitted

            $("#commentForm").validate();

            

            

            // propose username by combining first- and lastname

            $("#username").focus(function() {

               var firstname = $("#firstname").val();

               var lastname = $("#lastname").val();

               if(firstname && lastname && !this.value) {

                  this.value = firstname + "." + lastname;

               }

            });

            //code to hide topic selection, disable for demo

            var newsletter = $("#newsletter");

            // newsletter topics are optional, hide at first

            var inital = newsletter.is(":checked");

            var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");

            var topicInputs = topics.find("input").attr("disabled", !inital);

            // show when newsletter is checked

            newsletter.click(function() {

               topics[this.checked ? "removeClass" : "addClass"]("gray");

               topicInputs.attr("disabled", !this.checked);

            });

         });



// 入力中のフォームの色を変更する

function msOver(i) {

  // 入力中のフォームの色

  commentForm.elements[i].style.backgroundColor = '#FAE5CB';

}

function msOut(i) {

  // 通常のフォームの色

  commentForm.elements[i].style.backgroundColor = '#FFF';

}

//-->
