var IE4 = false;
var NS6 = false;
if (document.all){IE4 = true;}else if (document.getElementById){NS6 = true;}


/** -- PESQUISA -- **/

	/** Pesquisa Rapida **/
	function submitPR(obj){
		obj.target='';
		obj.action="mods.php?name=Pesquisa&file=resPesquisa";
		obj.submit();
	}
	function submitFuncionario(obj){
		obj.target='';
		obj.action="mods.php?name=Funcionarios";
		obj.submit();
	}
	/** Pesquisa Avancada **/
	function submitPA(obj){
		obj.target='';
		obj.action="mods.php?name=Pesquisa&file=resPesquisa";
		obj.submit();
	}
	/** Pesquisa por Referencia (IdAngariacao)**/
	function submit_IDANG(obj, alertMSG){
		//obj.target='';
		var value = trim(obj.idAngariacao.value);
		if(value.length > 0){
			obj.action="mods.php?name=Pesquisa&file=resPesquisa";
			obj.submit();
		}
		else{
			alert(alertMSG);
			obj.idAngariacao.select();
			return false;
		}
	}

	/** executa nova pesquisa com 'Ordernar Por:' no resultado da pesquisa  **/
	function submitOrderBy(obj){
		obj.target='';
		//obj.action="mods.php?name=HCPesquisa&file=resPesquisa";
		obj.submit();
	}

	/** submit QuerComprar **/
	function submitQC(obj){
		if(trim(obj.nomefrom.value).length == 0){
			alert("Insira o seu Nome.");
			obj.nomefrom.focus();
			return true;
		}
		if( (trim(obj.emailfrom.value).length == 0) && (trim(obj.telef.value).length == 0) && (trim(obj.telem.value).length == 0)){
			alert("Insira o Email ou um contacto telefónico válido.");
			obj.emailfrom.focus();
			return false;
		}
		if(obj.idTipo.selectedIndex == 0){
			alert("Escolha o Tipo de Imóvel.");
			obj.idTipo.focus();
			return true;
		}
		if(obj.idDistrito.selectedIndex == 0){
			alert("Escolha o Distrito.");
			obj.idDistrito.focus();
			return true;
		}
		if(obj.idConcelho.selectedIndex == 0){
			alert("Escolha o Concelho.");
			obj.idConcelho.focus();
			return true;
		}

		obj.target='';
		obj.action = "mods.php?name=Compra&file=querComprar&op=2";
		obj.submit();
	}

	/** submit QuerVender **/
	function submitQV(obj){
		if(trim(obj.nomefrom.value).length == 0){
			alert("Insira o seu Nome.");
			obj.nomefrom.focus();
			return true;
		}
		if( (trim(obj.emailfrom.value).length == 0) && (trim(obj.telef.value).length == 0) && (trim(obj.telem.value).length == 0)){
			alert("Insira o Email ou um contacto telefónico válido.");
			obj.emailfrom.focus();
			return false;
		}
		if(obj.idTipo.selectedIndex == 0){
			alert("Escolha o Tipo de Imóvel.");
			obj.idTipo.focus();
			return true;
		}
		if(obj.idDistrito.selectedIndex == 0){
			alert("Escolha o Distrito.");
			obj.idDistrito.focus();
			return true;
		}
		if(obj.idConcelho.selectedIndex == 0){
			alert("Escolha o Concelho.");
			obj.idConcelho.focus();
			return true;
		}
	
		obj.target='';
		obj.action="mods.php?name=Venda&file=querVender&op=2";		
		obj.submit();
	}

	/** submit Recrutamento **/
	function submitRec(obj){
		if(trim(obj.nomefrom.value).length == 0){
			alert("Insira o seu Nome.");
			obj.nomefrom.focus();
			return false;
		}
		if(trim(obj.morada.value).length == 0){
			alert("Insira a sua Morada.");
			obj.morada.focus();
			return false;
		}
		if( (trim(obj.emailfrom.value).length == 0) && (trim(obj.telem.value).length == 0)){
			alert("Insira pelo menos um contacto: o Email ou o Telemóvel.");
			obj.emailfrom.focus();
			return false;
		}

		//obj.target='';
		obj.submit();
	}

	/** submit CONTACTO: Enviar Pedido de Contacto **/
	function submitContacto(obj){
		if(trim(obj.nomefrom.value).length == 0){
			alert("Insira o seu Nome.");
			obj.nomefrom.focus();
			return true;
		}
		if( (trim(obj.emailfrom.value).length == 0) && (trim(obj.telef.value).length == 0) && (trim(obj.telem.value).length == 0)){
			alert("Insira o Email ou um contacto telefónico válido.");
			obj.emailfrom.focus();
			return false;
		}
		obj.target='';
		obj.action = "mods.php?name=Contactos&file=contactos&op=2";
		obj.submit();
	}



	/** dado o idDistrito preenche a select com os concelhos **/
	function showConcelhos(objectSelect, obj) {
	   while (objectSelect.form.idConcelho.length > 1) {
	        objectSelect.form.idConcelho.remove(objectSelect.form.idConcelho.options.length-1);
	    }
	    if (objectSelect.form.idDistrito.value > 0) {
	    	obj.target='busca';
			obj.action="feed.php?id=jvConcelhos&iddistrito=" + objectSelect.form.idDistrito.value;
			obj.submit();
	    }
	    else{
	       	objectSelect.form.idConcelho.options.length = 0;
	       	objectSelect.form.idConcelho.options[0] = new Option('', '');
	       	if (objectSelect.form.idFreguesia){
	       		objectSelect.form.idFreguesia.options.length = 0;
	       		objectSelect.form.idFreguesia.options[0] = new Option('', '');
	       	}
	    }
	}
	function showConcelhosPR(obj) {
		objConc = document.getElementById("idConcelho[]");
		objDist = document.getElementById("idDistrito[]");
		while (objConc.length > 1) {
			objConc.remove(objConc.options.length-1);
		}
	    if (objDist.value > 0) {
	    	obj.target='busca';
			obj.action="feed.php?id=LFR_jvConcelhos&iddistrito=" + objDist.value+"&destino=idConcelho[]";
			obj.submit();
	    }
	    else{
	       	objConc.options.length = 1;
	       	//objConc.options[0] = new Option('', '');
	    }
	}

	/** dado o idDistrito preenche a select dos consultores com os concelhos **/
	function showConcelhosC(objectSelect, obj) {
	    while (objectSelect.form.idConcelhoC.length > 1) {
	        objectSelect.form.idConcelhoC.remove(objectSelect.form.idConcelhoC.options.length-1);
	    }
	    if (objectSelect.form.idDistritoC.value > 0) {
	    	obj.target='busca';
			obj.action="feed.php?id=jvConcelhos&destino="+objectSelect.form.id+".idConcelhoC&iddistrito=" + objectSelect.form.idDistritoC.value;
			obj.submit();
	    }
	    else{
	       	objectSelect.form.idConcelhoC.options.length = 0;
	       	objectSelect.form.idConcelhoC.options[0] = new Option('', '');
	    }
	}

	/** dado o idDistrito preenche a select do Recrutamento com os concelhos **/
	function showConcelhosRecrutamento(objectSelect, obj) {
	    while (objectSelect.form.idConcelho.length > 1) {
	        objectSelect.form.idConcelho.remove(objectSelect.form.idConcelho.options.length-1);
	    }
	    if (objectSelect.form.idDistrito.value > 0) {
	    	obj.target='busca';
			obj.action="feed.php?id=LFR_jvConcelhosRecrutamento&destino="+objectSelect.form.id+".idConcelho&iddistrito=" + objectSelect.form.idDistrito.value;
			obj.submit();
	    }
	    else{
	       	objectSelect.form.idConcelho.options.length = 0;
	       	objectSelect.form.idConcelho.options[0] = new Option('', '');
	    }
	}

	/** dado o idConcelho preenche a select com as freguesias **/
	function freguesias(objectSelect, obj) {
	   while (objectSelect.form.idFreguesia.length > 1) {
	        objectSelect.form.idFreguesia.remove(objectSelect.form.idFreguesia.options.length-1);
	    }
	    if (objectSelect.form.idConcelho.value > 0) {
	    	obj.target='busca';
			obj.action="feed.php?id=jvFreguesias&idconcelho=" + objectSelect.form.idConcelho.value;
			obj.submit();
	    }
	    else{
	       	objectSelect.form.idFreguesia.options.length = 0;
	       	objectSelect.form.idFreguesia.options[0] = new Option('', '');
	    }
	}
	
	/** dado o idConcelho preenche a select com as freguesias **/
	function allFreguesias(objectSelect, obj) {
	   while (objectSelect.form.idFreguesia.length > 1) {
	        objectSelect.form.idFreguesia.remove(objectSelect.form.idFreguesia.options.length-1);
	    }
	    if (objectSelect.form.idConcelho.value > 0) {
	    	obj.target='busca';
			obj.action="feed.php?id=jvAllFreguesias&destino="+obj.id+".idFreguesia&idconcelho=" + objectSelect.form.idConcelho.value;
			obj.submit();
	    }
	    else{
	       	objectSelect.form.idConcelho.options.length = 0;
	       	objectSelect.form.idConcelho.options[0] = new Option('', '');
	    }
	}

	/** dado o idDistrito preenche a select com os concelhos das Agências**/
	function showConcelhosAgencia(objectSelect, obj) {
		while (objectSelect.form.idConcelho.length > 1) {
			objectSelect.form.idConcelho.remove(objectSelect.form.idConcelho.options.length-1);
		}
		if (objectSelect.form.distrito.value > 0) {
			obj.target='busca';
			obj.action="feed.php?id=jvConcelhosAgencia&iddistrito=" + objectSelect.form.distrito.value;
			obj.submit();
		}
		else{
			objectSelect.form.idConcelho.options.length = 0;
			objectSelect.form.idConcelho.options[0] = new Option('', '');
			if (objectSelect.form.idFreguesia){
				objectSelect.form.idFreguesia.options.length = 0;
				objectSelect.form.idFreguesia.options[0] = new Option('', '');
			}
		}
	}

	/** preenche com as tipologias nos forms de pesquisa **/
	function tipologias(obj) {
	    var oOption;
	    
	    obj.idTipologia0.disabled = true;
	    obj.idTipologia1.disabled = true;
	    while (obj.idTipologia0.length > 1) {
	       obj.idTipologia0.remove(obj.idTipologia0.options.length-1);
	    }
	    while (obj.idTipologia1.length > 1) {
	       obj.idTipologia1.remove(obj.idTipologia1.options.length-1);
	    }
	    if (obj.idTipo.value ==	11)	{
	        obj.idTipologia0.disabled	=	false;
	        obj.idTipologia1.disabled	=	false;
	        
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T1","3");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T2","5");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T3","7");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T4","9");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option(">= T5","11");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T1","3");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T2","5");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T3","7");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T4","9");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option(">= T5","11");
	    }
	    
	    if (obj.idTipo.value ==	12)	{
	        obj.idTipologia0.disabled	=	false;
	        obj.idTipologia1.disabled	=	false;
	        
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T1","3");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T2","5");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T3","7");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T4","9");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option(">= T5","11");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T1","3");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T2","5");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T3","7");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T4","9");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option(">= T5","11");
	    }
	    
	    if (obj.idTipo.value ==	1) {
	        obj.idTipologia0.disabled	=	false;
	        obj.idTipologia1.disabled	=	false;
	        
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T1","3");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T2","5");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T3","7");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option("T4","9");
	        obj.idTipologia0.options[obj.idTipologia0.options.length] = new Option(">= T5","11");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T1","3");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T2","5");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T3","7");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option("T4","9");
	        obj.idTipologia1.options[obj.idTipologia1.options.length] = new Option(">= T5","11");
	    }
	}

	/** dado o idDistrito preenche a select com os concelhos **/
	function allConcelhos(objectSelect, obj) {
	    while (objectSelect.form.idConcelho.length > 1) {
	        objectSelect.form.idConcelho.remove(objectSelect.form.idConcelho.options.length-1);
	    }
	    if (objectSelect.form.idDistrito.value > 0) {
	    	obj.target='busca';			
			obj.action="feed.php?id=jvAllConcelhos&destino="+obj.id+".idConcelho&iddistrito=" + objectSelect.form.idDistrito.value;
			obj.submit();
	    }
	    else{
	       	objectSelect.form.idConcelho.options.length = 0;
	       	objectSelect.form.idConcelho.options[0] = new Option('', '');
	       	if (objectSelect.form.idFreguesia){
	       		objectSelect.form.idFreguesia.options.length = 0;
	       		objectSelect.form.idFreguesia.options[0] = new Option('', '');
	       	}
	    }
	}
	
	/**  mostra/esconde blocos de pesquisa  **/
	function showPane(showMenuID, showContentID, hideMenuID, hideContentID){
		document.getElementById(hideMenuID).style.display = 'none';
		document.getElementById(hideContentID).style.display = 'none';
		document.getElementById(showMenuID).style.display = 'block';
		document.getElementById(showContentID).style.display = 'block';
	}

	function showPaneG(aDivsMenu, menuSelec){
		for (i=0;i<aDivsMenu.length;i++){
			obj = document.getElementById(aDivsMenu[i][0]);
			obj.style.display = 'none';
			obj = document.getElementById(aDivsMenu[i][1]);
			obj.style.display = 'none';
		}
		if (menuSelec == 0 || menuSelec == 1){
			obj = document.getElementById(aDivsMenu[menuSelec][0]);
			obj.style.display = 'block';
			obj = document.getElementById(aDivsMenu[menuSelec][1]);
			obj.style.display = 'block';
		}else if (menuSelec == 2){
			obj = document.getElementById("contentA");
			obj.style.display = 'block';
			obj = document.getElementById("contentC");
			obj.style.display = 'block';
			obj = document.getElementById("menuC");
			obj.style.display = 'block';
		}else if (menuSelec == 3){
			obj = document.getElementById("contentA");
			obj.style.display = 'block';
			obj = document.getElementById("contentD");
			obj.style.display = 'block';
			obj = document.getElementById("menuD");
			obj.style.display = 'block';
		}
		//for (i=0;i<aDivsMenu.length;i++){
		//	obj = document.getElementById(aDivsMenu[i][0]);
		//	obj.style.display = 'none';
		//	obj = document.getElementById(aDivsMenu[i][1]);
		//	obj.style.display = 'none';
		//}
		//obj = document.getElementById(aDivsMenu[menuSelec][0]);
		//obj.style.display = 'block';
		//obj = document.getElementById(aDivsMenu[menuSelec][1]);
		//obj.style.display = 'block';
	}

	/**  mostra/esconde blocos na pesquisaA em Preco/Financiamento  **/
	function showPanePA(showContentID, hideContentID, setOFFid, setONid, radioCheck){
		radioCheck.checked = true;
		setOFFid.className = 'txt10';
		setONid.className = 'txt10_red';
		document.getElementById(hideContentID).style.display = 'none';
		document.getElementById(showContentID).style.display = 'block';
	}

	/**  limpa os valores do Preco ao escolher Financiamento  **/
	function clearTABvaluesPrice(obj){
		obj.precomin.value="";
		obj.precomax.value="";
	}
	/**  limpa os valores do Financiamento ao escolher Preco  **/
	function clearTABvaluesFinance(obj){
		obj.v_entrada.value="";
		obj.v_prest.value="";
		obj.v_anos.value="";
	}

	/** Favoritos **/
	function addToFavoritos(obj, idImovel, idLoja, idEmpresa){
		obj.action="/mods.php?name=Favoritos&file=addFavorito&idImovel="+idImovel+"&idLoja="+idLoja+"&idEmpresa="+idEmpresa;
		obj.target='trata';
		obj.submit();
	}

	function remFavorito(obj, idImovel, idLoja, idEmpresa, mensagem){
		if(confirm(mensagem)){
		//if(confirm("Deseja remover este imóvel da sua lista de favoritos?")){
			obj.action="/mods.php?name=Favoritos&file=remFavorito&idImovel="+idImovel+"&idLoja="+idLoja+"&idEmpresa="+idEmpresa;
			obj.target='trata';
			obj.submit();
		}
	}
	function remFavoritoReloadPage(obj, idImovel, idLoja, idEmpresa, mensagem){
		if(confirm(mensagem)){
		//if(confirm("Deseja remover este imóvel da sua lista de favoritos?")){
			//obj.action="mods.php?name=Favoritos&file=remFavoritoReloadPage&idImovel="+idImovel+"&idLoja="+idLoja+"&idEmpresa="+idEmpresa;
			obj.action="mods.php?name=Favoritos&file=remFavoritoReloadPage&idImovel="+idImovel+"&idLoja="+idLoja+"&idEmpresa="+idEmpresa;
			obj.target='trata';
			obj.submit();
		}
	}

/**  -- FICHA DO IMOVEL  -- **/

	var openedDIV = -1;
	var openTable = "<table border=0 cellspacing=0 cellpadding=0 width='100%'><tr><td width=8 height=9><img src='/i/box/c1.jpg' width=8 height=9></td><td height=7 style='background: URL(/i/box/px_top.jpg) repeat-x top'><img src='/i/s.gif' width=1 height=7></td><td width=8 height=9><img src='/i/box/c2.jpg' width=8 height=9></td></tr><tr><td style='background: URL(/i/box/px_left.jpg) repeat-y left'><img src='/i/s.gif' width=8 height=1></td><td align=center>";
	var endTable = "</td><td style='background: URL(/i/box/px_right.jpg) repeat-y right'><img src='/i/s.gif' width=8 height=1></td></tr><tr><td width=8 height=9><img src='/i/box/c3.jpg' width=8 height=9></td><td height=7 style='background: URL(/i/box/px_bottom.jpg) repeat-x bottom'><img src='/i/s.gif' width=1 height=7></td><td width=8 height=9><img src='/i/box/c4.jpg' width=8 height=9></td></tr></table>";
	var loading = openTable + "<br><br><br>a carregar&nbsp;<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width=60 height='10' id='index3'><PARAM NAME=movie VALUE='/i/swf/wait.swf'><PARAM NAME=quality VALUE=high><param name='wmode' value='transparent'><EMBED src='/i/swf/wait.swf' width=60 height=10 quality=high bgcolor=#FFFFFF NAME='index3' TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer' wmode='transparent'></EMBED></OBJECT><br><br><br>" + endTable;

	/**  mostra DIV com info do Imovel  **/
	function showInfoImovel(objDIV, idLoja, canalNovidades){
		if(openedDIV != -1){
			document.getElementById(""+openedDIV+"_A").innerHTML = loading;
			document.getElementById(""+openedDIV+"").style.display='block';		
			document.getElementById(""+openedDIV+"_A").style.display='none';
			objDIV.style.display='none';		
			document.getElementById(""+objDIV.id+"_A").style.display='block';
			openedDIV = objDIV.id;
		}
		else{
			openedDIV = objDIV.id;
			document.getElementById(""+objDIV.id+"_A").innerHTML = loading;
			document.getElementById(""+objDIV.id+"_A").style.display='block';		
			objDIV.style.display='none';
		}

		document.imovel_form.action="feed.php?id=jvImovel&idI=" + objDIV.id+"&idL=" + idLoja+"&cn="+canalNovidades;
		document.imovel_form.submit();
	}

	/**  esconde DIV com info de uma Noticia ou Imóvel  **/
	function hideInfoImovel(objDIV){
		document.getElementById(objDIV).style.display='block';
		document.getElementById(""+objDIV+"_A").style.display='none';
		openedDIV = -1;
	}

/**  -- NOTICIAS  -- **/
	/**  mostra DIV com info da Noticia  **/
	function showNoticia(objDIV, idLoja){
		if(openedDIV != -1){
			document.getElementById(""+objDIV.id+"_A").innerHTML = loading;
			document.getElementById(""+openedDIV+"").style.display='block';		
			document.getElementById(""+openedDIV+"_A").style.display='none';
			objDIV.style.display='none';		
			document.getElementById(""+objDIV.id+"_A").style.display='block';
			openedDIV = objDIV.id;
		}
		else{
			openedDIV = objDIV.id;
			document.getElementById(""+objDIV.id+"_A").innerHTML = loading;
			document.getElementById(""+objDIV.id+"_A").style.display='block';		
			objDIV.style.display='none';
		}

		document.noticia_form.action="feed.php?id=jvNoticia&idN=" + objDIV.id+"&idL=" + idLoja;
		document.noticia_form.submit();
	}

/** -- MISCELLANEOUS -- **/

	/** restringe a insercao de valores apenas do tipo numero [0..9] **/
	function tstSoNum(e) {
		if(e.ctrlKey){
			return false;
		}
		if(e.shiftKey){
			return false;
		}
		if(NS6){
			var tc = e.charCode;
			if(tc==0 || (tc >= 48 && tc <= 57)){
				return true;
			}
		}
		else{
			var tc = e.keyCode;
			if(tc==0 || tc==13 || (tc >= 48 && tc <= 57)){
				return true;
			}
		}
		return false
	}
	
	function cleanForm(f){
		for(i=0; i<f.elements.length;i++){
			if (f.elements[i].type == "checkbox") f.elements[i].checked = false;
			if (f.elements[i].type == "text") f.elements[i].value = "";
			if (f.elements[i].type == "select-one") f.elements[i].selectedIndex = 0;
			if (f.elements[i].type == "radio") f.elements[i].checked = false;
			if (f.elements[i].type == "textarea"){ f.elements[i].value = ""};
			if (f.elements[i].type == "hidden"){}
		}
	}

	/** Remove espaços no inicio e no fim da string. Remove espaços consecutivos e substitui por um espaço. **/
	function trim(inputString) {
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Check for spaces at the beginning of the string
	      retValue = retValue.substring(1, retValue.length);
	      ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Check for spaces at the end of the string
	      retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	   }
	   return retValue;
	}
	
	/** Valida um endereço de email **/
	function email_validate(email){
		em_val = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
		if(em_val.test(email)) return true
		else return false
	}
