$(document).ready(function(){
  /* Board */
  $('#board marquee').marquee('pointer').mouseover(function (){
    $(this).trigger('stop');
  }).mouseout(function (){
    $(this).trigger('start');
  }).mousemove(function (event){
    if ($(this).data('drag') == true){
      this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
    }
  }).mousedown(function (event){
    $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
  }).mouseup(function (){
    $(this).data('drag', false);
  });  
  
  /* About page */  
  $("a[rel=interior]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Интерьер ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
  
  /* Gallery page */
  $("a[rel=view]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">'+ $('h1').text() +' ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
  
  /* Events Tabs */
  $(".css-tabs:first").tabs(".css-panes:first > div.panTab");  

  /* Rand photo */
  $("#scroller").scrollable({circular: true}).autoscroll({autoplay: true});
  
  /* Events */
  $("#events1").scrollable({circular: false, mousewheel: true}).autoscroll({autoplay: false});
  $("#events2").scrollable({circular: false, mousewheel: true}).autoscroll({autoplay: false});
  //$("#events3").scrollable({circular: false, mousewheel: true}).autoscroll({autoplay: false});
  
  /* Teaser tooltip */
  $("div.teaser img[title]").tooltip({offset: [10, 2], effect: 'slide'}).dynamic({bottom:{direction:'down', bounce:true}});    
});
