var $$ = function(param) {
    var node = jQuery(param)[0];
    var id = jQuery.data(node);
    jQuery.cache[id] = jQuery.cache[id] || {};
    jQuery.cache[id].node = node;
    return jQuery.cache[id];
}

$(document).ready(function(){

  var hovered;

	// login link
  $('#login a').click(function(e){
    $('#login').toggleClass('open');
    if ($('#login div').is(':visible')) {
      $('#login div input#session_email')[0].focus();
    }
    return false;
  });
	
	// .thumb img.play hover / overlay
	$('#thumb_overlay').hide();

	$('.project_index #list_view li:first-child').css('border', 'none');
	$('.articles #list_view li:last-child').css('border', 'none');
	
$('.project_show img.play, li.showreel img.play, .articles img.play').mouseenter(function(){
	var width = ( parseFloat($(this).innerWidth()) );
	var height = ( parseFloat($(this).innerHeight()) );
	var offset = $(this).offset();
	
	$('#thumb_overlay').toggleClass('zoom', $(this).hasClass('zoom')).toggleClass('play', $(this).hasClass('play'));
	$('#thumb_overlay').attr('href', $(this).attr('data-upload') || $(this).closest('a').attr('href'));
	$('#thumb_overlay').css({'width' : width, 'height' : height, 'left' : offset.left, 'top' : offset.top});
	$('#thumb_overlay').stop(true,true).fadeIn(250);
	
});

$('#thumb_overlay').click(function(event){
    tb_show(null, $(this).attr('href'), false);
    this.blur();
    return false;
});

$('#thumb_overlay').mouseleave(function(){
	$('#thumb_overlay').stop(true, true).fadeOut(250);
});
	
  if (typeof(Cufon) !== 'undefined') {
  	Cufon.replace('#section_navigation li a',{hover: true});
  }
	
});

function browser(){
	$.browser.msie && $.browser.version
}

jQuery.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} 
});