// JavaScript Document

function play(filename){
	var player = '<object type="application/x-shockwave-flash" data="/musicplayer.swf?&autoplay=true&song_url='+filename+'&" width="0" height="0"><param name="movie" value="/musicplayer.swf?&autoplay=true&song_url='+filename+'" /><img src="noflash.gif" width="0" height="0" alt="" /></object>';	
	document.getElementById('player').innerHTML = player;
}

function showAnswer(container, answer){
    document.getElementById(container).innerHTML = answer;
}

function eraseAnswer(container){
    document.getElementById(container).innerHTML = '';
}

///////////////     ProgressItemInput    ////////////////////////
function ProgressItemInput(div_name){
  this.div_name = div_name;
  this.selected_items = new Array();
  this.register_events = function(){
    /// toggle each checkbox onClick
    checkboxes = document.getElementById(this.div_name).getElementsByTagName('input');
    for(var i=0; i<checkboxes.length; i++){
      var box = checkboxes[i];
      if(box.checked==true){
        box.parentNode.className="row checked";
      } else {
        box.parentNode.className="row";
      }
    } // end for loop
  } // end register_events()
  this.toggle_row = function(box){
    if(box.checked==true){
      box.parentNode.className="row checked";
      this.selected_items.push(box.value);
    } else {
      box.parentNode.className="row";
      var idx = this.selected_items.indexOf(box.value);  /// Prototype method (indexOf)
      if(idx>-1) this.selected_items.splice(idx, 1);
    }
    document.getElementById('debug_box').innerHTML='Selected Items: ' + this.selected_item_ids();
  } // end toggle_row
  this.selected_item_ids = function(){
    return this.selected_items.join(', ');
  } // end selected_item_ids

} // end ProgressItemInput




/********************** Progress Tracker ****************************/
function ProgressTracker(){
  this.defaultMessage = "Move your mouse over the 'blocks' in the progress bar above to see specific information covered during a lesson.";
  this.inBlock = function(divId){
    var blockDiv = document.getElementById(divId);
    var pContainer = document.getElementById('progress-bar-container');
    var pBar = document.getElementById('progress-bar');
    //pContainer.style.width=(pContainer.clientWidth + 2) + "px";
    //pBar.style.width=(pBar.clientWidth + 2) + "px";
    blockDiv.style.border="solid 1px #aaa";
    pMsg = document.getElementById('progress-message');
    moDiv = document.getElementById('mo-' + divId);
    pMsg.innerHTML = moDiv.innerHTML;
  }
  this.outBlock = function(divId){
    blockDiv = document.getElementById(divId);
    blockDiv.style.border="0";
    blockDiv.style.borderLeft="solid 1px #fff";
    var pContainer = document.getElementById('progress-bar-container');
    var pBar = document.getElementById('progress-bar');
    //pContainer.style.width=(pContainer.clientWidth - 2) + "px";
    //pBar.style.width=(pBar.clientWidth - 2) + "px";
    pMsg = document.getElementById('progress-message');
    //pMsg.innerHTML = "Move your mouse over the 'blocks' in the progress bar above to see specific information covered during a lesson.";
    pMsg.innerHTML = this.defaultMessage;
  }
}



