$(function(){
	// menu -------------------------------------------------------------------
	Cufon.replace('h1, h2, h3, p, a, label');	
	Cufon.replace('li', 	{hover:true, hoverables: { li: true, a: true , div:true} });	
	
	
	var $activeLink = $(".active>a");	
	var mode = $(document).getUrlParam("mode");
	var $activeBox = {};
	switch (mode){
		case "showInfo":
			$activeBox = $("#info");
			$activeLink = $("#moreInfoLink");
			break;
		case "screenSaver":
			$activeBox = $("#screenSaver");	
			$activeLink = $("#screenSaverLink");
			break;}
	
	
	var currentPage = window.location.pathname;
	// if we're at home
	if (currentPage.indexOf("index")!=-1|| currentPage.indexOf(".php") == -1){
		$("#moreInfoLink").click(function() {
			if($activeBox != null && $activeBox.is(":visible")){
				closeTheBox();
				if ($activeBox.attr('id') != $("#info").attr('id')) {
					openBox("#info", "#moreInfoLink");	
				} 
			} else {
				openBox("#info", "#moreInfoLink");
			}
	
			return false;
		});
		$("#screenSaverLink").click(function () {
			if($activeBox != null && $activeBox.is(":visible")){
				closeTheBox();
				if ($activeBox.attr('id') != $("#screenSaver").attr('id')){
				 	openBox("#screenSaver", "#screenSaverLink");
				}

			} else {
				openBox("#screenSaver", "#screenSaverLink");
			}
			return false;
		})
		$("#allGifsLink").click(function() {
			closeTheBox();
			return false;
		});
	}

	activateLink = function(_l){	
		$activeLink.parent().removeClass("active");
		$(_l).parent().addClass("active");
		$activeLink = $(_l);	
	}

	openBox = function(_box, _boxLink) {
		$(_box).slideDown();
		$activeBox = $(_box);
		activateLink(_boxLink);
	}
	
	closeTheBox = function () {
		if($activeBox)$activeBox.slideUp();
		activateLink("#allGifsLink");
	}
	
	$("#closeBox").click(function() {
		closeTheBox();
	})
	
	$(".comingSoonImg").hide();
	
	$("#header").click(function () {
		window.location.href = "index.php";
	});

});

