/* -----------------------------------------------------------------------------

ReadingSlideController

----------------------------------------------------------------------------- */

ReadingSlideController = Class.extend(
  SlideController,
  {

    //プロパティ----------------------------------------------------------------
    context     : {},     //initialize時必須
    type        : "",     //initialize時必須
    slidenumber : "",     //initialize時必須
    slideid     : "",     //initialize時必須
    template    : "",     //initialize時必須

    mode        : "challenge",  //challenge|review

    moreAvailable : true,

    //※以下はタイプがquestion以外のSlideでは無効なプロパティ
    q_no        : "",     //initialize時必須
    partQuestionCount: 0,    //同一パート内での出題番号
    //question_id : "",   //question_id
    answer      : "",
    useranswer  : "",
    data        : {},
    solution: false,

    currentGlossaryNo:0,

    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {
      this.parent( slideId );
      this.slideContent = $("div", $("#" + slideId));
    },

    commonInitialize: function(slideId,param) {
      this.parent( slideId );
      this.slideContent = $("div", $("#" + slideId));

      this.type       = param.type;
      this.slidenumber= param.slide_number;
      this.slideid    = slideId;
      this.data       = param.data;
      this.template   = param.template;

    },

    setContext: function( context ){
      //Slideを統べる親クラス（Context）をセット
      //※SlideからContextにはcontext.notifyメソッド経由で通知すること

      this.context = context;

    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      alert("この機能は未実装です：play");

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      alert("この機能は未実装です：stop");

    },

    toggleGuess: function(){

      alert("この機能は未実装です：toggleGuess");

    },

    toggleSolution: function(){

      alert("この機能は未実装です：toggleSolution");

    },
    
    commit: function(){

      alert("この機能は未実装です：commit");

    },

    dispQuestion: function(){

      alert("この機能は未実装です：dispQuestion");
      //this.context.notify('thinking');

    },

    //Timerボタンの操作-----------------------------------------------------------
    showTimer: function(){
      //Timerそのもののshow
      this.context.components["timer"].show();
    },
    hideTimer: function(){
      //Timerそのもののhide
      this.context.components["timer"].hide();
    },
    showTimerCounter: function(){
      //TimerCounterのshow
      $("#timer_diplay").show();
    },
    hideTimerCounter: function(){
      //TimerCounterのhide
      $("#timer_diplay").hide();
    },

    //Questionの操作-----------------------------------------------------------
    setTrueAnswer: function(){
      //各typeのクラスメソッドを参照してください

      alert("この機能は未実装です：setTrueAnswer");

    },

    setUserAnswer: function(){
      //各typeのクラスメソッドを参照してください

      alert("この機能は未実装です：setUserAnswer");

    },

    updateUserAnswewr: function(){
      //各typeのクラスメソッドを参照してください

      alert("この機能は未実装です：updateUserAnswewr");

    },

    toggleSolution: function(){
      //各typeのクラスメソッドを参照してください
      alert("この機能は未実装です：toggleSolution");
    },

    toggleSolution_type_draggable_q: function(){
      
      if ( $("#"+this.slideid+" .user_answer_area").css("display") != "none" ){
        $("#"+this.slideid+" .user_answer_area").hide();
        $("#"+this.slideid+" .true_answer_area").show();
        this.solution = 1;
      }
      else{
        $("#"+this.slideid+" .true_answer_area").hide();
        $("#"+this.slideid+" .user_answer_area").show();
        this.solution = 0;
      }

    },

    setResult: function(){
      //同期通信でカレントスライドの成績・進捗を更新する。PAUSE、FINISHなど確実にResultをpushしたいときはこっち
      if( this.solution == 1 ){
        r.show_solution(1);
      }
      if( this.useranswer != "" && this.useranswer != undefined ){
        var temp = String(this.useranswer);
        r.user_answer(temp);
      }
      return r.push();
    },

    setCurrentResult: function(){
      //非同期通信でカレントスライドの成績・進捗を更新する。スライドのstopなど、ページ遷移を伴わない場合のみ使用可能
      if( this.solution == 1 ){
        r.show_solution(1);
      }
      if( this.useranswer != "" ){
        var temp = String(this.useranswer);
        r.user_answer(temp);
      }
      r.push_current();
    },

    setCurrentSeen: function(){
      //非同期通信でカレントスライドのseenを送信するのに使用する
      //Resultをseenに
      if( r.result.minors[r._current_minor].seen != 1 ){
        r.seen();
        r.push_current();
      }
    },
    
    setPartDone: function(){
      //r.push();
    },

    setFinish: function(){
      r.done();
    },

    //AllTextの操作------------------------------------------------------------

    //全文テキスト(英)のスクロール状態を調べる
    checkScroll: function(){
      var tempSlideName    = "#"+this.slideid;

      //alert("scrollTop = "+$(tempSlideName+' .alltext').scrollTop()+"\n"+"innerHeight = "+$(tempSlideName+' .alltext').innerHeight()+"\n"+"outerHeight = "+$(tempSlideName+' .alltext').outerHeight()+"\n"+"height = "+$(tempSlideName+' .alltext').height()+"\n"+"scrollHeight = "+$(tempSlideName+' .alltext').get()[0].scrollHeight);

      if( $(tempSlideName+' .alltext').get()[0].scrollHeight - $(tempSlideName+' .alltext').scrollTop() > $(tempSlideName+' .alltext').innerHeight() + 10 ){
        if( $(tempSlideName+' .alltext').scrollTop() == 0 ){
          $(tempSlideName+' .ScrollStatusBar').text("Beginning");
        }
        else{
          $(tempSlideName+' .ScrollStatusBar').text("More Available");
        }
      }
      else{
        $(tempSlideName+' .ScrollStatusBar').text("End");
        this.moreAvailable = false;
        
        if( !this.moreAvailable ){
          //全文最後まで読んだらヘッダーのNEXTボタンをActiveにする
          c.notify('readed');
        }
      }
    },

    //段落移動
    gotoParagraph: function(){

      var tempSlideName    = "#"+this.slideid;
      var tempSlideController = this;

      var newScrollTop;
      var tempTarget = $(tempSlideName+' .alltext'+' a[name$="p_'+this.q_no+'"]');
      if( tempTarget.attr("offsetTop") ){
        newScrollTop = tempTarget.attr("offsetTop");
      }
      else{
        //段落か網掛けのうち、上にあるほうがscrollTop位置
        var tempScrollTop1 = $(tempSlideName+' .alltext #highlight_'+this.q_no).attr("offsetTop");
        var tempScrollTop2 = $(tempSlideName+' .alltext #arrow_'+this.q_no).attr("offsetTop");
        var tempScrollTop3 = $(tempSlideName+' .alltext .arrow_'+this.q_no).attr("offsetTop");


        if($(tempSlideName+' .alltext #highlight_'+this.q_no).get(0)){
          var tempScrollTop1 = $(tempSlideName+' .alltext #highlight_'+this.q_no).get()[0].offsetTop;
        }
        if($(tempSlideName+' .alltext #arrow_'+this.q_no).get(0)){
          var tempScrollTop2 = $(tempSlideName+' .alltext #arrow_'+this.q_no).get()[0].offsetTop;
        }
        if($(tempSlideName+' .alltext .arrow_'+this.q_no).get(0)){
          var tempScrollTop3 = $(tempSlideName+' .alltext .arrow_'+this.q_no).get()[0].offsetTop;
        }

        if( tempScrollTop1 == undefined ) tempScrollTop1 = 99999;
        if( tempScrollTop2 == undefined ) tempScrollTop2 = 99999;
        if( tempScrollTop3 == undefined ) tempScrollTop3 = 99999;
        
        newScrollTop = tempScrollTop1;
        if( tempScrollTop1 < tempScrollTop2 && tempScrollTop1 < tempScrollTop3 ){
          newScrollTop = tempScrollTop1;
        }
        else if( tempScrollTop2 < tempScrollTop1 && tempScrollTop2 < tempScrollTop3 ){
          newScrollTop = tempScrollTop2;
        }
        else if( tempScrollTop3 < tempScrollTop1 && tempScrollTop3 < tempScrollTop2 ){
          newScrollTop = tempScrollTop3;
        }
        else{
          newScrollTop = 0;
        }
  //      alert(this.q_no+": "+tempScrollTop1+"|"+tempScrollTop2+"|"+tempScrollTop3 +" >>> "+newScrollTop);
      }
      
      newScrollTop = newScrollTop - 40; //※40というのはなんとなくの数値
      if( newScrollTop < 0 || !newScrollTop ){
        newScrollTop = 0;
      }
      $(tempSlideName+' .alltext').attr("scrollTop",newScrollTop);

      this.setShadeText();
      this.setParagraphArrow();
      this.setInsertPoint();
      this.setGlossary();

    },

    hideAllPassageJP: function(){
      var temp = $("#"+this.slideid+" .passage_jp");
      for(var i = 0 ; i < temp.length ; i++  ){
        $(temp[i]).hide();
      }
    },


    //網掛けテキスト
    setShadeText: function(){
      var target = $( "#"+this.slideid + ' .highlight_'+this.q_no);
      target.css('background','silver');
    },

    //段落アロー
    setParagraphArrow: function(){
      var target = $( "#"+this.slideid + ' .arrow_' + this.q_no );
      target.html("　　");
      target.addClass('paragraph_arrow');
    },

    //Glossary
    setGlossary: function(){
      var targets = $("#"+this.slideid +' .alltext'+" span[id^='glossary_']");
      targets.addClass("glossary");

      var tempSlideController = this;
      $(targets).bind(
        "click",
        tempSlideController,
        function(e) {
          var index = Number( $("#"+tempSlideController.slideid +' .alltext'+" span[id^='glossary_']").index(this)) + 1;
          tempSlideController.showGlossary(index);
        }
      );

    },

    //type_iのテキスト挿入位置
    setInsertPoint: function(){
      //各typeのクラスメソッドを参照してください
      //alert("この機能は未実装です：setInsertPoint");
    },
    

    //Glossary
    showGlossary: function(glossary_no){

      this.hideGlossary();

      this.currentGlossaryNo = glossary_no;
      $("#glossary_area .glossary_"+this.major+"_"+this.currentGlossaryNo).show();
      $("#glossary_area").show();

    },

    hideGlossary: function(){

      $("#glossary_area").hide();
      $("#glossary_area .glossary_"+this.major+"_"+this.currentGlossaryNo).hide();

    },

    //問題エリアとAllTextの両方------------------------------------------------
    //網掛け
    setShadeQText: function(){
      var target = $( "#"+this.slideid +' #highlight_q_'+this.q_no);
      target.css('background','silver');
    }
    
  }
);

/* -----------------------------------------------------------------------------

ReadingSlideController_Intro

----------------------------------------------------------------------------- */
ReadingSlideController_Intro = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {
      this.parent( slideId );
      this.slideContent = $("div", $("#" + slideId));
      this.type       = param.type;
      this.slidenumber= param.slide_number;
      this.slideid    = slideId;
      this.data       = param.data;
    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //Timerエリアの非表示
      this.context.components["timer"].hide();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです
    }
    
  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Direction

----------------------------------------------------------------------------- */
ReadingSlideController_Direction = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです


      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //Timerエリアの非表示
      this.context.components["timer"].hide();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

    }

  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Passage

----------------------------------------------------------------------------- */
ReadingSlideController_Passage = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    checkScroller:undefined,

    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.major      = param.sameTypeCount;

      var tempSlideController = this;
      $("#"+this.slideid).ready(
        function(e){
          //document.onmousemove = tempSlideController.checkScroll;
          tempSlideController.hideAllPassageJP();
        }
      );

      var close_btn = $("#glossary_area .close_btn");
      $(close_btn).bind(
        "click",
        tempSlideController,
        function(e) {
          tempSlideController.hideGlossary();
        }
      );

    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //パッセージ未読チェック
      if( !this.checkScroller ){
        var self =this;
        this.checkScroller = setInterval(
          function(){
            self.checkScroll();
          },
          500
        );
      }
      
      this.setGlossary();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      clearInterval(this.checkScroller);
      this.checkScroller = undefined;
      
      this.hideGlossary();
    }

  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Instruction

----------------------------------------------------------------------------- */
/*
ReadingSlideController_Instruction = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {
      this.parent( slideId );
      this.slideContent = $("div", $("#" + slideId));
      this.type       = param.type;
      this.slidenumber= param.slide_number;
      this.slideid    = slideId;
      this.data       = param.data;
    },

    slideTimeout: function(){
      this.context.notify('next');
    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです
      var tempController = this;

      //3秒後にnext
      setTimeout(
        function(){ tempController.slideTimeout(tempController) },
        3000
      );
    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです
    }
    
  }
);
*/


/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_s

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_s = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.partQuestionCount = param.partQuestionCount;
      this.major      = this.data.major;
      this.q_no       = this.data.minor;

      //this.question_id= "q_"+this.q_no;
      this.answer     = this.data.correct_answer;

      var tempSlideController = this;
      //var tempQuestionName    = "#"+this.slideid+" li#q"+this.q_no+"_";
      var tempQuestionName    = "#"+this.slideid+" li#q"+this.major+"_"+this.q_no+"_";

      $("#"+this.slideid).ready(
        function(e){
          for( var i = 1 ; i <= 4 ; i++ ){
            $(tempQuestionName+i).bind(
              "click",
              tempSlideController,
              function(e) {
                tempSlideController.setUserAnswer({
                  "targetElement":jQuery(this),
                  "userAnswer":jQuery(this).attr("id").split('_')[2]
                });
              }
            );
          }

        }
      );


    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです
      
      //全文テキストに対する処理
      this.gotoParagraph();
      this.setShadeQText();
      this.hideAllPassageJP();

      //Resultを更新
      r.seek(this.partQuestionCount);
     
      //既存の成績の書き戻し
      this.solution = r.saw_solution();
      this.useranswer = r.user_answer();
      if( this.useranswer != "" ){
        this.revertUserAnswer();
      }

      //ShowSolutionボタンのONOFF
      this.solution = r.saw_solution();
      if( this.solution ){
        c.notify('sawSolution');
        this.showSolution();
      }

      //カレントスライドをseenにする
      this.setCurrentSeen();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();
    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //成績・進捗を更新
      this.setCurrentResult();

      this.hideGlossary();
    },

    dispQuestion: function() {
      $("#"+this.slideid+" .question").show();
    },

    hideQuestion: function() {
      $("#"+this.slideid+" .question").hide();
      $("#"+this.slideid+" .user_answer_area").hide();
    },

    toggleSolution: function(){

      var tempQuestionName    = "#"+this.slideid+" li#q"+this.major+"_"+this.q_no+"_"+this.answer;
      if( this.solution ){
        this.hideSolution();
      }
      else{
        this.showSolution();
      }

    },

    showSolution: function(){
      var tempQuestionName    = "#"+this.slideid+" li#q"+this.major+"_"+this.q_no+"_"+this.answer;
      $(tempQuestionName).addClass("showSolution");
      this.solution = 1;
    },

    hideSolution: function(){
      var tempQuestionName    = "#"+this.slideid+" li#q"+this.major+"_"+this.q_no+"_"+this.answer;
      $(tempQuestionName).removeClass("showSolution");
      this.solution = 0;
    },
    
    setUserAnswer: function(param){
      this.resetUserAnswer();
      param.targetElement.addClass("radio_select");
      this.useranswer = param.userAnswer;
      //alert( param.userAnswer == this.answer ? "正解！": "不正解..." );
    },

    revertUserAnswer: function(param){
      var tempSlideName    = "#slide_"+this.slidenumber;
      var tempQuestionName = "li#q"+this.major+"_"+this.q_no+"_";

      for( var i = 1 ; i <= 4 ; i++ ){
        if( this.useranswer != i ){
          $(tempQuestionName+i).removeClass("radio_select");
        }
        else{
          $(tempQuestionName+i).addClass("radio_select");
        }
      }
    },

    setTrueAnswer: function(){

      var tempSlideName    = "#slide_"+this.slidenumber;
      var tempQuestionName = "li#a"+this.major+"_"+this.q_no+"_";

      for( var i = 1 ; i <= 4 ; i++ ){
        if( this.answer != i ){
          $(tempQuestionName+i).removeClass("radio_select");
        }
        else{
          $(tempQuestionName+i).addClass("radio_select");
        }
      }

    },

    resetUserAnswer: function(){

      var tempSlideName    = "#"+this.slideid;
      var tempQuestionName = "li#q"+this.major+"_"+this.q_no+"_";
      for( var i = 1 ; i <= 4 ; i++ ){
        $(tempQuestionName+i).removeClass("radio_select");
      }
      this.useranswer = "";
    }

  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_c

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_c = Class.extend(
  ReadingSlideController,
  {
  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_m

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_m = Class.extend(
  ReadingSlideController,
  {
    initialize: function(slideId, param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.partQuestionCount = param.partQuestionCount;
      this.major        = this.data.major;
      this.q_no         = this.data.minor;
      //this.question_id  = "q_"+this.q_no;

      this.answer       = this.data.correct_answer;
      this.correct_num  = this.data.correct_answer.split(',').length;
      
      this.useranswer   = new Array();

      this.checked_num  = 0;

      this.template = param.template;


      var tempSlideController = this;
      var tempQuestionName    = "#"+this.slideid+" li#q"+this.major+"_"+this.q_no+"_";
      $("#"+this.slideid).ready(
        function(e){
          for( var i = 1 ; i <= tempSlideController.data.choice_e.length ; i++ ){
            $(tempQuestionName+i).bind(
              "click",
              tempSlideController,
              function(e) {
                tempSlideController.setUserAnswer({
                  "targetElement":jQuery(this),
                  "userAnswer":jQuery(this).attr("id")
                });
              }
            );
          }


        }
      );
      

      return this;

    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //全文テキストに対する処理
      this.gotoParagraph();
      this.setShadeQText();
      this.hideAllPassageJP();

      //Resultを更新
      r.seek(this.partQuestionCount);

      //既存の成績の書き戻し
      this.useranswer = r.user_answer();
      if( this.useranswer != "" ){
        this.useranswer = eval("["+r.user_answer()+"]");
        this.revertUserAnswer();
      }

      //ShowSolutionボタンのONOFF
      this.solution = r.saw_solution();
      if( this.solution ){
        c.notify('sawSolution');
        this.showSolution();
      }

      //カレントスライドをseenにする
      this.setCurrentSeen();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //成績・進捗を更新
      this.setCurrentResult();

      this.hideGlossary();
    },

    dispQuestion: function() {
      $("#"+this.slideid+" .question").show();
      //$("#"+this.slideid+" .user_answer_area").show();
      //this.context.notify('thinking');
    },

    hideQuestion: function() {
      $("#"+this.slideid+" .user_answer_area").hide();
    },

    toggleSolution: function(){

      if( !this.solution ){
        this.showSolution();
      }
      else{
        this.hideSolution();
      }
      
    },

    showSolution: function(param){
      var tempAnswer = String(this.answer).split(",");
      var tempQuestionName    = "#"+this.slideid+" li#q"+this.major+"_"+this.q_no+"_";

      for(var i = 0 ; i < tempAnswer.length ; i++ ){
        $(tempQuestionName+tempAnswer[i]).addClass("showSolution");
      }
      this.solution = 1;
    },
    
    hideSolution: function(param){
      var tempAnswer = String(this.answer).split(",");
      var tempQuestionName    = "#"+this.slideid+" li#q"+this.major+"_"+this.q_no+"_";

      for(var i = 0 ; i < tempAnswer.length ; i++ ){
        $(tempQuestionName+tempAnswer[i]).removeClass("showSolution");
      }
      this.solution = 0;
    },

    setUserAnswer: function(param){

      var tempSlideName    = "#"+this.slideid;

      var tempQuestionName = "li#a"+this.major+"_"+this.q_no+"_";

      var tempChoiceNo = param.targetElement.attr("id").split("_")[2];

      var tempChoices = $(tempSlideName+' .choices');

      //tempUserAnswerを初期化
      var tempUserAnswer = new Array;
      for( var i = 0 ; i < this.data.choice_e.length ; i++ ){
        tempUserAnswer[i] = 0;
      }

      //tempUserAnswerに既存の値をコピー
      for( var i = 0 ; i < this.useranswer.length ; i++ ){
        tempUserAnswer[ this.useranswer[i]-1 ] = 1;
      }

      //チェックボックスのONOFF
      if( tempUserAnswer[tempChoiceNo-1] == 0 ){
        tempUserAnswer[tempChoiceNo-1] = 1;
      }
      else{
        tempUserAnswer[tempChoiceNo-1] = 0;
      }

      //最終的な値でユーザーの回答を記録
      this.useranswer = [];
      this.checked_num = 0;
      for( var i = 0 ; i < tempUserAnswer.length ; i++ ){
        if( tempUserAnswer[i] == 1 ){
          this.useranswer.push((i+1));
          this.checked_num++;
        }
      }

      //最終的な値で表示のONOFF
      if( tempUserAnswer[tempChoiceNo-1] == 0 ){
        param.targetElement.removeClass("checkbox_select");
      }
      else{
        param.targetElement.addClass("checkbox_select");
      }

      if( this.checked_num == this.correct_num ){
        //alert( String(this.useranswer) == this.answer ? "正解！": "不正解..." );
      }

    },

    revertUserAnswer: function(param){
      var tempSlideName    = "#"+this.slideid;
      var tempQuestionName = "li#q"+this.major+"_"+this.q_no+"_";

      for( var i = 0 ; i < this.data.choice_e.length ; i++ ){
        $(tempQuestionName+i).removeClass("checkbox_select");
      }
      for( var i = 0 ; i < this.useranswer.length ; i++ ){
        $(tempQuestionName+(this.useranswer[i])).addClass("checkbox_select");
      }

    },

    setTrueAnswer: function(){

      var tempSlideName    = "#"+this.slideid;
      var tempQuestionName = "li#a"+this.major+"_"+this.q_no+"_";

      for( var i = 1 ; i <= tempSlideController.data.choice_e.length ; i++ ){
        if( this.answer != i ){
          $(tempQuestionName+i).removeClass("checkbox_select");
        }
        else{
          $(tempQuestionName+i).addClass("checkbox_select");
        }
      }

    }
  }
);

/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_i

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_i = Class.extend(
  ReadingSlideController,
  {
    initialize: function(slideId, param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.partQuestionCount = param.partQuestionCount;
      this.major      = this.data.major;
      this.q_no         = this.data.minor;
      //this.question_id  = "q_"+this.q_no;

      this.answer       = this.data.correct_answer;

      this.useranswer;

      this.template = param.template;


      var tempSlideName    = "#"+this.slideid;
      var tempSlideController = this;

      $(tempSlideName+' .alltext').ready(
        function(e){
          //tempSlideController.gotoParagraph();
          //tempSlideController.setShadeQText();
          //tempSlideController.hideAllPassageJP();
        }
      );


      return this;
    },

    //type_i テキスト挿入位置
    setInsertPoint: function(){
      var tempSlideName    = "#"+this.slideid;
      var tempSlideController = this;
      var tempEventTarget = tempSlideName+" .alltext .insert_"+this.q_no+"_";
      for(var i = 1 ; i <= 4 ; i++ ){
        $(tempEventTarget+i).text("■");
        $(tempEventTarget+i).bind(
          "click",
          tempSlideController,
          function(e) {
            tempSlideController.setUserAnswer({
              "targetElement":jQuery(this),
              "userAnswer":jQuery(this).attr("class")
            });
          }
        );
        $(tempEventTarget+i).removeClass("solution");
        $(tempEventTarget+i).css({
          "cursor":"pointer",
          "font-weight":"bold",
          "font-size":"140%"
        });
      } 
    },

    setUserAnswer: function(e){
      var tempSlideName    = "#"+this.slideid;
      var temp = tempSlideName+" .slidearea_left";
      this.resetUserAnswer();
      this.hideSolution();
      var tempEventTarget = tempSlideName+" .alltext ."+e.userAnswer;
      $(tempEventTarget).text(this.data.ins_s_e);
      $(tempEventTarget).css({
          "font-size":"100%"
      });
      this.useranswer = e.userAnswer.split("insert_"+this.q_no+"_")[1];
      //alert("正解は"+this.answer+" あなたの回答は"+this.useranswer);
    },

    revertUserAnswer: function(param){
      var tempSlideName = "#"+this.slideid;
      var temp          = tempSlideName+" .slidearea_left";
      var tempEventTarget = tempSlideName+" .alltext .insert_"+this.q_no+"_";
      for( var i = 1 ; i <= 4 ; i++ ){
        if( this.useranswer != i ){
          $(tempEventTarget+i).text("■");
          $(tempEventTarget+i).css({
            "font-size":"140%"
          });
        }
        else{
          $(tempEventTarget+i).text(this.data.ins_s_e);
          $(tempEventTarget+i).css({
              "font-size":"100%"
          });
        }
      }
    },

    setTrueAnswer: function(){
      var tempSlideName    = "#"+this.slideid;
      var tempEventTarget = tempSlideName+" .alltext .alltext .insert_"+this.q_no+"_"+this.data.correct_answer;
      $(tempEventTarget).text(this.data.ins_s_e);
      $(tempEventTarget).css({
        "font-size":"100%"
      });
    },

    resetUserAnswer: function(){
      var tempSlideName    = "#"+this.slideid;
      var tempSlideController = this;
      var tempEventTarget = tempSlideName+" .alltext .insert_"+this.q_no+"_";
      for(var i = 1 ; i <= 4 ; i++ ){
        $(tempEventTarget+i).text("■");
        $(tempEventTarget+i).css({
          "font-size":"140%"
        });
        $(tempEventTarget+i).removeClass("solution");
      } 

    },
/*
    hideSolution: function(){
      var tempSlideName    = "#"+this.slideid;
      var tempEventTarget = tempSlideName+" .alltext .insert_"+this.q_no+"_"+this.data.correct_answer;
      
      if( this.useranswer != this.answer ){
        $(tempEventTarget).text("■");
      }
      $(tempEventTarget).removeClass("solution");
      this.solution = 0;

    },
*/    
    toggleSolution: function(){
      
      if(!this.solution){
        this.showSolution();
      }
      else{
        this.hideSolution();
      }

    },

    showSolution: function (){
      var tempSlideName    = "#"+this.slideid;
      var tempEventTarget = tempSlideName+" .alltext .insert_"+this.q_no+"_"+this.data.correct_answer;

      if( this.useranswer != this.answer ){
        $(tempEventTarget).text(this.data.ins_s_e);
        $(tempEventTarget).css({
            "font-size":"100%"
        });
      }

      $(tempEventTarget).addClass("solution");
      this.solution = 1;
    },

    hideSolution: function (){
      var tempSlideName    = "#"+this.slideid;
      var tempEventTarget = tempSlideName+" .alltext .insert_"+this.q_no+"_"+this.data.correct_answer;
      if( this.useranswer != this.answer ){
        $(tempEventTarget).text("■");
        $(tempEventTarget).css({
          "font-size":"140%"
        });
      }
      $(tempEventTarget).removeClass("solution");
      this.solution = 0;
    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //全文テキストに対する処理
      this.gotoParagraph();
      this.setShadeQText();
      this.hideAllPassageJP();

      //Resultを更新
      r.seek(this.partQuestionCount);

      //既存の成績の書き戻し
      this.useranswer = r.user_answer();
      if( this.useranswer != "" ){
        this.revertUserAnswer();
      }

      //ShowSolutionボタンのONOFF
      this.solution = r.saw_solution();
      if( this.solution ){
        c.notify('sawSolution');
        this.showSolution();
      }

      //カレントスライドをseenにする
      this.setCurrentSeen();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //成績・進捗を更新
      this.setCurrentResult();

      this.hideGlossary();
    }

  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_d 

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_d = Class.extend(
  ReadingSlideController,
  {
    initialize: function(slideId, param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.partQuestionCount = param.partQuestionCount;
      this.major         = this.data.major;
      this.q_no         = this.data.minor;
      //this.question_id  = "q_"+this.q_no;

      this.answer       = this.data.correct_answer.split(",");
      this.useranswer   = new Array();

      this.checked_num  = 0;

      this.template = param.template;


      var tempSlideController = this;
      var tempSlideName = "#"+slideId;


      $("#"+this.slideid).ready(
        function(e){

          var optDropzone = {
            accept: '.draggable',
            hoverClass: 'dropzone_hover',
            drop: function(e, ui) {

              var msg   = "<p>"+ ui.draggable.attr("id")
                              + " が "+this.id
                              + " へドロップされました</p>"
              //alert(msg);
              
              //ドロップは1個しか許さない
              if ($(this).children().length == 0) {
                $(this).append(ui.draggable);
                ui.draggable.css({
                  "top":"0px",
                  "left":"0px"
                });
                tempSlideController.updateUserAnser();
              }
              else{
                ui.draggable.css({left: 0, top: 0});
              }
            }
          }
          $(tempSlideName+' .dropzone').droppable(optDropzone);


          //Dropzone0(draggableの初期位置)
          var optDropzone0 = {
            accept: '.draggable',
            hoverClass: 'dropzone_hover',
            drop: function(e, ui) {
              $(this).append(ui.draggable);
              tempSlideController.updateUserAnser();
            }
          }
          //alert($(tempSlideName+' #dropzone_q'+tempSlideController.q_no+'_0').attr("id"));
          $(tempSlideName+' #dropzone_q'+tempSlideController.major+"_"+tempSlideController.q_no+'_0').droppable(optDropzone0);


          var optDraggable = {
            cursor   : 'move',
            stop: function(e, ui) {
              $(e.target).css({
                position: 'relative', left: 0, top: 0,
                cursor:"pointer"
              });
            }
          }
          $(tempSlideName+' .draggable').draggable(optDraggable);

          tempSlideController.hideAllPassageJP();

        }
      );
    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //Resultを更新
      r.seek(this.partQuestionCount);

      //既存の成績の書き戻し
      this.useranswer = r.user_answer();
      if( this.useranswer != "" ){
        this.revertUserAnswer();
      }

      //ShowSolutionボタンのONOFF
      this.solution = r.saw_solution();
      if( this.solution ){
        c.notify('sawSolution');
        this.toggleSolution();
      }

      //カレントスライドをseenにする
      this.setCurrentSeen();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //成績・進捗を更新
      this.setCurrentResult();

      this.hideGlossary();
    },

    dispQuestion: function() {
      $("#"+this.slideid+" .question").show();
      //$("#"+this.slideid+" .user_answer_area").show();
      //this.context.notify('thinking');
    },

    hideQuestion: function() {
      //$("#"+this.slideid+" .question").hide();
      $("#"+this.slideid+" .user_answer_area").hide();
    },

    toggleSolution: function(){
      this.toggleSolution_type_draggable_q();
    },

    setUserAnswer: function(param){
      //alert("正解は"+this.answer+" あなたの回答は"+this.user_answer);
    },

    revertUserAnswer: function(){
      var tempSlideName = "#"+this.slideId;

      var tempAnswer  = String(r.user_answer());
      tempAnswer = tempAnswer.split(",");

      for( var i = 0 ; i < tempAnswer.length ; i++ ){
        var temp = $(tempSlideName+' #dropzone_q'+this.major+"_"+this.q_no+'_'+(i+1) );
        var temp2 = $("#draggable_q"+this.major+"_"+this.q_no+"_"+tempAnswer[i] );
        temp.append(temp2);
      }

    },

    setTrueAnswer: function(){
    },

    updateUserAnser: function(){

      var tempSlideController = this;
      var tempSlideName    = "#"+this.slideid;
      var tempUserAnser = new Array();
      var tempDroppableIdName = "dropzone_q"+this.major+"_"+this.q_no+"_";
      var tempDraggableIdName = "draggable_q"+this.major+"_"+this.q_no+"_";

      //dropzoneをチェック
      for( var i = 1 ; i <= this.answer.length ; i++ ){
        var tempDropZoneID = tempSlideName+' #'+tempDroppableIdName+i+' .draggable';
        if( $(tempDropZoneID).attr("id") ){
          tempUserAnser.push(String($(tempDropZoneID).attr("id")).split("_")[3]);
        }
      }
      

      if( tempUserAnser.length == this.answer.length){

        tempUserAnser = tempUserAnser.sort();
      
        if( String(tempUserAnser) == String(this.answer)){
          //alert("正解！ "+tempUserAnser);
        }
        else{
          //alert("不正解... "+tempUserAnser+" != "+this.answer);
        }
      }

      this.useranswer = String(tempUserAnser);

    }

  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_do

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_do = Class.extend(
  ReadingSlideController,
  {
    /*
    initialize: function(slideId, param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.partQuestionCount = param.partQuestionCount;
      this.major      = this.data.major;
      this.q_no         = this.data.minor;

      this.answer       = this.data.correct_answer.split(",");
      this.useranswer   = "";

      this.checked_num  = 0;

      this.template = param.template;


      var tempSlideController = this;
      var tempSlideName = "#"+slideId;


      $("#"+this.slideid).ready(
        function(e){

          var optDropzone = {
            accept: '.draggable',
            hoverClass: 'dropzone_hover',
            drop: function(e, ui) {

              var msg   = "<p>"+ ui.draggable.attr("id")
                              + " が "+this.id
                              + " へドロップされました</p>"
              //alert(msg);
              
              //ドロップは1個しか許さない
              if ($(this).children().length == 0) {
                $(this).append(ui.draggable);
                ui.draggable.css({
                  "top":"0px",
                  "left":"0px"
                });
                tempSlideController.updateUserAnser();
              }
              else{
                ui.draggable.css({left: 0, top: 0});
              }
            }
          }
          $(tempSlideName+' .dropzone').droppable(optDropzone);


          //Dropzone0(draggableの初期位置)
          var optDropzone0 = {
            accept: '.draggable',
            drop: function(e, ui) {
              $(this).append(ui.draggable);
              tempSlideController.updateUserAnser();
            }
          }
          //alert($(tempSlideName+' #dropzone_q'+tempSlideController.q_no+'_0').attr("id"));
          $(tempSlideName+' #dropzone_q'+tempSlideController.q_no+'_0').droppable(optDropzone0);


          var optDraggable = {
            cursor   : 'move',
            stop: function(e, ui) {
              $(e.target).css({
                position: 'relative', left: 0, top: 0,
                cursor:"pointer"
              });
            }
          }
          $(tempSlideName+' .draggable').draggable(optDraggable);

          tempSlideController.hideAllPassageJP();

        }
      );
    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //Resultを更新
      r.seek(this.partQuestionCount);

      //既存の成績の書き戻し
      this.useranswer = r.user_answer();
      if( this.useranswer != "" ){
        this.revertUserAnswer();
      }

      //ShowSolutionボタンのONOFF
      this.solution = r.saw_solution();
      if( this.solution ){
        c.notify('sawSolution');
      }

      //カレントスライドをseenにする
      this.setCurrentSeen();

      //タイマー起動
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //成績・進捗を更新
      this.setCurrentResult();

      this.hideGlossary();
    },

    dispQuestion: function() {
      $("#"+this.slideid+" .question").show();
      //$("#"+this.slideid+" .user_answer_area").show();
      //this.context.notify('thinking');
    },

    hideQuestion: function() {
      $("#"+this.slideid+" .user_answer_area").hide();
    },

    toggleSolution: function(){
      this.toggleSolution_type_draggable_q();
    },

    toggleSolution: function(){
      
      if ( $("#"+this.slideid+" .user_answer_area").css("display") != "none" ){
        $("#"+this.slideid+" .user_answer_area").hide();
        $("#"+this.slideid+" .true_answer_area").show();
        this.solution = 1;
      }
      else{
        $("#"+this.slideid+" .true_answer_area").hide();
        $("#"+this.slideid+" .user_answer_area").show();
        this.solution = 0;
      }

    },

    setUserAnswer: function(param){
      alert("正解は"+this.answer+" あなたの回答は"+this.user_answer);
    },

    setTrueAnswer: function(){
    },

    updateUserAnser: function(){

      var tempSlideController = this;
      var tempSlideName    = "#"+this.slideid;
      var tempUserAnser = new Array();
      var tempDroppableIdName = "dropzone_q"+this.q_no+"_";
      var tempDraggableIdName = "draggable_q"+this.q_no+"_";

      //dropzoneをチェック
      for( var i = 1 ; i <= this.answer.length ; i++ ){
        var tempDropZoneID = tempSlideName+' #'+tempDroppableIdName+i+' .draggable';
        if( $(tempDropZoneID).attr("id") ){
          tempUserAnser.push(String($(tempDropZoneID).attr("id")).split("_")[2]);
        }
      }
      
      if( tempUserAnser.length == this.answer.length){

        if( String(tempUserAnser) == String(this.answer)){
          //alert("正解！ "+tempUserAnser);
        }
        else{
          //alert("不正解... "+tempUserAnser+" != "+this.answer);
        }
      }

    }
    */
  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_ds

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_ds = Class.extend(
  ReadingSlideController,
  {
    initialize: function(slideId,param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.partQuestionCount = param.partQuestionCount;
      this.major      = this.data.major;
      this.q_no         = this.data.minor;


      this.answer   = new Array();
      var tempAnswer = param.data.correct_answer.split("|");

      for( var i = 0 ; i < tempAnswer.length ; i++ ){
        var temp2 = tempAnswer[i].split(",");
        this.answer.push(temp2);
      }
      //alert("正解：["+this.answer[0]+"]["+this.answer[1]+"]");
/*
      //余る選択肢を抽出する
      //回答は文字列なので配列に変換
      this.data.answers[0].answer_number = eval("["+param.data.answers[0].answer_number+"]");
      this.data.answers[1].answer_number = eval("["+param.data.answers[1].answer_number+"]");

      for(var i = 0 ; i < this.data.choices.length ; i++ ){
        this.data.choices[i].no = i+1;
        this.data.choices[i].use = 0;               //use=0は未使用
      }

      for(var i = 0 ; i < this.data.answers[0].answer_number.length ; i++ ){
        this.data.choices[this.data.answers[0].answer_number[i]-1].use = 1; //use=1はBOX1に
      }
      for(var i = 0 ; i < this.data.answers[1].answer_number.length ; i++ ){
        this.data.choices[this.data.answers[1].answer_number[i]-1].use = 2; //use=2はBOX2に
      }
*/

      var tempSlideController = this;
      var tempSlideName = "#"+slideId;

      $(tempSlideName).ready(
        function(e){

          var optDropzone = {
            tolerance: 'pointer',
            accept: '.draggable',
            hoverClass: 'droppable-hover',
            drop: function(e, ui) {
              $(this).append($(ui.draggable));
              $(ui.draggable).css({
                position: 'relative', left: 0, top: 0
              });

              tempSlideController.updateUserAnser();
            }
          }
          $(tempSlideName+' .dropzone').droppable(optDropzone);

          var optDraggable = {
            //opacity: 0.5,
            stop: function(e, ui) {
              $(e.target).css({
                position: 'relative', left: 0, top: 0,
                cursor:"pointer"
              });
            }
          }
          $(tempSlideName+' .draggable').draggable(optDraggable);

          tempSlideController.setShadeQText();

          tempSlideController.hideAllPassageJP();
        }
      );

      return this;
    },



    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //Resultを更新
      r.seek(this.partQuestionCount);

      //既存の成績の書き戻し
      this.useranswer   = r.user_answer();
      if( this.useranswer != "" ){
        this.revertUserAnswer();
      }

      //ShowSolutionボタンのONOFF
      this.solution = r.saw_solution();
      if( this.solution ){
        c.notify('sawSolution');
        this.toggleSolution();
      }

      //カレントスライドをseenにする
      this.setCurrentSeen();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //成績・進捗を更新
      this.setCurrentResult();

      this.hideGlossary();
    },

    dispQuestion: function() {
      $("#"+this.slideid+" .question").show();
      //$("#"+this.slideid+" .user_answer_area").show();
      //this.context.notify('thinking');
    },

    hideQuestion: function() {
      $("#"+this.slideid+" .user_answer_area").hide();
    },

    toggleSolution: function(){
      this.toggleSolution_type_draggable_q();
    },

    setUserAnswer: function(param){
      //alert("正解は"+this.answer+" あなたの回答は"+this.user_answer);
    },

    revertUserAnswer: function(){
      var tempSlideName = "#"+this.slideId;

      var tempAnswer  = String(r.user_answer());
      var tempAnswer2 = new Array();
      tempAnswer = tempAnswer.split("|");
      for( var i = 0 ; i < tempAnswer.length ; i++ ){
        var temp2 = tempAnswer[i].split(",");
        tempAnswer2.push(temp2);
      }

      for( var i = 0 ; i < tempAnswer2.length ; i++ ){
        var temp = tempAnswer2[i];
        for(var j = 0 ; j < temp.length ; j++ ){
          $(tempSlideName+' #dropzone_q'+this.q_no+'_'+(i+1) ).append($("#draggable_q"+this.q_no+"_"+temp[j] ));
        }
      }

    },

    setTrueAnswer: function(){
    },

    updateUserAnser: function(){
      var tempSlideController = this;
      var tempSlideName    = "#"+tempSlideController.slideid;

      var tempUserAnser1 = new Array();
      var tempUserAnser2 = new Array();

      var tempDroppableIdName = "dropzone_q"+this.q_no+"_";
      var tempDraggableIdName = "draggable_q"+this.q_no+"_";

      //dropzone1をチェック
      var dz = tempSlideName+' #'+tempDroppableIdName+'1 .draggable';


      for( var i = 0 ; i < $(dz).length ; i++ ){
        tempUserAnser1.push($(dz)[i].id.split(tempDraggableIdName)[1]);
      }
      tempUserAnser1 = tempUserAnser1.sort();

      //dropzone2をチェック
      var dz = tempSlideName+' #'+tempDroppableIdName+'2 .draggable';
      for( var i = 0 ; i < $(dz).length ; i++ ){
        tempUserAnser2.push($(dz)[i].id.split(tempDraggableIdName)[1]);
      }
      tempUserAnser2 = tempUserAnser2.sort();

      //alert("["+tempUserAnser1+"]["+tempUserAnser2+"]");
      if( String(tempUserAnser1) == String(this.answer[0]) && String(tempUserAnser2) == String(this.answer[1]) ){
        //alert("正解！");
      }
      else{
        //alert("不正解");
      }
      this.useranswer = String(tempUserAnser1)+"|"+String(tempUserAnser2);
      //alert("this.useranswer = "+this.useranswer);
    }

  }
);


/* -----------------------------------------------------------------------------

ReadingSlideController_Qtype_p

----------------------------------------------------------------------------- */
ReadingSlideController_Qtype_p = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

      this.partQuestionCount = param.partQuestionCount;
      this.major      = this.data.major;
      this.q_no       = this.data.minor;
      this.answer     = this.data.correct_answer;

      var tempSlideController = this;
      var tempQuestionName    = "#"+this.slideid+" div#q"+this.major+"_"+this.q_no+"_";


      $("#"+this.slideid).ready(
        function(e){
          for( var i = 1 ; i <= 4 ; i++ ){
            $(tempQuestionName+i).bind(
              "click",
              tempSlideController,
              function(e) {
                tempSlideController.setUserAnswer({
                  "targetElement":jQuery(this),
                  "userAnswer":jQuery(this).attr("id").split('_')[2]
                });
              }
            );
          }

        }
      );
    },

    play: function(){
      //外部からSlide(Question)を開始するメソッドです

      //全文テキストに対する処理
      this.gotoParagraph();
      this.setShadeQText();
      this.hideAllPassageJP();

      //Resultを更新
      r.seek(this.partQuestionCount);
      //既存の成績の書き戻し
      this.solution = r.saw_solution();
      this.useranswer = r.user_answer();
      if( this.useranswer != "" ){
        this.revertUserAnswer();
      }

      //ShowSolutionボタンのONOFF
      this.solution = r.saw_solution();
      if( this.solution ){
        c.notify('sawSolution');
        this.showSolution();
      }

      //カレントスライドをseenにする
      this.setCurrentSeen();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //成績・進捗を更新
      this.setCurrentResult();

      this.hideGlossary();
    },

    dispQuestion: function() {
      $("#"+this.slideid+" .question").show();
    },

    hideQuestion: function() {
      $("#"+this.slideid+" .question").hide();
      $("#"+this.slideid+" .user_answer_area").hide();
    },

    toggleSolution: function(){

      if( this.solution ){
        this.hideSolution();
      }
      else{
        this.showSolution();
      }

    },

    showSolution: function(){
      var tempQuestionName    = "#"+this.slideid+" div#q"+this.major+"_"+this.q_no+"_"+this.answer;
      $(tempQuestionName).addClass("showSolution");
      this.solution = 1;
    },

    hideSolution: function(){
      var tempQuestionName    = "#"+this.slideid+" div#q"+this.major+"_"+this.q_no+"_"+this.answer;
      $(tempQuestionName).removeClass("showSolution");
      this.solution = 0;
    },


    setUserAnswer: function(param){
      this.resetUserAnswer();
      param.targetElement.addClass("picture_select");
      this.useranswer = param.userAnswer;
    },

    revertUserAnswer: function(param){
      var tempSlideName    = "#slide_"+this.slidenumber;
      var tempQuestionName = "div #q"+this.major+"_"+this.q_no+"_";

      for( var i = 1 ; i <= 4 ; i++ ){
        if( this.useranswer != i ){
          $(tempQuestionName+i).removeClass("picture_select");
        }
        else{
          $(tempQuestionName+i).addClass("picture_select");
        }
      }
    },

    setTrueAnswer: function(){

      var tempSlideName    = "#slide_"+this.slidenumber;
      var tempQuestionName = "div #a"+this.major+"_"+this.q_no+"_";

      for( var i = 1 ; i <= 4 ; i++ ){
        if( this.answer != i ){
          $(tempQuestionName+i).removeClass("picture_select");
        }
        else{
          $(tempQuestionName+i).addClass("picture_select");
        }
      }

    },

    resetUserAnswer: function(){

      var tempSlideName    = "#slide_"+this.slidenumber;
      var tempQuestionName = "#q"+this.major+"_"+this.q_no+"_";

      for( var i = 1 ; i <= 4 ; i++ ){
        $(tempQuestionName+i).removeClass("picture_select");
      }

    }

  }
);

/* -----------------------------------------------------------------------------

ReadingSlideController_PartEnd

----------------------------------------------------------------------------- */
ReadingSlideController_PartEnd = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

    },

    play: function(){

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //Timerエリアの非表示
      this.context.components["timer"].hide();
    },

    stop: function(){
    }
  }
);

/* -----------------------------------------------------------------------------

ReadingSlideController_examOutro

----------------------------------------------------------------------------- */
ReadingSlideController_examOutro = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {

      //全スライド共通初期化処理
      this.commonInitialize(slideId,param);

    },
    play: function(){

      //タイマー停止
      this.context.components["timer"].pauseTimer();

      //Timerエリアの非表示
      this.context.components["timer"].hide();

      this.setFinish();
    },

    stop: function(){
    }
  }
);

/* -----------------------------------------------------------------------------

ReadingSlideController_ReviewIndex

----------------------------------------------------------------------------- */
ReadingSlideController_ReviewIndex = Class.extend(
  ReadingSlideController,
  {
    //プロパティ----------------------------------------------------------------
    //メソッド------------------------------------------------------------------
    initialize: function(slideId,param) {

      this.parent( slideId );
      this.slideContent = $("div", $("#" + slideId));
      this.type       = param.type;
      this.slideid    = slideId;
      this.data       = param.data;
      this.template   = param.template;
    },
    play: function(){

      //外部からSlide(Question)を開始するメソッドです
      dispReviewIndex();

      //タイマー起動
      this.context.components["timer"].show();
      this.context.components["timer"].startTimer();

    },

    stop: function(){
      //外部からSlide(Question)を終了するメソッドです

      //タイマー停止
      this.context.components["timer"].pauseTimer();

    }
  }
);


