function getMenuItem(t,u,n,i) {
var a = document.createElement("a");
a.setAttribute("href", u);

if (n == 1) a.setAttribute("target", "_blank");

a.appendChild(document.createTextNode(t));

var li = document.createElement("li");
if (i == 1) li.setAttribute("class", "dir");

li.appendChild(a);
return li;	
}

function generateMenu() {
var menulist = document.getElementsByName("menuulnav")[0];
var root = "http://www.capitaspinnacle.com/";
var pages = root+"pages/";
var about = pages+"about/";
var products = pages+"products/";
var platform = pages+"platform/";

if (!menulist) {
	// above wont work for IE
	elems = document.getElementsByTagName("ul");
	for (i=0; i<elems.length; i++) {
		if (elems[i].id == "nav") {
			menulist = elems[i];
			break;
			}
	}
}
if (menulist) {
	menulist.appendChild(getMenuItem("Home",root,0,0));		

	var submenu = getMenuItem("About Us", href=about+"about.html", 0, 1);
	var ul = document.createElement("ul");
	ul.appendChild(getMenuItem("Mission Statement",about+"statement.html",0,0));		
	ul.appendChild(getMenuItem("Leadership Team",about+"team.html",0,0));		
	ul.appendChild(getMenuItem("Information Kit",about+"informationkit.html",0,0));		
	ul.appendChild(getMenuItem("Contact Us",about+"contactus.html",0,0));						
	submenu.appendChild(ul);
	menulist.appendChild(submenu);

	submenu = getMenuItem("Products", href=products+"products.html", 0, 1);
	ul = document.createElement("ul");
	ul.appendChild(getMenuItem("Life Insurance",   products+"insurance.html",0,0));		
	ul.appendChild(getMenuItem("Annuities",        products+"annuities.html",0,0));		
	ul.appendChild(getMenuItem("Life Settlements", products+"settlements.html",0,0));
	ul.appendChild(getMenuItem("LTC",              products+"ltc.html",0,0));
	ul.appendChild(getMenuItem("Quick Life",       products+"quicklife.html",0,0));
	ul.appendChild(getMenuItem("Disability Income",products+"disability.html",0,0));						
	submenu.appendChild(ul);
	menulist.appendChild(submenu);

	submenu = getMenuItem("Platform", href=platform+"platform.html", 0, 1);
	ul = document.createElement("ul");
	ul.appendChild(getMenuItem("Case Design",       platform+"casedesign.html",0,0));		
	ul.appendChild(getMenuItem("Advanced Marketing",platform+"planning.html",0,0));		
	ul.appendChild(getMenuItem("Case Management",   platform+"management.html",0,0));		
	submenu.appendChild(ul);
	menulist.appendChild(submenu);

	menulist.appendChild(getMenuItem("Licensing",    pages+"licensing.html",0,0));
	menulist.appendChild(getMenuItem("Broker Dealer",    pages+"brokerdealer.html",0,0));
	menulist.appendChild(getMenuItem("Testimonials",     pages+"testimonials.html",0,0));
	menulist.appendChild(getMenuItem("Producers Center", pages+"producerscenter.html",0,0));	
	menulist.appendChild(getMenuItem("Events & Programs",pages+"eventsandprograms.html",0,0));			
}
}


