<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function carrega_imagens(){
MM_preloadImages('img/menu_empresa_on.jpg','img/menu_serviços_on.jpg','img/menu_tabelas_on.jpg','img/menu_doméstica_on.jpg','img/menu_contato_on.jpg');
}

function carrega_imagens_sub(){
MM_preloadImages('../img/menu_empresa_on.jpg','../img/menu_serviços_on.jpg','../img/menu_tabelas_on.jpg','../img/menu_doméstica_on.jpg','img/menu_contato_on.jpg');
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.title; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um e-mail válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é obrigatório.\n'; }
  } if (errors) alert('Os seguintes erros ocorreram:\n'+errors);
  document.MM_returnValue = (errors == '');
}

	/*------------------------------------------------------
	'Método: validarCampos
	'Finalidade: Validar prrenchimento do campo do formulário
	'Parametros: campo: objeto campo
	'			 validacao: tipo de validação
	'Retorno: True/False
	'Exemplo: validarCampos(document.form.campo,'Vazio')
	------------------------------------------------------*/
	function validarCampos(campo,validacao) {
		//Retira espaços em branco
		campo.value = Trim(campo.value);

		// Verifica se o campo não é vazio.
		if (validacao == 'Vazio') {
			if (campo.value == '') {
				if ((campo.type == 'text') || (campo.type == 'textarea') || (campo.type == 'password') || (campo.type == 'file'))
					alert('O campo ' + campo.title + ' não pode ser vazio.');
				else if (campo.type == 'select-one')
					alert('Selecione uma opção do campo ' + campo.title + '.');

				campo.focus();
				return false;
			}
		}
		// Verifica se o campo tem um endereço de email válido
		if (validacao == 'Email') {
			if (campo.value != '') {
				prim = campo.value.indexOf("@")
				if ((prim < 2) || (campo.value.indexOf("@",prim + 1) != -1) || (campo.value.indexOf(".") < 1) || (campo.value.indexOf(" ") != -1) || (campo.value.indexOf(".@") > 0) || (campo.value.indexOf("@.") > 0) || (campo.value.indexOf(".com.br.") > 0) || (campo.value.indexOf("/") > 0) || (campo.value.indexOf("[") > 0) || (campo.value.indexOf("]") > 0) || (campo.value.indexOf("(") > 0) || (campo.value.indexOf(")") > 0) || (campo.value.indexOf("..") > 0)) {
					alert('O campo ' + campo.title + ' deve ter um endereço de e-mail válido.');
					campo.focus();
					return false;
				}
			}
		}
		// Verifica se o campo tem um CEP formatado
		if (validacao == 'CEP') {
			if (campo.value != '') {
				if (!parseInt(campo.value.replace('-',''))) {
					alert('O campo ' + campo.title + ' deve ter um CEP no formato 00000-000.');
					campo.focus();
					return false;
				}
			}
		}

		// Verifica se o campo tem uma data válida
		if (validacao == 'Data') {
			if ((ValidaData(campo.value) != 'true') && (campo.value != '' )) {
				alert('Data - ' + (ValidaData(campo.value)));
				campo.focus();
				return false;
			}
		}		
	
		return true;
	}
	
	/*------------------------------------------------------
	'Método: Trim
	'Finalidade: Retirar espaços da string
	'Parametros: texto string
	'Retorno: texto string sem espaços
	'Exemplo: Trim(texto)
	------------------------------------------------------*/
	function Trim(str) {
		while(str.charAt(0) == " ")
			str = str.substr(1,str.length -1);
		
		while(str.charAt(str.length-1) == " ")
			str = str.substr(0,str.length-1);

		return str;
	} 
	/*------------------------------------------------------
	'Método: FormataData
	'Finalidade: Formatar Data
	'Parametros: campo: objeto formulário
	'			 teclapres: tecla pressionada
	'Retorno: String formatada (DD/MM/AAAA)
	------------------------------------------------------*/
	function FormataData(formulario,Campo,teclapres) {
		var tecla = teclapres.keyCode;
		vr = document[formulario][Campo].value;
		vr = vr.replace( ".", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( "/", "" );
		vr = vr.replace( "-", "" );
		tam = vr.length + 1;

		if ( tecla != 9 && tecla != 8 && tecla != 46 && tecla != 37 && tecla != 39){
			if ( tam > 2 && tam < 5 )
				document[formulario][Campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
			if ( tam >= 5 && tam < 10 )
				document[formulario][Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); 
		}
	}

	/*------------------------------------------------------
	'Método: ValidaData
	'Finalidade: Validar Data
	------------------------------------------------------*/
	function ValidaData(string) {
		bissexto = ''
		data = string
		if (data.length != 10) { return 'A data deve ser no formato DD/MM/AAAA' }
			else {
		 if (data.substring(0,4).indexOf('/') == 2) {
		  if (data.substring(3,8).indexOf('/') == 2) {
		   dia = data.substring(0,2)
		   mes = data.substring(3,5)
		   ano = data.substring(6,10)
		   if (mes < 0 || mes > 12) { return 'Mês inválido'; }
		   if (ano < 1890 || ano > 2100) { return 'Ano inválido'; }
		   if (mes == 01 || mes == 03 || mes == 05 || mes == 07 || mes == 08 || mes == 10 || mes == 12) { n_dias = 31 }
		   else if (mes == 04 || mes == 06 || mes == 09 || mes == 11) { n_dias = 30 }
		   else if (mes == 02) { if (ano % 4 == 0) { n_dias = 29 ; bissexto = 'SIM'} else { n_dias = 28 } }
		   if (dia < 0 || dia > n_dias) { return 'Dia inválido'; }
		   if (bissexto == '') bissexto = 'NÃO'
		   return 'true';
		  }
		 }
	  }
	}
	
	/*------------------------------------------------------
	'Método: tratarNumero
	'Finalidade: Permitir digitar somente números
	'Parametros: e: codigo keyascii
	'			 pCaracteresAdicionais: caracteres validos alem dos numeros
	'Retorno: Não há
	'Exemplo: onKeyPress="return(tratarNumero(event,pCaracteresAdicionais))"
	------------------------------------------------------*/
	function tratarNumero(e,pCaracteresAdicionais) { 
		var key = '';
		var len = len2 = 0;
		var strCheck = '0123456789' + pCaracteresAdicionais;
		var codigo = (window.Event) ? e.which : e.keyCode;
		if (codigo == 13) return true;  // Tecla Enter
		if (codigo == 8) return true;  // Tecla Backspace
		//if (e.keyCode == 46) return true;  // Tecla Delete
		if (e.keyCode == 37) return true;  // seta para esquerda
		if (e.keyCode == 39) return true;  // seta para direita

		key = String.fromCharCode(codigo);  // Pega o valor de "key"
		if (strCheck.indexOf(key) == -1)
			return false; // Nao é uma tecla valida	
		else  
			return true; // É uma tecla valida	
	}

//-->
