//Save state
function setCookie(cookieName, cookieValue)
{
	document.cookie=cookieName + "=" + escape(cookieValue);
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{ 
		c_start=document.cookie.indexOf(c_name + "=");
		
		if (c_start!=-1)
		{ 
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
		
			if (c_end==-1) {
				 c_end=document.cookie.length;
			}
			
			return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	
	return null
}

function setInLastState() {

	var lastState = getCookie(window.parent.name);

	if(lastState == 'hide') {
		switchState(document.right_bar, 'show');
	}
	
	return true;
}
//End Save State

var lastState = null;

function maximizeMainContents() {
	switchState(document.right_bar, lastState);
}

function switchState(elementTarget, action)
{
	var currentState = '';
	
	if(action == 'show') {
		elementTarget.style.display="";
		currentState = 'hide';
	}else{
		elementTarget.style.display="none";
		currentState = 'show';
	}
	
	//Save current state;
	window.name = elementTarget.id;
	setCookie(window.name, currentState);
	
	lastState = currentState;
	
	return true;
}