(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

// preload css images
jQuery.preLoadImages("http://www.triflecreative.com/wp-content/themes/template/images/spaces-tab.gif","http://www.triflecreative.com/wp-content/themes/template/images/spaces-tab-hover.gif","http://www.triflecreative.com/wp-content/themes/template/images/communications-tab.gif","http://www.triflecreative.com/wp-content/themes/template/images/communications-tab-hover.gif");

// text replace
Cufon.replace('#menu a',{hover: true});
Cufon.replace('#tabs a',{hover: true});

$(document).ready(function() {
	$('#header').height($(window).height());	
	$(window).resize(function(){
		$('#header').height($(window).height());
	});					
	
	$("ul.sf-menu").superfish({dropShadows:   false, autoArrows:    true});	 
	$("#accordion").accordion({ autoHeight: false });
 
	// gallery
	$('#gallery').cycle({
		fx: 'fade' ,
		next: '#gallery'
	});
	
	// horizontal gallery
	$('#horizontal a').lightBox();
	
	// ie6 hover fix
	$("#content ul.projects li").hover(
	      function () {
	        $(this).addClass('hover');
	      }, 
	      function () {
	        $(this).removeClass('hover');
	      }
	);
	
	// stick social media items if page too small
	if ($(window).height() < 560) {
		$('ul.social').addClass('stuck');
	} else {
		$('ul.social').removeClass('stuck');	  	
	}
	// if ipod / ipad set header to body height
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	if (agentID) {
		$('#header').height($('body').height());
	}
	
	$(window).resize(function(){
		//set header height
	  	if (agentID) {
			$('#header').height($('body').height());
		} else {
			$('#header').height($(window).height());
		}
	  
	  // move social media icons on a small screen
	  if ($(this).height() < 560) {
	  	$('ul.social').addClass('stuck');
	  } else {
	  	$('ul.social').removeClass('stuck');	  	
	  }
	});
	
});		

// add this
var addthis_config = {
     ui_offset_top: -17,
     ui_offset_left: 0
}	
