// HELPER FUNCTIONS
// IE 5+, Netscape 4+ (PC & MAC)

	function MM_findObj(n, d) { //v4.0
		var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && document.getElementById) x=document.getElementById(n); return x;
	}



// GLOBAL DECLARATIONS
	var waitVar = new Array(100);
	var isSliding;
	function slidingIndicator() {
		bool = false;
	}



// DHTML FUNCTIONS -----------------------------------------------------------------------
	/*
		All functions by Adam J. Moore (adam@adamjmoore.com)
		
		IE 5+, Netscape 4+ (PC & MAC)
			slideDiv
			setWaitVarAfterSequence
			setWaitVarAfterSequenceDelay
			swapImage
			showDiv
			hideDiv
			showDivDelay
			hideDivDelay			
			callFunction
		
		IE 5+, Netscape 6+ (PC & MAC)
			morphTextColor
			morphTextColorRev
			isDivVisible
			displayDivOn
			displayDivOff					
	*/



function slideDiv(divObj, xAmt, yAmt, speed, smoothness, serialize, setVarIndex, waitVarIndex, boolSlideIndicatorObjName) { 
	/*
		Description:
		This function produces a 2-dimensional slide at a constant rate
		
		Inputs:
				divObj		-	The div object ID to slide
				xAmt		-	The amount to slide horizontally, in pixels
				yAmt		-	The amount to slide vertically, in pixels
				speed		-	The speed of the slide, 1 to 100 (fastest)
				smoothness	-	The smoothness of the slide movement; 
								affects the speed, 1 (smoothest) to 100 
				serialize	-	boolean; set the div to be acted upon in serial
				waitVarIndex-	index used for waitVar array; used for action serialization;
				setVarIndex	-	the index in the waitVar array to set as done;

		Limitations:
				in NN4 only	-	May not be able to move divs which weren't originally 
								placed absolutely. May result in an error.
	*/
	
	if ((serialize && waitVar[waitVarIndex] == 'done') || !serialize) {		
	
		//Get the current coordinates of the Div
		if (document.layers) {
			xCur = MM_findObj(divObj).left;
			yCur = MM_findObj(divObj).top;			
		} else {
			if (MM_findObj(divObj).style.position=='relative') {
				xCur = MM_findObj(divObj).style.left;
				yCur = MM_findObj(divObj).style.top;							
				if (xCur.indexOf('px') > 0) xCur = xCur.replace('px', '');
				if (yCur.indexOf('px') > 0) yCur = yCur.replace('px', '');
				if (xCur.indexOf('pt') > 0) xCur = xCur.replace('pt', '');
				if (yCur.indexOf('pt') > 0) yCur = yCur.replace('pt', '');
				xCur = parseInt(xCur);
				yCur = parseInt(yCur);
			} else {				
				xCur = MM_findObj(divObj).offsetLeft;
				yCur = MM_findObj(divObj).offsetTop;
			}		
			//alert(xCur + ',' + yCur);
		}		
		
		//Calculate the horizontal component	
		//Check for overshoot
		xNext = xCur;
		if (xAmt != 0) {
		if (xAmt < 0) {
			//Direction is -
			xFinal = xCur + xAmt;
			xNext = xCur - smoothness;
			if (xNext < xFinal) { 
				xNext = xFinal;
				xAmt = 0;
			} else {
				xAmt = xAmt + smoothness;
			}
			
		} else {
			//Direction is +
			xFinal = xCur + xAmt;		
			xNext = xCur + smoothness;
			if (xNext > xFinal) { 
				xNext = xFinal;
				xAmt = 0;
			} else {
				xAmt = xAmt - smoothness;
			}
		}
		}
	
		//Calculate the vertical component	
		//Check for overshoot
		yNext = yCur;
		if (yAmt != 0) {
		if (yAmt < 0) {
			//Direction is -
			yFinal = yCur + yAmt;
			yNext = yCur - smoothness;
			if (yNext < yFinal) { 
				yNext = yFinal;
				yAmt = 0;
			} else {
				yAmt = yAmt + smoothness;
			}
			
		} else {
			//Direction is +
			yFinal = yCur + yAmt;		
			yNext = yCur + smoothness;
			if (yNext > yFinal) { 
				yNext = yFinal;
				yAmt = 0;
			} else {
				yAmt = yAmt - smoothness;
			}
		}
		}
		
	
		//Set horizontal & vertical components	
		if (document.layers) {
			MM_findObj(divObj).left = xNext;
			MM_findObj(divObj).top = yNext;
		} else {
			MM_findObj(divObj).style.left = xNext;
			MM_findObj(divObj).style.top = yNext;
		}

	}

	//Recursive call	
	if (xAmt!=0 || yAmt!=0)	{
		isSliding = true;		
		if (boolSlideIndicatorObjName != '') eval(boolSlideIndicatorObjName).bool = true;		
		setTimeout('slideDiv(\'' + divObj + '\',' + xAmt + ',' + yAmt + ',' + speed + ',' + smoothness + ',' + serialize + ',' + setVarIndex + ',' + waitVarIndex + ',\'' + boolSlideIndicatorObjName + '\')', 101-speed+20);		
		
	} else {
		isSliding = false;
		if (boolSlideIndicatorObjName != '') eval(boolSlideIndicatorObjName).bool = false;
		if (serialize) waitVar[setVarIndex] = 'done';
	}

}

function setWaitVarAfterSequence(setVarIndex, waitVarIndexa, waitVarIndexb) {
	var allDone = true;
	for(i=waitVarIndexa; i<=waitVarIndexb; i++) {
		if (waitVar[i] != 'done') {
			allDone=false;
			break;
		}
	}
	
	if (allDone) {
		waitVar[setVarIndex] = 'done';
	} else {
		setTimeout('setWaitVarAfterSequence(' + setVarIndex + ',' + waitVarIndexa + ',' + waitVarIndexb + ')', 100);
	}
}

function setWaitVarAfterSequenceDelay(setVarIndex, waitVarIndexa, waitVarIndexb, delay) {
	var allDone = true;
	for(i=waitVarIndexa; i<=waitVarIndexb; i++) {
		if (waitVar[i] != 'done') {
			allDone=false;
			break;
		}
	}
	
	if (allDone) {
		setTimeout('waitVar[' + setVarIndex + '] = \'done\'', delay);
	} else {
		setTimeout('setWaitVarAfterSequenceDelay(' + setVarIndex + ',' + waitVarIndexa + ',' + waitVarIndexb + ',' + delay + ')', 100);
	}
}

function swapImage(imgId, uncachedImageFile) {
	MM_findObj(imgId).src = uncachedImageFile;
} 

function showDiv(divId, outterDivStr) {
	if (document.layers) {
		if (!outterDivStr) { 
			eval('document.'+divId).visibility='visible';		
		 } else {
		 	eval(outterDivStr + '.' +divId).visibility='visible';		
		}
	 } else {
	 	MM_findObj(divId).style.visibility = 'visible';
	}
}

function hideDiv(divId, outterDivStr) {
	if (document.layers) {
		if (!outterDivStr) { 
			eval('document.'+divId).visibility='hidden';		
		 } else {
		 	eval(outterDivStr + '.' +divId).visibility='hidden';		
		}
	 } else {
	 	MM_findObj(divId).style.visibility = 'hidden';
	}
}

function displayDivOn(divId, outterDivStr) {
	if (document.layers) {
		if (!outterDivStr) { 
			eval('document.'+divId).display='block';		
		 } else {
		 	eval(outterDivStr + '.' +divId).display='block';		
		}
	 } else {
	 	MM_findObj(divId).style.display = 'block';
	}
}

function displayDivOff(divId, outterDivStr) {
	if (document.layers) {
		if (!outterDivStr) { 
			eval('document.'+divId).display='none';		
		 } else {
		 	eval(outterDivStr + '.' +divId).display='none';		
		}
	 } else {
	 	MM_findObj(divId).style.display = 'none';
	}
}

function isDivDisplayed(divId, outterDivStr) {
	if (document.layers) {
		if (!outterDivStr) { 
			if (eval('document.'+divId).display=='none') { return false; } else { return true; }
		 } else {
		 	if (eval(outterDivStr + '.' +divId).display=='none') { return false; } else { return true; }	
		}
	 } else {
	 	if (MM_findObj(divId).style.display=='none') { return false; } else { return true; }
	}
}

function isDivVisible(divId, outterDivStr) {
	if (document.layers) {
		if (!outterDivStr) { 
			if (eval('document.'+divId).visibility=='hidden') { return false; } else { return true; }
		 } else {
		 	if (eval(outterDivStr + '.' +divId).visibility=='hidden') { return false; } else { return true; }	
		}
	 } else {
	 	if (MM_findObj(divId).style.visibility=='hidden') { return false; } else { return true; }
	}
}

function showDivDelay (divId, serialize, setVarIndex, waitVarIndex, delay) {
	if (serialize && waitVar[waitVarIndex] != 'done') {
		setTimeout('showDivDelay(\'' + divId + '\', true, ' + setVarIndex + ',' + waitVarIndex + ',' + delay + ')', 100);
	} else {
		MM_findObj(divId).style.visibility = 'visible';
		MM_findObj(divId).style.display = 'block';		
		if (serialize) setTimeout('waitVar[' + setVarIndex + '] = \'done\'', delay);
	}
}

function changeIndex (divId, newIndex, serialize, setVarIndex, waitVarIndex) {
	if (serialize && waitVar[waitVarIndex] != 'done') {
		setTimeout('changeIndex(\'' + divId + '\',' + newIndex + ', true, ' + setVarIndex + ',' + waitVarIndex + ')', 100);
	} else {
		MM_findObj(divId).style.zIndex = newIndex;
		if (serialize) waitVar[setVarIndex] = 'done';
	}
}

function morphTextColor (spanId, colorArray, speed, serialize, setVarIndex, waitVarIndex) {
	if (serialize && waitVar[waitVarIndex] != 'done') {
		setTimeout('morphTextColor(\'' + spanId + '\',' + colorArray.nameOf + ',' + speed + ', true, ' + setVarIndex + ',' + waitVarIndex + ')', 100);
	} else {
		for (mtcI=1; mtcI<=colorArray.length-1; mtcI++) {
			setTimeout('MM_findObj(\'' + spanId + '\').style.color = \'' + colorArray[mtcI] + '\'', mtcI*(100-speed));	
		}
		if (serialize) waitVar[setVarIndex] = 'done';
	}
}

function morphTextColorRev (spanId, colorArray, speed, serialize, setVarIndex, waitVarIndex) {
	if (serialize && waitVar[waitVarIndex] != 'done') {
		setTimeout('morphTextColorRev(\'' + spanId + '\',' + colorArray.nameOf + ',' + speed + ', true, ' + setVarIndex + ',' + waitVarIndex + ')', 100);
	} else {
		for (mtcI=colorArray.length-1; mtcI>=1; mtcI--) {
			setTimeout('MM_findObj(\'' + spanId + '\').style.color = \'' + colorArray[mtcI] + '\'', (colorArray.length-mtcI)*(100-speed));				
		}
		if (serialize) setWaitVarAfterSequenceDelay(setVarIndex, waitVarIndex, waitVarIndex, (colorArray.length-1)*(100-speed))
	}
}

function callFunction (funcString, serialize, setVarIndex, waitVarIndex) {
	var regexp = /'/g; //Remove quotes from function call...
	if (serialize && waitVar[waitVarIndex] != 'done') {
		setTimeout('callFunction(\'' + funcString.replace(regexp, '\\\'') + '\', true, ' + setVarIndex + ',' + waitVarIndex + ')', 100);
	} else {
		eval(funcString);
		if (serialize) waitVar[setVarIndex] = 'done';
	}
}

function hideDivDelay (divId, serialize, setVarIndex, waitVarIndex, delay) {
	if (serialize && waitVar[waitVarIndex] != 'done') {
		setTimeout('hideDivDelay(\'' + divId + '\', true, ' + setVarIndex + ',' + waitVarIndex + ',' + delay + ')', 100);
	} else {
		MM_findObj(divId).style.visibility = 'hidden';
		MM_findObj(divId).style.display = 'none';		
		if (serialize) setTimeout('waitVar[' + setVarIndex + '] = \'done\'', delay);
	}
}
