$(document).ready(function(){
	$('div#content p#warning').remove();
	$('div#content div#image_mount').css('height','512px');
	$('div#content div#image_mount').css('width','768px');
	jQuery.preloadImages = function()
	{
		for(var i = 0; i<arguments.length; i++)
		{
			jQuery("<img>").attr("src", arguments[i]);
		}
	}
    
   var firstBornSrc = $('ul#image_thumbs li a').eq(0).attr('href');
   var firstBornTitl = $('ul#image_thumbs li a img').eq(0).attr('alt');
   var images = $('ul#image_thumbs li a img').size();
   if (images > 0) {
	   // $('div#image_mount').prepend('<img src="'+firstBornSrc+'" alt="'+firstBornTitl+'" title="'+firstBornTitl+'" />');   
	   $('div#image_mount').prepend('<img class="focus"/>');   
	   $('div#image_mount').prepend('<img class="throbber"/>');   
	   $('div#image_mount img.throbber').attr('src','/images/throbber.gif');
	   $('div#image_mount img.focus').hide();
	   $('div#image_mount img.focus').attr('src',firstBornSrc);
	   $('div#image_mount img.focus').load(imageCenter);
	   $('div#image_mount img.focus').bind('load',function() {
	     $(this).show();
	   });
	   
	   $('ul#image_thumbs li a').click(function() {
		  $('div#image_mount img.focus').hide();
		  var newHref = $(this).attr('href');
		  var newTitl = $(this).children('img.focus').attr('alt');
		  $('div#image_mount img.focus').attr('src',newHref);
		  $('div#image_mount img.focus').attr('alt',newTitl);
		  $('div#image_mount img.focus').attr('title',newTitl);
		  $('div#image_mount img.focus').load(imageCenter);
	      $('div#image_mount img.focus').bind('load',function() {
		    // $(this).show();
		  });
		  // alert();    
	      return false;
	   });
   } else {
     $('div#image_mount').prepend('<p>No images have been added to this category yet</p>');   
   }
   /*
   $('a,img').ToolTip(
	{
		className: 'inputsTooltip',
		position: 'mouse',
		delay: 200
	}
);
	*/
  $('input:submit').addClass('submitify');
});

imageCenter = function() {
     var imgHeight = $(this).height();
     var imgWidth = $(this).width();
	 var imgLeft = (768 - imgWidth) / 2;
	 var imgTop = (512 - imgHeight) / 2;
	 $(this).css('top',imgTop);
	 $(this).css('left',imgLeft);
}
