/*
	The Deepend Website

	Copyright (C) 2006 Michael Diolosa (michael@deepend.com),
	                   Deepend New York, Inc.,
                           490 Broadway Floor 5,
                           New York, NY, 10012 

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/* CLASS StatusManager */
function StatusManager ()
{
}

StatusManager.setDefaultStatus = function (status)
{
	window.defaultStatus = status;
}

StatusManager.setStatus = function (status)
{
	window.status = status;
}

StatusManager.setTitle = function (title)
{
	document.title = title;
}






/* CLASS Animator */
function Animation (obj, name, secs)
{
	this._name = name;
	this._element = obj;
	this._currentStep = 0;
	this._speed = 30;
	this._steps = Math.ceil ((secs * 1000) / this._speed);
	this._interval = null;
	this._reverse = false;
	Animation._animations [this._name] = this;
}

Animation.prototype.start = function(reverse)
{	
	this.stop ();
	
	if (reverse != null && this._reverse != reverse)
			this._reverse = reverse;
		
	this._interval = setInterval ("Animation._animations ['" + this._name+ "'].step ()", this._speed);
}

Animation.prototype.stop = function()
{
	clearInterval (this._interval);
	this._interval = null;
}
	
Animation.prototype.step = function()
{
	if ((this._reverse && this._currentStep < 0) || (!this._reverse && this._currentStep == this._steps)) {
		this.stop ();
		return;
	}
		
	var step = this._currentStep + 1;
	
	var currentOpacity = ((step * 100) / this._steps) / 100;
	
	if (this._reverse)
		Math.floor (currentOpacity);
	else
		Math.ceil (currentOpacity);
	
	OpacityManager.setOpacity (this._element, currentOpacity);
	
	if (this._reverse)
		this._currentStep--;
	else
		this._currentStep++;
}

Animation._animations = new Array ();






/* CLASS MotherShip */
function MotherShip (title)
{
	this.title = title;
}

MotherShip.getAnimation = function (obj, name)
{
	if (Animation._animations [name] == null)
		new Animation (obj, name, 2);
	
	return Animation._animations [name];
}

MotherShip.prototype.initialize = function ()
{
	StatusManager.setDefaultStatus (this.title)
	StatusManager.setTitle (this.title)
}