/*--------------------------------------------------------------------
JAVASCRIPT  "index" - Camara Municipal de Soure

Version: 	1.0 - 2006/2007
author: 		Burocratik (alexandre gomes)
email: 		alex@burocratik.com
website: 	http://www.burocratik.com
-----------------------------------------------------------------------*/
/* =NOTICIAS: coloca-los todos fora do stage do on.load
-----------------------------------------------------------------------*/
var W3CDOM = (document.getElementsByTagName && document.createElement);
if (W3CDOM){
	var link = document.createElement('link');
	link.setAttribute("rel", "stylesheet");
	link.setAttribute("type", "text/css");
	link.setAttribute("href", "scripts/index-javascript.css");
	link.setAttribute("media", "screen");
	document.getElementsByTagName("head")[0].appendChild(link);
}

/* =EVENTOS: roll over do fundo
-----------------------------------------------------------------------*/
function overEventos(){
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	if (!document.getElementById("secHeaderContent")) return false; 
	var elem=getElementsByClassName(document, "p", "comOver");
	for (var i=0; i<elem.length; i++ ) {			
		elem[i].onmouseover=function(){
			this.style.backgroundColor="#ffffff"			
		}
		elem[i].onmouseout=function(){
			this.style.backgroundColor="transparent"
		}
	}	
}

/* =NOTICIAS: abrir e fechar das noticias
-----------------------------------------------------------------------*/
function fVisivel(id) {
  var divs = document.getElementsByTagName("div");
  for (var i=0; i<divs.length; i++ ) {
    if (divs[i].className.indexOf("txtRestante") == -1) continue;
    if (divs[i].getAttribute("id") == id) {
      addClass("add",divs[i],"show"); //adiciona nova class, esta funcao esta em geral.js
    } else {
	 	addClass("remove",divs[i],"show"); //remove nova class, esta funcao esta em geral.js
    }
  }
}

// =Desactivar o botao ao clicar
function fBotao(clicado){
	var links = getElementsByClassName(document, "a", "linkNoticia");
	for (var i=0; i<links.length; i++ ) {
		if (links[i] == clicado) {
			addClass("add",links[i],"linkOff"); 
	   } else {
			addClass("remove",links[i],"linkOff"); 
    	}
	}
}

function iniciarLinks() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	var links = getElementsByClassName(document, "a", "linkNoticia");
	for (var i=0; i<links.length; i++ ) {
   	var sectionId = links[i].getAttribute("href").split("#")[1];
    	if (!document.getElementById(sectionId)) continue;
		links[i].destination = sectionId;
    	links[i].onclick = function() {
			fBotao(this);
      	fVisivel(this.destination);
      	return false;
    	} 
	}
}

/* =Preparar Eventos
-----------------------------------------------------------------------*/
addLoadEvent(overEventos);
addLoadEvent(iniciarLinks);





