// JavaScript Document
function doWidthChangeMem(elem,startWidth,endWidth,steps,intervals,powr) { 
//Width changer with Memory by www.hesido.com
    if (elem.widthChangeMemInt)
	window.clearInterval(elem.widthChangeMemInt);
    var actStep = 0;
    elem.widthChangeMemInt = window.setInterval(
	function() { 
	  elem.currentWidth = easeInOut(startWidth,endWidth,steps,actStep,powr);
	  elem.style.backgroundPosition = elem.currentWidth + "px"; 
	  actStep++;
	  if (actStep > steps) window.clearInterval(elem.widthChangeMemInt); 
	  
	} 
	,intervals)
}
function widthChange() { 
    if (!this.currentWidth) this.currentWidth = 0; 
	//if no memory is set, set it first; 
    doWidthChangeMem(this,this.currentWidth,5,10,10,0.5);
	if (!this.currentColor) this.currentColor = '663300'; 
	//if no memory is set, set it first; 
    doColor(this,this.currentColor, 'ff9900',10,10,1); 
	
	
    } 
function widthRestore() { 
    if (!this.currentWidth) return; 
    doWidthChangeMem(this,this.currentWidth,0,15,10,0.5); 

	if (!this.currentColor) return;
    doColor(this,this.currentColor,'663300',15,10,1);
	
    }
	
function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
//Generic Animation Step Value Generator By www.hesido.com 
    var delta = maxValue - minValue; 
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
    return Math.ceil(stepp) 
    } 

function colorChange() { 
    if (!this.currentColor) this.currentColor = '00a0c6'; 
	//if no memory is set, set it first; 
    doColor(this,this.currentColor, 'ff9900',15,10,1); 
    } 
function colorRestore() { 
    if (!this.currentColor) return;
    doColor(this,this.currentColor,'00a0c6',15,10,1); 
    }

function doColor(elem,startColor,endColor,steps,intervals,powr) { 
    if (elem.colorChangeMemInt)
	window.clearInterval(elem.colorChangeMemInt);
    var actStep = 0;
	var startR = h2d(startColor.substring(0,2)); 
	var startG = h2d(startColor.substring(2,4)); 
	var startB = h2d(startColor.substring(4,6)); 
	var endR = h2d(endColor.substring(0,2)); 
	var endG = h2d(endColor.substring(2,4)); 
	var endB = h2d(endColor.substring(4,6)); 
    elem.colorChangeMemInt = window.setInterval(
	function() {  
	  elem.currentR = easeInOut(startR,endR,steps,actStep,powr);
	  elem.currentG = easeInOut(startG,endG,steps,actStep,powr);
	  elem.currentB = easeInOut(startB,endB,steps,actStep,powr);
	  elem.currentColor = ("00").substring(0, 2 - d2h(elem.currentR).length) + d2h(elem.currentR) + ("00").substring(0, 2 - d2h(elem.currentG).length) + d2h(elem.currentG) + ("00").substring(0, 2 - d2h(elem.currentB).length) + d2h(elem.currentB); 
	  actStep++;
	  elem.style.color = "#" + elem.currentColor;
	  if (actStep > steps) 
	  {	window.clearInterval(elem.colorChangeMemInt); 
	  	elem.currentColor = endColor;
		elem.style.color = "#" + elem.currentColor;}
	} 
	,intervals)
}

var hD="0123456789ABCDEF";
function d2h(d) {
var h = hD.substr(d&15,1);
while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;}
return h;
}
function h2d(h) {return parseInt(h,16);}

function Animate() {
	var iObj = new Array();
	iObj = document.getElementsByTagName("a");
	for (i=0;i<iObj.length; i++) {
		if (iObj.item(i).parentNode.getAttribute("id") == "topnav") 
		{iObj.item(i).onmouseover = widthChange; iObj.item(i).onmouseout = widthRestore; }
		if (iObj.item(i).parentNode.parentNode.className  == "nav") 
		{iObj.item(i).onmouseover = colorChange; iObj.item(i).onmouseout = colorRestore; iObj.item(i).onclick = function() {newItem(this.href); return false;}; } //hideContent((this.href.substring(this.href.lastIndexOf("/") + 1)), "ul") 
		//if (iObj.item(i).parentNode.parentNode.parentNode.parentNode.className == "nav") 
		//{iObj.item(i).onclick = function() {newItem(this.href); return false;}; }
		//if (iObj.item(i).parentNode.className.lastIndexOf("hidden") >= 0) 
		//{iObj.item(i).parentNode.style.display = "none";}
		
	}
	
	var catItemHeight;
	iObj = document.getElementsByTagName("div");
	for (i=0;i<iObj.length; i++) {
	    if (iObj.item(i).className == "catItem")
	    {
	        if (iObj.item(i).offsetHeight) 
	            {catItemHeight = iObj.item(i).offsetHeight;}
	    }
	}
	for (i=0;i<iObj.length; i++) {
	    if (iObj.item(i).className == "catItem")
	    {
	        iObj.item(i).style.height = catItemHeight;
	    }
	}
	
}

/*
window.onload = function() {	
	Animate();
}
*/