$(document).ready(function() {
  var distances;
  
  if (env.lang == 'en') {
    distances = {
      teaser : 185,
      story : 331,
      diary : 516,
      downloads : 738
    };
  } else {
    distances = {
      teaser : 185,
      story : 310,
      diary : 508,
      downloads : 730
    };
  }
  
  $("#link-teaser").click(function() {
    $('#silverscreen').scrollTo('0px', 500, {axis:'x'});
    $('#arrow').animate({ 
        left: "" + distances.teaser + "px"
      }, "500");
    _gaq.push(['_trackPageview', '/page/front']);
  });
  $("#link-story").click(function() {
    $('#silverscreen').scrollTo('1100px', 500, {axis:'x'});
    $('#arrow').animate({ 
        left: "" + distances.story + "px"
      }, "500");
    _gaq.push(['_trackPageview', '/page/story']);
  });
  
  $("#link-diary").click(function() {
    $('#silverscreen').scrollTo('2200px', 500, {axis:'x'});
    $('#arrow').animate({ 
        left: "" + distances.diary + "px"
      }, "500");
    _gaq.push(['_trackPageview', '/page/diary']);
  });
  $("#link-downloads").click(function() {
    $('#silverscreen').scrollTo('3300px', 500, {axis:'x'});
    $('#arrow').animate({ 
        left: "" + distances.downloads + "px"
      }, "500");
    _gaq.push(['_trackPageview', '/page/downloads']);
  });
  
  $(".videothumb", "#slide-diaries").click(function(e) {
    e.preventDefault();
    $("#videoplayer").fadeOut(50);
    var videoid = $(this).attr('rel');
    $("#videoplayer").html('<object width="320" height="240" ><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.facebook.com/v/' + videoid + '" /><embed src="http://www.facebook.com/v/' + videoid + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="320" height="240"></embed></object>');
    setTimeout(function() { $("#videoplayer").fadeIn(500); }, 1100);
    _gaq.push(['_trackEvent', 'FBVideo', 'clicked']);
  });
   
  $("#navi-facebook").click(function() {
    _gaq.push(['_trackPageview', '/ext/facebook']);
  });
  
  $("#navi-press").click(function() {
    _gaq.push(['_trackPageview', '/ext/press']);
  });
  
  $("#navi-restricted").click(function() {
    _gaq.push(['_trackPageview', '/restricted']);
  });
  
  $("#navi-contact").click(function() {
    _gaq.push(['_trackPageview', '/ext/contact']);
  });
  
  $(".track").click(function() {
    _gaq.push(['_trackPageview', $(this).attr('rel')]);
  });
  
});