//<script language="JavaScript">
//clientlib.js

//these functions borrowed from search/head.html
function MakeArray(n) {
	this.length = n
	return this
}

monthNames = new MakeArray(12)
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"


function customDateString(oneDate) {
	var theMonth = monthNames[oneDate.getMonth() + 1]
	var theYear = oneDate.getFullYear()
	return theMonth + " " + oneDate.getDate() + ", " + theYear
}

function jumpInside(sel){
	location.href = sel.options[sel.selectedIndex].value;
}
//end borrowed funcs

 
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=3653"
				); //stick other URLs in the array if you want a rotation sort of thing to happen
			var d = new Date();
			d.setDate(d.getDate()+7); //expire in 7 days
			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.2.7331.1), Copyright (c) 1997-2001 XCache Technologies All Rights Reserved 
// Page: http://192.168.23.45:80/shared/lib/clientlib.js 
// File: file://e:\CacheDir\cache1\shared\lib\00000004.js 
// Origin File: file://E:\wwwdata\pcw\shared\lib\clientlib.js 
// Date: Sat, 04 Jun 2005 09:31:45 GMT 
