/*
######################################################################
# $Id: projects.js,v 1.2 2006/05/09 17:57:54 emalethan Exp $
# Copyright (c) 2006 Beanlogic Limited
######################################################################
*/

//----------------------------------------------------------------------- Constructors
Project = function(id)
{
    this.initialise(id);
};

//----------------------------------------------------------------------- Instance Methods

Project.prototype =
{
    id: "",
    visible: false,
    element: null,
    initialise : function (id)
    {
        this.id = id;
        Project.__projects[Project.__projects.length] = this;
    },
    hide: function()
    {
        Element.hide(this.id);
    },
    show : function()
    {
        new Effect.Appear(this.id);
    }
};

//----------------------------------------------------------------------- Static Properties

Project.lastCommand = null;
Project.lastTimer = null;
Project.hoverExitDelay = 600;
Project.__projects = new Array();
Project.__currentIndex = 0;

//----------------------------------------------------------------------- Static Methods

Project.clearCurrentHover = function()
{
    if(!Project.lastTimer)
    {
        return;
    }
    clearTimeout(Project.lastTimer);
    eval(Project.lastCommand);
    Project.lastTimer = null;
    Project.lastCommand = null;
}

Project.hoverEndWith = function(command)
{
    Project.lastCommand = command
    Project.lastTimer = setTimeout(command, Project.hoverExitDelay)
}

Project.showProject = function(id)
{
	for(var i=0; i < Project.__projects.length; ++i)
	{
		var proj = Project.projectAt(i);
		if(proj.id == 'Project' + id)
		{
		    Project.showProjectAt(i);
		    break;
		}
	}
}

Project.showProjectAt = function(index)
{
    Project.clearCurrentHover();
	Project.__currentIndex = index;
	var proj = Project.projectAt(index)
	proj.show();
}

//Sets mouse out and start the count down to hiding the current one
Project.setMouseOut = function()
{
    Project.hoverEndWith("Project.hideProjectAt(" + Project.__currentIndex +")");
}

//Hides the project pointed to by index
Project.hideProjectAt = function(index)
{
	var proj = Project.projectAt(index);
	proj.hide();
}

//returns the project at index
Project.projectAt = function(index)
{
	return Project.__projects[index];
}

Project.hideAll = function()
{
	for(var i=0; i < Project.__projects.length; ++i)
	{
		var proj = Project.projectAt(i);
		proj.hide(true);
	}
}
