
$(function() {

  var lang = "de";
  if( document.URL.match(/\/en\//) ) {
    lang = "en";
  }

  // external pages
  $('a[rel=external]').attr("target", "_blank");

  // manage multipage
  $('#main div.page').each( function(i) { 

    // hide all but first
    if (i != 0 ) 
      $(this).hide(); 

    // add page nav container
    $('.subcl', $(this)).append('<div class="pagenav"></div>');

    // add back
    if (i > 0) 
      $('.pagenav', $(this)).append('<span class="back"><a href="javascript:page(' + (i - 1) + ');">' + (lang == "en" ? "Previous" : "Zur&uuml;ck") + '</a></span>');

    // add forward
    if (i < $('#main div.page').length - 1) 
      $('.pagenav', $(this)).append('<span class="more"><a href="javascript:page(' + (i + 1) + ');">' + (lang == "en" ? "Next" : "Weiter") + '</a></span>');

  });

  // hover effects in p.more_this
  $('#main div.more_this').hide();
  $('#main p.more_this').hover(
    function(){
      $('#main div.more_this').hide();
      $(this).next('div.more_this').fadeIn('slow');
    }, 
    function(){ }
  );
  $('#main div.textbox').hover(
    function(){ },
    function(){
      $('div.more_this', $(this)).fadeOut('slow');
    }
  );

  // popups
  $("a[rel^='popup']").prettyPopin({
			modal: false,
			width: false,
			height: false,
			opacity: 0.5,
			animationSpeed: 'fast',
			followScroll: true, 
			loader_path: '/images/prettyPopin/loader.gif',
			callback: function(){}
		});



});

function page (p) {
  $('#main div.page').each( function(i) { 
    if (i == p ) { $(this).show(); } else { $(this).hide();  }
  });
}


