function hasCookie(name) {
	return (jQuery.cookie(name) != null && jQuery.cookie(name) != undefined);
}

/*
If a referrer cookie exists, don't do anything, otherwise
auto-load the current promo page.

This is to appease affiliates who disagree with our practice of
running strange things like 'promotions' and 'sales'!
*/

function redirnocookie(URL) {
	if (hasCookie("referred")) {
		return true;
	}

	try { window.location = URL; } catch(e) { ; }
}

/*
If a referrer cookie exists, forward them on, otherwise
don't do anything.
*/

function redircookie(URL) {
	if (!hasCookie("referred")) {
		return true;
	}

	try { window.location = URL; } catch(e) { ; }
}

/*
If they don't have a referrer cookie, set one based on
the DOM value of document.referrer, then load URL.
This 'referrer' cookie is separate from our 'referred' cookie.
*/

function redirnoreferrercookie(URL) {
	/* The referrer_set cookie to work around a nasty bug with jQuery.cookie and IE8 */
	if (hasCookie("referrer_set")) {
		return true;
	}

	var cookie_opts = {
		expires: 1, /* just one day! */
		path:    '/',
		domain:  'dreamhost.com'
	};

	jQuery.cookie("cookietest", "ok", cookie_opts);
	if (jQuery.cookie("cookietest") != "ok") { /* browser doesn't support cookies? */
		return true;
	}

	jQuery.cookie("referrer", document.referrer, cookie_opts);
	jQuery.cookie("referrer_set", "yes", cookie_opts);
	try { window.location = URL; } catch(e) { ; }
}


