//<script>
//<!-- Copyright 1999-2003 Alexa Internet, Inc.  All Rights Reserved.
var g_imgPath="IMAGE/";var g_imgExt=".gif";var g_imgPfx="button_";

function Element(sName, sTopMargin, bBtn, state0Width, state1Width, state2Width, sStateMode) {
	var o=new AlxObj();
	o.oType="Element";
	o.name=sName;
	o.oTop=window.g_oTop;
	o.state0width = state0Width;
	o.state1width = state1Width;
	o.state2width = state2Width;
	o.sStateMode = sStateMode;
	o.bInserted = false;
	o.cp=new Array();
	o.tt=Element_tt;
	o.redirect="http://redirect.alexa.com/redirect?";
	if (!window.document.all[o.name]) {
		o.m_tgt=window.document.createElement('TD'); o.m_tgt.id=o.name; o.m_tgt.style.height="21px"; o.m_tgt.className="tbLink"; o.m_tgt.vAlign="top"; o.m_tgt.marginTop=sTopMargin;
		if ((sName.indexOf("chrome") < 0) && (!bBtn)) { o.btn=new Button(o); }
	}
	if (window.g_oCookie.readPersist(REG_AMZNID) != "") {
		o.assoc_id = window.g_oCookie.readPersist(REG_AMZNID);
	} else {
		o.assoc_id = "alexa65-tb-20";
	}
	o.insert=Element_insert; 
	o.insertCopy=Element_insertCopy;
	o.reinsert=Element_reinsert;
	o.remove=Element_remove;
	o.onclick=Element_onclick; o.onmouseover=Element_onmouseover; o.onmouseout=Element_onmouseout;
	o.activate=Element_activate; o.deactivate=Element_deactivate; o.onSecureDocument=Element_onSecureDocument;
	o.tween = Element_tween;
	o._destroy = o.destroy;
	o.destroy = Element_destroy;
	o.create();
	return o;
	function Element_insert() { 
		// init button
		var rVal = false; 
		if (this.btn) {
			var oImgSet = this.btn.labelSet.get(0);
			this.m_tgt.style.width = oImgSet.width;
		}
		if((this.oTop) && (!this.bInserted)) { 
			this.oTop.appendChild(this.m_tgt); 
			rVal = true; 
		} 
		this.bIsVisible = true;
		return rVal; 
	}
	function Element_reinsert() {
	
	}
	function Element_insertCopy() {
		var rVal = false;
		if ((this.cp) && (this.m_tgt) && (this.oTop)) {
			var newRecord=this.cp.length;
			this.cp[newRecord]=this.m_tgt.cloneNode(true);
			this.oTop.appendChild(this.cp[newRecord]);
			rVal = this.cp[newRecord];
		}
		return rVal;
	}
	function Element_remove() { var rVal = false; this.oTop.removeChild(this.m_tgt); rVal = true; return rVal; }
	function Element_onclick() { var rVal = false; rVal = true; return rVal; }
	function Element_activate() { var rVal = false;  this.m_tgt.style.display=''; rVal = true; return rVal; }
	function Element_deactivate() { var rVal = false; this.m_tgt.style.display='none'; rVal=true; return rVal; }
	function Element_tween(oElement) { 
		var rVal = false; 
		this.tweenID = oElement.oID; 
		et.register(EVT_MOUSEOVER,this); 
		et.register(EVT_MOUSEOUT,this); 
		return rVal; 
	}
	function Element_onmouseover(aArgs) { var rVal = false; if (aArgs[0].oID == this.tweenID) { this.m_tgt.replaceChild(this.btn.labelSet.get(1).image,this.m_tgt.all.tags("IMG")[0]); rVal = true; } return rVal; }
	function Element_onmouseout(aArgs) { var rVal = false; if (aArgs[0].oID == this.tweenID) { this.m_tgt.replaceChild(this.btn.labelSet.get(0).image,this.m_tgt.all.tags("IMG")[0]); rVal = true; } return rVal; }
	function Element_tt(sMsg) { var rVal = false; if (this.m_tgt) { this.m_tgt.title = sMsg; rVal = true; } return rVal; }
	function Element_destroy() { this.bInserted = false; this._destroy(); }
}

function ArrowElement(sName, sTopMargin, bBtn, state0Width, state1Width, state2Width, nArrowCount, sStateMode) {
	var o = new Element(sName, sTopMargin, true, state0Width, state1Width, state2Width, sStateMode);
	o.oType="ArrowElement";
	o.arrowCount = nArrowCount;
	o.btn = new ArrowButton(o); 
	o.create();
	return o;
}
function DadElement(sName, sTopMargin, bBtn, state0Width, state1Width, state2Width, sStateMode) {
	var o=new Element(sName, sTopMargin, bBtn, state0Width, state1Width, state2Width, sStateMode);
	o.oType="DadElement";
	if (window.document.all['xsl_'+o.name]) { o.XSLDOM=window.document.all['xsl_'+o.name]; }
	o.onDataLoaded_DadDSN=DadElement_onDataLoaded_DadDSN;
	o._tt=o.tt; o.tt=DadElement_tt;
	o.dsn = dsndad;
	o.create();
	et.register(EVT_DATALOAD_PREFIX+"DadDSN",o);
	return o;
	function DadElement_onDataLoaded_DadDSN(oDSN) {
		if (oDSN._parser)
		{
			var sHTML=oDSN._parser.transform(window.document.all['xsl_'+this.name].XMLDocument);
			this.tt(oDSN._parser.get("/ALEXA/@URL"));
		}
	}
	function DadElement_tt(sMsg) {
		var rVal = true;
		if (!this.tipRoot) { this.tipRoot = sMsg; return true;}
		this._tt(((this.tipRoot.indexOf("{{NOURL}}") == -1) ? this.tipRoot+sMsg : this.tipRoot.replace("{{NOURL}}","")));
		return rVal;
	}
}
function ArrowDadElement(sName, sTopMargin, bBtn, state0Width, state1Width, state2Width, sStateMode) {
	var o=new ArrowElement(sName, sTopMargin, bBtn, state0Width, state1Width, state2Width, 2, sStateMode);
	o.oType="ArrowDadElement";
	if (window.document.all['xsl_'+o.name]) { o.XSLDOM=window.document.all['xsl_'+o.name]; }
	o.onDataLoaded_DadDSN=ArrowDadElement_onDataLoaded_DadDSN;
	o._tt=o.tt; o.tt=ArrowDadElement_tt;
	o.create();
	return o;
	function ArrowDadElement_onDataLoaded_DadDSN(oDSN) {
		rVal = false;
		if (oDSN._parser)
		{
			var sHTML=oDSN._parser.transform(window.document.all['xsl_'+this.name].XMLDocument);
			this.tt(oDSN._parser.get("/ALEXA/@URL"));
		}
		rVal = true;
		return rVal;
	}
	function ArrowDadElement_tt(sMsg) {
		if (!this.tipRoot) { this.tipRoot = sMsg; return true;}
		this._tt(((this.tipRoot.indexOf("{{NOURL}}") == -1) ? this.tipRoot+sMsg : this.tipRoot.replace("{{NOURL}}","")));
		return true;
	}
}

function AdElement(sName,sClick, state0Width, state1Width, state2Width, sStateMode) {
	var o = new DadElement(sName, 0, false, state0Width, state1Width, state2Width, sStateMode);
	o.oType="AdElement";
	o.action=sClick;
	o.sID = g_oCookie.readPersist(REG_AMZNID);
	if (o.sID == "") {
		o.sID= "alexashopping-3-20";
	}
	//o.newUrl = new String("www.amazon.com/exec/obidos/redirect-home/" + o.sID);
	o.newUrl = "http://www.amazon.com/gp/redirect.html?link_code=ur2&tag=" + o.sID + "&camp=1789&creative=9325&location=%2Fgp%2Fhomepage.html%2F";
	//o.newUrl = new String("www.amazon.com/gp/redirect.html?{{getAmznID('tag')}}creative=9325&camp=1789&link_code=ur2&6path="+sClick + 
	//		"&location=%2Fgp%2Fhomepage.html");
	//	"http://www.amazon.com/gp/redirect.html?link_code=ur2&tag=narbi-20&camp=1789&creative=9325&location=%2Fgp%2Fhomepage.html%2F"
	o.newUrl = encodeURIComponent(o.newUrl);
	o.action=o.newUrl;
	et.register(EVT_DATALOAD_PREFIX+"AdDSN",o);
	o.haveList = false; o.haveDad = false;
	
	o.onDataLoaded_DadDSN = AdElement_onDataLoaded_DadDSN;
	o.onDataLoaded_AdDSN = AdElement_onDataLoaded_AdDSN;
	o.onclick = AdElement_onclick;
	o.scanList = AdElement_scanList;
	o.isTTSet = false;
	o.create();
	return o;
	function AdElement_onDataLoaded_AdDSN(oDSN) {
		this.haveList = true;
		if (oDSN._parser)
		{
			this.aList = oDSN._parser.get("/alexa/ad");
		}
		if (this.haveDad) {
			this.scanList();
		}
		this._tt(this.tipRoot);
		return true;
	}
	function AdElement_onDataLoaded_DadDSN(oDSN) {
		this.haveDad = true;

		if (this.haveList) {
			this.scanList();
		}
		
		if (!this.isTTSet)
		{
			this._tt(this.tipRoot);
			this.isTTSet = true;
		}
		return true;
	}
	
	function AdElement_scanList() {
		for (var si in this.aList) {
			if (eval(this.aList[si].trigger)) {
				break;
			}
		}
		return true;
	}
	
	function AdElement_onclick() { if (!event) { event=""; } nav_main_wnd(this.action.parse(), event, "", false); return true; }
}
function HTMLDadElement(sName, sTopMargin) {
	var o=new DadElement(sName, sTopMargin, true);
	o.oType="HTMLDadElement";
	if (o.btn) { o.btn.destroy(); o.btn = null; }
	if (!window.document.all[o.name]) {
		o.m_tgt=window.document.createElement('TD');
		o.m_tgt.noWrap="true";
		o.m_tgt.vAlign="top";
		o.m_tgt.style.position="relative";
		o.m_tgt.style.className="tbLink";
		o.m_tgt.id=o.name;
	}
	o._insert = o.insert; o.insert = HTMLDadElement_insert;
	o.onDataLoaded_DadDSN=HTMLDadElement_onDataLoaded_DadDSN;
	o.create();
	return o;
	function HTMLDadElement_onDataLoaded_DadDSN(oDSN) {
		g_oLogger.out(this, "Loaded.");
		this.cnt=oDSN._parser.transform(window.document.all['xsl_'+this.name].XMLDocument);
		window.document.all[this.name].innerHTML='';window.document.all[this.name].insertAdjacentHTML("afterbegin",this.cnt);
		return true;
	}
	function HTMLDadElement_insert() {
		// need to modify for threestate.
		var sSearchPref = window.g_oCookie.readPersist(REG_WIDESEARCH);
		sWidth = 150;
		switch (sSearchPref) {
			case "narrow": sWidth = 100; break;
			case "normal": sWidth = 150;	break;
			case "wide": sWidth = 200;	break;
		}
		this.m_tgt.width=sWidth;
		this._insert();
		return true;
	}
}
function SearchFormElement(sName, sTopMargin) {
	var o=new HTMLDadElement(sName,sTopMargin,true);
	o.oType="SearchFormElement";
	o.XMLDOM = window.document.all['dummyXML'];
	o.setSearchPreference = SearchFormElement_setSearchPreference;
	var oNode = o.XMLDOM.XMLDocument.selectSingleNode("/alexa");
	oNode.setAttribute("SEARCHWIDTH",window.g_sSearchWidth);
	o._parser = new XMLParser(o.XMLDOM);
	var form = window.document.createElement("INPUT");
	form.id="searchterm"; form.name="searchterm";
	form.type="text"; form.size="25";
	form.enctype="application/x-www-form-urlencoded";
	form.lang="utf-8";
	form.onkeypress=search_submit;
	form.style.fontSize = "11px"; form.style.fontFamily = "Microsoft Sans Serif,Arial,Helvetica"; form.style.paddingTop="3px";form.style.borderColor="#999"; form.style.borderStyle="solid";form.style.borderWidth="1px"; form.style.width=window.g_sSearchWidth; form.style.height="20px";
	o.input = form;
	o.m_tgt.insertAdjacentElement("afterbegin",form);
	o.onDataLoaded_DadDSN = SearchFormElement_onDataLoaded_DadDSN;
	o.onDataLoaded_MenuDSN = SearchFormElement_onDataLoaded_MenuDSN;
	o.create();
	et.register(EVT_DATALOAD_PREFIX+"MenuDSN",o);
	if (g_oCookie.readPersist(REG_FILLSEARCH) == "false") {
		et.unregister(EVT_DATALOAD_PREFIX+"DadDSN",o);
	}
	return o;
	function SearchFormElement_onDataLoaded_MenuDSN(oDSN) {
		if (!oDSN) { oDSN=dsnmenu; }
		if (oDSN._parser)
		{
			this.nodeItems = oDSN._parser.get("/alexa/rules/rule");
			this.items = new Array(this.nodeItems.length);
			for (var si in this.nodeItems) {
				this.items[this.nodeItems[si].domain] = new Array();
				this.items[this.nodeItems[si].domain]['page']=new String(this.nodeItems[si].page);
				this.items[this.nodeItems[si].domain]['prefix']=new String(this.nodeItems[si].prefix);
			}
		}
		return true;
	}

	function SearchFormElement_onDataLoaded_DadDSN(oDSN) {
		// cycle through rules
		var sSite = new String(oDSN.currenturl);
		// strip out unusefuls to get domain
		var sDomain = new String(sSite);
		sDomain = sDomain.replace("http://","");
		sDomain = sDomain.substring(0,sDomain.indexOf("/"));
		if (this.items) {
			if (!this.items[sDomain]) {
				// not a canonical domain or international, strip host.
				sDomain = sDomain.substring(sDomain.indexOf(".")+1);
				if (!this.items[sDomain]) { return true; } // no match
			}
			var oItem = this.items[sDomain];
			// check for page
			if (sSite.indexOf(oItem.page) > -1) {
				if (sSite.indexOf(oItem.prefix) > -1) {
					// got a search term, grab the string
					var nStart = sSite.indexOf(oItem.prefix)+oItem.prefix.length;
					var nEnd = sSite.indexOf('&',sSite.indexOf(oItem.prefix));
					if (nEnd < 0) { nEnd = sSite.length; }
					var sTerm = sSite.substring(nStart,nEnd);
					//while (sTerm.indexOf("+") > -1) { sTerm = sTerm.replace("+"," "); }
					sTerm = sTerm.replace(/\+/gi, ' ');
					if (this.input) { this.input.value = decodeURIComponent(sTerm); }
				}
			}
		}
		return true;
	}

	function SearchFormElement_setSearchPreference() {
		// 0 = narrow, 1 = normal, 2 = wide
		var oNode = o.XMLDOM.XMLDocument.selectSingleNode("/alexa");
		var sSearchPref = window.g_oCookie.readPersist(REG_WIDESEARCH);
		sWidth = 150;
		switch (sSearchPref) {
			case "narrow": sWidth = 100; break;
			case "normal": sWidth = 150;	break;
			case "wide": sWidth = 200;	break;
		}
		oNode.setAttribute("SEARCHWIDTH",sWidth);		
		if (this.m_tgt) {
			this.m_tgt.style.width = sWidth;
			if (this.m_tgt.all.tags("INPUT").length > 0) {
				this.m_tgt.all.tags("INPUT")[0].style.width = sWidth;
			}
		}
		g_sbFill = window.g_oCookie.readPersist(REG_FILLSEARCH);
		if (g_sbFill == "true") {
			et.register(EVT_DATALOAD_PREFIX+"DadDSN",this);
			g_sbFill = true;
		} else {
			et.unregister(EVT_DATALOAD_PREFIX+"DadDSN",this);
			g_sbFill = false;
		}
		return true;
	}
}
function ActionDadElement(sName, sClick, bBtn, state0Width, state1Width, state2Width, sStateMode) {
	var o=new DadElement(sName, 0, bBtn, state0Width, state1Width, state2Width, sStateMode);
	o.oType="ActionDadElement";
	o.onDataLoaded_DadDSN=ActionDadElement_onDataLoaded_DadDSN;
	o.onclick=ActionDadElement_onclick;
	o.prefix="";
	et.register(EVT_DEACTIVATE,o);
	o.create();
	return o;
	function ActionDadElement_onDataLoaded_DadDSN(oDSN) {
		if (oDSN._parser)
		{
			this.url=oDSN._parser.get("/ALEXA/@REALURL");
			if (String(this.url).indexOf("#") > -1)
			{
				this.url = this.url.substring(0,this.url.indexOf("#")-1);
			}
			this.tt(this.url);
		} else {
			this.tt("");
		}
		return true;
	}
	function ActionDadElement_onclick() {
		if (!event) { event = ''; }
		this.suffix = (this.pCode) ? "p="+this.pCode + "&" : "";
		var action=this.prefix + this.url;
		action = action.replace("?url=","?" + this.suffix+"url=");
		if (this.url) { nav_main_wnd(action, event); }
	}
	return true;
}
function ActionElement(sName, sClick, bBtn, state0Width, state1Width, state2Width, sStateMode) {
	var o=new Element(sName, 0, bBtn, state0Width, state1Width, state2Width, sStateMode);
	o.oType="ActionElement";
	o.action=sClick; o.onclick=ActionElement_onclick;
	o.prefix = "";
	o.create(); return o;
	function ActionElement_onclick() { if (!event) { event=""; } nav_main_wnd(this.action, event); }
	return true;
}
function BrandElement(sName, sTopMargin, bBtn, state0Width, state1Width, state2Width, sStateMode) {
	dout("BrandElement: start\n");
	var sAssocID = g_oCookie.readPersist(REG_AMZNID);
	bBrand = false;
	if(sAssocID != "") {
		if (BrowserProxy.Update.CheckBrandImage(sAssocID) == true) {
				bBrand = true;
		} else {
			BrowserProxy.Update.FetchBrandImage(assocID);
		}
	}
	var sStateMode = 0;
	var bElapsed = true;
	var sStateWidth = 0;
	if (bBrand == true)
	{
		var oImg = new Image();
		BrowserProxy.Update.LoadBrandImage(oImg);
		//oImg.src = "http://client.alexa.com/branding/cgi-bin/getimg.cgi?amzn_id=" + sAssocID;
		sStateWidth = oImg.width;
	}
	//var sStateWidth = g_oCookie.readPersist("brandimgw"); 
	//if ((sStateWidth == 0) && (sCachedWidth > 0)) { sStateWidth = sCachedWidth; } 
	var o = new ActionElement(sName, sTopMargin, bBtn, sStateWidth, sStateWidth, sStateWidth, sStateMode);	
	o.oType = "ActionElement";
	if ((bBrand == true) && (sStateWidth > 0)) {
		o.btn=new BrandButton(o);
	} else {
		sStateWidth = 62;
		o.btn=new Button(o);
	}
	
	o.create();
	return o;
	
}

// represents an element that only responds to a click.
function PushElement(elmType, sName, sTopMargin, state0Width, state1Width, state2Width, sStateMode) {
	var o=new elmType(sName,sTopMargin, false, state0Width, state1Width, state2Width, sStateMode);
	o.oType = "PushElement";
	o.attachEvents = PushElement_attachEvents;
	o.attachEvents();
	o.create();
	return o;
	function PushElement_attachEvents() {
		this.btn.parent.m_tgt.onmouseup=PushElement_onmouseup;
		this.btn.parent.m_tgt.onmousedown=PushElement_onmousedown;
		this.btn.onmousedown = PushElement_onmousedown;
		this.btn.onmouseup = PushElement_onmouseup;
		return true;
	}
	function PushElement_onmousedown() {
		if (this.btn) { 
			this.btn.onmousedown(); return true;
		} else {
			if ( this.clickable ) {
				for (var si in alxAll.objects.Button) {
					if ((alxAll.objects.Button[si].parent.oID != this.parent.tweenID) && 
							(this.parent.oID != alxAll.objects.Button[si].parent.oID)) {
						if ((alxAll.objects.Button[si].parent.m_tgt.all.tags("IMG")[0]) && 
							(String(alxAll.objects.Button[si].parent.m_tgt.all.tags("IMG")[0].src).indexOf("pixel.gif") < 0)) {
							alxAll.objects.Button[si].clicked=false; alxAll.objects.Button[si].onmouseout(alxAll.objects.Button[si].parent.m_tgt.all.tags("IMG")[0]);
						}
					}
				}
				var oImgSet = this.labelSet.get(2);
				oImgSet.image.width = oImgSet.width;
				this.parent.m_tgt.replaceChild(oImgSet.image, this.parent.m_tgt.all.tags("IMG")[0]);
				oImg = this.parent.m_tgt.all.tags("IMG")[0];
				oImg.style.cursor="hand";
				this.mouseout=false; this.clicked=false; this.mouseover=true;
			}
		}
		return true;
	}
	function PushElement_onmouseup() {
		if (this.btn) {
			this.btn.onmouseup(); return true;
		} else {
			var oImgSet = this.labelSet.get(1);
			oImgSet.image.width = oImgSet.width;
			this.parent.m_tgt.replaceChild(oImgSet.image, this.parent.m_tgt.all.tags("IMG")[0]);
			oImg = this.parent.m_tgt.all.tags("IMG")[0];
			oImg.style.cursor="hand";
			this.mouseout=false; this.clicked=false; this.mouseover=true;
			et.exec(EVT_CLICK,new Array(this));
			this.parent.onclick();
			return true;
		}
	}
}
// drop down for any consumer of DAD data.
function PopupDadElement(sName, nWidth, nHeight, sFile, state0Width, state1Width, state2Width, sStateMode) {
	var o=new ArrowDadElement(sName,5, false, state0Width, state1Width, state2Width, sStateMode);
	o.oType="PopupDadElement";
	o.height=nHeight; o.width=nWidth;
	o.file=String(PopupDadElement.fileroot+sFile).toString();
	o.onDataLoaded_DadDSN=PopupDadElement_onDataLoaded_DadDSN;
	o.onclick=PopupDadElement_onclick;
	o._deactivate=o.deactivate; o.deactivate=PopupDadElement_deactivate;
	o.dsn = dsndad;
	o.create();
	et.register(EVT_DEACTIVATE,o);
	return o;
	function PopupDadElement_onDataLoaded_DadDSN(oDSN) {
		if (oDSN._parser)
		{
			this.tt(oDSN._parser.get("/ALEXA/@URL"));
		}
	}
	function PopupDadElement_onclick() { 
		if (!this.inproc) {
			this.inproc = true;
			if (!this.popup) { this.popup=new Popup(this); }
			this.popup.build();
			this.btn.clicked=true;
			try { this.m_tgt.previousSibling.btn.clicked=true; } catch(ex) { /* no button -hint */ }
			var rVal = et.exec(EVT_CLICK,new Array(this));
		}
		return true;
	}
	function PopupDadElement_deactivate() {
		this._deactivate();
		if (this.popup) { this.popup.hide(); }
		return true;
	}
}

PopupDadElement.fileroot= RESOURCE_URI + "CHTML/";
function AboutElement(sName) {
	var o=new Element(sName, 0, true);
	o.oType="AboutElement";
	o.onclick=AboutElement_onclick;
	o.create();
	return o;
	function AboutElement_onclick() {
		if (!this.popup) { this.popup=new AboutPopup(this); }
		this.popup.build();
		var rVal = et.exec(EVT_CLICK,new Array(this));
		return true;
	}
}
// Options menu.
function MenuElement(sName, oMenuObject, state0Width, state1Width, state2Width) {
	var o=new Element(sName,0, false, state0Width, state1Width, state2Width);
	o.oType="MenuElement";
	o.onDataLoaded_MenuDSN=MenuElement_onDataLoaded_MenuDSN;
	o.onclick=MenuElement_onclick;
	o.menu=new Menu(oMenuObject, o);
	o.create();
	et.register(EVT_DATALOAD_PREFIX+"MenuDSN",o);
	var sbFill = window.g_oCookie.readPersist(REG_FILLSEARCH);
	if (sbFill == "true") {
		et.unregister(EVT_DATALOAD_PREFIX+"DadDSN",this);
	}
	return o;
	function MenuElement_onDataLoaded_MenuDSN(oDSN) {
		if (!oDSN) { oDSN=dsnmenu; }
		if (oDSN._parser)
		{
			this.items=oDSN._parser.get(this.node);
			for (var si in this.items) {
				if (this.items[si].type == "separator") {
					if ((!this.items[si].condition) || ((this.items[si].condition) && (eval(this.items[si].condition)))) { this.menu.add("", true,parseInt(si)+1); }
				} else {
					if ((!this.items[si].condition) || ((this.items[si].condition) && (eval(this.items[si].condition)))) {
						sName = new String(this.items[si].name).parse();
						this.menu.add(sName.toString(), this.items[si],parseInt(si)+1);
					}
				}
				if (!this.tagged) {
					if (((this.items[si].track) && (this.items[si].track != "ignore")) || (!this.items[si].track)) {
						cw.tag(this,parseInt(si)+1);
					}
				}
			}
			this.tagged=true;
		}
		return true;
	}
	function MenuElement_onclick() { this.menu.onclick(); return true; } 
}
// Search drop down menu. inherits from MenuElement.
function SearchElement(sName, sTopMargin, state0Width, state1Width, state2Width) {
	var o=new MenuElement(sName, objSearchMenu, state0Width, state1Width, state2Width);
	o.oType="SearchElement";
	o.node="/alexa/search";
	o.go=SearchElement_go;
	o.cl=new Array();
	o._onDataLoaded_MenuDSN=o.onDataLoaded_MenuDSN;
	o.onDataLoaded_MenuDSN=SearchElement_onDataLoaded_MenuDSN;
	o.menu.popMenu.onSelect=SearchElement.onSelect;
	o.tagged = false;
	o.create();
	return o;
	// TODO: find easier way to populate menu from XML.
	// TODO: more generalized way of populating object properties from XML doc.
	function SearchElement_onDataLoaded_MenuDSN(oDSN) {
		this._onDataLoaded_MenuDSN(oDSN);
		if (oDSN._parser)
		{
			var aSearch;
			for (var si in this.items) {
				this.cl[si]=new Array();
				this.cl[si]['name']=this.items[si].name;
				this.cl[si]['action']=new Object();
				this.cl[si]['action'].type=oDSN._parser.get(o.node+"["+si+"]/action/@type");
				this.cl[si]['action'].root=oDSN._parser.get(o.node+"["+si+"]/action/@root");
				this.cl[si]['keyword']=new Object();
				this.cl[si]['keyword'].prefix=oDSN._parser.get(o.node+"["+si+"]/keyword/@prefix");
				this.cl[si]['keyword'].delimeter=oDSN._parser.get(o.node+"["+si+"]/keyword/@delimeter");
				this.cl[si]['fields']=oDSN._parser.get(o.node+"["+si+"]/fields/field");
				// ACS - 7/01/2003 - added sc param for click tracking
				this.cl[si]['sc']=oDSN._parser.get(o.node+'['+si+']/@sc');
			}
		}
		return true;
	}

	/*
	*  Method for SearchElement.
	*  This tries to figure out how to create a valid GET query based on the
	*  rules in XML/menu.xml and encoding everything correctly.
	*  Depends on:
	*   - redirect automatically url_decoding the GET string, as
	*   - menu.xml structure
	*  This function calls nav_main_wnd() which actually sends the main browser
	*  to the specified URI.
	* TODO: possible bug where  redirect is not decoding the URI before sending
	* cTODO: it to non-alexa/amazon sites.
	*/
	function SearchElement_go(si, oEvent) {
		var sKeyword= window.document.all['searchterm'].value;
		var delimiter = this.cl[si].keyword.delimeter;
		if(delimiter != "" && delimiter != " ") {
			sKeyword = sKeyword.replace(/ /gi, delimiter);
		}
		sKeyword = encodeURIComponent(sKeyword);
		if ( (sKeyword!='') && (this.cl[si].action.type == "url") ) {
			var path=new Array();
			var incr=0;
			var field="";
			var action=''; 
			var startPath= decodeURIComponent(new String(this.cl[si].action.root).parse().toString());
			action+= startPath;
			var prefix = new String(this.cl[si].keyword.prefix).parse().toString();
			//path[incr++]=prefix+"="+sKeyword.replace(" ", this.cl[si].keyword.delimeter);
			path[incr++]=prefix + sKeyword;
			var fields=this.cl[si].fields;
			if (typeof(fields) == "object") { 
			var sVal = '';
				for (var field in fields) {
					sVal = fields[field].value;
					path[incr++]=fields[field].prefix+"="+sVal.parse(); 
				} 
			}
			action += path.join("&");
			if (action.indexOf("alexa.com") > -1) {	
				action += "&p=" + elmSearchMenu.pCode; 
			}
			nav_main_wnd(action, oEvent, true);
			this.pCode = null;
		}
		return true;
	}
}
function search_submit() { 
	var rVal = false; 
	if (event.keyCode == 13) { 
		rVal = true; 
		elmSearchMenu.pCode="TBChrome_T_t_40_L1"; 
 		var nType=0; 
 		et.exec(EVT_CLICK,new Array(elmSearch)); // simulate reporting of search button
 		SearchElement.onSelect(nType+1,true); 
	} 
	return true; 
}
function search_button_submit() { 
	if (!event) { event = ""; }
 	var nType=0; elmSearchMenu.pCode="TBChrome_T_g_40_L1"; 
 	et.exec(EVT_CLICK,new Array(elmSearch)); // simulate reporting of search button
 	SearchElement.onSelect(nType+1,true); 
	return true;
}
function SearchElement_onSelect(si, bIgnoreClick) {
	if (!elmSearchMenu.pCode) { elmSearchMenu.pCode="TBSearch_T_t_40_L2"; }
	elmSearchMenu.go(si-1); 
 	if (!bIgnoreClick) {
 		var rVal = et.exec(EVT_CLICK, new Array(elmSearchMenu, si));
 	}
	elmSearchMenu.btn.mouseout=false; elmSearchMenu.btn.clicked = false;
	elmSearchMenu.btn.override = false;
	elmSearchMenu.btn.onmouseout();
	return true;
}
SearchElement.onSelect=SearchElement_onSelect;
function OptionElement(sName,sTopMargin, bBtn, state0Width, state1Width, state2Width, sStateMode) {
	var o=new MenuElement(sName, objOptionMenu, bBtn, state0Width, state1Width, state2Width, sStateMode);
	o.oType="OptionElement";
	o.node="/alexa/option";
	et.register(EVT_ACTIVATE,o);
	et.register(EVT_DEACTIVATE,o);
	o._onDataLoaded_MenuDSN=o.onDataLoaded_MenuDSN;
	o.onDataLoaded_MenuDSN=OptionElement_onDataLoaded_MenuDSN;
	o.activate=OptionElement_activate;
	o.deactivate=OptionElement_deactivate;
	o._onclick=o.onclick;
	o.onclick=OptionElement_onclick;
	o.tagged = false;
	o.create();
	return o;
	function OptionElement_activate() {	this.menu.clear(); this.onDataLoaded_MenuDSN(dsnmenu); return true;	}
	function OptionElement_deactivate() {	this.menu.clear(); this.onDataLoaded_MenuDSN(dsnmenu); return true;	}
	function OptionElement_onDataLoaded_MenuDSN(oDSN) { this._onDataLoaded_MenuDSN(oDSN); return true; }
	function OptionElement_onclick() { this._onclick(); return true; }
}

// Button Class.
function Button(oElement, bCreate) {
	var o=new AlxObj();
	window.g_imgPath="images/";
	o.oType="Button";
	o.parent=oElement;
	o.imgName = o.parent.name;
	o.loaded=Button_loaded;
	o.onmouseover=Button_onmouseover; 
	o.onmouseout=Button_onmouseout;
	o.onclick	= Button_onclick;
	o.buildList=Button_buildList;
	o.onLabelChange = Button_onLabelChange;
	o.labelmask = 0;
	o.clickable=true;
	o.failed = 0;
	o._super_destroy=o.destroy;
	o.destroy=Button_destroy;
	o.parent.m_tgt.onmouseover=o.onmouseover;
	o.parent.m_tgt.onmouseout=o.onmouseout;
	o.parent.m_tgt.onclick=o.onclick;
	o.ignoreL = false;
	o.parent.m_tgt.btn=o;
	o.clicked=false;
	o.threeState = true;
	if (!bCreate) {
		o.buildList();
		o.onmouseout();
	}
	o.create();
	et.register(EVT_LABELCHANGE,o);
	return o;
	function Button_onLabelChange(aArgs) {
//		if (aArgs.length != 2) { return false; }
		var state = aArgs[2];
		this.labelSet.switchSet();
		this.mouseout = false; this.clicked = false; this.onmouseout();
		return true;
	}
	function Button_buildList() {
		this.labelSet = new LabelSet(this); this.labelSet.init();
		if (this.parent.oType=="PushElement") { this.parent.attachEvents(); }
	}	
	function Button_destroy() {	this._super_destroy(); return true; }
	function Button_loaded() { return true;}
	function Button_onmouseover() {
		if (this.btn) {
			event.cancelBubble=true; this.btn.onmouseover(); return true;
		} else {
			try {
				if ( (!this.mouseover) && (!this.clicked) && (this.clickable) ) {
					et.exec(EVT_MOUSEOVER,new Array(this.parent));
					var oImgSet = this.labelSet.get(1);
					oImgSet.image.width = oImgSet.width;
					this.mouseout=false; this.mouseover=true;
					this.parent.m_tgt.replaceChild(oImgSet.image, this.parent.m_tgt.all.tags("IMG")[0]);
					var oImg=this.parent.m_tgt.all.tags("IMG")[0];
					oImg.width = oImgSet.width;
					oImg.style.cursor="hand"; window.g_oMouseOver=this;
					setTimeout("window.document.all.dummy.mouseCaller='" + this.oID + "';",5);
				}
			} catch (ex) {
			} 
		}
		return true;
	}
	function Button_onmouseout() {
		if (this.btn) {
			event.cancelBubble=true; this.btn.onmouseout(); return true;
		} else {
			if ( (!this.mouseout) && (this.clicked!=true) && (this.clickable) ) {
				if (!this.override) {
					var oImgSet = this.labelSet.get(0);
					oImgSet.image.width = oImgSet.width;
					this.parent.m_tgt.style.width=oImgSet.width;
					this.mouseover=false; this.mouseout=true;
					if (this.parent.m_tgt.all.tags("IMG")[0]) {
						this.parent.m_tgt.replaceChild(oImgSet.image,this.parent.m_tgt.all.tags("IMG")[0]);
					} else {
						this.parent.m_tgt.insertAdjacentElement("afterbegin",oImgSet.image);
					}
					var oImg=this.parent.m_tgt.all.tags("IMG")[0];  
					oImg.width = oImgSet.width;
					var rVal = et.exec(EVT_MOUSEOUT,new Array(this.parent));
					oImg.style.cursor="hand";
				}
			}
		}
		return true;
	}
	function Button_onclick() {
		if (this.btn) { 
			event.cancelBubble=true; this.btn.onclick(); return true;
		} else {
			if ( this.clickable ) {
				for (var si in alxAll.objects.Button) {
					if ((alxAll.objects.Button[si].parent.oID != this.parent.tweenID) && (this.parent.oID != alxAll.objects.Button[si].parent.oID)) {
						if (alxAll.objects.Button[si].parent.m_tgt.all.tags("IMG")[0]) {
							if (String(alxAll.objects.Button[si].parent.m_tgt.all.tags("IMG")[0].src).indexOf("pixel.gif") < 0) {
								alxAll.objects.Button[si].clicked=false; alxAll.objects.Button[si].onmouseout();
							}
						}
					}
				}
				this.clicked=true;
				var oImgSet = this.labelSet.get(2);
				oImgSet.image.width = oImgSet.width;
				this.parent.m_tgt.replaceChild(oImgSet.image, this.parent.m_tgt.all.tags("IMG")[0]);
				var rVal = et.exec(EVT_CLICK,new Array(this));
				this.parent.onclick();
				var oImg = this.parent.m_tgt.all.tags("IMG")[0];
				oImg.width = oImgSet.width;
				oImg.style.cursor="hand";
				this.mouseout=false; this.mouseover=true; 
			}
		}
		return true;
	}
}
function BrandButton(oElement, bCreate) {
	var o = new Button(oElement, true);
	o.oType = "BrandButton";
	o.imgName = BrowserProxy.System.ReadClientState(REG_AMZNID);
	o.buildList = BrandButton_buildList;
	
	o.create();

	o.buildList();
	o.onmouseout();

	return o;

	function BrandButton_buildList() {
		this.labelSet = new LabelSet(this); this.labelSet.init(BrandImageSet);
		if (this.parent.oType=="PushElement") { this.parent.attachEvents(); }
	}	
}
function ArrowButton(oElement) {
	var o = new Button(oElement, true);
	o.oType="ArrowButton";
	o.imgName = o.parent.arrowCount + "arrow";
	o.buildList();
	o.onmouseout();
	o.create();
	return o;
}
// Options and search menus.
// Gets rendered in the machine's chrome.
// (not html)
function Menu(oBrowserObject, oElement) {
	var o=new AlxObj();
	o.oType="Menu";
	o.clear=Menu_clear;
	o.popMenu=oBrowserObject;
	o.popMenu.ref=o;
	o.popMenu.OnSelect=Menu.onSelect;
	o.popMenu.Oncancel=Menu.onCancel;
	o.element=oElement; 
	o.actions=new Array();
	o.add=Menu_add;
	o.onclick=LocalMenu_onclick;
	o.incr=1;
	o.create();
	return o;
	function Menu_add(sCaption,oNode,sNode) { 
		try {
			this.actions[sNode]=oNode;
			this.popMenu.addItem(sCaption, sNode, true);
	
			if ((oNode.activeonsecure) && ((elmSecure.secure) && (oNode.activeonsecure=="false"))) { 
				this.popMenu.enableItem(sNode, false); 
			}
		} catch(ex) {}
		return true;
	}
	function Menu_clear() { try { this.popMenu.DeleteItems(); } catch(ex) { } return true; }
	function LocalMenu_onclick() { 
		currentCookie=(window.g_oCookie.readPersist(REG_DISABLE_WYM) == "false")  ? true : false;
		window.g_bWebYouMade=currentCookie;
		elmOptions.menu.clear();
		elmOptions.onDataLoaded_MenuDSN(dsnmenu);
		this.popMenu.Display(window.event.screenX, window.event.screenY);  
		return true;
	}
}
Menu.onSelect=Menu_onSelect; 
Menu.onCancel=Menu_onCancel;
Menu.onclick =Menu_onclick;
function Menu_onSelect(si) {
	et.exec(EVT_CLICK, new Array(elmOptions, si));
	// Pass this back up to the top level
	this.event.srcElement.btn.clicked=false;
	this.event.srcElement.btn.mouseout=false;
	if (this.event.srcElement.btn.joiner) {
		this.event.srcElement.btn.joiner.clickElement.override = false;
		this.event.srcElement.btn.joiner.clickElement.clicked = false;
	}
	this.event.srcElement.btn.override = false;
	this.event.srcElement.btn.onmouseout();
	if (this.event.srcElement.btn.parent.menu.actions[si].src == "script") { 
		eval(this.event.srcElement.btn.parent.menu.actions[si].action);
	} else {
		var sUrl = new String(this.event.srcElement.btn.parent.menu.actions[si].action).parse();
		nav_main_wnd(sUrl, this.event);
	}
	return true;
}
function Menu_onCancel() { this.event.srcElement.btn.clicked=false; this.event.srcElement.btn.override=false; this.event.srcElement.btn.mouseout=false; this.event.srcElement.btn.onmouseout(); return true; }
function Menu_onclick() { 
	this.menu.popMenu.Display(window.event.screenX, window.event.screenY); 
	return true; 
}
function Spacer() {
	var o=new AlxObj();
	o.oType="Spacer";
	o.oTop=window.g_oTop;
	o.spacer=window.g_oSpacer.cloneNode();
	o.m_tgt=window.document.createElement("TD"); 
	o.m_tgt.appendChild(o.spacer);
	o.cp= new Array();
	o.insert=Spacer_insert; o.insertCopy=Spacer_insertCopy;
	return o;
	function Spacer_insert(width, height) {	this.spacer.width=width; this.spacer.height=height;	this.oTop.appendChild(this.m_tgt); return true; }
	function Spacer_insertCopy(sWidth, sHeight) {
		this.oTop=window.g_oTop;
		var newRecord=this.cp.length;
		this.cp[newRecord]=this.m_tgt.cloneNode(true);
		this.cp[newRecord].style.width=sWidth; this.cp[newRecord].style.height=sHeight;
		this.cp[newRecord].all.tags("IMG")[0].width=sWidth;
		this.oTop.appendChild(this.cp[newRecord]);
		return true;
	}   
}

// browser resizing: how many links can we cram in?
function Resizer(oElement, nMargin) {
	var o=new AlxObj();
	o.oType="Resizer";
	o.loaded=false;
	o.element=oElement;
	o.onLoad=Resizer_onLoad;
	o.onresize=Resizer_onresize;
 	o.setNodeProp = Resizer_setNodeProp;
	o.onDataLoaded_DadDSN=Resizer_onDataLoaded_DadDSN;
	o.exec=Resizer_exec;
	o.bResizing=0; o.margin=0;
	o.aHiddenAnchors=new Array(); o.aHiddenSpacers=new Array();
	o.recalcSize = Resizer_recalcSize;
	o.truncate = Resizer_truncate;
	o.bHidAll = false;
	o.create();
	et.register(EVT_DATALOAD_PREFIX+"DadDSN",o); 
	et.register(EVT_LOAD,o);
	et.register(EVT_RESIZE,o);
	
	return o;
 	function Resizer_setNodeProp(oNode,bShow) {
 		var l_oNode = oNode;
 		var bDisp = (bShow) ? "" : "none";
 		if (oNode) {
 			oNode.style.display=bDisp;
 			for (var si = 0; si < 2; si++) {
 				if (l_oNode.previousSibling) {
 					l_oNode = l_oNode.previousSibling;
 				}
 			}
 			l_oNode.style.display=bDisp;
 		}
 	}
	function Resizer_onLoad() { this.loaded=true; et.register(EVT_DATALOAD_PREFIX+"DadDSN",this); return true; }
	function Resizer_onresize() { 
		this.actor.style.width="0px";
		var rVal = false; 
		var oLink = null;
		this.recalcSize();
		// first condition: if this.recalcSize() is <= body width, kill all.
		if ( this.margin < document.body.offsetWidth) {
			// space is available.
			if (this.bHidAll) {
				// previously, we hid all links, unhide them.
 				for (var si=0; si < this.ac.length; si++) { this.setNodeProp(this.ac[si],true); }
			}
			// check to see if exec is already running, if not, run it.
 			if (this.bResizing < 1) {  this.bResizing++; this.exec(); this.bResizing--; } 
			this.bHidAll = false;
		} else {
			// no space is available.
			for (var si=0; si < this.ac.length; si++) {
 				// hide links
 				this.setNodeProp(this.ac[si],false);
			}
			this.actor.style.width="0px";
			rval = true; 
			this.bHidAll = true;
		}
		return rVal; 
	}
	function Resizer_truncate(oLink) {
		if (oLink) {
			var oPrev = null;
			try { 
				if (oLink.previousSibling)
				{
					oPrev = oLink.previousSibling; 
				}
			} catch (ex) {}  // no previous sibling to link.
			if ( (oPrev !== null) && (oPrev.tagName == "SPAN") ) { 
				oPrev.style.display="";
			}
			oLink.style.display="";  // show the current link
			// make sure link is max 175 pixels.
			var cur=String(oLink.innerText);
			while (oLink.offsetWidth > 175) {	
				cur=String(oLink.innerText); 
				oLink.innerHTML='';
				oLink.insertAdjacentHTML("beforeend",cur.substring(0,cur.length-8)+'...');
			}	
			var oldcnt = String(oLink.innerText); // to save entities
			oLink.innerHTML='';
			oLink.insertAdjacentHTML("beforeend",oldcnt); // rerender truncated link caption
		}
	}
	function Resizer_exec(bRecurse) {
		var nNewWidth = 0;
		if (this.margin > 0) {
			try { BrowserProxy.SetBarSize(22, 22, 22, 250); } catch(ex) { }
			var si=null; var count=0; var showcount=0; var oPrev = null;
			if (this.ac) {
				if (this.ac.length > 0) { // at least one link
					if (this.ac.length > 10) {
						this.ac[10].style.display="none";
						var uBound = 10;
						try {
							this.ac[10].previousSibling.style.display="none";
						} catch(ex) {
							dout(ex.message);
						}
					} else {
						var uBound = this.ac.length;
					}
					for (si=0; si < uBound; si++) { // iterate through all links
						var oLink = this.ac[si];
						this.truncate(oLink);
						var nOffsetRight = oLink.parentElement.offsetLeft+oLink.offsetLeft+oLink.offsetWidth;
						oPrev = null;
						try { 
							if (oLink.previousSibling)
							{
								oPrev = oLink.previousSibling; 
							} else {
								oPrev = null;
							}
						} catch (ex) { 
							oPrev = null; 
						}  // no previous sibling to link.
						if (nOffsetRight > (window.document.body.clientWidth - this.nRightBound) ) {
							// link is out of bounds, hide it.
							if ((oPrev !== null) && (oPrev.tagName == "SPAN")) { 
								oPrev.style.display = "none";
							}
							oLink.style.display="none";
						} else {
							if ((oPrev !== null) && (oPrev.tagName == "SPAN")) {
								oPrev.style.display = "";
								nNewWidth += oPrev.offsetWidth;
							}
							// add it to the "visible" list to get width.
							nNewWidth += oLink.offsetWidth;
							oLink.style.display="";
						}
					}
				}
				this.actor.style.width=nNewWidth; 
			}
		}
		var nDiff = document.body.offsetWidth - g_oTop.offsetWidth;
 		if (nDiff > 0) { this.actor.style.width=nNewWidth+nDiff; }
		return true;
	}
	function Resizer_onDataLoaded_DadDSN() {
		this.bSized=false;
		this.actor=window.document.all[this.element.name];
		this.actor.style.width="0px";
		this.margin=0;
		this.ac=this.actor.all.tags("A"); this.sc=this.actor.all.tags("SPAN");
		this.recalcSize();
		this.onresize();
		this.bSized=true;
		return true;
	}
	function Resizer_recalcSize() {
		// get actual size for this object
		var tmpActor = this.actor;
		var nAggregateSize = 0;
		var nLeftBound = 0;
		var nRightBound = 0;
		count=0;
		do {
 			if (count++ == 300) { break; }
 			bDone = true;
 			if (tmpActor) {
				if (tmpActor.previousSibling) {
					tmpActor = tmpActor.previousSibling;
					nAggregateSize+=tmpActor.offsetWidth;
					nLeftBound+=tmpActor.offsetWidth;
				} else { 
					bDone = true;
					break; 
				}
			}
		} while (tmpActor);
		var tmpActor = this.actor;
		count=0;
		do {
			try {
				if (count++ == 300) { break; }
				if (tmpActor.nextSibling) {
					tmpActor = tmpActor.nextSibling;
					nRightBound+=tmpActor.offsetWidth;
				} else { 
					break; 
				}
			} catch (ex) { 
				dout(ex.message);	
				break; 
			}
		} while (tmpActor);
		rVal = true; 
		this.margin=document.body.offsetWidth - nAggregateSize;
		if (this.margin < 0) {
			this.margin=0; 
		}
		this.nLeftBound = nLeftBound; this.nRightBound = nRightBound;
		this.actor.style.width=this.margin+"px";
		return rVal;
	}
}
function ElmSearchForm_resize(bLarge) {
	elmSearchForm.setSearchPreference();
	BP_onNavigateComplete(null, BrowserProxy.Host.Browser, BrowserProxy.Host.Location);
	elmOptions.menu.clear(); elmOptions.onDataLoaded_MenuDSN();
	var rVal = et.exec(EVT_DATALOAD_PREFIX+"DadDSN",dsndad);
	return rVal;
}
function setlabels(bShow) {
	window.g_bShowNames=bShow;
	//window.g_oCookie.write("shownames",((bShow) ? "true" : "false"));
	for (var si in alxAll.objects.Button) { alxAll.objects.Button[si].labels(bShow); }
	elmOptions.menu.clear(); elmOptions.onDataLoaded_MenuDSN();
	BP_onNavigateComplete(null, BrowserProxy.Host.Browser, BrowserProxy.Host.Location);
	elmSIChrome.onDataLoaded_DadDSN();
	var rVal = et.exec(EVT_DATALOAD_PREFIX+"DadDSN",dsndad);
	setTimeout('resizer.exec()',20);
}
function ElmAmazon_button_onclick() { this._onclick(); this.clicked=false; return true; }
function Element_onSecureDocument() {	this.secure=true; this.clicked=true; return true; }
function ElmWayback_onDataLoaded_DadDSN(oDSN) {	if (this.secure) { this.clicked=false; this.secure =false; this.btn.onmouseout(); } this._super_onDataLoaded_DadDSN(oDSN); return true; }
// Toolbar off message when toolbar shouldn't be active (eg secure, off,
// intranet... et al).
function SecureElement(sName, sTopMargin) {
	var o=new Element(sName, sTopMargin, true);
	if (o.btn) { o.btn.destroy(); o.btn = null; }
	o.oType="SecureElement";
	if (!window.document.all[o.name]) {
		o.m_tgt=window.document.createElement('TD');
		o.m_tgt.noWrap="true"; o.m_tgt.vAlign="bottom"; o.m_tgt.style.position="relative"; o.m_tgt.style.clip="rect(0px,100px,21px,0)";  o.m_tgt.id=o.name;
	}
	o.onSecureDocument=SecureElement_onSecureDocument;
	o.activate=SecureElement_activate;
	o.deactivate=SecureElement_deactivate;
	o.secure = false;
	o.create();
	et.register(EVT_SECUREDOCUMENT,o);
	et.register(EVT_ACTIVATE,o);
	et.register(EVT_DEACTIVATE,o);
	return o;
	function SecureElement_activate(xArgs) { 
		this.secure = false; 
		this.msg=''; 
		this.m_tgt.innerHTML=''; 
		this.m_tgt.style.display="none"; 
		return true;
	}
	function SecureElement_deactivate(xArgs) {
		if (!this.msg) { 
			this.msg="<div style=\"position:relative;top:5px;font-family:Arial,Helvetica;font-size:11px;\">Toolbar is turned off.  <a href=\"javascript:void(0);\" onclick=\"et.activate();\">Click here to turn it back on.</a></div>"; 
		}
		this.m_tgt.innerHTML='';this.m_tgt.insertAdjacentHTML("beforeend",this.msg); 
		this.m_tgt.style.display="";
		this.m_tgt.style.width="100%";
		return true;
	}
	function SecureElement_onSecureDocument(xArgs) { 
		this.secure = true; 
		this.msg="<div style=\"position:relative;top:5px;font-family:Arial,Helvetica;font-size:11px;\">Secure/Intranet site, or offline. Alexa info not available.</div>"; 
		return true;
	}
}
// override a particular instance's function
// Site Info rank for this one.
function ElmSIChrome_onDataLoaded_DadDSN(oDSN) {
	if (!oDSN) { var oDSN = dsndad; }
	var rootAlexaNode = oDSN._parser.XMLDOM.selectSingleNode("ALEXA");
	if (rootAlexaNode) { rootAlexaNode.setAttribute("SHOWNAMES",window.g_oCookie.readPersist(REG_SHOWNAMES)); }
	this.m_tgt.width= (window.g_oCookie.readPersist(REG_SHOWNAMES) == "icons_text") ? this.WLong : this.WShort;
	this._onDataLoaded_DadDSN(oDSN);
	return true;
}
function checkMouseStatus(sID) { var parent = alxAll.objects.Button[sID].parent.m_tgt; return true; }

function getCurrentSearchUrl() {
	var rVal='';
	if (dsndad._parser)
	{
		g_sCurrentUrl = dsndad._parser.get("/ALEXA/@REALURL");
		if (g_sCurrentUrl.indexOf("http://") == 0) {
			rVal = "site:";
			nEnd = g_sCurrentUrl.indexOf("/",8);
			if (nEnd == -1) {
				rVal += g_sCurrentUrl.substring(7);
			} else {
				rVal += g_sCurrentUrl.substring(7,g_sCurrentUrl.indexOf("/",8));
			}
			rVal += " ";
		}
	}
	return rVal;
}

function HintElement(sName) {
	var o = new PopupDadElement(sName,0,true,0,0,0,0);
	o.oType="HintElement";
	o.insert = HintElement_insert;	
	o.hide = HintElement_hide;
	o.file=String(PopupDadElement.fileroot+"hints.html").toString();
	o._onDataLoaded_HintDSN = o.onDataLoaded_DadDSN;
	o.onDataLoaded_DadDSN = HintElement_onDataLoaded_DadDSN;
	o.onSecureDocument = HintElement_onSecureDocument;
	o.onDataLoaded_HintDSN = HintElement_onDataLoaded_HintDSN;
	o.m_tgt=document.all.hintdisplay;
	document.all.hintdiv.style.top=elmRLClick.m_tgt.offsetTop;
	document.all.hintdiv.style.left=elmRLClick.m_tgt.offsetLeft;
	o.dadloaded = false;
	o.hintloaded = false;
	o.onclick = HintElement_onclick;
	o.dsn = dsnhint;
	o.showOthers = HintElement_showOthers;
	o.bFirst = true;
	o.unReg = HintElement_unReg;
	o.setOther = HintElement_setOther;
	o.setHintProp = HintElement_setHintProp;
	o.create();
	et.register(EVT_DATALOAD_PREFIX+"HintDSN",o);
	et.register(EVT_DATALOAD_PREFIX+"DadDSN",o);
	et.register(EVT_SECUREDOCUMENT,o);
	return o;
	function HintElement_insert() {
		return true; // virtual override
	}
	function HintElement_onDataLoaded_DadDSN(oDSN) {
		if ((this.dadloaded == true) && (document.all.hintdiv.style.display==="")) {
			// hide hint on subsequent pageturn __if__ it's visible
			window.clearTimeout(this.timeout);
			this.hide(100);
			return true;
		}
		this.dadloaded = true;
		if (this.hintloaded == true) {
			et.exec(EVT_DATALOAD_PREFIX+"HintDSN",dsnhint);
		}
	}
	function HintElement_onDataLoaded_DadDSN_FromSecure(oDSN) {
		this.unReg();
		window.clearTimeout(this.timeout);
		return true;
	}
	function HintElement_onSecureDocument() {
		this.setHintProp(0);
		elmAmazon.m_tgt.style.display = "";
		elmAmazon.m_tgt.style.filter = "";
		window.clearTimeout(this.timeout);
		this.onDataLoaded_DadDSN = HintElement_onDataLoaded_DadDSN_FromSecure;
	}
	function HintElement_onDataLoaded_HintDSN(oDSN) {
		this.hintloaded = true;
		if (this.dadloaded == true) {
			et.unregister(EVT_DATALOAD_PREFIX+"HintDSN",this);
			var rVal = this._onDataLoaded_HintDSN(oDSN);
			// hide related links for now..we'll reset them in 7 seconds.
			var sResult = oDSN._parser.transform(document.all.xsl_hint.XMLDocument);
			document.all.hintdisplay.insertAdjacentHTML("afterbegin",sResult);
			document.all.hintdiv.style.top="1px";
			document.all.hintdiv.style.left=elmSIClick.m_tgt.offsetLeft;
			document.all.hintdiv.style.zIndex = 10000;
			document.all.hintdiv.style.display="";
			// hide the rest of the elements
			var oNode = elmSIClick.m_tgt;
			while(oNode) {
				oNode.style.display="none";
				try {
					oNode = oNode.nextSibling;
				} catch(ex) {
					oNode = null;
				}
			}
			this.timeout = window.setTimeout('elmHint.hide(100)',25000);
			return rVal;
		}
	}
	function HintElement_onclick() { 
		if (this.bMoving) {
			this.bCancel = true;
		} else {
			if (!this.inproc) {
				this.inproc = true;
				if (!this.popup) { this.popup=new HintPopup(this); }
				this.popup.build();
				window.clearTimeout(this.timeout);
				this.unReg();
				this.m_tgt.blur();
				document.all.hintdiv.style.display="none";
				this.setHintProp(0);
				this.setOther(100);
				et.exec(EVT_DATALOAD_PREFIX+"DadDSN",dsndad);
				resizer.onresize();
			}
			this.m_bClick = true;
			return true;
		}
	}

	function HintElement_cancel() {
		window.clearTimeout(this.timeout);
	}

	function HintElement_setOther(nOpacity) {
		var oNode = elmSIClick.m_tgt;
		while(oNode) {
			oNode.style.display = "";
			if (nOpacity == 100) {
				oNode.style.filter = ""; // fix bug in xp w/clearType enabled.
			} else {
				oNode.style.filter = "alpha(opacity="+nOpacity+")";
			}
			try {
				oNode = oNode.nextSibling;
			} catch (ex) {
				oNode = null;
			}
		}
	}
	function HintElement_showOthers(nOpacity) {
		if (nOpacity > 90) {
			nOpacity = 100;
		} else {
			nOpacity+=20;
		}
		this.setOther(nOpacity);
		if (nOpacity==100) {
			return true;
		}
		if (this.bFirst) {
			this.unReg();
			et.exec(EVT_DATALOAD_PREFIX+"DadDSN",dsndad);
			if (this.m_bClick) {
				rVal = et.exec(EVT_CLICK,new Array(this));
			}
			this.bFirst = false;
		}
		this.bMoving = true;
		setTimeout("elmHint.showOthers("+nOpacity+")",10);
		return true;
	}

	function HintElement_setHintProp(nOpacity) {
		document.all.hintdiv.children[0].style.filter = "alpha(opacity="+nOpacity+")";
	}
	
	function HintElement_unReg() {
		et.unregister(EVT_DATALOAD_PREFIX+"DadDSN",this);
		et.unregister(EVT_SECUREDOCUMENT,this);
		et.unregister(EVT_DATALOAD_PREFIX+"HintDSN",this);
	}
	function HintElement_hide(nOpacity) {
		if (this.bCancel == true) {
			this.setHintProp(100);
			document.all.hintdiv.style.display="";
			this.bCancel = false;
			this.onclick();
		} else {
			if (nOpacity < 10) {
				nOpacity = 0;
				this.unReg();
				document.all.hintdiv.style.display="none";	
			}
			this.setHintProp(nOpacity);
			if (nOpacity == 0) {
				this.bMoving = false;
				if (!et.secure) {
					window.setTimeout("elmHint.showOthers(0)",10);
				}
				return true;
			} else {
				nOpacity-=10;
				setTimeout("elmHint.hide("+nOpacity+")",100);
			}
		}
	}
}
// open a new window (eg popup config, email feature)
function WindowElement(sName, sTopMargin, state0Width, state1Width, state2Width, sStateMode, sUrl) {
	var o = new PushElement(ActionDadElement,sName, sTopMargin, state0Width, state1Width, state2Width, sStateMode);
	o.oType = "WindowElement";
	o.url = sUrl;
	o.setWindowProps = WindowElement_setWindowProps;
	o.onclick = WindowElement_onclick;
	o.create();
	return o;
	function WindowElement_setWindowProps(sWidth,sHeight,sTop,sLeft,sFlags) {
		this.winWidth = sWidth;
		this.winHeight =sHeight;
		this.winFlags = (sFlags != '') ? sFlags : "";
		this.winTop = sTop;
		this.winLeft = sLeft;
		this.winName = "win_"+this.oID;
		var sOpenStr = "width="+this.winWidth+",height="+this.winHeight;
		sOpenStr+= (this.winTop) ? ",top="+this.winTop : "";
		sOpenStr+= (this.winLeft) ? ",left="+this.winLeft : "";
		sOpenStr+= (this.winFlags) ? ","+this.winFlags : "";
		this.openStr = sOpenStr;
	}
	function WindowElement_onclick() {
		if (this.windowurl) { 
			this.linkto = String(this.windowurl).parse();
			this.oWindow = window.open(this.linkto, this.winName.substring(0,10), this.openStr); 
		}
		return true;
	}
}

function PManagerWindowElement(sName, sTopMargin, state0Width, state1Width, state2Width, sStateMode, sUrl) {
	var o = new WindowElement(sName, sTopMargin, state0Width, state1Width, state2Width, sStateMode, sUrl);
	o.oType="PManagerWindowElement";
	o._activate = o.activate;
	o.activate = PManagerWindowElement_activate;
	o.deactivate = PManagerWindowElement_deactivate;
	o.onPopup = PManagerWindowElement_onPopup;
	o.create();
	et.register(EVT_ACTIVATE,o);
	et.register(EVT_DEACTIVATE,o);
	et.register(EVT_POPUP,o);
	return o;
	
	function PManagerWindowElement_onPopup(aArgs) {
		if (g_oCookie.readPersist(REG_ENABLEPOPUPBUTTON) != "false") {
			if ((aArgs[0] == "autokilled") ||
				(aArgs[0] == "promptkilled")) {
				var sName = "Blocked";
			} 
			else if ((aArgs[0] == "autoallowed") ||
					 (aArgs[0] == "promptallowed")) {
				var sName = "Allowed";
			} else {
				this.tt("View status of Popup Manager");
				return true;
			}
			this.tt("Popup "+sName+" from "+aArgs[1]);
			var oImage = g_oImageTemplate.cloneNode(true);
			oImage.btn = this.btn;

			var sState = g_oCookie.readPersist(REG_SHOWNAMES);
			switch (sState) {
				case "icons_text":
					var sWidth = this.state0width;
					var sMode = 0;
					break;
				case "icons_stext":
					var sWidth = this.state1width;
					var sMode = 1;
					break;
				case "icons_only":
					var sWidth = this.state2width;
					var sMode = 2;
					break;
			}
			oImage.src = g_sImagePath + "/"+sMode+"button_pmanager_activated_0" + g_sImageSuffix;
			g_oLogger.out(this, "setting image: " + oImage.src);
			oImage.width = sWidth;
			this.m_tgt.replaceChild(oImage, this.m_tgt.all.tags("IMG")[0]);
		}
		return true;
	}

	function PManagerWindowElement_activate() {
		g_oLogger.out(this,"activate called..");
		if (g_oCookie.readPersist(REG_ENABLEPOPUP) == "false") {
			this.deactivate();
		} else {
			BrowserProxy.Host.IEEventSink.KillPopups = true;
			if (g_oCookie.readPersist(REG_ENABLEPOPUPBUTTON) != "false") {
				g_oLogger.out(this,"button is enabled in settings, showing.");
				this.m_tgt.style.display='';
			} 
		}
		
		
	}
	function PManagerWindowElement_deactivate() {
		g_oLogger.out(this,"deactivate called..");
		BrowserProxy.Host.IEEventSink.KillPopups = false;
		this.m_tgt.style.display='none';
	}
}
function URLEncode( plaintext )
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
        var ch = '';
	for (var i = 0; i < plaintext.length; i++ ) {
		ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			
		}
	} // for

	return encoded
};


if ( typeof(oScriptReport) == 'object' )
	oScriptReport.load('dsp.class.js');
