
function  validarForm (campo , enviarNome) { //campo tem as IDs dos campos obrigatorios
    tamanho =  campo.length;
    var camp = campo;
	
    for(i=0;i<camp.length ; i++) {
        if(document.getElementById(camp[i]).value=='' || document.getElementById(camp[i]).value==null) {
            window.alert("Preencha o campo "+ camp[i].toUpperCase() );
            document.getElementById(enviarNome).value = "Confirmar Correções";
            document.getElementById(camp[i]).style.border = "1px solid #C75F4E";
            document.getElementById(camp[i]).focus();
            return false;
        }
    }
	
    document.getElementById(enviarNome).disabled = true;
    document.getElementById(enviarNome).value = "Processando dados... "
    document.getElementById(enviarNome).style.backgroundColor = "#F1F2F1";
    document.getElementById(enviarNome).style.border = "1px solid #F1F2F1";
    return true;
}

function  validarFormulario (campo) { //campo tem as IDs dos campos obrigatorios
    tamanho =  campo.length;
    var camp = campo;
	
    for(i=0;i<camp.length ; i++) {
        if(document.getElementById(camp[i]).value=='' || document.getElementById(camp[i]).value==null) {
            window.alert("Preencha o campo "+ camp[i].toUpperCase() );
            document.getElementById(camp[i]).style.border = "1px solid #C75F4E";
            document.getElementById(camp[i]).focus();

            return false;
        }
    }
	
    return true;
}


function validarEmail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){
            return true;
        }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
            return true;
        }
    }else{
        return false;
    }
}


function listaOver (elemento , cor) {
    elemento.style.backgroundColor = cor;
    elemento.style.color = "#1A7BA8";
	
}

function listaOut (elemento , cor) {
    elemento.style.backgroundColor = cor;
    elemento.style.color = "";
}

function aguarde () {
    document.getElementById("enviar").disabled = true;
    document.getElementById("enviar").value = "Aguarde..."
}

function excluir() {
    var x = confirm("Você realmente deseja excluir ?");  return x;
}

function rollOver (elemento) {
    elemento.style.backgroundColor='#e2e2e2';
    elemento.className = "nomeClass";
}

function rollOut (elemento) {
    elemento.style.backgroundColor='';
}

function ampliarImagem (arquivo , legenda) {
    var divId = 'exibeImg';
    document.getElementById(divId).innerHTML = "<img src='img.php?img="+
    arquivo+
    "&l=390&a=300' alt='Ampliada' /><br /><span class='obs'>"+
    legenda+
    "</span>";
    return false;
}

function voltar () {
    history.go(-1);
}

function showHidden(id) {

    var div = document.getElementById(id);
    
    if(div.style.display=="none")
        div.style.display = "block";
    else
        div.style.display = "none";
    
    return false;

}

function focarPrimeiroInput() {
    var bFound = false;
    for (f=0; f < document.forms.length; f++)  {
        for(i=0; i < document.forms[f].length; i++)  {
            if (document.forms[f][i].type != "hidden") {
                if (document.forms[f][i].disabled != true) {
                    document.forms[f][i].focus();
                    bFound = true;
                }
            }
      
            if (bFound == true)
                break;
        }
        if (bFound == true)
            break;
    }
}

function submitLogin() {
    if(document.getElementById("login_nome").value=="" || document.getElementById("login_senha").value=="") {
        alert("Preencha corretamente o email e sua senha");
        return false;
    } else
        return true;
}


function amplFoto(foto , localId , largura , altura , texto) {

    $("#"+localId).fadeOut("slow" , function () {
        document.getElementById(localId).innerHTML = "ampliando...";
        document.getElementById(localId).innerHTML = "<img src='img.php?img="+foto
        +"&l="+largura
        +"&a="+altura
        +"' alt=" +texto+"/>"
        +"<br />"+texto+"<br />";
        
        $("#"+localId).fadeIn(900);

    });
   
    return false;
}

function hideThis(element) {
    $(element).hide(900);
}


function jsShow(elementoId ,hideElementId){
    $("#"+elementoId).show(1000);
    $("#"+hideElementId).hide(1000);
}

function eco(valor , idDestino) {
    document.getElementById(idDestino).value = valor;
}



