// Automatic.Digital.Design v0.6.5.14
// This code ©2008 Giovanni Di Gregorio All Rights Reserved · makao.it
// Every intellectual property reserved. Please refer to makao.it/add
// Please report comments or bugs to add@makao.it
// Free for personal and commercial use, please not remove this copyrights informations


// General utilities
function al(value) {
	window.alert(value);
}
function $$(obj) { 
	return document.getElementById(obj);
}

// Namespace AutomaticDigitalDesign
var AutomaticDigitalDesign = {
	
	// Utilities
	sniff : function(b) { // sniffa il browser
		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;
		};
	},
	spin : function(obj, what, pos) { // popola un innerHTML
		$$(obj).innerHTML = (!pos) ? what : ((pos == 'after') ? what+$$(obj).innerHTML : $$(obj).innerHTML+what);
	},
	getCssValue : function(obj, p) { // legge il valore di una proprietą CSS 
		if(add.sniff('IE')) { 
			switch (p) {
				case 'background-color': p = 'backgroundColor'; break;
				case 'border-top-width': p = 'borderTopWidth'; break;
				case 'border-top-color': p = 'borderTopColor'; break;
				case 'border-right-width': p = 'borderRightWidth'; break;
				case 'border-right-color': p = 'borderRightColor'; break;
				case 'border-bottom-width': p = 'borderBottomWidth'; break;
				case 'border-bottom-color': p = 'borderBottomColor'; break;
				case 'border-left-width': p = 'borderLeftWidth'; break;
				case 'border-left-color': p = 'borderLeftColor'; break;
				case 'padding-top': p = 'paddingTop'; break;
				case 'padding-right': p = 'paddingRight'; break;
				case 'padding-bottom': p = 'paddingBottom'; break;
				case 'padding-left': p = 'paddingLeft'; break;
				case 'margin-top': p = 'marginTop'; break;
				case 'margin-right': p = 'marginRight'; break;
				case 'margin-bottom': p = 'marginBottom'; break;
				case 'margin-left': p = 'marginLeft'; break;
				case 'font-size': p = 'fontSize'; break;
			};
			return obj.currentStyle[p];
		} else {
			return document.defaultView.getComputedStyle(obj,null).getPropertyValue(p);
		};
	},
	parseClass : function(cn,p) { // legge il valore di una proprietą in una classe CSS  - uso interno
		this.classname = '.'+cn;
		this.cssRules;
		if(add.sniff('IE')) {
			this.cssRules = 'rules';
		} else {
			this.cssRules = 'cssRules';
		};
		for (var s = 0; s < document.styleSheets.length; s++){
			for (var r = 0; r < document.styleSheets[s][this.cssRules].length; r++) {
				if(document.styleSheets[s][this.cssRules][r].selectorText == this.classname) {
					return document.styleSheets[s][this.cssRules][r].style[p];
				};
			};
		};
	},
	hexToRgb : function(color) { // converte un valore esadecimale in RGB - uso interno
		if(color.toString().indexOf('#') != -1) {
			color = color.replace(/#/g, "");
			this.rgbRed = parseInt(color.slice(0,2), 16);
			this.rgbGreen = parseInt(color.slice(2,4), 16);
			this.rgbBlue = parseInt(color.slice(4,6), 16);
			this.rgbArray = [this.rgbRed, this.rgbGreen, this.rgbBlue];
		} else {
			this.rgbArray = color.replace(/rgb\(|\)/g, '').split(', ');
			this.rgbArray = [parseInt(this.rgbArray[0]),parseInt(this.rgbArray[1]),parseInt(this.rgbArray[2])];
		};
		return this.rgbArray;
	},
	mouse : function(e) {
		this.xy = {
			x : (add.sniff('IE')) ? window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft : e.pageX,
			y : (add.sniff('IE')) ? window.event.clientY  + document.body.scrollTop + document.documentElement.scrollTop : e.pageY
		};
		return this.xy;
	},

	// Methods
	play : function(e) { // metodo di avvio per script, wait, load, fx, drag
		this.easing = this.easing || 'linear';
		if(!this.duration || this.duration == 0 || this.duration == 1) this.duration = 2;
		(this.valueType != 'rel') ? this.valueType = 'abs' : this.valueType = 'rel';
		switch (this.action) {
			case 'fx':
				for(x in this.newClass) {
					if(this.newClass[x] != 'null') {
						if((!this.opacity[x] || this.opacity[x] == 'null') && add.parseClass(this.newClass[x], 'opacity')) this.opacity[x] = parseInt(add.parseClass(this.newClass[x], 'opacity'));
						if((!this.width[x] || this.width[x] == 'null') && add.parseClass(this.newClass[x], 'width')) this.width[x] = parseInt(add.parseClass(this.newClass[x], 'width'));
						if((!this.height[x] || this.height[x] == 'null') && add.parseClass(this.newClass[x], 'height')) this.height[x] = parseInt(add.parseClass(this.newClass[x], 'height'));
						if((!this.left[x] || this.left[x] == 'null') && add.parseClass(this.newClass[x], 'left')) this.left[x] = parseInt(add.parseClass(this.newClass[x], 'left'));
						if((!this.top[x] || this.top[x] == 'null') && add.parseClass(this.newClass[x], 'top')) this.top[x] = parseInt(add.parseClass(this.newClass[x], 'top'));
						if((!this.backgroundColor[x] || this.backgroundColor[x] == 'null') && add.parseClass(this.newClass[x], 'backgroundColor')) this.backgroundColor[x] = add.parseClass(this.newClass[x], 'backgroundColor');
						if((!this.borderTop[x] || this.borderTop[x] == 'null') && add.parseClass(this.newClass[x], 'borderTopWidth')) this.borderTop[x] = parseInt(add.parseClass(this.newClass[x], 'borderTopWidth'));
						if((!this.borderTopColor[x] || this.borderTopColor[x] == 'null') && add.parseClass(this.newClass[x], 'borderTopColor')) this.borderTopColor[x] = add.parseClass(this.newClass[x], 'borderTopColor');
						if((!this.borderRight[x] || this.borderRight[x] == 'null') && add.parseClass(this.newClass[x], 'borderRightWidth')) this.borderRight[x] = parseInt(add.parseClass(this.newClass[x], 'borderRightWidth'));
						if((!this.borderRightColor[x] || this.borderRightColor[x] == 'null') && add.parseClass(this.newClass[x], 'borderRightColor')) this.borderRightColor[x] = add.parseClass(this.newClass[x], 'borderRightColor');
						if((!this.borderBottom[x] || this.borderBottom[x] == 'null') && add.parseClass(this.newClass[x], 'borderBottomWidth')) this.borderBottom[x] = parseInt(add.parseClass(this.newClass[x], 'borderBottomWidth'));
						if((!this.borderBottomColor[x] || this.borderBottomColor[x] == 'null') && add.parseClass(this.newClass[x], 'borderBottomColor')) this.borderBottomColor[x] = add.parseClass(this.newClass[x], 'borderBottomColor');
						if((!this.borderLeft[x] || this.borderLeft[x] == 'null') && add.parseClass(this.newClass[x], 'borderLeftWidth')) this.borderLeft[x] = parseInt(add.parseClass(this.newClass[x], 'borderLeftWidth'));
						if((!this.borderLeftColor[x] || this.borderLeftColor[x] == 'null') && add.parseClass(this.newClass[x], 'borderLeftColor')) this.borderLeftColor[x] = add.parseClass(this.newClass[x], 'borderLeftColor');
						if((!this.paddingTop[x] || this.paddingTop[x] == 'null') && add.parseClass(this.newClass[x], 'paddingTop')) this.paddingTop[x] = parseInt(add.parseClass(this.newClass[x], 'paddingTop'));
						if((!this.paddingRight[x] || this.paddingRight[x] == 'null') && add.parseClass(this.newClass[x], 'paddingRight')) this.paddingRight[x] = parseInt(add.parseClass(this.newClass[x], 'paddingRight'));
						if((!this.paddingBottom[x] || this.paddingBottom[x] == 'null') && add.parseClass(this.newClass[x], 'paddingBottom')) this.paddingBottom[x] = parseInt(add.parseClass(this.newClass[x], 'paddingBottom'));
						if((!this.paddingLeft[x] || this.paddingLeft[x] == 'null') && add.parseClass(this.newClass[x], 'paddingLeft')) this.paddingLeft[x] = parseInt(add.parseClass(this.newClass[x], 'paddingLeft'));
						if((!this.marginTop[x] || this.marginTop[x] == 'null') && add.parseClass(this.newClass[x], 'marginTop')) this.marginTop[x] = parseInt(add.parseClass(this.newClass[x], 'marginTop'));
						if((!this.marginRight[x] || this.marginRight[x] == 'null') && add.parseClass(this.newClass[x], 'marginRight')) this.marginRight[x] = parseInt(add.parseClass(this.newClass[x], 'marginRight'));
						if((!this.marginBottom[x] || this.marginBottom[x] == 'null') && add.parseClass(this.newClass[x], 'marginBottom')) this.marginBottom[x] = parseInt(add.parseClass(this.newClass[x], 'marginBottom'));
						if((!this.marginLeft[x] || this.marginLeft[x] == 'null') && add.parseClass(this.newClass[x], 'marginLeft')) this.marginLeft[x] = parseInt(add.parseClass(this.newClass[x], 'marginLeft'));
						if((!this.fontSize[x] || this.fontSize[x] == 'null') && add.parseClass(this.newClass[x], 'fontSize')) this.fontSize[x] = parseInt(add.parseClass(this.newClass[x], 'fontSize'));
						if((!this.color[x] || this.color[x] == 'null') && add.parseClass(this.newClass[x], 'color')) this.color[x] = add.parseClass(this.newClass[x], 'color');
					};
				};
				this.fxGo = add.fxGo;
				this.fxGo();
			break;
			case 'script':
				this.stop(true);
				this.scriptGo = add.scriptGo;
				this.scriptGo();
			break;
			case 'wait':
				this.stop(true);
				this.waitGo = add.waitGo;
				this.waitGo();
			break;
			case 'load':
				this.loadGo = add.loadGo;
				this.loadGo();
			break;
			case 'drag':
				this.stop(true);
				this.object = this.object || ((add.sniff('IE')) ? e.srcElement.id : e.target.id);
				this.dragGo = add.dragGo;
				this.dragGo(e);
			break;
		}
	},
	stop : function(i) {
		clearTimeout(this.fxTM);
		this.obj = this.$;
		this.inherit = function() { // ereditarietą dello stop
			if(this.obj) {
				clearTimeout(this.obj.fxTM);
				this.obj = this.obj.$;
				var that = this;
				this.stopTM = setTimeout(function() { that.inherit(); }, 20);
			};
		};
		if(i) this.inherit();
	},
	
	// Class add.script
	script : function(p) {
		this.exec = p.exec;
		this.successfully = p.successfully;
		this.$ = p.successfully;
		this.action = 'script';
		this.wait = p.wait;
		this.play = add.play;
		this.stop = add.stop;
	},
	scriptGo : function() {
		var that = this;
		this.exec();
		if(this.wait && this.successfully) { this.waitTM = setTimeout(function() { that.successfully.play() }, this.wait) } else if(!this.wait && this.successfully) { this.successfully.play() };
	},
	
	// Class add.wait
	wait : function(p) {
		this.wait = p.wait;
		this.successfully = p.successfully;		
		this.$ = p.successfully;
		this.action = 'wait';
		this.play = add.play;
		this.stop = add.stop;
	},
	waitGo : function() {
		var that = this;
		this.waitTM = setTimeout(function() { that.successfully.play() }, this.wait);
	},
	
	// Class add.load
	load : function(p) {
		this.object =  p.object || [];
		this.uri = p.uri || [];
		this.method = p.method || 'get';
		this.render =  p.render;
		this.requestHeader = p.requestHeader || 'application/x-www-form-urlencoded';
		this.successfully = p.successfully;
		this.wait = p.wait;
		this.$ = p.successfully;
		this.action = 'load';
		this.play = add.play;
	},
	loadGo : function() {
		this.url = (this.uri.indexOf('?') == -1) ? this.uri + "?add.cache=" + new Date().getTime() : this.uri + "&add.cache=" + new Date().getTime();
		var that = this;
		var http = (add.sniff('IE') && !add.sniff('IE7+')) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		http.open(this.method, this.url);
		http.onreadystatechange = function() {
		    if(http.readyState == 4) {
			    if(http.status == 200) {
					if(that.object) { add.spin(that.object, http.responseText, that.render) } else { return http.responseText };
					if(that.wait && that.successfully) { that.waitTM = setTimeout(function() { that.successfully.play() }, that.wait) } else if(!that.wait && that.successfully) { that.successfully.play() }
			    };
		    };
	    };
		http.setRequestHeader('Content-Type', this.requestHeader);
		http.send(null);
	},

	// Class add.fx
	fx : function(p) {
		this.object = (p.object) ? ((typeof p.object != 'object') ? [p.object] : p.object) : [];
		this.newClass = p.newClass || [];
		this.object = p.object || [];
		this.opacity = p.opacity || [];
		this.width = p.width || [];
		this.height = p.height || [];
		this.left = p.left || [];
		this.top = p.top || [];
		this.backgroundColor = p.backgroundColor || [];
		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.paddingTop = p.paddingTop || (p.padding || []);
		this.paddingRight = p.paddingRight || (p.padding ||	[]);
		this.paddingBottom = p.paddingBottom || (p.padding || []);
		this.paddingLeft = p.paddingLeft || (p.padding || []);
		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.fps = p.fps;
		this.easing = p.easing;
		this.duration = p.duration;
		this.wait = p.wait;
		this.successfully = p.successfully;
		this.$ = p.successfully;
		this.action = 'fx';
		this.play = add.play;
		this.stop = add.stop;
	},
	fxGo : function() {
		this.time = 0;
		// 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 = [];
		for(i in this.object) {
			this.obj = $$(this.object[i]);
			// Check dell'opacitą attuale, 'isNaN' č usato per il supporto a MSIE
			if(!this.startOpacity[i]) {
				if(add.getCssValue(this.obj, 'display') == 'none' && ((this.obj.style.opacity*100) <= 0 || isNaN((this.obj.style.opacity*100)))) {
					this.startOpacity[i] = 0;
					// this.obj.style.visibility = 'hidden';
				} else if(add.getCssValue(this.obj, 'display') != 'none' && ((this.obj.style.opacity*100) <= 0 || isNaN((this.obj.style.opacity*100)))) {
					this.startOpacity[i] = 100;
				} else {
					this.startOpacity[i] = (this.obj.style.opacity*100);
				};
			} else {
				this.startOpacity[i] = this.startOpacity[i];
			};
			this.obj.style.display = 'inline';
			this.changeOpacity[i] = (this.valueType == 'abs') ? this.opacity[i] - this.startOpacity[i] : this.opacity[i];
			// Check della larghezza attuale
			this.verticalExtra = (parseInt(add.getCssValue(this.obj, 'border-right-width')) + parseInt(add.getCssValue(this.obj, 'border-left-width')) + parseInt(add.getCssValue(this.obj, 'padding-left')) + parseInt(add.getCssValue(this.obj, 'padding-right')));
			if(!this.startWidth[i]) {
				this.startWidth[i] =  (!isNaN(this.verticalExtra)) ? this.obj.offsetWidth - this.verticalExtra : this.obj.offsetWidth;	
			};
			this.changeWidth[i] = (this.valueType == 'abs') ? this.width[i] - this.startWidth[i] : this.width[i];
			// Check dell'altezza attuale
			this.horizontalExtra = (parseInt(add.getCssValue(this.obj, 'border-top-width')) + parseInt(add.getCssValue(this.obj, 'border-bottom-width')) + parseInt(add.getCssValue(this.obj, 'padding-top')) + parseInt(add.getCssValue(this.obj, 'padding-bottom')));
			if(!this.startHeight[i]) {
				this.startHeight[i] = (!isNaN(this.horizontalExtra)) ? this.obj.offsetHeight - this.horizontalExtra : this.obj.offsetHeight;
			};
			this.changeHeight[i] = (this.valueType == 'abs') ? this.height[i] - this.startHeight[i] : this.height[i];
			// Check di left e top
			this.startLeft[i] = parseInt(add.getCssValue(this.obj, 'left'));
			this.changeLeft[i] = (this.valueType == 'abs') ? this.left[i] - this.startLeft[i] : this.left[i];
			this.startTop[i] = parseInt(add.getCssValue(this.obj, 'top'));
			this.changeTop[i] = (this.valueType == 'abs') ? this.top[i] - this.startTop[i] : this.top[i];
			// Check del colore di background
			if(this.backgroundColor[i]) {
				this.startBackgroundRed[i] = add.hexToRgb(add.getCssValue(this.obj, 'background-color'))[0];
				this.startBackgroundGreen[i] = add.hexToRgb(add.getCssValue(this.obj, 'background-color'))[1];
				this.startBackgroundBlue[i] = add.hexToRgb(add.getCssValue(this.obj, 'background-color'))[2];
				this.changeBackgroundRed[i] = (add.hexToRgb(this.backgroundColor[i])[0] != this.startBackgroundRed[i]) ? add.hexToRgb(this.backgroundColor[i])[0] - this.startBackgroundRed[i] : 0;
				this.changeBackgroundGreen[i] = (add.hexToRgb(this.backgroundColor[i])[1] != this.startBackgroundGreen[i]) ? add.hexToRgb(this.backgroundColor[i])[1] - this.startBackgroundGreen[i] : 0;
				this.changeBackgroundBlue[i] = (add.hexToRgb(this.backgroundColor[i])[2] != this.startBackgroundBlue[i]) ? add.hexToRgb(this.backgroundColor[i])[2] - this.startBackgroundBlue[i] : 0;
			};
			// Check del colore del font 
			if(this.fontColor[i]) {
				this.startFontRed[i] = add.hexToRgb(add.getCssValue(this.obj, 'color'))[0];
				this.startFontGreen[i] =add.hexToRgb(add.getCssValue(this.obj, 'color'))[1];
				this.startFontBlue[i] = add.hexToRgb(add.getCssValue(this.obj, 'color'))[2];
				this.changeFontRed[i] = (add.hexToRgb(this.fontColor[i])[0] != this.startFontRed[i]) ? add.hexToRgb(this.fontColor[i])[0] - this.startFontRed[i] : 0;
				this.changeFontGreen[i] = (add.hexToRgb(this.fontColor[i])[1] != this.startFontGreen[i]) ? add.hexToRgb(this.fontColor[i])[1] - this.startFontGreen[i] : 0;
				this.changeFontBlue[i] = (add.hexToRgb(this.fontColor[i])[2] != this.startFontBlue[i]) ? add.hexToRgb(this.fontColor[i])[2] - this.startFontBlue[i] : 0;
			};
			// Check del colore del bordo top
			if(this.borderTopColor[i]) {
				this.startBorderTopColorRed[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-top-color'))[0];
				this.startBorderTopColorGreen[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-top-color'))[1];
				this.startBorderTopColorBlue[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-top-color'))[2];
				this.changeBorderTopColorRed[i] = (add.hexToRgb(this.borderTopColor[i])[0] != this.startBorderTopColorRed[i]) ? add.hexToRgb(this.borderTopColor[i])[0] - this.startBorderTopColorRed[i] : 0;
				this.changeBorderTopColorGreen[i] = (add.hexToRgb(this.borderTopColor[i])[1] != this.startBorderTopColorGreen[i]) ? add.hexToRgb(this.borderTopColor[i])[1] - this.startBorderTopColorGreen[i] : 0;
				this.changeBorderTopColorBlue[i] = (add.hexToRgb(this.borderTopColor[i])[2] != this.startBorderTopColorBlue[i]) ? add.hexToRgb(this.borderTopColor[i])[2] - this.startBorderTopColorBlue[i] : 0;		
			};
			// Check del colore del bordo right
			if(this.borderRightColor[i]) {
				this.startBorderRightColorRed[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-right-color'))[0];
				this.startBorderRightColorGreen[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-right-color'))[1];
				this.startBorderRightColorBlue[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-right-color'))[2];
				this.changeBorderRightColorRed[i] = (add.hexToRgb(this.borderRightColor[i])[0] != this.startBorderRightColorRed[i]) ? add.hexToRgb(this.borderRightColor[i])[0] - this.startBorderRightColorRed[i] : 0;
				this.changeBorderRightColorGreen[i] = (add.hexToRgb(this.borderRightColor[i])[1] != this.startBorderRightColorGreen[i]) ? add.hexToRgb(this.borderRightColor[i])[1] - this.startBorderRightColorGreen[i] : 0;
				this.changeBorderRightColorBlue[i] = (add.hexToRgb(this.borderRightColor[i])[2] != this.startBorderRightColorBlue[i]) ? add.hexToRgb(this.borderRightColor[i])[2] - this.startBorderRightColorBlue[i] : 0;		
			};
			// Check del colore del bordo bottom
			if(this.borderBottomColor[i]) {
				this.startBorderBottomColorRed[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-bottom-color'))[0];
				this.startBorderBottomColorGreen[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-bottom-color'))[1];
				this.startBorderBottomColorBlue[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-bottom-color'))[2];
				this.changeBorderBottomColorRed[i] = (add.hexToRgb(this.borderBottomColor[i])[0] != this.startBorderBottomColorRed[i]) ? add.hexToRgb(this.borderBottomColor[i])[0] - this.startBorderBottomColorRed[i] : 0;
				this.changeBorderBottomColorGreen[i] = (add.hexToRgb(this.borderBottomColor[i])[1] != this.startBorderBottomColorGreen[i]) ? add.hexToRgb(this.borderBottomColor[i])[1] - this.startBorderBottomColorGreen[i] : 0;
				this.changeBorderBottomColorBlue[i] = (add.hexToRgb(this.borderBottomColor[i])[2] != this.startBorderBottomColorBlue[i]) ? add.hexToRgb(this.borderBottomColor[i])[2] - this.startBorderBottomColorBlue[i] : 0;		
			};
			// Check del colore del bordo left
			if(this.borderLeftColor[i]) {
				this.startBorderLeftColorRed[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-left-color'))[0];
				this.startBorderLeftColorGreen[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-left-color'))[1];
				this.startBorderLeftColorBlue[i] = add.hexToRgb(add.getCssValue(this.obj, 'border-left-color'))[2];
				this.changeBorderLeftColorRed[i] = (add.hexToRgb(this.borderLeftColor[i])[0] != this.startBorderLeftColorRed[i]) ? add.hexToRgb(this.borderLeftColor[i])[0] - this.startBorderLeftColorRed[i] : 0;
				this.changeBorderLeftColorGreen[i] = (add.hexToRgb(this.borderLeftColor[i])[1] != this.startBorderLeftColorGreen[i]) ? add.hexToRgb(this.borderLeftColor[i])[1] - this.startBorderLeftColorGreen[i] : 0;
				this.changeBorderLeftColorBlue[i] = (add.hexToRgb(this.borderLeftColor[i])[2] != this.startBorderLeftColorBlue[i]) ? add.hexToRgb(this.borderLeftColor[i])[2] - this.startBorderLeftColorBlue[i] : 0;		
			};
			// Check del bordo attuale
			this.startBorderTop[i] = parseInt(add.getCssValue(this.obj, 'border-top-width'));
			this.startBorderRight[i] = parseInt(add.getCssValue(this.obj, 'border-right-width'));
			this.startBorderBottom[i] = parseInt(add.getCssValue(this.obj, 'border-bottom-width'));
			this.startBorderLeft[i] = parseInt(add.getCssValue(this.obj, 'border-left-width'));
			this.changeBorderTop[i] = (this.valueType == 'abs') ? this.borderTop[i] - this.startBorderTop[i] : this.borderTop[i];
			this.changeBorderRight[i] = (this.valueType == 'abs') ? this.borderRight[i] - this.startBorderRight[i] : this.borderRight[i];
			this.changeBorderBottom[i] = (this.valueType == 'abs') ? this.borderBottom[i] - this.startBorderBottom[i] : this.borderBottom[i];
			this.changeBorderLeft[i] = (this.valueType == 'abs') ? this.borderLeft[i] - this.startBorderLeft[i] : this.borderLeft[i];
			// Check del padding
			this.startPaddingTop[i] = parseInt(add.getCssValue(this.obj, 'padding-top'));
			this.startPaddingRight[i] = parseInt(add.getCssValue(this.obj, 'padding-right'));
			this.startPaddingBottom[i] = parseInt(add.getCssValue(this.obj, 'padding-bottom'));
			this.startPaddingLeft[i] = parseInt(add.getCssValue(this.obj, 'padding-left'));
			this.changePaddingTop[i] = (this.valueType == 'abs') ? this.paddingTop[i] - this.startPaddingTop[i] : this.paddingTop[i];
			this.changePaddingRight[i] = (this.valueType == 'abs') ? this.paddingRight[i] - this.startPaddingRight[i] : this.paddingRight[i];
			this.changePaddingBottom[i] = (this.valueType == 'abs') ? this.paddingBottom[i] - this.startPaddingBottom[i] : this.paddingBottom[i];
			this.changePaddingLeft[i] = (this.valueType == 'abs') ? this.paddingLeft[i] - this.startPaddingLeft[i] : this.paddingLeft[i];
			// Check del margin
			this.startMarginTop[i] = parseInt(add.getCssValue(this.obj, 'margin-top'));
			this.startMarginRight[i] = parseInt(add.getCssValue(this.obj, 'margin-right'));
			this.startMarginBottom[i] = parseInt(add.getCssValue(this.obj, 'margin-bottom'));
			this.startMarginLeft[i] = parseInt(add.getCssValue(this.obj, 'margin-left'));
			this.changeMarginTop[i] = (this.valueType == 'abs') ? this.marginTop[i] - this.startMarginTop[i] : this.marginTop[i];
			this.changeMarginRight[i] = (this.valueType == 'abs') ? this.marginRight[i] - this.startMarginRight[i] : this.marginRight[i];
			this.changeMarginBottom[i] = (this.valueType == 'abs') ? this.marginBottom[i] - this.startMarginBottom[i] : this.marginBottom[i];
			this.changeMarginLeft[i] = (this.valueType == 'abs') ? this.marginLeft[i] - this.startMarginLeft[i] : this.marginLeft[i];
			// Check del font
			if(!this.unit) this.unit = 'px';
			this.startFontSize[i] = parseInt(add.getCssValue(this.obj, 'font-size'));
			this.changeFontSize[i] = (this.valueType == 'abs') ? this.fontSize[i] - this.startFontSize[i] : this.fontSize[i];
		};
		this.fxLoop = add.fxLoop;  
		this.fxLoop();
	},
	fxLoop : function() {
		if(this.time < this.duration && this.time != -1){
			this.time++;
			for (i in this.object) {
				this.obj = $$(this.object[i]);
				// Setta la nuova classe CSS se disponibile
				if(this.time == 1 && this.newClass[i] && this.newClass[i] != 'null') this.obj.className = this.newClass[i];
				// set width con fix per numeri negativi
				if(!isNaN(this.changeWidth[i])) this.obj.style.width = ((add.fxEasing(this.easing, parseInt(this.startWidth[i]), parseInt(this.changeWidth[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startWidth[i]), parseInt(this.changeWidth[i]), this.duration, this.time) : 0) + 'px';
				// set height con fix per numeri negativi
				if(!isNaN(this.changeHeight[i])) this.obj.style.height = ((add.fxEasing(this.easing, parseInt(this.startHeight[i]), parseInt(this.changeHeight[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startHeight[i]), parseInt(this.changeHeight[i]), this.duration, this.time) : 0) + 'px';
				// set opacity
				if(!isNaN(this.changeOpacity[i])) {
					this.obj.style.filter = "alpha(opacity:" + parseInt(add.fxEasing(this.easing, parseInt(this.startOpacity[i]), parseInt(this.changeOpacity[i]), this.duration, this.time)) + ")";
					this.obj.style.KHTMLOpacity = parseInt(add.fxEasing(this.easing, parseInt(this.startOpacity[i]), parseInt(this.changeOpacity[i]), this.duration, this.time))/100;
					this.obj.style.MozOpacity = parseInt(add.fxEasing(this.easing, parseInt(this.startOpacity[i]), parseInt(this.changeOpacity[i]), this.duration, this.time))/100;
					this.obj.style.opacity = parseInt(add.fxEasing(this.easing, parseInt(this.startOpacity[i]), parseInt(this.changeOpacity[i]), this.duration, this.time))/100;
				};
				// set left e top con fix per numeri negativi
				if(!isNaN(this.changeLeft[i])) this.obj.style.left = ((add.fxEasing(this.easing, parseInt(this.startLeft[i]), parseInt(this.changeLeft[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startLeft[i]), parseInt(this.changeLeft[i]), this.duration, this.time) : 0) + 'px';
				if(!isNaN(this.changeTop[i])) this.obj.style.top = ((add.fxEasing(this.easing, parseInt(this.startTop[i]), parseInt(this.changeTop[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startTop[i]), parseInt(this.changeTop[i]), this.duration, this.time) : 0) + 'px';
				// set backgroundColor con fix per numeri negativi
				if(this.backgroundColor[i] && this.backgroundColor[i] != 'null' && this.backgroundColor[i] != 'transparent') {
					this.$backgroundRed = (parseInt(add.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBackgroundRed[i], this.changeBackgroundRed[i], this.duration, this.time)).toString(16)));
					this.$backgroundGreen = (parseInt(add.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBackgroundGreen[i], this.changeBackgroundGreen[i], this.duration, this.time)).toString(16)));
					this.$backgroundBlue = (parseInt(add.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBackgroundBlue[i], this.changeBackgroundBlue[i], this.duration, this.time)).toString(16)));				
					this.obj.style.backgroundColor = '#'+this.$backgroundRed+this.$backgroundGreen+this.$backgroundBlue;
				};
				// set color con fix per numeri negativi
				if(this.fontColor[i] && this.fontColor[i] != 'null') {
					this.$colorRed = (parseInt(add.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startFontRed[i], this.changeFontRed[i], this.duration, this.time)).toString(16)));
					this.$colorGreen = (parseInt(add.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startFontGreen[i], this.changeFontGreen[i], this.duration, this.time)).toString(16)));
					this.$colorBlue = (parseInt(add.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startFontBlue[i], this.changeFontBlue[i], this.duration, this.time)).toString(16)));
					this.obj.style.color = '#'+this.$colorRed+this.$colorGreen+this.$colorBlue;			
				};
				// set borderTopColor con fix per numeri negativi
				if(this.borderTopColor[i] && this.borderTopColor[i] != 'null') {
					this.$borderTopRed = (parseInt(add.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderTopColorRed[i], this.changeBorderTopColorRed[i], this.duration, this.time)).toString(16)));
					this.$borderTopGreen = (parseInt(add.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderTopColorGreen[i], this.changeBorderTopColorGreen[i], this.duration, this.time)).toString(16)));
					this.$borderTopBlue = (parseInt(add.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderTopColorBlue[i], this.changeBorderTopColorBlue[i], this.duration, this.time)).toString(16)));
					this.$borderTopRgb = '#'+this.$borderTopRed+this.$borderTopGreen+this.$borderTopBlue;
				};
				// set borderRightColor con fix per numeri negativi
				if(this.borderRightColor[i] && this.borderRightColor[i] != 'null') {
					this.$borderRightRed = (parseInt(add.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderRightColorRed[i], this.changeBorderRightColorRed[i], this.duration, this.time)).toString(16)));
					this.$borderRightGreen = (parseInt(add.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderRightColorGreen[i], this.changeBorderRightColorGreen[i], this.duration, this.time)).toString(16)));
					this.$borderRightBlue = (parseInt(add.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderRightColorBlue[i], this.changeBorderRightColorBlue[i], this.duration, this.time)).toString(16)));
					this.$borderRightRgb = '#'+this.$borderRightRed+this.$borderRightGreen+this.$borderRightBlue;
				};
				// set borderBottomColor con fix per numeri negativi
				if(this.borderBottomColor[i] && this.borderBottomColor[i] != 'null') {
					this.$borderBottomRed = (parseInt(add.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderBottomColorRed[i], this.changeBorderBottomColorRed[i], this.duration, this.time)).toString(16)));
					this.$borderBottomGreen = (parseInt(add.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderBottomColorGreen[i], this.changeBorderBottomColorGreen[i], this.duration, this.time)).toString(16)));
					this.$borderBottomBlue = (parseInt(add.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderBottomColorBlue[i], this.changeBorderBottomColorBlue[i], this.duration, this.time)).toString(16)));
					this.$borderBottomRgb = '#'+this.$borderBottomRed+this.$borderBottomGreen+this.$borderBottomBlue;
				};
				// set borderLeftColor con fix per numeri negativi
				if(this.borderLeftColor[i] && this.borderLeftColor[i] != 'null') {
					this.$borderLeftRed = (parseInt(add.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderLeftColorRed[i], this.changeBorderLeftColorRed[i], this.duration, this.time)).toString(16)));
					this.$borderLeftGreen = (parseInt(add.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderLeftColorGreen[i], this.changeBorderLeftColorGreen[i], this.duration, this.time)).toString(16)));
					this.$borderLeftBlue = (parseInt(add.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time)) < 0) ? '00' : ((parseInt(add.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time)) > 255) ? 'ff' : ((parseInt(add.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time)).toString(16).length == 1) ? '0'+parseInt(add.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time)).toString(16) : parseInt(add.fxEasing(this.easing, this.startBorderLeftColorBlue[i], this.changeBorderLeftColorBlue[i], this.duration, this.time)).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 = ((add.fxEasing(this.easing, parseInt(this.startBorderTop[i]), parseInt(this.changeBorderTop[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startBorderTop[i]), parseInt(this.changeBorderTop[i]), this.duration, this.time) : 0) + 'px';
				if(!isNaN(this.changeBorderRight[i])) this.obj.style.borderRightWidth = ((add.fxEasing(this.easing, parseInt(this.startBorderRight[i]), parseInt(this.changeBorderRight[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startBorderRight[i]), parseInt(this.changeBorderRight[i]), this.duration, this.time) : 0) + 'px';
				if(!isNaN(this.changeBorderBottom[i])) this.obj.style.borderBottomWidth = ((add.fxEasing(this.easing, parseInt(this.startBorderBottom[i]), parseInt(this.changeBorderBottom[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startBorderBottom[i]), parseInt(this.changeBorderBottom[i]), this.duration, this.time) : 0) + 'px';
				if(!isNaN(this.changeBorderLeft[i])) this.obj.style.borderLeftWidth = ((add.fxEasing(this.easing, parseInt(this.startBorderLeft[i]), parseInt(this.changeBorderLeft[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startBorderLeft[i]), parseInt(this.changeBorderLeft[i]), this.duration, this.time) : 0) + 'px';
				if(this.borderTopColor[i]) this.obj.style.borderTopColor = this.$borderTopRgb;
				if(this.borderRightColor[i]) this.obj.style.borderRightColor = this.$borderRightRgb;
				if(this.borderBottomColor[i]) this.obj.style.borderBottomColor = this.$borderBottomRgb;
				if(this.borderLeftColor[i]) this.obj.style.borderLeftColor = this.$borderLeftRgb;
				// set padding con fix per numeri negativi
				if(!isNaN(this.changePaddingTop[i])) this.obj.style.paddingTop = ((add.fxEasing(this.easing, parseInt(this.startPaddingTop[i]), parseInt(this.changePaddingTop[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startPaddingTop[i]), parseInt(this.changePaddingTop[i]), this.duration, this.time) : 0) + 'px';
				if(!isNaN(this.changePaddingRight[i])) this.obj.style.paddingRight = ((add.fxEasing(this.easing, parseInt(this.startPaddingRight[i]), parseInt(this.changePaddingRight[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startPaddingRight[i]), parseInt(this.changePaddingRight[i]), this.duration, this.time) : 0) + 'px';
				if(!isNaN(this.changePaddingBottom[i])) this.obj.style.paddingBottom = ((add.fxEasing(this.easing, parseInt(this.startPaddingBottom[i]), parseInt(this.changePaddingBottom[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startPaddingBottom[i]), parseInt(this.changePaddingBottom[i]), this.duration, this.time) : 0) + 'px';
				if(!isNaN(this.changePaddingLeft[i])) this.obj.style.paddingLeft = ((add.fxEasing(this.easing, parseInt(this.startPaddingLeft[i]), parseInt(this.changePaddingLeft[i]), this.duration, this.time) >= 0) ? add.fxEasing(this.easing, parseInt(this.startPaddingLeft[i]), parseInt(this.changePaddingLeft[i]), this.duration, this.time) : 0) + 'px ';
				if(!isNaN(this.changeMarginTop[i])) this.obj.style.marginTop = add.fxEasing(this.easing, parseInt(this.startMarginTop[i]), parseInt(this.changeMarginTop[i]), this.duration, this.time) + 'px';
				if(!isNaN(this.changeMarginRight[i])) this.obj.style.marginRight = add.fxEasing(this.easing, parseInt(this.startMarginRight[i]), parseInt(this.changeMarginRight[i]), this.duration, this.time) + 'px';
				if(!isNaN(this.changeMarginBottom[i])) this.obj.style.marginBottom = add.fxEasing(this.easing, parseInt(this.startMarginBottom[i]), parseInt(this.changeMarginBottom[i]), this.duration, this.time) + 'px';
				if(!isNaN(this.changeMarginLeft[i])) this.obj.style.marginLeft = add.fxEasing(this.easing, parseInt(this.startMarginLeft[i]), parseInt(this.changeMarginLeft[i]), this.duration, this.time) + 'px';
				// set font-size con fix per numeri negativi
				if(!isNaN(this.changeFontSize[i])) this.obj.style.fontSize = ((add.fxEasing(this.easing, parseInt(this.startFontSize[i]), parseInt(this.changeFontSize[i]), this.duration, this.time) >=0) ? add.fxEasing(this.easing, parseInt(this.startFontSize[i]), parseInt(this.changeFontSize[i]), this.duration, this.time) : 0) + this.unit;
			};
			// loop
			var that = this;
			this.fxTM = setTimeout(function() { that.fxLoop(); }, 20);
		} else {		
			// Operazioni di chiusura	
			var that = this;
			clearTimeout(this.fxTM);
			if(this.wait && this.successfully) { this.waitTM = setTimeout(function() { that.successfully.play() }, this.wait) } else if(!this.wait && this.successfully) { this.successfully.play() }
			// ((this.obj.style.opacity*100) <= 0 && !isNaN(this.changeOpacity) && time != -1) ? this.obj.style.display = 'none' : null;			
		};
	},
	fxEasing : function(easing, start, change, duration, time) {
		switch (easing){
			case 'linear' : 
				return change*time/duration+start;
			break;
			// al quadrato
			case 'quadIn' : 
				return change*(time/=duration)*time+start;
			break;
			case 'quadOut' :
				return -change*(time/=duration)*(time-2)+start;
			break;
			case 'quadInOut' :
				if((time/=duration/2)<1) return change/2*time*time+start;
				return -change/2*((--time)*(time-2)-1)+start;
			break;
			// al cubo
			case 'cubeIn' :
				return change*Math.pow(time/duration,3)+start;
			break;
			case 'cubeOut' :
				return change*(Math.pow(time/duration-1,3)+1)+start;			
			break;
			case 'cubeInOut' :
				if((time/=duration/2)<1) return change/2*Math.pow(time,3)+start;
				return change/2*(Math.pow(time-2,3)+2)+start;
			break;
			// alla quarta
			case 'fourthIn' :
				return change*(time/=duration)*Math.pow(time,3) + start;
			break;
			case 'fourthOut' :
				return -change * ((time=time/duration-1)*Math.pow(time,3) - 1) + start;	
			break;
			case 'fourthInOut' :
				if((time/=duration/2) < 1) return change/2*Math.pow(time,4) + start;
				return -change/2 * ((time-=2)*Math.pow(time,3) - 2) + start;
			break;
			// alla quinta
			case 'fifthIn' :
				return change*(time/=duration)*Math.pow(time,4) + start;
			break;
			case 'fifthOut' :
				return change*((time=time/duration-1)*Math.pow(time,4) + 1) + start;	
			break;
			case 'fifthInOut' :
				if((time/=duration/2) < 1) return change/2*Math.pow(time,5) + start;
				return change/2*((time-=2)*Math.pow(time,4) + 2) + start;
			break;
			// al seno
			case 'sineIn' :
				return change*(1-Math.cos(time/duration*(Math.PI/2)))+start;
			break;
			case 'sineOut' :
				return change*Math.sin(time/duration*(Math.PI/2))+start;
			break;
			case 'sineInOut' :
				return -change/2 * (Math.cos(Math.PI*time/duration) - 1) + start;
			break;
			// esponenziale
			case 'expoIn' :
				return change*Math.pow(2,10*(time/duration-1))+start;
			break;
			case 'expoOut' :
				return (time==duration) ? start+change : change * (-Math.pow(2, -10 * time/duration) + 1) + start;
			break;
			case 'expoInOut' :
				if(time==0) return start;
				if(time==duration) return start+change;
				if((time/=duration/2) < 1) return change/2 * Math.pow(2, 10 * (time - 1)) + start;
				return change/2 * (-Math.pow(2, -10 * --time) + 2) + start;
			break;
			// circolare
			case 'circularIn' :
				return -change * (Math.sqrt(1 - (time/=duration)*time) - 1) + start;
			break;
			case 'circularOut' :
				return change * Math.sqrt(1 - (time=time/duration-1)*time) + start;
			break;
			case 'circularInOut' :
				if((time/=duration/2) < 1) return -change/2 * (Math.sqrt(1 - Math.pow(time,2)) - 1) + start;
				return change/2 * (Math.sqrt(1 - (time-=2)*time) + 1) + start;
			break;
			// elastico   >> problemi con MSIE risolti sostituendo  '(this.a < Math.abs(change))'  con  '(this.a <= Math.abs(change))'
			case 'elasticIn' :
				this.s=1.70158;this.p=0;this.a=change;
				if(time==0) return start;  if((time/=duration)==1) return start+change;  if(!this.p) this.p=duration*.3;
				if(this.a <= Math.abs(change)) { this.a=change; this.s=this.p/4; }
				else this.s = this.p/(2*Math.PI) * Math.asin (change/this.a);
				return -(this.a*Math.pow(2,10*(time-=1)) * Math.sin( (time*duration-this.s)*(2*Math.PI)/this.p )) + start;
			break;
			case 'elasticOut' :
				this.s=1.70158;this.p=0;this.a=change;
				if(time==0) return start;  if((time/=duration)==1) return start+change;  if(!this.p) this.p=duration*.3;
				if(this.a <= Math.abs(change)) { this.a=change; this.s=this.p/4; }
				else this.s = this.p/(2*Math.PI) * Math.asin (change/this.a);
				return this.a*Math.pow(2,-10*time) * Math.sin( (time*duration-this.s)*(2*Math.PI)/this.p ) + change + start;
			break;
			case 'elasticInOut' :
				this.s=1.70158;this.p=0;this.a=change;
				if(time==0) return start;  if((time/=duration/2)==2) return start+change;  if(!this.p) this.p=duration*(.3*1.5);
				if(this.a <= Math.abs(change)) { this.a=change; this.s=this.p/4; }
				else this.s = this.p/(2*Math.PI) * Math.asin (change/this.a);
				if(time < 1) return -.5*(this.a*Math.pow(2,10*(time-=1)) * Math.sin( (time*duration-this.s)*(2*Math.PI)/this.p )) + start;
				return this.a*Math.pow(2,-10*(time-=1)) * Math.sin( (time*duration-this.s)*(2*Math.PI)/this.p )*.5 + change + start;
			break;
			// torna indietro
			case 'backIn' :
				this.s = 1.70158;
				return change*(time/=duration)*time*((this.s+1)*time - this.s) + start;
			break;
			case 'backOut' :
				this.s = 1.70158;
				return change*((time=time/duration-1)*time*((this.s+1)*time + this.s) + 1) + start;
			break;
			case 'backInOut' :
				this.s = 1.70158; 
				if((time/=duration/2) < 1) return change/2*(Math.pow(time,2)*(((this.s*=(1.525))+1)*time - this.s)) + start;
				return change/2*((time-=2)*time*(((this.s*=(1.525))+1)*time + this.s) + 2) + start;
			break;
			// rimbalzo
			case 'bounceIn' : //easing, start, change, duration, time
				return change - add.fxEasing('bounceOut', 0, change, duration, duration-time) + start;
			break;
			case 'bounceOut' :
				if((time/=duration) < (1/2.75)) {
					return change*(7.5625*Math.pow(time,2)) + start;
				} else if(time < (2/2.75)) {
					return change*(7.5625*(time-=(1.5/2.75))*time + .75) + start;
				} else if(time < (2.5/2.75)) {
					return change*(7.5625*(time-=(2.25/2.75))*time + .9375) + start;
				} else {
					return change*(7.5625*(time-=(2.625/2.75))*time + .984375) + start;
				}
			break;
			case 'bounceInOut' : //easing, start, change, duration, time
				if(time < duration/2) return add.fxEasing('bounceIn', 0, change, duration, time*2) * .5 + start;
				return add.fxEasing('bounceOut', 0, change, duration, time*2-duration) * .5 + change*.5 + start;
			break;	
		}
	},
	
	// Class add.drag
	drag : function(p) {
		this.object = p.object;
		this.left = p.left || 0;
		this.right = p.right || Infinity;
		this.top = p.top || 0;
		this.bottom = p.bottom || Infinity;
		this.target = p.target;
		this.action = 'drag';
		this.successfully = p.successfully;
		this.unsuccessfully = p.unsuccessfully;
		this.wait = p.wait;
		this.play = add.play;
		this.stop = add.stop;
	},
	dragGo : function(e) {
		$$(this.object).style.position = 'absolute';
		this.x = add.mouse(e).x - parseInt(add.getCssValue($$(this.object), 'left'));
		this.startX = parseInt(add.getCssValue($$(this.object), 'left'));
		this.y = add.mouse(e).y - parseInt(add.getCssValue($$(this.object), 'top'));
		this.startY = parseInt(add.getCssValue($$(this.object), 'top'));
		var that = this;
		this.move = function(e) {
			if((add.mouse(e).x - that.x) > that.left && ((add.mouse(e).x - that.x) + parseInt(add.getCssValue($$(that.object), 'width'))) < that.right) $$(that.object).style.left = (add.mouse(e).x - that.x) + 'px';
			if((add.mouse(e).y - that.y) > that.top && ((add.mouse(e).y - that.y) + parseInt(add.getCssValue($$(that.object), 'height'))) < that.bottom) $$(that.object).style.top = (add.mouse(e).y - that.y) + 'px';
			that.lastX = add.mouse(e).x; that.lastY = add.mouse(e).y;
		};
		this.release = function() {
			(add.sniff('IE')) ? ($$(that.object).detachEvent('onmousemove', that.move)) : ($$(that.object).removeEventListener('mousemove', that.move, false));
			(add.sniff('IE')) ? ($$(that.object).detachEvent('onmouseup', that.release)) : ($$(that.object).removeEventListener('mouseup', that.release, false));
			if(that.target) {
				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.wait && that.unsuccessfully) { that.waitTM = setTimeout(function() { that.unsuccessfully.play() }, that.wait) } else if(!that.wait && that.unsuccessfully) { that.unsuccessfully.play() }
					};
				} else {
					if(that.successfully) {
						that.$ = that.successfully;
						if(that.wait && that.successfully) { that.waitTM = setTimeout(function() { that.successfully.play() }, that.wait) } else if(!that.wait && that.successfully) { that.successfully.play() }
					};
				};
			} else {
				if(that.successfully) {
					that.$ = that.successfully;
					if(that.wait && that.successfully) { that.waitTM = setTimeout(function() { that.successfully.play() }, that.wait) } else if(!that.wait && that.successfully) { that.successfully.play() }
				};
			};
		};
		if(add.sniff('IE')) { $$(that.object).attachEvent('onmousemove', this.move) } else { $$(that.object).addEventListener('mousemove', this.move, false)};
		if(add.sniff('IE')) { $$(that.object).attachEvent('onmouseup', this.release) } else { $$(that.object).addEventListener('mouseup', this.release, false)};
	},
	
	// Class add.event
	event : function(p) {
		this.object = p.object;
		this.event = p.event;
		this.action = p.action;
		this.capturing = p.capturing || false; // not for IE
		this.eventLoop = add.eventLoop;
		this.eventLoop();
	},
	eventLoop : function() { // attach event when object in DOM is loaded
		if($$(this.object)) {
			if(add.sniff('IE')) { $$(this.object).attachEvent('on'+this.event, this.action) } else { $$(this.object).addEventListener(this.event, this.action, this.capturing) }
			clearTimeout(this.evTM);
		} else {
			var that = this;
			this.evTM = setTimeout(function() { that.eventLoop(); }, 20);
		};
	}
}

var add = AutomaticDigitalDesign;
