; (function($) {
	/**
	* Resizes an inner element's font so that the inner element completely fills the outer element.
	* @author Russ Painter WebDesign@GeekyMonkey.com
	* @version 0.1
	* @param {Object} Options which are maxFontPixels (default=40), innerTag (default='span')
	* @return All outer elements processed
	* @example <div class='mybigdiv filltext'><span>My Text To Resize</span></div>
	*/
	$.fn.textfill = function(options) {
		var defaults = {
		};
		var Opts = jQuery.extend(defaults, options);
		return this.each(function() {
			var fontSize = Opts.maxFontPixels;
			var ourText = $(Opts.innerTag + ':visible:first', this);
			var maxHeight = $(this).height();
			var maxWidth = $(this).width();
			var textHeight;
			var textWidth;
			do {
				ourText.css('font-size', fontSize);
				textHeight = ourText.height();
				textWidth = ourText.width();
				fontSize = fontSize - 1;
			} while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);
		});
	};
})(jQuery);


// create the namespace
var ARN 	= ARN || {};

// self executing function to make
// sure jQuery arrives intact
(function($){
	
	// create our bootstrap
	ARN.ajax = new function()
	{
	
		var SPEED			= 450;
		// variables 
		var sBase			= $.address.baseURL()+'',
		$window				= $('body,html'),
		$mainContent		= $('#showcontent'),
		$substance	=	$('#substance-showcontent');
		
			
		this.init = function()
		{
			ajaxLinks();
			AddressChange();
			
		}
		
		
		function ajaxLinks()
		{
			$.address.crawlable(false);
			$.address.wrap(false);
			$.address.autoUpdate(true);
			$('a:urlInternal').live('click', function(e) { 

				$el = $(this);
				// remember our scroll position
					$('body,html').animate({ scrollTop: 0}, 333, 'easeOutExpo');
			
					//replace the domain in the link to create a neat hashtag
					var path = $(this).attr('href').replace(sBase, '');
					
					$.address.value(path);
					return false;
					// Default action (go to link) prevented
					e.preventDefault();
		
				
			});
		}
		
		
		
		function AddressChange()
		{

			$.address.change(function(e) {
							$('#portfolio .hidden').animate({left: '0px'}).removeClass('hidden');

				
				// when the hashed address changes, execute
				if (e.value) {
					$('body,html').animate({ scrollTop: 0}, 333, 'easeOutExpo');


					//console.log($.address.baseURL()+"/" +  ' != ' +  $.address.value());
					if ($.address.baseURL()+"/" != $.address.baseURL() + $.address.value())
					{	
						
						$mainContent.delay('fast').slideUp(555, 'easeOutExpo', function() {
						$mainContent.load(e.value + ' #substance-showcontent', function() 
						{
						$mainContent.delay('fast').slideDown(555, 'easeOutExpo', function() {

							var $response = $('#substance-showcontent');
							// if there is an empty response do nothing
							if( $response.length < 1 ) return;
							// our content has loaded, transition in
					
							
													});	

										});	
							});						
						
				 	}
				}
			}); 
		}
		
	}
		ARN.ajax.init();

	
})(jQuery);


jQuery(document).ready(function($) {
	
	


$('#atention h1').textfill({ maxFontPixels: 30 });
$('#atention h2').textfill({ maxFontPixels: 30 });

	// GRAYSCALE AND ROLLOVER PORTFOLIO //
	
	
	
	$('#portfolio li .colorImg').css({opacity: 0});
	$('#portfolio li .zwImg').css({top:'-140px'});
	
	$('#portfolio li').hover(function() {
	$('.colorImg', this).stop().animate({opacity: 1});
	$('.zwImg', this).stop().animate({opacity: 0});


	}, function(){
	$('.colorImg', this).animate({opacity: 0});
	$('.zwImg', this).animate({opacity: 1});

	});

	
	// GRAYSCALE AND ROLLOVER PORTFOLIO //
		
		
// filter




		$('#filter a').click(function() {
									$('#showcontent').slideUp(333, 'easeOutExpo');
				
		
		var filterVal = $(this).text().toLowerCase().replace(' ','-');
				
		if(filterVal == 'all') {

			$('#portfolio .hidden').show().fadeIn();
			$('#portfolio img, #portfolio .description').animate({left: '0px'}, 222, 'easeOutExpo');
			$('#portfolio li').removeClass('hidden');
			$('#portfolio li').removeClass('marginright');
			


		} else {

			$('#portfolio li').each(function() {
				
				if(!$(this).hasClass(filterVal)) {
					$('img, .description' ,this).animate({left: '230px'});
					$(this).fadeOut().addClass('hidden');


				} else {
					$(this).show().fadeIn();
					$('img, .description' ,this).animate({left: '0px'}, 222, 'easeOutExpo')
					$(this).removeClass('hidden');

		
				}
			});
		

			}

				
		});

	
		
	
	
	
	$(window).load(function() {
		
		
	
	
	(function() {
		var lis = $('#portfolio li .zwImg');
		
			var i = 0;
			(function displayImages() {
				lis.eq(i++).animate({top:'0px'}, 100, 'easeOutExpo', displayImages);
			
		})();
	
	})();












}); // end .load //

$('.gotop').click(function () {
$('body,html').animate({ scrollTop: 0}, 666, 'easeOutExpo');
		});
}); // end .ready //
