(function($) {

    exibeMensagem = function(msg) {
        alert(msg);
    }


    identificarNavegador = function() {
        navegador = $.browser.name;
        versao = ($.browser.version).split(".")[0];

        $("body")
		.addClass(navegador)
		.addClass(navegador + versao);
    }

    identificarResolucao = function() {

        //resolucao = "res"+screen.width;
        areaVisivel = $("body").width();
        //$("#componente").prepend("<br>"+ resolucao);
        classe = 'res';

        if (areaVisivel < 800)
            classe += '800';
        else if (areaVisivel < 960)
            classe += '960';
        else if (areaVisivel < 1024)
            classe += '1024';
        else if (areaVisivel < 1088)
            classe += '1088';
        else if (areaVisivel < 1152)
            classe += '1152';
        else if (areaVisivel < 1280)
            classe += '1280';
        else if (areaVisivel < 1360)
            classe += '1360';
        else if (areaVisivel < 1440)
            classe += '1440';
        else if (areaVisivel < 1600)
            classe += '1600';
        else if (areaVisivel < 1680)
            classe += '1680';

        classes = $("body").attr("class");
        classes.split(" ").forEach(removerClasse);

        function removerClasse(c) {
            $("body").removeClass(c);
        }

        $("body").addClass(classe);

        /* -------------------------------------------
        RESOLUÇÃO -> ÁREA VISÍVEL (CHROME)
        1920 -> ?
        1680 -> ?
        1600 -> ?
        1440 -> 1423
        1360 -> 1343
        1280 -> 1263
        1152 -> 1135
        1088 -> 1071
        1024 -> 1007
        960 -> 946
        800 -> 783 
        ----------------------------------------------*/
    }

    msg = function(txt) {
        window.console ? console.log(txt) : alert(txt);
    }

    $.fn.debug = function() {
        return this.each(function(i) {
            window.console ? console.log(this) : null;
        });
    }

    /* destacar um elemento
    default: firstEvent:focus | activeClass:onFocus | lastEvent:blur
    modo de usar:
    $("input:text, input:password, textarea").highlight();		
    $("ul li").highlight({ firstEvent:'mouseover', activeClass:'hover', lastEvent:'mouseout' });
    */
    $.fn.highlight = function(options) {
        var settings = jQuery.extend({
            activeClass: 'onFocus',
            firstEvent: 'focus',
            lastEvent: 'blur'
        }, options);

        return $(this)
		.bind(settings.firstEvent, function() {
		    $(this).addClass(settings.activeClass)
		})
		.bind(settings.lastEvent, function() {
		    $(this).removeClass(settings.activeClass)
		});
    }

    /* kill default event 
    usage: myfunction(e){ kill(e); doStuffs() }	
    */
    kill = function(e) {
        if (!e) e = window.event;
        (e.stopPropagation) ? e.stopPropagation() : e.cancelBubble = true;
        (e.preventDefault) ? e.preventDefault() : e.returnValue = false;
        return false;
    }

    /* ir para uma pagina
    usage: goto('index.php') */
    goto = function(url) {
        window.location = url;
    }

    in_array = function(x, matriz) {
        var txt = "¬" + matriz.join("¬") + "¬";
        var er = new RegExp("¬" + x + "¬", "gim");
        return ((txt.match(er)) ? true : false);
    }

    $.fn.example = function(text) {  /* options */
        /*var defaults = {  
        text: "Digite"
        };  
        var options = $.extend(defaults, options);  */

        return this.each(function() {
            input = $(this);
            input.val(text)
			.focus(function() {
			    if (input.val() == text) input.val("");
			})
			.blur(function() {
			    if ($.trim(input.val()) == "") input.val(text);
			});
        });
    };

    $.fn.equalizarColunas = function() {
        var maxHeight = 0;
        this.each(function() {
            if (this.offsetHeight > maxHeight) { maxHeight = this.offsetHeight; }
        });
        this.each(function() {
            $(this).height(maxHeight + "px");
            if (this.offsetHeight > maxHeight) {
                $(this).height((maxHeight - (this.offsetHeight - maxHeight)) + "px");
            }
        });
    };

    $.fn.tios = function() {
        return this.parent().siblings();
    }

    $.fn.primos = function() {
        return this.tios().children();
    }

})(jQuery);