    ///////////////////////
   // BROWSER DETECTION //
  ///////////////////////
var ns  =    (navigator.appName.indexOf("Netscape")!=-1);
var ns4 =    (ns && parseInt(navigator.appVersion)==4);
var ns5min = (ns && parseInt(navigator.appVersion)>=5);
var safari = (navigator.userAgent.indexOf("Safari/")!=-1);
var safari1 = (safari && eval(parseInt(navigator.appVersion.indexOf("Safari/")+7)) >= 85 &&  eval(parseInt(navigator.appVersion.indexOf("Safari/")+7)) <= 400 );
var safari2 = (safari && eval(parseInt(navigator.appVersion.indexOf("Safari/")+7)) >= 400);
var firefox =(navigator.userAgent.indexOf("Firefox/")!=-1);
var ie  =    (navigator.appVersion.indexOf('MSIE')!=-1);
var ie4 =    (ie && eval(parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)))==4);
var ie5 =    (ie && eval(parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)))==5);
var ie5min = (ie && eval(parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)))>=5);
var ie6 =    (ie && eval(parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)))==6);
var ie6min = (ie && eval(parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)))>=6);
var ie7 =    (ie && eval(parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)))==7);
var ie7min = (ie && eval(parseInt(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5)))>=7);
var domua =  (ie5min || ns5min || firefox || safari);
var mac = (navigator.userAgent.indexOf('Macintosh')!=-1 || navigator.userAgent.indexOf('Mac_')!=-1);

/* page init code */
var loaded = false;
var secpre = 'https://www.pollys.com/';
var secprecgi = 'https://www.pollys.com/cgi-bin/';
var secureprefix = (document.location.protocol=='https:')? secpre:'';
var secureprefixcgi = (document.location.protocol=='https:')? secprecgi:'';
var insecureprefix = (document.location.protocol=='https:')? 'http://www.pollys.com':'';
//var signinsignout = (document.cookie.indexOf('PGCCUSTOMER=')!=-1)?'<a href="'+secureprefixcgi+'signout.cgi">sign out</a>&nbsp;&nbsp;|&nbsp;&nbsp;':'<a href="'+secureprefixcgi+'signin.cgi">sign in</a>&nbsp;&nbsp;|&nbsp;&nbsp;';
var re1 = /PGCCUSTOMER=([^;]+)/;
var re2 = /PGCREMEMBER=([^;]+)/;
var re3 = /PGCFIRSTNAME=([^;]+)/;
var re4 = /PGCREMEMBERFIRSTNAME=([^;]+)/;
var custemail;
var custfirstname = '';
var signinyouraccount = '<a href="'+secprecgi+'signin.cgi">sign in</a>';
if (re1.test(document.cookie)) {
	custemail=re1.exec(document.cookie)[1];
	signinyouraccount = '<a href="'+secprecgi+'editprofile.cgi?mode=review">your account</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="'+secprecgi+'signout.cgi">sign out</a>';
	if (re3.test(document.cookie)) {
		custfirstname=re3.exec(document.cookie)[1];
		signinyouraccount = custfirstname+' : '+signinyouraccount;
		}
	}
else if (re2.test(document.cookie)) {
	custemail=re2.exec(document.cookie)[1];
	signinyouraccount = '<a href="'+secprecgi+'signin.cgi?dest='+secprecgi+'editprofile.cgi?mode=review">your account</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="'+secprecgi+'signout.cgi?forgetme=1">sign out</a>';
	if (re4.test(document.cookie)) {
		custfirstname=re4.exec(document.cookie)[1];
		signinyouraccount = custfirstname+' : '+signinyouraccount;
		}
	}

// If user comes from checkout page, assume that they want to continue adding to their last order.
// Reinstate 'ORDER' cookie from backup stored in 'LASTORDER' cookie.
if (document.referrer.indexOf('checkout.cgi')!=-1 && location.href.indexOf('/thanks.cgi')==-1 && getCookie('LASTORDER')!=null) {
	setCookie('ORDER',getCookie('LASTORDER'));
	}

function init() {
	if (typeof(initLocal)!='undefined') {initLocal();}
	high(nav1Items,nav1Default);
	high(nav2Items,nav2Default);
	loaded = true;
	return true;
	}
window.onload = init;





function fnErrorTrap(sMsg,sUrl,sLine){
	//alert((sMsg.indexOf('Invalid argument.')!=-1 || sMsg.indexOf('Access is denied')!=-1) + ' for: ' +sMsg);
	if (sMsg.indexOf('Invalid argument.')!=-1 || sMsg.indexOf('Access is denied')!=-1) {
		if (sw < minw || sh < minh) {
			resizeToMinimum(minw,minh)
			return true;
			}
		}
	else {return false;}
	}
if (ie) {window.onerror=fnErrorTrap;}
var sh;
var sw;
function updateClientDimensions() {
	sw = parseInt((safari)? document.clientWidth:document.body.clientWidth);
	sh = parseInt((safari)? document.clientHeight:document.body.clientHeight);
	}
var minw=false;
var minh=false;
window.rsto=false;
function resizeToMinimum(w,h) {
	updateClientDimensions();
	if (w && h) {minw=w;minh=h;}
	var rsw=0;
	var rsh=0;
	var doit=false;
	if (minw && sw < minw) {rsw = minw - sw;doit=true;}
	if (minh && sh < minh) {rsh = minh - sh;doit=true;}
	if (doit) {
		if (ie) {
			if (window.rsto){clearTimeout(window.rsto);}
			window.rsto = setTimeout('window.resizeBy('+rsw+','+rsh+')',100);
			}
		else {
			if (safari1 && rsw==0) {rsw=1;}
			window.resizeBy(rsw,rsh);
			}
		updateClientDimensions();
		}
	}


/* Navigation highlight */
var navtimer = null;
var nav1Items = new Array('topnavtabsnone','topnavtabsshop','topnavtabsdiscover');
var nav2Items = new Array('none','shop','discover');

var nav1Default = 0;
var nav2Default = 0;
var nav2_1High = 0;
var nav3_1High = 0;
var nav3_1Hidden = true;
var nav2_2High = 0;
var nav3_2High = 0;
var nav3_2Hidden = true;

function high(group,who) {
	clearTimeout(navtimer);
	for (var i=0;i<group.length;i++) {
		eval('L.layerProp("'+group[i]+'")').visibility = 'hidden';
		}
	eval('L.layerProp("'+group[who]+'")').visibility = 'visible';
	
	if      (group[who]=='topnavtabsdiscover' && nav3_2Hidden) { tabhigh(nav3_2High); }
	else if (group[who]=='topnavtabsshop'     && nav3_1Hidden) { tabhigh(nav3_1High); }
	
	}
function tabhigh() {
	return true;
	}

function writenavlayercode() {
	document.writeln('<DIV CLASS="topnavtabs" ID="topnavtabsnone">');
	document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="20">');
	document.writeln('	<tr>');
	document.writeln('		<td align="center" valign="top" bgcolor="#FF9933" height="23">');
	document.writeln('		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="23">');
	document.writeln('			<tr align="center" valign="bottom" height="23">');
	document.writeln('				<td width="80" height="23"> </td>');
	document.writeln('				<td width="140" height="23"><a href="#" onclick="window.focus(); return false;" onmouseover="clearTimeout(navtimer); high(nav1Items,1); high(nav2Items,1);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 500);"><img src="'+ secureprefix +'/images/home_nav_top_shop_off.gif" name="shoptab" width="140" height="20" border="0"></a></td>');
	document.writeln('				<td width="3"><img src="'+ secureprefix +'/images/t.gif" width="1" height="20" border="0"></td>');
	document.writeln('				<td width="140"><a href="#" onclick="window.focus(); return false;" onmouseover="clearTimeout(navtimer); high(nav1Items,2); high(nav2Items,2);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 500);"><img src="'+ secureprefix +'/images/home_nav_top_discover_off.gif" name="discovertab" width="140" height="20" border="0"></td></td>');
	document.writeln('				<td align="right" valign="middle" class="navutil">'+signinyouraccount+'</td>');
	document.writeln('				<td width="30" height="23"> </td>');
	document.writeln('			</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('</table>');
	document.writeln('</DIV>');
	document.writeln('<DIV CLASS="topnavtabs" ID="topnavtabsshop">');
	document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="20">');
	document.writeln('	<tr>');
	document.writeln('		<td align="center" valign="top" bgcolor="#FF9933" height="23">');
	document.writeln('		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="23">');
	document.writeln('			<tr align="center" valign="bottom" height="23">');
	document.writeln('				<td width="80" height="23"> </td>');
	document.writeln('				<td width="140" height="23"><a href="#" onclick="window.focus(); return false;" onmouseover="clearTimeout(navtimer); high(nav1Items,1); high(nav2Items,1);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 500);"><img src="'+ secureprefix +'/images/home_nav_top_shop_on.gif" name="shoptab" width="140" height="20" border="0"></a></td>');
	document.writeln('				<td width="3"><img src="'+ secureprefix +'/images/t.gif" width="1" height="20" border="0"></td>');
	document.writeln('				<td width="140"><a href="#" onclick="window.focus(); return false;" onmouseover="clearTimeout(navtimer); high(nav1Items,2); high(nav2Items,2);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 500);"><img src="'+ secureprefix +'/images/home_nav_top_discover_off.gif" name="discovertab" width="140" height="20" border="0"></td></td>');
	document.writeln('				<td align="right" valign="middle" class="navutil">'+signinyouraccount+'</td>');
	document.writeln('				<td width="30" height="23"> </td>');
	document.writeln('			</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('</table>');
	document.writeln('</DIV>');
	document.writeln('<DIV CLASS="topnavtabs" ID="topnavtabsdiscover">');
	document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="20">');
	document.writeln('	<tr>');
	document.writeln('		<td align="center" valign="top" bgcolor="#FF9933" height="23">');
	document.writeln('		<table cellpadding="0" cellspacing="0" border="0" width="100%" height="23">');
	document.writeln('			<tr align="center" valign="bottom" height="23">');
	document.writeln('				<td width="80" height="23"> </td>');
	document.writeln('				<td width="140" height="23"><a href="#" onclick="window.focus(); return false;" onmouseover="clearTimeout(navtimer); high(nav1Items,1); high(nav2Items,1);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 500);"><img src="'+ secureprefix +'/images/home_nav_top_shop_off.gif" name="shoptab" width="140" height="20" border="0"></a></td>');
	document.writeln('				<td width="3"><img src="'+ secureprefix +'/images/t.gif" width="1" height="20" border="0"></td>');
	document.writeln('				<td width="140"><a href="#" onclick="window.focus(); return false;" onmouseover="clearTimeout(navtimer); high(nav1Items,2); high(nav2Items,2);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 500);"><img src="'+ secureprefix +'/images/home_nav_top_discover_on.gif" name="discovertab" width="140" height="20" border="0"></td></td>');
	document.writeln('				<td align="right" valign="middle" class="navutil">'+signinyouraccount+'</td>');
	document.writeln('				<td width="30" height="23"> </td>');
	document.writeln('			</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('</table>');
	document.writeln('</DIV>');
	document.writeln('<DIV CLASS="topnavitems" ID="none">');
	document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="20">');
	document.writeln('	<tr>');
	document.writeln('		<td align="center" valign="top">');
	document.writeln('		<table cellpadding="0" cellspacing="0" border="0" width="652" height="20">');
	document.writeln('			<tr align="left" valign="middle">');
	document.writeln('				<td class="navitm" width="652">');
	document.writeln('				<!-- empty -->');
	document.writeln('				</td>');
	document.writeln('			</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('</table>');
	document.writeln('</DIV>');
	document.writeln('<DIV CLASS="topnavitems" ID="shop">');
	document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="20" bgcolor="#CC6600">');
	document.writeln('	<tr>');
	document.writeln('		<td align="left" valign="bottom">');
	document.writeln('		<table cellpadding="0" cellspacing="0" border="0" width="652" height="20">');
	document.writeln('			<tr align="left" valign="middle">');
	document.writeln('				<td width="120"> </td>');
	document.writeln('				<td class="navitm" width="652">');
	document.writeln('				<a href="' + insecureprefix + '/store/coffee.html" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_1High==1)?'<span class="navitmYellow">':'') + 'Coffee' + ((nav2_1High==1)?'</span>':'') + '</a>');
	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('				<a href="' + insecureprefix + '/store/tea.html" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_1High==2)?'<span class="navitmYellow">':'') + 'Tea' + ((nav2_1High==2)?'</span>':'') + '</a>');
//	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
//	document.writeln('				<a href="' + insecureprefix + '/store/equipment.html" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_1High==3)?'<span class="navitmYellow">':'') + 'Equipment' + ((nav2_1High==3)?'</span>':'') + '</a>');
//	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
//	document.writeln('				<a href="' + insecureprefix + '/store/gifts.html" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_1High==4)?'<span class="navitmYellow">':'') + 'Gifts' + ((nav2_1High==4)?'</span>':'') + '</a>');
	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('				<a href="' + insecureprefix + '/store/special.html?popto=PGC801" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_1High==5)?'<span class="navitmYellow">':'') + 'Peanuts' + ((nav2_1High==5)?'</span>':'') + '</a>');
	document.writeln('				</td>');
	document.writeln('			</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('</table>');
	document.writeln('</DIV>');
	document.writeln('<DIV CLASS="topnavitems" ID="discover">');
	document.writeln('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="20" bgcolor="#CC6600">');
	document.writeln('	<tr>');
	document.writeln('		<td align="left" valign="top">');
	document.writeln('		<table cellpadding="0" cellspacing="0" border="0" width="652" height="20">');
	document.writeln('			<tr align="left" valign="middle">');
	document.writeln('				<td width="120"> </td>');
	document.writeln('				<td class="navitm" width="652">');
	document.writeln('				<a href="' + insecureprefix + '/discover/roasting.html" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_2High==1)?'<span class="navitmYellow">':'') + 'Roasting' + ((nav2_2High==1)?'</span>':'') + '</a>');
	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('				<a href="' + insecureprefix + '/discover/brewing.html" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);" class="navitm">' + ((nav2_2High==2)?'<span class="navitmYellow">':'') + 'Brewing' + ((nav2_2High==2)?'</span>':'') + '</a>');
	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('				<a href="' + insecureprefix + '/discover/galleries/" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_2High==3)?'<span class="navitmYellow">':'') + 'Photos' + ((nav2_2High==3)?'</span>':'') + '</a>');
	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('				<a href="' + insecureprefix + '/discover/video/" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_2High==4)?'<span class="navitmYellow">':'') + 'Videos' + ((nav2_2High==4)?'</span>':'') + '</a>');
	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('				<a href="' + insecureprefix + '/discover/press/" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_2High==5)?'<span class="navitmYellow">':'') + 'Press' + ((nav2_2High==5)?'</span>':'') + '</a>');
	document.writeln('				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
	document.writeln('				<a href="' + insecureprefix + '/discover/about_us.html" onmouseover="clearTimeout(navtimer);" onmouseout="navtimer=setTimeout(\'high(nav1Items,nav1Default); high(nav2Items,nav2Default);\', 700);">' + ((nav2_2High==6)?'<span class="navitmYellow">':'') + 'About Us' + ((nav2_2High==6)?'</span>':'') + '</a>');
	document.writeln('				</td>');
	document.writeln('			</tr>');
	document.writeln('		</table>');
	document.writeln('		</td>');
	document.writeln('	</tr>');
	document.writeln('</table>');
	document.writeln('</DIV>');
	}

    ///////////////
   // LAYERTOOL //
  ///////////////
 // Makes cross-browser DHTML scripting practical.
///////////////
var L=new layerTool();
function layerTool() {
	this.windowref = (arguments.length>0)? arguments[0]:window;
	if (domua) {
		this.layerProp=new Function("if (safari) {this.windowref.arguments = arguments;} with (this.windowref) {return document.getElementById(arguments[arguments.length-1]).style;}");
		this.layerRef =new Function("if (safari) {this.windowref.arguments = arguments;} with (this.windowref) {return document.getElementById(arguments[arguments.length-1]);}");
		this.layerDoc =new Function("with (this.windowref) {return document;}");
		}
	else if (ie4) {
		this.layerProp=new Function("with (this.windowref) {return document.all[arguments[arguments.length-1]].style;}");
		this.layerRef =new Function("with (this.windowref) {return document.all[arguments[arguments.length-1]];}");
		this.layerDoc =new Function("with (this.windowref) {return document;}");
		}
	else if (ns4) {
		this.layerProp=navProp;
		this.layerRef=navProp;
		this.layerDoc=navDocRef
		}
	}
function navProp() { with (this.windowref) {
		retVal="";
		for (x=0;x<arguments.length;x++) {
			retVal+="document.layers['"+arguments[x]+"']";
			if (x!=arguments.length-1) { retVal+="."; }
			}
		return eval(retVal);
	}}
function navDocRef() { with (this.windowref) {
		retVal="";
		for (x=0;x<arguments.length;x++) {
			retVal+="document.layers['"+arguments[x]+"']";
			if (x!=arguments.length-1) { retVal+="."; }
			}
		return eval(retVal +'.document');
	}}

    /////////////////
   // LAYEROBJECT //
  /////////////////
 // Object oriented approach to DHTML layer management.
/////////////////
//methods
layerObject.prototype.show = showLayer;
layerObject.prototype.hide = hideLayer;
layerObject.prototype.setPosition = setPosition;
layerObject.prototype.write = writeto;
layerObject.prototype.draw = drawLayer;
layerObject.prototype.getHeight = getHeight;
layerObject.prototype.getWidth = getWidth;
layerObject.prototype.setHeight = setHeight;
layerObject.prototype.setWidth = setWidth;

function layerObject(name,pos,nest,winref) {
	//properties
	this.name = name;
	this.position = pos;
	this.nest = nest;
	this.windowref = (winref)? winref:window;
	this.layerAddress = ((nest.length == 0)? "":"'" + nest.join("','") + "',") + "'" + this.name + "'";
	this.visibility = 'hidden';
	}
function showLayer() {
	with (eval(this.windowref)) {
		eval('L.layerProp('+this.layerAddress+')').visibility = "visible";
		if (ns5min) { eval('L.layerProp('+this.layerAddress+')').display = "block"; }
		}
	}
function hideLayer() {
	with (eval(this.windowref)) {
		eval('L.layerProp('+this.layerAddress+')').visibility = "hidden";
		if (ns5min) { eval('L.layerProp('+this.layerAddress+')').display = "none"; }
		}
	}
function getHeight() {
	var ret=0;
	with (eval(this.windowref)) {
		ret = (ns4)? eval('L.layerProp('+this.layerAddress+')').document.height:eval('L.layerRef('+this.layerAddress+')').offsetHeight;
		if (isNaN(ret)) {ret = eval('L.layerProp('+this.layerAddress+')').height;}
		return ret;
		}
	}
function getWidth() {
	var ret=0;
	with (eval(this.windowref)) {
		ret = (ns4)? eval('L.layerProp('+this.layerAddress+')').document.width:eval('L.layerRef('+this.layerAddress+')').offsetWidth;
		if (isNaN(ret)) {ret = eval('L.layerProp('+this.layerAddress+')').width;}
		return ret;
		}
	}

function setHeight(h) {
	//this.windowref.arguments=arguments;
	//with (eval(this.windowref)) {
		if (ns4) { eval('L.layerProp('+this.layerAddress+')').document.height=h; }
		else {eval('L.layerProp('+this.layerAddress+')').height=h;}
		return h;
	//	}
	}
function setWidth(w) {
	//this.windowref.arguments=arguments;
	//with (eval(this.windowref)) {
		if (ns4) { eval('L.layerProp('+this.layerAddress+')').document.width=w; }
		else { eval('L.layerProp('+this.layerAddress+')').width=w; }
		return w;
	//	}
	}

function drawLayer() {
	with (eval(this.windowref)) {
		eval('L.layerProp('+this.layerAddress+')').zIndex = (this.position).z;
		eval('L.layerProp('+this.layerAddress+')').left = (this.position).x;
		eval('L.layerProp('+this.layerAddress+')').top = (this.position).y;
		}
	}
function writeto(contenttowrite) {
if (safari) {this.windowref.arguments = arguments;}
if (safari) {this.windowref.contenttowrite = contenttowrite;}
	with (eval(this.windowref)) {
		if (ns4) {
			eval('L.layerProp('+this.layerAddress+')').document.write(contenttowrite);
			eval('L.layerProp('+this.layerAddress+')').document.close();
			}
		else  {
			eval('L.layerRef('+this.layerAddress+')').innerHTML = contenttowrite;
			if (ns5min) {this.hide();this.show();}
			}
		}
	}
function setPosition(pos) {
	this.position = pos;
	}
function Point(X,Y,Z) {
	this.x = X;
	this.y = Y;
	this.z = Z;
	}

// ##############  Get coordinates of any image #############
function getImageCoords(imgname) {
	var rx = 0;
	var ry = 0;
	if (top.domua||ie4) {
		var parentstring = 'document.images[imgname]';
		for (var i=0;i<4;i++) {
			rx+=parseInt(eval(parentstring).offsetLeft);
			ry+=parseInt(eval(parentstring).offsetTop);
			parentstring+='.offsetParent';
			}
		}
	if (top.ns) {
		rx = document.images[imgname].x;
		ry = document.images[imgname].y;
		}
	return new Array(rx,ry);
	}

// ##############  Cookie handling functions #############
function setCookie(name, value) { // set site-wide cookie
	if (arguments.length <= 2) { // set to expire in one hour
//		var expDate = new Date();
//		expDate.setHours(expDate.getHours() + 1);//the next hour might be a minute away - and what happens if you're setting it to hour 13 or 24 or 25?
// updated to millisecond calc on 12/4/2007
		var expDate = new Date(new Date().getTime() + (60 * 60 * 1000));//working in milliseconds
		var expire = expDate.toGMTString();
		}
	else { //expire date was passed as third arg - use it instead
		var expire = arguments[2].toGMTString();
		}
	document.cookie = name + "=" + value + "; expires=" + expire + "; path=/;";
}	

function getCookie(name) {
    var arg = name + '=';
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while(i < clen) {
        var j = i + alen;
        if(document.cookie.substring(i, j) == arg)
			{
            return getCookieAt(j);
			}
        i = document.cookie.indexOf(' ', i);
        if(i == -1)
			{
            break;
			}
        i += 1;
    }
    return null;
}

function getCookieAt(offset) {
	if (document.cookie.charAt(offset) == ""){
		return null;
		}
    var endstr = document.cookie.indexOf(';', offset);
    if(endstr == -1){
        endstr = document.cookie.length;
		}
	return document.cookie.substring(offset, endstr);
}

function deleteCookie(name) {
    var exp = new Date();
	exp.setHours(exp.getHours() - 1);
    document.cookie = name + "=null; expires=" + exp.toGMTString() + "; path=/;";
	}

// debug
function printdetails(object) {	var str = ''; for (prop in object) { str += prop + ":" + object[prop] +"<br>\n"; } var wi = window.open('about:blank','zone','scrollbars=yes'); wi.document.write(str); wi.document.close();}

