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);
}


//top image
/* picture indices go from 1 to N */
var r = Math.floor(Math.random() * 5 + 1);
document.getElementById('container0').style.backgroundImage = 'url(themes/Gov1/images/art' + r + '.png)';

//bottom image
/* note: story indices go from 0 to N */
var story = 's';
var step = 0;
if (readCookie('bottomStory')) {
	story = readCookie('bottomStory');
	step = parseInt(readCookie('bottomStoryStep'));
}
switch (story) {
	case 's':
		if (step > 5) { story = 'p'; step = 0; }
		break;
	case 'p':
		if (step > 1) { story = 's'; step = 0; }
		break;
}
document.getElementById('container1').style.backgroundImage = 'url(themes/Gov1/images/bart' + story + step + '.png)';
createCookie('bottomStory', story, 7);
createCookie('bottomStoryStep', step+1, 7);

//liquid layout workaround
if (!document.getElementById('rightmenu'))
	document.getElementById('content').style.marginRight = '15px';