// JavaScript Document
Cufon.replace('h1 span, h2, h3, .header-menu li a span, .the-work .work-item a.launch-project');

$( function () {
  if ( $.browser.msie ) {
    $( 'body' ).addClass ( 'ie' );
  } else {
    $( 'body' ).addClass ( 'ff' );    
  }
  
  if ( $( 'body' ).width ( ) < 960 ) {
    $( 'body' ).width ( 960 );
  }
  
  /* if ( $( '.generic-content-box' ).height ( ) < 500 ) {
    $( '.generic-content-box' ).height ( 500 );
  } */
  
  if($('body').hasClass('home')){
    $(function(){
            new TWTR.Widget({
              version: 2,
              type: 'profile',
              rpp: 8,
              id: 'twitter-section',
              interval: 30000,
              width: 250,
              height: 258,
              theme: {
                shell: {
                  background: '#757575',
                  color: '#ffffff'
                },
                tweets: {
                  background: '#141314',
                  color: '#ffffff',
                  links: '#9c9c9c'
                }
              },
              features: {
                scrollbar: false,
                loop: true,
                live: true,
                hashtags: true,
                behavior: 'default'
              }
            }).render().setUser('58ninety').start();
    });
  }
      /*************** showreel ****************/
  if ( $( 'body' ).hasClass ( 'showreel' ) ) {
      // Add VideoJS to all video tags on the page when the DOM is ready
      VideoJS.setupAllWhenReady();
  }
  
     /*************** the work ****************/
  if ( $( 'body' ).hasClass ( 'the-work' ) ) {
    $('.the-work .work-set li').each ( function ( index ) {
        $(this).click ( function () {
          // opt out if its a
        if ( !$(this).hasClass ( 'header' ) ) {
          
          var classNameSet = $( this ).attr ( 'class' ).split ( " " );
          
          for ( var i = 0; i < classNameSet.length; i++ ) {
            var className = classNameSet [ 0 ];
            
              // does the id actaully exist?!?!?!?
            if ( $( '#' + className ) ) {
              break;  
            }
          }
          
          changeContent ( className );
        }
      } );
    });
    
   if (swfobject.hasFlashPlayerVersion("9.0.0")) {
     
      //$("#Expedia-slides, #Hotels-ca").html ( "" );
      $("#Expedia-slides").wrapInner ( "<div class='swf-wrapper'><div id='Expedia-swf-wrapper'>" );
      $("#Hotels-ca-slides").wrapInner ( "<div class='swf-wrapper'><div id='Hotels-swf-wrapper'>" );
     
        // has Flash
      swfobject.embedSWF("http://umbraco.58ninety.com/media/1056/snowglobe_300x250_en.swf", "Expedia-swf-wrapper", "300", "250", "9.0.0", "expressInstall.swf")
      swfobject.embedSWF("http://umbraco.58ninety.com/media/1049/hotels_300x250.swf", "Hotels-swf-wrapper", "300", "250", "9.0.0", "expressInstall.swf");
      
   }  
  }
  
  
} );



function changeContent ( divId ) {

    // display the current content
  $( '#right-column .work-item' ).each ( function ( index ) {
      if ( $( this ).attr ( 'id' ) == divId ) {
      $( this ).fadeIn ( 'fast' );
    } else {
      $( this ).css ( 'display', 'none' );
    }
  });
  
    // fix the list items
  $('.the-work .work-set li').each ( function ( index ) {
      if ( $( this ).hasClass ( divId ) ) {
      $( this ).addClass ( 'active' );
    } else {
      $( this ).removeClass ( 'active' );
    }
  });
}
