Nav.letterSpringForce	= 250.0;
Nav.letterSpringDamping	= 30.0;
Nav.largePercent		= 200;
Nav.spread				= 7;

Nav.prototype.init					= Nav_init;
Nav.prototype.addLink				= Nav_addLink;
Nav.prototype.setActive				= Nav_setActive;
Nav.prototype.setHover				= Nav_setHover;
Nav.prototype.getLetterSize			= Nav_getLetterSize;
Nav.prototype.setLetterSize			= Nav_setLetterSize;
Nav.prototype.frameMouseOutEvent	= Nav_frameMouseOutEvent;
Nav.prototype.aMouseOverEvent		= Nav_aMouseOverEvent;

Nav.prototype.htmlSpanFrame = null;
Nav.prototype.arHtmlA = {};
Nav.prototype.arTitle = {};
Nav.prototype.arAnimations = {};
Nav.prototype.aCount = 0;
Nav.prototype.titleCount = 0;

function Nav(arLinks)
{
	this.init();
	
	for(i in arLinks)
		this.addLink(i, arLinks[i]);
}

function Nav_init()
{
	var htmlDivPlaceholder = document.getElementById("navPlaceholder");
	this.htmlDivFrame = document.createElement("div");
	this.htmlDivFrame.setAttribute(classAttribute, "navFrame");
	htmlDivPlaceholder.insertBefore(this.htmlDivFrame, null);

	
	//Animator.setAnimate(true);
	
	new EventWrapper("mouseout", new CallWrapper(this, "frameMouseOutEvent"), this.htmlDivFrame);
}

function Nav_addLink(title, url)
{
	this.arTitle[this.titleCount] = title;
	
	if(this.titleCount != 0)
		title = "  " + title;
	
	for(var i = 0; i < title.length; i++)
	{
		this.arHtmlA[this.aCount] = document.createElement("a");
		this.arHtmlA[this.aCount].setAttribute("href", url);
		if(title.charAt(i) == ' ')
			this.arHtmlA[this.aCount].innerHTML = "&nbsp;";
		else
			this.arHtmlA[this.aCount].appendChild(document.createTextNode(title.charAt(i)));
		this.arHtmlA[this.aCount].titleIndex = this.titleCount;
		
		this.htmlDivFrame.appendChild(this.arHtmlA[this.aCount]);
		
		new EventWrapper("mouseover", new CallWrapper(this, "aMouseOverEvent"), this.arHtmlA[this.aCount], this.aCount);
		
		/*var property = new Property(this, "LetterSize", this.aCount);
		property.setValue(100);
		this.arAnimations[this.aCount] = new SpringAnimation(property, Nav.letterSpringForce, Nav.letterSpringDamping);
		this.arAnimations[this.aCount].start();*/
		
		this.aCount++;
	}
	
	this.titleCount++;
}

function Nav_setActive(titleIndex)
{
	var start = 0;
	var end;
	
	for(var i = 0; i < titleIndex; i++)
	{
		start += this.arTitle[i].length + 2;
	}
	
	if(titleIndex == -1)
		end = 0;
	else
		end = start + this.arTitle[titleIndex].length;

	
	for(var i = 0; i < this.aCount; i++)
	{
		if(i >= start && i < end)
		{
			this.arHtmlA[i].oldHref = this.arHtmlA[i].getAttribute("href");
			this.arHtmlA[i].setAttribute("href", "javascript:void(0)");
			this.arHtmlA[i].setAttribute(classAttribute, "active");
		}
		else
		{
			if(this.arHtmlA[i].oldHref)
				this.arHtmlA[i].setAttribute("href", this.arHtmlA[i].oldHref);
			this.arHtmlA[i].oldHref = null;
			this.arHtmlA[i].setAttribute(classAttribute, "");
		}
	}
}	

function Nav_setHover(titleIndex)
{
	var start = 0;
	var end;
	
	for(var i = 0; i < titleIndex; i++)
	{
		start += this.arTitle[i].length + 2;
	}
	
	if(titleIndex == -1)
		end = 0;
	else
		end = start + this.arTitle[titleIndex].length;
	
	for(var i = 0; i < this.aCount; i++)
	{
		if(this.arHtmlA[i].getAttribute(classAttribute) != "active")
		{
			if(i >= start && i < end)
				this.arHtmlA[i].setAttribute(classAttribute, "hover");
			else
				this.arHtmlA[i].setAttribute(classAttribute, "");
		}
	}
}	

function Nav_getLetterSize(index)
{
	return parseInt(this.arHtmlA[index].style.fontSize);
}

function Nav_setLetterSize(percent, index)
{
	this.arHtmlA[index].style.fontSize = percent + "%";
}

function Nav_frameMouseOutEvent(e)
{
	this.setHover(-1);
	for(var i = 0; i < this.aCount; i++)
	{
		this.arHtmlA[i].style.fontSize = "100%";
		//this.arAnimations[i].setAnimate(100);
	}
}

function Nav_aMouseOverEvent(e, index)
{	
	this.setHover(this.arHtmlA[index].titleIndex);
	for(var i = 0; i < this.aCount; i++)
	{
		if(Math.abs(index-i) <= Nav.spread)
			//this.arAnimations[i].setAnimate((Nav.largePercent-100)*(Nav.spread-Math.abs(index-i))/Nav.spread + 100);
			this.arHtmlA[i].style.fontSize = ((Nav.largePercent-100)*(Nav.spread-Math.abs(index-i))/Nav.spread + 100) + "%";
		else
			//this.arAnimations[i].setAnimate(100);
			this.arHtmlA[i].style.fontSize = "100%";
	}
}