$(document).ready(function() {

    $(".telefone").mask("(99) 9999-999");


    $(".pointer").mouseover(function() {
        $(this).css("cursor", "pointer");
    });

    $("#form_busca").click(function () {
        if($(this).val()=="buscar") {
            $(this).val("");
        }
    });

    $('#amplFotoDiv').scrollFollow( {
        speed :1000,
        offset :60
    });
    


});
function getURL(href) {
    document.location.href= href;
}

function getUrl(href) {
    getURL(href);
}

function hide(element) {
    $(element.id).hide("slow");
}


function down(element) {
    $(element).slideDown("slow");
}

function up(element) {
    $(element).slideUp("slow");
}


function amplFoto(foto , legenda) {
    $("#cobreTudo").css("width", $(document).width());
    $("#cobreTudo").css("height", $(document).height());
    $("#cobreTudo").css("opacity", "0");
    $("#cobreTudo").css("display", "block");
    $("#cobreTudo").animate( {
        opacity :0.5,
        borderWidth :1
    }, 600);

    $("#amplFotoDiv").slideDown(1000);
    $("#amplFoto").html("<img src='img.inc.php-"+foto+"-600-800' alt='"+legenda+"' /> <br> " + legenda);
// $("#superConteudo").html(conteudoPagina);
}

function amplFoto2(foto , legenda) {
    $("#cobreTudo").css("width", $(document).width());
    $("#cobreTudo").css("height", $(document).height());
    $("#cobreTudo").css("opacity", "0");
    $("#cobreTudo").css("display", "block");
    $("#cobreTudo").animate( {
        opacity :0.5,
        borderWidth :1
    }, 600);

    $("#amplFotoDiv").slideDown(1000);
    $("#amplFoto").html("<br><br><img src='"+foto+"' width=300 alt='"+legenda+"' /> <br><br> <span style='color: black;'>" + legenda + "</span>");
// $("#superConteudo").html(conteudoPagina);
}

function fecharFoto() {
    $("#cobreTudo").animate( {
        opacity :0,
        borderWidth :1
    }, 1000, function() {
        $("#cobreTudo").hide();
    });

    $("#amplFotoDiv").slideUp(1000);

}




function limparSelect(selectId) {
    $("#" + selectId).html("");
}

function addListValue(inputComValor, targetSelect) {
    var valor = $("#" + inputComValor).attr("value");
    $("#" + targetSelect).append(
        "<option value='" + valor + "' selected='selected'>" + valor
        + "</option>");
    $("#" + inputComValor).attr("value", "");
}


function validarContato() {
    var retorno = false;
    retorno =  validarFormulario( new Array('nome' , 'email' , 'mensagem'));
    return retorno;
}


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;
    }
}

current_foto = 0;



function fnPassaFoto() {

    if(current_foto >= fotosArray.length) {
        current_foto = 0;
    }

    $("#"+alvoId).fadeOut("slow" , function() {
        $("#"+alvoId).html("<a href='"+urlArray[current_foto]+"'><img src='../img.inc.php-" + fotosArray[current_foto] + "-" +  width + "-" + height +"' alt='' /></a>" + "<div class='noticia-legenda'>"+legendasArray[current_foto]+"</div>");
        $("#"+alvoId).fadeIn("slow");
        current_foto++;
    });
}

function voltaFoto() {
    current_foto--;
    clearInterval(intervalo)
    fnPassaFoto();
    return false;
}

function proximaFoto() {
    clearInterval(intervalo);
    fnPassaFoto();
    return false;
}
