/* valida */
function valida() {
   submitOK="true";
   if (!valido(document.getElementById("mym").value)){
     alert("Email Inválido");
     submitOK="false";
   }
   if (submitOK=="false")
   {
    return false
   }
}

function valido(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

/* Target blank nao valida como XHML */

function init() {
	createExternalLinks();
}

function createExternalLinks() {
    if(document.getElementsByTagName) {
        var anchors = document.getElementsByTagName('a');
        for(var i=0; i<anchors.length; i++) {
            var anchor = anchors[i];
            if(anchor.getAttribute("href") && anchor.getAttribute('rel')=='co-worker') { // <-- É necessário inserir rel="co-worker neighbor" no link
                anchor.target = '_blank';
                var title = anchor.title + ' (Este link abre uma nova janela)'; // <-- Insere este texto no final do Title do link
                anchor.title = title;
            }
        }
    }
}

function addEvent(obj, evType, fn){
    if(obj.addEventListener){
        obj.addEventListener(evType, fn, false);

        return true;

    } else if (obj.attachEvent){
        var r = obj.attachEvent('on'+evType, fn);

        return r;

    } else {
        return false;

    }
}
addEvent(window, "load", init);



/* Popups */
var newwindow;
function poptastic(url)
{
	newwindow=window.open(url,'name','height=350,width=350,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
	if (window.focus) {newwindow.focus()}
}

	function submitEmail() {
			var form = document.frontendForm;
			// do field validation
			if (form.email.value == "" || form.youremail.value == "") {
				alert( 'Tem de introduzir correctamente o seu e-mail do seu amigo.' );
				return false;
			}
			return true;
		}
	

