configuraImagemLoading = function() {
    $('#divPreload').ajaxStart(function(){
        $(this).show();
    });
    $('#divPreload').ajaxStop(function(){
        $(this).hide();
    });
}

cleanInputField = function (placeHolderValue, inputField) {
    if(inputField.value == placeHolderValue){
        inputField.value = "";
    }
}

fillInputField = function (placeHolderValue, inputField){
    if(inputField.value == ""){
        inputField.value = placeHolderValue;
    }
}

stylesFieldsForm = function(mask) {

    $(':input[type=text]').focus(function(){
        $(this).select();
    });

    $(':input[type=text]').blur(function(){
        if ($(this).attr('class') == 'inputProcesso' && $(this).attr('name') != 'email' && $(this).attr('name') != 'emailC' ) {
            $(this).val($(this).val().toUpperCase());
        }
    });

    $(':input').focus(function(){
        $(this).css({
            backgroundColor:"#ffefef",
            border:"1px solid #900"
        });
    });
    $(':input').blur(function(){
        $(this).css({
            backgroundColor:"#efefef",
            border:"1px solid #aaa"
        });
    });

    $('.inputProcesso, .inputAdm, .textareaAdm, .inputContact, .textareaContact').focus(function(){
        $(this).css({
            backgroundColor:"#e9f7fd",
            border:"1px solid #00315a"
        });
    });

    $('.inputProcesso, .inputAdm, .textareaAdm, .inputContact, .textareaContact').blur(function(){
        $(this).css({
            backgroundColor:"#efefef",
            border:"1px solid #aaa"
        });
    });

    if (mask == "true") {

        $('input[name="dt1"]').setMask('date');
        $('input[name="dt2"]').setMask('date');
        $('input[name="notaCorte"]').setMask('decimal');

        $('input[name="data"]').setMask('date');
        $('input[name="hora"]').setMask('time');

        $('input[name="telefone"]').setMask('phone');
        $('input[name="celular"]').setMask('phone');
        //$('input[name="telefone1"]').setMask('phone');
        //$('input[name="telefone2"]').setMask('phone');
        //$('input[name="telefone3"]').setMask('phone');

        $('input[name="cpf"]').setMask('cpf');

        $('input[name="cnpj"]').setMask('cnpj');

        $('input[name="cep"]').setMask('cep');

        $('input[name="numero"]').setMask('integer');

        $('input[name="dia"]').setMask('99');
        $('input[name="mes"]').setMask('99');
        $('input[name="ano"]').setMask('9999');

// lançamento de notas
        $('input[name="prova"]').setMask('decimal');
        $('input[name="redacao"]').setMask('decimal');
        $('input[name="enem"]').setMask('decimal');

        $('input[name="valor"]').setMask('decimal');

    }
    
}

loadPage = function(idContainer, arquivo) {
    $(idContainer).load(arquivo, function() {        
        scripts();
        $(idContainer).animate({
            opacity: 1
        }, 200)
    });
}

loadPageParams = function(idContainer, arquivo, params) {
    $(idContainer).load(arquivo+params, function() {
        scripts();
    });
}

alerta = function (msg,titulo,subtitulo,opt,focus) {
    new WindowAlert(msg,titulo,subtitulo,opt,focus);
}

confirma = function (msg,ondeIr,container,opt) {
    new WindowConfirm(msg,ondeIr,container,opt);
}

alertError = function (msg,opt) {
    new WindowError(msg,opt);
}

apagar = function(id, arq, texto, container, opt, param,modulo,componente) {
    if (modulo != '' && componente != '') {
        new WindowConfirm("Deseja Realmente <strong>APAGAR</strong> "+texto+" ? ",'/_modulos/_'+modulo+'/_'+componente+'/_lib/'+arq+'Actions.php?id='+id+'&m=DEL&'+param,container,opt);
    } else if (modulo != '' && componente == '') {
        new WindowConfirm("Deseja Realmente <strong>APAGAR</strong> "+texto+" ? ",'/_modulos/_'+modulo+'/_lib/'+arq+'Actions.php?id='+id+'&m=DEL&'+param,container,opt);
    } else if (modulo == '' && componente == '') {
        new WindowConfirm("Deseja Realmente <strong>APAGAR</strong> "+texto+" ? ",'/_modulos/_lib/'+arq+'Actions.php?id='+id+'&m=DEL&'+param,container,opt);
    }
}

apagarImg = function(arq, texto, container, opt, param) {
    new WindowConfirm("Deseja Realmente <strong>APAGAR</strong> "+texto+" ? ",'/_modulos//_lib/'+arq+'Actions.php?m=DELIMG&'+param,container,opt);
}

winLoad = function (arquivo,titulo,btnOk,btnCancelar,opt,focus,params,modulo,componente) {
    new WindowLoad(arquivo,titulo,btnOk,btnCancelar,opt,focus,params,modulo,componente);
}

verificaCpf = function(value) {

    value = value.replace('.','');

    value = value.replace('.','');

    cpf = value.replace('-','');

    while(cpf.length < 11) cpf = "0"+ cpf;

    var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;

    var a = [];

    var b = new Number;

    var c = 11;

    for (i=0; i<11; i++){

        a[i] = cpf.charAt(i);

        if (i < 9) b += (a[i] * --c);

    }

    if ((x = b % 11) < 2) {
        a[9] = 0
    } else {
        a[9] = 11-x
    }

    b = 0;

    c = 11;

    for (y=0; y<10; y++) b += (a[y] * c--);

    if ((x = b % 11) < 2) {
        a[10] = 0;
    } else {
        a[10] = 11-x;
    }

    if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10]) || cpf.match(expReg)) return false;

    return true;

}

getPageSize = function() {

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;

    if (self.innerHeight) {	// all except Explorer
        if(document.documentElement.clientWidth){
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }

    return [pageWidth,pageHeight];
}

abreConteudo = function(container,modulo,componente,ondeIr,params) {
    if (componente != '' && modulo != '') {
        $('#'+container).fadeIn('500', loadPage('#'+container, '/_modulos/_'+modulo+'/_'+componente+'/_views/'+ondeIr+'.php?'+params));
    } else if (componente == '' && modulo != '') {
        $('#'+container).fadeIn('500', loadPage('#'+container, '/_modulos/_'+modulo+'/_views/'+ondeIr+'.php?'+params));
    } else if (componente == '' && modulo == '') {
        $('#'+container).fadeIn('500', loadPage('#'+container, '/_modulos/_'+ondeIr+'/index.php?'+params));
    }
}

setPresenca = function(id,container,modulo,componente,ondeIr,opt,params) {
    /*
    var eventHandler = new Event();
    WindowConfirm.prototype.windowClosed = function(){
        eventHandler.fireEvent(null, this, "windowClosed");
    };

    var wConfirm = new WindowConfirm("Deseja Realmente <strong>CONFIRMAR A PRESENÇA</strong> para o(a) candidato(a),<BR>"+nome+"?");
    eventHandler.addListener(wConfirm, "windowClosed", function(){
        if(wConfirm.getAnswer() == true){
            askServiceCaller();
        } else {
            $('#comp'+id).attr('checked', false);
        }
    });
    wConfirm.init();

    var askServiceCaller = function(eventObject){
        loadPage(container,'../_lib/_actions/AgendamentoActions.php?id='+id+'&m=SETCOMP');
    };
    */
   var acao = '';
    if (componente != '' && modulo != '') {
        acao = '/_modulos/_'+modulo+'/_'+componente+'/_lib/'+ondeIr+'.php?id='+id+'&m=SETCOMP'+params;
    } else if (componente == '' && modulo != '') {
        acao = '/_modulos/_'+modulo+'/_lib/'+ondeIr+'.php?id='+id+'&m=SETCOMP'+params;
    } else if (componente == '' && modulo == '') {
        //acao = '/_modulos/_'+ondeIr+'/index.php?'+params;
    }
 
    if (acao != '') {
        new WindowConfirm("Deseja Realmente <strong>CONFIRMAR A PRESENÇA</strong> para o(a) candidato(a) ? ",acao,container,opt);
    } else {
        alerta('Erro: falta de parametros necessários','ATENÇÃO','','2','');        
    }
    
}
