window.onload = function() {

	if (!document.getElementById('sub1')) return;
	checkCookie();

}

function switchContent(obj) {

	obj = (!obj) ? 'sub1' : obj;

	var contentDivs = document.getElementById('container-text-menu').getElementsByTagName('div');
	for (var i=0, contentDiv; contentDiv=contentDivs[i]; i++) {
		if (contentDiv.id && contentDiv.id.indexOf('sub') != -1) {
			contentDiv.className = 'hide';
		}
	}
	document.getElementById(obj).className = '';
	createCookie('whichContent',obj,365)
	
}

function checkCookie() {

	(readCookie('whichContent')) ? switchContent(readCookie('whichContent')) : switchContent('sub1');

}

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, c; c=ca[i]; 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;

}

