function toggleDiv(divName, NameOfCookie, style) {
	
	divElement = document.getElementById(divName);
	imgExpand = false;
	//alert("NameOfCookie is " + NameOfCookie);
	//OPEN & DELETE
	//If the block is closed then open the div and delete the cookie
	if (divElement.style.display == "none"){
		if (style == "StyledMiddleBox") {
			toggleDivRound(divName);
		} else {
			divElement.style.display = "block";
			imgExpand = true;
		}
		removeCookie(NameOfCookie,"true");
	} else {
	//CLOSE & SET
	//Else close the div and set the cookie with the id
		if (style == "StyledMiddleBox") {
			toggleDivRound(divName);
		} else {
			divElement.style.display = "none";
			imgExpand = false;
		}
		removeCookie(NameOfCookie,"false");
	}
	if  (style != "StyledMiddleBox") {
		try {
			imgElement = document.getElementById(NameOfCookie);
			if (imgExpand == true){
				imgElement.src = "/images/arrowUp.gif"
			} else {
				imgElement.src = "/images/arrowDown.gif"
			}
		} catch (e){}
	}
}

function toggleDivRound(divName) {

	var divNameCollapse = divName + "_collapse";
	
	var expandValue = (document.getElementById(divName).style.display == 'none') ? 'block' : 'none';
	document.getElementById(divName).style.display = expandValue;
	if (expandValue == 'block') {
		document.getElementById(divNameCollapse).style.display = "none";
	} else {
		document.getElementById(divNameCollapse).style.display = "block";

	}
}

function removeCookie(id, rightCollapse) {
	var cookieVal;
	var cookieName="right";
	cookieVal = getCookie(cookieName);
//alert("id: " + id + " rightCollapse " + rightCollapse);	
// OPEN
	if (rightCollapse == "true") {
	
		// DELETE THE COOKIE		
		deleteCookie(cookieName);
		
		var cookieArray = new Array();
		var cookieValArray = new Array();
		var newCookie;	
		cookieArray=cookieVal.split(" ");	
		//alert("length " + cookieArray.length);
		//LOOP through cookie 
		//   remove value
		//   recreate cookie
		//   SET cookie
		  for (i=0;i<cookieArray.length;i++) {
			cookieValArray = cookieArray[i];
			//alert(id + " cookieValArray " + cookieValArray + " " + cookieArray[i]);
			if (cookieValArray == id ) {
				imgElement = document.getElementById(cookieValArray);
				imgElement.src = "images/arrowUp.gif"	
				divElement.style.display = "block";
			} else {
				if (i < 1) {
				newCookie = cookieValArray;
				} else {
				newCookie = newCookie + " " + cookieValArray;
				}
			}
		//alert("here");		
		setCookie(cookieName,newCookie);
	  }
	  
	} else {
//ELSE
//CLOSE
		if (cookieVal == null) {
		cookieVal = id;
		} else {	
		cookieVal = unescape(cookieVal) + " " + id;
		}	
	//alert("in the else " + cookieVal);
	deleteCookie(cookieName);	
	setCookie(cookieName,cookieVal);
	}
}

function checkCookie(divName, NameOfCookie, style) {

	var cookieName="right";

	divElement = document.getElementById(divName);

	if (document.cookie.length > 0) { 
		var cookiethere = document.cookie.indexOf(cookieName);
		if (cookiethere != -1) {
			var cookieArray = new Array();
			var cookieValArray = new Array();
			cookieVal = getCookie(cookieName);
			cookieArray=cookieVal.split(" ");
			//alert("Length " + cookieArray.length);
 	 		for (i=0;i<cookieArray.length;i++) {
				cookieValArray = cookieArray[i];
				if (cookieValArray == NameOfCookie) {
					if (style == "StyledMiddleBox") {
						toggleDivRound(divName);
					} else {
						imgElement = document.getElementById(NameOfCookie);
						imgElement.src = "/images/arrowDown.gif"	
						divElement.style.display = "none";
						break;
					}
					//alert("EQUAL!! cookie val array DIV:" + divName+ " " + NameOfCookie);
				//} else {
					//alert("Not EQUAL!!");
					//imgElement = document.getElementById(NameOfCookie);
					//imgElement.src = "/images/arrowUp.gif"	
					//divElement.style.display = "block";
			}} //end for and if
		} //end cookiethere
	}  //end length
}  //end method

var collapsibleRightDivs = new Array();
var rSlideSpeed = 15; //steps in to move the menu, higher # is faster
var rSlideTimeout = 5; //milliseconds between steps, lower is faster

function CollapsibleRight(rightToggle, contentDiv, blockId) {
	rightToggle.contentDiv = contentDiv;
	if(contentDiv.offsetHeight == 0) {
		contentDiv.style.visibility = "hidden";
		contentDiv.style.display="";
		rightToggle.contentHeight = contentDiv.offsetHeight;
		contentDiv.style.display="none";
	} else {
		rightToggle.contentHeight = contentDiv.offsetHeight;
	}
	rightToggle.arrowDown = document.getElementById("rightArrow_" + blockId); 
	collapsibleRightDivs[collapsibleRightDivs.length] = rightToggle;
	
	rightToggle.showContent = function(e) {
		//open mine, and close all others
		this.contentDiv.style.height = "0px";
		this.contentDiv.style.visibility = "visible";
		this.contentDiv.style.display = "block";
		this.arrowDown.style.display = "none";
		this.slideOpen(); 
		for(var i=0; i < collapsibleRightDivs.length; i++) {
			if(collapsibleRightDivs[i] != this) {
				collapsibleRightDivs[i].arrowDown.style.display = "block";
				collapsibleRightDivs[i].slideClose();
			}
		}
	}

	rightToggle.slideOpen = function() {
		var newHeight = this.contentDiv.offsetHeight + rSlideSpeed;
		if(newHeight >= this.contentHeight) {
			this.contentDiv.style.height = this.contentHeight + "px";

		} else {
			this.contentDiv.style.height = newHeight + "px";
			setTimeout("toggleSlideOpen('" + this.id + "')",  rSlideTimeout);
		}
	}
	
	rightToggle.slideClose = function() {
		var newHeight = this.contentDiv.offsetHeight - rSlideSpeed;
		if(newHeight <= 0) {
			this.contentDiv.style.display = "none";
		} else {
			this.contentDiv.style.height = newHeight + "px";
			setTimeout("toggleSlideClose('" + this.id + "')",  slideTimeout);
		}
	}
}

function toggleSlideOpen(toggleId) {
	var toggle = document.getElementById(toggleId);
	toggle.slideOpen();
}

function toggleSlideClose(toggleId) {
	var toggle = document.getElementById(toggleId);
	toggle.slideClose();
}
