$(function(){
	
// position sub cat UL in center

 var subUlWidth = $('#subpages ul').width();
 var subUlHeight = $('#subpages ul').height();
 $('#subpages').css('margin-top', -(subUlHeight/2));
 $('#subpages').css('margin-left', -(subUlWidth/2));	
 var contentHeight = $('#content').height();
 $('#content').css('margin-top', -(contentHeight/2));
 
 var total = $('#gallery .item a img').length;  
 var counter = '1 / '+ total;
 $('#myTitle .counter').text(counter);
 $('li.main').mouseover(function(event) {
  $(this).find('ul.sub')
   .stop()
   .animate(
    { opacity: 1 }, {
     duration: 'slow',
     easing: 'easeOutBack'
    });
 });
 $('li.main').mouseout(function(event) {
  $(this).find('ul.sub')
   .stop()
   .animate(
    { opacity: 0 }, {
     duration: 'slow',
     easing: 'easeOutBack'
    });
 });
 $('#gallery .item a img').mouseover(function(){
	$(this).stop().addClass('shadow')
	.animate(
    { width: '120%', height: '120%', top: '-10%', left: '-10%' }, {
     duration: 'slow',
     easing: 'easeOutBack'
    });
 });
 $('#gallery .item a img').mouseout(function(){
	$(this).stop().removeClass('shadow')
	.animate(
    { width: '245', height: '138', top: '0', left: '0' }, {
     duration: 'slow',
     easing: 'easeOutBack'
    });
 }); 
 $('#gallery .item a[rel=image]').click(function(){
   var index = $('#gallery .item a').index(this)+1;
   api.goTo(index);
   var slideTitle = api.getField('title');
   $('#myTitle .left').text(slideTitle);
   counter = vars.current_slide+1 +' / '+ total;
   $('#myTitle .counter').text(counter);
   $('#gallery').hide('slow');
   $('#fullscreen').show('slow');
 });
 $('#gallery .item a[rel=video]').fancybox({
			'width'				: '85%',
			'height'			: '85%',
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'titleShow'			: false
 });
 $('#myTitle .prev').click(function(){
   api.prevSlide();
   var slideTitle = api.getField('title');
    $('#myTitle .left').text(slideTitle);
    counter = vars.current_slide+1 +' / '+ total;
    $('#myTitle .counter').text(counter);
 });
 $('#myTitle .next').click(function(){
   api.nextSlide();
   var slideTitle = api.getField('title');
    $('#myTitle .left').text(slideTitle);
    counter = vars.current_slide+1 +' / '+ total;
    $('#myTitle .counter').text(counter);
 }); 
 $('#arrow-left').click(function(){
   api.prevSlide();
   var slideTitle = api.getField('title');
    $('#myTitle .left').text(slideTitle);
    counter = vars.current_slide+1 +' / '+ total;
    $('#myTitle .counter').text(counter);
 });
 $('#arrow-right').click(function(){
   api.nextSlide();
   var slideTitle = api.getField('title');
    $('#myTitle .left').text(slideTitle);
    counter = vars.current_slide+1 +' / '+ total;
    $('#myTitle .counter').text(counter);
 }); 
 $('#myTitle .close').click(function(){
   $('#gallery').show('slow');
   $('#fullscreen').hide('slow');
 }); 
});
