// JavaScript Document

// background resize
jQuery(function($){
	$.supersized({
		//Background image
		slides	:  [ { image : 'images/main-bg.jpg' } ]					
	});
});



// isotope
    $(function(){
      
      var $container = $('#container');

      $('#filters').find('a').click(function(){
        // get href attribute, minus the #, plus a . to make it a class
        var filterName = '.' + $(this).attr('href').slice(1);
        filterName = filterName === '.show-all' ? '*' : filterName;
        $container.isotope({ filter: filterName })
        return false;
      });

      // change size of clicked element
      $container.find('.element').live('click', function(){
		if ($(this).is('.large')) {	
		jQuery('.expanded',this).fadeToggle("fast", "linear");  
		jQuery('.thumbed',this).fadeToggle("fast", "linear");
		jQuery('h5',this).fadeToggle("fast", "linear");
        $(this).toggleClass('large');
        $container.isotope('reLayout');
				}
	else {				
		jQuery('.large > .expanded').fadeToggle("fast", "linear");
		jQuery('.large > .thumbed').fadeToggle("fast", "linear");
		jQuery('.large > h5').fadeToggle("fast", "linear");
		$container.find('.large').removeClass('large');
		

		jQuery('.expanded',this).fadeToggle("fast", "linear");  
		jQuery('.thumbed',this).fadeToggle("fast", "linear");
		jQuery('h5',this).fadeToggle("fast", "linear");
        $(this).toggleClass('large');
        $container.isotope('reLayout');
			
		}
      });

      
      // change layout
      var isHorizontal = false;
      $('#layouts a').click(function(){
        var mode = $(this).attr('href').slice(1);
            wasHorizontal = isHorizontal;
        isHorizontal = $(this).hasClass('horizontal');
  
        if ( wasHorizontal !== isHorizontal ) {
          // need to do some clean up for transitions and sizes
          var style = isHorizontal ? 
            { height: '80%', width: $container.width() } : 
            { width: 'auto' };
          // stop any animation on container height / width
          $container.filter(':animated').stop();

          $container.addClass('no-transition').css( style );
          setTimeout(function(){
            $container.removeClass('no-transition').isotope({ layoutMode : mode });
          }, 100 )
        } else {
          // go ahead and apply new layout
          $container.isotope({ layoutMode : mode });
        }
        return false;
      });

      // switches selected class on buttons
      $('#options').find('.option-set a').click(function(){
        var $this = $(this);

        // don't proceed if already selected
        if ( !$this.hasClass('selected') ) {
          $this.parents('.option-set').find('.selected').removeClass('selected');
          $this.addClass('selected');
        }

      });

      $container.isotope({
        itemSelector : '.element',
        // layoutMode : 'fitRows',
        masonry : {
          columnWidth : 235
        },
        masonryHorizontal : {
          rowHeight: 170
        },
        animationEngine : $.browser.opera ? 'jquery' : 'best-available',
        // animationEngine : 'jquery',
      });

    });
	
	
	
$(document).ready(function()
{ 

	$('.hastip').tooltipsy({
		alignTo: 'element',
		offset: [1, -1],
		content: '',
		show: function (e, $el) {
			$el.fadeIn(200);
		},
		hide: function (e, $el) {
			$el.fadeOut(200);
		},
		delay: 200,
		className: 'tooltipsy',
		css: {}
	});
	   
	$('.top-nav').mouseenter(function() {
	  jQuery('img',this).stop(true, true).fadeIn();
	}) 
	$('.top-nav').mouseleave(function() {
	  jQuery('img',this).stop(true, true).fadeOut();
	})   
   
});	
   
   



