

	/*
	Animation Properties
	*/
	var num1;
	var interval = 40; // 25 iterations per seciond
	var time1 = 0;	// time counter increment every iteration
	var startingPropertyValue = 0;
	var endingPropertyValue = 0;
	var propertyToAnimate;
	var seconds = 0;
	var endMotionCallback;	// function to execute when animation finished
	var animationRunning = false;


		// toggle Box
		function toggleBox(boxName,h){

			if (animationRunning) return;
			var els = document.getElementById(boxName).childNodes;
			// close
			var str="";
			var validNodes = new Array();
			for (i=0; i<els.length;i++){
				if (els[i].nodeType == 1) validNodes.push(els[i]);
	//			str+="["+i+":"+els[i].nodeType+"]<br> ";
			}
	
			var bodyEl = validNodes[0];
			
			
			if (h=="" || h==null || h==undefined) {
				height =  parseInt(bodyEl.style.height.replace(/px/i,""));
			} else {
				height = h;
			}			
			
			//close
			if (bodyEl.style.display == "block"){
				animate(bodyEl,height,-1*(height-1),0.8,"closeBox('"+boxName+"',"+height+")");	// property, startvalue, endvalue, seconds
			} else {			
			// open
	//			bodyEl.style.height = "0px"
				bodyEl.style.display = "block";
				animate(bodyEl,1,height,0.8,"openBox('"+boxName+"')");	// property, startvalue, endvalue, seconds
			}
		
		}

		// close an open box, pass box top container id as string
		function closeBox(boxName,h){
			var els = document.getElementById(boxName).childNodes;
			// close
			var str="";
			var validNodes = new Array();
			for (i=0; i<els.length;i++){
				if (els[i].nodeType == 1) validNodes.push(els[i]);
	//			str+="["+i+":"+els[i].nodeType+"]<br> ";
			}
	
			var bodyEl = validNodes[0];
			//close
			bodyEl.style.display = "none";
			bodyEl.style.height = height+"px";
		
		}
	
	
		// open a closed box, pass box top container id as string
		function openBox(boxName){
			var els = document.getElementById(boxName).childNodes;
			// close
			var str="";
			var validNodes = new Array();
			for (i=0; i<els.length;i++){
				if (els[i].nodeType == 1) validNodes.push(els[i]);
	//			str+="["+i+":"+els[i].nodeType+"]<br> ";
			}
	
			var bodyEl = validNodes[0];
			// open
			bodyEl.style.display = "block";
		
		}
	
	
	
	// quintic easing in - accelerating from zero velocity
	// t: current time, b: beginning value, c: change in value, d: duration
	// t and d can be frames or seconds/milliseconds
	
	
	
	function easeInQuint(t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	}
	
	// sinusoidal easing out - decelerating to zero velocity
	function easeOutSine(t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	}
	

	
	// animating the height of a box
	// propertyAffected = html element (object)
	// startValue = starting vaue
	// endValue = ending value
	// sec = number of seconds for animation to take palce (an approximation)
	// evalFunc = function to execute when animation finishes
	function animate(propertyAffected,startValue,endValue,secs,evalFunc){
		endMotionCallback = evalFunc;
		seconds = secs*20;
		startingPropertyValue = startValue;
		endingPropertyValue = endValue;
		propertyAffected.style.height = startValue+"px";
		num1 = setInterval("animateAnimationRenderer()",interval);
		propertyToAnimate = propertyAffected;
		animationRunning = true;
	}
	
	
	// animation renderer function, runs on setInterval
	function animateAnimationRenderer(){
	
		var el = propertyToAnimate;
		var b = parseInt(el.style.height);
		//startTime,y,distance,duration
		var val = Math.round(easeOutSine(time1,startingPropertyValue,endingPropertyValue,seconds));
		el.style.height = val+"px";
		//el.innerHTML = val;
		time1++;
		//alert("t:"+t+"b:"+b+"c:"+c+"d:"+d);
		if (startingPropertyValue < endingPropertyValue){
			if (b>=endingPropertyValue+startingPropertyValue) {
				clearInterval(num1);
				if (endMotionCallback != null) {
					eval(endMotionCallback);
					endMotionCallback = null;
					time1 = 0;
					animationRunning = false;
				}
				
			}
		} else {
			if (b<=startingPropertyValue+endingPropertyValue) {
				clearInterval(num1);
				if (endMotionCallback != null) {
					eval(endMotionCallback);
					endMotionCallback = null;
					time1 = 0;
					animationRunning = false;
				}			
			}
			
		}	
	}
	
	
/*******************************************************************************
 open window function
********************************************************************************/
 
function Open_Window(winName) { //v2.0
var size = 'width=775,height=560';
var features;
features = size+'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,fullscreen=no';
  var Popup = window.open(winName,"tisWindow",features);
  Popup.focus();
}
 
function Open_Window2(winName) { //v2.0
var size = 'width=500,height=400';
var features;
features = size+'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,fullscreen=no';
  var Popup = window.open(winName,"tisWindow",features);
  Popup.focus();
}
 
 	
	
	