<!--

function abrir_fechar_divs(name,name2){
	if (document.getElementById(name).style.display=="none"){
		document.getElementById(name).style.display="block";
		if (name2!=''){
			document.getElementById(name2).innerHTML="(Fechar)";
		}
		
		guarda_estado_div(name,'block');

		}
	else {
		if (name2!=''){
			document.getElementById(name2).innerHTML="(Abrir)";
		}
		document.getElementById(name).style.display="none";

		guarda_estado_div(name,'none');
		}
}

//login dos utilizadores do Site
function formlogin() {

//email validação
email_valor=document.loginutilizador.email_entrada.value;
	if (document.loginutilizador.email_entrada.value!=''){
					
		email=/^.+@.+\..{2,3}$/;
		if (!(email.test(document.loginutilizador.email_entrada.value))) { 
	       alert('Erro: E-mail incorrecto.');
	       return(false);
		
	}
	}else{
		      alert('Erro: O seu E-mail não preenchido.');
		      return(false);
	}

//verificar senha
senha=document.loginutilizador.senha.value;
	if (senha=='') {
		alert('Erro: A sua Senha não preenchido.');
		return(false);
	}
				
document.loginutilizador.submit();
document.loginutilizador.email_entrada.value='';
document.loginutilizador.senha.value='';
}


function formnewsletter() {

email='';
nome='';
morada='';
codpostal='';
cidade='';
newsletter=0;
agendacul=0;
smsalert=0;

//verificar nome
nome=document.registoutilizador.nome.value;
	if (nome=='') {
		alert('Erro: O seu Nome não preenchido.');
		return(false);
	}
				
//email validação
email_valor=document.registoutilizador.email.value;
	if (document.registoutilizador.email.value!=''){
					
		email=/^.+@.+\..{2,3}$/;
		if (!(email.test(document.registoutilizador.email.value))) { 
	       alert('Erro: E-mail incorrecto.');
	       return(false);
		
	}
	}else{
		      alert('Erro: O seu E-mail não preenchido.');
		      return(false);
	}

termosvalido='';
termosvalido=document.registoutilizador.termosvalido.value;
if (termosvalido!='1') {
	if (!document.registoutilizador.termos.checked) {
		alert('Erro: Termos não aceites.');
		return(false);
	}
}
morada=document.registoutilizador.morada.value;
codpostal=document.registoutilizador.codpostal.value;
cidade=document.registoutilizador.cidade.value;
sexo=document.registoutilizador.sexo.value;
data_nasc=document.registoutilizador.data_nasc.value;
profissao=document.registoutilizador.profissao.value;

if (termosvalido!='1') {
	document.registoutilizador.email.value='';
	document.registoutilizador.nome.value='';
	document.registoutilizador.morada.value='';
	document.registoutilizador.codpostal.value='';
	document.registoutilizador.cidade.value='';
	document.registoutilizador.data_nasc.value='';
}
registar(nome,email_valor,morada,codpostal,cidade,sexo,data_nasc,profissao);
}



function formsenha() {

//verificar termos e senhas
senha_antiga='';
senha1='';
senha2='';

//verificar senha antiga
senha_antiga=document.registoutilizador.senha_antiga.value;
	if (senha_antiga=='') {
		alert('Erro: Senha Antiga não preenchida.');
		return(false);
	}

//verificar senha1
senha1=document.registoutilizador.senha1.value;
	if (senha1=='') {
		alert('Erro: Senha não preenchida.');
		return(false);
	}

//verificar senha2
senha2=document.registoutilizador.senha2.value;
	if (senha2=='') {
		alert('Erro: Senha de Confirmação preenchida.');
		return(false);
	}


//verificar se senhas iguais
if (senha1!=senha2) {
	alert('Erro: Senhas não são iguais.');
	return(false);
}

altsenha(senha1,senha_antiga);
}






//***********************
//***********************
function daily(pageURL,fotow,fotoh) {
	fotow=Math.min(fotow+40,.95*screen.availWidth)
	fotoh=Math.min(fotoh+40,.95*screen.availHeight)
	window.open(pageURL,"","top="+10+",left="+10+",toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width="+fotow+",height="+fotoh+">");
}

function pop(oque,w,h) {
  poppage=popup('','Referendo',w,h,0,0,0,1,0,0,1);
  poppage.document.write("<HTML><HEAD><TITLE>CMMealhada_Popup</TITLE></HEAD><BODY>");
  poppage.document.write(oque);
  poppage.document.write("</BODY></HTML>");
}

function popup(url,windowName,width,height,directories,location,menubar,scrollbars,status,toolbar,resizable){
  browser_width=window.screen.availWidth;
  browser_height=window.screen.availHeight;
  if (width==-1&&height==-1){
    width=browser_width;
    height=browser_height;
  }
  var acima=(browser_height-height)/2
  var aesqerda=(browser_width-width)/2
  var features =
  'width='        + width +
  ',height='      + height +
  ',directories=' + directories +
  ',location='    + location +
  ',menubar='     + menubar +
  ',scrollbars='  + scrollbars +
  ',status='      + status +
  ',toolbar='     + toolbar +
  ',resizable='   + resizable+
  ',top='         + acima +
  ',left='        + aesqerda+
  ',screenX='     + aesqerda +
  ',screenY='     + acima;
  return window.open(url,windowName,features)
}
//****************************************************************************
function borderit(which,color){//if IE 4+ or NS 6+
  if (document.all||document.getElementById){
    which.style.borderColor=color
  }
}
rector=1
a=1
stopit=0
var the_timeout
function init(which){
  clearTimeout(the_timeout)
  stopit=0
  shake=which
  shake.style.left=0
  shake.style.top=0
}

function rattleimage(){
  if ((!document.all&&!document.getElementById)||stopit==1) return
  if (a==1){
    shake.style.top=parseInt(shake.style.top)+rector
  }else if (a==2){
    shake.style.left=parseInt(shake.style.left)+rector
  }else if (a==3){
    shake.style.top=parseInt(shake.style.top)-rector
  }else{
    shake.style.left=parseInt(shake.style.left)-rector
  }
  if (a<4){
    a++
  }else{
    a=1
  }
  the_timeout=setTimeout("rattleimage()",100)
}

function stoprattle(which){
  stopit=1
  which.style.left=0
  which.style.top=0
}

//****************************************************************************
var x,y,a,b,timer,thisbox,isbox,urlimg
var posleftvorher

var box

if (document.layers) {
	var left_pos=".left=";
	var top_pos=".top=";
	var doc="document.";
	var stl="";
}

if (document.all) {
	var left_pos=".pixelLeft=";
	var top_pos=".pixelTop=";
	var doc="";
	var stl=".style";
}

function openbox(thisbox) {
	isbox = thisbox 
		if(document.layers) {
			box = document.popupbox
			box.visibility="visible"
			document.popupbox.document.write("<img src='"+thisbox+"'>")
			document.popupbox.document.close()
			document.popupbox.left=x+25
			document.popupbox.top=y
		}

		if(document.all) {
			box = document.all.popupbox.style
			box.visibility="visible"
			popupbox.innerHTML="<img src='"+thisbox+"'>"
			eval(doc+"popupbox"+stl+left_pos+(x+25))
			eval(doc+"popupbox"+stl+top_pos+y)		
			timer=setTimeout("openbox(isbox)",50)
		}
	
}
//*******************************************************************
function closebox(){
		clearTimeout(timer)
		box.visibility="HIDDEN"
}

function handlerMM(e){
//	x = (document.layers) ? e.pageX : event.clientX
//	y = (document.layers) ? e.pageY : event.clientY
}
if (document.layers){
	document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
//*******************************************************************
function showByShadow(object,shadow,x,y) {
    if (document.layers && document.layers[object]) {
        document.layers[object].left = document.layers[shadow].pageX + x;
        document.layers[object].top = document.layers[shadow].pageY + y;
        document.layers[object].visibility = 'visible';
    }else if (document.all){
        document.all[object].style.visibility = 'visible';
        if (document.all[object].myFlag == null) {
            document.all[object].style.posLeft = document.all[object].offsetLeft + x;
            document.all[object].style.posTop = document.all[object].offsetTop + y;
    		document.all[object].myFlag = true;
        }
    }
}

function hide(object) {
    if (document.layers && document.layers[object])
        document.layers[object].visibility = 'hidden';
    else if (document.all)
        document.all[object].style.visibility = 'hidden';
}

//***********************
//***********************
//***********************Cinema***********************//

function mostra_filme(id,controlo) {
  document.lista.acao.value='cinema.php';
  document.lista.id.value=id;
  document.lista.par.value=controlo;
  document.lista.submit();
}