﻿function ajaxAlert(message){alert(message);}
function ajaxRequestJson(jsonString, pageName, webMethodFunc, func){AjaxRequestJson(jsonString, pageName, webMethodFunc, func);}
function AjaxRequestJson(jsonString, pageName, webMethodFunc, func){$.ajax({type: "POST",data: jsonString,contentType: "application/json; charset=utf-8",dataType: "json",url: pageName+"/"+webMethodFunc,success: function(d){var data;try{data = JSON.parse(d.d);}catch(e){ajaxAlert("Não foi possível ler o JSON retornado de '"+webMethodFunc+"'.");return;}func.call(this.constructor, data);},error: function(){ajaxAlert("Erro na chamada assíncrona '"+webMethodFunc+"'. Verifique se a sua conexão de internet e tente novamente.")}});}
function TransferEnterKey(input, button){$(input).keypress(function(e){var code = (e.keyCode ? e.keyCode : e.which);if(code == 13) {$(button).trigger("click");}});}
//$(".ajaxLoad").ajaxStop(function(){$(this).hide();});
$(document).ready(function(){
    $(".imgBtn").fadeTo(50,.9).hover(function(){
        $(this).stop().fadeTo(50,1);
    }, function(){
        $(this).stop().fadeTo(50,.9);
    });
    $('.menu ul li').click(function(){
        var loc = $(this).find('a').attr('href');
        document.location = loc;
    });
});

(function($)
{
    jQuery.fn.quickAlert = function(msg, time, options)
    {
        if (time === undefined) { time = 2000; }
        $.fn.quickAlert.defaults = {
            clearExistent: true,
            cssClass: 'quickAlert',
            afterAppendFn: function() { }
        };
        var opts = $.extend({}, $.fn.quickAlert.defaults, options);
        if (opts.clearExistent)
        {
            $(this).find('.' + opts.cssClass).remove();
        }
        var id = opts.cssClass + (new Date).getTime();
        $(this).append('<div id="' + id + '"class="' + opts.cssClass + '"><div>' + msg + '</div></div>');
        opts.afterAppendFn.call(this.constructor, $('#' + id));
        if (time > 0)
        {
            window.setTimeout(function() { $('#' + id).hide(300, function() { $('#' + id).remove(); }); }, time);
        }
        return $(this);
    }
})(jQuery);

String.format = function( text ){if ( arguments.length <= 1 ){return text;}var tokenCount = arguments.length - 2;for( var token = 0; token <= tokenCount; token++ ){text = text.replace( new RegExp( '\\{' + token + '\\}', 'gi' ),arguments[ token + 1 ] );}return text;}

$(function(){$.extend($.fn.disableTextSelect = function() {return this.each(function(){if($.browser.mozilla){$(this).css('MozUserSelect','none');}else if($.browser.msie){$(this).bind('selectstart',function(){return false;});}else{$(this).mousedown(function(){return false;});}});});$('.noSelect').disableTextSelect();});