Cookie checker

can someone point me to javascript that will check for a cookie and if its not there, set one one up? I have this function but I don’t know how to set it to search for the cookie first before making one.

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=/";
}

Any help or just a point in the right direction would be greatly appreciated.