//////////////////////////////
// SmoothTab Code
// by Lorenzo Carrara @ Cubica
//////////////////////////////

SmoothTab = function(id, direction, containerelement, displacement, tabsmargin)
{
	this.init(id, direction, containerelement, displacement, tabsmargin);
}

var st = SmoothTab.prototype;

// Static fields

st.tabcontainerclassname = "smoothtabcontainer";
st.horizontaltabclassname = "smoothtab_h";
st.verticaltabclassname = "smoothtab_v";
st.mousecatchdistance = 20; // Distance of the mouse pointer from the tab container which container movement stops at
st.movementtweenduration = 1;
st.fadetweenduration = 4;
st.mouseeventtrashrate = 15;
st.mouseeventdelay = 50;

// Class methods

st.init = function(id, direction, containerelement, displacement, tabsmargin)
{
	this.id = id;
	switch(direction)
	{
		case "horizontal" : this.direction = "horizontal"; break;
		default : this.direction = "vertical";
	}
	this.containerelement = containerelement;
	this.calcRange();
	this.displacement = displacement;
	this.tabsmargin = tabsmargin;
	this.tabels = new Array();
	this.numtabs = 0;
	this.tabcontainercreated = false;
	this.tabcontainerwidth = 0;
	this.tabcontainerheight = 0;
	this.trashedmouseevents = 0;
	this.ns4=(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>3) ? true:false;
	this.ie4=(navigator.appName!="Netscape" && parseInt(navigator.appVersion)>3) ? true:false;
	this.lastmousex = 0;
	this.lastmousey = 0;
	this.stopped = false;
}

st.addTab = function(imgname, tabwidth, tabheight, properties)
{
	var tab = document.createElement("DIV");
	tab.style.width=tabwidth + "px";
	tab.style.height=tabheight + "px";
	tab.style.backgroundImage = "url(" + imgname + ")";
	tab.style.backgroundRepeat = "no-repeat";
	var tabid = this.id + this.numtabs;
	tab.id = tabid;
	this.createTabContainer();
	if(this.direction == "horizontal")
	{
		if(this.numtabs == 0) tab.style.marginLeft = "0px";
		// the following line is required to correct an IE bug that sets a mysterious 7 pixels
		// margin between the first and second tab
		else if((this.numtabs == 1) && (this.ie4)) tab.style.marginLeft = (this.tabsmargin - 7) + "px";
		else tab.style.marginLeft = this.tabsmargin + "px";
		tab.className = this.horizontaltabclassname;
	}
	else // vertical tabs
	{
		if(this.numtabs == 0) tab.style.marginTop = "0px";
		else tab.style.marginTop = this.tabsmargin + "px";
		tab.className = this.verticaltabclassname;
	}
	if(this.direction == "horizontal")
	{
		if(this.tabcontainerheight < tabheight) this.tabcontainerheight = tabheight;
		this.tabcontainerwidth += ((this.numtabs==0)?0:this.tabsmargin) + tabwidth;
	}
	else if(this.direction == "vertical")
	{
		if(this.tabcontainerwidth < tabwidth) this.tabcontainerwidth = tabwidth;
		this.tabcontainerheight += ((this.numtabs==0)?0:this.tabsmargin) + tabheight;
	}
	
	this.updateTabContainerSize();
	this.updateTabContainerDisplacement();
	
	// Tween opacity
	this.tabcontainer.appendChild(tab);
	var ot = new OpacityTween(tab,Tween.strongEaseOut, 0, 100, this.fadetweenduration);
	ot.start();
	//de(this.tabcontainer.style.top + ", " + this.tabcontainer.style.left);
	//alert("tab w: " + tab.style.width + "\ntab h: " + tab.style.height + "\ntab ml: " + tab.style.marginLeft + "\ntc w: " + this.tabcontainer.style.width);
	var tabel = new SmoothTabElement(tabid, tab, properties, this);
	this.tabels[this.numtabs++] = tabel;
	return tabel;
}

st.createTabContainer = function()
{
	if(this.tabcontainercreated == false)
	{
		this.tabcontainer = document.createElement("DIV");
		this.tabcontainer.className = this.tabcontainerclassname;
		this.updateTabContainerSize();
		this.tabcontainer.style.position = "absolute";
		if(this.direction == "horizontal")
		{
			// Displacement parsing
			if(!isNaN(this.displacement))
			{
				this.displacement = parseInt(this.displacement, 10);
				this.tabcontainer.style.top = this.displacement + "px";
			}
			else if((this.displacement != "top-outside") && (this.displacement != "top-inside") && (this.displacement != "bottom-inside") && (this.displacement != "bottom-outside")) // top-inside is default
			{
				this.displacement = "top-inside";
			}
	
			this.tabcontainer.style.left = this.minpos + "px";
			this.tween = new Tween(this.tabcontainer.style, "left", Tween.strongEaseOut, this.minpos, this.minpos, this.movementtweenduration, "px");
		}
		else
		{
			// Displacement parsing
			if(!isNaN(this.displacement))
			{
				this.displacement = parseInt(this.displacement, 10);
				this.tabcontainer.style.left = this.displacement + "px";
			}
			else if((this.displacement != "left-outside") && (this.displacement != "left-inside") && (this.displacement != "right-inside") && (this.displacement != "right-outside")) // right-outside is default
			{
				this.displacement = "right-outside";
			}
			this.tabcontainer.style.top = this.minpos + "px";
			this.tween = new Tween(this.tabcontainer.style, "top", Tween.strongEaseOut, this.minpos, this.minpos, this.movementtweenduration, "px");
		}
		this.tabcontainer.id = this.id;
		document.body.appendChild(this.tabcontainer);
		var thisst = this;
		document.onmousemove = function(e)
		{
			thisst.moveTabContainer(e, false);
		};
		window.onresize = function(e)
		{
			thisst.updateTabContainerDisplacement();
		};
		if (navigator.appName=="Netscape") { 
  			document.captureEvents(Event.MOUSEMOVE);
		}
		this.tabcontainercreated = true;
	}
}

st.moveTabContainer = function(e, delayed)
{
	//$('debug').innerHTML = "EVENTO";
	if(!this.stopped)
	{
		var tempX;
		var tempY;
		if(delayed)
		{
			tempX = this.lastmousex;
			tempY = this.lastmousey;
		}
		else
		{
			if (this.ie4) { // grab the x-y pos.s if browser is IE
				tempX = event.clientX + document.body.scrollLeft;
				tempY = event.clientY + document.body.scrollTop;
			} else {  // grab the x-y pos.s if browser is NS
				tempX = e.pageX;
				tempY = e.pageY;
			}
			// catch possible negative values in NS4
			if (tempX < 0){tempX = 0;}
			if (tempY < 0){tempY = 0;} 
		}
		
		
		if(this.mousetrashinterval) clearInterval(this.mousetrashinterval);
		
		this.trashedmouseevents = ++this.trashedmouseevents % this.mouseeventtrashrate;
		
		if((this.trashedmouseevents == 0) || delayed)
		{  
			//deb = $('debug');
			//deb.innerHTML = "mouseevents : " + this.mouseevents + ", delayed : " + delayed;
			if(!this.isInsideElement(this.tabcontainer, tempX, tempY, this.mousecatchdistance))
			{
				if(this.direction == "horizontal")
				{
					// Horizontal tween
					var newval = Math.min(Math.max(this.minpos, tempX - Math.round(this.tabcontainerwidth/2)), this.maxpos - this.tabcontainerwidth);
					this.tween.stop();
					this.tween.continueTo(newval, this.movementtweenduration);
				}
				else if(this.direction == "vertical")
				{
					// Vertical tween
					var newval = Math.min(Math.max(this.minpos, tempY - Math.round(this.tabcontainerheight/2)), this.maxpos - this.tabcontainerheight);
					this.tween.stop();
					this.tween.continueTo(newval, this.movementtweenduration);
				}
			}
		}
		else
		{
			this.lastmousex = tempX;
			this.lastmousey = tempY;
			thisst = this;
			this.mousetrashinterval = window.setInterval(function() { thisst.moveTabContainer(null, true); }, this.mouseeventdelay);
		}
	}
}


st.updateTabContainerSize = function()
{
	this.tabcontainer.style.width = this.tabcontainerwidth + "px";
	this.tabcontainer.style.height = this.tabcontainerheight + "px";
	//$('debug').innerHTML = "tch=" + this.tabcontainerheight + ", tcw=" + this.tabcontainerwidth;
}

st.updateTabContainerDisplacement = function()
{
	if(this.direction == "horizontal")
	{
		if(this.displacement == "top-outside")
		{
			this.tabcontainer.style.top = (this.findPosY(this.containerelement) - this.tabcontainerheight) + "px";
		}
		else if(this.displacement == "top-inside")
		{
			this.tabcontainer.style.top = this.findPosY(this.containerelement) + "px";
		}
		else if(this.displacement == "bottom-inside")
		{
			this.tabcontainer.style.top = (this.findPosY(this.containerelement) + this.containerelement.offsetHeight - this.tabcontainerheight) + "px";
		}
		else if(this.displacement == "bottom-outside")
		{
			this.tabcontainer.style.top = (this.findPosY(this.containerelement) + this.containerelement.offsetHeight) + "px";
		}
	}
	else if(this.direction == "vertical")
	{
		if(this.displacement == "left-outside")
		{
			this.tabcontainer.style.left = (this.findPosX(this.containerelement) - this.tabcontainerwidth) + "px";
		}
		else if(this.displacement == "left-inside")
		{
			this.tabcontainer.style.left = this.findPosX(this.containerelement) + "px";
		}
		else if(this.displacement == "right-inside")
		{
			this.tabcontainer.style.left = (this.findPosX(this.containerelement) + this.containerelement.offsetWidth - this.tabcontainerwidth) + "px";
		}
		else if(this.displacement == "right-outside")
		{
			this.tabcontainer.style.left = (this.findPosX(this.containerelement) + this.containerelement.offsetWidth) + "px";
		}
	}
}

st.calcRange = function()
{
	if(this.direction == "horizontal")
	{
		var pos = this.findPosX(this.containerelement);
		this.minpos = pos;
		this.maxpos = pos + (this.containerelement.offsetWidth);
	}
	else // vertical tabs
	{
		var pos = this.findPosY(this.containerelement);
		this.minpos = pos;
		this.maxpos = pos + (this.containerelement.offsetHeight);
	}
	//$('debug').innerHTML = "minpos=" + this.minpos + ", maxpos=" + this.maxpos;
}

st.setMinPos = function(num)
{
	this.minpos = num;
}

st.setMaxPos = function(num)
{
	this.maxpos = num;
}

st.setRange = function(num1, num2)
{
	this.minpos = num1;
	this.maxpos = num2;
}

st.findPosX = function(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

st.findPosY = function(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

st.isInsideElement = function(el, posx, posy, distance)
{
	if(!distance) distance = 0;
	var elstarth = this.findPosX(el);
	var elendh = elstarth + el.offsetWidth;
	var elstartv = this.findPosY(el);
	var elendv = elstartv + el.offsetHeight;
	if((posx >= (elstarth - distance)) && (posx <= (elendh + distance)) && (posy >= (elstartv - distance)) && (posy <= (elendv + distance))) return true;
	else return false;
}

SmoothTabElement = function(id, el, props, stc)
{
	this.init(id, el, props, stc);
}

var ste = SmoothTabElement.prototype;

ste.init = function(id, el, props, stc)
{
	this.id = id;
	this.el = el;
	this.listeners = new Array();
	this.tweens = new Array();
	this.numlisteners = 0;
	// Properties
	this.func = "none";
	this.stoptabswhenactive = false;
	this.closetabswhenactive = false;
	if(props)
	{
		if(props.func == "toggle") this.func = "toggle";
		if(props.stoptabswhenactive == true) this.stoptabswhenactive = true;
		if(props.closetabswhenactive == true) this.closetabswhenactive = true;
	}
	//alert("id:" + id + ", func:" + this.func + ", stop:" + this.stoptabswhenactive + ", close:" + this.closetabswhenactive);
	this.stc = stc;
	this.el.onclick = Delegate.create(this, this.tabClicked);
	this.active = false;
}
ste.addListener = function(l)
{
	this.listeners[this.numlisteners++] = l;
}
ste.tabClicked = function()
{
	if(this.func == "toggle") this.active = !this.active;
	//if(this.active == false) this.stc.stopped = false;
	if(this.active == true)
	{
		if(this.closetabswhenactive == true)
		{
			for(var i=0; i < this.stc.tabels.length; i++)
			{
				tabel = this.stc.tabels[i];
				if(tabel != this) tabel.deactivate();
			}
		}
		
		if(this.stoptabswhenactive == true)
		{
			this.stc.stopped = true;
		}
	}
	else
	{
		if(this.stc.stopped == true)
		{
			var foundstopper = false;
			for(var i=0; i < this.stc.tabels.length; i++)
			{
				tabel = this.stc.tabels[i];
				if((tabel != this) && (tabel.active == true) && (tabel.stoptabswhenactive == true)) foundstopper = true;
			}
			this.stc.stopped = foundstopper;
		}
	}
	this.notifyListeners();
}
ste.deactivate = function()
{
	if(this.active == true)
	{
		this.active = false;
		this.notifyListeners();
	}
}
ste.notifyListeners = function()
{
	for(var j=0;j<this.numlisteners;j++)
	{
		this.listeners[j](this);
	}
}
ste.addFadeElement = function(fel, funcz, duration, location)
{
	this.addListener(function(tabel) {if(tabel.active) {  if(location) tabel.positionFadeElement(fel, location); var otw = new OpacityTween(fel, funcz, 0, 100, duration); otw.start(); } else { var otw = new OpacityTween(fel, funcz, 100, 0, duration); otw.start(); }});
}

ste.positionFadeElement = function(fel, location)
{
	fel.style.position = "absolute";
	fel.style.display = "block";
	if(this.stc.direction == "horizontal")
	{
		if(location == "tab-top")
		{
			fel.style.top = (parseInt(this.stc.tabcontainer.style.top) - fel.offsetHeight) + "px";
		}
		else // tab-bottom is default
		{
			fel.style.top = (parseInt(this.stc.tabcontainer.style.top) + this.stc.tabcontainer.offsetHeight) + "px";
		}
		fel.style.left = (Position.cumulativeOffset(this.el)[0] - Math.round(fel.offsetWidth/2) + Math.round(this.el.offsetWidth/2)) + "px";
	}
	else //if(this.stc.direction == "vertical")
	{
		if(location == "tab-right")
		{
			fel.style.left = (parseInt(this.stc.tabcontainer.style.left) + this.stc.tabcontainer.offsetWidth) + "px";
		}
		else // tab-right is default
		{
			fel.style.left = (parseInt(this.stc.tabcontainer.style.left) - fel.offsetWidth) + "px";
		}
		fel.style.top = (Position.cumulativeOffset(this.el)[1] - Math.round(fel.offsetHeight/2) + Math.round(this.el.offsetHeight/2)) + "px";
	}
}


/*  Prototype JavaScript framework
 *  (c) 2005 Sam Stephenson <sam@conio.net>
 *  Prototype is freely distributable under the terms of an MIT-style license.
 *  For details, see the Prototype web site: http://prototype.conio.net/
/*--------------------------------------------------------------------------*/

//note: modified & stripped down version of prototype, to be used with moo.fx by mad4milk (http://moofx.mad4milk.net).

var Class = {
	create: function() {
		return function() {
			this.initialize.apply(this, arguments);
		}
	}
}

Object.extend = function(destination, source) {
	for (property in source) destination[property] = source[property];
	return destination;
}

Function.prototype.bind = function(object) {
	var __method = this;
	return function() {
		return __method.apply(object, arguments);
	}
}

Function.prototype.bindAsEventListener = function(object) {
var __method = this;
	return function(event) {
		__method.call(object, event || window.event);
	}
}

function $() {
	if (arguments.length == 1) return get$(arguments[0]);
	var elements = [];
	$c(arguments).each(function(el){
		elements.push(get$(el));
	});
	return elements;

	function get$(el){
		if (typeof el == 'string') el = document.getElementById(el);
		return el;
	}
}

if (!window.Element) var Element = new Object();

Object.extend(Element, {
	remove: function(element) {
		element = $(element);
		element.parentNode.removeChild(element);
	},

	hasClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var hasClass = false;
		element.className.split(' ').each(function(cn){
			if (cn == className) hasClass = true;
		});
		return hasClass;
	},

	addClassName: function(element, className) {
		element = $(element);
		Element.removeClassName(element, className);
		element.className += ' ' + className;
	},
  
	removeClassName: function(element, className) {
		element = $(element);
		if (!element) return;
		var newClassName = '';
		element.className.split(' ').each(function(cn, i){
			if (cn != className){
				if (i > 0) newClassName += ' ';
				newClassName += cn;
			}
		});
		element.className = newClassName;
	},

	cleanWhitespace: function(element) {
		element = $(element);
		$c(element.childNodes).each(function(node){
			if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) Element.remove(node);
		});
	},

	find: function(element, what) {
		element = $(element)[what];
		while (element.nodeType != 1) element = element[what];
		return element;
	}
});

var Position = {
	cumulativeOffset: function(element) {
		var valueT = 0, valueL = 0;
		do {
			valueT += element.offsetTop  || 0;
			valueL += element.offsetLeft || 0;
			element = element.offsetParent;
		} while (element);
		return [valueL, valueT];
	}
};

//useful array functions
Array.prototype.each = function(func){
	for(var i=0;ob=this[i];i++) func(ob, i);
}

function $c(array){
	var nArray = [];
	for (i=0;el=array[i];i++) nArray.push(el);
	return nArray;
}

/*////////////
Tween
Author: Philippe Maegerman
Email: mx2004-at-pandora.be
Website: http://jsTween.blogspot.com
Download: http://cfpim.coffeeflower.com/jsTween/Tween.js
*/////////////
function Delegate() {}
Delegate.create = function (o, f) {
	var a = new Array() ;
	var l = arguments.length ;
	for(var i = 2 ; i < l ; i++) a[i - 2] = arguments[i] ;
	return function() {
		var aP = [].concat(arguments, a) ;
		f.apply(o, aP);
	}
}

Tween = function(obj, prop, func, begin, finish, duration, suffixe){
	this.init(obj, prop, func, begin, finish, duration, suffixe)
}
var t = Tween.prototype;

t.obj = new Object();
t.prop='';
t.func = function (t, b, c, d) { return c*t/d + b; };
t.begin = 0;
t.change = 0;
t.prevTime = 0;
t.prevPos = 0;
t.looping = false;
t._duration = 0;
t._time = 0;
t._pos = 0;
t._position = 0;
t._startTime = 0;
t._finish = 0;
t.name = '';
t.suffixe = '';
t._listeners = new Array();	
t.setTime = function(t){
	this.prevTime = this._time;
	if (t > this.getDuration()) {
		if (this.looping) {
			this.rewind (t - this._duration);
			this.update();
			this.broadcastMessage('onMotionLooped',{target:this,type:'onMotionLooped'});
		} else {
			this._time = this._duration;
			this.update();
			this.stop();
			this.broadcastMessage('onMotionFinished',{target:this,type:'onMotionFinished'});
		}
	} else if (t < 0) {
		this.rewind();
		this.update();
	} else {
		this._time = t;
		this.update();
	}
}
t.getTime = function(){
	return this._time;
}
t.setDuration = function(d){
	this._duration = (d == null || d <= 0) ? 100000 : d;
}
t.getDuration = function(){
	return this._duration;
}
t.setPosition = function(p){
	this.prevPos = this._pos;
	var a = this.suffixe != '' ? this.suffixe : ''
	if(this.obj[this.prop]) this.obj[this.prop] = p + a;
	this._pos = p;
	this.broadcastMessage('onMotionChanged',{target:this,type:'onMotionChanged'});
}
t.getPosition = function(t){
	if (t == undefined) t = this._time;
	return this.func(t, this.begin, this.change, this._duration);
};
t.setFinish = function(f){
	this.change = f - this.begin;
};
t.geFinish = function(){
	return this.begin + this.change;
};
t.init = function(obj, prop, func, begin, finish, duration, suffixe){
	if (!arguments.length) return;
	this._listeners = new Array();
	this.addListener(this);
	if(suffixe) this.suffixe = suffixe;
	this.obj = obj;
	this.prop = prop;
	this.begin = begin;
	this._pos = begin;
	this.setDuration(duration);
	if (func!=null && func!='') {
		this.func = func;
	}
	this.setFinish(finish);
}
t.start = function(){
	this.rewind();
	this.startEnterFrame();
	this.broadcastMessage('onMotionStarted',{target:this,type:'onMotionStarted'});
	//alert('in');
}
t.rewind = function(t){
	this.stop();
	this._time = (t == undefined) ? 0 : t;
	this.fixTime();
	this.update();
}
t.fforward = function(){
	this._time = this._duration;
	this.fixTime();
	this.update();
}
t.update = function(){
	this.setPosition(this.getPosition(this._time));
	}
t.startEnterFrame = function(){
	this.stopEnterFrame();
	this.isPlaying = true;
	this.onEnterFrame();
}
t.onEnterFrame = function(){
	if(this.isPlaying) {
		this.nextFrame();
		setTimeout(Delegate.create(this, this.onEnterFrame), 0);
	}
}
t.nextFrame = function(){
	this.setTime((this.getTimer() - this._startTime) / 1000);
	}
t.stop = function(){
	this.stopEnterFrame();
	this.broadcastMessage('onMotionStopped',{target:this,type:'onMotionStopped'});
}
t.stopEnterFrame = function(){
	this.isPlaying = false;
}

t.continueTo = function(finish, duration){
	this.begin = this._pos;
	this.setFinish(finish);
	if (this._duration != undefined)
		this.setDuration(duration);
	this.start();
}
t.resume = function(){
	this.fixTime();
	this.startEnterFrame();
	this.broadcastMessage('onMotionResumed',{target:this,type:'onMotionResumed'});
}
t.yoyo = function (){
	this.continueTo(this.begin,this._time);
}

t.addListener = function(o){
	this.removeListener (o);
	return this._listeners.push(o);
}
t.removeListener = function(o){
	var a = this._listeners;	
	var i = a.length;
	while (i--) {
		if (a[i] == o) {
			a.splice (i, 1);
			return true;
		}
	}
	return false;
}
t.broadcastMessage = function(){
	var arr = new Array();
	for(var i = 0; i < arguments.length; i++){
		arr.push(arguments[i])
	}
	var e = arr.shift();
	var a = this._listeners;
	var l = a.length;
	for (var i=0; i<l; i++){
		if(a[i][e])
		a[i][e].apply(a[i], arr);
	}
}
t.fixTime = function(){
	this._startTime = this.getTimer() - this._time * 1000;
}
t.getTimer = function(){
	return new Date().getTime() - this._time;
}
Tween.backEaseIn = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158;
	return c*(t/=d)*t*((s+1)*t - s) + b;
}
Tween.backEaseOut = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158;
	return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
}
Tween.backEaseInOut = function(t,b,c,d,a,p){
	if (s == undefined) var s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}
Tween.elasticEaseIn = function(t,b,c,d,a,p){
		if (t==0) return b;  
		if ((t/=d)==1) return b+c;  
		if (!p) p=d*.3;
		if (!a || a < Math.abs(c)) {
			a=c; var s=p/4;
		}
		else 
			var s = p/(2*Math.PI) * Math.asin (c/a);
		
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	
}
Tween.elasticEaseOut = function (t,b,c,d,a,p){
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);
	}
Tween.elasticEaseInOut = function (t,b,c,d,a,p){
	if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) var p=d*(.3*1.5);
	if (!a || a < Math.abs(c)) {var a=c; var s=p/4; }
	else var s = p/(2*Math.PI) * Math.asin (c/a);
	if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
}

Tween.bounceEaseOut = function(t,b,c,d){
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
}
Tween.bounceEaseIn = function(t,b,c,d){
	return c - Tween.bounceEaseOut (d-t, 0, c, d) + b;
	}
Tween.bounceEaseInOut = function(t,b,c,d){
	if (t < d/2) return Tween.bounceEaseIn (t*2, 0, c, d) * .5 + b;
	else return Tween.bounceEaseOut (t*2-d, 0, c, d) * .5 + c*.5 + b;
	}

Tween.strongEaseInOut = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
	}

Tween.regularEaseIn = function(t,b,c,d){
	return c*(t/=d)*t + b;
	}
Tween.regularEaseOut = function(t,b,c,d){
	return -c *(t/=d)*(t-2) + b;
	}

Tween.regularEaseInOut = function(t,b,c,d){
	if ((t/=d/2) < 1) return c/2*t*t + b;
	return -c/2 * ((--t)*(t-2) - 1) + b;
	}
Tween.strongEaseIn = function(t,b,c,d){
	return c*(t/=d)*t*t*t*t + b;
	}
Tween.strongEaseOut = function(t,b,c,d){
	return c*((t=t/d-1)*t*t*t*t + 1) + b;
	}

Tween.strongEaseInOut = function(t,b,c,d){
	if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
	return c/2*((t-=2)*t*t*t*t + 2) + b;
	}

/*////////////
OpacityTween
Author: Philippe Maegerman
Email: mx2004-at-pandora.be
Creation Date: January 20 2006
*/////////////
/////////////
/////////////
/////////////
/////////////

OpacityTween.prototype = new Tween();
OpacityTween.prototype.constructor = Tween;
OpacityTween.superclass = Tween.prototype;

function OpacityTween(obj,func,fromOpacity,toOpacity,duration){
	this.targetObject = obj;
	this.init(new Object(),'x',func,fromOpacity,toOpacity,duration);
}
var o = OpacityTween.prototype;
o.targetObject = {};
o.onMotionChanged = function(evt){
	var v = evt.target._pos;
	var t = this.targetObject;
	t.style['opacity'] = v / 100;
	t.style['-moz-opacity'] = v / 100;
	if(t.filters) t.filters.alpha['opacity'] = v;
}