 /*v 1.3 1-17-08   */


 //chapter expand toggle


 //


 // defines a new utility function "getElementsbyClass" that should exist in javascript but doesn't. 


function getElementsByClass(node,searchClass,tag) {


var classElements = new Array();


var els = node.getElementsByTagName(tag); // use "*" for all elements


var elsLen = els.length;


var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");


for (i = 0, j = 0; i < elsLen; i++) {


if ( pattern.test(els[i].className) ) {


classElements[j] = els[i];


j++;


}


}


return classElements;


}


 


  //begin chapter expand toggle functions  ********


//variant of getElementsByClass above.


function getElementsByChapter(chapterNo) {


var classElements = new Array();


var els = document.getElementsByTagName('a'); // use "*" for all elements


var elsLen = els.length;


if (!chapterNo){


  var pattern = new RegExp("(chapter)");}


else {


	var pattern = new RegExp("(chapter"+chapterNo+")");}


var pattern2 = new RegExp("(level1)");


for (i = 0, j = 0; i < elsLen; i++) {


if  ( pattern.test(els[i].className) && !pattern2.test(els[i].className)  ){


    classElements[j] = els[i];


	//alert(els[i].className);


j++;   }  }


return classElements;}





  function toggleByChapter(chapterNo){


   var div = getElementsByChapter(chapterNo); 


 for(var i=0; i<div.length; i++){ 


	    if (div[i].style.visibility=='visible'){


         div[i].style.visibility = 'hidden';


		 div[i].style.display = 'none';  }


	        else { div[i].style.visibility = 'visible';


		           div[i].style.display = 'block';  }  


	}


  }


 //end chapter expand toggle  functions*******


 





//for explanation of how to use this, see http://umhscompliance.net/mlearn/?q=node/393


  function toggle(selectedLayer){


  // Written By: WillyDuitt@hotmail.com || 03-22-2005 \\;


   var div = getElementsByClass(document, 'toggle', '*');


    for(var i=0; i<div.length; i++){ 


         div[i].style.visibility = 'hidden';


		 div[i].style.display = 'none';


      }  





         document.getElementById(selectedLayer).style.visibility = 'visible';


		 document.getElementById(selectedLayer).style.display = "block";


  }


  


  function toggleMulti(selectedLayer, searchClass, tag){


  // Written By: WillyDuitt@hotmail.com || 03-22-2005 \\;


   var div = getElementsByClass(document, searchClass, tag);


    for(var i=0; i<div.length; i++){ 


         div[i].style.visibility = 'hidden';


		 div[i].style.display = 'none';


      }  


         document.getElementById(selectedLayer).style.visibility = 'visible';


		 document.getElementById(selectedLayer).style.display = "block";


  }


  


//these functions display the correct div depending on if you are viewing module thru MLearning or not.


/*To use, create 2 divs: 


<div id="noAPI">non-scorm content goes here</div> 


<div id="API">scorm content goes here</div> 


Just before the closing </body> tag, put the following:


<script language="javascript">parent.APIOK()?scorm():noscorm();</script>*/


function scorm(){


document.getElementById('yesAPI').style.display='block';


 document.getElementById('noAPI').style.display='none'; }


function noscorm(){


document.getElementById('noAPI').style.display='block'; 


document.getElementById('yesAPI').style.display='none'; 


}





