
<!-- Codigo -->


function swap(m){
	
	document.getElementById(m).src = "http://www.futuralia.fil.pt/futuralia/framework/imagens/setablue.jpg";
	
	}
	
	
function unswap(m){
	
	document.getElementById(m).src = "http://www.futuralia.fil.pt/futuralia/framework/imagens/setagrey.jpg";
	
	}
	

function emptybox(elem){
	x= document.getElementById(elem).value 
	if((x=="Pesquisar") ||(x=="introduza o seu e-m@ail")||(x=="introduza o e-m@ail")||(x=="introduza o seu nome")||(x=="introduza o nome")){	
		document.getElementById(elem).value="";
		}
	
	}
	
function showdiv(m){
	
	document.getElementById(m).style.display = "block"
	
	}
	
function hidediv(m){
	
	document.getElementById(m).style.display = "none"
	
	}
	
function writeinbox(m){
	
	document.getElementById('pesquisabox2').value = m;
	document.getElementById('sites').style.display = "none"
	
	}
	
	
	
function searchweb(){
	
	y = document.getElementById('pesquisabox').value;
	if(y=="Pesquisar"){
		
		alert("deve definir um termo de pesquisa")
		}else{
			z = document.getElementById('pesquisabox2').value;
			if (z=="Google"){
				var w = window.open("http://www.google.pt/search?q="+y);
				w.focus();
				}
				
			if (z=="Portal FIL"){
				var w = window.open("http://www.fil.pt/irj/servlet/prt/portal/prtroot/iWeb.pesquisa?Grupo=$server_name$&keywords="+y);
				w.focus();
				}
			if (z=="Outras Feiras"){
				var w = window.open("http://www.topv.fil.pt/irj/servlet/prt/portal/prtroot/iWeb.pesquisa?Grupo=Feiras&keywords="+y);
				w.focus();
				}	
			
			if (z=="Outras feiras"){
				var w = window.open("http://www.topv.fil.pt/irj/servlet/prt/portal/prtroot/iWeb.pesquisa?Grupo=Feiras&keywords="+y);
				w.focus();
				}	
				
			if (z=="Neste site"){
				var w = window.open("http://www.fil.pt/irj/servlet/prt/portal/prtroot/iWeb.pesquisa?Grupo=Futuralia&keywords="+y);
				w.focus();
				}
			if (z=="Neste Site"){
				var w = window.open("http://www.fil.pt/irj/servlet/prt/portal/prtroot/iWeb.pesquisa?Grupo=Futuralia&keywords="+y);
				w.focus();
				}	
			}

	
	}	
	
// FORMULARIOS

 function trim(s)
	{
	  return s.replace(/^\s+|\s+$/, '');
	}

	 
	 function validate(p)
	 {		
		 var error="";
		 if (p == 1)	
		 {		 	 
			var fld = document.XmlForms.email_news;			
		 }
		 else
		 {		 
			 var fld_nome = document.XmlForms.nome;
			 var fld_nome2 = document.XmlForms.nome_friend;
			 var fld = document.XmlForms.email_friend;
			 
			 var tfld_nome = trim(fld_nome.value);		   
		  	
			if ((tfld_nome == '') || (tfld_nome == 'introduza o seu nome')){              				
				fld_nome.style.background = 'Yellow';
				error = error + "Por favor insira o seu nome.\n";
			} 
			else 
			{
				fld_nome.style.background = 'White';
			}
			
			 
			
			var tfld_nome2 = trim(fld_nome2.value); 		   
		 	if ((tfld_nome2 == '') || (tfld_nome2 == 'introduza o nome')){              
				fld_nome2.style.background = 'Yellow';
				error = error + "Por favor insira o nome do seu amigo.\n";
			}
			else 
			{
				fld_nome2.style.background = 'White';
			}
			 		 
		 }
					 
		 
		 var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
		 var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
		 var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
		    
		if (!emailFilter.test(tfld)) {              //test email for illegal characters
			fld.style.background = 'Yellow';
			error = error + "Por favor insira um email valido.\n";
		} else if (fld.value.match(illegalChars)) {
			fld.style.background = 'Yellow';
			error = error + "O email que inseriu contém caracteres inválidos.\n";
		} else {
		      fld.style.background = 'White';
		   }
		   
				   
		   
		   if (error != '')
			{
				alert(error)
				return;			
			}
			
		 var url = '';	
		 if (p == 1)	
		 {		 	 
			url  = "http://www.futuralia.fil.pt/irj/servlet/prt/portal/prtmode/preview/prtroot/pcd!3aportal_content!2fportais!2fiweb.associacoes!2fiweb.aip!2fpt.iweb.feiras.feiras!2fwww.futuralia.fil.pt.futuralia!2fwww.futuralia.fil.pt.inscricaonews?sap-config-mode=true&url_email="+document.XmlForms.email_news.value
			SendEmail(url);			
			document.XmlForms.email_news.value = 'introduza o seu e-m@ail';
		 }
		 else
		 {		 
			url  = "http://devinteraip.aip.pt/irj/servlet/prt/portal/prtmode/preview/prtroot/pcd!3aportal_content!2fportais!2fiweb.associacoes!2fiweb.aip!2fpt.iweb.feiras.feiras!2fwww.futuralia.fil.pt.futuralia!2fwww.futuralia.fil.pt.sugestao?sap-config-mode=true&url_nome="+document.XmlForms.nome.value+"&url_nome_friend="+document.XmlForms.nome_friend.value+"&url_email_friend="+document.XmlForms.email_friend.value
			SendEmail(url);			
			document.XmlForms.email_friend.value = 'introduza o e-m@ail';
			document.XmlForms.nome.value = 'introduza o seu nome';
			document.XmlForms.nome_friend.value = 'introduza o nome';
		 }					    
}

function SendEmail(url)
{
var left = Math.round(screen.width/3);
var top =40;
var options = "height=150,width=315,location=no,menubar=no,resizable=no,scrollbars=No,status=yes,titlebar=no,toolbar=no,screenX=" + left + ",screenY=" + top + ",top=" + top + ",left=" + left;
window.open(url,"SendEmail",options);


}
	
	
	//FORMULARIOS end