
window.onload = SizeMenuBar;
window.onresize = SizeMenuBar;
window.onscroll = SizeMenuBar;

function toggleItem(theB,theOId) {
	try {
		// Switch the Holder
		if (theB.alt == "Hide") {
			document.getElementById(theOId).style.display = "none";
			theB.alt = "Show";
			theB.src = "images/cross.gif";
		} else if (theB.alt == "Show") {
			document.getElementById(theOId).style.display = "";
			theB.alt = "Hide";
			theB.src = "images/minus.gif";
		} else {
			// It's Dead Jim
		}
	} catch (Exception) {
		// It's Dead Jim
	}
}

function Confirm(theText,thePage) {
	Answer = confirm(" " + theText + " ");
	if (Answer==true) {
		window.location=thePage;
	} else {
		//do nothing
	}
}

function findPosition(theObject) {
	try {
		if( theObject.offsetParent ) {
			for( var posX = 0, posY = 0; theObject.offsetParent; theObject = theObject.offsetParent ) {
				posX += theObject.offsetLeft;
				posY += theObject.offsetTop;
			}
			return [posX,posY];
		} else {
			return [theObject.x,theObject.y];
		}
	} catch (Exception) {
		// Something bad happend in finding it.. lets return 0x0 so nothing breaks
		return [0,0];
	}
}

function SizeMenuBar() {
	var theCellID = "MenuCell";
	var theOffSet = findPosition(document.getElementById(theCellID))[1]+4;
	if (document.documentElement.scrollHeight > document.body.scrollHeight) {
		document.getElementById(theCellID).style.height = (document.documentElement.scrollHeight - theOffSet);
		SizeBodySplit("BodyTop", "FooterTop");
	} else {
		document.getElementById(theCellID).style.height = (document.body.scrollHeight - theOffSet);
		SizeBodySplit("BodyTop", "FooterTop");
	}
	try {
		sizeFlash();
	} catch (Exception) {
	}
	WindowLoading();
}

function SizeBodySplit(theItem,theFooter) {
	try {
		var theOffSet = parseInt(findPosition(document.getElementById("BodyTop"))[1]) + 4 + parseInt(document.getElementById("FooterTop").scrollHeight);

		if (document.documentElement.scrollHeight > document.body.scrollHeight) {
			document.getElementById(theItem).style.height = (document.documentElement.scrollHeight - theOffSet);
		} else {
			document.getElementById(theItem).style.height = (document.body.scrollHeight - theOffSet);
		}
	} catch (Exception) {
		//if Failed
	}
}

//===================================================================================================================================================
// For use on an object with a 
// onmouseover & onmouseout
// ex: <a href='#' onmouseover="DrawBubble('TheText Here',TransTime (-slower),theXMod,theYMod,'Arrowpos');" onmouseout="DrawBubble('');">Bottom Left</a>

var FADINGTOOLTIP;
var wnd_height, wnd_width;
var tooltip_height, tooltip_width;
var tooltip_shown=false;
var transparency = 100;
var timer_id = 1;

// override events
document.onmousemove = AdjustToolTipPosition;

function DisplayTooltip(tooltip_text, theTrans, theX, theY){
	if (theTrans == null) {
		transparency = 0;
	} else {
		transparency = theTrans;
	}

	if (theX == null) {
		theXMod = 0;
	} else {
		theXMod = theX;
	}

	if (theY == null) {
		theYMod = 0;
	} else {
		theYMod = theY;
	}

	if (FADINGTOOLTIP == null) {
		return;
	}

	FADINGTOOLTIP.innerHTML = tooltip_text;
	tooltip_shown = (tooltip_text != "")? true : false;

	if(tooltip_text != ""){
		// Get tooltip window height
		tooltip_height=(FADINGTOOLTIP.style.pixelHeight)?FADINGTOOLTIP.style.pixelHeight:FADINGTOOLTIP.offsetHeight;
		ToolTipFading();
	} else {
		clearTimeout(timer_id);
		FADINGTOOLTIP.style.visibility="hidden";
	}
}

function AdjustToolTipPosition(e){
	if(tooltip_shown){
		try {
			offset_y = (event.clientY + tooltip_height - document.body.scrollTop + 30 >= wnd_height) ? - 15 - tooltip_height: 20;
			FADINGTOOLTIP.style.visibility = "visible";
			FADINGTOOLTIP.style.left = Math.min(wnd_width - tooltip_width - 10 ,Math.max(3, event.clientX + theXMod)) + document.body.scrollLeft + 'px';
			FADINGTOOLTIP.style.top = (event.clientY + theYMod) + offset_y + document.body.scrollTop + 'px';
		} catch (Exception) {
			offset_y = (e.clientY + tooltip_height - document.body.scrollTop + 30 >= wnd_height) ? - 15 - tooltip_height: 20;
			FADINGTOOLTIP.style.visibility = "visible";
			FADINGTOOLTIP.style.left = Math.min(wnd_width - tooltip_width - 10 ,Math.max(3, e.clientX + theXMod)) + document.body.scrollLeft + 'px';
			FADINGTOOLTIP.style.top = (e.clientY + theYMod) + offset_y + document.body.scrollTop + 'px';
		}
	}
}

function WindowLoading(){
	try {
		MM_preloadImages('images/navigation/consulting_on','images/navigation/tpm_tpr_on.gif','images/navigation/seminars_on.gif','images/navigation/training_on.gif','images/navigation/products_on.gif','images/navigation/pmo_on.gif','images/navigation/maintenance_tip_on.gif','images/navigation/justforyou_on.gif','images/navigation/aboutus_on.gif','images/navigation/myaccount_on.gif');
	} catch (Exception) {
	}

	FADINGTOOLTIP=document.getElementById('FADINGTOOLTIP');

	// Get tooltip window width 
	tooltip_width = (FADINGTOOLTIP.style.pixelWidth) ? FADINGTOOLTIP.style.pixelWidth : FADINGTOOLTIP.offsetWidth;

	// Get tooltip window height
	tooltip_height=(FADINGTOOLTIP.style.pixelHeight)? FADINGTOOLTIP.style.pixelHeight : FADINGTOOLTIP.offsetHeight;

	wnd_height=document.body.clientHeight;
	wnd_width=document.body.clientWidth;
	}

function ToolTipFading(){
	if(transparency <= 100){
	FADINGTOOLTIP.style.filter="alpha(opacity="+transparency+")";
	transparency += 5;
	timer_id = setTimeout('ToolTipFading()', 35);
	}
}

function DrawBubble(theTXT, theTrans, theX, theY, thePos, theColor, theIMGFolder) {
	// Determins if there is text to output
	if (theTXT != "" && theTXT != null) {
		if (thePos != "" && thePos != null) {
			theArrowPos = thePos;
		} else {
			theArrowPos = "N";
		}

		var theBGColor = "#CCCCCC";
		var theURL = "images/ToolTipBubble/";
		var theOUT = "";

		if (theColor != "" && theColor != null) {
			theBGColor = theColor;
		}

		if (theIMGFolder != "" && theIMGFolder != null) {
			theURL = theURL + theIMGFolder + "/";
		}

		if (theArrowPos == "NA") {
			theOUT = theTXT
		} else {
			theOUT = "<TABLE cellspacing=0 cellpadding=0>";
				theOUT = theOUT + "<TR valign=top>";
					theOUT = theOUT + "<TD align=right><IMG SRC=" + theURL + "topleft.gif BORDER=0></TD>";
					theOUT = theOUT + "<TD background=" + theURL + "topline.gif></TD>";
					theOUT = theOUT + "<TD align=left><IMG SRC=" + theURL + "topright.gif BORDER=0></TD>";
				theOUT = theOUT + "</TR>";
				if (theArrowPos.substring(1,2) == "T") {
					theOUT = theOUT + "<TR valign=Top>";
				} else if (theArrowPos.substring(1,2) == "B") {
					theOUT = theOUT + "<TR valign=Bottom>";
				} else {
					theOUT = theOUT + "<TR>";
				}
					theOUT = theOUT + "<TD align=left background=" + theURL + "leftline.gif>";
						if (theArrowPos.substring(0,1) == "L") {
							theOUT = theOUT + "<IMG SRC=" + theURL + "L" + theArrowPos.substring(1,2) + ".gif BORDER=0>";
						}
					theOUT = theOUT + "</TD>";
					theOUT = theOUT + "<TD bgcolor=" + theBGColor + ">" + theTXT + "</TD>";
					theOUT = theOUT + "<TD align=right background=" + theURL + "rightline.gif>";
						if (theArrowPos.substring(0,1) == "R") {
							theOUT = theOUT + "<IMG SRC=" + theURL + "R" + theArrowPos.substring(1,2) + ".gif BORDER=0>";
						}
					theOUT = theOUT + "</TD>";
				theOUT = theOUT + "</TR>";
				theOUT = theOUT + "<TR=Bottom>";
					theOUT = theOUT + "<TD align=right><IMG SRC=" + theURL + "bottomleft.gif BORDER=0></TD>";
					theOUT = theOUT + "<TD background=" + theURL + "bottomline.gif></TD>";
					theOUT = theOUT + "<TD align=left><IMG SRC=" + theURL + "bottomright.gif BORDER=0></TD>";
				theOUT = theOUT + "</TR>";
			theOUT = theOUT + "</TABLE>";
		}

		DisplayTooltip(theOUT, theTrans, theX, theY);
	} else {
		DisplayTooltip("");
	}
}
//===================================================================================================================================================
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//=================================================================================================

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie= name + "=" + escape(value) +
		((expires) ? "; expires=" + expires.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else {
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}

//=================================================================================================

function SetShowHideOptionsHeader() {
	if (getCookie("HeaderCellCookie") == "Hidden") {
		document.getElementById('HeaderCell').style.display = "none";
		document.getElementById('HeaderCellMin').style.display = "none";
		document.getElementById('HeaderCellMax').style.display = "";
	} else {
		document.getElementById('HeaderCell').style.display = "";
		document.getElementById('HeaderCellMin').style.display = "";
		document.getElementById('HeaderCellMax').style.display = "none";
	}
}

function ShowHidePageHeader(){
	if (document.getElementById('HeaderCell').style.display == "") {
		document.getElementById('HeaderCell').style.display = "none";
		document.getElementById('HeaderCellMin').style.display = "none";
		document.getElementById('HeaderCellMax').style.display = "";
		setCookie("HeaderCellCookie", "Hidden");
	} else {
		document.getElementById('HeaderCell').style.display = "";
		document.getElementById('HeaderCellMin').style.display = "";
		document.getElementById('HeaderCellMax').style.display = "none";
		setCookie("HeaderCellCookie", "Show");
	}
	SizeMenuBar();
	try {
		ShowHideMainMenu();
		ShowHideMainMenu();
	} catch (Exception) {
		// Option isn't there
	}
}

function SetShowHideOptionsMenu() {
	if (getCookie("MenuCellCookie") == "Hidden") {
		document.getElementById('MenuCell').style.display = "none";
		document.getElementById('MenuCellMin').style.display = "none";
		document.getElementById('MenuCellMax').style.display = "";
	} else {
		document.getElementById('MenuCell').style.display = "";
		document.getElementById('MenuCellMin').style.display = "";
		document.getElementById('MenuCellMax').style.display = "none";
	}
}

function ShowHideMainMenu(){
	if (document.getElementById('MenuCell').style.display == "") {
		document.getElementById('MenuCell').style.display = "none";
		document.getElementById('MenuCellMin').style.display = "none";
		document.getElementById('MenuCellMax').style.display = "";
		setCookie("MenuCellCookie", "Hidden");
	} else {
		document.getElementById('MenuCell').style.display = "";
		document.getElementById('MenuCellMin').style.display = "";
		document.getElementById('MenuCellMax').style.display = "none";
		setCookie("MenuCellCookie", "Show");
	}
	SizeMenuBar();
}

function EnableHeaderMenuHidding() {
	EnableHeaderHidding();
	EnableMenuHidding();
}

function DisableHeaderMenuHidding() {
	DisableHeaderHidding();
	DisableMenuHidding();
}

function EnableHeaderHidding() {
	document.getElementById("HeaderBodySpacerCell").innerHTML = "<IMG SRC=\"images/HeaderMin.jpg\" onclick=\"ShowHidePageHeader();\" onmouseover=\"DrawBubble('Minimize the Top Banner',100,5,-30,'LT');\" onmouseout=\"DrawBubble('');\" id=\"HeaderCellMin\" style=\"display:;\"><IMG SRC=\"images/HeaderMax.jpg\" onclick=\"ShowHidePageHeader();\" onmouseover=\"DrawBubble('Maximize the Top Banner',100,5,-30,'LT');\" onmouseout=\"DrawBubble('');\" id=\"HeaderCellMax\" style=\"display:None;\">";
	SetShowHideOptionsHeader();
}

function DisableHeaderHidding() {
	document.getElementById("HeaderBodySpacerCell").innerHTML = ""
	setCookie("HeaderCellCookie", "");
}

function EnableMenuHidding() {
	document.getElementById("MenuBodySpacerCell").innerHTML = "<IMG SRC=\"images/MenuMin.jpg\" onclick=\"ShowHideMainMenu();\" onmouseover=\"DrawBubble('Minimize the Main Menu',100,5,-30,'LT');\" onmouseout=\"DrawBubble('');\" id='MenuCellMin' style=\"display:;\"><IMG SRC=\"images/MenuMAX.jpg\" onclick=\"ShowHideMainMenu();\" onmouseover=\"DrawBubble('Maximize the Main Menu',100,5,-30,'LT');\" onmouseout=\"DrawBubble('');\" id='MenuCellMax' style=\"display:none;\">&nbsp;";
	SetShowHideOptionsMenu();
}

function DisableMenuHidding() {
	document.getElementById("MenuBodySpacerCell").innerHTML = "&nbsp;&nbsp;"
	setCookie("MenuCellCookie", "");
}

function printObjectContentById(theID) {
	try {
		var i = null;
		var myW = null;
		var myBody = "";

		myBody = document.getElementById(theID).innerHTML;

		myBody = myBody.replace(/<noprint>/gi,"<SPAN style=\"display:none;\">");
		myBody = myBody.replace(/<\/noprint>/gi,"</SPAN>");

		myW = window.open("","");
		myW.document.write("<HTML>\n<HEAD>\n" + document.getElementsByTagName("head")[0].innerHTML + "\n</HEAD>\n<BODY>\n" + myBody + "\n</BODY>\n</HTML>\n");
		myW.document.close();

		try {
			myW.print();
		} catch (Exception) {
			// Must not like Printing
		}
	} catch (Exception) {
		// It's Dead Jim
	}
}

function RevolvingWindow(ObjectName,HolderID) {
	/* Example Usage
	var myRWindow = new RevolvingWindow("myRWindow","RWindowHolder");

	myRWindow.addElement("<img src=\"http://www.marshallinstitute.com/images/rotating/sample1.jpg\" border=\"0\" ALT=\"S1\">");
	myRWindow.addElement("<img src=\"http://www.marshallinstitute.com/images/rotating/sample2.jpg\" border=\"0\" ALT=\"S2\">");
	myRWindow.addElement("<img src=\"http://www.marshallinstitute.com/images/rotating/sample3.jpg\" border=\"0\" ALT=\"S3\">");

	myRWindow.setStyle("in");
	myRWindow.PausedHover = "images/RevolvingWindow/paused_hover.gif";
	myRWindow.PausedHoverWidth = 12;

	myRWindow.randomStart();

	myRWindow.drawWindow();
	myRWindow.Play();
	*/

	// THis is info gotten from the start it HAS TO BE RIGHT
	this.ObjectName = ObjectName;
	this.HolderID = HolderID

	// This is Vars used in the Object
	this.ElementList = new Array();
	this.CurrentElement = 0;
	this.inTransition = false;
	this.DIVCounter = 1;
	this.Paused = false;
	this.mousePaused = false;
	this.PlayEnabled = false;
	this.MenuEnabled = false;
	this.crossFaderTimer = 1;
	this.autoNextTimer = 1;
	this.Delay = 11000;
	this.TransitionSpeed = 6;
	this.FadeStyle = 2;

	// This is the URL to the images used in the Menu
	this.NextButton_UP = "images/RevolvingWindow/Next.gif";
	this.NextButton_OVER = "images/RevolvingWindow/Next_over.gif";
	this.PauseButton_UP = "images/RevolvingWindow/Pause.gif";
	this.PauseButton_OVER = "images/RevolvingWindow/Pause_over.gif";
	this.PlayButton_UP = "images/RevolvingWindow/Play.gif";
	this.PlayButton_OVER = "images/RevolvingWindow/Play_over.gif";
	this.PreviousButton_UP = "images/RevolvingWindow/Previous.gif";
	this.PreviousButton_OVER = "images/RevolvingWindow/Previous_over.gif";
	this.PausedHover = "images/RevolvingWindow/paused_hover.gif";
	this.PausedHoverWidth = 16;

	// This is the Alignment of Menu Buttons
	this.Menu_VALIGN = "middle";
	this.NextButton_ALIGN = "right";
	this.PausePlayButton_ALIGN = "center";
	this.PreviousButton_ALIGN = "left";

	// Start of Functionality
	this.randomStart = function() {
		this.CurrentElement = Math.floor(Math.random()*this.ElementList.length);
	};

	this.togglePause = function() {
		this.Paused = !this.Paused;
		this.drawMenu();
		if (!this.Paused) {
			this.Play();
		}
	};

	this.previous = function() {
		if (!this.inTransition) {
			clearTimeout(this.autoNextTimer);
			this.CurrentElement--;
			this.switchContent();
			if (this.PlayEnabled) {
				this.Play();
			}
		}
	};

	this.next = function() {
		if (!this.inTransition) {
			clearTimeout(this.autoNextTimer);
			this.CurrentElement++;
			this.switchContent();
			if (this.PlayEnabled) {
				this.Play();
			}
		}
	};

	this.mousePause = function(e) {
		if (!this.mousePaused) {
			if (!this.Paused) {
				this.mousePaused = true;
				this.Paused = true;
				this.drawMenu();
				this.drawPausedHover();
			} else {
				this.mousePaused = false;
			}
		}
	};

	this.mousePlay = function(e) {
		if (!e){
			var e = window.event;
		}

		var wasFound = false;
		var myBox = document.getElementById(this.HolderID + "ContentHolder");
		var theTarget = (e.relatedTarget) ? e.relatedTarget : e.toElement;

		while (theTarget != myBox && theTarget.nodeName != 'BODY' && !wasFound) {
			theTarget = theTarget.parentNode;
			if (theTarget == myBox){
				wasFound = true;
			}
		}

		if (!wasFound) {
			if (this.mousePaused) {
				this.mousePaused = false;
				this.Paused = false;
				this.drawMenu();
				if (this.PlayEnabled) {
					this.Play();
				}
				this.removePausedHover();
			}
		}
	};

	this.drawPausedHover = function () {
		var myBox = document.getElementById(this.HolderID + "ContentHolderTooltip");
		var myArea = document.getElementById(this.HolderID + "ContentHolder");
		var myAreaPos = this.findPosition(myArea);

		myBox.style.display = "";
		myBox.innerHTML = "<img src=\"" + this.PausedHover + "\" border=\"0\" ALT=\"Paused\">";

		myBox.style.left = ((myAreaPos[0]+myArea.offsetWidth)-this.PausedHoverWidth);
		myBox.style.top = myAreaPos[1];
	};

	this.removePausedHover = function() {
		var myBox = document.getElementById(this.HolderID + "ContentHolderTooltip");

		myBox.style.display = "none";
		myBox.innerHTML = "";
	};

	this.setStyle = function(theStyle) {
		try {
			if (theStyle.toLowerCase() == "in") {
				this.FadeStyle = 1;
			} else if (theStyle.toLowerCase() == "out") {
				this.FadeStyle = 2;
			} else if (theStyle.toLowerCase() == "cross") {
				this.FadeStyle = 3;
			} else if (theStyle.toLowerCase() == "snap") {
				this.FadeStyle = 4;
			}
		} catch (Exception) {
			this.FadeStyle = 1;
		}
	};

	this.addElement = function(element) {
		this.ElementList = this.addToArray(this.ElementList,element);
	};

	this.drawWindow = function() {
		var theOut = "";

		theOut += "<DIV class=\"" + this.HolderID + "ContentHolderTooltip\" id=\"" + this.HolderID + "ContentHolderTooltip\" style=\"Z-INDEX: 998; display: none; POSITION: absolute\"></DIV>";
		theOut += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
		theOut += "	<tr valign=\"top\">\n";
		theOut += "		<td align='center' id=\"" + this.HolderID + "ContentHolder\" onmouseOver=\"javascript:" + this.ObjectName + ".mousePause(event);\" onmouseOut=\"javascript:" + this.ObjectName + ".mousePlay(event);\">&nbsp;</td>\n";
		theOut += "	</tr>\n";
		if (this.MenuEnabled) {
			theOut += "	<tr valign=\"top\">\n";
			theOut += "		<td align='center' id=\"" + this.HolderID + "MenuHolder\">&nbsp;</td>\n";
			theOut += "	</tr>\n";
		}
		theOut += "</table>\n";

		document.getElementById(this.HolderID).innerHTML = theOut;
		this.drawContent();
		this.drawMenu();
	};

	this.switchContent = function() {
		try {
			this.inTransition = true;

			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.zIndex = 996;

			document.getElementById(this.HolderID + "ContentHolder").innerHTML += "<DIV class=\"RWindowDIV" + this.HolderID + "DIV" + this.DIVCounter + "\"' id=\"" + this.HolderID + "DIV" + this.DIVCounter + "\" style=\"Z-INDEX: 997; VISIBILITY: hidden; POSITION: absolute;\">" + this.ElementList[Math.abs(this.CurrentElement) % this.ElementList.length] + "</DIV>";

			var myPos = this.findPosition(document.getElementById(this.HolderID + "ContentHolder"));
			var myWidth = document.getElementById(this.HolderID + "ContentHolder").offsetWidth;
			var myHeight = document.getElementById(this.HolderID + "ContentHolder").offsetHeight;


			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.left = myPos[0] + 'px';
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.top = myPos[1] + 'px';
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.width = myWidth;
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.height = myHeight;
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.filter="alpha(opacity=100)";
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.opacity=1;
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.visibility = "visible";

			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.left = myPos[0] + 'px';
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.top = myPos[1] + 'px';
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.width = myWidth;
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.height = myHeight;
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.filter="alpha(opacity=0)";
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.opacity = 0;
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.visibility = "visible";

			this.crossFadeContent(0);

		} catch (Exception) {
			this.drawContent();
		}
	};

	this.drawContent = function() {
		try {
			document.getElementById(this.HolderID + "ContentHolder").innerHTML = "<DIV class=\"RWindowDIV" + this.HolderID + "DIV" + this.DIVCounter + "\"' id=\"" + this.HolderID + "DIV" + this.DIVCounter + "\" style=\"Z-INDEX: 997;\">" + this.ElementList[Math.abs(this.CurrentElement) % this.ElementList.length] + "</DIV>";
		} catch (Exception) {
			document.getElementById(this.HolderID + "ContentHolder").innerHTML = "<DIV class=\"RWindowDIV" + this.HolderID + "DIV" + this.DIVCounter + "\"' id=\"" + this.HolderID + "DIV" + this.DIVCounter + "\" style=\"Z-INDEX: 997;\">It's Dead Jim [" + this.CurrentElement + "] [" + this.ElementList.length + "] [" + (Math.abs(this.CurrentElement) % this.ElementList.length) + "]</DIV>";
		}
		this.DIVCounter++;
		this.inTransition = false;
	};

	this.crossFadeContent = function(theINIT) {
		if (theINIT <= 100) {
			this.inTransition = true;
			try {
				var myOld = document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1));
				var myNew = document.getElementById(this.HolderID + "DIV" + this.DIVCounter);

				if (this.FadeStyle == 1) { // Fade In
					// IE
					myNew.style.filter="alpha(opacity="+ theINIT +")";

					// FF & WebKit
					myNew.style.opacity=(theINIT/100);
				} else if (this.FadeStyle == 2) { // Fade Out
					myOld.style.zIndex = 997; // Moves old to frong
					myNew.style.zIndex = -1; // Moves new to the back

					// IE
					myNew.style.filter="alpha(opacity=100)";
					myOld.style.filter="alpha(opacity="+ (100-theINIT) +")";

					// FF & WebKit
					myNew.style.opacity=1;
					myOld.style.opacity=((100-theINIT)/100);
				} else if (this.FadeStyle == 3) { // Cross Out
					// IE
					myOld.style.filter="alpha(opacity="+ (100-theINIT) +")";
					myNew.style.filter="alpha(opacity="+ theINIT +")";

					// FF & WebKit
					myOld.style.opacity=((100-theINIT)/100);
					myNew.style.opacity=(theINIT/100);
				} else if (this.FadeStyle == 4) { // Snap
					// IE
					myOld.style.filter="alpha(opacity=0)";
					myNew.style.filter="alpha(opacity=100)";

					// FF & WebKit
					myOld.style.opacity=0;
					myNew.style.opacity=1;

					theINIT = 100;
				}
			} catch (Exception) {
				// It's Dead Jim
			}

			theINIT += this.TransitionSpeed;
			this.crossFaderTimer = setTimeout(this.ObjectName + ".crossFadeContent(" + theINIT + ")", 35);
		} else {
			// Clean up dead DIV Counter

			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.zIndex = -1;
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.width = "";
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.height = "";
			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.visibility = "hidden";

			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.position = "";
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.width = "";
			document.getElementById(this.HolderID + "DIV" + this.DIVCounter).style.height = "";

			document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-1)).style.position = "absolute";

			this.DIVCounter++;
			this.inTransition = false;

			try {
				// Try Cleaning up old div
				//document.getElementById(this.HolderID + "ContentHolder").removeChild(document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-2)));
				document.getElementById(this.HolderID + "DIV" + (this.DIVCounter-2)).removeNode(true);
			} catch (Exception) {
				//It's Dead Jim
			}
		}
	};

	this.Play = function() {
		this.PlayEnabled = true;
		this.Paused = false;
		this.mousePaused = false;
		this.drawMenu();
		clearTimeout(this.autoNextTimer);
		this.autoNextTimer = setTimeout(this.ObjectName + ".timedNext()", this.Delay);
	};

	this.timedNext = function() {
		clearTimeout(this.autoNextTimer);
		if (!this.Paused) {
			if (!this.inTransition) {
				this.CurrentElement++;
				this.switchContent();
			}
			this.autoNextTimer = setTimeout(this.ObjectName + ".timedNext()", this.Delay);
		}
	};

	this.drawMenu = function() {
		if (this.MenuEnabled) {
			var theOut = "";

			if (this.PlayEnabled) {
				var cellWidth = 33;
			} else {
				var cellWidth = 50;
			}

			theOut += "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
			theOut += "	<tr valign=\"" + this.Menu_VALIGN + "\">\n";
			theOut += "		<td align=\"" + this.PreviousButton_ALIGN + "\" width=\"" + cellWidth + "%\"><a href=\"javascript:" + this.ObjectName + ".previous();\"><img src=\"" + this.PreviousButton_UP + "\" onmouseover='javascript:this.src=\"" + this.PreviousButton_OVER + "\";' onmouseout='javascript:this.src=\"" + this.PreviousButton_UP + "\";' border=\"0\" ALT=\"Previous\"></a></td>\n";
			if (this.PlayEnabled) {
				theOut += "		<td align=\"" + this.PausePlayButton_ALIGN + "\" width=\"" + cellWidth + "%\"><a href=\"javascript:" + this.ObjectName + ".togglePause();\">";
				if (this.Paused) {
				theOut += "<img src=\"" + this.PlayButton_UP + "\" onmouseover='javascript:this.src=\"" + this.PlayButton_OVER + "\";' onmouseout='javascript:this.src=\"" + this.PlayButton_UP + "\";' border=\"0\" ALT=\"Play\">";
				} else {
					theOut += "<img src=\"" + this.PauseButton_UP + "\" onmouseover='javascript:this.src=\"" + this.PauseButton_OVER + "\";' onmouseout='javascript:this.src=\"" + this.PauseButton_UP + "\";' border=\"0\" ALT=\"Pause\">";
				}
				theOut += "</a></td>\n";
			}
			theOut += "		<td align=\"" + this.NextButton_ALIGN + "\" width=\"" + cellWidth + "%\"><a href=\"javascript:" + this.ObjectName + ".next();\"><img src=\"" + this.NextButton_UP + "\" onmouseover='javascript:this.src=\"" + this.NextButton_OVER + "\";' onmouseout='javascript:this.src=\"" + this.NextButton_UP + "\";' border=\"0\" ALT=\"Next\"></a></td>\n";
			theOut += "	</tr>\n";
			theOut += "</table>\n";

			document.getElementById(this.HolderID + "MenuHolder").innerHTML = theOut;
		}
	};

	this.addToArray = function(theArray,theItem) {
		if (theArray != null) {
			var tempArray = new Array(theArray.length+1);
			var i=0;
			for (i=0;i<theArray.length;i++) {
				tempArray[i] = theArray[i];
			}
			tempArray[theArray.length] = theItem;
			return tempArray;
		} else {
			return null;
		}
	};

	this.findPosition = function(theObject) {
		try {
			if( theObject.offsetParent ) {
				for( var posX = 0, posY = 0; theObject.offsetParent; theObject = theObject.offsetParent ) {
					posX += theObject.offsetLeft;
					posY += theObject.offsetTop;
				}
				return [posX,posY];
			} else {
				return [theObject.x,theObject.y];
			}
		} catch (Exception) {
			// Something bad happend in finding it.. lets return 0x0 so nothing breaks
			return [0,0];
		}
	};
}

// Progress Meeter ================================================================================
	function drawProgressBar(theHolder,thePercent,theTxt,theFColor,theEColor,theWidth,theHeight) {
		var myHolder = null;
		var myPercent = 100;
		var myTxt = null;
		var myFillColor = "#FF0000";
		var myEmptyColor = "#FFFFFF";

		var myWidth = 250;
		var myHeight = 22;

		var myFillHolder = null;
		var myEmptyHolder = null;

		var myFillBar = null;
		var myEmptyBar = null;

		var tempVar = null;

		myHolder = document.getElementById(theHolder);

		if (myHolder != null) {
			// Process incoming Vars ====================================================
				tempVar = parseFloat(thePercent);
				if (!isNaN(tempVar)) {
					myPercent = tempVar;
				}

				tempVar = theTxt;
				if ((tempVar != null) && (tempVar != "")) {
					myTxt = tempVar;
				}

				tempVar = theFColor;
				if ((tempVar != null) && (tempVar != "")) {
					myFillColor = tempVar;
				}

				tempVar = theEColor;
				if ((tempVar != null) && (tempVar != "")) {
					myEmptyColor = tempVar;
				}
			// ==========================================================================

			// Get Dimentions ===========================================================
				tempVar = parseFloat(theWidth);
				if (!isNaN(tempVar)) {
					myWidth = Math.abs(tempVar);
				} // Else default;

				tempVar = parseFloat(theHeight);
				if (!isNaN(tempVar)) {
					myHeight = Math.abs(tempVar);
				} // Else default;
			// ==========================================================================

			// Init/Draw Holder and Items ===============================================
				if (myTxt == null) {
					myTxt = ((Math.round(myPercent*100)/100) + "%");
				}

				myHolder.innerHTML = "";
				myHolder.style.position = "relative";
				myHolder.style.width = myWidth;
				myHolder.style.height = myHeight;
				myHolder.style.overflow = "hidden";
				myHolder.style.display = "inline-block";

				// Sub Empty =======================================================
					myEmptyHolder = document.createElement("div");
					myEmptyHolder.style.position = "absolute";
					myEmptyHolder.style.width = myWidth;
					myEmptyHolder.style.height = myHeight;
					myEmptyHolder.style.overflow = "hidden";
					myEmptyHolder.style.display = "inline"
					myEmptyHolder.style.top = 0;
					myEmptyHolder.style.left = 0;
					myEmptyHolder.style.zIndex = 0;

					// ========================================================
						myEmptyBar = document.createElement("input");
						myEmptyBar.setAttribute("type","text");
						myEmptyBar.setAttribute("value",myTxt);
						myEmptyBar.style.width = myWidth;
						myEmptyBar.style.height = myHeight;
						myEmptyBar.style.background = myEmptyColor;
						myEmptyBar.style.color = myFillColor;
						myEmptyBar.style.fontFamily = "Verdana";
						myEmptyBar.style.fontWeight = "bold";
						myEmptyBar.style.textAlign = "center";
						myEmptyBar.style.lineHeight = (myHeight-4 + "px");
						myEmptyBar.style.cursor = "help";

						myEmptyHolder.appendChild(myEmptyBar);
					// ========================================================

					myHolder.appendChild(myEmptyHolder);
				// =================================================================

				// Sub Fill ========================================================
					myFillHolder = document.createElement("div");
					myFillHolder.style.position = "absolute";
					myFillHolder.style.width = Math.round(myWidth*(myPercent/100));
					myFillHolder.style.height = myHeight;
					myFillHolder.style.overflow = "hidden";
					myFillHolder.style.display = "inline"
					myFillHolder.style.top = 0;
					myFillHolder.style.left = 0;
					myFillHolder.style.zIndex = 10;

					// ========================================================
						myFillBar = document.createElement("input");
						myFillBar.setAttribute("type","text");
						myFillBar.setAttribute("value",myTxt);
						myFillBar.style.width = myWidth;
						myFillBar.style.height = myHeight;
						myFillBar.style.background = myFillColor;
						myFillBar.style.color = myEmptyColor;
						myFillBar.style.fontFamily = "Verdana";
						myFillBar.style.fontWeight = "bold";
						myFillBar.style.textAlign = "center";
						myFillBar.style.lineHeight = (myHeight-4 + "px");
						myFillBar.style.cursor = "help";

						myFillHolder.appendChild(myFillBar);
					// ========================================================

					myHolder.appendChild(myFillHolder);
				// =================================================================
			// ==========================================================================
		}
	}
// ================================================================================================