
// Basic Browser Sniffing
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
	
// Main Animation Function
function animateThis(sDefaultSection,iContentDelay) {
	
	wid=(isIE?document.body.offsetWidth:window.innerWidth);
	hgt=(isIE?document.body.offsetHeight:window.innerHeight);
		
	//Figure out which section the user wants
	var urlparts = document.location.href.split("#");
	var sectionName = (urlparts.length==1?sDefaultSection:urlparts[urlparts.length-1]);

	//setCookie('AnimateHeader',1);
	//if (getCookie('AnimateHeader',1)==1) {
		setTimeout("grow('HeaderBar',15,3,260,3,50)",100);
		setTimeout("fade('HeaderLeaf',0,3,100,50)",200);
		setTimeout("fade('MenuTable',0,10,100,100)",100);
		setTimeout("if (ActiveSection=='') showSection('"+sectionName+"');",iContentDelay);
		setCookie('AnimateHeader',0);
	/*
	} else {
		setTimeout("grow('HeaderBar',260,3,260,3,10)",100);
		setTimeout("fade('HeaderLeaf',100,2,100,100)",100);
		setTimeout("fade('MenuTable',0,5,100,50)",10);
	}
	*/		
}

// -------------------------------------------------------
// Function: grow
// Purpose:  Makes a section grow to a certain size
// Arguments: objID - String containing an object id
//				dx - the incremental x change
//				dy - the incremental y change
//				xMax - the incremental y change
//				yMax - the final x value
//				interval - milliseconds between steps
// -------------------------------------------------------
var growTimer=null;
function grow(objID,dx,dy,xMax,yMax,interval) {
	var obj=document.getElementById(objID);
	obj.width  = (dx>0?min(xMax,obj.width+dx):min(xMax,obj.width+dx));
	obj.height = (dy>0?min(yMax,obj.height+dy):max(yMax,obj.height+dy));
	if (obj.height!=xMax || obj.width!=yMax) {
		growTimer=setTimeout("grow('"+objID+"',"+dx+","+dy+","+xMax+","+yMax+","+interval+")", interval);
	}
}

// -------------------------------------------------------
// Function: move
// Purpose:  Makes a section grow to a certain size
// Arguments: objID - String containing an object id
//				x - destination x
//				y - destination y
//				time - milliseconds for motion
//				interval - milliseconds between steps
//
//
//  add acceleration: y = (1-cos(x*pi))/2<BR>
// another option 1+2+3..10..+3+2+1 = 100
// -------------------------------------------------------
var moveTimer=null;
function move(objID,x,y,time,interval) {
	var obj=document.getElementById(objID);
alert('moving...' + obj.id)
	var nSteps = time/interval;
	var dx = (x - obj.left)/nSteps;
	var dx = (y - obj.top)/nSteps;
alert('moving: '+dx)
	obj.left =  obj.left+dx;
	obj.top =  obj.top+dx;
	if (obj.left!=x || obj.yop!=y) {
		growTimer=setTimeout("grow('"+objID+"',"+dx+","+dy+","+xMax+","+yMax+","+interval+")", interval);
	}
}

// -------------------------------------------------------
// Function: fade
// Purpose:  Makes a section fade from one alpha to another
// Arguments: objID - String containing an object id
//				alpha - the starting alpha value (100=opaque)
//				dAlpha - the incremental change
//				alphaMax - the final alpha value
//				interval - milliseconds between steps
// -------------------------------------------------------
var fadeTimer=null;
function fade(objID,alpha,dAlpha,alphaMax,interval) {
	var obj=document.getElementById(objID);
	alpha = (dAlpha>0?min(alphaMax,alpha+dAlpha):max(alphaMax,alpha+dAlpha));
	if (alpha>0) {
		obj.style.display='block'
		obj.style.visibility='visible'
		if (isIE && obj.filters.alpha) obj.filters.alpha.opacity=alpha;
		if (!isIE) obj.style.MozOpacity=alpha/100;
	} else {
		obj.style.display='none';
	}
	if (alpha!=alphaMax) {
		var strCall = "fade('"+objID+"',"+alpha+","+dAlpha+","+alphaMax+","+interval+")";
		fadeTimer=setTimeout(strCall, interval);
	}
}
	
// Display Section Function
var ActiveSection = '';
function showSection(NewSection) {
//	move(ActiveSection,300,300,1000,10);
	if (ActiveSection) fade(ActiveSection,100,-100,0,50);
	try {fade('Home',100,-100,0,50);} catch (e) {}; //Just in case
	fade(NewSection,0,15,100,50);
	if (isNN) {
		// Netscape does not seem to apply the width correctly
		// so I'll just set it manually to a smaller number...
		var obj = document.getElementById(NewSection);
		var obj2 = document.getElementById(NewSection+'Background');
		obj.style.width=355;
		if (obj2) obj2.style.left=300 + obj.offsetLeft;
	}
	ActiveSection = NewSection;
	return false; // Prevent link from refreshing page
}
	
// Min and Max Functions
function min (a,b) {return a<b?a:b;}
function max (a,b) {return a>b?a:b;}