// =========================================================================
//                RightColumn Contents behavior Javascripts
// =========================================================================
function setLinkTags() {
	// links put in the boxFocus sent from the page content
	var atags = document.getElementsByTagName("a");
	var str_link = "";
	var linkToFocusRemoveExists = "false";
	var linkToFocusAnchorRemoveExists = "true";
	for(var t=0; t<atags.length; t++) {
		if(atags[t].className == "linkToFocus") { // if the class is linkToFocus
			var str_source = trim( atags[t].innerHTML );				
			str_link += "<p><a href='" + atags[t].href  +  "'" + 
						" target='" + atags[t].target + "'" + ">" + 
							str_source + 
						"</a></p>";
			linkToFocusRemoveExists = "true";
		}
	}
	// links put in the boxFocus from the paragraphe titles
	var h3tags = document.getElementsByTagName("h3");
	var str_anchor = "";
	for(var t=0; t<h3tags.length; t++) {
		var str_source = trim( h3tags[t].innerHTML );
		var pathname = window.location.pathname;
		var filename = pathname.substring(pathname.lastIndexOf("/")+1, pathname.length);
		
		if(h3tags[t].className != "linkToFocusRemove") { // if the class is not linkToFocusRemove
			str_anchor += "<p><a href='" + filename + "#" + t + "'>" + str_source + "</a></p>";
			// adding an anchor to the h3 tags
			h3tags[t].innerHTML = "<a name='" + t + "'>" + str_source + "</a>";
			linkToFocusAnchorRemoveExists = "false";
		}
	}
	if(h3tags.length != 0 && linkToFocusAnchorRemoveExists == "false"){
		var blocBoxFocusId = "blocBoxFocusAnchor";
		var boxFocus = document.getElementById(blocBoxFocusId);
		boxFocus.innerHTML += str_anchor ;
		blocBoxFocusId = "boxFocusAnchor";
		boxFocus = document.getElementById(blocBoxFocusId);
		boxFocus.style.display = "block";
	} else { // don't display the hole area
		blocBoxFocusId = "boxFocusAnchor";
		boxFocus = document.getElementById(blocBoxFocusId);
		boxFocus.style.display = "none";
	}
	
	if(linkToFocusRemoveExists == "true"){
		blocBoxFocusId = "blocBoxFocusLink";
		boxFocus = document.getElementById(blocBoxFocusId);
		boxFocus.innerHTML += str_link ;
		blocBoxFocusId = "boxFocusLink";
		boxFocus = document.getElementById(blocBoxFocusId);
		boxFocus.style.display = "block";
	} else { // don't display the hole area
		blocBoxFocusId = "boxFocusLink";
		boxFocus = document.getElementById(blocBoxFocusId);
		boxFocus.style.display = "none";
	}
	
	if( fileOnly(window.location.href).indexOf("jeu") >= 0) { // currentFilename got from the menu.jsp where it has been loaded
	
		boxFocusAnchorId = document.getElementById("boxFocusAnchor");
		boxFocusLinkId = document.getElementById("boxFocusLink");
		boxFocusAnchorId.style.display="none";
		boxFocusLinkId.style.display="none";
		boxFocusId = document.getElementById("boxFocus");
		boxFocusId.style.display = "block";
		boxFocusId.style.width="200px";
		boxFocusId.style.height="500px";
		boxFocusId.style.position="relative";
		boxFocusId.style.textAlign="right";
		boxFocusId.style.background = "#fff url(static/images/jeu/cadeaux.gif) no-repeat bottom right";
	}
}

