function GetCookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function SetCookie(name,value,expires) {
    document.cookie = name + "=" +escape(value) + ((expires) ? ";expires=" + expires.toGMTString() : "");
}

function getLinks(){
	var el, elUsed;

	el = document.getElementsByTagName("a");
	for(i=0; i < el.length; i++){
		if(el[i].rel == "clickMap"){
			el[i].onclick = function ifonclick(){ expand(this.id); return false; };
		}
		if(el[i].rel == "popup"){
			elUsed = el[i];
			//el[i].onclick = new Function("openWindow('" + el[i].href + "','width=100,height=100,left=100,top=100'); return false;");
			elUsed.onclick = new Function("openWindow(this.href,'width=100,height=100,left=100,top=100'); return false;");
		}
		if(el[i].rel == "print_lista"){
			el[i].onclick = new Function("openWindow(this.href,'width=600,height=480,left=100,top=100'); return false;")
		}
	}
}


function expand(id){
	var elExpand, idExpand;
	
	idExpand = "ctrl_" + id;
	elId = document.getElementById(id);
	elExpand = document.getElementById(idExpand);
	cook = "ctrl_" + id;
	
	//alert(elExpand.style.display);
	
	if(elExpand.style.display == 'none'){
		elExpand.style.display = "block";
		elId.innerHTML = "<span>[-]</span>";
		elId.setAttribute("title", "Recolher links desta área.");
		elId.className = "off";
		SetCookie(cook, "block");
	} else {
		elExpand.style.display = "none";
		elId.innerHTML = "<span>[+]</span>";
		elId.setAttribute("title", "Mostrar links para conteúdo desta área.");
		elId.className = "on";
		SetCookie(cook, "none");
	}
}