$(document).ready(function() {
  
  // assign class info-text
  // style is defined in oskar-screen and hides the informations
  // the style is missing in oskar-print - therefor it is displayed
  // $("#info").children().toggleClass("info-text");
  
  $("#navigation li a").click(function(ev) {
      var navigationLinks = $("#navigation li a").get();
      toggleNavItem($(this));
      for (i=0;i<navigationLinks.length;i++){
        if(ev.currentTarget == navigationLinks[i]) {
          var target = $("#info").children()[i];
          $(target).toggleClass("info-text");
        }
      }
			
			if($("#info div.vcard").is(":visible")) {
				$("#info #about").css('top','7.5em');
			} else {
				$("#info #about").css('top','0');
			}
			return false;
  });
  $("#info > div").click(function() {
    $(this).addClass("info-text");
    var id = "#" + this.id + "_link";
    toggleNavItem(id);
  })
  
  function toggleNavItem(id) {
    $(id).toggleClass('navigation-active');
  }
  

  // show project description on mouseover
  // unless lightbox is active
  $('.project').mouseover(function(){
    if(!$("#lightbox").is(":visible")){
      $(this).css('z-index','100');
      $(this).children('a.lightbox:first').show();
    }
  });
  
  // hide project description on mouseout
  $('.project').mouseout(function(){
    $(this).children('a.lightbox:first').hide();
    $(this).css('z-index','2');
  });

	// attach lightbox to project description
	$('.project a.lightbox').each(function(){
		$(this).lightbox({
			fitToScreen: true,
			overlayOpacity : 0,
			resizeSpeed : 0,
			borderSize : 15,
			displayTitle:false,
			imageClickClose:false,
			fileLoadingImage : 'images/ajax-loader.gif',
			strings:{
				help: ' \u2190 / P - previous image\u00a0\u00a0\u00a0\u00a0\u2192 / N - next image\u00a0\u00a0\u00a0\u00a0ESC / X - close image gallery',
				prevLinkTitle: 'previous image',
				nextLinkTitle: 'next image',
				prevLinkText:  'prev',
				nextLinkText:  'next',
				closeTitle: 'close image gallery',
				image: '',
				of: ' / '
			}
			
	  });
	  
	  // hide info texts and project description
	  // when lightbox is activated
	  $(this).click(function() {
	    // $("#info div").hide();
			$("#info").children().addClass("info-text");
	    $("#navigation li a").removeClass("navigation-active");
	    $(".project a").hide();
	    return false;
	  })
	  
	});
	
  // $(".project a").hide();
	// $("#footer").positionFooter(false);
	

});