function checkStatus(){
	if(document.getElementById("controls") && document.getElementById("logged-in-options")){
		//alert("ok let's go");
		var controls = document.getElementById("controls");
		var showHide = document.getElementById("logged-in-options");
		var cookievalue = readCookie("status");
		//alert(cookievalue);
		if(cookievalue == "hide"){
			//alert("cookie status is hide");
			showHide.className = "hide";
			controls.src = "/images/plus.gif";
		}
		if(cookievalue == "show"){
			//alert("cookie status is show");
			showHide.className = "show";
			controls.src = "/images/minus.gif";
		}
	}
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function setStatus(newstatus){
	var date = new Date();
	date.setTime(date.getTime()+(1*24*60*60*1000));
	document.cookie = 'status=' + newstatus + '; expires=' + date.toGMTString() + '; path=/';
}
/*


function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

*/

function showHideReplace(control, obj){
	var controls = document.getElementById(control);
	var showHide = document.getElementById(obj);
	if(showHide.className == "hide"){
		showHide.className = "show";
		controls.src = "/images/minus.gif";
		setStatus("show");
	}else{
		showHide.className = "hide";
		controls.src = "/images/plus.gif";
		setStatus("hide");
	}
	return false;
}

if (window.addEventListener)
window.addEventListener("load", checkStatus, false)
else if (window.attachEvent)
window.attachEvent("onload", checkStatus)
else if (document.getElementById)
window.onload=checkStatus;
