
$(document).ready( function(){
	
	
	$('.gallery-layout li a').click( function() {
		if($(this).parent().hasClass('on') == false) {
			var newImageURL = $(this).attr('href');
			
			$('.gallery-layout li').removeClass();
			$(this).parent().addClass('on');
			
			var caption = $(this).attr('title');
			var imageTag = '<img src="'+newImageURL+'" alt="'+caption+'"/>';  

			
			$(function () {
			  var img = new Image();
			  
			  // wrap our new image in jQuery, then:
			  $(img)
			    // once the image has loaded, execute this code
			    .load(function () {
			      // set the image hidden by default  
			      $(this).css('display','none');
			      $('#MainImageHolder img').fadeOut('slow');
			      
			      // with the holding div #loader, apply:
			      $('#MainImageHolder')
			        // remove the loading class (so no background spinner), 
			        .removeClass('loading')
			        // then insert our image
			        .append(this);
			    
			      // fade our image in to create a nice effect
			      $('#MainImage').animate({height:$(this).height()},{queue:false});
			      $('#MainImage').animate({width:$(this).width()});
				  
			      $(this).fadeIn('slow');
			    })
			    
			    // if there was an error loading the image, react accordingly
			    .error(function () {
			      // notify the user that the image could not be loaded
			    })
			    
			    // *finally*, set the src attribute of the new image to our image
			    .attr('src', newImageURL);
			});
			
			// $('#MainImageHolder').append(imageTag);
		}
		
		return false;
	});
	
	$('.gallery-layout').css('background','none');
	$('.gallery-layout li a').css('visibility','visible');

/*
	$('.clearText,#SearchForm_SearchForm_Search').focus( function(){
		if( $(this).attr('cleared') ) return;
		$(this).val('');
		$(this).attr({ cleared: true});
	});
	
	// Homepage header switches
	var CurrentHeaderSwitch = '#DesignHome';
	$('.designSection span a').mouseenter( function() {
		if (CurrentHeaderSwitch != '#Design' + $(this).html()) {
			$(CurrentHeaderSwitch).fadeOut();
			CurrentHeaderSwitch = '#Design' + $(this).html();
			$(CurrentHeaderSwitch).fadeIn();
		}
	});
	$('#Logo').mouseenter( function() {
		if (CurrentHeaderSwitch != '#DesignHome') {
			$(CurrentHeaderSwitch).fadeOut();
			$('#DesignHome').fadeIn();
			CurrentHeaderSwitch = '#DesignHome';
		}
	});
	
	// Homepage Portfolio switches
	var CurrentPortfolioSwitch = "#BoxPortfolio1";
	$('.portfolioContainerText a').mouseenter( function() {
		if (CurrentPortfolioSwitch != "#Box" + $(this).attr('id') ) {
			$(CurrentPortfolioSwitch).animate( { height:"20px" }, { queue:false, duration:1000 } );
			CurrentPortfolioSwitch = "#Box" + $(this).attr('id');
			$(CurrentPortfolioSwitch).animate( { height:"160px" }, { queue:false, duration:1000 } );
		}
		return false;
	});
	
	// Fancy Headings
	$('.fancy, .typography .introText h2, #Content h1').prepend('<span></span>');
	*/

  
	
});



$(window).load( function(){
	$('#MainImage').animate({height:$('#MainImageHolder img').height()},{queue:false});
	$('#MainImage').animate({width:$('#MainImageHolder img').width()});
});
