// przechowuje indeks aktualnie przegladanej sekcji (umozliwia to wyswietlenie aktualnego menu po 3s.)
currentMenuIndex=-1;

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

//createLoggingPane();

function hideAll() {
	MM_changeProp('nav5-1','','style.display','none','DIV');	
	MM_changeProp('nav5-2','','style.display','none','DIV');	}

var Id;
var hideInfoTimeout;

function hideMenu(count) {
	Id = window.setTimeout("hideAllModules("+count+");",3000);
	//log(Id);
  
}

// ustawia zmienna globalna currentMenuIndex, przechowuje ona indeks aktualnie przegladanej sekcji
function setCurrentMenuIndex(index) {
	currentMenuIndex = index;
}

// pokazuje aktualne menu (dla aktualnie przegladanej sekcji)
function showCurrentMenu(count) {
	if (currentMenuIndex != -1) {
		Id = window.setTimeout("showModules("+currentMenuIndex+","+count+");",3000);
	} else {
		hideMenu(count);
	}
}

function showMenu() {
	//alert(Id);
  	if (Id) window.clearTimeout(Id);
}

function showModules(index,count){
	//alert(index);
	showMenu();
	for(i=0;i<count;i++){
		var elem = document.getElementById('sections:'+i+':section_div');
			if(i==index) {
				elem.style.display = 'block';
			} else {
				elem.style.display = 'none';
		}
	}
}
		
function hideAllModules(count){
	for(i=0;i<count;i++){
		var elem = document.getElementById('sections:'+i+':section_div');
		elem.style.display = 'none';
	}
}

function showInfo(index,count) {
//alert ('info'+index);
	if (hideInfoTimeout) window.clearTimeout(hideInfoTimeout);
	for (i=0;i<count;i++) {
		if (i!=index) {
			MM_changeProp('home:mod_desc:'+i+':info','','style.display','none','DIV');
		} else {
			MM_changeProp('home:mod_desc:'+i+':info','','style.display','block','DIV');
		}
	}
	MM_changeProp('info_dummy','','style.display','none','DIV');
}

function hideInfo(count){
	hideInfoTimeout = window.setTimeout("hideAllInfo("+count+");",5000);
}

function hideAllInfo(count) {
//alert ('info'+index);
	for (i=0;i<count;i++) {
		MM_changeProp('home:mod_desc:'+i+':info','','style.display','none','DIV');
	}
	MM_changeProp('info_dummy','','style.display','none','DIV');
}

function change_image(image, newSrc) {
    image.src = newSrc;
}

function font_size_plus() {
    var children = getElementsByTagAndClassName(null, null, "display:module-content")
    forEach(children, function(element) {
        //        if (!some(["h1", "h2", "h3"], function(item) {
        //            return item == element.tagName.toLowerCase()
        //        })) {
        var fontSizeStyle = getStyle(element, "font-size")
        var fontSize = new Number(fontSizeStyle.substring(0, fontSizeStyle.length - 2))
        element.style.fontSize = fontSize + 2 + "px"
        //        }
    })
}

function font_size_minus() {
    var children = getElementsByTagAndClassName(null, null, "display:module-content")
    forEach(children, function(element) {
        var fontSizeStyle = getStyle(element, "font-size")
        var fontSize = new Number(fontSizeStyle.substring(0, fontSizeStyle.length - 2))
        element.style.fontSize = fontSize - 2 + "px"
    })
}
		
		
function showCorrectAnswer(correct,answer,index){
	//alert(correct);		
	//alert(answer);
	//alert(answer.style);

	var parentId = 'answer_list['+index+']';
	
	//var parentId = 'bottom_div['+index+']';
	
	var answers = getElementsByTagAndClassName('a', null, document.getElementById(parentId));
			
	if(correct){
		answer.className = 'goodanswer';
		document.getElementById('correct_answer_div['+index+']').style.display='block';
    } else {
    	for (i=0;i<answers.length;i++){
    		if(answers[i].className == 'correct_answer'){
    			answers[i].className = 'goodanswer';
    		}
    		//alert('asda');
    		//alert(answers[i].onclick);
    	}
		answer.className = 'wronganswer';
		document.getElementById('incorrect_answer_div['+index+']').style.display='block';
	}
	
	document.getElementById('answer_comments['+index+']').style.display='block';
	document.getElementById('bottom_div['+index+']').style.display='block';
	
	
	for (i=0;i<answers.length;i++){
		answers[i].onclick = function(){return false;}
	}	
}



