function elm(obj){
	return document.getElementById(obj);
}

function login(){
	if(elm('txtuser').value==''){
		alert('Tem de Preencher este campo.');
		elm('txtuser').focus();
		
		return false;
	}
	if(elm('txtsenha').value==''){
		alert('Tem de Preencher este campo.');
		elm('txtsenha').focus();
		
		return false;
	}	
	return true;
}

function newsletter(){
	if(elm('txtemail').value==''){
		alert('Tem de Preencher este campo.');
		elm('txtemail').focus();
		
		return false;
	}
	return validarEmail(elm('txtemail').value);
	
	return true;
}
function validarEmail(valor) {
	if (/^([0-9a-zA-Z]+[-._+&amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{3,6}$/.test(valor)){
		return true
	} else {
		alert("O Email está incorrecto.");
		return false;
	}
}

function pesquisa(){
	if(elm('txtpesquisa').value==''){
		alert('Tem de Preencher este campo.');
		elm('txtpesquisa').focus();
		
		return false;
	}
	
	return true;
}
function vlogin(){
	if(elm('usuario').value==""){
			alert('Tem de preencher o Nome');
			elm('usuario').select();
			elm('usuario').focus();
			
			return false;
	}
	if(elm('email').value==""){
			alert('Tem de preencher o Telefone');
			elm('telefone').select();
			elm('telefone').focus();
			
			return false;
	}
	
	return true;
}
function abrirPopup(pagina, largura, altura,yTopo,scBars) {
	var esquerda = (screen.width - largura)/2;
	var topo = (screen.height - altura)/2;
	
	if(yTopo=='' || yTopo=='undefined'){yTopo=topo};
	if(scBars==''){scBars='no'};
	
	if (typeof(remote)=="undefined") {
		remote = window.open(pagina,'','height=' + altura + ', width=' + largura + ', top=' + yTopo + ', left=' + esquerda + ',resizable=no,scrollbars=' + scBars + ',statusbar=no,menubar=no'); 
	}else{
		remote.close();
		remote = window.open(pagina,'','height=' + altura + ', width=' + largura + ', top=' + yTopo + ', left=' + esquerda + ',resizable=no,scrollbars=' + scBars + ',statusbar=no,menubar=no');
	}
}