/* video popup window
   Written for ACME Bowl by Impact Studio Pro. 2008.
   Written by Jonathan Campbell.
   Graphic design (popup window) by Nathan Bosseler. */

/* How to use this:
     
     Add an onclick() handler to the HTML element that calls document.body.doVideoPopup();
     Like this: return document.body.videoPopup.go();

     This script adds a videoPopup() method to your HTML document body.

     Note that the design is fixed, but this script maintains flexible arrays and objects
     to make changing the listed items very flexible. You can have a maximum of 6 items.

     Make sure that you specify the HTML 4 DTD at the top of your document to prevent the
     browser from running things in "Quirks" mode! */




/* Okay. Here we go: */


/* the subdirectory this script's assets exist in */
document.videoPopupPath = "videopopup/";
/* button definitions */
document.videoPopupButtons = [
	/* #1 */
	{
		title: "The Alley",
		title_img: "the_alley.title.png",
		title_img_x: 74,
		title_img_y: 40,
		thumb_img: "the_alley.thumb.jpg",
		video_flv: "the_alley.video.flv",
		hpins_img: "the_alley.pins.png"
	},
	/* #2 */
	{
		title: "Ten Bar &amp; Grill",
		title_img: "ten_bar_and_grill.title.png",
		title_img_x: 70,
		title_img_y: 30,
		thumb_img: "ten_bar_and_grill.thumb.jpg",
		video_flv: "ten_bar_and_grill.video.flv",
		hpins_img: "ten_bar_and_grill.pins.png"
	},
	/* #3 */
	{
		title: "Seven 10",
		title_img: "seven_10.title.png",
		title_img_x: 78,
		title_img_y: 40,
		thumb_img: "seven_10.thumb.jpg",
		video_flv: "seven_10.video.flv",
		hpins_img: "seven_10.pins.png"
	},
	/* #4 */
	{
		title: "ACME Events",
		title_img: "acme_events.title.png",
		title_img_x: 88,
		title_img_y: 30,
		thumb_img: "acme_events.thumb.jpg",
		video_flv: "acme_events.video.flv",
		hpins_img: "acme_events.pins.png"
	},
	/* #5 */
	{
		title: "Q Billiards",
		title_img: "q_billiards.title.png",
		title_img_x: 70,
		title_img_y: 40,
		thumb_img: "q_billiards.thumb.jpg",
		video_flv: "q_billiards.video.flv",
		hpins_img: "q_billiards.pins.png"
	},
	/* #6 */
	{
		title: "ACME Promo",
		title_img: "acme_promo.title.png",
		title_img_x: 90,
		title_img_y: 30,
		thumb_img: "acme_promo.thumb.jpg",
		video_flv: "acme_promo.video.flv",
		hpins_img: "acme_promo.pins.png"
	}
];


/* make sure the web browser is not insane in the membrane */
if (typeof(document) != 'undefined' && typeof(document.body) != 'undefined') {
	document.body.videoPopup = new Object();
	document.body.videoPopup.setup = function() {
		/* PNG transparency is possible in FireFox and Safari.
               But MSIE requires us to use CSS filters to accomplish the same */
		this.msieNeedsFiltersForTransparency = false;
		if (navigator.appName == "Microsoft Internet Explorer" && typeof(document.body.filters) != 'undefined') {
			this.msieNeedsFiltersForTransparency = true;
		}

		this.doGo = function() {
			/* bring up the background cover */
			this.backgroundCoverOn();

			/* turn on the ticker */
			this.intervalOn();

			/* bring up the menu, and place it in an appropriate place */
			this.showMenuBox();

			/* go to the right page */
			this.gotoMainMenu();

			/* we're shown. calling "go" again should have no effect */
			this.go = function() { }
			this.hideMe = this.doHide;

			/* return false, so the minimal Javascript scrap calling us can return our "false" to onclick */
			return false;
		}
		this.doHide = function() {
			/* hide menu box */
			this.hideMenuBox();

			/* hide the background cover */
			this.backgroundCoverOff();

			/* shut off the ticker */
			this.intervalOff();

			/* we're hidden. calling "hideMe" again should have no effect */
			this.go = this.doGo;
			this.hideMe = function() { }

			/* return false, to be consistent with "go"s return value */
			return false;
		}

		/* the menu box */
		this.showMenuBox = function() {
			var boxWidth = 650,boxHeight = 551;
			var documentBodySize = this.getBrowserClientSize();
			var boxTop = Math.floor((documentBodySize.height - boxHeight) / 2) + this.getBrowserScrollYPos();
			var boxLeft = Math.floor((documentBodySize.width - boxWidth) / 2);

			if (typeof(this.menuBoxElement) == 'undefined' || this.menuBoxElement == null) {
				this.menuBoxTopHdrElement = null;
				this.menuBoxElement = document.createElement('div');
				/* once again, MSIE is inept about PNG transparency */
				if (this.msieNeedsFiltersForTransparency) {
					/* delay sub-item creation we need until later, when the parent is visible */
				}
				else {
					this.menuBoxElement.style.backgroundImage = 'url('+document.videoPopupPath+'tophdr.png)';
					this.menuBoxElement.style.backgroundRepeat = 'no-repeat';
				}
				this.menuBoxElement.style.visibility = 'hidden';
				this.menuBoxElement.style.position = 'absolute';
				document.body.appendChild(this.menuBoxElement);

				/* menu body. to avoid slowing down the browser, this part is not transparent */
				this.menuBoxElement.backgroundBodyElement = document.createElement('div');
				this.menuBoxElement.backgroundBodyElement.style.position = 'absolute';
				this.menuBoxElement.backgroundBodyElement.style.top = '101px';
				this.menuBoxElement.backgroundBodyElement.style.left = '0px';
				this.menuBoxElement.backgroundBodyElement.style.width = boxWidth.toString()+'px';
				this.menuBoxElement.backgroundBodyElement.style.height = (boxHeight-101).toString()+'px';
				this.menuBoxElement.backgroundBodyElement.style.backgroundImage = 'url('+document.videoPopupPath+'backgnd.png)';
				this.menuBoxElement.backgroundBodyElement.style.backgroundRepeat = 'no-repeat';
				this.menuBoxElement.appendChild(this.menuBoxElement.backgroundBodyElement);

				/* back to video menu */
				this.backToVideoMenuElement = document.createElement('div');
				this.backToVideoMenuElement.mom = this;
				this.backToVideoMenuElement.setup = function() {
					this.style.visibility = 'hidden';
					this.style.top = '180px';
					this.style.left = '27px';
					this.style.width = '221px';
					this.style.height = '27px';
					this.style.cursor = 'pointer';
					this.style.position = 'absolute';
					if (this.mom.msieNeedsFiltersForTransparency) {
						this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.videoPopupPath+"backtomainmenu.png')";
					}
					else {
						this.style.backgroundRepeat = 'no-repeat';
						this.style.backgroundImage = 'url('+document.videoPopupPath+'backtomainmenu.png)';
					}
					this.show = function() {
						this.style.visibility = 'visible';
					}
					this.hide = function() {
						this.style.visibility = 'hidden';
					}
					this.onmouseover = function() {
						if (this.mom.msieNeedsFiltersForTransparency)
							this.filters[0].src = document.videoPopupPath+"backtomainmenu_hot.png";
						else
							this.style.backgroundImage = 'url('+document.videoPopupPath+'backtomainmenu_hot.png)';
					}
					this.onmouseout = function() {
						if (this.mom.msieNeedsFiltersForTransparency)
							this.filters[0].src = document.videoPopupPath+"backtomainmenu.png";
						else
							this.style.backgroundImage = 'url('+document.videoPopupPath+'backtomainmenu.png)';
					}
					this.onclick = function() {
						this.mom.gotoMainMenu();
					}
				}
				this.backToVideoMenuElement.setup();
				this.menuBoxElement.appendChild(this.backToVideoMenuElement);

				/* copyright notice */
				this.copyrightElement = document.createElement('div');
				this.copyrightElement.mom = this;
				this.copyrightElement.setup = function() {
					this.style.position = 'absolute';
					this.style.left = '96px';
					this.style.top = '525px';
					this.style.width = '448px';
					this.style.height = '14px';
					if (this.mom.msieNeedsFiltersForTransparency) {
						this.setupImage = function() {
							this.setupImage = null;
							this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.videoPopupPath+"copyright.png')";
						}
					}
					else {
						this.style.backgroundRepeat = 'no-repeat';
						this.style.backgroundImage = 'url('+document.videoPopupPath+'copyright.png)';
					}
					this.hideMe = function() {
						this.style.visibility = 'hidden';
					}
					this.showMe = function() {
						this.style.visibility = 'visible';
					}
				}
				this.copyrightElement.setup();
				this.menuBoxElement.appendChild(this.copyrightElement);

				/* welcome */
				this.welcomeElement = document.createElement('div');
				this.welcomeElement.mom = this;
				this.welcomeElement.setup = function() {
					this.style.position = 'absolute';
					this.style.left = '150px';
					this.style.top = '209px';
					this.style.width = '345px';
					this.style.height = '29px';
					if (this.mom.msieNeedsFiltersForTransparency) {
						this.setupImage = function() {
							this.setupImage = null;
							this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.videoPopupPath+"welcome.png')";
						}
					}
					else {
						this.style.backgroundRepeat = 'no-repeat';
						this.style.backgroundImage = 'url('+document.videoPopupPath+'welcome.png)';
					}
					this.hide = function() {
						this.style.visibility = 'hidden';
					}
					this.show = function() {
						this.style.visibility = 'visible';
					}
				}
				this.welcomeElement.setup();
				this.menuBoxElement.appendChild(this.welcomeElement);

				/* "Click on any of the videos below for on demand viewing */
				this.clickOnAnyVideoMsg = document.createElement('div');
				this.clickOnAnyVideoMsg.mom = this;
				this.clickOnAnyVideoMsg.setup = function() {
					this.style.position = 'absolute';
					this.style.textAlign = 'center';
					this.style.left = '420px';
					this.style.top = '140px';
					this.style.width = '200px';
					this.style.height = '40px';
					this.style.fontFamily = 'Arial';
					this.style.fontWeight = '900';
					this.style.cursor = 'default';
					this.style.fontSize = '10pt';
					this.style.color = '#FFFFFF';
					this.innerHTML = "Click on any of these videos below for on-demand viewing";
					this.hide = function() {
						this.style.visibility = 'hidden';
					}
					this.show = function() {
						this.style.visibility = 'visible';
					}
				}
				this.clickOnAnyVideoMsg.setup();
				this.menuBoxElement.appendChild(this.clickOnAnyVideoMsg);

				/* back to site */
				this.back2siteElement = document.createElement('div');
				this.back2siteElement.mom = this;
				this.back2siteElement.setup = function() {
					this.style.position = 'absolute';
					this.style.left = '12px';
					this.style.top = '112px';
					this.style.width = '106px';
					this.style.height = '29px';
					this.style.cursor = 'pointer';
					if (this.mom.msieNeedsFiltersForTransparency) {
						this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.videoPopupPath+"back2site.png')";
					}
					else {
						this.style.backgroundRepeat = "no-repeat";
						this.style.backgroundImage = "url("+document.videoPopupPath+"back2site.png)";
					}

					this.onmouseover = function() {
						if (this.mom.msieNeedsFiltersForTransparency)
							this.filters[0].src = document.videoPopupPath+"back2site_hot.png";
						else
							this.style.backgroundImage = "url("+document.videoPopupPath+"back2site_hot.png)";
					}
					this.onmouseout = function() {
						if (this.mom.msieNeedsFiltersForTransparency)
							this.filters[0].src = document.videoPopupPath+"back2site.png";
						else
							this.style.backgroundImage = "url("+document.videoPopupPath+"back2site.png)";
					}
					this.onclick = function() {
						this.mom.hideMe();
						return false;
					}
				}
				this.back2siteElement.setup();
				this.menuBoxElement.appendChild(this.back2siteElement);

				/* the buttons */
				this.videoPopupButtonActive = null;
				for (i=0;i < document.videoPopupButtons.length;i++) {
					var obj = document.videoPopupButtons[i];
					if (typeof(obj) == 'undefined' || obj == null)
						continue;
					if (typeof(obj.element) != 'undefined' || obj.element != null)
						continue;

					var posX = 17 + (302 * (i%2));
					var posY = 240 + (87 * Math.floor(i/2));
					var width = 316,height = 105;

					obj.element = document.createElement('div');
					obj.element.mom = this;
					obj.element.info = obj;
					obj.element.shouldBeAtX = posX;
					obj.element.shouldBeAtY = posY;
					obj.element.shouldBeWidth = width;
					obj.element.shouldBeHeight = height;
					obj.element.setup = function() {
						this.style.cursor = 'pointer';
						this.style.position = 'absolute';
						this.style.top = this.shouldBeAtY.toString() + 'px';
						this.style.left = this.shouldBeAtX.toString() + 'px';
						this.style.width = this.shouldBeWidth.toString() + 'px';
						this.style.height = this.shouldBeHeight.toString() + 'px';
						if (this.mom.msieNeedsFiltersForTransparency) {
							this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.videoPopupPath+"btnbkgen.png')";
						}
						else {
							this.style.backgroundImage = 'url('+document.videoPopupPath+'btnbkgen.png)';
							this.style.backgroundRepeat = 'no-repeat';
						}

						this.pinOverlay = document.createElement('div');
						this.pinOverlay.mommy = this;
						this.pinOverlay.setup = function() {
							this.style.position = 'absolute';
							this.style.top = '26px';
							this.style.left = '18px';
							this.style.width = '45px';
							this.style.height = '53px';
							if (this.mommy.mom.msieNeedsFiltersForTransparency) {
								this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.videoPopupPath+"fullpins.png')";
							}
							else {
								this.style.backgroundRepeat = 'no-repeat';
								this.style.backgroundImage = 'url('+document.videoPopupPath+'fullpins.png)';
							}

							this.setImage = function(url) {
								if (!url || url == "")
									url = document.videoPopupPath+'fullpins.png';

								if (this.mommy.mom.msieNeedsFiltersForTransparency)
									this.filters[0].src=url;
								else
									this.style.backgroundImage = 'url('+url+')';
							}
						}
						this.appendChild(this.pinOverlay);
						this.pinOverlay.setup();

						var thumb_src = "";
						if (typeof(this.info.thumb_img) != 'undefined')
							thumb_src = document.videoPopupPath+this.info.thumb_img;

						if (thumb_src != "") {
							this.thumbOverlay = document.createElement('div');
							this.thumbOverlay.mommy = this;
							this.thumbOverlay.imgSrc = thumb_src;
							this.thumbOverlay.setup = function() {
								this.style.position = 'absolute';
								this.style.top = '26px';
								this.style.left = '194px';
								this.style.width = '95px';
								this.style.height = '53px';
								if (this.mommy.mom.msieNeedsFiltersForTransparency) {
									this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.imgSrc+"',sizingMethod='crop')";
								}
								else {
									this.style.backgroundRepeat = 'no-repeat';
									this.style.backgroundImage = 'url('+
										this.imgSrc+')';
								}
							}
							this.appendChild(this.thumbOverlay);
							this.thumbOverlay.setup();
						}

						var title_src = "";
						if (typeof(this.info.title_img) != 'undefined')
							title_src = document.videoPopupPath + this.info.title_img;

						if (title_src != "") {
							this.titleOverlay = document.createElement('div');
							this.titleOverlay.mommy = this;
							this.titleOverlay.imgSrc = title_src;
							this.titleOverlay.setup = function() {
								var ty = 0,tx = 0;

								if (typeof(this.mommy.info.title_img_x) != 'undefined')
									tx = this.mommy.info.title_img_x;
								if (typeof(this.mommy.info.title_img_y) != 'undefined')
									ty = this.mommy.info.title_img_y;

								this.style.position = 'absolute';
								this.style.top = ty.toString()+'px';
								this.style.left = tx.toString()+'px';
								this.style.width = '140px';
								this.style.height = '70px';
								if (this.mommy.mom.msieNeedsFiltersForTransparency) {
									this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.imgSrc+"',sizingMethod='crop')";
								}
								else {
									this.style.backgroundRepeat = 'no-repeat';
									this.style.backgroundImage = 'url('+
										this.imgSrc+')';
								}
							}
							this.appendChild(this.titleOverlay);
							this.titleOverlay.setup();
						}

						this.dimHover = document.createElement('div');
						this.dimHover.mommy = this;
						this.dimHover.setup = function() {
							this.style.position = 'absolute';
							this.style.top = '13px';
							this.style.left = '9px';
							this.style.width = (this.mommy.shouldBeWidth-22).toString()+'px';
							this.style.height = (this.mommy.shouldBeHeight-26).toString()+'px';
							this.style.backgroundColor = '#6F0000';
							this.showing = false;
							this.dimming = 0;
							this.dimtarget = 0;
							this.show = function() {
								this.dimtarget = 0.25;
								this.mommy.showing = true;
							}
							this.hide = function() {
								this.dimtarget = 0;
								this.mommy.showing = false;
							}
							this.tick = function() {
								if (this.dimming == this.dimtarget)
									return;

								if (this.dimming < this.dimtarget) {
									this.dimming = this.dimming + 0.75;
									if (this.dimming > this.dimtarget)
										this.dimming = this.dimtarget;
								}
								else if (this.dimming > this.dimtarget) {
									this.dimming = this.dimming - 0.5;
									if (this.dimming < this.dimtarget)
										this.dimming = this.dimtarget;
								}

								if (this.dimming < 0)
									this.dimming = 0;

								if (this.dimming == 0)
									this.style.visibility = 'hidden';
								else
									this.style.visibility = 'visible';

								if (this.mommy.mom.msieNeedsFiltersForTransparency)
									this.filters[0].opacity = (this.dimming * 100).toString();
								else
									this.style.opacity = this.dimming.toString();
							}
							this.style.visibility = 'visible';
							if (this.mommy.mom.msieNeedsFiltersForTransparency)
								this.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
							else
								this.style.opacity = '0';
							this.style.visibility = 'hidden';
						}
						this.appendChild(this.dimHover);
						this.dimHover.setup();

						this.onmouseover = function() {
							this.mom.videoPopupButtonActive = this;

							var i = this.info;
							if (typeof(i.hpins_img) != 'undefined' && i.hpins_img != "") {
								this.pinOverlay.setImage(document.videoPopupPath+i.hpins_img);
							}
						}
						this.onmouseout = function() {
							this.mom.videoPopupButtonActive = null;
							this.pinOverlay.setImage();
						}
						this.onmousedown = function() {
							var i = this.info;

							if (typeof(i.video_flv) != 'undefined' && i.video_flv != "") {
								this.mom.gotoVideoFLV(document.videoPopupPath+i.video_flv);
							}
						}
					}
					obj.tick = function() {
						this.element.dimHover.tick();
					}
					obj.hide = function() {
						this.element.style.visibility = 'hidden';
						this.element.dimHover.style.visibility = 'hidden';
					}
					obj.show = function() {
						this.element.style.visibility = 'visible';
						this.element.dimHover.style.visibility = 'visible';
					}
					this.menuBoxElement.appendChild(obj.element);
					obj.element.setup();
				}
			}

			this.menuBoxElement.style.visibility = 'visible';
			this.menuBoxElement.style.height = boxHeight.toString() + 'px';
			this.menuBoxElement.style.width = boxWidth.toString() + 'px';
			this.menuBoxElement.style.left = boxLeft.toString() + 'px';
			this.menuBoxElement.style.top = boxTop.toString() + 'px';
			this.menuBoxElement.style.zIndex = "100000";

			if (typeof(this.copyrightElement.setupImage) == 'function')
				this.copyrightElement.setupImage();
			if (typeof(this.welcomeElement.setupImage) == 'function')
				this.welcomeElement.setupImage();
			if (typeof(this.back2siteElement.setupImage) == 'function')
				this.back2siteElement.setupImage();

			if (this.menuBoxTopHdrElement == null && this.msieNeedsFiltersForTransparency) {
				this.menuBoxTopHdrElement = document.createElement('div');
				this.menuBoxTopHdrElement.style.position = 'absolute';
				this.menuBoxTopHdrElement.style.height = boxHeight.toString();
				this.menuBoxTopHdrElement.style.width = boxWidth.toString();
				this.menuBoxTopHdrElement.style.left = '0px';
				this.menuBoxTopHdrElement.style.top = '0px';
				this.menuBoxTopHdrElement.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+document.videoPopupPath+"tophdr.png');";
				this.menuBoxElement.appendChild(this.menuBoxTopHdrElement);
			}

			return true;
		}
		/* if box showing, main menu, and we transition to flash playback */
		this.gotoVideo = function(url) {
			var i;

			this.showMenuBox();
			this.welcomeElement.hide();
			this.copyrightElement.hideMe();
			this.clickOnAnyVideoMsg.hide();
			this.backToVideoMenuElement.show();
			this.videoPopupButtonActive = null;
			this.intervalOff(); /* turn off the interval timer, focus on the flash movie */

			if (this.menuBoxElement.backgroundBodyElement.style.backgroundImage != 'url('+document.videoPopupPath+'bkgndvplay.png)')
				this.menuBoxElement.backgroundBodyElement.style.backgroundImage = 'url('+document.videoPopupPath+'bkgndvplay.png)';

			for (i=0;i < document.videoPopupButtons.length;i++) {
				var obj = document.videoPopupButtons[i];
				if (typeof(obj) == 'undefined' || obj == null)
					continue;

				obj.hide();
			}
		}
		this.dropFLVPlayer = function() {
			if (typeof(this.flvPlayer) == 'undefined' || this.flvPlayer == null)
				return;
				
			this.flvPlayer.parentNode.removeChild(this.flvPlayer);
			this.flvPlayer = null;
		}
		this.gotoVideoFLV = function(url) {
			this.dropFLVPlayer();
			this.gotoVideo(url);

			var rellurl = url;
			if (rellurl.substring(0,document.videoPopupPath.length) == document.videoPopupPath)
				rellurl = rellurl.substring(document.videoPopupPath.length);

			if (navigator.appName == "Microsoft Internet Explorer") {
				this.flvPlayer = document.createElement('object');
				this.flvPlayer.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
				this.menuBoxElement.appendChild(this.flvPlayer);
				this.flvPlayer.style.position = 'absolute';
				this.flvPlayer.style.top = '207px';
				this.flvPlayer.style.left = '52px';
				this.flvPlayer.movie=document.videoPopupPath+"flvplay.swf?movieurl="+escape(rellurl);
				this.flvPlayer.width=548;
				this.flvPlayer.height=330;
				this.flvPlayer.wmode="window";
				this.flvPlayer.swliveconnect="true";
				this.flvPlayer.allowScriptAccess="sameDomain";
			}
			else {			
				this.flvPlayer = document.createElement('div');
				this.flvPlayer.style.position = 'absolute';
				this.flvPlayer.style.top = '207px';
				this.flvPlayer.style.left = '52px';
				this.flvPlayer.innerHTML = "<embed src=\""+document.videoPopupPath+"flvplay.swf?movieurl="+escape(rellurl)+"\" width=\"548\" height=\"330\" wmode=\"window\" swliveconnect=\"true\"></embed>";
				this.menuBoxElement.appendChild(this.flvPlayer);
			}
		}
		/* Flash player calls this when finished */
		this.flashStopped = function() {
			this.gotoMainMenu();
		}
		/* if box showing, playing video, and we transition back to the page */
		this.gotoMainMenu = function() {
			var i;

			this.showMenuBox();
			this.welcomeElement.show();
			this.clickOnAnyVideoMsg.show();
			this.backToVideoMenuElement.hide();
			this.copyrightElement.showMe();
			this.videoPopupButtonActive = null;
			this.dropFLVPlayer();
			this.intervalOn();

			if (this.menuBoxElement.backgroundBodyElement.style.backgroundImage != 'url('+document.videoPopupPath+'backgnd.png)')
				this.menuBoxElement.backgroundBodyElement.style.backgroundImage = 'url('+document.videoPopupPath+'backgnd.png)';

			for (i=0;i < document.videoPopupButtons.length;i++) {
				var obj = document.videoPopupButtons[i];
				if (typeof(obj) == 'undefined' || obj == null)
					continue;

				obj.show();
			}
		}
		this.hideMenuBox = function() {
			if (typeof(this.menuBoxElement) == 'undefined' || this.menuBoxElement == null) return true;
			this.dropFLVPlayer();
			this.menuBoxElement.style.visibility = 'hidden';
			this.menuBoxElement.style.left = '-3000px';
			this.menuBoxElement.style.top = '-3000px';
			return true;
		}

		this.getBrowserScrollYPos = function() {
			var Y = 0;

			if (typeof(window.pageYOffset) != 'undefined' && window.pageYOffset != null) {
				Y = window.pageYOffset;
			}
			else if (typeof(document.body.scrollTop) != 'undefined' && document.body.scrollTop != null) {
				Y = document.body.scrollTop;
			}

			return Y;
		}
		/* code to determine the client area of the browser, so we can size/position correctly */
		/* WARNING: Make sure you call this at any point after the browser has parsed <BODY>...<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-9725256-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body> */
		this.getBrowserClientSize = function() {
			var width = 800,height = 600; /* reasonable assumptions if we can't */
			var obj = new Object();

			/* best way, exclude scrollbars from calculation */
			if (typeof(window.clientWidth) != 'undefined' && window.clientWidth > 16) {
				height = window.clientHeight;
				width = window.clientWidth;
			}
			/* another way, exclude scrollbars from calculation */
			else if (typeof(document.body.clientWidth) != 'undefined' && document.body.clientWidth > 16) {
				height = document.body.clientHeight;
				width = document.body.clientWidth;
			}
			/* fallback */
			else if (typeof(window.innerWidth) != 'undefined' && window.innerWidth > 16) {
				height = window.innerHeight;
				width = window.innerWidth;
			}
			/* fallback */
			else if (typeof(document.body.offsetWidth) != 'undefined' && document.body.offsetWidth > 16) {
				height = document.body.offsetHeight;
				width = document.body.offsetWidth;
			}

			obj.height = height;
			obj.width = width;
			return obj;
		}

		/* code to determine the client area of the body, so we can size/position correctly */
		/* WARNING: Make sure you call this at any point after the browser has parsed <BODY>...<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-9725256-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body> */
		this.getBrowserDocumentSize = function() {
			var width = 800,height = 600; /* reasonable assumptions if we can't */
			var obj = null;

			if (typeof(document.body.scrollHeight) != 'undefined' && document.body.scrollHeight > 16) {
				height = document.body.scrollHeight;
				width = document.body.scrollWidth;
				obj = new Object();
			}
			else if (typeof(document.body.clientWidth) != 'undefined' && document.body.clientWidth > 16) {
				height = document.body.clientHeight;
				width = document.body.clientWidth;
				obj = new Object();
			}
			else {
				obj = this.getBrowserClientSize();
			}

			obj.height = height;
			obj.width = width;
			return obj;
		}

		/* background cover-over element. this is what makes the "dimming" of the
               whole page possible when showing the video player */
		this.backgroundCoverOn = function() {
			var szObj = this.getBrowserDocumentSize();

			if (typeof(this.backgroundCoverElement) == 'undefined' || this.backgroundCoverElement == null) {
				this.backgroundCoverElement = document.createElement('div');
				this.backgroundCoverElement.style.backgroundColor = '#000000';
				this.backgroundCoverElement.style.visibility = 'hidden';
				this.backgroundCoverElement.style.position = 'absolute';
				this.backgroundCoverElement.style.height = '10px';
				this.backgroundCoverElement.style.width = '10px';
				this.backgroundCoverElement.style.left = '-3000px';
				this.backgroundCoverElement.style.top = '-3000px';
				this.backgroundCoverElement.style.padding = "0px";
				this.backgroundCoverElement.style.margin = "0px";
				document.body.appendChild(this.backgroundCoverElement);

				/* apply transparency */
				this.activeOpacity = 0.7;
				if (navigator.appName == "Microsoft Internet Explorer" &&
					typeof(this.backgroundCoverElement.filters) != 'undefined') {
					this.msieUseFilters = 1;
				}
				else {
					/* avoid MSIE bug that fails to apply CSS filter, when filter applied while hidden */
					this.msieUseFilters = 0;
					this.backgroundCoverElement.style.opacity = this.activeOpacity.toString();
				}
			}
			if (this.backgroundCoverElement.style.visibility == 'hidden') {
				this.backgroundCoverElement.style.visibility = 'visible';
				this.backgroundCoverElement.style.left = '0px';
				this.backgroundCoverElement.style.top = '0px';
			}

			if (this.msieUseFilters)
				this.backgroundCoverElement.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+
					(this.activeOpacity*100).toString()+");";

			this.backgroundCoverElement.style.height = szObj.height.toString()+'px';
			this.backgroundCoverElement.style.width = szObj.width.toString()+'px';
			this.backgroundCoverElement.style.zIndex = "99999"; /* make sure we're on top */
			return true;
		}
		this.backgroundCoverOff = function() {
			if (typeof(this.backgroundCoverElement) == 'undefined')
				return true;
			if (this.backgroundCoverElement == null)
				return true;
			if (this.msieUseFilters)
				this.backgroundCoverElement.style.filter = "";

			this.backgroundCoverElement.style.visibility = 'hidden';
			this.backgroundCoverElement.style.height = '10px';
			this.backgroundCoverElement.style.width = '10px';
			this.backgroundCoverElement.style.left = '-3000px';
			this.backgroundCoverElement.style.top = '-3000px';
			return true;
		}

		/* interval (timer) management, including what we do on a periodic basis */
		this.tick = function() {
			var i;

			for (i=0;i < document.videoPopupButtons.length;i++) {
				var obj = document.videoPopupButtons[i];
				if (typeof(obj) == 'undefined' || obj == null)
					continue;

				if (typeof(obj.tick) == 'function')
					obj.tick();

				if (typeof(obj.element) == 'undefined')
					continue;

				if (this.videoPopupButtonActive) {
					if (this.videoPopupButtonActive == obj.element) {
						if (obj.element.showing)
							obj.element.dimHover.hide();
					}
					else if (!obj.element.showing)
						obj.element.dimHover.show();
				}
				else {
					if (obj.element.showing)
						obj.element.dimHover.hide();
				}
			}
		}
		this.intervalOn = function() {
			if (this.intervalHandle != null)
				return true;

			this.intervalHandle = setInterval("document.body.videoPopup.tick()",this.intervalPeriod);
			return true;
		}
		this.intervalOff = function() {
			if (this.intervalHandle == null)
				return true;

			clearInterval(this.intervalHandle);
			this.intervalHandle = null;
			return true;
		}
		this.intervalHandle = null;
		this.intervalPeriod = 50;

		/* we need to preload the background and top PNG images so that the ACME
                   bowl logo doesn't show up cut off at the dividing line */
		this.preloadImages = new Array();
		this.preload = function(img) {
			var obj = new Image();
			obj.src = img;
			this.preloadImages.push(obj);
		}
		this.preload(document.videoPopupPath+"tophdr.png");
		this.preload(document.videoPopupPath+"backgnd.png");
		this.preload(document.videoPopupPath+"bkgndvplay.png");
		this.preload(document.videoPopupPath+"welcome.png");
		this.preload(document.videoPopupPath+"copyright.png");
		this.preload(document.videoPopupPath+"back2site.png");
		this.preload(document.videoPopupPath+"back2site_hot.png");
		this.preload(document.videoPopupPath+"btnbkgen.png");
		this.preload(document.videoPopupPath+"fullpins.png");
		this.preload(document.videoPopupPath+"backtomainmenu.png");
		this.preload(document.videoPopupPath+"backtomainmenu_hot.png");

		/* all buttons too */
		{
			var i;
			for (i=0;i < document.videoPopupButtons.length;i++) {
				var obj = document.videoPopupButtons[i];
				if (typeof(obj) == 'undefined' || obj == null)
					continue;

				if (typeof(obj.title_img) != 'undefined' && obj.title_img != null)
					this.preload(document.videoPopupPath + obj.title_img);
				if (typeof(obj.thumb_img) != 'undefined' && obj.thumb_img != null)
					this.preload(document.videoPopupPath + obj.thumb_img);
				if (typeof(obj.hpins_img) != 'undefined' && obj.hpins_img != null)
					this.preload(document.videoPopupPath + obj.hpins_img);
			}
		}

		/* make method "go" do something */
		this.go = this.doGo;
		this.hideMe = null;
	}
	document.body.videoPopup.setup();
}
