document.body.pageTrackingLoading = 1;

document.body.pageTracking = {
	init: function() {
	},
	currentPage: null,
	currentPageObj: null,
	pages: { },
	transformLinks: function(name) {
		/* navigate through this part of the DOM, and transform all
		 * anchored links to javascript-based page transitions */
		/* NTS: the whole point of having the links written as anchor
		 *      references is to make the links work in a safe fallback
		 *      manner in case the browser has JavaScript disabled */
		var e = document.getElementById("page_"+name);
		if (typeof(e) == 'undefined' || e == null) return;

		var a = document.body.getElementsByTagName("a");
		for (j=0;j < a.length;j++) {
			var anchor = a[j];

			/* alas, the browser combines the anchor into the whole URL even
			 * if the web developer didn't. */
			href = anchor.href;

			/* URLs ending in / should translate to .../index.php */
			if (href.length > 0 && href.substr(href.length-1,1) == "/")
				href += "index.php";

			anchor.x_href = href;
			anchor.onclick = function() {
				return document.body.pageTracking.changePage(this.x_href);
			}
		}
	},
	addPage: function(name,info,content) {
		if (typeof(this.pages[name]) != 'undefined') return;

		var addto = document.getElementById("contentregion");
		var elem = document.createElement("div");
		var title = info.title;
		if (typeof(title) == 'undefined') title = "(untitled)";
		elem.id = "page_"+name;
		elem.setAttribute("id","page_"+name);
		elem.className = "content";
		elem.setAttribute("class","content");
		elem.innerHTML = content;	/* FIXME: if the page has any JS it WONT be executed! */
		elem.style.visibility = 'hidden';
		elem.style.display = 'none';
		elem.style.top = '-4000px';
		elem.style.left = '-4000px';
		elem.title = title;
		this.pages[name] = elem;
		addto.appendChild(elem);
		this.transformLinks(name);

		if (typeof(info.js) != 'undefined') {
			var code = new Function("{"+info.js+"}"); code();
			this.assignPageObject(name,loading);
			loading = null;
		}
	},
	preparePage: function(name) {
		this.currentPageObj = document.getElementById("page_"+name);
		this.currentPage = name;
		this.transformLinks(name);
		this.pages[name] = document.getElementById("page_"+name);
	},
	hidePageImmediate: function(name) {
		var e = document.getElementById("page_"+name);
		if (typeof(e) == 'undefined' || e == null) return;
		e.style.visibility = 'hidden';
		e.style.display = 'none';
		e.style.top = '-4000px';
		e.style.left = '-4000px';
	},
	showPageImmediate: function(name) {
		var e = document.getElementById("page_"+name);
		if (typeof(e) == 'undefined' || e == null) return;
		e.style.visibility = '';
		e.style.display = 'block';
		e.style.top = '';
		e.style.left = '';
	},
	assignPageObject: function(name,obj) {
		if (typeof(this.pages[name]) != 'object') {
			alert('BUG: page '+name+' not assigned');
			return false;
		}

		this.pages[name].objJs = obj;
		obj.page = this.pages[name];
		obj.pageName = name;
		obj.absPath = 'document.body.pageTracking.pages[\''+name+'\'].objJs';

		if (typeof(obj.init) == 'function')
			obj.init(obj.absPath);

		return true;
	},
	pageencode: function(name) {
		var hexes = "0123456789abcdef";
		var x = '';
		var i,c;

		for (i=0;i < name.length;i++) {
			c = name.charCodeAt(i);
			if ((c >= 65 && c <= 90) || (c >= 97 && c <= 122)) { /* is a-z, A-Z */
				x += String.fromCharCode(c);
			}
			else {
				x += '%' + hexes.substr(Math.floor(c/16),1) + hexes.substr(c%16,1);
			}
		}

		return x;
	},
	changePage: function(name) {
		if (name.substr(0,7) == "http://") {
			var dom = name.substring(7,name.length);
			var i = dom.indexOf('/');
			if (i > 0) dom = dom.substr(0,i);

			if (dom != document.location.host)
				return true;
		}

		var s = name.toString();
		var i = s.indexOf('/');
		var rs = s;
		if (i > 0) {
			i = s.indexOf('/',i+2);
			if (i > 0) rs = s.substr(i+1);
		}

		/* DEBUG: remove this when the site is at root! */
		if (rs.substr(0,8) == "sfr2010/")
			rs = rs.substr(8);

		/* now "encode" it */
		rs = this.pageencode(rs);

		/* if that page hasn't been pre-cached, then just go ahead and load it up */
		if (typeof(this.pages[rs]) != "object")
			return true;

		this.dochangePage(rs);
		return false;
	},
	changePageFakeLink: function(name) {
		if (this.changePage(name))
			document.location = name;

		return false;
	},
	hashReescape: function(rs) { /* this is only needed because Firefox will un-escape our hash and hand it back that way */
		if (rs.indexOf('%') >= 0) return rs;
		return this.pageencode(rs);
	},
	dochangePage: function(rs) {
		document.body.pageTracking.hideMainMenuPopup();
		document.body.pageTracking.stopMainMenuHover();
		if (rs == this.currentPage) return false;
		var e = document.getElementById("page_"+rs);
		var op = this.currentPage;
		var opo = this.currentPageObj;
		this.currentPageObj = null;
		this.currentPage = null;
		if (typeof(e) == 'undefined' || e == null) return false;
		this.currentPage = rs;
		this.currentPageObj = e;
		this.showPageImmediate(this.currentPage);
		if (op != null && op != '') {
			this.hidePageImmediate(op);
			if (typeof(opo) == 'object' && typeof(opo.objJs) == 'object') {
				var o = opo.objJs;
				if (typeof(o.onHidePage) == 'function')
					o.onHidePage();
			}
		}
		if (rs == this.defaultPage) window.location = "#";
		else window.location = "#" + rs;
		document.body.autoCenter.doCenterContent();
		if (rs == this.defaultPage)
			document.title = this.defaultTitle;
		else
			document.title = this.pages[rs].title;
		this.matchMenu(rs);
		this.thisPage = rs;

		var obj = this.currentPageObj.objJs;
		if (typeof(obj) == 'object') {
			if (typeof(obj.onShowPage) == 'function')
				obj.onShowPage();
		}

		return false;
	},
	mainMenuHover: null,
	mainMenuHoverTimeout: null,
	mainMenuPopup: null,
	initMainMenuPopup: function(newBorderWidth) {
		if (typeof(newBorderWidth) == 'undefined' || newBorderWidth < 1)
			newBorderWidth = 10;
		
		if (this.mainMenuPopup == null) {
			this.mainMenuPopup = document.createElement('div');
			this.mainMenuPopup.innerHTML = "&nbsp;";
			this.mainMenuPopup.style.width = '400px';
			this.mainMenuPopup.style.height = '200px';
			this.mainMenuPopup.style.position = 'absolute';
			this.mainMenuPopup.newBorderWidth = newBorderWidth;
			this.mainMenuPopup.mom = this;
			this.mainMenuPopup.setup = function() {
				this.setup = function() { };
				this.resizeTo = function(w,h) {
					this.style.width = w.toString()+'px';
					this.style.height = h.toString()+'px';
					this.border.adjustBorders(w,h);
				}
				this.border = {
					borderWidth: 10,
					setup: function(mom) {
						this.mom = mom;
						this.setup = function() { }
						this.lel = document.createElement('div'); this.makeBorderElem(this.lel,0);
						this.rel = document.createElement('div'); this.makeBorderElem(this.rel,1);
						this.uel = document.createElement('div'); this.makeBorderElem(this.uel,2);
						this.bel = document.createElement('div'); this.makeBorderElem(this.bel,3);
						this.bkgnd = document.createElement('div'); this.makeBackgroundElem(this.bkgnd,1);
						this.innerRgn = document.createElement('div'); this.makeBackgroundElem(this.innerRgn,0);
						this.mom.innerRgn = this.innerRgn;
						this.mom.appendChild(this.lel);
						this.mom.appendChild(this.rel);
						this.mom.appendChild(this.uel);
						this.mom.appendChild(this.bel);
						this.mom.appendChild(this.bkgnd);
						this.mom.appendChild(this.innerRgn);
					},
					makeBorderElem: function(elem,side) {
						/* left,right,up,down = 0,1,2,3 */
						elem.style.position = 'absolute';
						elem.style.backgroundColor = 'black';
						if (document.body.filters && navigator.appName == "Microsoft Internet Explorer") {
							elem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=50);";
						}
						else {
							elem.style.opacity = '0.5';
						}
						elem.style.width = '1px';
						elem.style.height = '1px';
					},
					makeBackgroundElem: function(elem,trans) {
						elem.style.position = 'absolute';
						if (trans) {
							elem.style.backgroundColor = 'white';
							if (document.body.filters && navigator.appName == "Microsoft Internet Explorer") {
								elem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=90);";
							}
							else {
								elem.style.opacity = '0.9';
							}
						}
						elem.style.width = '1px';
						elem.style.height = '1px';
					},
					adjustBorders: function(w,h) {
						var iw = w - this.borderWidth * 2;
						var ih = h - this.borderWidth * 2;
						if (iw < 1) iw = 1;
						if (ih < 1) ih = 1;

						this.lel.style.top = '0px';
						this.lel.style.left = '0px';
						this.lel.style.width = this.borderWidth.toString()+'px';
						this.lel.style.height = h.toString()+'px';

						this.rel.style.top = '0px';
						this.rel.style.left = (w - this.borderWidth).toString()+'px';
						this.rel.style.width = this.borderWidth.toString()+'px';
						this.rel.style.height = h.toString()+'px';

						this.uel.style.top = '0px';
						this.uel.style.left = this.borderWidth.toString()+'px';
						this.uel.style.width = iw.toString()+'px';
						this.uel.style.height = this.borderWidth.toString()+'px';

						this.bel.style.top = (h - this.borderWidth).toString()+'px';
						this.bel.style.left = this.borderWidth.toString()+'px';
						this.bel.style.width = iw.toString()+'px';
						this.bel.style.height = this.borderWidth.toString()+'px';

						this.bkgnd.style.top = this.borderWidth.toString()+'px';
						this.bkgnd.style.left = this.borderWidth.toString()+'px';
						this.bkgnd.style.width = iw.toString()+'px';
						this.bkgnd.style.height = ih.toString()+'px';

						this.innerRgn.style.top = this.borderWidth.toString()+'px';
						this.innerRgn.style.left = this.borderWidth.toString()+'px';
						this.innerRgn.style.width = iw.toString()+'px';
						this.innerRgn.style.height = ih.toString()+'px';
					}
				}
				this.border.borderWidth = this.newBorderWidth;
				this.border.setup(this);
				this.border.adjustBorders(400,200);
			}
			this.mainMenuPopup.setup();
		}
		else {
			this.mainMenuPopup.border.borderWidth = newBorderWidth;
			this.mainMenuPopup.border.adjustBorders(400,200);
		}

		return this.mainMenuPopup;
	},
	showMainMenuPopup: function(relto) {
		var elem = relto,patience = 100;
		var x = 0,y = elem.offsetHeight;

		/* kludge: line up top with the edge of the menu */
		x -= 12;
		y += 7;

		while (patience-- > 0 && elem && typeof(elem) == 'object' && elem != document.body) {
			x += elem.offsetLeft;
			y += elem.offsetTop;
			elem = elem.parentNode;
		}
		
		this.mainMenuPopup.menuRel = relto;
		this.mainMenuPopup.style.left = x.toString()+'px';
		this.mainMenuPopup.style.top = y.toString()+'px';
		document.body.appendChild(this.mainMenuPopup);
	},
	hideMainMenuPopup: function() {
		if (this.mainMenuPopup != null) {
			if (this.mainMenuPopup.parentNode != null && typeof(this.mainMenuPopup.parentNode) == 'object' &&
				this.mainMenuPopup.parentNode)
				this.mainMenuPopup.parentNode.removeChild(this.mainMenuPopup);
		}
	},
	onMainMenuHoverTimeout: function() {
		this.stopMainMenuHover();

		if (typeof(this.mainMenuHoverWhat2do) == 'function')
			this.mainMenuHoverWhat2do(this.mainMenuHoverWhat2doCtx);
	},
	beginMainMenuHover: function(what2do,ctx,howlong) {
		if (this.mainMenuHoverTimeout != null || this.mainMenuHover != null)
			return;
		if (howlong == null || typeof(howlong) == 'undefined')
			howlong = 250;

		this.mainMenuHover = null;
		this.mainMenuHoverWhat2do = what2do;
		this.mainMenuHoverWhat2doCtx = ctx;
		this.mainMenuHoverTimeout = setTimeout("document.body.pageTracking.onMainMenuHoverTimeout();",howlong);
	},
	stopMainMenuHover: function() {
		if (this.mainMenuHover != null) {
			this.mainMenuHover.parentNode.removeChild(this.mainMenuHover);
			this.mainMenuHover = null;
		}
		if (this.mainMenuHoverTimeout != null) {
			clearTimeout(this.mainMenuHoverTimeout);
			this.mainMenuHoverTimeout = null;
		}
	},
	mainMenuPopupSelector: null,
	mainMenuPopupAddSelectorImage: function(elem,url,x,y,w,h) {
		if (this.mainMenuPopupSelector == null)
			this.mainMenuPopupSelector = document.createElement('div');

		this.mainMenuPopupSelector.setup = function(url,x,y,w,h) {
			this.style.position = 'absolute';
			this.style.left = x.toString()+'px';
			this.style.top = y.toString()+'px';
			this.style.width = w.toString()+'px';
			this.style.height = h.toString()+'px';
			this.style.backgroundImage = 'url('+url+')';
			this.offsetX = x;
			this.offsetY = y;
		}
		this.mainMenuPopupSelector.setup(url,x,y,w,h);
		elem.appendChild(this.mainMenuPopupSelector);
	},
	mainMenuPopupInitSubItems: function(elem,width,cols) {
		var w = elem.offsetWidth,h = elem.offsetHeight;

		elem.subitems = [ ];
		elem.intendedWidth = w;
		elem.intendedHeight = h;
		elem.hilightElem = document.createElement('div');
		elem.appendChild(elem.hilightElem);
		elem.hilightElem.style.position = 'absolute';
		elem.hilightElem.style.backgroundColor = '#BFBFBF';

		if (document.body.filters && navigator.appName == "Microsoft Internet Explorer") {
			elem.hilightElem.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=45);";
		}
		else {
			elem.hilightElem.style.opacity = '0.45';
		}

		elem.hilightElem.style.visibility = 'hidden';
		elem.itemWidth = width/cols;
		elem.totalWidth = width;
		elem.itemsPerRow = cols;
		elem.itemHeight = 47;
		elem.newItem = function(nfo) {
			var px = this.subitems.length % this.itemsPerRow;
			var py = Math.floor(this.subitems.length / this.itemsPerRow);
			var nobj = document.createElement('div');
			if (px < (this.itemsPerRow-1)) nobj.itemWidth = this.itemWidth - 10;
			else nobj.itemWidth = this.itemWidth;
			nobj.itemHeight = this.itemHeight;
			nobj.style.position = 'absolute';
			nobj.style.left = (px * this.itemWidth).toString()+'px';
			nobj.style.top = (py * this.itemHeight).toString()+'px';
			nobj.style.width = nobj.itemWidth.toString()+'px';
			nobj.style.height = this.itemHeight.toString()+'px';
			if (typeof(nfo.image) != 'undefined') {
				if (typeof(nfo.img_ofsx) == 'undefined') nfo.img_ofsx = 0;
				if (typeof(nfo.img_ofsy) == 'undefined') nfo.img_ofsy = 0;
				nobj.style.backgroundImage = 'url('+nfo.image+')';
				nobj.style.backgroundPosition = (-nfo.img_ofsx).toString()+'px '+(-nfo.img_ofsy).toString()+'px';
			}
			else if (typeof(nfo.title) != 'undefined') {
				nobj.style.backgroundImage = 'url(dottedh47.png)';
				var o2 = document.createElement('div');
				nobj.appendChild(o2);
				o2.style.fontSize = '20px';
				o2.style.fontFamily = 'Times new roman';
				o2.style.fontWeight = '300';
				o2.style.color = 'black';
				o2.style.width = nobj.style.width;
				o2.style.textAlign = 'center';
				o2.style.position = 'absolute';
				o2.style.left = '0px';
				o2.style.top = '12px';
				o2.innerHTML = nfo.title;
			}
			else {
				/* DEBUG */
				nobj.style.backgroundColor = 'red';
			}

			if (typeof(nfo.url) != 'undefined') {
				nobj.style.cursor = 'pointer';
				nobj.x_href = nfo.url;
				nobj.onmouseover = function() {
					this.mom.hilightItem(this.index);
				}
				nobj.onmouseout = function() {
					this.mom.hilightItem(-1);
				}
				nobj.onclick = function() {
					if (document.body.pageTracking.changePage(this.x_href))
						document.location = this.x_href;

					document.body.pageTracking.hideMainMenuPopup();
					return false;
				}
			}

			nobj.mom = this;
			nobj.index = this.subitems.length;
			this.appendChild(nobj);
			this.subitems.push(nobj);
			return nobj;
		}
		elem.hilightItem = function(index) {
			if (index >= 0 && index < this.subitems.length) {
				var obj = this.subitems[index];
				this.hilightElem.style.top = obj.style.top;
				this.hilightElem.style.left = obj.style.left;
				this.hilightElem.style.width = obj.itemWidth.toString()+'px';
				this.hilightElem.style.height = obj.itemHeight.toString()+'px';
				this.hilightElem.style.visibility = '';
			}
			else {
				this.hilightElem.style.visibility = 'hidden';
			}
		}
	},
	mainMenuPopupSelectorHilightPage: function(elem,page) {
		var ch = null,i,cmv;

		this.mainMenuPopupSelectorForPage = page;
		if (this.mainMenuPopupSelector == null)
			return;

		for (i=0;ch == null && i < elem.subitems.length;i++) {
			var el = elem.subitems[i];
			if (typeof(el) != 'object') continue;
			if (typeof(el.x_href) == 'undefined') continue;
			cmv = document.body.pageTracking.pageencode(el.x_href);

			if (cmv == page)
				ch = el;
		}

		if (ch != null) {
			var x = el.offsetLeft + this.mainMenuPopupSelector.offsetX;
			var y = el.offsetTop + this.mainMenuPopupSelector.offsetY;
			this.mainMenuPopupSelector.style.visibility = '';
			this.mainMenuPopupSelector.style.left = x.toString()+'px';
			this.mainMenuPopupSelector.style.top = y.toString()+'px';
		}
		else {
			this.mainMenuPopupSelector.style.visibility = 'hidden';
			this.mainMenuPopupSelector.style.left = '0px';
			this.mainMenuPopupSelector.style.top = '0px';
		}
	},
	menusToNotify: [],
	mainMenuDrops: {
		'_common': {
			borderWidth: 10,
			borderWidthInner: 10,
			topMessageFontSize: 14,
			topMessagePaddingBottom: 6,
			selector: {
				url: 'fisherman.png',
				x: 16,
				y: 4,
				w: 59,
				h: 34
			},
			divider: {
				h: 1,
				paddingY: 10
			}
		},
		'_order': [
			'fishing',
			'generalinfo',
			'media'
		],
		fishing: {
			rows: 2,
			cols: 2,
			colWidth: 221,
			rowHeight: 47,
			topMessage: 'If you are trying to decide between Alaska fishing trips, take a minute to explore what we have to offer at our reknowned fishing lodge.',
			topMessageHeight: 26,
			items: [
				{	title: 'Fishing Packages',	url: 'fishing.packages.php'  },
				{	title: 'Rates',			url: 'rates.php'             },
				{	title: 'Accommodations',	url: 'accommodations.php'    },
				{	title: 'Dining',		url: 'dining.php'            }
			],
			match: [
				{
					to: 'fishing.packages.php',
					from: [
						'fishing.packages.fully.guided.php',
						'fishing.packages.self.guided.php',
						'fishing.packages.fresh.water.php',
						'fishing.chart.php',
						'local.species.php',
						'fishing.packages.php'
					]
				}
			]
		},
		generalinfo: {
			rows: 2,
			cols: 1,
			colWidth: 221,
			rowHeight: 47,
			topMessage: 'Learn more about travel to Alaska.',
			topMessageHeight: 11,
			items: [
				{	title: 'Travel Tips',		url: 'travel.tips.php'       },
				{	title: 'Reservations',		url: 'rates.php'             }
			]
		},
		media: {
			rows: 2,
			cols: 2,
			colWidth: 180,
			rowHeight: 47,
			topMessage: 'See what\'s happening now at Salmon Falls Lodge!',
			topMessageHeight: 11,
			items: [
				{	title: 'Photo',			url: 'photo.php'             },
				{	title: 'Video',			url: 'video.php'             },
				{	title: 'Live cam',		url: 'livecam.php'           }
			]
		}
	},
	convertMenu: function(name) {
		var div = document.getElementById('mainmenu_'+name);
		var img = document.getElementById('mainmenupng_'+name);
		var map = document.getElementById('mainmenumap_'+name);
		if (div == null || map == null || img == null) return;
		if (typeof(div) == 'undefined' || typeof(map) == 'undefined') return;
		if (typeof(img) == 'undefined') return;
		
		var total_menu_height = 40; /* FIXME: The PHP script knows this it should pass it along */
		var total_menu_width = 492 + 20 + 30; /* FIXME */

		var hlx = 0;
		var gx = parseInt(div.getAttribute('x_left'));
		var gy = parseInt(div.getAttribute('x_top'));

		var img_url = img.src;
		var img_hot_url = img.getAttribute('x_hot_src');
		var img_width = img.width;
		var img_height = img.height;

		/* create a new DIV in memory. we will quickly swap the new DIV over the old
		 * for seamless and invisible transformation */
		var hdiv = document.createElement('div');
		hdiv.style.position = 'absolute';
		hdiv.style.top = (0).toString()+'px';
		hdiv.style.left = (0).toString()+'px';
		hdiv.style.width = total_menu_width.toString()+'px';
		hdiv.style.height = total_menu_height.toString()+'px';

		/* create a new DIV in memory. we will quickly swap the new DIV over the old
		 * for seamless and invisible transformation */
		var ndiv = document.createElement('div');
		ndiv.style.position = 'absolute';
		ndiv.style.top = gy.toString()+'px';
		ndiv.style.left = gx.toString()+'px';
		ndiv.style.width = img_width.toString()+'px';
		ndiv.style.height = img_height.toString()+'px';

		for (a=0;a < map.areas.length;a++) {
			var area = map.areas[a];
			var left = parseInt(area.getAttribute('x_left'));
			var top = parseInt(area.getAttribute('x_top'));
			var right = parseInt(area.getAttribute('x_right'));
			var bottom = parseInt(area.getAttribute('x_bottom'));
			var drop = area.getAttribute('x_drop');
			var title = area.getAttribute('x_title');
			if (right <= left || bottom <= top) continue;
			var trx;

			var sub = document.createElement('div');
			sub.style.position = 'absolute';
			sub.style.top = top.toString()+'px';
			sub.style.left = left.toString()+'px';
			sub.style.width = (right - left).toString()+'px';
			sub.style.height = (bottom - top).toString()+'px';
			sub.style.backgroundImage = 'url('+img_url+')';
			sub.style.backgroundRepeat = 'no-repeat';
			sub.style.backgroundPosition = (-left).toString()+'px '+(-top).toString()+'px';
			sub.hilightX = hlx;
			sub.hilightY = 0;
			sub.hilightH = total_menu_height;
			if ((a+1) == map.areas.length)
				trx = total_menu_width;
			else
				trx = right + gx;
			sub.hilightW = trx - hlx;
			hlx = trx;
			sub.hotSrc = img_hot_url;
			sub.normSrc = img_url;
			sub.nowSrc = img_url;
			sub.style.cursor = 'pointer';
			sub.x_href = area.href;
			sub.drop = drop;
			sub.mom = this;
			sub.onmousedown = function() {
				document.body.pageTracking.stopMainMenuHover();
				this.hoverDelayed();
			}
			sub.onmouseup = function() {
				document.body.pageTracking.hideMainMenuPopup();
				document.body.pageTracking.stopMainMenuHover();
				this.hoverDelayed();
			}
			sub.onmouseover = function() {
				document.body.pageTracking.stopMainMenuHover();
				this.isHot = true;
				this.updateState();
				this.hoverDelayed();
			}
			sub.applyDropInfo = function(tobj,sobj) {
				if (typeof(sobj) == 'object') {
					if (typeof(sobj.borderWidthInner) != 'undefined')
						this.dropItemInfo.borderWidthInner = sobj.borderWidthInner;
					if (typeof(sobj.borderWidth) != 'undefined')
						this.dropItemInfo.borderWidth = sobj.borderWidth;
					if (typeof(sobj.topMessage) != 'undefined')
						this.dropItemInfo.topMessage = sobj.topMessage;
					if (typeof(sobj.topMessageHeight) != 'undefined')
						this.dropItemInfo.topMessageHeight = sobj.topMessageHeight;
					if (typeof(sobj.topMessageFontSize) != 'undefined')
						this.dropItemInfo.topMessageFontSize = sobj.topMessageFontSize;
					if (typeof(sobj.rowHeight) != 'undefined')
						this.dropItemInfo.rowHeight = sobj.rowHeight;
					if (typeof(sobj.topMessagePaddingBottom) != 'undefined')
						this.dropItemInfo.topMessagePaddingBottom = sobj.topMessagePaddingBottom;
					if (typeof(sobj.colWidth) != 'undefined')
						this.dropItemInfo.colWidth = sobj.colWidth;
					if (typeof(sobj.selector) != 'undefined')
						this.dropItemInfo.selector = sobj.selector;
					if (typeof(sobj.cols) != 'undefined')
						this.dropItemInfo.cols = sobj.cols;
					if (typeof(sobj.rows) != 'undefined')
						this.dropItemInfo.rows = sobj.rows;
					if (typeof(sobj.divider) != 'undefined')
						this.dropItemInfo.divider = sobj.divider;
					if (typeof(sobj.items) != 'undefined')
						this.dropItemInfo.items = sobj.items;
					if (typeof(sobj.match) != 'undefined')
						this.dropItemInfo.match = sobj.match;
				}
			}
			sub.hoverDelayed = function() {
				var func = null;
				this.dropInfo = this.mom.mainMenuDrops;
				var cmn = this.dropInfo._common;
				var drp = this.dropInfo[this.drop];
				
				this.dropItemInfo = { };
				this.dropItemInfo.items = [ ];
				this.dropItemInfo.match = { };
				this.dropItemInfo.divider = false;
				this.dropItemInfo.cols = 1;
				this.dropItemInfo.rows = 1;
				this.dropItemInfo.colWidth = 1;
				this.dropItemInfo.rowHeight = 1;
				this.dropItemInfo.borderWidthInner = 1;
				this.dropItemInfo.borderWidth = 1;
				this.dropItemInfo.topMessage = '';
				this.dropItemInfo.topMessageHeight = 1;
				this.dropItemInfo.topMessageFontSize = 10;
				this.dropItemInfo.topMessagePaddingBottom = 1;
				this.applyDropInfo(this.dropItemInfo,cmn);
				this.applyDropInfo(this.dropItemInfo,drp);
				this.dropItemInfoOrder = this.dropInfo._order;
				
				func = function(ctx) {
					/* NTS: executes within the context of
					 *      document.body.pageTracking */
					var el,dividery=0;
					var x = document.body.pageTracking;
					var p = x.initMainMenuPopup(ctx.dropItemInfo.borderWidth);
					x.showMainMenuPopup(ctx);
					p.onmouseover = function() {
						/* the intent is to make it disappear when the user moves the
						 * cursor off of it. the best and stable way is to wait for
						 * the cursor to move on, then move off */
						document.body.pageTracking.stopMainMenuHover();
						this.onmouseout = function() {
							document.body.pageTracking.beginMainMenuHover(function(ctx) {
								document.body.pageTracking.hideMainMenuPopup();
								},this,750);
						}
					}
					
					if (typeof(ctx.dropItemInfo.divider) == 'object' && ctx.dropItemInfo.divider)
						dividery = ctx.dropItemInfo.divider.h + (ctx.dropItemInfo.divider.paddingY*2);
					
					p.menuWidth = (ctx.dropItemInfo.borderWidth + ctx.dropItemInfo.borderWidthInner)*2 +
						ctx.dropItemInfo.colWidth*ctx.dropItemInfo.cols;
					p.innerRgn.innerHTML = '';
					p.resizeTo(p.menuWidth,(ctx.dropItemInfo.borderWidth + ctx.dropItemInfo.borderWidthInner)*2 +
						dividery + ctx.dropItemInfo.topMessageHeight + ctx.dropItemInfo.topMessagePaddingBottom +
						(ctx.dropItemInfo.rowHeight*ctx.dropItemInfo.rows));
					
					p.head1 = document.createElement('div');
					p.head1.style.position = 'absolute';
					p.head1.style.left = ctx.dropItemInfo.borderWidthInner.toString()+'px';
					p.head1.style.top = ctx.dropItemInfo.borderWidthInner.toString()+'px';
					p.head1.style.width = (p.menuWidth - ((ctx.dropItemInfo.borderWidthInner + ctx.dropItemInfo.borderWidth)*2)).toString()+'px';
					p.head1.style.height = (ctx.dropItemInfo.topMessageHeight - 2).toString()+'px';
					p.head1.style.textAlign = 'center';
					p.head1.style.fontSize = ctx.dropItemInfo.topMessageFontSize.toString()+'px';
					p.head1.style.fontWeight = '300';
					p.head1.style.fontFamily = 'Calibri, Arial';
					p.head1.style.color = 'black';
					p.head1.innerHTML = ctx.dropItemInfo.topMessage;
					p.innerRgn.appendChild(p.head1);
					
					if (typeof(ctx.dropItemInfo.divider) == 'object' && ctx.dropItemInfo.divider) {
						p.head2 = document.createElement('div');
						p.head2.style.position = 'absolute';
						p.head2.style.left = ctx.dropItemInfo.borderWidthInner.toString()+'px';
						p.head2.style.top = (ctx.dropItemInfo.borderWidthInner + ctx.dropItemInfo.topMessageHeight + ctx.dropItemInfo.divider.paddingY + ctx.dropItemInfo.topMessagePaddingBottom).toString()+'px';
						p.head2.style.width = (p.menuWidth - ((ctx.dropItemInfo.borderWidthInner + ctx.dropItemInfo.borderWidth)*2)).toString()+'px';
						p.head2.style.height = ctx.dropItemInfo.divider.h.toString()+'px';
						p.head2.style.backgroundColor = 'black';
						p.head2.style.color = 'black';
						p.innerRgn.appendChild(p.head2);
					}
					
					p.head3 = document.createElement('div');
					p.head3.style.position = 'absolute';
					p.head3.style.left = ctx.dropItemInfo.borderWidthInner.toString()+'px';
					p.head3.style.top = (dividery + ctx.dropItemInfo.borderWidthInner + ctx.dropItemInfo.topMessageHeight + ctx.dropItemInfo.topMessagePaddingBottom).toString()+'px';
					p.head3.style.width = (p.menuWidth - ((ctx.dropItemInfo.borderWidthInner + ctx.dropItemInfo.borderWidth)*2)).toString()+'px';
					p.head3.style.height = (ctx.dropItemInfo.rowHeight*ctx.dropItemInfo.rows).toString()+'px';
					p.innerRgn.appendChild(p.head3);
					p.subitems = p.head3.subitems;
					
					/* and then use common code to transform the head3 element into the menu */
					x.mainMenuPopupInitSubItems(p.head3,p.menuWidth - ((ctx.dropItemInfo.borderWidthInner + ctx.dropItemInfo.borderWidth)*2),ctx.dropItemInfo.cols);
					if (typeof(ctx.dropItemInfo.selector) == 'object') {
						x.mainMenuPopupAddSelectorImage(p.head3,
							ctx.dropItemInfo.selector.url,
							ctx.dropItemInfo.selector.x,
							ctx.dropItemInfo.selector.y,
							ctx.dropItemInfo.selector.w,
							ctx.dropItemInfo.selector.h);
					}
					
					var items = ctx.dropItemInfo.items;
					if (typeof(items) != 'undefined') {
						for (i=0;i < items.length;i++) {
							var io = items[i];
							el = p.head3.newItem(io);
						}
					}
					
					page = document.body.pageTracking.thisPage;
					var match = ctx.dropItemInfo.match;
					if (typeof(match) != 'undefined') {
						var found = 0;
						for (mi=0;!found && mi < match.length;mi++) {
							var obj = match[mi];
							if (typeof(obj) != 'undefined') {
								for (fi=0;!found && fi < obj.from.length;fi++) {
									if (page == document.body.pageTracking.pageencode(obj.from[fi])) {
										page = document.body.pageTracking.pageencode(obj.to);
										found = 1;
									}
								}
							}
						}
					}
					
					x.mainMenuPopupSelectorHilightPage(p.head3,page);
				}
				
				if (func != null)
					document.body.pageTracking.beginMainMenuHover(func,this);
				else {
					document.body.pageTracking.beginMainMenuHover(function() {
						document.body.pageTracking.hideMainMenuPopup();},this);
				}
			}
			sub.onmouseout = function() {
				this.isHot = false;
				this.updateState();
				document.body.pageTracking.stopMainMenuHover();
			}
			sub.updateState = function() {
				var nsrc = this.normSrc;
				if (this.isHot)
					nsrc = this.hotSrc;
				if (this.isStuck)
					this.hidiv.doHilight(this.hilightX,this.hilightY,this.hilightW,this.hilightH);
				else
					this.hidiv.doHilight();

				if (nsrc != this.nowSrc) {
					this.nowSrc = nsrc;
					this.style.backgroundImage = 'url('+this.nowSrc+')';
				}
			}

			sub.onclick = function() {
				if (document.body.pageTracking.changePage(this.x_href))
					document.location = this.x_href;

				return false;
			}

			/* hilight DIV. Must be behind the DIV we create */
			var subhi = document.createElement('div');
			subhi.style.backgroundColor = '#3F5FBF';
			subhi.style.position = 'absolute';
			subhi.style.top = (0).toString()+'px';
			subhi.style.left = (0).toString()+'px';
			subhi.style.width = (1).toString()+'px';
			subhi.style.height = (1).toString()+'px';
			subhi.doHilight = function(x,y,w,h) {
				if (typeof(x) == 'undefined') {
					this.style.visibility = 'hidden';
					this.style.top = (0).toString()+'px';
					this.style.left = (0).toString()+'px';
					this.style.width = (1).toString()+'px';
					this.style.height = (1).toString()+'px';
				}
				else {
					this.style.visibility = '';
					this.style.top = y.toString()+'px';
					this.style.left = x.toString()+'px';
					this.style.width = w.toString()+'px';
					this.style.height = h.toString()+'px';
				}
			}
			sub.hidiv = subhi;

			hdiv.appendChild(subhi);
			ndiv.appendChild(sub);
		}

		/* SWAP! */
		div.parentNode.appendChild(hdiv);
		div.parentNode.appendChild(ndiv);
		div.parentNode.removeChild(div);
		this.menusToNotify.push(ndiv);
	},
	matchMainMenu: function(rs) {
		for (mti=0;mti < this.menusToNotify.length;mti++) {
			var mto = this.menusToNotify[mti];
			if (typeof(mto) == 'object') {
				var c = mto.childNodes;
				for (cni=0;cni < c.length;cni++) {
					var cn = c[cni];
					if (typeof(cn) == 'object') {
						cn.isStuck = false;
						var url = cn.x_href;
						var i = url.lastIndexOf('/');
						if (i > 0) {
							var page = url.substr(i+1);
							if (rs == this.pageencode(page)) {
								cn.isStuck = true;
							}
							else {
								/* dig deeper */
								var drop = cn.drop;
								var mo = this.mainMenuDrops[drop];
								if (typeof(mo) == 'object' && typeof(mo.items) != 'undefined') {
									for (mi=0;!cn.isStuck && mi < mo.items.length;mi++) {
										var io = mo.items[mi];
										if (typeof(io) == 'object' && typeof(io.url) != 'undefined') {
											if (rs == this.pageencode(io.url)) {
												cn.isStuck = true;
											}
										}
									}
								}
								if (typeof(mo) == 'object' && typeof(mo.match) != 'undefined') {
									for (mi=0;!cn.isStuck && mi < mo.match.length;mi++) {
										var io = mo.match[mi];
										if (typeof(io) == 'object' && typeof(io.from) != 'undefined') {
											for (fi=0;!cn.isStuck && fi < io.from.length;fi++) {
												if (rs == this.pageencode(io.from[fi])) {
													cn.isStuck = true;
												}
											}
										}
									}
								}
							}
						}
						cn.updateState();
					}
				}
			}
		}
	},
	matchMainDropDown: function(rs) {
		var a = this.mainDropDown;
		if (a == null || typeof(a) != 'object') return;
		var b = a.dropdownMain;
		if (b == null || typeof(b) != 'object') return;
		var c = b.childNodes;
		if (c == null || typeof(c) != 'object') return;
		var i,sel=null;

		for (i=0;i < c.length;i++) {
			var o = c[i];
			if (typeof(o.url) == 'undefined' || o.url == null) continue;
			if (rs == this.pageencode(o.url)) {
				if (o.item.dontmatch == 1) {
				}
				else {
					sel = o;
					break;
				}
			}
		}

		if (sel == null) {
			sel = unescape(rs);
			i = sel.lastIndexOf('.');
			sel = sel.substr(0,i);
			a.currentItem.innerHTML = sel;
		}
		else
			a.currentItem.innerHTML = sel.title;
	},
	matchMenu: function(rs) {
		this.matchMainMenu(rs);
		this.matchMainDropDown(rs);
	},
	setupMenu: function() {
		var elem = document.getElementById('mainmenu_dropdown');
		if (elem == null || typeof(elem) == 'undefined') return;
		this.mainDropDown = elem;
		elem.style.visibility = '';
		elem.style.cursor = 'pointer';

		elem.button = document.getElementById('mainmenu_dropdown_r');
		if (elem.button != null && typeof(elem.button) != 'undefined') {
			elem.button.mom = elem;
			elem.button.hotImg = new Image();
			elem.button.hotImg.src = "goto_right_hot.png";
			elem.button.normImgUrl = "goto_right.png";
			elem.button.isStuck = false;
			elem.button.onmouseover = function() {
				this.isHot = true;
				this.updateState();
			}
			elem.button.onmouseout = function() {
				this.isHot = false;
				this.updateState();
			}
			elem.button.updateState = function() {
				if (this.isHot || this.isStuck)
					this.style.backgroundImage = 'url('+elem.button.hotImg.src+')';
				else
					this.style.backgroundImage = 'url('+elem.button.normImgUrl+')';
			}
			elem.onclick = function() {
				if (!this.button.isStuck)
					this.showDropdown();
				else
					this.hideDropdown();
				return false;
			}
		}

		var citem = document.createElement('div');
		citem.style.position = 'absolute';
		citem.style.fontSize = '12px';
		citem.style.fontWeight = '300';
		citem.style.fontFamily = '"Nobile Bold", Arial';
		citem.style.color = "#6F6F6F";
		citem.style.width = '140px';
		citem.style.left = '68px';
		citem.style.top = '6px';
		citem.innerHTML = "...";
		elem.appendChild(citem);
		elem.currentItem = citem;

		elem.repositionSelf = function() {
			var left = 62 - 10,top = 29,obj = this;

			while (obj != null && typeof(obj) == 'object' && obj != document.body) {
				left += obj.offsetLeft;
				top += obj.offsetTop;
				obj = obj.parentNode;
			}

			this.xLeft = left;
			this.xTop = top;

			this.cdrc.style.left = this.xLeft.toString()+'px';
			this.cdrc.style.top = this.xTop.toString()+'px';
		}

		var cdrc = document.createElement('div');
		cdrc.style.position = 'absolute';
		elem.cdrc = cdrc;

		var cdrp = document.createElement('div');
		cdrp.style.backgroundImage = 'url(goto_dropdown.png)';
		cdrp.style.width = (154+10).toString()+'px';
		cdrp.style.color = '#1F1F1F';
		cdrc.appendChild(cdrp);

		var cdrb = document.createElement('div');
		cdrb.style.backgroundImage = 'url(goto_dropdown_end.png)';
		cdrb.style.width = (154+10).toString()+'px';
		cdrb.style.height = '9px';
		cdrc.appendChild(cdrb);

		elem.repositionSelf();

		var menu = [
			{	title: 'Home',			page: 'index.php'
			},
			{	divider: true
			},
			{	title: 'Fish Your Dreams',	page: 'fish.your.dreams.php'
			},
			{	title: 'Fishing Packages',	page: 'fishing.packages.php'
			},
				{	title: 'Fully Guided',		page: 'fishing.packages.fully.guided.php',	indent: 1
				},
				{	title: 'Self Guided',		page: 'fishing.packages.self.guided.php',	indent: 1
				},
/*				{	title: 'Fresh Water',		page: 'fishing.packages.fresh.water.php',	indent: 1
				}, */
				{	title: 'Fishing Chart',		page: 'fishing.chart.php',			indent: 1
				},
				{	title: 'Local Species',		page: 'local.species.php',			indent: 1
				},
			{	title: 'Rates',			page: 'rates.php'
			},
/*			{	title: 'Adventures',		page: 'adventures.php',
			}, */
			{	title: 'Accommodations',	page: 'accommodations.php'
			},
			{	title: 'Dining',		page: 'dining.php'
			},
			{	divider: true
			},
			{	title: 'General Info',		page: 'general.info.php'
			},
				{	title: 'Travel Tips',		page: 'travel.tips.php',			indent: 1
				},
				{	title: 'Reservations',		page: 'rates.php',				indent: 1,	dontmatch: 1
				},

			{	divider: true
			},
			{	title: 'Media',			page: 'photo.php',	dontmatch: 1
			},
				{	title: 'Photo',			page: 'photo.php',				indent: 1
				},
				{	title: 'Video',			page: 'video.php',				indent: 1
				},
/*				{	title: 'Live Cam',		page: 'livecam.php',				indent: 1
				}, */
/*			{	title: 'Catch of the Day',	page: 'catch.of.the.day.php'
			}, */
			{
				title: 'Contact Us',		page: 'contactus.php'
			}
/*			{	title: 'Newsletter',		page: 'newsletter.php'
			} */
		];

		elem.dropdownMain = cdrp;
		elem.dropdownBtm = cdrb;
		elem.dropdown = cdrc;
		elem.showDropdown = function() {
			this.repositionSelf();
			document.body.appendChild(this.dropdown);
			this.button.isStuck = true;
			this.button.updateState();
			this.dropdown.focus();
		}
		elem.hideDropdown = function() {
			if (this.dropdown.parentNode != null)
				this.dropdown.parentNode.removeChild(this.dropdown);

			this.button.isStuck = false;
			this.button.updateState();
		}

		elem.currentItem.innerHTML = menu[0].title;

		/* build the menu */
		for (i=0;i < menu.length;i++) {
			var item = menu[i];
			var nelem = document.createElement('div');
			nelem.style.position = 'relative';
			nelem.style.left = '18px';
			nelem.style.width = (154 + 10 - (18+18)).toString()+'px';
			nelem.mom = elem;
			nelem.item = item;
			nelem.url = item.page;

			if (item.divider == true) {
				/* TODO: use a png of a dotted line */
				nelem.innerHTML = '- - - - - - - - - - - - - - - - - - -';
				nelem.style.color = '#7F7F7F';
				nelem.style.cursor = 'default';
				nelem.style.fontSize = '4px';
				nelem.onclick = function() {
					this.mom.hideDropdown();
				}
			}
			else if (typeof(item.page) != 'undefined') {
				var indent = '';
				if (typeof(item.indent) != 'undefined' && item.indent > 0) {
					for (j=0;j < item.indent;j++)
						indent += '&nbsp; &nbsp;';
				}
				nelem.innerHTML = indent + item.title;
				nelem.title = item.title;
				nelem.style.cursor = 'pointer';
				nelem.x_href = item.page;
				nelem.onclick = function() {
					this.isHot = false;
					this.updateState();
					if (document.body.pageTracking.changePage(this.x_href))
						document.location = this.x_href;

					this.mom.hideDropdown();
				}
				nelem.onmouseover = function() {
					this.isHot = true;
					this.updateState();
				}
				nelem.onmouseout = function() {
					this.isHot = false;
					this.updateState();
				}
				nelem.updateState = function() {
					if (this.isHot) {
						this.style.backgroundColor = '#7F7F7F';
						this.style.color = '#FFFFFF';
					}
					else {
						this.style.backgroundColor = '';
						this.style.color = '';
					}
				}
			}

			elem.dropdownMain.appendChild(nelem);
		}
	},
	mainDropDown: null,
	dimOverlay: null,
	initDimOverlay: function() {
		if (this.dimOverlay == null) {
			this.dimOverlay = document.createElement('div');
			this.dimOverlay.style.position = 'absolute';
			this.dimOverlay.style.left = '0px';
			this.dimOverlay.style.top = '0px';
			this.dimOverlay.style.backgroundColor = '#000000';
			if (document.body.filters) {
				this.dimOverlay.style.filter = 'Alpha(opacity=75)';
			}
			else {
				this.dimOverlay.style.opacity = '0.75';
			}
		}
		if (this.dimOverlay.parentNode != null)
			this.dimOverlay.parentNode.removeChild(this.dimOverlay);
		document.body.appendChild(this.dimOverlay);
		this.dimOverlay.style.zIndex = '9998';
		this.dimOverlay.style.width = document.body.currentDims.w.toString()+'px';
		this.dimOverlay.style.height = screen.height.toString()+'px';
		this.dimOverlay.onclick = function() {
			document.body.pageTracking.dismissDimOverlay();
			return false;
		}
	},
	dismissDimOverlay: function() {
		if (typeof(this.dimOverlayOnDismiss) == 'function')
			this.dimOverlayOnDismiss(this.dimOverlayCtx);

		this.dismissDimOverlayImmediate();
	},
	dismissDimOverlayImmediate: function() {
		if (this.dimOverlay.parentNode != null)
			this.dimOverlay.parentNode.removeChild(this.dimOverlay);
	},
	beginDimOverlay: function(ctx,andThen,onDismiss) {
		this.initDimOverlay();
		this.dimOverlayCtx = ctx;
		this.dimOverlayAndThen = andThen;
		this.dimOverlayOnDismiss = onDismiss;

		if (typeof(this.dimOverlayAndThen) == 'function')
			this.dimOverlayAndThen(this.dimOverlayCtx);
	},
	dimOverlayAndThen: null,
	dimOverlayOnDismiss: null,
	dimOverlayVideo: null,
	dimOverlayPlayVideo: function(nfo) {
		if (this.dimOverlay == null) return false;
		if (typeof(nfo) != 'object') return false;
		if (typeof(nfo.play) != 'object') return false;
		var w = nfo.play.asWidth,h = nfo.play.asHeight;
		if (w < 16) w = 16;
		if (h < 16) h = 16;

		var totalWidth = w + 8*2;
		var totalHeight = h + 8*2 + 14 + 8;
		var px = Math.floor((document.body.currentDims.w - totalWidth) / 2).toString();
		var py = 150;

		this.dimOverlayDismissVideo();

		this.dimOverlayVideo = document.createElement('div');
		document.body.appendChild(this.dimOverlayVideo);
		var dv = this.dimOverlayVideo;

		dv.blurb = document.createElement('div');
		dv.blurb.style.position = 'absolute';
		dv.blurb.style.left = '8px';
		dv.blurb.style.top = (h+8*2 + 14).toString()+'px';
		dv.blurb.style.width = w.toString()+'px';
		dv.blurb.style.fontSize = '10px';
		dv.blurb.style.lineHeight = '12px';
		dv.blurb.style.fontWeight = '300';
		dv.blurb.style.textAlign = 'center';
		dv.blurb.style.color = '#1F1F1F';
		dv.blurb.innerHTML = nfo.blurb;
		dv.appendChild(dv.blurb);

		/* hopefully the browser rendered it and set offsetHeight */
		if (dv.blurb.offsetHeight >= 12)
			totalHeight += dv.blurb.offsetHeight;
		else
			totalHeight += 12;

		this.dimOverlayVideo.style.position = 'absolute';
		this.dimOverlayVideo.style.left = px.toString()+'px';
		this.dimOverlayVideo.style.top = py.toString()+'px';
		this.dimOverlayVideo.style.width = totalWidth.toString()+'px';
		this.dimOverlayVideo.style.height = totalHeight.toString()+'px';
		this.dimOverlayVideo.style.backgroundColor = 'white';
		this.dimOverlayVideo.style.zIndex = '9999';
		var drops = '2px 2px 4px #000000';
		this.dimOverlayVideo.style.webkitBoxShadow = drops;
		this.dimOverlayVideo.style.MozBoxShadow = drops;
		this.dimOverlayVideo.style.boxShadow = drops;
		this.dimOverlayVideo.closeVideo = function() {
		}

		dv.video = document.createElement('div');
		dv.video.style.position = 'absolute';
		dv.video.style.left = '8px';
		dv.video.style.top = '8px';
		dv.video.style.width = w.toString()+'px';
		dv.video.style.height = h.toString()+'px';
		dv.video.style.backgroundColor = '#DFDFDF';
		dv.video.innerHTML = "Loading video...<br><br>If the video does not load, consider installing or upgrading the Adobe Flash plugin";
		dv.video.style.color = '#3F3F3F';
		dv.appendChild(dv.video);

		dv.titlee = document.createElement('div');
		dv.titlee.style.position = 'absolute';
		dv.titlee.style.left = '8px';
		dv.titlee.style.top = (h+8*2 - 4).toString()+'px';
		dv.titlee.style.width = w.toString()+'px';
		dv.titlee.style.fontSize = '12px';
		dv.titlee.style.fontWeight = '900';
		dv.titlee.style.textAlign = 'center';
		dv.titlee.style.color = '#1F1F1F';
		dv.titlee.innerHTML = nfo.title;
		dv.appendChild(dv.titlee);

		/* now put something IN that video region to play the video */
		if (nfo.play.type == 'flv') {
			/* call up the Adobe Flash plugin */
			if (navigator.appName == "Microsoft Internet Explorer") {
				var html = '<object width='+w.toString()+' height='+h.toString()+
					' classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\">'+
					'<param name=\"movie\" value=\"'+'play_flv.swf?url='+escape(nfo.play.url)+'\">'+
					'<param name=\"wmode\" value=\"window\">'+
					'</object>';
				var em = document.createElement('div');
				em.style.position = 'absolute';
				em.style.left = '0px';
				em.style.top = '0px';
				em.style.width = w.toString()+'px';
				em.style.height = h.toString()+'px';
				em.innerHTML = html;
				dv.video.appendChild(em);
				dv.video.flash = em.children[0];
				dv.video.flashCnt = em;

				this.dimOverlayVideo.closeVideo = function() {
					/* trick Flash into unloading */
					this.video.flash.setAttribute('src','/sssss.swf');
					this.video.flashCnt.removeChild(this.video.flash);
					this.video.removeChild(this.video.flashCnt);
					this.removeChild(this.video);
				}
			}
			else {
				/* Firefox/Safari/Google Chroma/etc */
				var em = document.createElement('embed');
				em.style.position = 'absolute';
				em.style.left = '0px';
				em.style.top = '0px';
				em.style.width = w.toString()+'px';
				em.style.height = h.toString()+'px';
				em.setAttribute('width',w);
				em.setAttribute('height',h);
				em.setAttribute('src','play_flv.swf?url='+escape(nfo.play.url));
				dv.video.appendChild(em);
				dv.video.flash = em;

				this.dimOverlayVideo.closeVideo = function() {
					/* trick Flash into unloading */
					this.video.flash.setAttribute('src','/sssss.swf');
					this.video.removeChild(this.video.flash);
					this.removeChild(this.video);
				}
			}
		}
	},
	dimOverlayDismissVideo: function() {
		if (this.dimOverlayVideo != null) {
			this.dimOverlayVideo.closeVideo();
			this.dimOverlayVideo.parentNode.removeChild(this.dimOverlayVideo);
			this.dimOverlayVideo = null;
		}
	},
	onPlayFLVComplete: function() {
		this.dismissDimOverlay();
	}
};

document.body.pageTrackingLoading = 2;
document.body.pageTracking.init();
document.body.pageTrackingLoading = 0;

