On page load, if cookie set then hide div?

Here is where you get the functions for handling cookies:
http://www.quirksmode.org/js/cookies.html


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);
}

The div to be shown should have a class name set to hide by default.


#advert {
   display: none;
}
#advert.show {
    display: block;
}

With the above cookie handling functions, you can use them like this:

Place the following script just before the </body> tag.


var days = 1;
var advert = document.getElementById('advert');
if (readCookie('seenAdvert')) {
    advert.className = '';
} else {
    advert.className = 'show';
    createCookie('seenAdvert', 'yes', days);
}