
  /* Main function
  - - - - - - - - - - - - - - - - */
  $.euroas.photos = function() {
  
    // Expand default args
    arg = $.extend($.euroas.photos.defaults, arguments[0] || {});
  
    // Don't act on absent elements
    if (!$(arg.element).length) return this;
    
  	$(arg.element)
      .find('img:not(.main)')
      .parent()
        .click($.euroas.switchPhotos)
  
  	$(arg.element)
      .find('img.main')
      .parent()
        .css({'position': 'relative', 'display': 'block'})
        .append('<div class="zoom-hover" />')
        .find('.zoom-hover').css({ opacity:0 }).end()
        .bind({
          mouseover: function() {
            height  = $('img', this).height();
            width   = $('img', this).width();
            offsetY = $('img', this).outerHeight() - height;
            offsetX = $('img', this).outerWidth() - width;
            
            $('.zoom-hover', this).css({ height: height, width: width, top: offsetY/2, left: offsetX/2 }).stop().animate({ opacity:.3 }, 200); },
          mouseout: function() {
            $('.zoom-hover', this).stop().animate({ opacity:0 }, 400); }
          })
        .fancybox({
          'transitionIn'    : 'elastic',
          'transitionOut'   : 'elastic',
          'easingIn'        : 'easeOutBack',
          'easingOut'       : 'easeInBack',
          'speedIn'         : 600,
          'speedOut'        : 200,
          'overlayColor'    : '#000',
          'titlePosition'   : 'over' });
  };
  
  
  /* Default arguments & variables
  - - - - - - - - - - - - - - - - */
  $.euroas.photos.defaults = {
    element : '.photos',
  };
  
  
  /* Switch photos
  - - - - - - - - - - - - - - - - */
  $.euroas.switchPhotos = function() {
  
    $elem = $(this);
    url   = $elem.attr('href');
    main  = $('img.main').attr('src');
    
    if (url != main)
      $('img.main')
        .attr('src', url)
        .parent()
          .attr('href', url.replace(/\/small/, ''));
    
    return false;
  };
