//Window Open function for main index page to open lessons 
function window_open(fname,nWidth,nHeight){ 
	var attr = "left=" + ((screen.width-nWidth)/2-5) + ",top=" + ((screen.height-nHeight)/2-29) + ","+
	"resizable=0,width=" + nWidth + ",height=" + nHeight + ",menubar=0, scrollbars=0";
	var theWindow=window.open(fname,"name", attr)
	theWindow.focus();
}

//If environment is Content Launcher
function addCLOnloadFunction(){
	var elem = document.getElementById('startLink');
	elem.onclick=function() {
    	try{
    	  scormManager.setParam("minPoints", 0);
    		scormManager.setParam("maxPoints", 100);
    		scormManager.setParam("userPoints", 100);
    		scormManager.setParam("status", "completed");
    		scormManager.saveData();
    	}catch(error){
    			scormManager.trace("Error while trying to set lesson completed");
    	}
		var dir = elem.href.replace("file:///","");
		var parts = decodeURI(dir.split('/').join('\\'));
		contentlauncher.properties.ShellExecute(parts,'open');
		return false;
	}
}

//If any other environment
function addWhateverOnloadFunction(){
     try{
      scormManager.setParam("minPoints", 0);
  		scormManager.setParam("maxPoints", 100);
  		scormManager.setParam("userPoints", 100);
  		scormManager.setParam("status", "completed");
  		scormManager.saveData();
  	}catch(error){
  			scormManager.trace("Error while trying to set lesson completed");
  	}
}

//Special function for Access contents to show additional informations about chapter exercises
var isHelpDisplayed = false;
function toggleInfo(elementId, link){
   if(!isHelpDisplayed){
      document.getElementById(elementId).style.display="block";
      link.innerHTML = "schließen";
      isHelpDisplayed = true;
   }else{
            document.getElementById(elementId).style.display="none";
            link.innerHTML = "öffnen";
            isHelpDisplayed = false;
   }
}