// JavaScript Document
function getElem(id){
	return	document.getElementById(id);
}

// Mostrar a DIV de AJUDA
function mostrarDiv(){
	document.getElementById('dTexto').style.visibility = 'visible';

	pX = window.screen.width/2 - 200;
	pY = window.screen.height/2 - 150;


	document.getElementById('dTexto').style.left = pX + 'px';
	document.getElementById('dTexto').style.top = pY + 'px';
}

// Esconder a DIV de AJUDA
function esconderDiv(){
	document.getElementById('dTexto').style.visibility = 'hidden';
}

function replaceBR(str){

	//alert(str);
	n = (str.split("<br>")).length;
	for (i=0; i<n; i++ ){
		str = str.replace('<br>', "\r\n");
	}

	return str;
}

function nl2br( str ) {
	return str.replace(/([^>])\n/g, '$1<br />\n');
}



// VERIFICAR DADOS

//Verificar E-mail
function isReady(obj) {

	mensagem = "P.f., introduza um e-mail válido.";

	if (obj.value!=''){
		if (isEmail(obj.value) == false) {
			alert(mensagem);
			obj.focus();
			return false;
		}
	}

	return true;
}



function isEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
	return true;
	else
	return false;
}

function isProper(string) {
	if (string.search(/^\w+( \w+)?$/) != -1)
	return true;
	else
	return false;
}





