	/* 
	******************************************
	   UTILITY FUNCTIONS
	******************************************
	*/
	function Left(str, n){
		if (n <= 0)
			return "";
		else if (n > String(str).length)
			return str;
		else
			return String(str).substring(0,n);
	}

	function Right(str, n){
		if (n <= 0)
		   return "";
		else if (n > String(str).length)
		   return str;
		else {
		   var iLen = String(str).length;
		   return String(str).substring(iLen, iLen - n);
		}
	}

	function getElementsByClassName(oElm, strTagName, strClassName){
		/*
			Written by Jonathan Snook, http://www.snook.ca/jonathan
			Add-ons by Robert Nyman, http://www.robertnyman.com
		*/
		var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
		var arrReturnElements = new Array();
		strClassName = strClassName.replace(/\-/g, "\\-");
		var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
		var oElement;
		for(var i=0; i<arrElements.length; i++){
			oElement = arrElements[i];      
			if(oRegExp.test(oElement.className)){
				arrReturnElements.push(oElement);
			}   
		}
		return (arrReturnElements)
	}
	
	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
	
	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}
	
	




	function changeTabs(theTab, theWrapper) {
		/* 
		******************************************
		  changeTabs()
		  Author: Evan Lavidor, BEAM Interactive
		  Date:   27 March 2006
		  Notes:  Changes the active state  of 
		  		  the tabs and the content that
				  displays on the page for each
				  tab.  
				  
				  Basically just does some element
				  searching and then sets styles
				  or class names.
		******************************************
		*/
		
		// set ID of the <li> and <div> that we're looking for/comparing against
		var activeDiv = theTab + "Content";
		var activeLI = theTab + "Tab";
		
		// get all page elements with a class of "tabContent" - this is all the tabs
		var allContent = getElementsByClassName(document.getElementById(theWrapper), "div", "tabContent");

		// loop over each tab, and deactivate it (set content to invisible, and change the tab itself)
		for (var i=0; i<allContent.length; i++) {
			var thisDiv = document.getElementById(allContent[i].id);
			
			if (allContent[i].id == activeDiv) {
				thisDiv.style.display = "block";
			}
			else {
				thisDiv.style.display = "none";
			}
		}
		
		// now adjust the tabs
		// get all <li> elements on the page
		var allTabs = document.getElementsByTagName("li");
		
		// loop over the <li> elements
		for (var j=0; j<allTabs.length; j++) {
			
			// if the <li>'s parent has the id of "tabList", then it's one of the tabs
			if (allTabs[j].parentNode.id == "tabList") {
				
				// if the tab's id matches the one we need, set the class to activeTab
				if (allTabs[j].id == activeLI) {
					allTabs[j].className = "activeTab";
				}
				else {
					allTabs[j].className = "";
				}
			
			}
		}
	}
