// Original imageLoad function from: http://www.chazzuka.com/experiments/jquery-ajax-image-viewer/filebrowser.asp
// Modified by Tyler Mulligan - www.detrition.net

function imageLoad(file)
{
  $('#imageview')
	.addClass("loading")
	.html('<img src="img/ajax-loader.gif" /><p>Loading...</p>');
  var max = 600;		
  var img = new Image();
  $(img)
	.load(function () {
		  $(this).hide();
		  $('#imageview').removeClass('loading').html('').append(this);
		  if($(this).width() > $(this).height()) {
			if($(this).width() > max) $(this).attr('width', max);
		  } else {
			if ($(this).height() > max) $(this).attr('height', max);
		  }
		  $(this).fadeIn();
		  
	})
	.error(function () {alert('Could not load the file');})
	.attr('src', file);
}

