function trocaIdioma(){
	window.location = 'sistema/trocar_idioma/index.php?idioma='+idioma+'&url='+url;
}

function trocaIdiomaInterno(){
	window.location = base+'sistema/trocar_idioma/index.php?idioma='+idioma+'&url='+url;
}

function esqueciSenha(msg){
	if(document.getElementById('email').value==""){
		document.getElementById('email').focus();
		alert(unescape(msg));
		return false;
	}else{
		document.forms[0].action = "sistema/recuperasenha/index.php";
		document.forms[0].submit();		
	}
}

function alertLocation(msg,url){
	alert(unescape(msg));
	window.location = url;
}

function alertComum(msg){
	alert(unescape(msg));
}

function confereCamposLogin(msg){
	if(document.getElementById('email').value==""){
		alert(unescape(msg));
		document.getElementById('email').focus();
		return false;
	}
}

function editContatos(idForm){
	document.forms[idForm].action = "edit.php";
	document.forms[idForm].submit();
}

function viewContatos(idForm){
	document.forms[idForm].action = "view.php";
	document.forms[idForm].submit();
}

function viewFotos(idForm){
	document.forms[idForm].action = "view.php";
	document.forms[idForm].submit();
}

function editFotos(idForm){
	document.forms[idForm].action = "edit.php";
	document.forms[idForm].submit();
}

function delFotos(idForm){
	document.forms[idForm].action = "del.php";
	document.forms[idForm].submit();
}

function confirmaContatos(msg,idForm){
	var confirma = confirm(unescape(msg));
	if (confirma == true){
		document.forms[idForm].action = "confirma.php";
		document.forms[idForm].submit();
	}else{
		window.location = '../agenda/';
	}
}

function confirma(msg,idForm,urlSim,urlNao){
	var confirma = confirm(unescape(msg));
	if (confirma == true){
//            alert(urlSim + "?id=" + idForm);
//            window.location = urlSim + "?id=" + idForm;

		document.forms[idForm].action = urlSim;
		document.forms[idForm].submit();
	}else{
		window.location = urlNao;
	}
}

//function confirma2(msg,idForm, idFoto, urlSim,urlNao){
//	var confirma = confirm(unescape(msg));
//	if (confirma == true){
//
//            window.location = urlSim + "?idFoto=" + idFoto + "&idAlbum=" + idForm;
//
////		document.forms[idForm].action = urlSim;
////		document.forms[idForm].submit();
//	}else{
//		window.location = urlNao;
//	}
//}

function verificaUsuario(msg1,msg2,msg3){
	if (document.getElementById('email').value == "" || document.getElementById('senha').value == ""){
		alert(unescape(msg1));
		return false;
	}else{
		/*parte1 = document.getElementById('email').value.indexOf("@");
		parte2 = document.getElementById('email').value.indexOf(".");
		parte3 = document.getElementById('email').value.length;
		if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
			document.getElementById('senha').value = "";
			document.getElementById('email').value = "";
			alert(unescape(msg2));
		return false;
		}else{*/
			if (document.getElementById('senha').value.length <= 5){
				document.getElementById('senha').value = "";
				alert(unescape(msg3));
				return false;
			}else{
				document.forms[0].action = 'insert.php';
				document.forms[0].submit();
				return true;
			}
		//}
	}
}

c=0
du="";
   function abreMenu(dv,n){
	for(i=1;i<=n;i++){
	   if(i==dv ){
		   if(du!=dv){
		      document.getElementById('submenu'+i).style.display="inline";
			   du=dv
			}else{
			   du=""
			   document.getElementById('submenu'+i).style.display="none";
			}
	   }else{
		     document.getElementById('submenu'+i).style.display="none";				  					
	   }				
	}
}


function MascaraMoeda(objTextBox, e){
    if (e.which == 44 || e.keyCode == 44){
        alert("Utilize um ponto como separador.");
    }else{
        //48 57
        if((e.which >= 48 && e.which <= 57) || e.which == 8 || e.which == 46){
            return true;
        }else{
            if((e.keyCode >= 48 && e.keyCode <= 57) || e.keyCode == 8 || e.keyCode == 46){
                return true;
            }else{
                alert("Utilize apenas numeros.");
                return false;
            }
        }
        
    }
    return false;
}

function limitaCaracteres(textarea, limit, infodiv){
	var text = textarea.value; 
	var textlength = text.length;
	var info = document.getElementById(infodiv);
	if(textlength > limit){
		info.innerHTML = 'Utilize '+limit+' caracteres';
		textarea.value = text.substr(0,limit);
		return false;
	}else{
		info.innerHTML = 'Restam '+ (limit - textlength) +' catacteres';
		return true;
	}
}
