
var menudiv=document.createElement("div");

var countSlash=0;
var strLocation=document.location.toString();
var k=strLocation.indexOf(".org/new/");
if (k>-1) 
	strLocation=strLocation.substring(k+9);
k=strLocation.indexOf("/");
while (k>-1) {
	strLocation=strLocation.substring(k+1);
	countSlash++;
	k=strLocation.indexOf("/");
}

	
document.body.appendChild(menudiv);
menudiv.style.position="absolute";
menudiv.className="bx_red";
menudiv.style.display="none";

var menus=new Array();

menus[0]=new makeMenu('markets');
menus[0].addItem("Annapolis",'markets/annapolis.html');
menus[0].addItem("Bethesda",'markets/bethesda.html');
menus[0].addItem("Crystal City",'markets/crystal_city.html');
menus[0].addItem("Dupont Circle",'markets/dupont_circle.html');
menus[0].addItem("Foggy Bottom",'markets/foggy_bottom.html');
menus[0].addItem("H Street NE",'markets/h_street.html');
menus[0].addItem("Health and Human Services",'markets/health_and_human_services.html');
menus[0].addItem("Penn Quarter",'markets/penn_quarter.html');
menus[0].addItem("St. Michaels",'markets/st_michaels.html');
menus[0].addItem("Silver Spring",'markets/silver_spring.html');
menus[0].addItem("by the White House",'markets/white_house.html');
menus[0].initMenu();

menus[1]=new makeMenu('programs');
menus[1].addItem("EBT/WIC Programs",'programs/ebt_wic_programs.php');
menus[1].addItem("Chef at Market",'programs/chef_at_market.php');
menus[1].addItem("FoodPrints",'programs/foodprints.html');
menus[1].addItem("Gleaning",'programs/gleaning.html');
menus[1].initMenu();


menus[2]=new makeMenu('about_us');
menus[2].addItem("Press",'about_us/press.html');
menus[2].addItem("Distinctions",'about_us/distinctions.html');
menus[2].addItem("Staff Contact List",'about_us/staff_contact_list.html');
menus[2].addItem("Board Members",'about_us/board_members.html');
menus[2].initMenu();

menus[3]=new makeMenu('support_us');
menus[3].addItem("Farmland Feast",'support_us/farmland_feast.html');
menus[3].addItem("Volunteer",'support_us/volunteer.html');
menus[3].addItem("Combined Federal Campaign",'support_us/combined_federal_campaign.html');
menus[3].addItem("Our Supporters",'support_us/our_supporters.html');
menus[3].addItem("Our Partners",'support_us/our_partners.html');
menus[3].initMenu();
menus[4]=new makeMenu('farmers');
menus[4].addItem("Farmer/Producer Application",'farmers_producers/farmer_producer_application.html');
menus[4].addItem("Meet our Farmers/Producers",'farmers_producers/meet_our_farmers_producers.php');
menus[4].initMenu();



function showMenu(strMenu) {
	var i=0;
	var tobj=document.getElementById(strMenu);
	var x = 0;
	var y = tobj.offsetHeight;
	while (tobj.offsetParent && tobj.tagName.toUpperCase() != 'BODY') {
		x += tobj.offsetLeft;
		y += tobj.offsetTop;
		tobj = tobj.parentNode;
	}	
	x += tobj.offsetLeft;
	y += tobj.offsetTop;
	menudiv.style.left = x + 'px';
	menudiv.style.padding='0px';
	menudiv.style.top = y-12 + 'px';
	menudiv.style.display="inline";
	while (menudiv.childNodes[0]) {
	    menudiv.removeChild(menudiv.childNodes[0]);
	}
	for (i=0;i<menus.length;i++)
		if (menus[i].menuName==strMenu) 
			menudiv.appendChild(menus[i].menuTable);
	
}

function hideMenu() {
	menudiv.style.display="none";
}

function makeMenu(strName) {
	this.items=new Array();
	this.menuName=strName;
	this.menuTable=document.createElement('table');
	this.menuTable.setAttribute('cellpadding','4');
	this.menuTable.setAttribute('cellspacing','0');
	this.menuTable.setAttribute('border','0');
	this.menuBody=document.createElement('tbody');
	this.addItem=_addItem;
	this.initMenu=_initMenu;
}
function _addItem(strItemText,strItemLink) {
	var subf=countSlash;
	while (subf>0) {
		strItemLink="../"+strItemLink;
		subf--;
	}
	var tRow=document.createElement("tr");
	tRow.setAttribute('width','100%');
	var tCell=document.createElement("td");
	var tLink=document.createElement("a");
	tLink.setAttribute('href', strItemLink);
	tLink.className='link_menu';
	tLink.setAttribute('class', 'link_menu');
	tLink.innerHTML=strItemText;
	tCell.appendChild(tLink);
	tCell.onclick=function(ev) {
		document.location=tCell.childNodes[0].getAttribute('href');
	}
	tCell.onmouseover=function(ev) {
		tCell.style.backgroundColor="#672013";
		tCell.childNodes[0].style.color="#96a768";
	}
	tCell.onmouseout=function(ev) {
		tCell.style.backgroundColor="#672013";
		tCell.childNodes[0].style.color="white";
	}
	tRow.appendChild(tCell);
	this.items[this.items.length]=tRow;
	
}
function _initMenu() {
	var i=0;
	for (i=0;i<this.items.length;i++) {
		this.menuBody.appendChild(this.items[i]);		
	}	
	this.menuTable.appendChild(this.menuBody);
	
	
}