var expandID; var restoreID;

function expandWidth() {clearAllActions(); expandID = window.setInterval(doExpand, 30); document.getElementById('expand').style.display='none'; document.getElementById('contract').style.display='block'; createCookie('pageWidth','expanded','30'); }

function doExpand() { document.getElementById('body').style.width = parseInt(((document.getElementById('body').offsetWidth * 5) + expandedWidth()) / 6) + 'px'; }
function expandedWidth() { return (document.getElementById('main').offsetWidth * 0.95); }

function clearAllActions() {
	window.clearInterval(expandID);
	window.clearInterval(restoreID);
	}

function restoreWidth() { clearAllActions(); restoreID = window.setInterval(doRestore, 30); document.getElementById('contract').style.display='none'; document.getElementById('expand').style.display='block'; createCookie('pageWidth','restored','30'); }
function doRestore() {
	document.getElementById('body').style.width = parseInt(((document.getElementById('body').offsetWidth * 5) + 728) / 6) + 'px';
	if (document.getElementById('body').offsetWidth == 728) clearAllActions();
	}
	
function checkPageWidth() {
	if (readCookie('pageWidth') == 'expanded') { expandWidth(); }
}
	
		
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);
}

