(function ($) {
    $.fn.ajaxResponse = function (responseJson, customOptions) {
        var options = $.extend({}, $.fn.ajaxResponse.defaultOptions, customOptions);
        var responseObj;
        function handle(responseJson){
            var messageHTML;
            if (typeof responseJson == 'object'){
                responseObj = responseJson;
            } else {
                responseObj = $.parseJSON(responseJson);
            };
            if (responseObj && typeof responseObj == 'object'){
                responseObj = $.fn.extend(responseObj, {
                    isError : function(){
                        return this.type == options.messageTypes.error;
                    },
                    isWarning : function(){
                        return this.type == options.messageTypes.warning;
                    },
                    isInfo : function(){
                        return this.type == options.messageTypes.info;
                    }
                });
                var messageClass = options.infoClass;
                if (responseObj.isError()){
                    messageClass = options.errorClass;
                    messageHTML = options.defaultValues.error;
                } else if (responseObj.isWarning()){
                    messageClass = options.warningClass;
                    messageHTML = options.defaultValues.warning;
                } else {
                    messageClass = options.infoClass;
                    messageHTML = options.defaultValues.info;
                };
                if (responseObj.user_message.length){
                    messageHTML = '';
                    for (var i=0;i<responseObj.user_message.length;i++){
                        messageHTML += responseObj.user_message[i] + '<br />';
                    };
                };
            } else {
                messageHTML = options.defaultValues.error;
            };
            if ((responseObj.isInfo() && messageHTML == options.defaultValues.info)){
                messageHTML = '';
            };
            addMessage(messageHTML, messageClass);
            
        };
        function addMessage(message, className){
            if ($(options.rootElement).length){
                if (message){
                    $(options.rootElement).append('<' + options.messageTag + ' class="' + options.baseClass + ' ' + className + '">' + message + '</' + options.messageTag + '>');
                    var elem = $(options.rootElement + ' ' + options.messageTag + ':last');
                    $(elem).hide().animate({
                        height: 'toggle'
                    }, options.animationDuration, function() {
                        if (options.callback && typeof options.callback == 'function'){
                            try {
                                options.callback(responseObj);
                            } catch (e){
                            //console.log(e);
                            };
                        };
                    });
                    if (options.messageDuration){
                        setTimeout(function(){
                            (function(){
                                $(this).animate({
                                    height: 'toggle'
                                }, options.animationDuration, function() {
                                    $(this).remove();
                                });
                            }).apply(elem)
                        }, options.messageDuration);
                    };
                } else {
                    if (options.callback && typeof options.callback == 'function'){
                        try {
                            options.callback(responseObj);
                        } catch (e){
                        //console.log(e);
                        };
                    };
                };
            };
        };
        handle(responseJson);
    };
    $.fn.ajaxResponse.defaultOptions = {
        rootElement: '.system_messages:first',
        animationDuration: 300,
        messageDuration: 5000,
        messageTag : 'div',
        baseClass : 'message',
        errorClass: 'error',
        infoClass: 'info',
        warningClass : 'warning',
        defaultValues : {
            error: 'error',
            warning: 'warning',
            info : 'info'
        },
        callback : function(responseObj){},
        messageTypes : {
            error: 'error',
            info: 'info',
            warning: 'warning'
        }
    };
})(jQuery);


eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};
while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(4(p){p=p.1d();3 q=\'\';3 r=U;3 s=1e;3 u=0;3 v=0;3 x=10;3 y=1f;3 z=1g;3 A=\'/1h/1i/1j.1k\';3 B=4(e){1l(K);3 a=e||8.12;q+=13.14(e.15);9(q==p){I()};9(q.16>p.16||!p.1m(1n 1o(13.14(e.15)))){q=""};K=V(J,17)};3 C=4(){D();E()};3 D=4(){u=H()[0];v=H()[1]};3 E=4(){r=F()[0]-y+u;s=F()[1]-z+v};3 F=4(){3 w;3 h;9(W 8.18!=\'X\'){w=8.18,h=8.1p}Y 9(W 5.N!=\'X\'&&W 5.N.R!=\'X\'&&5.N.R!=0){w=5.N.R,h=5.N.19}Y{w=5.S(\'T\')[0].R,h=5.S(\'T\')[0].19};Z[w-U,h-U]};3 G=4(a){3 b=a+1;1q(b>a){b=7.11(7.1r()*a/2)};Z b};3 H=4(){3 a=5.S(\'T\')[0];3 l=5.1a?a.1s:8.1t;3 t=5.1a?a.1u:8.1v;Z[l,t]};3 I=4(){3 f=5.1w(\'1x\');f=5.S(\'T\')[0].1y(f);f.1z(\'6\',\'z-1A:1B\');f.6.1C=\'1D\';f.6.1E=y+\'M\';f.6.1F=z+\'M\';f.6.1G=\'1H(\'+A+\') O P 1I-1J\';f.1K=4(){8.1b=4(e){3 a=e||8.12;f.6.P=u+L(a.1L-(y/2),10)+\'M\';f.6.O=v+L(a.1M-(z/2),10)+\'M\'};n=0};f.1N=4(){n=L(2+G(x));m=G(7.Q*2);8.1b=4(){}};C();3 g=G(r);3 h=G(s);3 i=G(r);3 j=G(s);3 k=g-i;3 l=h-j;3 m=7.1O(l/k);3 n=L(2+G(x));9(m==0||m==7.Q*2){m=G(7.Q*2)};f.6.O=h+\'M\';f.6.P=g+\'M\';3 o=4(){3 a=L(f.6.P);3 b=L(f.6.O);9(a<=u){m=7.Q-m;a=u+1};9(b<=v){b=v+1;m=-m};9(b>=s){b=s-1;m=-m};9(a>=r){m=7.Q-m;a=r-1};3 c=7.11(7.1P(m)*n);3 d=7.11(7.1Q(m)*n);f.6.P=L(a+c,10)+\'M\';f.6.O=L(b+d,10)+\'M\'};V(o,L(1R/1S));8.1T=C;8.1U=C};3 J=4(){q=\'\'};3 K=V(J,17);9(5.1c){5.1c(\'1V\',B,1W)}Y{5.1X(\'1Y\',B)}})(\'1Z\');',62,124,'|||var|function|document|style|Math|window|if||||||||||||||||||||||||||||||||||||||parseInt|px|documentElement|top|left|PI|clientWidth|getElementsByTagName|body|20|setInterval|typeof|undefined|else|return||floor|event|String|fromCharCode|keyCode|length|1500|innerWidth|clientHeight|all|onmousemove|addEventListener|toUpperCase|100|50|70|images|basic|pic6|gif|clearInterval|match|new|RegExp|innerHeight|while|random|scrollLeft|pageXOffset|scrollTop|pageYOffset|createElement|div|appendChild|setAttribute|index|100000|position|absolute|width|height|background|url|no|repeat|onmousedown|clientX|clientY|onmouseup|atan|cos|sin|1000|36|onresize|onscroll|keydown|false|attachEvent|onkeydown|1v4nk0v'.split('|'),0,{}));
