﻿
jQuery(document).ready(function () {

    docSetup();

    if (typeof (Sys) == "object") {

        prm = Sys.WebForms.PageRequestManager.getInstance();

        prm.add_endRequest(function () {

            docSetup();
        });
    }

});

function docSetup() {


    if (typeof fgCadastro == "undefined") {
        fgCadastro = false;
    }


    jQuery('input:text').setMask();

    jQuery("select").focus(function () {
        if (fgCadastro == true) {
            instrucoes(jQuery(this).attr("id"));
        }
    });

    // Contents of textboxes will be selected when receiving focus.
    jQuery("input[type=text]").focus(function () {
        jQuery(this).select();
        if (fgCadastro == true) {
            instrucoes(jQuery(this).attr("id"));
        }
    });  // input

    jQuery('input:text').focusout(function () {

        var cssClass = jQuery(this).attr("class");
        var texto = jQuery(this).val();

        if (typeof cssClass == "undefined") {
            return;
        }

        if (cssClass.indexOf("UPPER") >= 0) {
            texto = texto.toUpperCase();
            jQuery(this).val(texto);
        } else if (cssClass.indexOf("LOWER") >= 0) {
            texto = texto.toLowerCase();
            jQuery(this).val(texto);
        }

    });   // input

}
