//<!-- 04/21/03; 1:11:44 PM -->
//<!-- Begin

//POPUPS
function GetCookie(name) {
	   var result = null;
	   var cookies = " " + document.cookie + ";";
	   var searchName = " " + unescape(name) + "=";
	   var startOfCookie = cookies.indexOf(searchName);
	   var endOfCookie;
	   if (startOfCookie == -1) {return "none";}
	   if (startOfCookie !=1) {
	    // skip past cookie name
    startOfCookie += searchName.length;
	 endOfCookie = cookies.indexOf(";", startOfCookie);
	   result = unescape(cookies.substring(startOfCookie, endOfCookie));

	   }
	   return result;

}

function popup() {

// date stamping data
		var today = new Date();
		var offset= today.getTimezoneOffset();
		var gmttoday = today.toUTCString();
		gmttoday = Date.parse(gmttoday);
		gmttoday=gmttoday-(offset*1000*60);

		var nextPop = new Date();
		nextPop = gmttoday; // time this popup occurs

		var never = new Date();
		never.setTime(gmttoday + 10000000000); // time the cookie will expire
		var nextPopDelay = 8 * 60 *60 * 1000;



// begin returns

	// session cookie -- if already created or value of session cookie plus delay is greater than next pop time,  exit
		var enabled = GetCookie("enabled");
		if (enabled !="none") {
			if ((Number(enabled)+nextPopDelay)>= nextPop) {return;}
			}

	// user does not want a cookie and has said so, exit
		var popOff = GetCookie("popoff");
		if (isNaN(popOff)) {popOff=0;}
		if (popOff!=0) {return;} //if user has turned off mag sub popups and the popup due is a mag sub just set the cookies and return


	// enable session cookie so we don't have to do this again when the user opens another page

		if (enabled =="none"){
		document.cookie = "enabled" + "="+nextPop+"; domain=.macworld.com; path=/;";
		enabled = GetCookie("enabled");
			}			


	// if user has cookies turned off, exit
	 	if (enabled == "none"){
	 		return;
	 		}
	 	else{
	 	//	if (Number(enabled) != Number(nextPop)) {
	 		//	return;
	 		//	}
	 		}
		
	// read time of next cookie from user disk space.
		var isPopped = GetCookie("isPopped");
		if (isPopped == "none"){isPopped=0;}
		if (( Number(isPopped) + nextPopDelay) > gmttoday) {
		   return;
		}

// end returns

	// url for popup document
		var url = "popuplauncher.php"; 
		var height = 1;
		var width = 1;
		var magsub = 0;

	// check in case the site is macpublishing.net
		var subDomain;
		if (document.domain.match("macpublishing")) {
		  subDomain = ".macpublishing.net";
		} else {
		  subDomain = ".macworld.com";
		}


	// set a cookie for the time that this popup happened
		document.cookie = "isPopped" + "=" + nextPop + ";expires=" + never.toGMTString() + ";domain=" + subDomain + "; path=/;";
//		window.open(url, '_self',"menubar=no,scrollbars=no,location=no,toolbar=no,resizable=no,width=" + width + ",height=" + height);

location=url;
}

//POPUPS END


// End -->
