
// used to load more content via the "more" button
function ajax_append_visuals(filename, clicked_div){

	jQuery.get(
      filename,
      function(data) {
	
				jQuery('div.main').last().after( data );
				
				setupPrettyPhoto();
				
				clicked_div.fadeOut( 300, function(){
					jQuery(this).detach();
					} )
      }
  );
	
}

function getAndyStream(){

	var stream_list = jQuery('#andyStream');
	stream_list.empty();
	
	// show the little spinny thing
	var ajax_loader_img = jQuery(getAjaxLoaderDiv());
	stream_list.append(ajax_loader_img);
	
	jQuery.getJSON( 'http://api.flickr.com/services/feeds/photos_public.gne?id=48541392@N00&format=json&jsoncallback=?', 
		function(data) { 
			
			// ajax call complete, remove the spinny thing
			ajax_loader_img.remove();
	
			jQuery.each(data.items, 
				function(i, item) {
					// only want five items right now...
					if( i > 5 ){
						return;
					}
					stream_list.append('<li class="full_transparent"><a href=' + item.link + ' target="_blank"><img src=' + item.media.m + ' height="75" width="75"></li>');
				} 
			);
			
			jQuery(".full_transparent", stream_list).fadeTo(600, 1);
			
		}
	); // end jQuery.getJSON()
	
}

// just for fun
function letterSpacingAnimate(){
 
 jQuery('.title_no_indent').hover( function(){
   jQuery(this).animate({"letter-spacing": "-4px"}, 500, 'swing');
 }, function(){
   jQuery(this).animate({"letter-spacing": "0px"}, 500, 'swing');
 });
  
}

function setupPrettyPhoto(){

	jQuery("a[rel^='lightbox']").prettyPhoto({
		overlay_gallery : false,
		deeplinking: false
		});
	
}

jQuery(document).ready(function() {
	
	// not ideal, but ok for now. check if we're on the main page by testing for main buttons. otherwise, run the init code here
	if( jQuery('#main_buttons').length <= 0){
		
		IEcheck();
		getFlickrFaves();
		getAndyStream();
		setupPrettyPhoto();
		//letterSpacingAnimate();

		jQuery("#load_more a").live( 'click', function(){

			var clicked_div = jQuery(this).parent();
			ajax_append_visuals(this.getAttribute('data-load'), clicked_div ); // TODO add ability to have comma separated values in this attribute for multiple pages to load

			return false;
		});
		
	}
	
});


