	
	//the var that contains the scope
	var scope = "Global";
	
	//Switches the scope
	function switchScope() {
		if (scope == "Global") {
			scope = "Detail";	
		} else {
			scope = "Global";
		}
	}
	
	//sets the scope to global
	function setScopeToGlobal() {
		scope = "Global";
	}
	
	//sets the scope to detail
	function setScopeToDetail() {
		scope = "Detail";
	}
	
	//sets the scope to explanation
	function setScopeToExplanation() {
		scope = "Explanation";
	}
	
	//applies the scope on the elements
	function applyScopeOnElements() {
		var body = document.getElementsByTagName('body')[0];
		ShowElementsInScope(body);
	}
	
	//this function walk trough all the nodes, and sets the visibilty, depending on scope
	function ShowElementsInScope(node) {
  		if (node.nodeType == 1) { 
  			//if this node is a element node, check its scope.
  			var elementScope = node.getAttribute('scope');
  			var elementVisible = node.getAttribute('visible');
  			
  			//if the elements scope == scope or the elementscope = all
  			//then show this element
  			if (elementScope != null) {
	  			if (elementScope == scope || elementScope == "All") {
					if (elementVisible == 'true') {
						node.style.display = '';
					} 
				} else {
					//hide this element
					node.style.display = 'none';
				}
			}
 		}
  		if (node.childNodes != null) { 
    		for (var i=0; i < node.childNodes.length; i++) { 
     			ShowElementsInScope(node.childNodes.item(i)); 
    		} 
  		}
	}
