var predates = new Array('05/01/2008');

function doneNewCookie(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { 
    // if there are any cookies
    offset = document.cookie.indexOf(search)
    if (offset != -1) return true;
    else return false;
  }else return false;
}

function SetCookie (name, value, expire, path, domain) { 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = null;
	var expire = (argc > 2) ? argv[2] : null; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
	if(expire != null) expires = new Date(expire);
	document.cookie = name + "=" + value + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) + 
	((domain == null) ? "" : ("; domain=" + domain)) + 
	((secure == true) ? "; secure" : ""); 
}

function CheckPre(URL, cookiename, cookievalue, path, domain) {
	var now = new Date();
	now.setHours(0);
	now.setMinutes(0);
	now.setSeconds(0);
	var showpre=1;
	for (i=0;i <  predates.length;i++) {
		if(Math.round(Math.abs((new Date(predates[i])-now)/86400000)) == 0) showpre=0;
	}
	if (showpre == 0) {
	   var q = document.location.search || document.location.href.hash || "";
	   if (q.indexOf("GG_") == -1 && q.indexOf("YH_") == -1) {
		   //if (outerref == "(none)" && document.domain != "dimension.networkworld.com") {		
			  if (doneNewCookie(cookiename) != true) {
			    var expires = new Date();
				expires.setDate(expires.getDate()+1); // add one day
				SetCookie(cookiename,cookievalue,expires,path,domain);
			    if (doneNewCookie(cookiename) == true && q.indexOf("CDW_BG") == -1) { window.location.href = URL; }
			  }
		   //}
	   }
   }
}
CheckPre("/includes/ads-pre.html","pre",document.location,"/","www.demo.com");
