﻿var content_type = "cd"; //cd, scorm, hscorm
var screen_type = "normal"; //wide, normal
var rsitem = "items/rsimage.jpg";

var totalpages = 49;

function OpenTxtOnClick(tp){
	var cn=tp.childNodes;
	
	for(var i=0;i<cn.length;i++){
		if(cn[i].className=="OTContent"){
			if(cn[i].style.display=="none" || cn[i].style.display==""){
				cn[i].style.display="block";
				tp.getElementsByTagName("img")[0].src="items/otclose.jpg";
				tp.firstChild.blur();
			}else{
				cn[i].style.display="none";
				tp.getElementsByTagName("img")[0].src="items/otopen.jpg";
				
			}
		}
	}
}


function BuildContent(){
	if(String(navigator.appName).indexOf("Explorer",0) != -1 && String(navigator.appVersion).indexOf("MSIE 6.0",0) != -1 ){
		
		if(document.body.clientHeight <= "528"){
			document.getElementById("container").style.height = "500px";
			document.getElementById("chapter").style.height = "52px";
			document.getElementById("content").style.height = "350px";
		}else{
			document.getElementById("container").style.height = "500px";
			document.getElementById("rightside").style.height = document.body.clientHeight - 75;
			document.getElementById("chapter").style.height = "52px";
			document.getElementById("content").style.height = "350px";
		}
	}
	
	SetRightSide();
	
	if(screen_type == "wide") SetWideScreen();
	
	if(content_type == "hscorm"){
		var result = doLMSInitialize();
		startTimer();
		
		var comm = doLMSGetValue("cmi.comments");
		
		/*raw = Number(doLMSGetValue("cmi.core.score.raw"));	
		raw++;*/
		
		if(comm == ""){
			//inícializálunk
			var str = "";
		    for(i=0;i<totalpages;i++){
		        str += "0";
		    }
		    
		    doLMSSetValue("cmi.comments", str);
		    comm = str;
		    
		    doLMSSetValue("cmi.core.score.max", totalpages);
		}
		
		var pos = location.href;
	    var actpage = pos.substring(pos.lastIndexOf("/sco",location.href.length)+4, pos.length-5);
		
		if(actpage.indexOf("index", 0) != -1){
		    actpage = 0;
		}else{
		    actpage = Number(actpage);
		}
		
		var t1 = comm.substring(0, actpage);
		var t2 = comm.substring(actpage+1, comm.length);
		comm = t1 + "1" + t2;
		doLMSSetValue("cmi.comments", comm);
		
		var n = 0;
	    for(i=0;i<comm.length;i++){
		   if(comm.charAt(i) == "1") n++;
	    }
	    doLMSSetValue("cmi.core.score.raw", n);
    
	    if(n == totalpages){
	        doLMSSetValue("cmi.core.lesson_status","completed");
	    }
	}else if(content_type == "scorm"){
		loadPage();
	}
}


function doComplete(){
	if(content_type == "scorm"){
		if (doLMSGetValue("cmi.core.lesson_status") != "completed"){
			doLMSSetValue("cmi.core.lesson_status","completed");
		}
	}
	
	if(content_type != "cd") return unloadPage();
}

function SetWideScreen(){
	document.getElementById("rightside").style.border = "0px";
	
	document.getElementById("content").style.right = "40px";
	document.getElementById("content").style.width = "700px";
	
	document.getElementById("footer").style.background = "url(items/footerbgnd_big.gif) no-repeat left bottom";
	
	/*#nextbtn, #nextbtn_a, #nextbtn_img{ width:23px; height:24px;}*/
	document.getElementById("nextbtn_img").src = "items/nextbtn_big2.gif";
	document.getElementById("nextbtn").style.right = "70px";
	document.getElementById("nextbtn").style.width = "22px";
	document.getElementById("nextbtn").style.height = "24px";
	
	document.getElementById("aboutbtn").style.bottom = "7px";
}

function SetRightSide(){	
	//swf beillesztése
	var rs = new SWFObject("items/rightside.swf", "rsswf", "247", "483", "8", "#00ffff");
	
	var pos = location.href;
	var actpage = pos.substring(pos.lastIndexOf("/",location.href.length)+1, pos.length);
	var url = pos.substring(pos,pos.lastIndexOf("/",location.href.length))+"/";
	
	rs.addVariable("contentType", content_type);
	rs.addVariable("screenType", screen_type);
	rs.addVariable("rootUrl", url);
	rs.addVariable("actPage", actpage);
	rs.addVariable("stageWidth", "247");
	rs.addVariable("stageHeight", "483");
	rs.addVariable("myId", "rsswf");
	rs.addVariable("itemToLoad", rsitem);
	
	rs.addParam("scale", "noscale");
	rs.addParam("salign", "lt");
	rs.addParam("wmode", "transparent");
	rs.addParam("quality", "high");
	rs.addParam("menu", "false");
	rs.addParam("allowScriptAccess", "always");
	
	rs.write("rsflash");
}
/*
function ControllToc(){
	document.getElementById("tocbtn_a").blur();
	document.getElementById("rsswf").Change();
}*/

function NavigateToUrl(url){
	if(url != "none") location.assign(url);
}

function aboutWin(){
	document.getElementById("aboutbtn_a").blur();
	
	var lt = window;
	lt = window.open("about/about.html","aboutw","scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0,width=480,height=410,resizable=0");
	lt.window.moveTo(50,50);
	lt.focus();
}

function helpWin(){
	document.getElementById("helpbtn_a").blur();
	
	var lt = window;
	lt = window.open("help/help.html","helpw","scrollbars=1,toolbar=0,location=0,directories=0,status=0,menubar=0,width=550,height=388,resizable=0");
	lt.window.moveTo(50,50);
	lt.content_type = content_type;
	lt.focus();
}

function SetFlash(swf, w, h, posdiv, param){
	if(swf.indexOf("video_player.swf", 0) != -1){
		w = Number(w) + 15;
		h = Number(h) + 25;
	}

	var movieName = posdiv+"_Flash"
	var so2 = new SWFObject("items/loader.swf", movieName, w, h, "8", "#ffffff");
	
	var pos = location.href;
	var url = location.href.substring(pos,pos.lastIndexOf("/",location.href.length))+"/";
	
	so2.addVariable("rootUrl", url);
	so2.addVariable("swfUrl", swf);
	so2.addVariable("content", content_type);
	so2.addVariable("param", param);
	so2.addVariable("stagewidth", w);
	so2.addVariable("stageheight", h);
	so2.addVariable("myId", movieName);
	
	so2.addParam("scale", "noscale");
	so2.addParam("salign", "lt");
	so2.addParam("wmode", "transparent");
	so2.addParam("quality", "high");
	so2.addParam("menu", "false");
	so2.addParam("allowScriptAccess", "always");
	
	so2.write(posdiv);
}