$(document).ready(function(){    
    var tabs = [];
    var tabContainers = [];
    $('#designers ul.tabs a').each(function () {
     if (this.pathname == window.location.pathname) {
       tabs.push(this);
       tabContainers.push($(this.hash).get(0));

       // hide all tabs initally, except for the main tab
       $(tabContainers).hide()
     }
$('#home-video').hide();
	 
$('a#play-me').click(function() {
							  
	$('#video-trigger').hide();					  
	$('#home-video').fadeIn();

 return false;
  });

    });

    $(tabs).click(function (event) {
      event.preventDefault();

      // hide promo-images
      $('#promo-images').hide();
	  

      // hide all other tabs
      $(tabContainers).fadeOut().filter(this.hash).fadeIn();
      // console.log(this.hash);

      // set up the selected class
      $(tabs).removeClass('selected');
      $(this).addClass('selected');

      return false;
    });
    
    $('#promo-images').cycle({ 
      fx:            'fade',
      timeout:       '2000',
      speed:         '500',
      autostop:      '1',
      autostopCount: '6'
    });
    
    $("#latest-blog a#comments-link").click(function (event) {
      event.preventDefault();

      // hide latest-blog
      $('#latest-blog').hide();
      
      // show latest-comments
      $('#latest-comments').show();

      return false;
    });
    
    $("#latest-comments a#blog-link").click(function (event) {
      event.preventDefault();

      // hide latest-comments
      $('#latest-comments').hide();
      
      // show latest-blog
      $('#latest-blog').show();

      return false;
    });
    
    // Open all external links in a new window
    $('a[rel="external"]').click( function() {
       window.open( $(this).attr('href') );
       return false;
    });
    
    // Modal windows 
    $('a[rel*=facebox]').facebox({
       opacity: .8, 
       overlay: true
    });
});


 