function switchdiv(id)
{
  //safe function to hide or show an element with a specified id
  if (document.getElementById) { // DOM3 = IE5, NS6
    if (document.getElementById(id).style.display != 'none')
      document.getElementById(id).style.display = 'none';
    else
      document.getElementById(id).style.display = 'block';
   } else
   {
     if (document.layers) { // Netscape 4
       if (document.id.display != 'none')
         document.id.display = 'none';
       else
         document.id.display = 'block';
     } else { // IE 4
       if (document.all.id.style.display != 'none')
         document.all.id.style.display = 'none';
       else
         document.all.id.style.display = 'block';
     }
   }
}
function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

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 var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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 eraseCookie(name) {
	createCookie(name,"",-1);
}

function switchPanel() {
	var hide_panel = readCookie('hide_panel');
	if (!hide_panel || hide_panel == 'no') {
		hidediv('userpanel');
		createCookie('hide_panel', 'yes', 365);
	} else {
		showdiv('userpanel');
		createCookie('hide_panel', 'no', 365);
	}
}
