var contentWidth = parseInt($('#content').width()); 








$(function(){
  
  
  /*
  $('#products').mouseenter(function(){
      $('#nav-products').fadeIn();
  });
  
  
  $('#products').mouseleave(function(){
      $('#nav-products').fadeOut();
  });
  */
  
  
  
  function repositionCenter()
  {
    var wrapperHeight = $('#wrapper').height();
    var windowHeight = $(window).height();
    
    if(windowHeight > wrapperHeight)
    {
      var marginTop = parseInt((windowHeight - wrapperHeight) / 2 - 10);
      $('#wrapper').css({marginTop: marginTop + 'px' });
    }
    else
    {
      var marginTop = 0;
      $('#wrapper').css({marginTop: marginTop + 'px' });
    }
    
    contentWidth = parseInt($('#content').width()); 
  }
  
  repositionCenter();
  
  $(window).resize(function () { 
    repositionCenter(); 
    });

  
  $("#nav li.main").hoverIntent({
        over: function(){
          var li = $(this);
          $("#nav li.hover").removeClass('hover');
          li.find('.subnavigation').css({left: li.left + 'px'}).fadeIn(function(){
            li.addClass('hover');
          });
        }, 
        timeout: 10, 
        out: function(){
          var li = $(this);          
          li.find('.subnavigation').fadeOut(function(){
            li.removeClass('hover');
          });
          //li.removeClass('hover');
          //setTimeout(function(){li.removeClass('hover');}, 500);
          
        }
  });
  
  
  
  $("#lang").hoverIntent({
        over: function(){
          var li = $(this);
          li.find('.noactive').fadeIn(function(){
            li.addClass('hover');
          });
        }, 
        timeout: 10, 
        out: function(){
          var li = $(this);
          li.find('.noactive').fadeOut(function(){
            li.addClass('hover');
          });
        }
  });
  
  
  
  
  

});




var RotateTimeoutNews = null;
var AutoRotateNews = true;

$(function(){
  
  $('#small-preview-news a.item.current').show();
  setTimeout(RotateNews, 5000);
  
  $('#small-preview-news a.next').click(function(){
    
    if($('#small-preview-news-items').is(':animated'))
    {
      //return false;  
    }
    
    RotateNews();
    return false;
  });
  
  $('#small-preview-news a.prev').click(function(){
    if($('#small-preview-news-items').is(':animated'))
    {
      //return false;  
    }
    
    RotateReverse();
    return false;
  });
  
  $('#small-preview-news').mouseenter(function(){
    clearTimeout(RotateTimeoutNews);
    AutoRotateNews = false;
    $(this).addClass('hover');
  });
  
  $('#small-preview-news').mouseleave(function(){
    setTimeout(RotateNews, 5000);
    AutoRotateNews = true;
    $(this).removeClass('hover');
  });
});

function RotateNews(){
  clearTimeout(RotateTimeoutNews);
  
  var first = $('#small-preview-news a.item:first');
  var last = $('#small-preview-news a.item:last');
  first.insertAfter(last)
  $('#small-preview-news-items').css({marginTop: '0px'});
  
  $('#small-preview-news-items').stop().animate({
    marginTop: '-=24px'
  }, 500, function() {

  });
  if(AutoRotateNews)
  {
    RotateTimeoutNews = setTimeout(Rotate, 5000);
  }
}

function RotateReverse(){
  clearTimeout(RotateTimeout);
  
  var first = $('#small-preview-news a.item:first');
  var last = $('#small-preview-news a.item:last');
  last.insertBefore(first)
  $('#small-preview-news-items').css({marginTop: '-24px'});
  
  $('#small-preview-news-items').stop().animate({
    marginTop: '+=24px'
  }, 500, function() {

  });
  if(AutoRotateNews)
  {
    RotateTimeout = setTimeout(RotateNews, 5000);
  }
}



