window.onload=paginaCarregada;

function clickIE4(){
if (event.button==2){
return false;}}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
return false;}}}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;}
document.oncontextmenu=new Function("return false");
document.onselectstart=new Function("return false");
document.ondragstart=new Function("return false");

document.onselectstart=new Function("return false");
document.ondragstart=new Function("return false");
document.onmouseover=hidestatus;
document.onmouseout=hidestatus;
document.onblur=hidestatus;
var imagens = new Array("images/onde_s.jpg","images/servicos_s.jpg","images/inicio_s.gif","images/links_s.gif","images/contacto_s.jpg");

function pre_load_imagens() {
 if(!document.pre_imges) document.pre_imges=new Array();
 for(var x=0; x<imagens.length; x++) {
     document.pre_imges[x]=new Image();
     document.pre_imges[x].src=imagens[x];
 }
}
function hidestatus(){
window.status='FotoVal, a fotografia no seu melhor';
return true
}

function displayText( sText ) {
        $("displayArea").innerHTML = sText;
}

///limpa formulario
function limpa_formulario() {
        $("nome").value = '';
        $("email").value = '';
        $("telefone").value = '';
        $("assunto").value = '';
        $("mensagem").value = '';
		$("valida_humano").value = '';
}
function limpa_formulario_livro() {
        $("nome").value = '';
        $("email").value = '';
        $("localizacao").value = '';
        $("mensagem").value = '';
		$("valida_humano").value = '';
}
///fim limpa formulario
function carrega(pagina){
    ajaxGet("inc/sel_pag_aj.php?" + pagina,$("maincontent"),true,true,null)
}
function envia_dados(){
	ajaxGet("inc/contacto.php",$("maincontent"),true,false,obten_dados())
}
function envia_dados_livro(){
	ajaxGet("inc/livro_assina.php",$("maincontent"),true,false,obten_dados_livro())
}
function obten_dados(){
    var dados;
	dados ="nome="+$F("nome");
	dados +="&email="+$F("email");
	dados +="&assunto="+$F("assunto");
	dados +="&mensagem="+$F("mensagem");
	dados +="&telefone="+$F("telefone");
	dados +="&valida_humano="+$F("valida_humano");
    dados +="&copia="+$F("copia");
	dados +="&enviar=Enviar"
	//alert(dados);
    return dados;
}
function obten_dados_livro(){
    var dados;
	dados ="nome="+$F("nome");
	dados +="&email="+$F("email");
	dados +="&localizacao="+$F("localizacao");
	dados +="&mensagem="+$F("mensagem");
	dados +="&votacao="+$F("votacao");
	dados +="&valida_humano="+$F("valida_humano");
	dados +="&enviar=Enviar"
	//alert(dados);
    return dados;
}
function paginaCarregada(){
	pre_load_imagens();
	add_menu();
	initLightbox();
}
function add_menu(){
	var botao,i;
	botao=$('topright').getElementsByTagName('a');
    for(i=0;i<botao.length;i++)
    {
		campo=botao[i].href.split("?");
		if (campo[1]!=undefined){
		  botao[i].onclick = function(){
			 var endereco; 
			 endereco = this.href.split("?");
			 carrega(endereco[1]);
			 return false;
		  }
		}
    }
	
	botao=$('leftcol').getElementsByTagName('a');
    for(i=0;i<botao.length;i++)
    {
		var relAttribute = String(botao[i].getAttribute('rel'));
		//alert(relAttribute);
		if(relAttribute!="rss"){
		   botao[i].onclick = function(){
			 var endereco; 
			 endereco = this.href.split("?");
			 carrega(endereco[1]);
			 return false;
		   }
		}
    }
}
function add_eventos_todos(){
	var botao,i;
	botao=$('maincontent').getElementsByTagName('a');
    for(i=0;i<botao.length;i++)
    {
		//alert(botao[i].href);
		botao[i].onclick = function(){
			 var endereco; 
			 endereco = this.href.split("?");
			 carrega(endereco[1]);
			 return false;
		}
    }
}
function add_inicio(){
	var botao;	
	botao=$('contactar_inicio');
	botao.onclick = function(){
	  var endereco; 
	  endereco = this.href.split("?");
	  carrega(endereco[1]);
	  return false;
	}
	botao=$('servicos_inicio');
	botao.onclick = function(){
	  var endereco; 
	  endereco = this.href.split("?");
	  carrega(endereco[1]);
	  return false;
	}
}
function add_livro(){
	var botao;	
	botao=$('assinar-livro-link');
	botao.onclick = function(){
	  var endereco; 
	  endereco = this.href.split("?");
	  carrega(endereco[1]);
	  return false;
	}
}
function add_livro_confirma(){
	var botao;	
	botao=$('ver-assinaturas');
	botao.onclick = function(){
	  var endereco; 
	  endereco = this.href.split("?");
	  carrega(endereco[1]);
	  return false;
	}
}


var whichimage=0;
var pixeldelay=1000;
var ciclo;
function slideit(){
if (brows) $("slide").filters[0].apply()
$("slide").src=imageholder[whichimage].src
if (brows) $("slide").filters[0].play()
whichimage=(whichimage<slideimages.length-1)? whichimage+1 : 0
ciclo=setTimeout("slideit()",slidespeed+pixeldelay);
}

function addSmiley(destino,emoticon)
{
destino.value=destino.value+emoticon;
destino.focus();
return;
}
function liberta(){
try{
    GUnload();
}catch(e){
}
}