var toggled = false;

var toggled1 = false;
var toggled2 = false;

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	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;
}

function toggleConstructbodies(hide){
	if(hide == "true"){
		var x;
		var constructBodies = getElementsByClass("span_constructbody");
		
		if(toggled)
			for(x in constructBodies)
				constructBodies[x].style.display='';
		else
			for(x in constructBodies)
				constructBodies[x].style.display='none';
		toggled = !toggled;	
	}
	if (document.getElementById('modulebody') != null){
		document.getElementById('modulebody').style.display='';
	}
}

function toggleImportDetails(){
		var x;
		var constructBodies = getElementsByClass("span_importdetail");
		
		if(toggled)
			for(x in constructBodies)
				constructBodies[x].style.display='';
		else
			for(x in constructBodies)
				constructBodies[x].style.display='none';
		toggled = !toggled;
}

function togglePaths(hide){
	if(hide == "true"){
		var x;
		var constructBodies = getElementsByClass("td_path");
		
		if(toggled)
			for(x in constructBodies)
				constructBodies[x].style.display='';
		else
			for(x in constructBodies)
				constructBodies[x].style.display='none';
		toggled = !toggled;	
	}
}

function toggleHideNotes(){
	var x;
	var constructBodies = getElementsByClass("span_showhidenote");
	for(x in constructBodies){
		toggleElement(constructBodies[x]);
	}
}

function toggleElement(element){
	if(element.style.display=='none')
		element.style.display='';
	else
		element.style.display='none';
}

function toggle(elementName){
	var element = document.getElementById(elementName);
	toggleElement(element);
}

function mp_init(listName){
	if(listName != 'Group')
//		if (document.getElementById('span_groups')!=null)
			document.getElementById('span_groups').style.display='none';
	if(listName != 'Testcase')
//		if (document.getElementById('span_testcases'!=null))
			document.getElementById('span_testcases').style.display='none';
	if(listName != 'Module Parameter')
//		if (document.getElementById('span_parameters')!=null)
			document.getElementById('span_module parameters').style.display='none';
}

function init(listName){
	toggleHideNotes();
	if(listName != 'Group')
		document.getElementById('span_groups').style.display='none';
	if(listName != 'Function')
		document.getElementById('span_functions').style.display='none';
	if(listName != 'Type')
		document.getElementById('span_types').style.display='none';
	if(listName != 'Signature')
		document.getElementById('span_signatures').style.display='none';
	if(listName != 'Testcase')
		document.getElementById('span_testcases').style.display='none';
	if(listName != 'Altstep')
		document.getElementById('span_altsteps').style.display='none';
	if(listName != 'Template')
		document.getElementById('span_templates').style.display='none';
	if(listName != 'Constant')
		document.getElementById('span_constants').style.display='none';
	if(listName != 'Module Parameter')
		document.getElementById('span_module parameters').style.display='none';
	if(listName != 'External Function')
		document.getElementById('span_external functions').style.display='none';
	if(listName != 'External Constant')
		document.getElementById('span_external constants').style.display='none';

}