/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* File Name: course_hider.js                                   *
* Description: Based on health profiles hider this one has the *
*   selected link have class added to it.                      *
* Author: Neil Forshaw                                         *
* Date: 11/02/08                                               *
* Update: 19/09/08                                             *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
var sections = document.getElementsByTagName('div');
function init() {
    var jumpLinks = document.getElementsByTagName('a');
    var firstSectionDone = 0;
    for (var i = 0; i < sections.length;  i++ ){
        if (sections[i].className == 'section'){
            //Find the link which jumps to present section
            for (var j = 0; j < jumpLinks.length;  j++ ){
                //browser turns relative link to absolute, grab after #
                if ( jumpLinks[j].href.split('#')[1] == sections[i].id ){
                    jumpLinks[j].href='javascript:sectionReveal("'+jumpLinks[j].href.split('#')[1]+'")';
                }
            }
            if(firstSectionDone == 1){
                sections[i].style.display = 'none';
            }else{
                firstSectionDone = 1;
            }
        }
    }
}



function sectionReveal(section){
    for (var i = 0; i < sections.length;  i++ ){
        if (sections[i].className == 'section') sections[i].style.display = 'none';
    }
    document.getElementById(section).style.display = 'block';

    //Removed selected class from all tabs
    $(".course_section_tab span").removeClass('selected');
    //add selected tabs
    $("[href*='" + section + "'] span").addClass('selected');


}
// Paul Berry - Fix for print
function FullsectionReveal(section){
    for (var i = 0; i < sections.length;  i++ ){
        if (sections[i].className == 'section') sections[i].style.display = '';
    }
  //  document.getElementById(section).style.display = 'block';
    window.print();
}

