// JavaScript Document
function testCookie(domainName,redirect){
// detect if cookies are being blocked: set, then check.
 x_cookieName = "xyzzy"; // unique
x_domain  = domainName; // set to whatever domain you want to test, with the standard provisos

 x_expires = new Date(); x_expires.setFullYear(x_expires.getFullYear()+1); // testing persistent cookies
xDeleteCookie(x_cookieName); // don't get false positive

// add path if you want to. drop expires for session cookie. drop domain for default domain test.
document.cookie = x_cookieName + "=test; expires=" + x_expires.toGMTString() + "; domain=" + x_domain ;

// now look for it.
 x_cookieString = document.cookie || "";
 x_cookies = x_cookieString.split(/\s*;\s*/);
 x_found = 0;
for ( var i = 0; i < x_cookies.length; i++ ) {
     one_cookie = x_cookies[i];
     dough = one_cookie.split(/\s*=\s*/);
    if (dough[0] == x_cookieName) { x_found = 1; break; }
}

// ensure it's gone
xDeleteCookie(x_cookieName);

// do whatever you want with x_found bool
if (x_found == 1) {
}
else {
    window.location=redirect;
}
}
function xDeleteCookie(name) {
    var oldDate = new Date(1970, 1, 1);
    document.cookie = x_cookieName + "=0; expires=" + oldDate.toGMTString();
}

