//=========================================================================
function KVPair (key, value) {
//=========================================================================
	this.key = key;
	this.value = value;
}
//=========================================================================
function atPut (at, put) {
//=========================================================================
	for (var i = 0; i < this.array.length; ++i) {
		var elem = this.array[i];
		if (elem.key == at) {
			elem.value = put;
			return;
		}
	}
	var newElem = new KVPair (at, put);
	this.array[this.array.length] = newElem;
}
//=========================================================================
function get (key) {
//=========================================================================
	for (var i = 0; i < this.array.length; ++i) {
		var elem = this.array[i];
		if (elem.key == key)
			return elem.value;
	}
	return null;
}
//=========================================================================
function HashTable () {
//=========================================================================
	this.array = new Array();
	this.atPut = atPut;
	this.get =  get;
}

//  Utility

//=========================================================================
function setA(city, cityName) {
//=========================================================================
	var str = "<A HREF='http://www.indogram.com/index.html?city=" + city 
		+ "&cityName=" + escape(cityName) + "&basedir=" + basedir 
		+ "&centerpiece=" + "EventCalendarDetails.html" + "'>\n";
	document.write (str);
}
function popUpIndogramForm (link) {
	var w = window.open (link, "newWin", "resizable=yes, scrollbars=yes, width=570,height=550,screenX=150,left=150,screenY=80,top=80");
}
//=========================================================================
function setLinkToOutside (link, content, precontent, postcontent) {
//=========================================================================
   document.write (precontent);
   document.write ("<A class='ctrpcLnk'  HREF='#' onclick='popUpIndogramForm (\"" ); 
document.write (   				  link + "\");'>");
   document.write (content + "</A>");
   document.write (postcontent);
}
//=========================================================================
function setLinkToSearch (link, content, precontent, postcontent) {
document.write ("<A class='ctrpcLnk' target='_new'  HREF='" + link + "'>" + content + "</a>");
//=========================================================================
}
//=========================================================================

function setCenterpiece (ctrpiece, content, dots, titleText) {
//=========================================================================
var titleTxt = "";
if (arguments.length > 3) {
	titleTxt = titleText;
if (titleTxt.indexOf ("%20") != -1)
	titleTxt = "&title=" + titleText;
else
	titleTxt = "&title=" + escape (titleText);
}
   document.write ("<A class='ctrpcLnk'  HREF='http://www.indogram.com/index.html?city=" + city + "&cityName=" + escape (cityName) + "&basedir=" + basedir + "&centerpiece="+ ctrpiece  + titleTxt + "'>");
   document.write (content + "</A>" + ((dots) ?   "&nbsp;&middot;&nbsp;":""));
}

		function setMapArea (xl,yt,xr,yb,city, cityName) {
var cityFullName = cityName;
if (city=='rdu')
	cityName="Raleigh-Durham, NC";
if (city=='oak')
	cityName="Oakland-Fremont, CA";
if (city=='dfw')
	cityName='Dallas-Ft. Worth, TX';
				 document.write ("\n<AREA SHAPE=\"RECT\"  COORDS=\"" + xl + "," + yt + "," + xr + "," + yb + "\"" 
				 						+ " ALT=\"" + cityName + "\" " 
										+ " TITLE=\"" + cityName + "\" " 
				  						+ " HREF=\"http://www.indogram.com/index.html?title=" + escape ("Event Calendar in " + cityName) + "&city=" + city + "&cityName=" + escape (cityName) + "\">");
		}

function setCenterpiece2 (ctrpiece, content, dots, titleText) {
//=========================================================================
var titleTxt = "";
if (arguments.length > 3) {
	titleTxt = titleText;
if (titleTxt.indexOf ("%20") != -1)
	titleTxt = "&title=" + titleText;
else
	titleTxt = "&title=" + escape (titleText);
}
   document.write ("<A class='mainMenu' HREF='http://www.indogram.com/index.html?city=" + city + "&cityName=" + escape (cityName) + "&basedir=" + basedir + "&centerpiece="+ ctrpiece  + titleTxt + "'>");
   document.write (content + "</A>" + ((dots) ?   "&nbsp;&middot;&nbsp;":""));
}

		function setMapArea (xl,yt,xr,yb,city, cityName) {
var cityFullName = cityName;
if (city=='rdu')
	cityName="Raleigh-Durham, NC";
if (city=='oak')
	cityName="Oakland-Fremont, CA";
if (city=='dfw')
	cityName='Dallas-Ft. Worth, TX';
				 document.write ("\n<AREA SHAPE=\"RECT\"  COORDS=\"" + xl + "," + yt + "," + xr + "," + yb + "\"" 
				 						+ " ALT=\"" + cityName + "\" " 
										+ " TITLE=\"" + cityName + "\" " 
				  						+ " HREF=\"http://www.indogram.com/index.html?title=" + escape ("Event Calendar in " + cityName) + "&city=" + city + "&cityName=" + escape (cityName) + "\">");
		}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//					Menu
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//Global Variables
var linkArray = new HashTable();
var currentDoc = null;
var myMenu;
var divId ="";

var nn6 = document.getElementById;
var ie = document.all;
var otherBrowser = !(nn6 || ie);


//=========================================================================
function drawSubmenuItem () {
//=========================================================================
		var titleTxt = ""; 
		if (this.link.indexOf ("__") == -1) 
			titleTxt = "&title=" + escape (this.titleText + " in " + cityName);
		
        return ("<br><A class='mainMenu'   HREF='http://www.indogram.com/index.html?centerpiece=" + this.link   + 
			   titleTxt +  
			   "&city=" + city + "&basedir=" + basedir + "&cityName=" + escape (cityName) + "'><span class=subMenuItem>" + 
			   this.name + "</span></A><span class=bkg>&#133;</span>&nbsp;&nbsp;");															   
}

//=========================================================================
function SubmenuItem (name, link, titleText) {
//=========================================================================
		 this.name = name;
		 this.link = link;
		 this.draw = drawSubmenuItem;
		 this.titleText = titleText;
}
//=========================================================================
function addSubmenuItem (subMenuText, subMenuLink, titleText) {
//=========================================================================
		 var sub = new SubmenuItem (subMenuText, subMenuLink, titleText);
		 this.subArray[this.subArray.length] = sub;
}
//=========================================================================
function drawMenuItem () {
//=========================================================================
         var str = "";
		 if (this.link!= "#") {// Single level menu 
		 		var titleTxt = ""; 
				if (this.link.indexOf ("__") == -1) 
				   titleTxt = "&title=" + escape (this.titleText + " in " + cityName);
		 	str = "<A class='mainMenu' HREF='http://www.indogram.com/index.html?city=" + city 
				  	  + titleTxt 
				  	  + "&cityName=" + escape (cityName) + 
				  	  "&basedir=" + basedir + "&centerpiece=" + this.link + "'>" 
					  + this.name + "</A><span class=bkg>&#133;</span>&nbsp;&nbsp;";
		 }
		 else {
		 	if (!otherBrowser)												   																		   			
		 	   str = "<A class='mainMenu' HREF='" + 
				   this.link + "' onclick='handleClick(\"" + 
					  this.linkid + "\");'>" +  (this.name) + "<\/A>" + (this.expand ? "<span class=bkg>&#133;</span>"
					  			   : "<span style='color: gray'>&#133;</span>") + "&nbsp;&nbsp;";
			else
				str = this.name + "&nbsp;&nbsp;&nbsp;&nbsp;";
		 	if (this.expand) {
			  for (var i = 0; i < this.subArray.length; ++i)
			  	  str += this.subArray[i].draw();
			}				  
		 }															   		 
		str += "<BR><BR>";
//		 str += "<HR noshade  height=0 color=white>";
		 
    	 return str;
}
//=========================================================================
function MenuItem (name, expand, link, linkid, titleText) {
//=========================================================================
		 this.name = name;
		 this.expand = (otherBrowser?true:expand);	// Always expand for NN4 type browsers
		 this.link = link;
		 this.linkid = linkid;
		 this.subArray = new Array();
		 this.addSubmenuItem = addSubmenuItem;
		 this.draw = drawMenuItem;
		 if (arguments.length > 4)
		 	this.titleText = titleText;
}

function drawMainMenuItem () {
	var str = "<A class=mainMenu HREF='http://www.indogram.com/index.html?city=" + this.city + "&cityName=" + escape (this.cityName) + "'>" + this.name + "</A>&nbsp;&nbsp;<BR>";
	return str;
}
function MainMenuItem (name, city) {
if (city == 'dfw')
	this.cityName='Dallas-Ft. Worth, TX';
if (city =='bay')
	this.cityName='the Bay Area, CA';
	this.name = name;

	this.city = city;
	this.cityName = name;
	if (city == 'bay'){ 
		this.cityName = 'the Bay Area, CA';
	}
	if (city == 'dfw'){ 
		this.cityName = 'Dallas-Ft. Worth, TX';
	}
	if (city == 'rdu'){ 
		this.cityName = 'Raleigh-Durham, NC';
	}
	this.draw = drawMainMenuItem;
	cityName = this.cityName;
}
//=========================================================================
function addMenuItem (menuItem) {
//=========================================================================
		 this.array[this.array.length] = menuItem;
}
//=========================================================================
function drawMenu (divId) {
//=========================================================================
		 var str = "<BR>";
		 for (var i = 0; i < this.array.length; ++i)
		 	 str += this.array[i].draw();
		 var doc = null;
		 if (otherBrowser) {
		 	document.write (str);
		 }
		 else {
		 	 if (document.getElementById)
		 	 	doc = document.getElementById (divId);
		 	 else
		 	 	 if (document.all)
			 	 	doc = document.all[divId];			
		 	 doc.innerHTML = str;
		 }
}
//=========================================================================
function Menu () {
//=========================================================================
		 this.array = new Array();
		 this.addMenuItem = addMenuItem;
		 this.drawMenu = drawMenu;
}

//=========================================================================
function handleClick (linkName) {
//=========================================================================
		 var menuItem = linkArray.get (linkName);
		 menuItem.expand = !menuItem.expand;
		 
		 myMenu.drawMenu(divId);
}




