﻿new function() {

	tilt.attachEvent(document, "layout", function() {
		document.body.className = "l-inner";

		var audiences = estrada.grab(document.getElementById("l-navigation"), { audiences: "result" }).result;
		if (audiences) {
			audiences = audiences[0];
			createSelectBox(audiences);
		}

		function createSelectBox(target) {
			var html = ""
			var currentUrl;
			estrada.unh = {};
			estrada.unh.go = function(url) {
				if (url) {
					window.location = url;
				}
			}
			foreach(target.getElementsByTagName("a"), function(a, i) {
				var isCurrent = a.className == "current";
				if (isCurrent) {
					currentUrl = a.href;
				}
				html += "<option value=\"" + a.href + "\"" + (isCurrent ? " selected" : "") + ">" + a.innerHTML + "</option>";
			})
			target.innerHTML = "<h3>UNH INFORMATION FOR:</h3><select onchange=\"estrada.unh.go(this.value)\">" + (currentUrl ? "" : "<option value=\"\">SELECT ONE</option>") + html + "</select";
			return currentUrl;	
	
		}


	})
}