// Banner controller

function topbanner_DoFSCommand(command, args) {
	if (command == "banner") {
		_nextBanner();
	}
}
	
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<scr'+'ipt type="text/javascript" event="FSCommand(command,args)" for="topbanner">');
	document.write('topbanner_DoFSCommand(command, args);');
	document.write('</scr'+'ipt>');
}


var bannerLists = new Array();

bannerLists["default"] = "passover_468x60.swf,new_468x60.swf";
//bannerLists["index.aspx"] = "banner1.swf,banner2.swf";
/*bannerLists["contact.aspx"] = "banner1.swf,banner3.swf";
bannerLists["reservation.aspx"] = "banner1.swf,banner3.swf";
bannerLists["thanks.aspx"] = "banner1.swf,banner3.swf";
bannerLists["location.aspx"] = "banner3.swf,banner2.swf,banner1.swf";
bannerLists["about.aspx"] = "banner1.swf,banner3.swf,banner2.swf";*/

var currentBanner = -1;
var currentList = "";
var banner = null;

function findFlash() {
	if (window.document["topbanner"]) {
		return window.document["topbanner"];
	}
	if (navigator.appName.indexOf("Microsoft Internet")==-1) {
		if (document.embeds && document.embeds["topbanner"]) return document.embeds["topbanner"];
	} else {
		return document.getElementById("topbanner");
	}
}

function _getBannerList() {
	var u = document.location.href.split("?")[0];
	u = u.split("/")[u.split("/").length-1];
	try {
		currentList = bannerLists[u];
	} catch(err) {
		currentList = bannerLists["default"];
	}
	if (typeof currentList == "undefined" || currentList == "undefined") {
		currentList = bannerLists["default"];
	}
	// Run the first banner
	so = new SWFObject("img/banners/banner_template.swf", "topbanner", "468", "60", "7", "#FFFFFF");
	so.addParam("wmode","transparent");
	so.addParam("allowScriptAccess","always");
	so.addParam("name", "topbanner");
	so.write("bannercont");
	window.setTimeout("banner = findFlash(); _nextBanner();",500);
}

function _nextBanner() {
	try {
		var blist = currentList.split(",");
		currentBanner++;
		if (currentBanner == blist.length) currentBanner = 0;
		//alert(banner);
		banner.SetVariable("newbanner","img/banners/"+blist[currentBanner]);
	} catch(e) {
	}
}
