// JavaScript Document

function prepareRevenez(){
	if(!document.getElementById) return false;
	if(!document.getElementsByTagName) return false;
	
	var elem = document.getElementById("rev_btns");
	if(elem){
		// loop through all webRevenez buttons
		var buttons = elem.getElementsByTagName("a");
		for (var i=0; i<buttons.length; i++){
			// when button is clicked
			buttons[i].onclick = function(){
				// send which button to insert function
				insertRevenez(this);
				return false;
			}
		}
	}
}

function insertRevenez(mylink){
	if(!document.getElementById) return false;
	if(!document.getElementById("webrevenez")) return false;
	
	// "hijack" the href attribute of the selected button
	var module = mylink.getAttribute("href");
	
	// get the webrevenez element (where the iframe will be inserted
	var elem = document.getElementById("webrevenez");
	
	// code for <iframe>
	var flashdata = "<a href=\"#\" id=\"hide_wr\" class=\"hider\">CLOSE</a><br style=\"clear:both\" /><iframe src=\"" + module + "\" scrolling=\"no\" frameborder=\"0\" width=\"690\" height=\"440\"></iframe>";	
	
	// insert iframe element into DOM
	elem.innerHTML = flashdata;
	
	// jump to webrevenez area of page
	location.hash = "wr";
	
	var hide_btn = document.getElementById("hide_wr");
	hide_btn.onclick = function(){
		emptyWebRev();
		return false;
	}
	
	return false;
}


function emptyWebRev(){
	if(!document.getElementById) return false;	
	if(!document.getElementById("webrevenez")) return false;
	var wr = document.getElementById("webrevenez");
	wr.innerHTML = "";
}

// on load event, get the button behaviors ready
addLoadEvent(prepareRevenez);