

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Payper Box - Common Scripts File

Copyright (c) 2004 Payper Box. All rights reserved. 

Created: 16 Jul 2004
Updated: 16 Jul 2004

Revision History:
  1.00	Initial version. NK & TB, 16 Jul 2004

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Browser detection */

var agent = navigator.userAgent.toLowerCase();
is_major = parseInt(navigator.appVersion);
is_minor = parseFloat(navigator.appVersion);

is_nav  = ((agent.indexOf('mozilla') != -1) && (agent.indexOf('spoofer') == -1) && (agent.indexOf('compatible') == -1) && (agent.indexOf('opera') == -1) && (agent.indexOf('webtv') == -1));
	is_nav6up = (is_nav && (is_major >= 5));
var is_ie = (agent.indexOf("msie") != -1);
var is_mac = (agent.indexOf("mac") != -1);
var is_safari = ((agent.indexOf("mac os x") != -1) && (agent.indexOf("safari") != -1));
	if (is_safari) {
		is_nav = false;
	};
is_mozilla = ((agent.indexOf('mozilla') != -1) && (agent.indexOf('netscape') == -1) && (!is_ie));
	if (is_safari) {
		is_mozilla = false;
	};
is_opera = (agent.indexOf('opera') != -1);
	if (is_opera) { 
		is_ie = false; 
	};


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Style sheet code */

document.write('<link href="\/clients\/payperbox\/_styles\/ppb_layout.css" rel="StyleSheet" type="text\/css" \/>');

var internalStyleSheetHTML = '';

if ((is_nav6up) || (is_mozilla) || (is_safari)) {
	internalStyleSheetHTML += ' .menuItem { width: 165px; height: 15px; } ';
	internalStyleSheetHTML += ' #otherLocationsItem { width: 162px; } ';
	internalStyleSheetHTML += ' table.purchaseItem { margin-top: 7px; } th.purchaseDescription, th.purchasePrice, th.addToCartIcon, td.purchaseDescription, td.purchasePrice, td.addToCartIcon { font-size: large; } '; // I have no idea why this line has no affect...
	internalStyleSheetHTML += ' div.purchaseItem table tr th, div.purchaseItem table tr td { font-size: 85%; } ';

	if (is_nav6up) {
		internalStyleSheetHTML += ' body, li, ol, p, table, td, th, ul { font-size: small; } ';
		internalStyleSheetHTML += ' #peelOffBody { width: 180px; } #peelOff { left: 74px; } ';
		internalStyleSheetHTML += ' div.catalogItem { border: 2px outset #999; } ';
	};
};

if (is_opera) {
	internalStyleSheetHTML += ' #peelOff { position: static; margin-right: -30px; margin-left: 10px; z-index: 100000; } ';
};

if (internalStyleSheetHTML != '') {
	internalStyleSheetHTML = '<style type="text\/css"><!-' + '- ' + internalStyleSheetHTML + ' -' + '-><\/style>';
	document.write(internalStyleSheetHTML);
};


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Protocol, path, file name, etc.  */

var internalStyleSheetHTML = '';

var URL = location.href;
var URLProtocol = location.protocol;
var URLHostName = location.hostname;
var URLPort = location.port;
var URLPath = location.pathname;
var URLHash = location.hash;
var URLSearch = location.search;

var URLMinusQueryString = URLProtocol + URLHostName + URLPath;

var pathTemp;
var fileName = URLPath;
if ((URLProtocol.indexOf('file') != -1) && (is_ie)) { 
	pathTemp = fileName.split('\\'); 
} else { 
	pathTemp = fileName.split('/'); 
};
fileName = pathTemp[pathTemp.length - 1];
if (fileName == '') { 
	fileName = 'index.html'; 
};


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Event handling */

onload = function() { 
	pI();			// pageInitialization
};

if (is_nav) {
	onresize = function() { 
		if ((window.innerWidth != wIW) || (window.innerHeight != wIH)) { 
			location.reload(); 
		}; 
	};
} else { 
	onresize = function() { window.location.reload(); };
};

function doNothing() {
	// Actually do nothing...
};


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Banner ad swapper */

var bannerImageName = '';

function sBI() { // swapBannerImage
	if (bannerImageName != '') {
		document['bannerImage'].src = '\/clients\/payperbox\/images\/banners\/' + bannerImageName;
	};
};


/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Page initialization */

function gCOT() { // getCollectionsOfTags
	aTagArray = document.getElementsByTagName('a'); 
	divTagArray = document.getElementsByTagName('div'); 
	liTagArray = document.getElementsByTagName('li'); 
	spanTagArray = document.getElementsByTagName('span'); 
};

function aPI() { // additionalPageInitialization
	// doNothing();
};

function dLL() { // disableLogoLink
	if ((fileName == 'index.html') && (URLPath == '\/index.html')) {
		for (loop = 0; loop < (aTagArray.length - 1); loop++) {
			if (aTagArray[loop].id == 'logoHomeLink') {
				// alert(aTagArray[loop].href);
				aTagArray[loop].href = 'javascript:doNothing();';
				// aTagArray[loop].onclick = function() { setTimeout('window.status="Welcome to Payper Box!"', 0001); };
				aTagArray[loop].onmouseover = function() { setTimeout('window.status="Welcome to Payper Box!"', 0001); };
				aTagArray[loop].onmouseout = function() { setTimeout('window.status=""', 0001); };
			};
		};
	};
};

function sWS(statusMessageText) { // setWindowStatus
	setTimeout('window.status="' + statusMessageText + '"', 0001);
};

function pI() { // pageInitialization
	if (!document.getElementById) {
		return;
	};

	gCOT(); 	// getCollectionsOfTags
	sBI();		// swapBannerImage
	dLL();		// disableLogoLink
	aPI();		// additionalPageInitialization
};


