/**
 * by David Milner, September 2005
 * Copyright (c) 2005 by Spectrum Chromatography
 *
 * Spectrum grants you a royalty free license to use or modify this
 * software provided that this copyright notice appears on all copies.
 * This software is provided "AS IS," without a warranty of any kind.
 */

// starthere

setInterval ("MenuPosUpdate();", 125);

// menu.js
// all the stuff for lplc.com
// we use 1 nifty extra div for all the pop arounds

function ObjInfo (obj, objname) {
	var ret = '';
	for (i in obj) {
		ret += objname+'.'+i+' = '+obj[i]+'\n';
	}
	return ret;
}

function DebugMsg (msg) {
	var dv = document.getElementById('DebugDiv');
	if (dv) dv.innerHTML += msg + '<br />\n';
}

function DebugMsgHtml (msg) {
	msg = msg.replace (/&/g, '&amp;');
	msg = msg.replace (/</g, '&gt;');
	msg = msg.replace (/>/g, '&lt;');
	msg = msg.replace (/\n/g, '<br />\n');
	DebugMsg (msg);
}

function Val (msg) {
	msg = Number(msg.replace(/^(-{0,1}[0-9]*)[^0-9]+.*/, "$1"));
	return msg;
}

function HostGood () {
	return (window.location.host.search (/((lplc\.com)|(localhost)|(secure.spectrapor.com))/) >=0 );
}

function FileLoc () {
	var p = window.location.protocol + '//' + window.location.host;
	if (p.search (/s:/) >= 0) {
		if (p.search (/\./) >= 0) p += '/' + ssl;
		else p += '/' + ssll;
	}
	return p;
}

function ImgLoc () {
	var p = window.location.protocol + '//' + window.location.host;
	if (p.search (/(([^.]*\.lplc\.com)|(localhost)|(secure.spectrapor.com))/) < 0)
		p = 'http://www.lplc.com';

	if (p.search (/s:/) >= 0) {
		if (p.search (/\./) >= 0) p += '/' + ssl;
		else p += '/' + ssll;
	}
	return p;
}

function SBTV (button) {
	if (button.style) {
		button.style.backgroundColor = "powderblue";
		button.style.color = "black";
	}
}
function SBTU (button) {
	if (button.style) {
		button.style.backgroundColor = "slateblue";
		button.style.color = "white";
	}
}

function YesImGood () {
	return ((navigator.userAgent.search(/MSIE [456]\..*Mac/)) < 0);
}

var Debug=true;

var FocusColor = 'beige';
var BlurColor  = 'khaki';
var cococo = '#C0C0C0';
var img_cococo = '/img/C0C0C0';
var Hidden = 'hidden';
var Undefined = 'undefined';
var Columns = '/columns/';
var Instruments = '/instruments/';
var Syringes = '/syringes/';
var Inherit = 'inherit';
var ssl = 'lplc.com';
var ssll = 'lplc.com';
var nonsec = 'http://'+((window.location.host.search(/\./) >= 0)?'www.lplc.com': 'localhost');
var ErrorImg = new Image();

function ReportError (e, name) {
	ErrorImg.src = ImgLoc() + '/eimg/error.php?'+escape(ObjInfo(e, 'e')+name+'\n');
}

var MenuImageNames = new Array (img_cococo+'tl.gif',
				img_cococo+'tr.gif',
				img_cococo+'bl.gif',
				img_cococo+'br.gif',
				'/img/xin.gif',
				'/img/x.gif',
				'/img/bwtl.gif',
				'/img/bwtr.gif',
				'/img/bwbl.gif',
				'/img/bwbr.gif',
				'/img/bbtl.gif',
				'/img/bbtr.gif',
				'/img/bbbl.gif',
				'/img/bbbr.gif');
var MenuImages;
try {
	MenuImages = new Array (MenuImageNames.length);
	var start = ImgLoc ();
	for (var ix=0; ix<MenuImageNames.length; ix++) {
		MenuImages[ix] = new Image();
		MenuImages[ix].src = start + MenuImageNames[ix];
	}
} catch(e) { ReportError (e, 'Menu Image Cache Error'); }

var OurDiv = new NewOurDiv();
var OurMenu = new NewOurMenu();
var HttpConnection = new NewHttpConnection();

function NewOurDiv () {
	this.Opening = false;
	this.OpeningDirection = 1;
	this.Content = 0;	// 0:Nothing, 1:Search, 2:LogIn, 3:sub menu, 4:trademark, 5:LogOff, 6:SmallWindow, 7: BigWindow
	this.WantHeight = 0;
	this.WantWidth = 0;
	this.NowWidth = 1;
	this.NowHeight = 1;
	this.IncWidth = 1;
	this.IncHeight = 1;
	this.ThisDiv = false;
	this.CloseTimer = 0;
	this.rsjf = '';
	this.NoCloseTimer = new Function ("if (this.CloseTimer != 0) clearTimeout(this.CloseTimer); CloseTimer = 0;");

	this.FocusAtOpen = false;
	this.FocusControl = 0;

	this.ChangeSize = new Function ("width", "height", "return NODChangeSize(this, width, height);");
	this.NormalChangeSize = new Function ("return NODChangeSize (this, this.ThisDiv.offsetWidth, this.ThisDiv.offsetHeight);");
	this.Start = new Function ("dir", "FocusControl", "return NODStart (this, dir, FocusControl);");
	this.Bigger = Bigger;
	this.MakeOnScreen = new Function ("return NODMakeOnScreen (this);");
	this.EndUsage = new Function ("NODEndUsage(this);");
	this.EndUsageFunction = false;
	this.Init = new Function ("return NODInit(this);");
}

function NODStart (item, dir, control) {
	item.NowWidth = 1;
	item.NowHeight = 1;
	item.OpeningDirection = dir;
	if (control) {
		item.FocusAtOpen = true;
		item.FocusControl = control;
	} else {
		item.FocusAtOpen = false;
		item.FocusControl = false;
	}
	item.NormalChangeSize();
}

function NODEndUsage (item) {
	if (item.EndUsageFunction) item.EndUsageFunction();
	item.EndUsageFunction = false;
	item.Content=0;
	if (item.ThisDiv) {
		item.ThisDiv.innerHTML='';
		if (item.ThisDiv.style) item.ThisDiv.style.visibility=Hidden;
	}
	item.NoCloseTimer ();
}

function NODInit (item) {
	if (!item.ThisDiv) {
		item.ThisDiv = document.getElementById('SearchDiv');
	}
	if (!item.rsjf.length && typeof('DavesRsjf') != Undefined) {
		item.rsjf = DavesRsjf.replace (/\?/, '');
	}
	return (item.ThisDiv && item.ThisDiv.style);
}

function NODChangeSize (item, width, height) {
	if (!item.Init()) { return false; }
	try {
		item.IncHeight = Math.floor ((height - item.NowHeight)/7);
		if (item.IncHeight == 0 && item.NowHeight != height) {
			item.IncHeight = (item.NowHeight < height)? 1: -1;
		}
		item.IncWidth  = Math.floor ((width - item.NowWidth)/7);
		if (item.IncWidth == 0 && item.NowWidth != width ) {
			item.IncWidth = (item.NowWidth < width )? 1: -1;
		}

		item.WantHeight = height;
		item.WantWidth  = width;

		if (item.OpeningDirection == 0) item.ThisDiv.style.clip = "rect (auto auto "+item.NowHeight+"px "+item.NowWidth+" px)";
		else item.ThisDiv.style.clip = "rect (auto "+(item.WantWidth - item.NowWidth) + "px "+ item.NowHeight + "px auto)";
		if (!item.MakeOnScreen()) return false;
		if (!item.Opening) {
			item.Opening = true;
			setTimeout ("Bigger();", 75);
		}

		return true;
	} catch(e) {
		if (Debug) alert ('ChangeSize Error\n'+ObjInfo(e));
		ReportError (e, 'ChangeSize Error');
		return false;
	}
}

function NODMakeOnScreen (item) {
	if (!item.Init()) { return false; }

	var vheight, vwidth;
	var vtop, vleft;

	try {
		if (window.innerHeight) {
			vheight = window.innerHeight;
			vwidth  = window.innerWidth;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			vheight = document.documentElement.clientHeight;
			vwidth  = document.documentElement.clientWidth;
		} else if (document.body && document.body.clientHeight) {
			vheight = document.body.clientHeight;
			vwidth  = document.body.clientWidth;
		} else {
			vheight = document.height;
			vwidth  = document.width;
		}


		if (window.pageYOffset) {
			vtop  = window.pageYOffset;
			vleft = window.pageXOffset;
		} else if (document.body && (document.body.scrollTop || document.body.scrollLeft)) {
			vtop  = document.body.scrollTop;
			vleft = document.body.scrollLeft;
		} else if (document.documentElement && typeof(document.documentElement.scrollTop) == 'number') {
			vtop  = document.documentElement.scrollTop;
			vleft = document.documentElement.scrollLeft;
		} else {
			vtop  = 0;
			vleft = 0;
		}

		if (item.ThisDiv.offsetHeight + Val(item.ThisDiv.style.top) > vtop + vheight) {
			item.ThisDiv.style.top = (vtop + vheight - item.ThisDiv.offsetHeight) + 'px';
		}
		if (Val(item.ThisDiv.style.top) < vtop) {
			item.ThisDiv.style.top = (vtop) + 'px';
		}

		if (item.ThisDiv.offsetWidth + Val(item.ThisDiv.style.left) > vleft + vwidth) {
			item.ThisDiv.style.left = (vleft + vwidth - item.ThisDiv.offsetWidth) + 'px';
		}
		if (Val(item.ThisDiv.style.left) < vleft) {
			item.ThisDiv.style.left = (vleft) + 'px';
		}

		if (item.OpeningDirection == 0) item.ThisDiv.style.clip = "rect(auto auto "+OurDiv.NowHeight+"px "+OurDiv.NowWidth+"px)";
		else OurDiv.ThisDiv.style.clip = "rect(auto "+ OurDiv.NowWidth + "px " + OurDiv.NowHeight + "px auto)";
		item.ThisDiv.style.visibility = Inherit;

		return true;
	} catch(e) {
		if (Debug) alert ('MakeOnScreen Error\n'+ObjInfo(e));
		ReportError (e, 'MakeOnScreen Error');
		return false;
	}
}


function Bigger () {
	OurDiv.NowHeight += OurDiv.IncHeight;
	if (OurDiv.IncHeight > 0) {
		if (OurDiv.NowHeight > OurDiv.WantHeight) OurDiv.NowHeight = OurDiv.WantHeight;
	} else {
		if (OurDiv.NowHeight < OurDiv.WantHeight) OurDiv.NowHeight = OurDiv.WantHeight;
	}

	OurDiv.NowWidth += OurDiv.IncWidth;
	if (OurDiv.IncWidth > 0) {
		if (OurDiv.NowWidth > OurDiv.WantWidth) OurDiv.NowWidth = OurDiv.WantWidth;
	} else {
		if (OurDiv.NowWidth < OurDiv.WantWidth) OurDiv.NowWidth = OurDiv.WantWidth;
	}

	if (OurDiv.OpeningDirection == 0) OurDiv.ThisDiv.style.clip = "rect(auto auto "+OurDiv.NowHeight+"px "+(OurDiv.WantWidth - OurDiv.NowWidth)+"px)";
	else OurDiv.ThisDiv.style.clip = "rect(auto "+ OurDiv.NowWidth + "px " + OurDiv.NowHeight + "px auto)";

	if (OurDiv.NowHeight != OurDiv.WantHeight || OurDiv.NowWidth != OurDiv.WantWidth) {
		setTimeout ("Bigger();", 50);
	} else {
		OurDiv.Opening = false;
		OurDiv.ThisDiv.style.clip = "rect(auto auto auto auto)";
		if (OurDiv.FocusAtOpen && OurDiv.FocusControl && OurDiv.FocusControl.focus) {
			OurDiv.FocusControl.focus();
		}
		OurDiv.FocusAtOpen = false;
		OurDiv.FocusControl = 0;
	}
}

function Closing () {
	OurDiv.NoCloseTimer();
	if (OurDiv.Opening) return;
	OurDiv.IncHeight = Math.abs(OurDiv.IncHeight);
	OurDiv.NowHeight -= OurDiv.IncHeight;
	if (OurDiv.NowHeight <= 0) {
		OurDiv.NowHeight = 1;
		OurDiv.ThisDiv.style.visibility = Hidden;
		OurDiv.NowWidth = 1;
		OurDiv.innerHTML = '';
		OurDiv.EndUsage();
		return;
	}
	OurDiv.ThisDiv.style.clip = "rect(auto auto "+OurDiv.NowHeight+"px auto)";
	setTimeout ("Closing();", 75);
}


// end generic div handling


// Menu Handling
function NewOurMenu() {
	this.LastMenuCount = 0;
	this.LastSubItem = 0;
	this.Counter = 0;
	this.LastMenuDiv = false;
	this.SubMenuWidth = 0;

	this.Init = new Function ("return OurDiv.Init();");
	this.NoCloseTimer = new Function ("OurDiv.NoCloseTimer();");
	this.MenuUnHilite = new Function ("NOMMenuUnHilite(this);");
	this.MenuHilite = new Function ("which", "count", "NOMMenuHilite(this, which, count);");
	this.ForceMenuEnd = ForceMenuEnd;
}

function MenuOpsOver (which, count) {
	if (!OurMenu.Init()) return false;
	if (!which || !which.offsetParent) return false;

	OurMenu.NoCloseTimer();

	if (OurDiv.Content==3 && OurMenu.LastMenuCount == count) return true;

	try {
		OurMenu.LastSubItem = 0;
		OurMenu.Counter = 0;
		if (OurMenu.LastMenuCount && count != OurMenu.LastMenuCount) OurMenu.MenuUnHilite();
		OurDiv.EndUsage();
		OurMenu.MenuHilite (which, count);
		OurDiv.Content = 3;
		OurDiv.EndUsageFunction = OurMenu.ForceMenuEnd;

		var IReallyHaveAMenu = MenuData(count);
		OurDiv.ThisDiv.style.backgroundColor = '#CCA243';
		OurDiv.ThisDiv.style.padding = '0.4em';

		OurDiv.ThisDiv.style.width = 'auto';
		var AutoWidth = OurDiv.ThisDiv.offsetWidth;
		if (!YesImGood()) OurDiv.ThisDiv.style.width = (OurMenu.SubMenuWidth + 1.8)+'em';
		OurDiv.ThisDiv.style.zIndex = 80;

		var MainMenu = document.getElementById ('MenuMain');
		OurDiv.ThisDiv.style.top  = Val(MainMenu.style.top) + Number(which.offsetTop) + 12;
		OurDiv.ThisDiv.style.left = Val(MainMenu.offsetParent.style.left) + Number(which.offsetParent.offsetWidth);

		if (IReallyHaveAMenu) OurDiv.Start (1, false);

		return true;
	} catch (e) {
		if (Debug) alert ('MenuOpsOver Error\n'+ObjInfo(e));
		ReportError (e, 'MenuOpsOver Error');
		return false;
	}
}

function MenuOpsOut (which, count) {
	if (OurMenu.LastSubItem == 0) {
		OurDiv.NoCloseTimer();
		if (!OurDiv.Opening) {
			OurDiv.IncHeight = OurDiv.NowHeight / 7;
			if (OurDiv.IncHeight < 1) OurDiv.IncHeight = 1;
		}
		OurDiv.CloseTimer = setTimeout ("Closing();", 3000);
	}
}

function NOMMenuUnHilite(item) {
	if (item.LastMenuCount && item.LastMenuDiv && item.LastMenuDiv.style) {
		item.LastMenuDiv.style.backgroundColor = '#E0E0E0';
	}
}

function NOMMenuHilite(item, which, count) {
	item.LastMenuDiv = which;
	item.LastMenuCount = count;
	if (which && which.style)
		which.style.backgroundColor = '#FFCE54';
}

function ForceMenuEnd () {
	OurMenu.MenuUnHilite();
}

function MenuData (which) {
	var rsjf = OurDiv.rsjf;
	if (rsjf.length) rsjf = '?' + rsjf;

	switch (which) {
		case 1: 	// Column
			OurMenu.SubMenuWidth = 6.1;
			OurDiv.ThisDiv.innerHTML =
				SubMenu ('Disposable',  nonsec+Columns+'disposable.html'+rsjf)  +
				SubMenu ('Aqueous',     nonsec+Columns+'aqueous.html'+rsjf)     +
				SubMenu ('Organic',     nonsec+Columns+'organic.html'+rsjf)     +
				SubMenu ('Plungers',    nonsec+Columns+'plungers.html'+rsjf)    +
				SubMenu ('Accessories', nonsec+Columns+'accessories.html'+rsjf) +
				SubMenu ('Parts',       nonsec+Columns+'parts.html'+rsjf)       +
				SubMenu ('Soft-Gel',    nonsec+Columns+'softgel.html'+rsjf)     +
				SubMenu ('Fittings',    nonsec+Columns+'fittings.html'+rsjf);
			return true;
			break;
		case 2:		// Instruments
			OurMenu.SubMenuWidth = 9.7;
			OurDiv.ThisDiv.innerHTML =
				SubMenu ('Fraction Collector',   nonsec+Instruments+'cf2.html'+rsjf) +
				SubMenu ('UV Detector',          nonsec+Instruments+'uv.html'+rsjf)       +
				SubMenu ('Chart Recorder',       nonsec+Instruments+'recorder.html'+rsjf) +
				SubMenu ('Solvent Recycler',     nonsec+Instruments+'recycler.html'+rsjf) +
				SubMenu ('Peristaltic Pumps',    nonsec+Instruments+'pumps.html'+rsjf)    +
				SubMenu ('Interval Sampler',     nonsec+Instruments+'is95.html'+rsjf);
			return true;
			break;
		case 3:		// Tubing
			OurMenu.SubMenuWidth = 6.7;
			OurDiv.ThisDiv.innerHTML =
				SubMenu ('For Pumps',     nonsec+'/tubing/pumptube.html'+rsjf) +
				SubMenu ('General Use',   nonsec+'/tubing/lab.html'+rsjf)      +
				SubMenu ('Tubing Cutter', nonsec+'/tubing/cutter.html'+rsjf);
			return true;
			break;
		case 4:		// Others
			OurMenu.SubMenuWidth = 6.7;
			OurDiv.ThisDiv.innerHTML =
				SubMenu ('Thin-Layer',   nonsec+'/others/tlc.html'+rsjf)     +
				SubMenu ('Ion Exchange', nonsec+'/others/ionexch.html'+rsjf) +
				SubMenu ('Woven Mesh',   nonsec+'/others/mesh.html'+rsjf) +
				SubMenu ('Syringes',     nonsec+Syringes+'gasliq.html'+rsjf);
			return true;
			break;
		case 5:		// Documents
			OurMenu.SubMenuWidth = 5.0;
			OurDiv.ThisDiv.innerHTML =
				SubMenu ('Catalogs', nonsec+'/catalogs/index.html'+rsjf) +
				SubMenu ('Manuals',  nonsec+'/dirrs/index.html'+rsjf);
			return true;
			break;
		case 6:		// Information
			OurMenu.SubMenuWidth = 6.0;
			OurDiv.ThisDiv.innerHTML =
				SubMenu ('Copyright',     nonsec+'/copyrite.html'+rsjf) +
				SubMenu ('International', nonsec+'/international.html'+rsjf) +
				SubMenu ('Search',        nonsec+'/postok/SearchThis.php'+rsjf) +
				SubMenu ('Policies',      nonsec+'/lshop/policies/index.html'+rsjf) +
				SubMenu ('Warranty',      nonsec+'/noix/warranty.html'+rsjf) +
				SubMenu ('Home',          nonsec+'/index.html'+rsjf);
			return true;
			break;
		case 7:		// Home
			OurMenu.SubMenuWidth = 6.0;
			OurDiv.ThisDiv.innerHTML =
				SubMenu ('Home',          nonsec+'/index.html'+rsjf) +
				SubMenu ('Policies',      nonsec+'/lshop/policies/index.html'+rsjf) +
				SubMenu ('Copyright',     nonsec+'/copyrite.html'+rsjf) +
				SubMenu ('International', nonsec+'/international.html'+rsjf) +
				SubMenu ('Search',        nonsec+'/postok/SearchThis.php'+rsjf);
			return true;
			break;
		default:
			OurMenu.SubMenuWidth = 1;
			return false;
			break;
	}
	return false;
}

function SubMenu (name, to) {
	OurMenu.Counter ++;
	return	'<div OnClick="SubMenuClick(\''+to+'\');" class="submenuitem" style="width:'+OurMenu.SubMenuWidth+'em" OnMouseOver="SubMenuOver(this, '+OurMenu.Counter+');" OnMouseOut="SubMenuOut(this, '+OurMenu.Counter+');" >'+
		'<a href="'+to+'" class="MenuItem">'+name+'</a></div>\n';
}

function SubMenuOver (item, count) {
	OurDiv.NoCloseTimer();
	SubUnHilite (OurMenu.LastSubItem);
	OurMenu.LastSubDiv = item;
	OurMenu.LastSubItem = count;
	item.style.backgroundColor = '#FFCE54';
}

function SubMenuOut (item, count) {
	if (OurMenu.LastSubItem == count) {
		OurDiv.NoCloseTimer();
		if (!OurDiv.Opening) {
			OurDiv.IncHeight = OurDiv.NowHeight / 7;
			if (OurDiv.IncHeight < 1) OurDiv.IncHeight = 1;
		}
		OurDiv.CloseTimer = setTimeout ("Closing();", 3000);
	}
	SubUnHilite(item);
}

function SubUnHilite (item) {
	if (item && item.style)
		item.style.backgroundColor = '#E0E0E0';
}

function SubMenuClick (loc) {
	window.top.location = loc;
}


function MenuPosUpdate() {
	var MenuDiv;
	MenuDiv = document.getElementById('MenuMain');
	if (!MenuDiv) return;

	try {
		var vtop;
		if (window.pageYOffset) {
			vtop  = window.pageYOffset;
		} else if (document.body && (document.body.scrollTop || document.body.scrollLeft)) {
			vtop  = document.body.scrollTop;
		} else if (document.documentElement && typeof(document.documentElement.scrollTop) == 'number') {
			vtop  = document.documentElement.scrollTop;
		} else {
			vtop  = 0;
		}

		var dif;
		dif = vtop + 10 - MenuDiv.offsetTop;

		if (dif != 0) {
			var change;
			change = dif/2;
			if (change == 0) {
				change = 1;
				if (dif < 0) { change = -1; }
			}
			MenuDiv.style.top = (MenuDiv.offsetTop + change) +'px';
		}
	} catch (e) {
		if (Debug) alert ('MenuPosUpdate Error\n'+ObjInfo(e));
		ReportError (e, 'MenuPosUpdate Error');
	}
}

// end of Menu

// network link

function NewHttpConnection () {
	this.Connection = false;

	this.Init = new Function ("return NHCInit(this);");

	this.onreadystatechange = false;
	this.readyState = 0;
	this.status = 200;
	this.statusText = '';
	this.responseText = '';

	this.open = new Function ('op', 'loc', 'sync', 'this.Connection.open (op, loc, sync);');
	this.send = new Function ('what', 'this.Connection.send(what);');
	this.abort = new Function ('this.onreadystatechange = false; if (this.Connection.readyState != 0) { this.Connection.abort(); }');
	this.Xact = new Function ('loc', 'handler', 'NHCXact (this, loc, handler);');
}

function NHCInit (item) {
	if (!HostGood()) return false;
	if (NHCInit2(item) && item.Connection) {
		item.Connection.onreadystatechange = NHCReadyStateChange;
		item.onreadystatechange = false;
	}
	return true;
}

function NHCInit2 (item) {
	if (item.Connection) {
		item.Connection.abort();
		return true;
	}
	if (window.XMLHttpRequest) {
		item.Connection = new XMLHttpRequest();
		return true;
	}
	try {
		item.Connection = new ActiveXObject ("Msxml.2.XMLHTTP");
		return true;
	} catch (e) {
		try {
			item.Connection = new ActiveXObject ("Microsoft.XMLHTTP");
			return true;
		} catch(e) {
			ReportError (e, 'Cant get xmlhhtp handler');
		}
	}
	return false;
}

function NHCReadyStateChange () {
	if (HttpConnection.Connection) {
		HttpConnection.readyState = HttpConnection.Connection.readyState;
		if (HttpConnection.readyState == 4) try {
			HttpConnection.status = HttpConnection.Connection.status;
			HttpConnection.statusText = HttpConnection.Connection.statusText;
			HttpConnection.responseText = HttpConnection.Connection.responseText
			if (HttpConnection.onreadystatechange) {
				HttpConnection.onreadystatechange();
			}
		} catch (e) {
			if (Debug) alert ('RSC Error\n'+ObjInfo(e));
			ReportError (e, 'RSC Error');
		}
	}
}

function NHCXact (item, loc, handler) {
	item.onreadystatechange = handler;
	item.open ('GET', loc, true);
	item.send ('');
}

// end of network link

// start of registered trademark

function StartRtm (Link, evt, TM) {
	if (!OurMenu.Init()) return false;
	if (!HttpConnection.Init()) return false;

	try {
		OurDiv.EndUsage();

		OurDiv.Content = 4;
		OurDiv.EndUsageFunction = ForceRtmEnd;

		var FileBase = ImgLoc();
		OurDiv.ThisDiv.innerHTML =
			'<small><br /></small><table border="0" cellpadding="0" cellspacing="0">' +
			'<tr><td rowspan="2" colspan="2" height="20" width="20"><img src="'+FileBase+'/img/bwtl.gif" width="20" height="20" /></td><td height="1" class="rtmblue"></td><td colspan="2" rowspan="2" height="20" width="20"><img src="'+FileBase+'/img/bwtr.gif" width="20" height="20" /></td></tr>' +
			'<tr><td class="rtm" height="19"> <a href="javascript:OurDiv.EndUsage();">'+
			'<img src="'+FileBase+'/img/x.gif" width="23" height="19" align="right" border="0" /></a></td></tr>' +
			'<tr><td width="1" class="rtmblue"></td><td class="rtm" width="19"><br /></td><td class="rtm"><span id="RtmInfo"><span class="bigstrongred">Looking up '+TM+'</span></span></td><td class="rtm" width="19"><br /></td><td width="1" class="rtmblue"></td></tr>' +
			'<tr><td colspan="2" rowspan="2"><img src="'+FileBase+'/img/bwbl.gif" width="20" height="20" /></td><td height="19" class="rtm"><br /></td><td colspan="2" rowspan="2"><img src="'+FileBase+'/img/bwbr.gif" width="20" height="20" /></td></tr>' +
			'<tr><td class="rtmblue"> </td></tr>' +
			'</table>';

		OurDiv.ThisDiv.style.backgroundColor='transparent';
		OurDiv.ThisDiv.style.fontSize = '10pt';
		OurDiv.ThisDiv.style.padding = '0px';
		OurDiv.ThisDiv.style.clip = "rect(auto auto auto auto)";
		OurDiv.ThisDiv.style.zIndex = 95;

		var offsx = 0;
		var offsy = 0;
		var offer = Link;
		do {
			offer = offer.offsetParent;
			if (evt.offsetX || (offer.nodeName != 'TD')) {
				offsx += offer.offsetLeft;
				offsy += offer.offsetTop;
			}
		} while (offer.offsetParent && (!offer.id || (offer.id != 'bod')));

		if (typeof(evt.offsetX) != Undefined) {
			offsx += evt.offsetX;
			offsy += evt.offsetY;
		} else if (typeof(evt.layerX) != Undefined) {
			offsx += evt.layerX;
			offsy = evt.layerY;
		}

		if (typeof(evt.pageX) != Undefined) {
			offsx = evt.pageX;
			offsy = evt.pageY;
		}
		OurDiv.ThisDiv.style.left = offsx;
		OurDiv.ThisDiv.style.top = offsy;

		OurDiv.Start (1, false);
	} catch (e) {
		if (Debug) alert ('StartRtm Error\n'+ObjInfo(e));
		ReportError (e, 'StartRtm Error');
		return false;
	}

	try {
		HttpConnection.Xact (FileLoc()+'/tms.html?little=1;tm='+TM+';Ajax=1;', RtmHttpResponce);
	} catch (e) {
		if (Debug) alert ('StartRtm 2 Error\n'+ObjInfo(e));
		ReportError (e, 'StartRtm 2 Error');
		OurDiv.EndUsage();
		return false;
	}

	return true;
}

function ForceRtmEnd () {
	HttpConnection.abort();
}

function RtmHttpResponce () {
	if (HttpConnection.readyState != 4) return;

	var contnt = document.getElementById ('RtmInfo');
	if (HttpConnection.status == 200) {
		contnt.innerHTML = HttpConnection.responseText + '<br /><small><br />&nbsp;</small>' +
				   '<a href="javascript:OurDiv.EndUsage();" id="RtmCloseTag">Click here to close</a>';
		OurDiv.ThisDiv.style.width="15em";
		OurDiv.ThisDiv.style.zIndex = 90;
		OurDiv.NormalChangeSize ();
		OurDiv.ThisDiv.style.zIndex = 99;
		return;
	}
	contnt.innerHTML = 'Our web request returned ' + HttpConnection.status + ': ' + HttpConnection.statusText;
}


// done with trademarks.

// now search
var S_SearchInput;
var S_HaveLive;
var S_InProcess;
function StartSearch (evt) {
	if (!OurMenu.Init()) return false;
	S_HaveLive = false;
	if (HttpConnection.Init()) S_HaveLive = true;

	try {
		S_InProcess = false;
		OurDiv.EndUsage();
		OurDiv.Content = 1;
		OurDiv.EndUsageFunction = ForceSearchEnd;

		var FileBase = ImgLoc();
		OurDiv.ThisDiv.innerHTML =
			'<form name="SearchBox" method="post" OnSubmit="return DoSearch(this);" action="'+nonsec+'/postok/SearchThis.php?'+OurDiv.rsjf+'">' +
			'<table border="0" cellpadding="0" cellspacing="0">' +
			'<tr><td rowspan="2" colspan="2" height="20" width="20"><img src="'+FileBase+'/img/bwtl.gif" width="20" height="20" /></td><td height="1" class="rtmblue"></td><td colspan="2" rowspan="2" height="20" width="20"><img src="'+FileBase+'/img/bwtr.gif" width="20" height="20" /></td></tr>' +
			'<tr><td class="rtm" height="19"> <a href="javascript:OurDiv.EndUsage();"><img src="'+FileBase+'/img/x.gif" width="23" height="19" align="right" border="0" onmousedown="this.src=\''+FileBase+'/img/xin.gif\';" onmouseout="this.src=\''+FileBase+'/img/x.gif\';" onmouseup="this.src=\''+FileBase+'/img/x.gif\';" /></a></td></tr>' +
			'<tr><td width="1" class="rtmblue"></td><td class="rtm" width="19"><br /></td><td class="rtm"><span id="RtmInfo">Find: '+
			'<input type="text" id="SearchTextBox" name="searchtext" size="20" maxlength="50" onFocus="SearchFocus();" onBlur="SearchBlur();" onKeyPress="SearchChange(this);" /> <input type="submit" name="Find" value="go" class=\"spp\" onMouseOver=\"SBTV(this);\" onMouseOut=\"SBTU(this);\" />' +
			'</span></td><td class="rtm" width="19"><br /></td><td width="1" class="rtmblue"></td></tr>' +
			(S_HaveLive? '<tr><td width="1" class="rtmblue"></td><td class="rtm" width="19"><br /></td><td class="rtm" style="text-align:right"><span id="RtmInfo" style="font-size:7pt;">pages: '+
				     '<span id="SearchCount"> </span></span>' +
				     '</td><td class="rtm" width="19"><br /></td><td width="1" class="rtmblue"></td></tr>'
			: '') +
			'<tr><td colspan="2" rowspan="2"><img src="'+FileBase+'/img/bwbl.gif" width="20" height="20" /></td><td height="19" class="rtm"><br /></td><td colspan="2" rowspan="2"><img src="'+FileBase+'/img/bwbr.gif" width="20" height="20" /></td></tr>' +
			'<tr><td height="1" class="rtmblue"></td></tr>' +
			'</table>' +
			'</form>';
		OurDiv.ThisDiv.style.backgroundColor = 'transparent';
		OurDiv.ThisDiv.style.fontSize = '10pt';
		OurDiv.ThisDiv.style.padding = '0.5em';
		OurDiv.ThisDiv.style.width = 'auto';
		OurDiv.ThisDiv.style.zIndex = 80;

		var Icon = document.getElementById ('searchicon');
		var offsx = Icon.offsetLeft;
		var offsy = Icon.offsetTop;
		offsx += Icon.offsetParent.offsetLeft;
		offsy += Icon.offsetParent.offsetTop;
		offsx += Icon.offsetParent.offsetParent.offsetLeft;
		offsy += Icon.offsetParent.offsetParent.offsetTop;
		offsx += Icon.offsetParent.offsetParent.offsetParent.offsetLeft;
		offsy += Icon.offsetParent.offsetParent.offsetParent.offsetTop;
		offsy += Icon.offsetHeight + 2;
		offsx += Icon.offsetWidth - OurDiv.ThisDiv.offsetWidth;

		if (typeof(evt.offsetX) != Undefined) {
			offsx += evt.offsetX;
			offsy += evt.offsetY;
		} else if (typeof(evt.layerX) != Undefined) {
			offsx += evt.layerX;
			offsy = evt.layerY;
		}

		if (typeof(evt.pageX) != Undefined) {
			offsx = evt.pageX - OurDiv.ThisDiv.offsetWidth;
			offsy = evt.pageY;
		}
		OurDiv.ThisDiv.style.left = offsx;
		OurDiv.ThisDiv.style.top = offsy;

		S_SearchInput = document.getElementById ('SearchTextBox');
		S_SearchInput.style.backgroundColor = FocusColor;

		OurDiv.Start (0, S_SearchInput);
	} catch(e) {
		if (Debug) alert ('StartSearch Error\n'+ObjInfo(e));
		ReportError (e, 'StartSearch Error');
		return false;
	}

	return true;
}

function SearchFocus () {
	OurDiv.NoCloseTimer ();
	if (!S_SearchInput) S_SearchInput = document.getElementById ('SearchTextBox');
	if (S_SearchInput && S_SearchInput.style) S_SearchInput.style.backgroundColor = FocusColor;
}

function SearchBlur () {
	OurDiv.NoCloseTimer ();
	if (!S_SearchInput) S_SearchInput = document.getElementById ('SearchTextBox');
	if (S_SearchInput && S_SearchInput.style) S_SearchInput.style.backgroundColor = BlurColor;
	OurDiv.CloseTimer = setTimeout ("Closing();", 8000);
}

function DoSearch (OurForm) {
	SearchFocus ();
	OurForm.searchtext.value = OurForm.searchtext.value.replace (/^\s+/, '');
	if (OurForm.searchtext.value.length > 0) return true;
	alert ('Nothing to search for');
	return false;
}

function ForceSearchEnd () {
	HttpConnection.abort();
}

function SearchChange (fld) {
	if (S_InProcess) {
		HttpConnection.abort();
		HttpConnection = new NewHttpConnection();
		HttpConnection.Init();
	}
//	if (!S_HaveLive || !HttpConnection.Init()) return false;
	if (!S_HaveLive) return false;
	S_InProcess = true;
	HttpConnection.Xact (FileLoc()+'/postok/CountOnly.php?qry='+escape(fld.value)+';', SearchHttpResponce);
	return false;
}

function SearchHttpResponce () {
	if (HttpConnection.readyState != 4) return;

	var resp;
	S_InProcess = false;
	if (HttpConnection.status == 200) {
		RegExp.multiline = true;
		if (HttpConnection.responseText.match (/Count=([0-9]*);/i)) {
			var cnt = RegExp.$1;
			var plc = document.getElementById ('SearchCount');
			if (plc) { plc.innerHTML = cnt; }
		}
	}
}
// End of Search

// now log in:

function LoginDivs () {
	var LIO = document.getElementById ('LoginOn');
	LIO.innerHTML = '<span style="font-size:35px; color:red; font-weight:bold;">Logging in</span>';

	LIO = document.getElementById ('LoginError');
	LIO.innerHTML = '<form name="LoginError" action="javascript:void(0);" method="post" onsubmit="CloseLoginError(this); return false;">'+
			'<table border="0" cellpadding="0" cellspacing="0">'+
			'<tr><td rowspan="2" colspan="2" height="20" width="20"><img src="/img/bbtl.gif" width="20" height="20" /></td><td height="1" class="loginblue"></td><td colspan="2" rowspan="2" height="20" width="20"><img src="/img/bbtr.gif" width="20" height="20" /></td></tr>'+
			'<tr><td class="login" height="19"><br /></td></tr>'+
			'<tr><td width="1" rowspan="2" class="loginblue"></td><td class="login" rowspan="2" width="19"><br /></td><td class="login"><span id="LoginErrorMsg" style="color:red;"> </span></td><td class="login" rowspan="2" width="19"><br /></td><td width="1" rowspan="2" class="loginblue"></td></tr>'+
			'<tr><td class="login" align="center"> <input type="submit" id="TryAgainButton" value="Try Again" class="loginerror" /> </td></tr>'+
			'<tr><td colspan="2" rowspan="2"><img src="/img/bbbl.gif" width="20" height="20" /></td><td height="19" class="login"><br /></td><td colspan="2" rowspan="2"><img src="/img/bbbr.gif" width="20" height="20" /></td></tr>'+
			'<tr><td class="loginblue"> </td></tr>'+
			'</table></form>';
}

var L_LastFocus = 0;
function StartLogin (MyLink, evt, part) {
	if (!OurDiv.Init()) return false;
	if (!HttpConnection.Init()) return false;

	try {
	        LoginDivs();

		L_LastFocus = 0;

		OurDiv.EndUsage();
		OurDiv.Content = 2;
		OurDiv.EndUsageFunction = ForceLoginEnd;

		OurDiv.ThisDiv.innerHTML =
			'<form name="LoginBox" id="LoginBoxForm" method="post" onsubmit="return DoLogin(this);">' +
			'<small><br /></small><table border="0" cellpadding="0" cellspacing="0">' +
			'<tr><td><img src="'+nonsec+img_cococo+'tl.gif" width="20" height="20" /></td><td class="login"> </td><td class="login" align="right"><img src="'+nonsec+'/img/xin.gif" style="visibility:hidden" width="20" height="20" /><a href="javascript:void(0);" OnClick="OurDiv.EndUsage();" OnMouseOver="window.top.status=\'Close this window\'; return true;" OnMouseOut="window.top.status=\'\'; return true;"><img src="'+nonsec+'/img/x.gif" width="24" height="20" onmousedown="this.src=\''+nonsec+'/img/xin.gif\';" onmouseout="this.src=\''+nonsec+'/img/x.gif\';" onmouseup="this.src=\''+nonsec+'/img/x.gif\';" border="0" /></a></td><td><img src="'+nonsec+img_cococo+'tr.gif" width="20" height="20" /></td></tr>' +
			'<tr><td class="login" rowspan="3"><br /></td><td class="login"><b class="login">User Name:&nbsp; </b></td><td class="login"><input class="login" type="text" id="UserNameInput" name="LoginUserName" onfocus="LoginFocus(this);" onblur="LoginBlur(this);" /></td><td class="login" rowspan="3"><br /></td></tr>' +
			'<tr><td class="login"><b class="login">Password:&nbsp; </b></td><td class="login"><input  class="login" type="password" id="PasswordInput" name="LoginPassword" onfocus="LoginFocus(this);" onblur="LoginBlur(this);" /></td></tr>' +
			'<tr><td class="login"><br /></td><td class="login" align="center" rowspan="2"><input type="submit" name="GoLogin" value="Login" class="login" onfocus="LoginFocus(this);" onblue="LoginBlur(this);" /> &nbsp; <input type="button" value="Cancel" name="NoGoLogin" class="login" OnClick="OurDiv.EndUsage();" /></td></tr>' +
			'<tr><td><img src="'+nonsec+img_cococo+'bl.gif" width="20" height="20" /></td><td class="login"> </td><td><img src="'+nonsec+img_cococo+'br.gif" width="20" height="20" /></td></tr>' +
			'</table></form>';

		OurDiv.ThisDiv.style.backgroundColor='transparent';
		OurDiv.ThisDiv.style.fontSize = '10pt';
		OurDiv.ThisDiv.style.padding = '0px';
		OurDiv.ThisDiv.style.width = 'auto';
		OurDiv.ThisDiv.style.zIndex = 64;

		var offsx = MyLink.offsetParent.offsetLeft;
		var offsy = MyLink.offsetParent.offsetTop;
		if (typeof(evt.offsetX) != Undefined) {
			offsx += evt.offsetX;
			offsy += evt.offsetY;
		} else if (typeof(evt.layerX) != Undefined) {
			offsx += evt.layerX;
			offsy += evt.layerY;
		}
		if (typeof(evt.pageX) != Undefined) {
			offsx = evt.pageX;
			offsy = evt.pageY;
		} else if (typeof(evt.clientX) != Undefined) {
			offsx = evt.clientX;
			offsy = evt.clientY;
		}
		OurDiv.ThisDiv.style.left = offsx;
		OurDiv.ThisDiv.style.top  = offsy;

		OurDiv.Start (1, document.getElementById ('UserNameInput'));
	} catch (e) {
		if (Debug) alert ('StartLogin Error\n'+ObjInfo(e));
		ReportError (e, 'StartLogin Error');
		return false;
	}

	return true;
}

function ForceLoginEnd() {
	HttpConnection.abort();
	try { document.getElementById('LoginOn').style.visibility = Hidden;} catch(e){;}
	try { document.getElementById('LoginError').style.visibility = Hidden;} catch(e){;}
}

function LoginFocus(which) {
	OurDiv.NoCloseTimer();
	var ix;
	for (ix=0; ix<which.form.length; ix++) {
		try {
			if (which.form[ix].type == 'text' || which.form[ix].type == 'password')
				which.form[ix].style.backgroundColor = BlurColor;
		} catch(e){ ReportError (e, 'Login Focus BackgroundColor Error'); }
	}
	L_LastFocus = which.name;
	if (which.type == 'text' || which.type == 'password') {
		which.style.backgroundColor = FocusColor;
		return;
	}
}

function LoginBlur (which) {
	if (which.type == 'text' || which.type == 'password') {
		which.style.backgroundColor = BlurColor;
	}

	if (which.name == L_LastFocus) {
		OurDiv.CloseTimer = setTimeout ("Closing();", 5000);
	}
}

function DoLogin (OurForm) {
	if (!HttpConnection.Init()) return false;
	LoginFocus (OurForm.LoginUserName);
	OurForm.LoginUserName.value = OurForm.LoginUserName.value.replace(/^\s+/, '');
	if (OurForm.LoginUserName.value.length <= 0) {
		OurForm.LoginUserName.focus();
		return false;
	}

	var Cover = document.getElementById ('LoginOn');
	if (Cover && Cover.style) {
		var ldtop = Val (OurDiv.ThisDiv.style.top);
		Cover.style.top = (ldtop + ((OurDiv.ThisDiv.offsetHeight - Cover.offsetHeight) / 2 )) + 'px';
		var ldleft = Val (OurDiv.ThisDiv.style.left);
		Cover.style.left = (ldleft + ((OurDiv.ThisDiv.offsetWidth - Cover.offsetWidth) / 2)) + 'px';
		Cover.style.visibility = Inherit;
	}

	var info = '';
	for (var ix=0; ix<OurForm.elements.length; ix++) {
		info += escape(OurForm.elements[ix].name) + '=' + escape(OurForm.elements[ix].value) + ';';
		OurForm.elements[ix].disabled = true;
	}

	HttpConnection.Xact (FileLoc()+'/lshop/jlogin/index.html?'+info, LoginHttpResponce);

	return false;
}

function LoginHttpResponce () {
	if (HttpConnection.readyState != 4) return;

	var resp;
	if (HttpConnection.status == 200) {
		RegExp.multiline = true;
		if (HttpConnection.responseText.match (/<([a-z0-9]{14})>/)) {
			var Session = RegExp.$1
			newloc = window.location.search.replace (/((SESSION)|(LOGOUT)|(SCRTOP)|(SCRLFT)|(DLFT)|(DTOP)|(PART))=[^;]*;/ig, '');
			if (!newloc.length) newloc = '?';
			newloc += 'session='+Session+';';

			var WinTop, WinLeft;
			WinTop = 0;
			WinLeft = 0;
			if (window.pageYOffset) {
				WinTop  = window.top.pageYOffset;
				WinLeft = window.top.pageXOffset;
			} else if (document.body && (document.body.scrollTop || document.body.scrollLeft)) {
				WinTop  = document.body.scrollTop;
				WinLeft = document.body.scrollLeft;
			} else if (document.documentElement && typeof(document.documentElement.scrollTop) == 'number') {
				WinTop  = document.documentElement.scrollTop;
				WinLeft = document.documentElement.scrollLeft;
			}
			newloc += 'ScrTop='+WinTop+';';
			newloc += 'ScrLft='+WinLeft+';';

			if (HttpConnection.responseText.match (/\{([^{]+)\{/))
				newloc += 'Part='+escape(RegExp.$1)+';';
			if (HttpConnection.responseText.match (/_([^_]+)_/))
				newloc += 'DTop='+escape(RegExp.$1)+';';
			if (HttpConnection.responseText.match (/\|([^|]+)\|/))
				newloc += 'DLft='+escape(RegExp.$1)+';';
			var Cover = document.getElementById ('LoginOn');
			if (Cover && Cover.style)
				Cover.style.visibility = Hidden;
			window.location.search = newloc;
			return;
		}
		resp = HttpConnection.responseText;
	} else {
		resp = 'Our web request returned '+ HttpConnection.status + ': ' + HttpConnection.statusText;
	}

	var Frm = document.getElementById ('LoginBoxForm');
	if (Frm) {
		for (var ix=0; ix<Frm.elements.length; ix++) {
			Frm.elements[ix].disabled = false;
		}
	}

	resp = resp.replace (/&/g, '&amp;');
	resp = resp.replace (/>/g, '&gt;');
	resp = resp.replace (/</g, '&lt;');
	resp = resp.replace (/\n/g, '<br />\n');

	var LEM = document.getElementById ('LoginErrorMsg');
	if (LEM) {
		LEM.innerHTML = resp;
		var ldtop  = Val(OurDiv.ThisDiv.style.top);
		var ldleft = Val(OurDiv.ThisDiv.style.left);

		var LE = document.getElementById ('LoginError');
		if (LE && LE.style) {
			LE.style.top = (ldtop + ((OurDiv.ThisDiv.offsetHeight - LE.offsetHeight) / 2)) + 'px';
			ldleft = ldleft + ((OurDiv.ThisDiv.offsetWidth - LE.offsetWidth) / 2);
			if (ldleft < 5) ldleft = 5;
			LE.style.left = (ldleft) + 'px';
			LE.style.visibility = Inherit;
			LE.style.zIndex = 99;
			var button = document.getElementById ('TryAgainButton');
			if (button) button.focus();
		}
	}
}

function CloseLoginError () {
	var Cover = document.getElementById ('LoginOn');
	if (Cover && Cover.style) Cover.style.visibility = Hidden;
	var LE = document.getElementById ('LoginError');
	if (LE && LE.style) LE.style.visibility = Hidden;
	var Frm = document.getElementById ('LoginBoxForm');
	if (Frm) Frm.elements[0].focus();
}

// done with log in

// now log off

function StartLogoff (Link, evt) {
	if (!OurDiv.Init()) return false;

	if (OurDiv.Content == 5) return true;

	OurDiv.EndUsage ();
	OurDiv.Content = 5;

	var FileBase = ImgLoc();
	OurDiv.ThisDiv.innerHTML =
		'<small><br /></small><table border="0" cellpadding="0" cellspacing="0">' +
		'<tr><td rowspan="2" colspan="2" height="20" width="20"><img src="'+FileBase+'/img/bwtl.gif" width="20" height="20" /></td><td height="1" class="rtmblue"></td><td colspan="2" rowspan="2" height="20" width="20"><img src="'+FileBase+'/img/bwtr.gif" width="20" height="20" /></td></tr>' +
		'<tr><td class="rtm" height="19"> <a href="javascript:OurDiv.EndUsage();"><img src="'+FileBase+'/img/x.gif" width="23" height="19" align="right" border="0" /></a></td></tr>' +
		'<tr><td width="1" class="rtmblue"></td><td class="rtm"" width="19"><br /></td><td class="rtm"><span id="RtmInfo">'+
		'<input type="button" name="Dome" value="Yes,&nbsp;Log Out" OnClick="DoLogoff();" class=\"spp\" OnMouseOver=\"SBTV(this);\" OnMouseOut=\"SBTU(this);\" />'+
		'<br />'+
		'<input type="button" name="Dome" value="No,&nbsp;Stay logged in" onClick="OurDiv.EndUsage();" class=\"spp\" OnMouseOver=\"SBTV(this);\" OnMouseOut=\"SBTU(this);\" />'+
		'</span></td><td class="rtm" width="19"><br /></td><td width="1" class="rtmblue"></td></tr>' +
		'<tr><td colspan="2" rowspan="2"><img src="'+FileBase+'/img/bwbl.gif" width="20" height="20" /></td><td height="19" class="rtm"><br /></td><td colspan="2" rowspan="2"><img src="'+FileBase+'/img/bwbr.gif" width="20" height="20" /></td></tr>' +
		'<tr><td class="rtmblue"> </td></tr>' +
		'</table>';

	OurDiv.ThisDiv.style.backgroundColor='transparent';
	OurDiv.ThisDiv.style.fontSize = '10pt';
	OurDiv.ThisDiv.style.padding = '0px';
	OurDiv.ThisDiv.style.clip = "rect(auto auto auto auto)";
	OurDiv.ThisDiv.style.zIndex = 80;

	var offsx = 0;
	var offsy = 0;
	if (typeof(evt.pageX) != Undefined) {
		offsx = evt.pageX;
		offsy = evt.pageY;
	} else {
		var offer = Link;
		do {
			offer = offer.offsetParent;
			if (evt.offsetX || (offer.nodeName != 'TD')) {
				offsx += offer.offsetLeft;
				offsy += offer.offsetTop;
			}
		} while (offer.offsetParent && (!offer.id || (offer.id != 'bod')));

		if (typeof(evt.offsetX) != Undefined) {
			offsx += evt.offsetX;
			offsy += evt.offsetY;
		} else if (typeof(evt.layerX) != Undefined) {
			offsx += evt.layerX;
			offsy += evt.layerY;
		}
	}

	OurDiv.ThisDiv.style.left = offsx;
	OurDiv.ThisDiv.style.top = offsy;

	OurDiv.Start (1, false);

	return false;
}

function DoLogoff () {
	var newloc = window.location.search.replace (/((SESSION)|(DTOP)|(DLFT)|(LOGOUT)|(ScrTop)|(SCRLFT))=[^;]*;/gi, '');
	if (newloc.search (/\?/) < 0) newloc += '?';
	newloc += 'logout=1;';
	window.location.search = newloc;
}

// end of logoff

// start of opensmall
function ropensmall (loc, name, evt) {
	var top, left;
	top = 0;
	left = 0;

	if (typeof(evt.pageX) != Undefined) {
		left = evt.pageX;
		top  = evt.pageY;
	} else if (typeof(evt.x) != Undefined) {
		left = evt.x;
		top  = evt.y;
	}

	return ropensmall2 (loc, top, left);

}

function ropensmall2 (loc, top, left) {
	if (!OurDiv.Init()) return false;
	if (!HttpConnection.Init()) return false;

	LoginDivs();

	OurDiv.EndUsage ();
	OurDiv.Content = 6;
	OurDiv.EndUsageFunction = ForceLoginEnd;

	OurDiv.ThisDiv.style.backgroundColor='transparent';
	OurDiv.ThisDiv.style.fontSize = '10pt';
	OurDiv.ThisDiv.style.padding = '0px';
	OurDiv.ThisDiv.style.clip = "rect(auto auto auto auto)";
	OurDiv.ThisDiv.style.zIndex = 80;
	OurDiv.ThisDiv.style.width = 'auto';

	var Part;
	Part = loc.replace (/^.*Part=([^;]+);.*$/i, '$1');

	OurDiv.ThisDiv.innerHTML =
		"<div style=\"border:thick outset slateblue; background-color:white; padding:0px;\" id=\"SmallDiv\">" +
		'<div style="width:12em"><a href="javascript:OurDiv.EndUsage();"><img src="/img/x.gif" border="0" align="right"></a><br clear="all">\n' +
		'<span class="subtitle">Looking up ' + Part + '</span><br clear="all" />\n' +
		'<a href="javascript:OurDiv.EndUsage();" id="RtmCloseTag">Click here to close</a>'+
		"</div></div>";

	OurDiv.ThisDiv.style.clip = "rect(auto auto auto auto)";
	OurDiv.ThisDiv.style.left = left;
	OurDiv.ThisDiv.style.top = top;

	OurDiv.Start (1, false);
	HttpConnection.Xact (loc+';Ajax=1;', SmallLocHttpResponce);

	return true;
}

function SmallLocHttpResponce () {
	if (HttpConnection.readyState != 4) return;

	MyDiv = document.getElementById ('SmallDiv');
	if (!MyDiv) { return; }
	if (HttpConnection.status == 200) {
		MyDiv.innerHTML = '<div style="width:22em"><a href="javascript:OurDiv.EndUsage();"><img src="/img/x.gif" border="0" align="right"></a><br clear="all"></div>'+
				  HttpConnection.responseText + '<br clear="all" />' +
				  '<a href="javascript:OurDiv.EndUsage();" id="RtmCloseTag">Click here to close</a>';
	} else {
		MyDiv.innerHTML = '<div style="width:22em"><a href="javascript:OurDiv.EndUsage();"><img src="/img/x.gif" border="0" align="right"></a><br clear="all"></div>'+
				  'Our web request returned ' + HttpConnection.status + ': ' + HttpConnection.statusText + '<br clear="all" />' +
				  '<a href="javascript:OurDiv.EndUsage();" id="RtmCloseTag">Click here to close</a>';
	}

	var Ctl = document.getElementById ('SLLIname');
	if (!Ctl) Ctl = document.getElementById ('SmDefault');
	if (Ctl) {
		OurDiv.FocusControl = Ctl;
		OurDiv.FocusAtOpen = true;
	}
	OurDiv.NormalChangeSize();

	return;
}

function MoveUp (WinTop, WinLeft, DTop, DLft) {
	window.scrollTo (WinLeft, WinTop);
}

function SmallWin (DTop, DLft, Part) {
	if (!OurDiv.Init()) return false;
	ropensmall2 (FileLoc()+'/lshop/addsmall/index.html?'+OurDiv.rsjf+'Part='+escape(Part)+';', DTop, DLft);
}

// end of open small

// small login with part

function SLLogIn (Part) {
	if (!OurDiv.Init()) return false;
	if (!HttpConnection.Init()) return false;

	var LogInName = document.getElementById ('SLLIname');
	if (!LogInName) return false;
	LogInName.value = LogInName.value.replace (/^\s*(\S{0,1}.*\S{0,1})\s*$/, '$1');
	if (LogInName.value.length == 0) {
		alert ('You need to enter your user name to log in.');
		LogInName.focus();
		return true;
	}
	var Password;
	Password = document.getElementById ('SLLIpass');
	if (!Password) return false;
	Password.value = Password.value.replace (/^\s*(\S{0,1}.*\S{0,1})\s*$/, '$1');
	if (Password.value.length == 0) {
		alert ('You need to enter your password to log in.');
		Password.focus();
		return true;
	}

	LogInName = escape(LogInName.value);
	Password = escape(Password.value);

	var LIC = document.getElementById ('LoginOn');
	if (LIC) {
		var ldtop = Val (OurDiv.ThisDiv.style.top);
		LIC.style.top = (ldtop + ((OurDiv.ThisDiv.offsetHeight - LIC.offsetHeight) / 4)) + 'px';
		var ldleft = Val (OurDiv.ThisDiv.style.left);
		LIC.style.left = (ldleft + ((OurDiv.ThisDiv.offsetWidth - LIC.offsetWidth) / 2)) + 'px';
		LIC.style.visibility = Inherit;
	}

	var Xtra = '';
	if (Part.length) {
		Xtra = 'Part='+escape(Part)+';';
		Xtra += 'DTop='+Val(OurDiv.ThisDiv.style.top)+';';
		Xtra += 'DLft='+Val(OurDiv.ThisDiv.style.left)+';';
	}

	HttpConnection.Xact (nonsec+'/lshop/jlogin/index.html?'+'LoginUserName='+LogInName+';LoginPassword='+Password+';Login=Login;GoLogin=Login;'+Xtra, LoginHttpResponce);

	return true;
}

// end of small login with part

// small add/remove/update part

function SLPartPart (orig) {
	var PartPart;
	PartPart = '';

	var PartInput;
	PartInput = document.getElementById ('SmallAdPart');
	if (PartInput) {
		PartPart = 'Part='+PartInput.value+';';
		var PartQty;
		PartQty = document.getElementById ('SmallAdQty');
		if (PartQty) {
			PartQty.value = PartQty.value.replace (/^\s+/, '');
			PartQty.value = PartQty.value.replace (/\s+$/, '');
			var Qty = Val(PartQty.value);
			if (Qty < 0) {
				PartQty.value = '0';
				Qty = 0;
			}
			PartPart += 'Qty='+Qty+';';
		}
	}

	orig = orig.replace (/((PART)|(QTY))=[^;]*;/, '');
	if (!orig.length) orig = '?'
	orig += PartPart
	return orig;
}

function SLAR (loc, op) {
	var MyDiv = document.getElementById ('SmallDiv');
	if (!OurDiv.Init() || !HttpConnection.Init()) {
		if (MyDiv) {
			MyDiv.innerHTML = '<div style="width:22em"><a href="javascript:OurDiv.EndUsage();"><img src="/img/x.gif" border="0" align="right"></a><br clear="all"></div>'+
				          '<div id="AllSmall" class="allsmall"><span class="smh">' +
					  'Sorry, we encountered a problem and were unable to update youre cart<br clear="all" />' +
					  '</span><a href="javascript:OurDiv.EndUsage();" id="RtmCloseTag">Click here to close</a></div>';
		}
		return false;
	}

	HttpConnection.Xact (loc+'action='+op+';'+SLPartPart(window.location.search), SmallLocHttpResponce);

	if (MyDiv) {
		MyDiv.innerHTML = '<div id="AllSmall" class="allsmall"><span class="smh">Updating cart</span></div>';
	}

	OurDiv.NoCloseTimer ();
	OurDiv.CloseTimer = setTimeout ("Closing();", 4500);
	return true;
}


function SLAddUpdate (loc) {
	return SLAR(loc, 'Update');
}

function SLAddRemove (loc) {
	return SLAR(loc, 'Remove');
}

function SLAddCheckout (loc) {
	window.top.location.href = loc+'action=CheckOut;'+SLPartPart(window.location.search);
}

function SLAddViewcart (loc) {
	window.top.location.href = loc+'action=ViewCart;'+SLPartPart(window.location.search);
}

// end of small windows

// big policy window

function ropenbig (loc) {
	if (!OurDiv.Init()) return false;

	OurDiv.EndUsage ();
	OurDiv.Content = 7;

	OurDiv.ThisDiv.style.backgroundColor='transparent';
	OurDiv.ThisDiv.style.fontSize = '10pt';
	OurDiv.ThisDiv.style.padding = '0px';
	OurDiv.ThisDiv.style.clip = "rect(auto auto auto auto)";
	OurDiv.ThisDiv.style.zIndex = 80;
	OurDiv.ThisDiv.style.width = 'auto';

	OurDiv.ThisDiv.innerHTML =
		"<div style=\"border:thick outset slateblue; background-color:white; padding:0px;\" id=\"SmallDiv\">" +
		'<div style="float:right"><a href="javascript:OurDiv.EndUsage();"><img src="/img/x.gif" border="0" align="right"></a></div><br clear="all">\n' +
		'<iframe src="' + loc + ';Ajax=1;" frameborder="0" id="BigDiv"><br /></iframe>' +
		'<a href="javascript:OurDiv.EndUsage();" id="RtmCloseTag">Click here to close</a>'+
		"</div>";

	OurDiv.ThisDiv.style.clip = "rect(auto auto auto auto)";
	OurDiv.ThisDiv.style.zIndex = 99;
//	OurDiv.ThisDiv.style.left = window.top.style.left;
//	OurDiv.ThisDiv.style.top = window.top.style.top;

	return true;
}

