/*
	jool v0.6.8.004
	This code ©2009 Giovanni Di Gregorio All Rights Reserved · giovannidigregorio.it
	Every intellectual property reserved. Please refer to http://jool.giovannidigregorio.it
	Released under licence MIT http://www.opensource.org/licenses/mit-license.php
	Please report comments or bugs to shaithana@gmail.com
	Free for personal and commercial use, please not remove this copyright informations
	NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/

// General utilities
function al(value) {
    return alert(value);
};
function $$(obj) {
    return document.getElementById(obj);
};

// jool namespace
var jool = {
    version: '0.6.8.0',
    internal: '04',

    // internal methods
    pc: function(cn, p) {
        // parseClass legge il valore di una proprietà in una classe CSS
        this.cn = '.' + cn;
        this.cr;
        if (j.sniff('IE')) {
            this.cr = 'rules';
        } else {
            this.cr = 'cssRules';
        };
        for (var s = 0; s < document.styleSheets.length; s++) {
            for (var r = 0; r < document.styleSheets[s][this.cr].length; r++) {
                if (document.styleSheets[s][this.cr][r].selectorText == this.cn) {
                    return document.styleSheets[s][this.cr][r].style[p];
                };
            };
        };
    },
    htr: function(c) {
        // hexToRgb converte un valore esadecimale in RGB
        if (c.toString().indexOf('#') != -1) {
            c = c.replace(/#/g, '');
            this.r = parseInt(c.slice(0, 2), 16);
            this.g = parseInt(c.slice(2, 4), 16);
            this.b = parseInt(c.slice(4, 6), 16);
            this.rgb = [this.r, this.g, this.b];
        } else {
            this.rgb = c.replace(/rgb\(|\)/g, '').split(', ');
            this.rgb = [parseInt(this.rgb[0], 10), parseInt(this.rgb[1], 10), parseInt(this.rgb[2], 10)];
        };
        return this.rgb;
    },
    tcc: function(p) {
        // toCamelCasing converte una stringa con dash in camelCasing
        var str = p.split("-");
        var p = '';
        for (var i in str) {
            if (i > 0) str[i] = str[i].substring(0, 1).toUpperCase() + str[i].substring(1, str[i].length);
            p += str[i];
        };
        return p;
    },
    coords: function(e) {
        // trova le coordinate per j.gps
        j.gps.x = (j.sniff('IE')) ? window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft: e.pageX;
        j.gps.y = (j.sniff('IE')) ? window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop: e.pageY;
        j.gps.wScreen = window.screen.width;
        j.gps.hScreen = window.screen.height;
        j.gps.tScroll = document.documentElement.scrollTop;
        j.gps.lScroll = document.documentElement.scrollLeft;
    },
    css: function(obj, p) {
        // legge il valore di una proprietà CSS
        if (j.sniff('IE')) {
            if (obj.currentStyle[j.tcc(p)] == 'auto') {
                return 0;
            } else {
                return obj.currentStyle[j.tcc(p)];
            };
        } else {
            return document.defaultView.getComputedStyle(obj, null).getPropertyValue(p);
        };
    },

    // API methods
    play: function(e) {
        // metodo di avvio per fx, set, flow, load
        var that = this;
        switch (this.action) {
        case 'fx':
            (this.valueType != 'rel') ? this.valueType = 'abs': this.valueType = 'rel';
            if (!this.duration || this.duration == 0 || this.duration == 1) this.duration = 2;
            this.easing = this.easing || 'linear';
            this.stop(true);
            this.Go = j.fxGo;
            break;
        case 'set':
            this.Go = j.setGo;
            break;
        case 'flow':
            this.Go = j.flowGo;
            break;
        case 'load':
            this.Go = j.loadGo;
            break;
        };
        (this.wait) ? this.waitTM = setTimeout(function() {
            that.Go();
        },
        this.wait * 10) : this.Go();
    },
    stop: function(i) {
        // metodo di stop
        window.clearTimeout(this.waitTM);
        window.clearTimeout(this.fxTM);
        this.objStop = this.$;
        if (i == true) {
            while (this.objStop) {
                window.clearTimeout(this.objStop.fxTM);
                window.clearTimeout(this.objStop.waitTM);
                this.objStop = this.objStop.$;
            };
        };
    },

    // API jool.gps
    gps: function(obj) {
        this.coords = j.coords;
        var x = y = wScreen = hScreen = tScroll = lScroll = 0;
        if (j.sniff('IE')) {
            document.attachEvent('onmousemove', this.coords);
        } else {
            document.addEventListener('mousemove', this.coords, false);
        };
    },

    // API jool.sniff
    sniff: function(b) {
        switch (b) {
        case 'IE' || 'IE4+': if (document.all && !window.opera) return true;
            break;
        case 'IE5+':
            if (window.attachEvent && !window.opera) return true;
            break;
        case 'IE5.5+':
            if (window.createPopup && !window.opera) return true;
            break;
        case 'IE6+':
            if (document.compatMode && document.all && !window.opera) return true;
            break;
        case 'IE7+':
            if (document.documentElement && typeof document.documentElement.style.maxHeight != 'undefined' && !window.opera) return true;
            break;
        case 'Mozilla' || 'Safari' || 'Camino' || 'Firefox1+': if (window.getComputedStyle && !window.opera) return true;
            break;
        case 'Firefox1.5+':
            if (Array.every) return true;
            break;
        case 'Firefox2+':
            if (window.Iterator) return true;
            break;
        case 'Opera':
            if (window.opera) return true;
            break;
        case 'Opera8+':
            if (window.XMLHttpRequest && window.opera) return true;
            break;
        case 'Chrome':
            if ((navigator.userAgent.toLowerCase()).indexOf("chrome") > -1) return true;
            break;
        };
    },

    // API jool.dom
    dom: function(obj) {
        return new j.$dom(obj);
    },
    $dom: function(f) {
        this.f = f.split('!');
        this.h1 = [];
        this.h2 = [];
        this.z = [];
        this.z1 = [];
        this.z2 = [];
        // Selezione dei nodi del DOM da includere
        this.ID1 = (((this.f[0]).match(/#\S*(?=\.)/) || (this.f[0]).match(/#\S*/) || '*').toString()).replace('#', '');
        if (this.f[0].indexOf('#') != -1) {
            this.TAG1 = (((this.f[0]).match(/ \S*(?=\.)/) || (this.f[0]).match(/ \S*/) || '*').toString()).replace(' ', '');
        } else {
            this.TAG1 = (((this.f[0]).match(/\S*(?=\.)/) || (this.f[0]).match(/\S*/) || '*').toString()).replace(' ', '');
            if (this.TAG1 == '') this.TAG1 = '*';
        };
        this.CLASS1 = ((this.f[0]).match(/\.\S*/)) ? new RegExp("(^| )" + (((this.f[0]).match(/\.\S*/)).toString()).replace('.', '') + "( |$)") : new RegExp(/(^| )\S*( |$)/);
        if ((this.TAG1 == '*') && (this.CLASS1.toString() == '/(^| )\\S*( |$)/')) {
            this.z1.push($$(this.ID1));
        } else {
            if (this.ID1 != '*') {
                for (var i = 0; i < $$(this.ID1).getElementsByTagName(this.TAG1).length; i++) {
                    this.h1.push($$(this.ID1).getElementsByTagName(this.TAG1)[i]);
                };
            } else {
                for (var i = 0; i < document.getElementsByTagName(this.TAG1).length; i++) {
                    this.h1.push(document.getElementsByTagName(this.TAG1)[i]);
                };
            };
            for (var c = 0; c < this.h1.length; c++) {
                if (this.h1[c]) {
                    if ((this.CLASS1).test(this.h1[c].className)) {
                        this.z1.push(this.h1[c]);
                    };
                };
            };
        };
        // Selezione dei nodi del DOM da escludere eventualmente
        if (this.f[1]) {
            this.ID2 = (((this.f[0]).match(/#\S*(?=\.)/) || (this.f[1]).match(/#\S*/) || '*').toString()).replace('#', '');
            if (this.f[1].indexOf('#') != -1) {
                this.TAG2 = (((this.f[1]).match(/ \S*(?=\.)/) || (this.f[1]).match(/ \S*/) || '*').toString()).replace(' ', '');
            } else {
                this.TAG2 = (((this.f[1]).match(/\S*(?=\.)/) || (this.f[1]).match(/\S*/) || '*').toString()).replace(' ', '');
                if (this.TAG2 == '') this.TAG2 = '*';
            };
            this.CLASS2 = ((this.f[1]).match(/\.\S*/)) ? new RegExp("(^| )" + (((this.f[1]).match(/\.\S*/)).toString()).replace('.', '') + "( |$)") : new RegExp(/(^| )\S*( |$)/);
            if ((this.TAG2 == '*') && (this.CLASS2.toString() == '/(^| )\\S*( |$)/')) {
                this.z2.push($$(this.ID2));
            } else {
                if (this.ID2 != '*') {
                    for (var i = 0; i < $$(this.ID2).getElementsByTagName(this.TAG2).length; i++) {
                        this.h2.push($$(this.ID2).getElementsByTagName(this.TAG2)[i]);
                    };
                } else {
                    for (var i = 0; i < document.getElementsByTagName(this.TAG2).length; i++) {
                        this.h2.push(document.getElementsByTagName(this.TAG2)[i]);
                    };
                };
                for (var c = 0; c < this.h2.length; c++) {
                    if (this.h2[c]) {
                        if ((this.CLASS2).test(this.h2[c].className)) {
                            this.z2.push(this.h2[c]);
                        };
                    };
                };
            };
            this.is = [];
            for (var c = 0; c < this.z1.length; c++) {
                for (var e = 0; e < this.z2.length; e++) {
                    if (this.z1[c] == this.z2[e]) this.is[c] = true;
                };
                if (this.is[c] != true) this.z.push(this.z1[c]);
            };
        } else {
            this.z = this.z1;
        };
        return this.z;
    },

    // API jool.flow
    flow: function(obj) {
        return new j.$flow(obj);
    },
    $flow: function(p) {
        this.code = p.code;
        this.successfully = this.$ = p.successfully;
        this.action = 'flow';
        this.wait = p.wait;
        this.play = j.play;
        this.stop = j.stop;
    },
    flowGo: function() {
        (typeof this.code == 'string') ? eval(this.code) : this.code();
        if (this.$) { (typeof this.$ == 'string') ? eval(this.$) : ((this.$.action) ? this.$.play() : this.$());
        };
    },

    // API jool.set
    set: function(obj) {
        return new j.$set(obj);
    },
    $set: function(p) {
        this.object = p.object;
        this.dom = p.dom;
        this.text = p.text;
        this.html = p.html;
        this.cssClass = p.cssClass;
        this.style = p.style;
        this.successfully = this.$ = p.successfully;
        this.wait = p.wait;
        this.action = 'set';
        this.play = j.play;
        this.stop = j.stop;
    },
    setGo: function() {
        if (this.object) {
            for (var o in this.object) {
                this.obj = $$(this.object[o].replace('#', ''));
                if (this.text) {
                    (j.sniff('IE')) ? this.obj.innerText = this.text: this.obj.textContent = this.text;
                };
                if (this.html) this.obj.innerHTML = this.html;
                if (this.cssClass) this.obj.className = this.cssClass;
                if (this.style) this.styles = (this.style).split(';');
                for (var x in this.styles) {
                    var arg = this.styles[x].split(':');
                    eval('this.obj.style.' + j.tcc(arg[0]) + ' = \'' + arg[1] + '\'');
                };
            };
        };
        if (this.dom) {
            this.doms = j.dom(this.dom);
            for (var i in this.doms) {
                if (this.text) {
                    (j.sniff('IE')) ? this.doms[i].innerText = this.text: this.doms[i].textContent = this.text;
                };
                if (this.html) this.doms[i].innerHTML = this.html;
                if (this.cssClass) this.doms[i].className = this.cssClass;
                if (this.style) this.styles = (this.style).split(';');
                for (var x in this.styles) {
                    if (this.styles[x] != '') var arg = this.styles[x].split(':');
                    eval('this.doms[i].style.' + j.tcc(arg[0]) + ' = \'' + arg[1] + '\'');
                };
            };
        };
        if (this.$) { (typeof this.$ == 'string') ? eval(this.$) : ((this.$.action) ? this.$.play() : this.$());
        };
    },

    // API jool.load
    load: function(obj) {
        return new j.$load(obj);
    },
    $load: function(p) {
        this.object = p.object;
        this.store = p.store;
        this.uri = p.uri;
        this.variables = p.variables;
        this.method = p.method || 'GET';
        //puo essere 'GET' o 'POST'
        this.fill = p.fill || 'replace';
        //puo essere 'replace', 'before' o 'after'
        this.render = p.render || 'html';
        //puo essere 'html' o 'text'
        this.requestHeader = p.requestHeader;
        //esempio ['Content-Type', 'application/x-www-form-urlencoded']
        this.successfully = this.$ = p.successfully;
        this.unsuccessfully = this.n$ = p.unsuccessfully;
        this.wait = p.wait;
        this.action = 'load';
        this.play = j.play;
        this.stop = j.stop;
    },
    loadGo: function() {
        if (this.method == 'GET') var uri = this.uri + ((this.variables) ? '?' + this.variables + '&': '?') + 'j.cache=' + new Date().getTime();
        var that = this;
        var http = (j.sniff('IE') && !j.sniff('IE7+')) ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
        http.open(this.method, uri);
        http.onreadystatechange = function() {
            if (http.readyState == 4) {
                if (http.status >= 200 && http.status < 300) {
                    if (that.object) {
								that.object = that.object.replace('#', '');
                        switch (that.render) {
                        case 'html':
                            $$(that.object).innerHTML = (that.fill == 'replace') ? http.responseText: ((that.fill == 'before') ? http.responseText + $$(that.object).innerHTML: $$(that.object).innerHTML + http.responseText);
                            break;
                        case 'text':
                            if (j.sniff('IE')) {
                                $$(that.object).innerText = (that.fill == 'replace') ? http.responseText: ((that.fill == 'before') ? http.responseText + $$(that.object).innerText: $$(that.object).innerText + http.responseText);
                            } else {
                                $$(that.object).textContent = (that.fill == 'replace') ? http.responseText: ((that.fill == 'before') ? http.responseText + $$(that.object).textContent: $$(that.object).textContent + http.responseText);
                            };
                            break;
                        };
                    } else {
                        return http.responseText;
                    };
                    if (that.store) eval(that.store + ' = http.responseText');
                    if (that.$) { (typeof that.$ == 'string') ? eval(that.$) : ((that.$.action) ? that.$.play() : that.$());
                    };
                } else {
                    var httpError = 'error ' + http.status + ' | for http status codes see <a href=\'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\' style=\'text-decoration: underline\'>w3.org</a>';
                    if (that.object) {
								that.object = that.object.replace('#', '');
                        $$(that.object).innerHTML = httpError;
                    } else {
                        return http.status;
                    };
                    if (that.store) eval(that.store + ' = httpError');
                    if (that.n$) { (typeof that.n$ == 'string') ? eval(that.n$) : ((that.n$.action) ? that.n$.play() : that.n$());
                    };
                };
            };
        };
        if (this.requestHeader) http.setRequestHeader(this.requestHeader[0], this.requestHeader[1]);
        (this.method == 'post') ? http.send(eval(this.variables)) : http.send(null);
    },

    // API jool.fx
    fx: function(obj) {
        return new j.$fx(obj);
    },
    $fx: function(p) {
        this.p = p;
        this.newClass = p.newClass || [];
        this.object = p.object || [];
        this.except = p.except || '';
        this.dom = p.dom;
        this.classname = p.classname;
        this.opacity = p.opacity || [];
        this.width = p.width || [];
        this.walign = p.walign || 'left';
        this.height = p.height || [];
        this.halign = p.halign || 'top';
        this.left = p.left || [];
        this.top = p.top || [];
        this.backgroundColor = p.backgroundColor || [];
        this.border = p.border || [];
        this.borderColor = p.borderColor || [];
        this.borderTop = p.borderTop || (p.border || []);
        this.borderTopColor = p.borderTopColor || (p.borderColor || []);
        this.borderRight = p.borderRight || (p.border || []);
        this.borderRightColor = p.borderRightColor || (p.borderColor || []);
        this.borderBottom = p.borderBottom || (p.border || []);
        this.borderBottomColor = p.borderBottomColor || (p.borderColor || []);
        this.borderLeft = p.borderLeft || (p.border || []);
        this.borderLeftColor = p.borderLeftColor || (p.borderColor || []);
        this.padding = p.padding || [];
        this.paddingTop = p.paddingTop || (p.padding || []);
        this.paddingRight = p.paddingRight || (p.padding || []);
        this.paddingBottom = p.paddingBottom || (p.padding || []);
        this.paddingLeft = p.paddingLeft || (p.padding || []);
        this.margin = p.margin || [];
        this.marginTop = p.marginTop || (p.margin || []);
        this.marginRight = p.marginRight || (p.margin || []);
        this.marginBottom = p.marginBottom || (p.margin || []);
        this.marginLeft = p.marginLeft || (p.margin || []);
        this.fontSize = p.fontSize || [];
        this.color = p.color || [];
        this.valueType = p.valueType;
        this.unit = p.unit;
        this.easing = p.easing;
        this.duration = p.duration;
        this.wait = p.wait;
        this.successfully = this.$ = p.successfully;
        this.action = 'fx';
        this.play = j.play;
        this.stop = j.stop;
    },
    fxGo: function() {
        //performanceTime = new Date().getTime();
        this.time = 0;
        // Trasforma le assegnazioni esterne di border, padding e margin nelle proprietà dei lati
        if (this.borderTop.length == 0) this.borderTop = this.border || this.p.border;
        if (this.borderTopColor.length == 0) this.borderTopColor = this.borderColor || this.p.borderColor;
        if (this.borderRight.length == 0) this.borderRight = this.border || this.p.border;
        if (this.borderRightColor.length == 0) this.borderRightColor = this.borderColor || this.p.borderColor;
        if (this.borderBottom.length == 0) this.borderBottom = this.border || this.p.border;
        if (this.borderBottomColor.length == 0) this.borderBottomColor = this.borderColor || this.p.borderColor;
        if (this.borderLeft.length == 0) this.borderLeft = this.border || this.p.border;
        if (this.borderLeftColor.length == 0) this.borderLeftColor = this.borderColor || this.p.borderColor;
        if (this.paddingTop.length == 0) this.paddingTop = this.padding || this.p.padding;
        if (this.paddingRight.length == 0) this.paddingRight = this.padding || this.p.padding;
        if (this.paddingBottom.length == 0) this.paddingBottom = this.padding || this.p.padding;
        if (this.paddingLeft.length == 0) this.paddingLeft = this.padding || this.p.padding;
        if (this.marginTop.length == 0) this.marginTop = this.margin || this.p.margin;
        if (this.marginRight.length == 0) this.marginRight = this.margin || this.p.margin;
        if (this.marginBottom.length == 0) this.marginBottom = this.margin || this.p.margin;
        if (this.marginLeft.length == 0) this.marginLeft = this.margin || this.p.margin;
        // Dichiarazione degli array
        this.startOpacity = [];
        this.changeOpacity = [];
        this.startWidth = [];
        this.changeWidth = [];
        this.startHeight = [];
        this.changeHeight = [];
        this.startLeft = [];
        this.changeLeft = [];
        this.startTop = [];
        this.changeTop = [];
        this.startBorderTop = [];
        this.changeBorderTop = [];
        this.startBorderRight = [];
        this.changeBorderRight = [];
        this.startBorderBottom = [];
        this.changeBorderBottom = [];
        this.startBorderLeft = [];
        this.changeBorderLeft = [];
        this.startPaddingTop = [];
        this.changePaddingTop = [];
        this.startPaddingRight = [];
        this.changePaddingRight = [];
        this.startPaddingBottom = [];
        this.changePaddingBottom = [];
        this.startPaddingLeft = [];
        this.changePaddingLeft = [];
        this.startMarginTop = [];
        this.changeMarginTop = [];
        this.startMarginRight = [];
        this.changeMarginRight = [];
        this.startMarginBottom = [];
        this.changeMarginBottom = [];
        this.startMarginLeft = [];
        this.changeMarginLeft = [];
        this.startFontSize = [];
        this.changeFontSize = [];
        //this.backgroundColor = this.backgroundColor;
        this.startBackgroundRed = [];
        this.startBackgroundGreen = [];
        this.startBackgroundBlue = [];
        this.changeBackgroundRed = [];
        this.changeBackgroundGreen = [];
        this.changeBackgroundBlue = [];
        this.fontColor = this.color;
        this.startFontRed = [];
        this.startFontGreen = [];
        this.startFontBlue = [];
        this.changeFontRed = [];
        this.changeFontGreen = [];
        this.changeFontBlue = [];
        //this.borderTopColor = this.borderTopColor;
        this.startBorderTopColorRed = [];
        this.changeBorderTopColorRed = [];
        this.startBorderTopColorGreen = [];
        this.changeBorderTopColorGreen = [];
        this.startBorderTopColorBlue = [];
        this.changeBorderTopColorBlue = [];
        //this.borderRightColor = this.borderRightColor;
        this.startBorderRightColorRed = [];
        this.changeBorderRightColorRed = [];
        this.startBorderRightColorGreen = [];
        this.changeBorderRightColorGreen = [];
        this.startBorderRightColorBlue = [];
        this.changeBorderRightColorBlue = [];
        //this.borderBottomColor = this.borderBottomColor;
        this.startBorderBottomColorRed = [];
        this.changeBorderBottomColorRed = [];
        this.startBorderBottomColorGreen = [];
        this.changeBorderBottomColorGreen = [];
        this.startBorderBottomColorBlue = [];
        this.changeBorderBottomColorBlue = [];
        //this.borderLeftColor = this.borderLeftColor;
        this.startBorderLeftColorRed = [];
        this.changeBorderLeftColorRed = [];
        this.startBorderLeftColorGreen = [];
        this.changeBorderLeftColorGreen = [];
        this.startBorderLeftColorBlue = [];
        this.changeBorderLeftColorBlue = [];
        this.fxGoCheck = j.fxGoCheck;
        //al(this.backgroundColor);
        if (this.object.length > 0) {
            for (var i in this.object) {
                this.obj = $$((this.object[i]).replace('#', ''));
                this.fxGoCheck(i, i);
            };
        } else if (this.dom) {
            this.doms = j.dom(this.dom);
            for (var i in this.doms) {
                this.obj = this.doms[i];
                if (this.obj != $$(this.except)) {
                    this.fxGoCheck(i, 0);
                } else {
                    this.fxGoCheck(i, 1);
                };
            };
        };
        this.fxLoop = j.fxLoop;
        this.fxLoop();
    },
    fxGoCheck: function(i, f) {
        // Analizza la newClass
        if (this.newClass[f] && this.newClass[f] != 'null') {
            this.newClass[f] = (this.newClass[f]).replace('.', '');
            if ((!this.opacity[f] || this.opacity[f] == 'null') && j.pc(this.newClass[f], 'opacity')) this.opacity[f] = parseInt(j.pc(this.newClass[f], 'opacity'), 10);
            if ((!this.width[f] || this.width[f] == 'null') && j.pc(this.newClass[f], 'width')) this.width[f] = parseInt(j.pc(this.newClass[f], 'width'), 10);
            if ((!this.height[f] || this.height[f] == 'null') && j.pc(this.newClass[f], 'height')) this.height[f] = parseInt(j.pc(this.newClass[f], 'height'), 10);
            if ((!this.left[f] || this.left[f] == 'null') && j.pc(this.newClass[f], 'left')) this.left[f] = parseInt(j.pc(this.newClass[f], 'left'), 10);
            if ((!this.top[f] || this.top[f] == 'null') && j.pc(this.newClass[f], 'top')) this.top[f] = parseInt(j.pc(this.newClass[f], 'top'), 10);
            if ((!this.backgroundColor[f] || this.backgroundColor[f] == 'null') && j.pc(this.newClass[f], 'backgroundColor')) this.backgroundColor[f] = j.pc(this.newClass[f], 'backgroundColor');
            if ((!this.borderTop[f] || this.borderTop[f] == 'null') && j.pc(this.newClass[f], 'borderTopWidth')) this.borderTop[f] = parseInt(j.pc(this.newClass[f], 'borderTopWidth'), 10);
            if ((!this.borderTopColor[f] || this.borderTopColor[f] == 'null') && j.pc(this.newClass[f], 'borderTopColor')) this.borderTopColor[f] = j.pc(this.newClass[f], 'borderTopColor');
            if ((!this.borderRight[f] || this.borderRight[f] == 'null') && j.pc(this.newClass[f], 'borderRightWidth')) this.borderRight[f] = parseInt(j.pc(this.newClass[f], 'borderRightWidth'), 10);
            if ((!this.borderRightColor[f] || this.borderRightColor[f] == 'null') && j.pc(this.newClass[f], 'borderRightColor')) this.borderRightColor[f] = j.pc(this.newClass[f], 'borderRightColor');
            if ((!this.borderBottom[f] || this.borderBottom[f] == 'null') && j.pc(this.newClass[f], 'borderBottomWidth')) this.borderBottom[f] = parseInt(j.pc(this.newClass[f], 'borderBottomWidth'), 10);
            if ((!this.borderBottomColor[f] || this.borderBottomColor[f] == 'null') && j.pc(this.newClass[f], 'borderBottomColor')) this.borderBottomColor[f] = j.pc(this.newClass[f], 'borderBottomColor');
            if ((!this.borderLeft[f] || this.borderLeft[f] == 'null') && j.pc(this.newClass[f], 'borderLeftWidth')) this.borderLeft[f] = parseInt(j.pc(this.newClass[f], 'borderLeftWidth'), 10);
            if ((!this.borderLeftColor[f] || this.borderLeftColor[f] == 'null') && j.pc(this.newClass[f], 'borderLeftColor')) this.borderLeftColor[f] = j.pc(this.newClass[f], 'borderLeftColor');
            if ((!this.paddingTop[f] || this.paddingTop[f] == 'null') && j.pc(this.newClass[f], 'paddingTop')) this.paddingTop[f] = parseInt(j.pc(this.newClass[f], 'paddingTop'), 10);
            if ((!this.paddingRight[f] || this.paddingRight[f] == 'null') && j.pc(this.newClass[f], 'paddingRight')) this.paddingRight[f] = parseInt(j.pc(this.newClass[f], 'paddingRight'), 10);
            if ((!this.paddingBottom[f] || this.paddingBottom[f] == 'null') && j.pc(this.newClass[f], 'paddingBottom')) this.paddingBottom[f] = parseInt(j.pc(this.newClass[f], 'paddingBottom'), 10);
            if ((!this.paddingLeft[f] || this.paddingLeft[f] == 'null') && j.pc(this.newClass[f], 'paddingLeft')) this.paddingLeft[f] = parseInt(j.pc(this.newClass[f], 'paddingLeft'), 10);
            if ((!this.marginTop[f] || this.marginTop[f] == 'null') && j.pc(this.newClass[f], 'marginTop')) this.marginTop[f] = parseInt(j.pc(this.newClass[f], 'marginTop'), 10);
            if ((!this.marginRight[f] || this.marginRight[f] == 'null') && j.pc(this.newClass[f], 'marginRight')) this.marginRight[f] = parseInt(j.pc(this.newClass[f], 'marginRight'), 10);
            if ((!this.marginBottom[f] || this.marginBottom[f] == 'null') && j.pc(this.newClass[f], 'marginBottom')) this.marginBottom[f] = parseInt(j.pc(this.newClass[f], 'marginBottom'), 10);
            if ((!this.marginLeft[f] || this.marginLeft[f] == 'null') && j.pc(this.newClass[f], 'marginLeft')) this.marginLeft[f] = parseInt(j.pc(this.newClass[f], 'marginLeft'), 10);
            if ((!this.fontSize[f] || this.fontSize[f] == 'null') && j.pc(this.newClass[f], 'fontSize')) this.fontSize[f] = parseInt(j.pc(this.newClass[f], 'fontSize'), 10);
            if ((!this.color[f] || this.color[f] == 'null') && j.pc(this.newClass[f], 'color')) this.color[f] = j.pc(this.newClass[f], 'color');
        };
        // Check dell'opacità attuale, 'isNaN' è usato per il supporto a MSIE
        if (this.opacity[f] != null) {
            if (j.css(this.obj, 'display') == 'none') {
                this.startOpacity[i] = 0;
                this.obj.style.display = 'inline';
            } else {
                if ((j.css(this.obj, 'opacity') * 100) <= 0) {
                    this.startOpacity[i] = 0;
                } else if (isNaN((j.css(this.obj, 'opacity') * 100)) || j.css(this.obj, 'opacity') * 100 == 100) {
                    this.startOpacity[i] = 100;
                } else {
                    this.startOpacity[i] = (this.obj.style.opacity * 100);
                };
            };
            this.changeOpacity[i] = (this.valueType == 'abs') ? this.opacity[f] - this.startOpacity[i] : this.opacity[f];
        };
        // Check della larghezza attuale
        if (this.width[f] != null) {
            this.verticalExtra = parseInt(j.css(this.obj, 'border-left-width'), 10) || 0;
            this.verticalExtra += parseInt(j.css(this.obj, 'border-right-width'), 10) || 0;
            this.verticalExtra += parseInt(j.css(this.obj, 'padding-left'), 10) || 0;
            this.verticalExtra += parseInt(j.css(this.obj, 'padding-right'), 10) || 0;
            this.startWidth[i] = (!isNaN(this.verticalExtra)) ? this.obj.offsetWidth - this.verticalExtra: this.obj.offsetWidth;
            this.changeWidth[i] = (this.width[f] == 'auto') ? ((this.valueType == 'abs') ? this.obj.scrollWidth - this.startWidth[i] : this.obj.scrollWidth) : ((this.valueType == 'abs') ? this.width[f] - this.startWidth[i] : this.width[f]);
        };
        // Check dell'altezza attuale		
        if (this.height[f] != null) {
            this.horizontalExtra = parseInt(j.css(this.obj, 'border-top-width'), 10) || 0;
            this.horizontalExtra += parseInt(j.css(this.obj, 'border-bottom-width'), 10) || 0;
            this.horizontalExtra += parseInt(j.css(this.obj, 'padding-top'), 10) || 0;
            this.horizontalExtra += parseInt(j.css(this.obj, 'padding-bottom'), 10) || 0;
            this.startHeight[i] = (!isNaN(this.horizontalExtra)) ? this.obj.offsetHeight - this.horizontalExtra: this.obj.offsetHeight;
            this.changeHeight[i] = (this.height[f] == 'auto') ? ((this.valueType == 'abs') ? this.obj.scrollHeight - this.startHeight[i] : this.obj.scrollHeight) : ((this.valueType == 'abs') ? this.height[f] - this.startHeight[i] : this.height[f]);
            //$$('debug1').innerHTML += this.startHeight[i]+'<br/>';
        };
        // Check di left e top
        if (this.left[f] != null) {
            this.startLeft[i] = parseInt(j.css(this.obj, 'left'), 10);
            this.changeLeft[i] = (this.valueType == 'abs') ? this.left[f] - this.startLeft[i] : this.left[f];
        };
        if (this.top[f] != null) {
            this.startTop[i] = parseInt(j.css(this.obj, 'top'), 10);
            this.changeTop[i] = (this.valueType == 'abs') ? this.top[f] - this.startTop[i] : this.top[f];
        };
        // Check del colore di background
        if (this.backgroundColor[f]) {
            this.startBackgroundRed[i] = j.htr(j.css(this.obj, 'background-color'))[0];
            this.startBackgroundGreen[i] = j.htr(j.css(this.obj, 'background-color'))[1];
            this.startBackgroundBlue[i] = j.htr(j.css(this.obj, 'background-color'))[2];
            this.changeBackgroundRed[i] = (j.htr(this.backgroundColor[f])[0] != this.startBackgroundRed[i]) ? j.htr(this.backgroundColor[f])[0] - this.startBackgroundRed[i] : 0;
            this.changeBackgroundGreen[i] = (j.htr(this.backgroundColor[f])[1] != this.startBackgroundGreen[i]) ? j.htr(this.backgroundColor[f])[1] - this.startBackgroundGreen[i] : 0;
            this.changeBackgroundBlue[i] = (j.htr(this.backgroundColor[f])[2] != this.startBackgroundBlue[i]) ? j.htr(this.backgroundColor[f])[2] - this.startBackgroundBlue[i] : 0;
        };
        // Check del colore del font
        if (this.fontColor[f]) {
            this.startFontRed[i] = j.htr(j.css(this.obj, 'color'))[0];
            this.startFontGreen[i] = j.htr(j.css(this.obj, 'color'))[1];
            this.startFontBlue[i] = j.htr(j.css(this.obj, 'color'))[2];
            this.changeFontRed[i] = (j.htr(this.fontColor[f])[0] != this.startFontRed[i]) ? j.htr(this.fontColor[f])[0] - this.startFontRed[i] : 0;
            this.changeFontGreen[i] = (j.htr(this.fontColor[f])[1] != this.startFontGreen[i]) ? j.htr(this.fontColor[f])[1] - this.startFontGreen[i] : 0;
            this.changeFontBlue[i] = (j.htr(this.fontColor[f])[2] != this.startFontBlue[i]) ? j.htr(this.fontColor[f])[2] - this.startFontBlue[i] : 0;
        };
        // Check del colore del bordo top
        if (this.borderTopColor[f]) {
            this.startBorderTopColorRed[i] = j.htr(j.css(this.obj, 'border-top-color'))[0];
            this.startBorderTopColorGreen[i] = j.htr(j.css(this.obj, 'border-top-color'))[1];
            this.startBorderTopColorBlue[i] = j.htr(j.css(this.obj, 'border-top-color'))[2];
            this.changeBorderTopColorRed[i] = (j.htr(this.borderTopColor[f])[0] != this.startBorderTopColorRed[i]) ? j.htr(this.borderTopColor[f])[0] - this.startBorderTopColorRed[i] : 0;
            this.changeBorderTopColorGreen[i] = (j.htr(this.borderTopColor[f])[1] != this.startBorderTopColorGreen[i]) ? j.htr(this.borderTopColor[f])[1] - this.startBorderTopColorGreen[i] : 0;
            this.changeBorderTopColorBlue[i] = (j.htr(this.borderTopColor[f])[2] != this.startBorderTopColorBlue[i]) ? j.htr(this.borderTopColor[f])[2] - this.startBorderTopColorBlue[i] : 0;
        };
        // Check del colore del bordo right
        if (this.borderRightColor[f]) {
            this.startBorderRightColorRed[i] = j.htr(j.css(this.obj, 'border-right-color'))[0];
            this.startBorderRightColorGreen[i] = j.htr(j.css(this.obj, 'border-right-color'))[1];
            this.startBorderRightColorBlue[i] = j.htr(j.css(this.obj, 'border-right-color'))[2];
            this.changeBorderRightColorRed[i] = (j.htr(this.borderRightColor[f])[0] != this.startBorderRightColorRed[i]) ? j.htr(this.borderRightColor[f])[0] - this.startBorderRightColorRed[i] : 0;
            this.changeBorderRightColorGreen[i] = (j.htr(this.borderRightColor[f])[1] != this.startBorderRightColorGreen[i]) ? j.htr(this.borderRightColor[f])[1] - this.startBorderRightColorGreen[i] : 0;
            this.changeBorderRightColorBlue[i] = (j.htr(this.borderRightColor[f])[2] != this.startBorderRightColorBlue[i]) ? j.htr(this.borderRightColor[f])[2] - this.startBorderRightColorBlue[i] : 0;
        };
        // Check del colore del bordo bottom
        if (this.borderBottomColor[f]) {
            this.startBorderBottomColorRed[i] = j.htr(j.css(this.obj, 'border-bottom-color'))[0];
            this.startBorderBottomColorGreen[i] = j.htr(j.css(this.obj, 'border-bottom-color'))[1];
            this.startBorderBottomColorBlue[i] = j.htr(j.css(this.obj, 'border-bottom-color'))[2];
            this.changeBorderBottomColorRed[i] = (j.htr(this.borderBottomColor[f])[0] != this.startBorderBottomColorRed[i]) ? j.htr(this.borderBottomColor[f])[0] - this.startBorderBottomColorRed[i] : 0;
            this.changeBorderBottomColorGreen[i] = (j.htr(this.borderBottomColor[f])[1] != this.startBorderBottomColorGreen[i]) ? j.htr(this.borderBottomColor[f])[1] - this.startBorderBottomColorGreen[i] : 0;
            this.changeBorderBottomColorBlue[i] = (j.htr(this.borderBottomColor[f])[2] != this.startBorderBottomColorBlue[i]) ? j.htr(this.borderBottomColor[f])[2] - this.startBorderBottomColorBlue[i] : 0;
        };
        // Check del colore del bordo left
        if (this.borderLeftColor[f]) {
            this.startBorderLeftColorRed[i] = j.htr(j.css(this.obj, 'border-left-color'))[0];
            this.startBorderLeftColorGreen[i] = j.htr(j.css(this.obj, 'border-left-color'))[1];
            this.startBorderLeftColorBlue[i] = j.htr(j.css(this.obj, 'border-left-color'))[2];
            this.changeBorderLeftColorRed[i] = (j.htr(this.borderLeftColor[f])[0] != this.startBorderLeftColorRed[i]) ? j.htr(this.borderLeftColor[f])[0] - this.startBorderLeftColorRed[i] : 0;
            this.changeBorderLeftColorGreen[i] = (j.htr(this.borderLeftColor[f])[1] != this.startBorderLeftColorGreen[i]) ? j.htr(this.borderLeftColor[f])[1] - this.startBorderLeftColorGreen[i] : 0;
            this.changeBorderLeftColorBlue[i] = (j.htr(this.borderLeftColor[f])[2] != this.startBorderLeftColorBlue[i]) ? j.htr(this.borderLeftColor[f])[2] - this.startBorderLeftColorBlue[i] : 0;
        };
        // Check del bordo attuale
        if (this.borderTop[f] != null) {
            this.startBorderTop[i] = parseInt(j.css(this.obj, 'border-top-width'), 10);
            this.changeBorderTop[i] = (this.valueType == 'abs') ? this.borderTop[f] - this.startBorderTop[i] : this.borderTop[f];
        };
        if (this.borderRight[f] != null) {
            this.startBorderRight[i] = parseInt(j.css(this.obj, 'border-right-width'), 10);
            this.changeBorderRight[i] = (this.valueType == 'abs') ? this.borderRight[f] - this.startBorderRight[i] : this.borderRight[f];
        };
        if (this.borderBottom[f] != null) {
            this.startBorderBottom[i] = parseInt(j.css(this.obj, 'border-bottom-width'), 10);
            this.changeBorderBottom[i] = (this.valueType == 'abs') ? this.borderBottom[f] - this.startBorderBottom[i] : this.borderBottom[f];
        };
        if (this.borderLeft[f] != null) {
            this.startBorderLeft[i] = parseInt(j.css(this.obj, 'border-left-width'), 10);
            this.changeBorderLeft[i] = (this.valueType == 'abs') ? this.borderLeft[f] - this.startBorderLeft[i] : this.borderLeft[f];
        };
        // Check del padding
        if (this.paddingTop[f] != null) {
            this.startPaddingTop[i] = parseInt(j.css(this.obj, 'padding-top'), 10);
            this.changePaddingTop[i] = (this.valueType == 'abs') ? this.paddingTop[f] - this.startPaddingTop[i] : this.paddingTop[f];
        };
        if (this.paddingRight[f] != null) {
            this.startPaddingRight[i] = parseInt(j.css(this.obj, 'padding-right'), 10);
            this.changePaddingRight[i] = (this.valueType == 'abs') ? this.paddingRight[f] - this.startPaddingRight[i] : this.paddingRight[f];
        };
        if (this.paddingBottom[f] != null) {
            this.startPaddingBottom[i] = parseInt(j.css(this.obj, 'padding-bottom'), 10);
            this.changePaddingBottom[i] = (this.valueType == 'abs') ? this.paddingBottom[f] - this.startPaddingBottom[i] : this.paddingBottom[f];
        };
        if (this.paddingLeft[f] != null) {
            this.startPaddingLeft[i] = parseInt(j.css(this.obj, 'padding-left'), 10);
            this.changePaddingLeft[i] = (this.valueType == 'abs') ? this.paddingLeft[f] - this.startPaddingLeft[i] : this.paddingLeft[f];
        };
        // Check del margin
        if (this.marginTop[f] != null || this.halign != 'top') {
            this.startMarginTop[i] = parseInt(j.css(this.obj, 'margin-top'), 10);
            if (this.halign == 'bottom') {
                this.changeMarginTop[i] = ( - (this.height[f] - this.startHeight[i]));
            } else if (this.halign == 'center') {
                this.changeMarginTop[i] = ( - ((this.width[f] / 2) - (this.startWidth[i] / 2)));
            } else {
                this.changeMarginTop[i] = (this.valueType == 'abs') ? this.marginTop[f] - this.startMarginTop[i] : this.marginTop[f];
            };
        };
        if (this.marginRight[f] != null) {
            this.startMarginRight[i] = parseInt(j.css(this.obj, 'margin-right'), 10);
            this.changeMarginRight[i] = (this.valueType == 'abs') ? this.marginRight[f] - this.startMarginRight[i] : this.marginRight[f];
        };
        if (this.marginBottom[f] != null) {
            this.startMarginBottom[i] = parseInt(j.css(this.obj, 'margin-bottom'), 10);
            this.changeMarginBottom[i] = (this.valueType == 'abs') ? this.marginBottom[f] - this.startMarginBottom[i] : this.marginBottom[f];
        };
        if (this.marginLeft[f] != null || this.walign != 'left') {
            this.startMarginLeft[i] = parseInt(j.css(this.obj, 'margin-left'), 10);
            if (this.walign == 'right') {
                this.changeMarginLeft[i] = ( - (this.width[f] - this.startWidth[i]));
            } else if (this.walign == 'center') {
                this.changeMarginLeft[i] = ( - ((this.width[f] / 2) - (this.startWidth[i] / 2)));
            } else {
                this.changeMarginLeft[i] = (this.valueType == 'abs') ? this.marginLeft[f] - this.startMarginLeft[i] : this.marginLeft[f];
            };
        };
        // Check del font
        if (!this.unit) this.unit = 'px';
        if (this.fontSize[f] != null) {
            this.startFontSize[i] = parseInt(j.css(this.obj, 'font-size'), 10);
            this.changeFontSize[i] = (this.valueType == 'abs') ? this.fontSize[f] - this.startFontSize[i] : this.fontSize[f];
        };
    },
    fxLoop: function() {
        this.fxLoopActions = j.fxLoopActions;
        if (this.time < this.duration && this.time != -1) {
            this.time++;
            if (this.object.length > 0) {
                for (var i in this.object) {
                    this.obj = $$((this.object[i]).replace('#', ''));
                    this.fxLoopActions(i, i);
                };
            } else {
                //this.doms = j.dom(this.dom);
                for (var i in this.doms) {
                    this.obj = this.doms[i];
                    if (this.obj != $$(this.except)) {
                        this.fxLoopActions(i, 0);
                    } else {
                        this.fxLoopActions(i, 1);
                    };
                };
            };
            // Loop
            var that = this;
            this.fxTM = setTimeout(function() {
                that.fxLoop();
            },
            1);
        } else {
            //$$('header').innerHTML = (new Date().getTime()) - performanceTime;
            // Operazioni di chiusura	
            window.clearTimeout(this.fxTM);
            if (this.$) { (typeof this.$ == 'string') ? eval(this.$) : ((this.$.action) ? this.$.play() : this.$());
            };
        };
    },
    fxLoopActions: function(i, f) {
        //$$('info').innerHTML += this.obj.className+" ";

        // Setta la nuova classe CSS se disponibile
        if (this.time == 1 && this.newClass[f] && this.newClass[f] != 'null') this.obj.className = (this.newClass[f]).replace('.', '');

        // Set width con fix per numeri negativi
        if (!isNaN(this.changeWidth[i])) this.obj.style.width = ((j.fxEasing(this.easing, parseInt(this.startWidth[i], 10), parseInt(this.changeWidth[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startWidth[i], 10), parseInt(this.changeWidth[i], 10), this.duration, this.time) : 0) + 'px';

        // Set height con fix per numeri negativi
        if (!isNaN(this.changeHeight[i])) this.obj.style.height = ((j.fxEasing(this.easing, parseInt(this.startHeight[i], 10), parseInt(this.changeHeight[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startHeight[i], 10), parseInt(this.changeHeight[i], 10), this.duration, this.time) : 0) + 'px';

        // Set opacity
        if (!isNaN(this.changeOpacity[i])) {
            this.obj.style.filter = 'alpha(opacity:' + parseInt(j.fxEasing(this.easing, parseInt(this.startOpacity[i], 10), parseInt(this.changeOpacity[i], 10), this.duration, this.time), 10) + ')';
            this.obj.style.KHTMLOpacity = parseInt(j.fxEasing(this.easing, parseInt(this.startOpacity[i], 10), parseInt(this.changeOpacity[i], 10), this.duration, this.time), 10) / 100;
            this.obj.style.MozOpacity = parseInt(j.fxEasing(this.easing, parseInt(this.startOpacity[i], 10), parseInt(this.changeOpacity[i], 10), this.duration, this.time), 10) / 100;
            this.obj.style.opacity = parseInt(j.fxEasing(this.easing, parseInt(this.startOpacity[i], 10), parseInt(this.changeOpacity[i], 10), this.duration, this.time), 10) / 100;
        };

        // Set left e top con fix per numeri negativi
        if (!isNaN(this.changeLeft[i])) this.obj.style.left = ((j.fxEasing(this.easing, parseInt(this.startLeft[i], 10), parseInt(this.changeLeft[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startLeft[i], 10), parseInt(this.changeLeft[i], 10), this.duration, this.time) : 0) + 'px';
        if (!isNaN(this.changeTop[i])) this.obj.style.top = ((j.fxEasing(this.easing, parseInt(this.startTop[i], 10), parseInt(this.changeTop[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startTop[i], 10), parseInt(this.changeTop[i], 10), this.duration, this.time) : 0) + 'px';

        // Set backgroundColor con fix per numeri negativi
        if (this.backgroundColor[f] && this.backgroundColor[f] != 'null' && this.backgroundColor[f] != 'transparent') {
            this.$backgroundRed = (parseInt(j.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time), 10).toString(16)));
            this.$backgroundGreen = (parseInt(j.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time), 10).toString(16)));
            this.$backgroundBlue = (parseInt(j.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time), 10).toString(16)));
            this.obj.style.backgroundColor = '#' + this.$backgroundRed + this.$backgroundGreen + this.$backgroundBlue;
        };

        // Set color con fix per numeri negativi
        if (this.fontColor[f] && this.fontColor[f] != 'null') {
            this.$colorRed = (parseInt(j.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time), 10).toString(16)));
            this.$colorGreen = (parseInt(j.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time), 10).toString(16)));
            this.$colorBlue = (parseInt(j.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time), 10).toString(16)));
            this.obj.style.color = '#' + this.$colorRed + this.$colorGreen + this.$colorBlue;
        };

        // Set borderTopColor con fix per numeri negativi
        if (this.borderTopColor[f] && this.borderTopColor[f] != 'null') {
            this.$borderTopRed = (parseInt(j.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time), 10).toString(16)));
            this.$borderTopGreen = (parseInt(j.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time), 10).toString(16)));
            this.$borderTopBlue = (parseInt(j.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time), 10).toString(16)));
            this.$borderTopRgb = '#' + this.$borderTopRed + this.$borderTopGreen + this.$borderTopBlue;
        };

        // Set borderRightColor con fix per numeri negativi
        if (this.borderRightColor[f] && this.borderRightColor[f] != 'null') {
            this.$borderRightRed = (parseInt(j.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time), 10).toString(16)));
            this.$borderRightGreen = (parseInt(j.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time), 10).toString(16)));
            this.$borderRightBlue = (parseInt(j.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time), 10).toString(16)));
            this.$borderRightRgb = '#' + this.$borderRightRed + this.$borderRightGreen + this.$borderRightBlue;
        };

        // Set borderBottomColor con fix per numeri negativi
        if (this.borderBottomColor[f] && this.borderBottomColor[f] != 'null') {
            this.$borderBottomRed = (parseInt(j.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time), 10).toString(16)));
            this.$borderBottomGreen = (parseInt(j.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time), 10).toString(16)));
            this.$borderBottomBlue = (parseInt(j.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time), 10).toString(16)));
            this.$borderBottomRgb = '#' + this.$borderBottomRed + this.$borderBottomGreen + this.$borderBottomBlue;
        };

        // Set borderLeftColor con fix per numeri negativi
        if (this.borderLeftColor[f] && this.borderLeftColor[f] != 'null') {
            this.$borderLeftRed = (parseInt(j.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time), 10).toString(16)));
            this.$borderLeftGreen = (parseInt(j.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time), 10).toString(16)));
            this.$borderLeftBlue = (parseInt(j.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time), 10) < 0) ? '00': ((parseInt(j.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time), 10) > 255) ? 'ff': ((parseInt(j.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time), 10).toString(16).length == 1) ? '0' + parseInt(j.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time), 10).toString(16) : parseInt(j.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time), 10).toString(16)));
            this.$borderLeftRgb = '#' + this.$borderLeftRed + this.$borderLeftGreen + this.$borderLeftBlue;
        };

        // Set borders con fix per numeri negativi
        if (!isNaN(this.changeBorderTop[i])) this.obj.style.borderTopWidth = ((j.fxEasing(this.easing, parseInt(this.startBorderTop[i], 10), parseInt(this.changeBorderTop[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startBorderTop[i], 10), parseInt(this.changeBorderTop[i], 10), this.duration, this.time) : 0) + 'px';
        if (!isNaN(this.changeBorderRight[i])) this.obj.style.borderRightWidth = ((j.fxEasing(this.easing, parseInt(this.startBorderRight[i], 10), parseInt(this.changeBorderRight[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startBorderRight[i], 10), parseInt(this.changeBorderRight[i], 10), this.duration, this.time) : 0) + 'px';
        if (!isNaN(this.changeBorderBottom[i])) this.obj.style.borderBottomWidth = ((j.fxEasing(this.easing, parseInt(this.startBorderBottom[i], 10), parseInt(this.changeBorderBottom[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startBorderBottom[i], 10), parseInt(this.changeBorderBottom[i], 10), this.duration, this.time) : 0) + 'px';
        if (!isNaN(this.changeBorderLeft[i])) this.obj.style.borderLeftWidth = ((j.fxEasing(this.easing, parseInt(this.startBorderLeft[i], 10), parseInt(this.changeBorderLeft[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startBorderLeft[i], 10), parseInt(this.changeBorderLeft[i], 10), this.duration, this.time) : 0) + 'px';

        // Setta i colori dei bordi
        if (this.borderTopColor[f]) this.obj.style.borderTopColor = this.$borderTopRgb;
        if (this.borderRightColor[f]) this.obj.style.borderRightColor = this.$borderRightRgb;
        if (this.borderBottomColor[f]) this.obj.style.borderBottomColor = this.$borderBottomRgb;
        if (this.borderLeftColor[f]) this.obj.style.borderLeftColor = this.$borderLeftRgb;

        // Set padding con fix per numeri negativi
        if (!isNaN(this.changePaddingTop[i])) this.obj.style.paddingTop = ((j.fxEasing(this.easing, parseInt(this.startPaddingTop[i], 10), parseInt(this.changePaddingTop[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startPaddingTop[i], 10), parseInt(this.changePaddingTop[i], 10), this.duration, this.time) : 0) + 'px';
        if (!isNaN(this.changePaddingRight[i])) this.obj.style.paddingRight = ((j.fxEasing(this.easing, parseInt(this.startPaddingRight[i], 10), parseInt(this.changePaddingRight[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startPaddingRight[i], 10), parseInt(this.changePaddingRight[i], 10), this.duration, this.time) : 0) + 'px';
        if (!isNaN(this.changePaddingBottom[i])) this.obj.style.paddingBottom = ((j.fxEasing(this.easing, parseInt(this.startPaddingBottom[i], 10), parseInt(this.changePaddingBottom[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startPaddingBottom[i], 10), parseInt(this.changePaddingBottom[i], 10), this.duration, this.time) : 0) + 'px';
        if (!isNaN(this.changePaddingLeft[i])) this.obj.style.paddingLeft = ((j.fxEasing(this.easing, parseInt(this.startPaddingLeft[i], 10), parseInt(this.changePaddingLeft[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startPaddingLeft[i], 10), parseInt(this.changePaddingLeft[i], 10), this.duration, this.time) : 0) + 'px ';

        // Set margin con fix per numeri negativi
        if (!isNaN(this.changeMarginTop[i])) this.obj.style.marginTop = j.fxEasing(this.easing, parseInt(this.startMarginTop[i], 10), parseInt(this.changeMarginTop[i], 10), this.duration, this.time) + 'px';
        if (!isNaN(this.changeMarginRight[i])) this.obj.style.marginRight = j.fxEasing(this.easing, parseInt(this.startMarginRight[i], 10), parseInt(this.changeMarginRight[i], 10), this.duration, this.time) + 'px';
        if (!isNaN(this.changeMarginBottom[i])) this.obj.style.marginBottom = j.fxEasing(this.easing, parseInt(this.startMarginBottom[i], 10), parseInt(this.changeMarginBottom[i], 10), this.duration, this.time) + 'px';
        if (!isNaN(this.changeMarginLeft[i])) this.obj.style.marginLeft = j.fxEasing(this.easing, parseInt(this.startMarginLeft[i], 10), parseInt(this.changeMarginLeft[i], 10), this.duration, this.time) + 'px';

        // Set font-size con fix per numeri negativi
        if (!isNaN(this.changeFontSize[i])) this.obj.style.fontSize = ((j.fxEasing(this.easing, parseInt(this.startFontSize[i], 10), parseInt(this.changeFontSize[i], 10), this.duration, this.time) >= 0) ? j.fxEasing(this.easing, parseInt(this.startFontSize[i], 10), parseInt(this.changeFontSize[i], 10), this.duration, this.time) : 0) + this.unit;
    },
    fxEasing: function(e, s, c, d, t) {
        var er;
        switch (e) {
        case 'linear':
            er = c * t / d + s;
            break;
            // al quadrato
        case 'quadIn':
            er = c * (t /= d) * t + s;
            break;
        case 'quadOut':
            er = -c * (t /= d) * (t - 2) + s;
            break;
        case 'quadInOut':
            if ((t /= d / 2) < 1) er = c / 2 * t * t + s;
            er = -c / 2 * ((--t) * (t - 2) - 1) + s;
            break;
            // al cubo
        case 'cubeIn':
            er = c * Math.pow(t / d, 3) + s;
            break;
        case 'cubeOut':
            er = c * (Math.pow(t / d - 1, 3) + 1) + s;
            break;
        case 'cubeInOut':
            if ((t /= d / 2) < 1) er = c / 2 * Math.pow(t, 3) + s;
            er = c / 2 * (Math.pow(t - 2, 3) + 2) + s;
            break;
            // alla quarta
        case 'fourthIn':
            er = c * (t /= d) * Math.pow(t, 3) + s;
            break;
        case 'fourthOut':
            er = -c * ((t = t / d - 1) * Math.pow(t, 3) - 1) + s;
            break;
        case 'fourthInOut':
            if ((t /= d / 2) < 1) er = c / 2 * Math.pow(t, 4) + s;
            er = -c / 2 * ((t -= 2) * Math.pow(t, 3) - 2) + s;
            break;
            // alla quinta
        case 'fifthIn':
            er = c * (t /= d) * Math.pow(t, 4) + s;
            break;
        case 'fifthOut':
            er = c * ((t = t / d - 1) * Math.pow(t, 4) + 1) + s;
            break;
        case 'fifthInOut':
            if ((t /= d / 2) < 1) er = c / 2 * Math.pow(t, 5) + s;
            er = c / 2 * ((t -= 2) * Math.pow(t, 4) + 2) + s;
            break;
            // al seno
        case 'sineIn':
            er = c * (1 - Math.cos(t / d * (Math.PI / 2))) + s;
            break;
        case 'sineOut':
            er = c * Math.sin(t / d * (Math.PI / 2)) + s;
            break;
        case 'sineInOut':
            er = -c / 2 * (Math.cos(Math.PI * t / d) - 1) + s;
            break;
            // esponenziale
        case 'expoIn':
            er = c * Math.pow(2, 10 * (t / d - 1)) + s;
            break;
        case 'expoOut':
            er = (t == d) ? s + c: c * ( - Math.pow(2, -10 * t / d) + 1) + s;
            break;
        case 'expoInOut':
            if (t == 0) er = s;
            if (t == d) er = s + c;
            if ((t /= d / 2) < 1) er = c / 2 * Math.pow(2, 10 * (t - 1)) + s;
            er = c / 2 * ( - Math.pow(2, -10 * --t) + 2) + s;
            break;
            // circolare
        case 'circularIn':
            er = -c * (Math.sqrt(1 - (t /= d) * t) - 1) + s;
            break;
        case 'circularOut':
            er = c * Math.sqrt(1 - (t = t / d - 1) * t) + s;
            break;
        case 'circularInOut':
            if ((t /= d / 2) < 1) er = -c / 2 * (Math.sqrt(1 - Math.pow(t, 2)) - 1) + s;
            er = c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + s;
            break;
            // elastico   >> problemi con IE risolti sostituendo  '(this.a < Math.abs(c))'  con  '(this.a <= Math.abs(c))'
        case 'elasticIn':
            this.s = 1.70158;
            this.p = 0;
            this.a = c;
            if (t == 0) er = s;
            if ((t /= d) == 1) er = s + c;
            if (!this.p) this.p = d * .3;
            if (this.a <= Math.abs(c)) {
                this.a = c;
                this.s = this.p / 4;
            } else this.s = this.p / (2 * Math.PI) * Math.asin(c / this.a);
            er = -(this.a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - this.s) * (2 * Math.PI) / this.p)) + s;
            break;
        case 'elasticOut':
            this.s = 1.70158;
            this.p = 0;
            this.a = c;
            if (t == 0) er = s;
            if ((t /= d) == 1) er = s + c;
            if (!this.p) this.p = d * .3;
            if (this.a <= Math.abs(c)) {
                this.a = c;
                this.s = this.p / 4;
            } else this.s = this.p / (2 * Math.PI) * Math.asin(c / this.a);
            er = this.a * Math.pow(2, -10 * t) * Math.sin((t * d - this.s) * (2 * Math.PI) / this.p) + c + s;
            break;
        case 'elasticInOut':
            this.s = 1.70158;
            this.p = 0;
            this.a = c;
            if (t == 0) er = s;
            if ((t /= d / 2) == 2) er = s + c;
            if (!this.p) this.p = d * (.3 * 1.5);
            if (this.a <= Math.abs(c)) {
                this.a = c;
                this.s = this.p / 4;
            } else this.s = this.p / (2 * Math.PI) * Math.asin(c / this.a);
            if (t < 1) er = -.5 * (this.a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - this.s) * (2 * Math.PI) / this.p)) + s;
            er = this.a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - this.s) * (2 * Math.PI) / this.p) * .5 + c + s;
            break;
            // torna indietro
        case 'backIn':
            this.s = 1.70158;
            er = c * (t /= d) * t * ((this.s + 1) * t - this.s) + s;
            break;
        case 'backOut':
            this.s = 1.70158;
            er = c * ((t = t / d - 1) * t * ((this.s + 1) * t + this.s) + 1) + s;
            break;
        case 'backInOut':
            this.s = 1.70158;
            if ((t /= d / 2) < 1) er = c / 2 * (Math.pow(t, 2) * (((this.s *= (1.525)) + 1) * t - this.s)) + s;
            er = c / 2 * ((t -= 2) * t * (((this.s *= (1.525)) + 1) * t + this.s) + 2) + s;
            break;
            // rimbalzo
        case 'bounceIn':
            er = c - j.fxEasing('bounceOut', 0, c, d, d - t) + s;
            break;
        case 'bounceOut':
            if ((t /= d) < (1 / 2.75)) {
                er = c * (7.5625 * Math.pow(t, 2)) + s;
            } else if (t < (2 / 2.75)) {
                er = c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + s;
            } else if (t < (2.5 / 2.75)) {
                er = c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + s;
            } else {
                er = c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + s;
            };
            break;
        case 'bounceInOut':
            //e, s, c, d, t
            if (t < d / 2) er = j.fxEasing('bounceIn', 0, c, d, t * 2) * .5 + s;
            er = j.fxEasing('bounceOut', 0, c, d, t * 2 - d) * .5 + c * .5 + s;
            break;
        };
        return parseInt(er, 10);
    },

    // API jool.drag
    drag: function(obj) {
        return new j.$drag(obj);
    },
    $drag: function(p) {
        j.gps();
        this.object = p.object.replace('#', '');
        this.mover = (p.mover || p.object).replace('#', '');
        this.startevent = p.startevent || 'mousedown';
        this.endevent = p.endevent || 'mouseup';
        this.top = (p.cage && p.cage[0] != 'null') ? p.cage[0] : -Infinity;
        this.right = (p.cage && p.cage[1] != 'null') ? p.cage[1] : Infinity;
        this.bottom = (p.cage && p.cage[2] != 'null') ? p.cage[2] : Infinity;
        this.left = (p.cage && p.cage[3] != 'null') ? p.cage[3] : -Infinity;
        this.onstart = p.onstart;
        this.onmove = p.onmove;
        this.onstop = p.onstop;
        this.rtop = (p.resize && p.resize[0] != 'null') ? p.resize[0] : 0;
        this.rright = (p.resize && p.resize[1] != 'null') ? p.resize[1] : 0;
        this.rbottom = (p.resize && p.resize[2] != 'null') ? p.resize[2] : 0;
        this.rleft = (p.resize && p.resize[3] != 'null') ? p.resize[3] : 0;
        this.target = p.target;
        this.successfully = this.$ = p.successfully;
        this.unsuccessfully = this.n$ = p.unsuccessfully;
        this.stop = j.stop;
        this.dragGo = j.dragGo;
        this.dragGo();
    },
    dragGo: function() {
        var that = this;
        if ($$(this.object)) {
            window.clearTimeout(this.drTM);
            if (that.top != -Infinity) that.top = parseInt(j.css($$(that.object), 'margin-top'), 10) + that.top;
            if (that.right != Infinity) that.right = parseInt(j.css($$(that.object), 'margin-left'), 10) + parseInt(j.css($$(that.object), 'width'), 10) + that.right;
            if (that.bottom != Infinity) that.bottom = parseInt(j.css($$(that.object), 'margin-top'), 10) + parseInt(j.css($$(that.object), 'height'), 10) + that.bottom;
            if (that.left != -Infinity) that.left = parseInt(j.css($$(that.object), 'margin-left'), 10) + that.left;
            this.go = function() {
                // all'inizio del drag
                // that.newObj = $$(that.object).cloneNode(true);
                // document.body.appendChild(that.newObj);
                (j.sniff('IE')) ? document.attachEvent('onmousemove', that.move) : document.addEventListener('mousemove', that.move, false);
                (j.sniff('IE')) ? document.attachEvent('ondrag',
                function() {
                    return;
                }) : document.addEventListener('mousemove', that.move, false);
                (j.sniff('IE')) ? document.attachEvent(('on' + that.endevent), that.release) : document.addEventListener(that.endevent, that.release, false);
                if (that.onstart) { (typeof that.onstart == 'string') ? eval(that.onstart) : ((that.onstart.action) ? that.onstart.play() : that.onstart());
                };
                that.drag = 'null';
                that.start = false;
            };
            this.move = function() {
                // durante il drag
                if (that.onmove) { (typeof that.onmove == 'string') ? eval(that.onmove) : ((that.onmove.action) ? that.onmove.play() : that.onmove());
                };
                if (that.start == false) {
                    this.startX = j.gps.x;
                    this.startY = j.gps.y;
                    this.startW = parseInt(j.css($$(that.object), 'width'), 10);
                    this.startH = parseInt(j.css($$(that.object), 'height'), 10);
                    this.x = j.gps.x - parseInt(j.css($$(that.object), 'margin-left'), 10);
                    this.y = j.gps.y - parseInt(j.css($$(that.object), 'margin-top'), 10);
                    that.start = true;
                };
                var ol = ot = null;
                var op = $$(that.object).offsetParent;
                while (op) {
                    ol += op.offsetLeft;
                    ot += op.offsetTop;
                    op = op.offsetParent;
                };
                this.leftPoint = parseInt(j.css($$(that.object), 'margin-left'), 10) + parseInt(j.css($$(that.object), 'left'), 10) + ol;
                this.topPoint = parseInt(j.css($$(that.object), 'margin-top'), 10) + parseInt(j.css($$(that.object), 'top'), 10) + ot;
                this.rightPoint = this.leftPoint + this.startW;
                this.bottomPoint = this.topPoint + this.startH;
                // Drag
                if ((j.gps.x > (this.leftPoint + that.rleft) && j.gps.x < (this.rightPoint - that.rright) && j.gps.y > (this.topPoint + that.rtop) && j.gps.y < (this.bottomPoint - that.rbottom) && that.drag == 'null') || that.drag == 'drag') {
                    $$(that.object).style.cursor = 'move';
                    that.drag = 'drag';
                    that.vdrag = 'drag';
                    if ((j.gps.x - this.x) > that.left && ((j.gps.x - this.x) + this.startW) < that.right) $$(that.object).style.marginLeft = (j.gps.x - this.x) + 'px';
                    if ((j.gps.y - this.y) > that.top && ((j.gps.y - this.y) + parseInt(j.css($$(that.object), 'height'), 10)) < that.bottom) $$(that.object).style.marginTop = (j.gps.y - this.y) + 'px';
                };
                // Resize Left-Right
                if ((j.gps.x > this.leftPoint && j.gps.x < (this.leftPoint + that.rleft) && that.drag == 'null') || that.drag == 'left') {
                    $$(that.object).style.cursor = 'w-resize';
                    that.drag = 'left';
                    $$(that.object).style.width = ((this.startW - (j.gps.x - this.startX)) >= 10) ? (this.startW - (j.gps.x - this.startX)) + 'px': '10px';
                    if ((j.gps.y > this.topPoint && j.gps.y < (this.topPoint + that.rtop)) || that.vdrag == 'lt') {
                        $$(that.object).style.cursor = 'nw-resize';
                        that.vdrag = 'lt';
                        $$(that.object).style.height = ((this.startH - (j.gps.y - this.startY)) >= 10) ? (this.startH - (j.gps.y - this.startY)) + 'px': '10px';
                        if ((this.startH - (j.gps.y - this.startY)) >= 10) $$(that.object).style.marginTop = (j.gps.y - this.y) + 'px';
                    };
                    if ((j.gps.y < this.bottomPoint && j.gps.y > (this.bottomPoint - that.rbottom)) || that.vdrag == 'lb') {
                        $$(that.object).style.cursor = 'sw-resize';
                        that.vdrag = 'lb';
                        $$(that.object).style.height = ((this.startH + (j.gps.y - this.startY)) > 10) ? (this.startH + (j.gps.y - this.startY)) + 'px': '10px';
                    };
                    if ((this.startW - (j.gps.x - this.startX)) >= 10) $$(that.object).style.marginLeft = (j.gps.x - this.x) + 'px';
                };
                if ((j.gps.x < this.rightPoint && j.gps.x > (this.rightPoint - that.rright) && that.drag == 'null') || that.drag == 'right') {
                    $$(that.object).style.cursor = 'e-resize';
                    that.drag = 'right';
                    $$(that.object).style.width = ((this.startW + (j.gps.x - this.startX)) > 10) ? (this.startW + (j.gps.x - this.startX)) + 'px': '10px';
                    if ((j.gps.y > this.topPoint && j.gps.y < (this.topPoint + that.rtop)) || that.vdrag == 'rt') {
                        $$(that.object).style.cursor = 'ne-resize';
                        that.vdrag = 'rt';
                        $$(that.object).style.height = ((this.startH - (j.gps.y - this.startY)) >= 10) ? (this.startH - (j.gps.y - this.startY)) + 'px': '10px';
                        if ((this.startH - (j.gps.y - this.startY)) >= 10) $$(that.object).style.marginTop = (j.gps.y - this.y) + 'px';
                    };
                    if ((j.gps.y < this.bottomPoint && j.gps.y > (this.bottomPoint - that.rbottom)) || that.vdrag == 'rb') {
                        $$(that.object).style.cursor = 'se-resize';
                        that.vdrag = 'rb';
                        $$(that.object).style.height = ((this.startH + (j.gps.y - this.startY)) > 10) ? (this.startH + (j.gps.y - this.startY)) + 'px': '10px';
                    };
                };
                // Resize Top-Bottom
                if ((j.gps.y > this.topPoint && j.gps.y < (this.topPoint + that.rtop) && that.drag == 'null') || that.drag == 'top') {
                    $$(that.object).style.cursor = 'n-resize';
                    that.drag = 'top';
                    $$(that.object).style.height = ((this.startH - (j.gps.y - this.startY)) >= 10) ? (this.startH - (j.gps.y - this.startY)) + 'px': '10px';
                    if ((this.startH - (j.gps.y - this.startY)) >= 10) $$(that.object).style.marginTop = (j.gps.y - this.y) + 'px';
                };
                if ((j.gps.y < this.bottomPoint && j.gps.y > (this.bottomPoint - that.rbottom) && that.drag == 'null') || that.drag == 'bottom') {
                    $$(that.object).style.cursor = 's-resize';
                    that.drag = 'bottom';
                    $$(that.object).style.height = ((this.startH + (j.gps.y - this.startY)) > 10) ? (this.startH + (j.gps.y - this.startY)) + 'px': '10px';
                };
                that.lastX = j.gps.x;
                that.lastY = j.gps.y;
                if (that.startX != that.lastX) that.moved = true;
            };
            this.release = function() {
                // alla fine del drag
                that.start = false;
                that.drag = 'null';
                that.vdrag = 'null';
                $$(that.object).style.cursor = 'move';
                if (that.onstop) { (typeof that.onstop == 'string') ? eval(that.onstop) : ((that.onstop.action) ? that.onstop.play() : that.onstop());
                };
                (j.sniff('IE')) ? (document.detachEvent('onmousemove', that.move)) : document.removeEventListener('mousemove', that.move, false);
                (j.sniff('IE')) ? document.detachEvent(('on' + that.endevent), that.release) : document.removeEventListener(that.endevent, that.release, false);
                if (that.target && that.moved) {
                    if (that.lastX < $$(that.target).offsetLeft || that.lastX > ($$(that.target).offsetLeft + $$(that.target).offsetWidth) || that.lastY < $$(that.target).offsetTop || that.lastY > ($$(that.target).offsetTop + $$(that.target).offsetHeight)) {
                        if (that.unsuccessfully) {
                            that.$ = that.unsuccessfully;
                            if (that.n$) { (typeof that.n$ == 'string') ? eval(that.n$) : ((that.n$.action) ? that.n$.play() : that.n$());
                            };
                        };
                    } else {
                        if (that.successfully) {
                            that.$ = that.successfully;
                            if (that.$) { (typeof that.$ == 'string') ? eval(that.$) : ((that.$.action) ? that.$.play() : that.$());
                            };
                        };
                    };
                } else if (!that.target && that.successfully) {
                    that.$ = that.successfully;
                    if (that.$) { (typeof that.$ == 'string') ? eval(that.$) : ((that.$.action) ? that.$.play() : that.$());
                    };
                };
            };
            (j.sniff('IE')) ? $$(this.mover).attachEvent(('on' + this.startevent), this.go) : $$(this.mover).addEventListener(this.startevent, this.go, false);
            (j.sniff('IE')) ? $$(this.object).attachEvent('onmouseover',
            function() {
                $$(that.object).style.cursor = 'move';
            }) : $$(this.object).addEventListener('mouseover',
            function() {
                $$(that.object).style.cursor = 'move';
            },
            false);
        } else if (!$$(this.object)) {
            this.drTM = setTimeout(function() {
                that.dragGo();
            },
            1);
        };
    },

    // API jool.event
    event: function(obj) {
        return new j.$event(obj);
    },
    $event: function(p) {
        this.object = p.object;
        this.tag = p.tag;
        this.dom = p.dom;
        this.event = p.event;
        this.remove = p.remove || false;
        this.action = p.action;
        this.capturing = p.capturing || false;       // not for IE
        this.eventLoop = j.eventLoop;
        this.eventLoop();
    },
    eventLoop: function() {
        if (this.object) {
				for (var x=0; x<this.object.length; x++) {  
            	if ($$(this.object[x].replace('#', ''))) {
                	if (this.remove == false) {
                    	(j.sniff('IE')) ? $$(this.object[x].replace('#', '')).attachEvent('on' + this.event, this.action) : $$(this.object[x].replace('#', '')).addEventListener(this.event, this.action, this.capturing);
                	} else {
                    	(j.sniff('IE')) ? $$(this.object[x].replace('#', '')).attachEvent('on' + this.event,
                    	function(event) {
                        event.stopPropagation();
                    }) : $$(this.object[x].replace('#', '')).removeEventListener(this.event,
                    	function(event) {
                        event.stopPropagation();
                    },
                    	this.capturing);
                	}
                	clearTimeout(this.evTM);
            	} else if (!$$(this.object[x].replace('#', ''))) {
                	var that = this;
                	this.evTM = setTimeout(function() {
                    that.eventLoop();
                },
                	1);
            	};
        		};
				return;
		  };
        if (this.dom) {
            this.doms = j.dom(this.dom);
            if (this.doms.length > 0) {
                for (var t in this.doms) {
                    (j.sniff('IE')) ? this.doms[t].attachEvent('on' + this.event, this.action) : this.doms[t].addEventListener(this.event, this.action, this.capturing);
                };
                clearTimeout(this.evTM);
                return;
            };
            var that = this;
            this.evTM = setTimeout(function() {
                that.eventLoop();
            },
            1);
        };
    }
};

var j = jool;
