if (!btbCookies) {
	var btbCookies = new CookieJar({
		expires: 604800,	// 1 week
		path: "/"	// all subdirectories
		// domain: "www.broaderthanbroadway.com"
	});
	// window.alert("CookeJar created.");
}

function setCookie(boolean) {
	var tabbedBrowsing = {
		tabbing: boolean
	};
	btbCookies.put("myTabbedSettings", tabbedBrowsing);
}

function resetSubNavs() {
	$("topLogo").setStyle({
		marginLeft: "0",
		position: "absolute",
		left: "25px"
	});
	/*$("tab").setStyle({
		marginLeft: "0",
		position: "absolute",
		left: "20px"
	});*/
	$("topNav").setStyle({
		marginLeft: "0",
		backgroundPosition: "left bottom",
		position: "absolute",
		left: "0"
	});
	$A($$("#topNav li.intro, #topNav li.skills, #topNav li.projects, #topNav li.code, #topNav li.bio")).each(function(li) {
		if (ie7 == true || ie6 == true) {
			li.setStyle("min-height: 73px; height: auto !important; height: 73px;");
		} else {
			li.setStyle("height: auto;");
		}
	});
	$$("#topNav li ul.subNav").each(function(ul) {
		ul.setStyle({
			width: "auto",
			height: "auto",
			backgroundColor: "transparent"
		});
		Move.element(ul, ul.up(1), "move");
		ul.previous().remove();	// <div class="subNavWrap"></div>
		ul.previous().remove();	// <a href='#' title='Close this sub-navigation for this section' class='ocSubOpen'></a>
		ul.previous().remove();	// <a href='#' title='Open this sub-navigation for this section' class='ocSubClosed'></a>
	});
	$$("#topNav li ul.subNav li").each(function(li) {
		li.setStyle({
			paddingTop: "2px",
			float: "none"
		});
	});
}

function tabNow() {
	setCookie(true);
	resetSubNavs();
	// var myTabbedSettings = btbCookies.get("myTabbedSettings");
	// window.alert(btbCookies.get("myTabbedSettings").tabbing);
	$("tab").writeAttribute("href", "javascript:clickNow();").writeAttribute("title", "Enable mouse browsing").update("Enable mouse browsing");
}
function clickNow() {
	setCookie(false);
	setSubNavs();
	repositionFixed();
	// var myTabbedSettings = btbCookies.get("myTabbedSettings");
	// window.alert(btbCookies.get("myTabbedSettings").tabbing);
	$("tab").writeAttribute("href", "javascript:tabNow();").writeAttribute("title", "Enable tabbed browsing").update("Enable tabbed browsing");
	if (ie7 == true || ie6 == true) {
		$$("#topNav li img.ocSub").each(function(img) {
			img.setStyle({
				bottom: "3px"
			});
		});
		$$("#topNav li div.subNavWrap").each(function(img) {
			img.setStyle({
				bottom: "3px"
			});
		});
	}
}


function setTabbedBrowsing() {
	$("topLogo").up().insert({
		before: "<a href='javascript:tabNow();' title='Enable tabbed browsing' id='tab'>Enable tabbed browsing</a>"
	});
	$("tab").observe("focus", function() {
		this.setStyle("left: 20px;");
	}).observe("blur", function() {
		this.setStyle("left: -10000px;");
	});
}