if (document.getElementById && document.getElementsByTagName) {
	//if (window.addEventListener) window.addEventListener('load', initAnims, false);
	//else if (window.attachEvent) window.attachEvent('onload', initAnims);
}

function initAnims() {
		

			
	//	Init size animation with memory, both directions
		var animElements = document.getElementById("resizercontainer").getElementsByTagName("img");

		for(var i=0; i<animElements.length; i++) {
			animElements[i].onmouseover = widthChange;
			//animElements[i].onmouseover = showbox(i);
			//animElements[i].onmouseout = widthRestore;
		}

		function widthChange() {
			//alert("close me");
			
			if (!this.currentPos) this.currentPos = 0; //if no mem is set, set it first;
			doWidthChangeMem(this,this.currentPos,8,0,10,15,2);

		}

		function widthRestore() {
			
			if (!this.currentPos) return;	//avoid error if mouseout an element occurs before the mosueover
												//(e.g. the pointer already in the object when onload)
			doWidthChangeMem(this,this.currentPos,0,10,10,0.5);
		}

		
		
	}

//*******************
function setOpacity(id, value) {
	id.style.opacity = value/100;
	id.style.filter = 'alpha(opacity=50)';
	
}
var IE = document.all?true:false;

function fade(elem,startRGB,endRGB,finalRGB,steps,intervals,powr) {

	if (elem.bgFadeInt) window.clearInterval(elem.bgFadeInt);
	var actStep = 0;
	var actBack = 0;
	var r=0; var b=0; var g=0;

	//setOpacity(elem, 5);
	elem.bgFadeInt = window.setInterval(
		function() {
			r = easeInOut(startRGB[0],endRGB[0],steps,actStep,powr);
			g = easeInOut(startRGB[1],endRGB[1],steps,actStep,powr);
			b = easeInOut(startRGB[2],endRGB[2],steps,actStep,powr);
			if(r == undefined){ r = endRGB[0]; }
			if(g == undefined){ g = endRGB[1]; }
			if(b == undefined){ b = endRGB[2]; }
			elem.style.color = "rgb("+r+","+g+","+b+")";
			actStep++;
			if (actStep > steps) {
				r = easeInOut(finalRGB[0],endRGB[0],steps,steps-actBack,powr);
				g = easeInOut(finalRGB[1],endRGB[1],steps,steps-actBack,powr);
				b = easeInOut(finalRGB[2],endRGB[2],steps,steps-actBack,powr);
				if(r == undefined){ r = finalRGB[0]; }
				if(g == undefined){ g = finalRGB[1]; }
				if(b == undefined){ b = finalRGB[2]; }

				elem.style.color = "rgb("+r+","+g+","+b+")";
				actBack++;
				if (actBack > steps){
					window.clearInterval(elem.bgFadeInt);
				}
			}
		}
		,intervals)
}

function doWidthChangeMem(elem,startWidth,endWidth,finalWidth,steps,intervals,powr) {
	if (elem.widthChangeMemInt) window.clearInterval(elem.widthChangeMemInt);
	var actStep = 0;
	var actBack = 0;
	elem.widthChangeMemInt = window.setInterval(
		function() {
			
			elem.style.left = easeInOut(startWidth,endWidth,steps,actStep,powr)+"px";
			actStep++;

			if (actStep > steps){
				elem.style.left = easeInOut(startWidth,endWidth,steps,steps-actBack,powr)+"px";
				actBack++;
				if (actBack > steps){
					window.clearInterval(elem.widthChangeMemInt);
				}
			}
		}
		,intervals)
}

function doHeightChangeMem(elem,startHeight,endHeight,steps,intervals,powr) {
	//alert(endHeight);
	//alert(elem);
	if (elem.heightChangeMemInt) window.clearInterval(elem.heightChangeMemInt);
	var actStep = 0;
	//alert(elem.style.pixelHeight);
	elem.heightChangeMemInt = window.setInterval(
		function() {
			//alert(easeInOut(startWidth,endWidth,steps,actStep,powr));
			elem.style.height = easeInOut(startHeight,endHeight,steps,actStep,powr)+"px";
			actStep++;

			if (actStep > steps){
				window.clearInterval(elem.heightChangeMemInt);
				//elem.style.height = '';
				

			}
		}
		,intervals)
	
}

function doOpacityChangeMem(elem,startHeight,endHeight,steps,intervals,powr) {
	//alert(endHeight);
	//alert(elem);
	if (elem.OpacityChangeMemInt) window.clearInterval(elem.OpacityChangeMemInt);
	var actStep = 0;
	//alert(elem.style.pixelHeight);
	elem.OpacityChangeMemInt = window.setInterval(
		function() {
			//alert(easeInOut(startWidth,endWidth,steps,actStep,powr));
			value = easeInOut(startHeight,endHeight,steps,actStep,powr);
			//elem.style.opacity = value/100;
			setOpacity(elem, value)
			//elem.style.filter = 'alpha(opacity='+value+');';
			actStep++;

			if (actStep > steps){
				window.clearInterval(elem.OpacityChangeMemInt);
			}
		}
		,intervals)
	
}
//*******************

function doPosChangeMem(elem,startPos,endPos,steps,intervals,powr) {
	if (elem.posChangeMemInt) window.clearInterval(elem.posChangeMemInt);
	var actStep = 0;
	elem.posChangeMemInt = window.setInterval(
		function() {
			elem.currentPos = [
				easeInOut(startPos[0],endPos[0],steps,actStep,powr),
				easeInOut(startPos[1],endPos[1],steps,actStep,powr)
				];
			elem.style.left = elem.currentPos[0]+"px";
			elem.style.top = elem.currentPos[1]+"px";
			actStep++;
			if (actStep > steps) window.clearInterval(elem.posChangeMemInt);
		}
		,intervals)

}

//*******************

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
		var delta = maxValue - minValue;
		var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
		return Math.ceil(stepp)

}


function TextScroll(scrollname, div_name, up_name, down_name){
    this.div_name = div_name;
    this.name = scrollname;
	var dd = document.getElementById(this.div_name);
	//alert(dd.offsetTop);

    this.scrollCursor = 0;
    this.speed = 10;
    this.timeoutID = 0;
    this.div_obj = null;
    this.up_name = up_name;
    this.dn_name = down_name;

	{
			if (document.getElementById) {
				div_obj = document.getElementById(this.div_name);
				//alert(this.scrollCursor);
				if (div_obj) {
					this.div_obj = div_obj;
					this.div_obj.style.overflow = 'hidden';
					
				}
				div_up_obj = document.getElementById(this.up_name);
				div_dn_obj = document.getElementById(this.dn_name);
				if (div_up_obj && div_dn_obj) {
					/*
					div_up_obj.setAttribute("onmouseover", scrollname + ".scrollUp();")
					div_up_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
					div_dn_obj.setAttribute("onmouseover", scrollname + ".scrollDown();")
					div_dn_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
					*/
					div_up_obj.onmouseover = function() { eval(scrollname + '.scrollUp();') };
					div_up_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };

					div_dn_obj.onmouseover = function() { eval(scrollname + '.scrollDown();') };
					div_dn_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };
				}
			}
	}

	this.stopScroll = function() {
			clearTimeout(this.timeoutID);
			//alert(this.scrollCursor);
	}

	this.scrollUp = function() {
        if (this.div_obj) {
            this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
            this.div_obj.scrollTop = this.scrollCursor;
            this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
        }
    }

	this.scrollDown = function() {

		if (this.div_obj) {
			//alert(this.scrollTop);
			this.scrollCursor += this.speed;
			this.div_obj.scrollTop = this.scrollCursor;
			if (this.div_obj.scrollTop == this.scrollCursor) {
				this.timeoutID = setTimeout(this.name + '.scrollDown()', 60);
			} else {
				this.scrollCursor = this.div_obj.scrollTop;
			}
		}
	}

	this.resetScroll = function() {
        if (this.div_obj) {
            this.div_obj.scrollTop = 0;
            this.scrollCursor = 0;
        }
    }
}




function preload(id) {

	var point = self.document.location.hash.substring(1);
	var ref = document.getElementById(point);
	ref.focus();

if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById(id).style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.hidepage.visibility = 'hidden';
}
else { // IE 4
document.all.hidepage.style.visibility = 'hidden';
}
}
}


