//<script language="JavaScript">
//clientlib.js

function jumpInside(sel){
	location.href = sel.options[sel.selectedIndex].value;
}
 
function WM_netscapeCssFix() {
  /*
    Source: Webmonkey Code Library
    (http://www.hotwired.com/webmonkey/javascript/code_library/)

    Author: Taylor
    Author Email: taylor@wired.com
    Author URL: http://www.taylor.org/
    */

  // This part was inspired by Matthew_Baird@wayfarer.com
  // It gets around another unfortunate bug whereby Netscape 
  // fires a resize event when the scrollbars pop up. This 
  // checks to make sure that the window's available size 
  // has actually changed.
  if (document.WM.WM_netscapeCssFix.initWindowWidth != window.innerWidth || document.WM.WM_netscapeCssFix.initWindowHeight != window.innerHeight) {
    document.location = document.location;
  }
}

function WM_netscapeCssFixCheckIn() {
  // This function checks to make sure the version of Netscape 
  // in use contains the bug; if so, it records the window's 
  // width and height and sets all resize events to be handled 
  // by the WM_netscapeCssFix() function.
  if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) == 4)) {
    if (typeof document.WM == 'undefined'){
      document.WM = new Object;
    }
    if (typeof document.WM.WM_scaleFont == 'undefined') {
      document.WM.WM_netscapeCssFix = new Object;
      document.WM.WM_netscapeCssFix.initWindowWidth = window.innerWidth;
      document.WM.WM_netscapeCssFix.initWindowHeight = window.innerHeight;
    }
    window.onresize = WM_netscapeCssFix;
  }
}

WM_netscapeCssFixCheckIn();
var popupwin;
function exitPopUp(){
	var i = Math.random()*5;
	if(navigator.cookieEnabled && i < 1){//don't hit up cookieless browsers
		if(String(document.cookie).indexOf('exitpopup') == -1 &&
			String(location.hostname).indexOf('pcworld.com') != -1){
			//don't ask if already asked in last 30 days;
			//don't ask if not in pcworld.com domain (see comment below)
			var arrURLs = new Array("https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=PCW&cds_page_id=794",
				"https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=PCW&cds_page_id=3653",
				"https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=PCW&cds_page_id=3654");
			var d = new Date();
			d.setDate(d.getDate()+30);//in 30 days, expire
			var sCookie = "exitpopup=1; expires="+d.toGMTString();
			var sAgent = navigator.userAgent;
			//domain and path business not working in Netscape, hence test
			if(sAgent.indexOf("MSIE") != -1)
				sCookie += "; domain=pcworld.com; path=/";
			document.cookie = sCookie;
			var url = Array_RandomlySelectElement(arrURLs);
			popupwin = window.open(url,"","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,menubar=no,width=375,height=480");
			popupwin.focus();
		}
	}
}

/*
preconditions: Array_RandomlySelectElement() is visible in client
*/
function goSub(){
	var arrURLs = new Array("https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=PCW&cds_page_id=839",
		"https://w1.buysub.com/servlet/OrdersGateway?cds_mag_code=PCW&cds_page_id=7978");
	location.href = Array_RandomlySelectElement(arrURLs);
}

function Array_RandomlySelectElement(arr){
	var len = arr.length;
	var idx = Math.floor(Math.random()*len);
	return arr[idx];
}

window.onunload = exitPopUp;
// Created with XCache Version:(2.1.5803.2), Copyright (c) 1997-2001 XCache Technologies All Rights Reserved 
// Page: http://w03.pcworld.com:80/shared/lib/clientlib.js 
// File: file://E:\wwwData\pcw\cache1\shared\lib\00000001.js 
// Origin File: file://E:\wwwData\pcw\shared\lib\clientlib.js 
// Date: Mon, 22 Jul 2002 08:04:01 GMT 

