$(document).ready(function(){

	topMenu();
});

$(function(){
  $("a[rel=fancybox-group]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
      
  $("a.fancybox,a[rel=fancybox]").fancybox({
				'overlayShow'	: false,
				'transitionIn'	: 'elastic',
				'transitionOut'	: 'elastic'
			});
});

function topMenu(){
  $('#navigation ul li ul').parent().addClass('sub').append('<span class="sub-icon">&nbsp;</span>');
  $('#navigation > ul > li').hover(function(){
    $(this).addClass('active');
    $(this).children('ul').show();
  },function(){
    $(this).removeClass('active');
    $(this).children('ul').hide();
  });
  
  var location = $('h3.title').text();
  $('#topnav ul li a').filter(function() {
      return $(this).text() == location;
  }).addClass('focus');
}

$(function accordionFeatures(){
    var parent = $('.accordion li');
    //parent.eq(0).children('.content').show();
    parent.children('.title').click(function(){
        parent.children('.content').slideUp();
        $(this).next('.content').slideDown();
        return false;
    });
});

$(function scrollTop(){
    $('#scrolltop').click(function(){
        $('html').animate({
            scrollTop: $("#header").offset().top
            }, 1000);
        return false;
    });
});

$(function zoomThumbnail(){    
    $('.thumbnail.fancybox').append('<span class="zoom">&nbsp;</span>');
    $('.thumbnail.fancybox').hover(function(){
        var imageWidth  = parseInt($(this).width()),
            imageHeight = parseInt($(this).height());
        $(this).children('span.zoom').css({
            'top'   : imageHeight /2 - 15,
            'left'  : imageWidth /2 - 15
        });
        $(this).children('span.zoom').fadeIn();
        $(this).children('img').animate({'opacity':'0.5'});
    },function(){
        $(this).children('span.zoom').fadeOut();
        $(this).children('img').animate({'opacity':'1'});
    });
});
