function muda(over, obj) {obj.src='/imagem/menu_over_'+over+'.png';}
function voltaMuda(over, obj) {obj.src='/imagem/menu_'+over+'.png';}

function troca(imagem, obj) {	obj.src=imagem+'_over.gif';}
function voltaTroca(imagem, obj) {	obj.src=imagem+'.gif';}



function formataString(campo, mask, event) {
       key = event.keyCode;
       if(key=='0')
       key = event.which;


       if(key==8 || key==39 || key==37 || key==46 || key==9)
               return true;
       string = campo.value;
       i = string.length;

       var maskAux = '';
       k=0;
       for(a=0;a<mask.length;a++) {
               if(mask.charAt(a) == '§' || mask.charAt(a) == '!') {
                       if(campo.value.charAt(a)) {
                               maskAux += campo.value.charAt(k);
                       }
               }
               else if(mask.charAt(a) == '#') {
                       if(campo.value.charAt(a) && verificaNumero(campo.value.charAt(a))) {
                               maskAux += campo.value.charAt(k);
                       }
               }
               else {

                       if(campo.value.charAt(a) && campo.value.charAt(a) == mask.charAt(a)) {
                               maskAux += mask.charAt(a);
                       }
                       else if(campo.value.charAt(a)) {
                               maskAux += mask.charAt(a);
                               k--;
                       }
               }
               k++;
       }
       if (i < mask.length) {
               if (mask.charAt(i) == '#') {
                       if(!verificaNumeroPress(campo,event))
                       {
                               return false;
                       }
                       maskAux += String.fromCharCode(key);
                       /*if(mask.charAt(i+1) != '!' && mask.charAt(i+1) != '§' && mask.charAt(i+1) != '#') {
                         maskAux += mask.charAt(i+1);
                       } */
                       var a = i+1;
                       while(a<mask.length && mask.charAt(a) != '!' && mask.charAt(a) != '§' && mask.charAt(a) != '#') {
                               maskAux += mask.charAt(a);
                               a++
                       }
               }
               else if(mask.charAt(i) == '!' || mask.charAt(i) == '§') {

                       maskAux += String.fromCharCode(key);
                       var a = i+1;
                       while(a<mask.length && mask.charAt(a) != '!' && mask.charAt(a) != '§' && mask.charAt(a) != '#') {
                               maskAux += mask.charAt(a);
                               a++
                       }
                       
               }
               else {
										if(mask.charAt(i)==String.fromCharCode(key)) {
										maskAux += String.fromCharCode(key);
										var a = i+1;
										while(a<mask.length && mask.charAt(a) != '!' && mask.charAt(a) != '§' && mask.charAt(a) != '#') {
											maskAux += mask.charAt(a);
											a++
											}
										}
                       else if((i+1)<mask.length && mask.charAt(i+1) == "#") {
                               if(verificaNumeroPress(campo,event)) {
                                       maskAux += mask.charAt(i) + String.fromCharCode(key);
                               }
                       }
                       else if((i+1)<mask.length && (mask.charAt(i+1) == "§" ||mask.charAt(i+1) == "!" )) {
                               maskAux += mask.charAt(i) + String.fromCharCode(key);
                       }
               }
               campo.value=maskAux;
               try {
///event.keyCode = 0;
			event.preventDefault();
		}
		catch (e) {
//event.charCode = 0;
			event.returnValue = false;
		}

	}
	else return false;
}

function verificaNumeroPress(campo,event) {
code = event.keyCode;
if(code=='0') {
code = event.charCode;
}

codeAux = 0;
if(arguments[2]) {
codeAux = arguments[2].charCodeAt(0);
}

if ( (code < 48 && code != codeAux && code != 8 && code!=39 && code!=37 && code != 9 && code != 46) || (code > 57 ) ) {
try {
///event.keyCode = 0;
event.preventDefault();
}
catch (e) {
//event.charCode = 0;
event.returnValue = false;
}
return false;

}
else {
return true;
}
}
function verificaNumero(valor) {
code = valor.charCodeAt(0);
if ( (code < 48 ) || (code > 57 ) ) {
return false;
}
return true;
}


function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
	if(ok.indexOf(e.charAt(i))<0){ 
	return (false);}	
	} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);	} 
	}
}

function limpar_alertas(l) {
  var objmensagem = document.getElementById("alerta_nome");
  objmensagem.innerHTML = "";
	var objmensagem = document.getElementById("alerta_email");
  objmensagem.innerHTML = "";
	return false;
	
}

function check_form(f) {	
	if(f.nome.value.length < 1 ){
		var obj = document.getElementById("alerta_nome");
		obj.innerHTML = "Favor preencher o seu nome";
		f.nome.focus(); // put the prompt in the name field 
		return false;
	}
	if(f.email.value.length < 1 ){
		var obj = document.getElementById("alerta_email");
		obj.innerHTML = "Favor informar seu email";
		f.email.focus(); // put the prompt in the name field 
		return false;
	}
	if(!check_email(f.email.value)){
		var obj = document.getElementById("alerta_email");
		obj.innerHTML = "E-mail inválido";
		f.email.focus();
		return false;
	}	
	if(f.mensagem.value.length < 1 ){
		var obj = document.getElementById("alerta_mensagem");
		obj.innerHTML = "Favor escrever sua mensagem";
		f.mensagem.focus(); // put the prompt in the name field 
		return false;
	}
	
}