/*
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 (document.cookie.indexOf("referred")>-1) {
		return true;
	} else { 
		eval("window.location=URL;");
	};
}

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

function redircookie(URL) {
	if (document.cookie.indexOf("referred")>-1) {
		eval("window.location=URL;");
	} else { 
		return true;
		};
}

/*
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 setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
";path=/;domain=dreamhost.com"+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function redirnoreferrercookie(URL) {
	if (document.cookie.indexOf("referrer")>-1) {
		return true;
	} else {
		setCookie("cookietest","ok",3650);
		if (document.cookie.indexOf("cookietest")>-1) {
			setCookie("referrer",document.referrer,3650);
			eval("window.location=URL;");
		} else {
		  return true;
		}
	};
}
