var newSpan = ("<span></span>");
var newDiv = ("<div></div>");
var newImg = ("<img></img>");
var newA = ("<a></a>");
var menuPos = {};
var msie = $.browser.msie?'_ieHack':'';

	$(window).resize(function() {

		menuPos = $("#whiteBar").offset();
	
	});

	$(document).ready(function() {

	menuPos = $("#whiteBar").offset();

	$(newDiv).attr("id","menu1Trigger").attr("class","menuTopText").addClass("topMenuCommon").addClass("tmc" + msie).css("left", "250px").html("US").appendTo("#whiteBar");
	$(newDiv).attr("id","menu2Trigger").attr("class","menuTopText").addClass("topMenuCommon").addClass("tmc" + msie).css("left", "350px").html("CONNECT").appendTo("#whiteBar");
	$(newDiv).attr("id","menu3Trigger").attr("class","menuTopText").addClass("topMenuCommon").addClass("tmc" + msie).css("left", "450px").html("SERVE").appendTo("#whiteBar");
	$(newDiv).attr("id","menu4Trigger").attr("class","menuTopText").addClass("topMenuCommon").addClass("tmc" + msie).css("left", "550px").html("RESOURCES").appendTo("#whiteBar");
	$(newDiv).attr("id","menu5Trigger").attr("class","menuTopText").addClass("topMenuCommon").addClass("tmc" + msie).css("left", "650px").html("CONTACT").appendTo("#whiteBar");
	



    $("div .topMenuCommon").hover(
      function () {
	    $(this).addClass("topMenuHover");
		$(newDiv).attr("id","currentMenu").addClass("dropMenu").html("").appendTo(this);
		buildMenu(this.id);
      }, 
      function () {
	    $(this).removeClass("topMenuHover");
        $(this).find("div:last").remove();
      }
    );



	});

function buildMenu(foo) {
	var menuIndex = parseInt(foo.substr(4,1));
	var menuLinks = new Array();

	switch(menuIndex)	
	{
		case 1:
			menuLinks[0] = "VISION";
			menuLinks[1] = "NANUET";
			menuLinks[3] = "vision.php";
			menuLinks[4] = "nanuet.php";
		break;
		case 2:
			menuLinks[0] = "EVENTS";
			menuLinks[1] = "MAILING LIST";
			menuLinks[3] = "events.php";
			menuLinks[4] = "mailinglist.php";
		break;
		case 3:
			menuLinks[0] = "COMMUNITY";
			menuLinks[1] = "CHURCH";
			menuLinks[3] = "community.php";
			menuLinks[4] = "church.php";
		break;
		case 4:
			menuLinks[0] = "SERMONS";
			menuLinks[1] = "READING";
			menuLinks[3] = "sermons.php";
			menuLinks[4] = "reading.php";
		break;
		case 5:
			menuLinks[0] = "STAFF";
			menuLinks[1] = "DIRECTIONS";
			menuLinks[3] = "staff.php";
			menuLinks[4] = "directions.php";
		break;
		}

	 $(newImg).attr("src","images/currentMenu.png").appendTo("#currentMenu");
	 $("<BR />").appendTo("#currentMenu");
	 $(newA).attr("href",menuLinks[3]).html(menuLinks[0]).appendTo("#currentMenu");
	 $("<HR />").attr("color","#FFFFFF").attr("width","90").attr("size","1").appendTo("#currentMenu");
	 $(newA).attr("href",menuLinks[4]).html(menuLinks[1]).appendTo("#currentMenu");
	 $("<BR />").appendTo("#currentMenu");
	 $(newImg).attr("src","images/spacer.gif").attr("width","10").attr("height","10").appendTo("#currentMenu");


}

