var bGenRunOnce = false;
thisMonth="September";
lastUpdate="9/1/2010";
var topboxTimer = 0;
var rolling = false;

var topcont = [];

topcont[0]=Array("home","<img src='img/flag.gif' align='right'> <b>I</b>n the heart of the Massachusetts Arts District in downtown Indianapolis,<br>  <b> Metro Nightclub & Restaurant </b> has a classic pub feel, friendly folk,   <a href='menu.htm'>great eats</a><br> and <a href='specials.htm'>monthly drink specials</a>.   For Indy\'s best selection of entertainment, karaoke and <br>games, Metro\'s got a wide variety   of <a href='events.htm'>weekly and special events</a>.");

topcont[1]=Array("specials","<img src='img/drink.gif' align='right'>  <h5>Everyday Specials in " + thisMonth + "</h5>  <h6>Great Deals All Month Long</h6>  $3.50 Samuel Adams Octoberfest bottles - $3.75 Dreamsickles <br> $3 Miller High Life to benefit Iraq & Afghanistan War Veterans</br>");

topcont[2]=Array("menu","<img src='img/spoonfork.gif' align='right'>  <h5>Restaurant Hours</h5>  <h6>Celebrating 19 Years of Service!</h6>  Monday thru Saturday 5pm - 10pm<br>   Sunday 1pm - 10pm");

topcont[3]=Array("events","<img src='img/spot.gif' align='right'>  <h5>Entertainment & Events</h5>  <table width='400px'>  <tr>  <td width='100px' valign='top' align='center' class='font9'><b>MONDAYS</b><br>Live Entertainment & Open Mic</td>  <td width='100px' valign='top' align='center' class='font9'><b>TUESDAYS</b><br>Indy's #1 Karaoke<br>10pm</td>  <td width='100px' valign='top' align='center' class='font9'><b>WEDNESDAYS</b><br>Board Meeting<br>$2 Well Drinks* </td>  <td width='100px' valign='top' align='center' class='font9'><b>THURSDAYS</b><br>Indy's #1 Karaoke <br>Coors Light & Miller Lite Draft Specials</td>  </tr>  </table>  ");

topcont[4]=Array("shopping","<img src='img/cart.gif' align='right'>  <h5>Metropolis Gift Shop</h5>  <i>Upstairs at Metro</i><br>  Open 4pm to 2am Mon thru Thu, 4pm to 3am Fri & Sat, 1pm to Midnight Sun<br>  We have new items every week!  ");

topcont[5]=Array("contact","<img src='img/cell.gif' align='right'>  <h5>Contact Metro Nightclub & Restaurant</h5>  Metro has daily specials and events not listed on this site.<br>  For info about tonight\'s happenings, give us a call.<br>  <h6>317 639 6022</h6>  ");

topcont[6]=Array("direct","<img src='img/globe.gif' align='right'>  <h5>Driving Directions to Metro</h5><br>  Metro is located at <b>707 Massachusetts Ave</b> in downtown Indianapolis.<br>   See below for directions to Metro and maps showing other gay hotspots in Indy.  ");

var slide = [];
slide[0]=["img/sl_indypride.gif","http://www.indyprideinc.com"]
slide[1]=["img/sl_indypride.gif","http://www.indyprideinc.com"]
slide[2]=["img/sl_indypride.gif","http://www.indyprideinc.com"]
slideIndex = -1;

initGen = function() {

	var sId;
	preload();
	
	var sPage = getPage();
	var aTb=document.getElementsByTagName("img");

	for (i=0;i<aTb.length;i++) {
		sId = aTb[i].getAttribute("id");
		if (sId && sId.indexOf("tb_")==0) {
			var aId = sId.split("_")
			if (aId[1]==sPage) {
				aTb[i].src = "img/mo_" + sPage + "_loc.gif"
			} else {
				addEvent(aTb[i],"mouseover",rollOn);
				addEvent(aTb[i],"mouseout",rollOff);				
			}
		}
	}
	setTopText("tb_" + sPage);

	getLastUpdate();

	if (sPage=="home") {
		getDrinkSpecials();
		ob("img_home").innerHTML = "img/mo_home_loc.gif"
	}
	
	changeSlide();
}

function setTopText(sId) {

	var o = ob(sId);
	var aId = sId.split("_")

	rolling = (o.src.indexOf("_on")>-1)?true:false;

	for (i=0;i<topcont.length;i++) {
		if (rolling) {
			if (topcont[i][0]== aId[1]) var mnu = topcont[i][1];
		} else {
			if (topcont[i][0] == getPage()) var mnu = topcont[i][1];
		}
	}	
	ob("topbox").innerHTML = mnu;
	
}

function getPage() {
	
	var p = window.location.href
	var pA = p.split("/")
	p = pA[pA.length-1]
	pA = p.split(".")
	if (pA[0]=="index") pA[0]="home";
	return pA[0]
}

function rollOn() {

	sId = this.getAttribute("id");
	if (sId) {
		var aId = sId.split("_")
		this.src = "img/mo_" + aId[1] + "_on.gif"
		clearInterval(topboxTimer);
		rolling = true;
		topboxTimer = setInterval("setTopText('" + sId + "');",250);
	}
}

function rollOff() {

	sId = this.getAttribute("id");
	var aId = sId.split("_")
	this.src = "img/mo_" + aId[1] + ".gif"
	if (!rolling) setTopText(sId);
}

function preload(){
	var imgs = []
	var objImage = new Image();

	imgs[0] = "img/bg.gif";
	imgs[1] = "img/logo.gif";
	imgs[2] = "img/mo_home.gif";
	imgs[3] = "img/mo_home_on.gif";
	imgs[4] = "img/mo_home_loc.gif";
	imgs[5] = "img/mo_specials.gif";
	imgs[6] = "img/mo_specials_on.gif";
	imgs[7] = "img/mo_specials_loc.gif";
	imgs[8] = "img/mo_menu.gif";
	imgs[9] = "img/mo_menu_on.gif";
	imgs[10] = "img/mo_menu_loc.gif";
	imgs[11] = "img/mo_shopping.gif";
	imgs[12] = "img/mo_shopping_on.gif";
	imgs[13] = "img/mo_shopping_loc.gif";
	imgs[14] = "img/mo_events.gif";
	imgs[15] = "img/mo_events_on.gif";
	imgs[16] = "img/mo_events_loc.gif";
	imgs[17] = "img/mo_contact.gif";
	imgs[18] = "img/mo_contact_on.gif";
	imgs[19] = "img/mo_contact_loc.gif";
	imgs[20] = "img/mo_direct.gif";
	imgs[21] = "img/mo_direct_on.gif";
	imgs[22] = "img/mo_direct_loc.gif";
	imgs[23] = "img/aniflag.gif";
	imgs[24] = "img/drink.gif";
	imgs[25] = "img/menu.gif";
	imgs[26] = "img/shopping.gif";
	imgs[27] = "img/events.gif";
	imgs[28] = "img/contact.gif";
	imgs[29] = "img/direct.gif";

	for (var i=0;i<imgs.length;i++) {
		objImage.src = imgs[i]
	}
}

function getLastUpdate() {
	ob("lastUpdate").innerHTML = "Last updated " + lastUpdate;
}
function getDrinkSpecials() {
	ob("drinkSpecials").innerHTML = "Drink Specials in " + thisMonth;
}

function changeSlide() {
	slideIndex++;
	if (slideIndex == slide.length) slideIndex=0;
	ob("slideDiv").innerHTML = "<a href='" + slide[slideIndex][1] + "' target='_new'>" + 	"<img src='" + slide[slideIndex][0] + "' width='468' height='60' border='0'></a>"
	window.setTimeout('changeSlide()',9000)
}
	
addEvent = function( obj, type, fn ) {

	if (obj.addEventListener) {
		obj.addEventListener( type, fn, false );
		eventCache.add(obj, type, fn);
	} else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
		eventCache.add(obj, type, fn);
	} else {
		obj["on"+type] = obj["e"+type+fn];
	}
}

eventCache = function(){	
	var listEvents = [];	
	return {		
		listEvents : listEvents,		
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);	
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};				
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};				
				item[0][item[1]] = null;
			};
		}
	};
}();


function cancelThisEvent(e) {

	if (typeof(e)=="undefined" && typeof(window.event) != "undefined") e = window.event;

	if (!e) return false;

	if (typeof( window.event ) != "undefined" ) {
		e.returnValue=false;
		e.cancelBubble=true;
	} 
	if (e.stopPropagation) e.stopPropagation();
	if (e.preventDefault) e.preventDefault();
	
	return false;
}


function getParams() {
	var idx = window.location.href.indexOf('?');
	var params = new Array();
	if (idx != -1) {
		var pairs = window.location.href.substring(idx+1, window.location.href.length).split('&');
		for (var i=0; i<pairs.length; i++) {
			nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
		}
	}
	return params;
}



function ob(sID) {return document.getElementById(sID);}

window.addEvent(window,'load',function(){if(!bGenRunOnce)initGen();});
window.addEvent(window,'unload',eventCache.flush);