/**
 * @class wsFlashObject
 * @author Russell Sherman
 * @version 1.0
 */
var wsFlashObject =
{
	debug: false,
	elem: null,
	startPos: null,
	endPos: null,
	startTime:null,
	duration: null,
	endTime:null,
	interval: null,
	intTime: 20,
	intSteps: null,
	curStep: null,
	expanded: null,

	flashOne:null,
	flashTwo:null,
	load: true,
	/**
	 * init
	 */
	init: function( FlashParams, container )
	{
		this.flashOne = FlashParams;
		this.createUfoDiv( this.flashOne.cntId, container );
		UFO.create( this.flashOne, this.flashOne.cntId );
	},
	/**
	 * init2
	 */
	init2: function( FlashParams, container )
	{
		this.flashTwo = FlashParams;
		this.createUfoDiv( this.flashTwo.cntId, container );

		this.elem = document.getElementById( this.flashTwo.cntId );

		if(this.debug)
		{
			Dbg.create( wsFlashObject );
		}
	},

	/**
	 * animate
	 */
	animate: function( begin, end, time )
	{
		/*
			IE doesn't want to animate div that contains flash
			Firefox and safari crash if we clear inner html and later attach flash with ExternalAPI
		*/
		switch(this.elem.firstChild.nodeName)
		{
			case "IMG":
			case "OBJECT":
				this.load = true;
				this.elem.innerHTML = ''
			break;
		}


		this.startPos = begin;
		this.endPos = end;
		this.startTime = this.now();
		this.duration = time*1000;
		this.endTime = this.startTime + this.duration;
		this.intSteps = this.duration/this.intTime;
		this.curStep = 0;
		this.interval = setInterval( "wsFlashObject.update()", this.intTime );
	},
	/**
	 * now - return current time using getTime
	 */
	now: function()
	{
		var d = new Date();
		return d.getTime();
	},
	/**
	 * update - set the current values for animated object
	 */
	update: function()
	{
		if(this.debug)
		{
			Dbg.update();
		}

		if( !this.elem || ( this.curStep >= this.intSteps ) )
		{
			clearInterval( this.interval );
			if(!this.expanded)
			{
				this.elem.style.display = 'none';
			}

			if(this.load)
			{
				UFO.load( this.flashTwo, this.flashTwo.cntId );
				this.load = false;
			}
			return;
		}

		var currentHeight = Quad.easeInOut( this.curStep, this.startPos, this.endPos-this.startPos, this.intSteps );
		this.elem.style.height = currentHeight + "px";

		this.curStep ++;
	},
	/**
	 * open
	 */
	open:function()
	{
		var e = document.getElementById( this.flashOne.cntId );
		this.expanded = true;
		this.elem.style.display = 'block';
		this.elem.style.top = GetPosition.y(e)+"px";
		this.elem.style.left = GetPosition.x(e)+"px";
		this.animate( 148, 248, .25 )
	},
	/**
	 * close
	 */
	close:function()
	{
		this.expanded = false;
		this.animate( 248, 148, .125 )
	},
	/**
	 * toggle
	 */
	toggle:function()
	{
		if(this.expanded)
		{
			this.close();
		}
		else
		{
			this.open();
		}
	},

	createUfoDiv:function( id, container )
	{
		var e = document.getElementById( container );
		e.innerHTML+='<div id="'+id+'"><img src="../../../../case_banner_dell/j/i/getFlashPlayer.gif" /></div>\n\n';
	}
};
//end object wsFlashObject

/**
 * A class for creation of quadric ease
 * @class Quad
 * @author Russell Sherman
 * @version 1.0
 */
var Quad =
{
	/**
	 * easeNone - linear ease (no ease)
	 */
	easeNone: function( t, b, c, d )
	{
		return c*t/d + b;
	},
	/**
	 * easeIn -
	 */
	easeIn: function(t, b, c, d)
	{
		return c*(t/=d)*t + b;
	},
	/**
	 * easeOut
	 */
	easeOut: function(t, b, c, d)
	{
		return -c *(t/=d)*(t-2) + b;
	},
	/**
	 * easeInOut
	 */
	easeInOut: function(t, b, c, d)
	{
		if ((t/=d/2) < 1)
			return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	}
};

/**
 * A class for debug output
 * @class Dbg
 * @author Russell Sherman
 * @version 1.0
 */
var Dbg =
{
	dbgObj:null,
	/**
	 * Create debug output object
	 */
	create: function( obj )
	{
		this.dbgObj = obj;
		if( !document.getElementById( 'debugOutput' ) )
		{//debug enabled write debug output div
			document.writeln( '' );
			document.writeln( '<div id="debugOutput">' );
			document.writeln( '    <div id="sTime">dbg - startTime </div>' );
			document.writeln( '    <div id="eTime">dbg - endTime </div>'	);
			document.writeln( '    <div id="nTime">dbg - now </div>'	);
			document.writeln( '</div>' );
		}
	},
	/**
	 * Update debug output object
	 */
	update: function()
	{
		if( document.getElementById( 'debugOutput' ) )
		{//debug enabled and debug output div exists
			var element = document.getElementById( 'sTime' );
			element.innerHTML = this.dbgObj.startTime;
			var element = document.getElementById( 'eTime' );
			element.innerHTML = this.dbgObj.endTime;
			var element = document.getElementById( 'nTime' );
			element.innerHTML = this.dbgObj.now();
		}
	}

};

var GetPosition =
{
	x: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;
	},

	y: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;
	}
};



