
$(function(){
	
	if ($.browser.msie && $.browser.version < 7)
		$('img[src$=.png]').pngfix();

	$('img[hover],input[hover]').imghover();
	
	// FLIR replacement
	FLIR.init( new FLIRStyle( { mode:'progressive' } ) );
	$("h1").each( function() { FLIR.replace(this, new FLIRStyle({ cFont:'scalacaps' })); } );
	$("h2").each( function() { FLIR.replace(this, new FLIRStyle({ cFont:'scalacaps' })); } );		
	
	// lightbox
	if ( $("#projectGallery").length > 0 ) {
		$('#projectGallery a').lightBox();
	}
	
    $("a.lightbox").lightBox();
});


;(function($){

	$.fn.pngfix = function () {	
		if ($.browser.msie && $.browser.version < 7) {
			return this.each (function () {
				$(this).css({
					filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.src+"')"
				});
				this.src = '/images/spacer.gif';
			});
		} else {
			return this;
		}
	};

	$.prefetch = function() {
	  for(var i = 0; i<arguments.length; i++)  {
		jQuery("<img>").attr("src", arguments[i]);
	  }
	}

	$.fn.imghover = function () {
		return this.each (function () {
			$(this).data('__img__original', this.src);
			$.prefetch($(this).attr('hover'));
		}).hover(function(){
			this.src = $(this).attr('hover');
		},function(){
			this.src = $(this).data('__img__original');
		});
	};
    
    
})(jQuery);