/* [/web/js/navigation.js] */

var navLastClickedButton = null;
var lastSection = "";

Event.observe(window, 'load', function() {
	var f = function() {
		if (!$("Nav")) {
			setTimeout(f, 500);
			return;
		}

		setTimeout(function() {
			$("Header").setStyle({ visibility: "inherit" });
		}, 3000);
		
		setTimeout(function() {
			$$(".Facebook")[0].setStyle({ visibility: "inherit" });
			$$(".Twitter")[0].setStyle({ visibility: "inherit" });
			
			// $("Footer").setStyle({ visibility: "inherit" });
			// $("Support").setStyle({ visibility: "inherit" });
		}, 6000);
		
		$$("#Nav a").each(function(item) {
			if (item.href != "" && !item.hasAttribute("target")) {
				item.setAttribute("_href", item.href);
				item.onclick = function() { 
					if (item.getAttribute("_href").indexOf("book") > -1) {
						lastSection = "book";
					} else {
						lastSection = "other";
					}
					
					$$(".Loading")[0].style.display = "block";
					$("frame").src = item.getAttribute("_href");
					
					if (navLastClickedButton != null) {
						var prnt = navLastClickedButton.parentNode;
						prnt.removeClassName("On");
						prnt.className = prnt.className.substr(0, prnt.className.length - 2);
					}
					
					item.parentNode.className = item.parentNode.className + "On On";
					navLastClickedButton = item;
				}
				
				item.removeAttribute("href");
			}
		});
	}
	
	f();
});

function relocateIFrame() {
	if (lastSection == "book") {
		$("frame").setStyle({ position: "relative", top: "-242px" });
	} else {
		$("frame").setStyle({ position: "relative", top: "0px" });
	}
}

function hideLoader() {
	$$(".Loading")[0].style.display = "none";
	
	new Effect.Appear($("frame"), {
		duration: 0.8,
		from: 0,
		to: 0.999999,
		afterFinish: function() {
			pageStarted = true;
		}
	});
}

function showLoader() {
	$$(".Loading")[0].style.display = "block";
	$("frame").setOpacity(0);
}