

function format(value,format)
{
	value = value.replace(/\D/g,"");
	var result="";
	
	if(format.length < value.length)
		return value;
	
	for(i=0,j=0;(i<format.length)&&(j<value.length);i++)
	{
		var ch = format.charAt(i) ;
		if(ch == '#')
		{
			result += value.charAt(j++);
			continue;
		}
		result += ch;
	}
	return result;
}

/*
	função para remover espaços no inicio e fim da string
*/
function trim(str){
	return str.replace(/^\s*|\s*$/g,"");
}

/*
	funcao de validação de email
*/
function validaEmail(Email){
	  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Email)) {
	    return true;
	  }
	  else {
		return false;
	  }
	}

function validarFormNull(oForm){
		var i;
	
		for(i=0;i<oForm.elements.length;i++)
			{
			if((oForm.elements[i].value == "") && (oForm.elements[i].title != ""))
			{
				alert("Campo " + oForm.elements[i].title + " deve ser preenchido!");
				oForm.elements[i].select();
				return false;
			}
		}
		
		if(!validaEmail(oForm.Email.value))
		{
			
				alert("Preencha o e-mail  corretamente!");
				return false;
		}
		
		if(oForm.Telefone.value.length<13)
		{
				alert("Preencha o telefone  corretamente!");
				return false;
		}
		
		if(oForm.Mensagem.value.length<15)
		{
				alert("Campo Dúvida deve ter no minimo 15 caracteres !");
				return false;
		}
		
		return true;
}
	

	
function submitFormMsg()
	{
		var oForm = document.getElementById('formMsg');
	
		if(!validarFormNull(oForm))
		{
			return;
		}
	
		if(!validaEmail(oForm.sEmail.value))
		{
			alert("Preencha o e-mail corretamente!");
			return;
		}
		
		oForm.submit();
}
function abrirCorretorOnLine(){	
		window.open("http://www.incortel.com.br/corretor-on-line/corretor.php?id=&clique=","","width=450,height=350");
}