$(document).ready(function(){
  var passed,pSample,pTitle,largePath,largeTitle,largeAlt,largeHook,currentImg;
   if($('#thumbs')){
   $('#thumbs a').preload();
   $('#thumbs img').css('opacity', 0.5);
	$('#thumbs a').click(function(){
	     currentImg = $(this).attr('href');

	     if(currentImg != largePath){
   	     largePath = $(this).attr('href');
      	  largeTitle = $(this).attr('title');
      	  largeAlt = $(this).children('img').attr('alt');
           largeHook = document.location = '#'+largeAlt;

	     $('#thumbs img').css('opacity', 0.5);
	     $(this).children('img').css('opacity', 1.0);
   	  $('h1 span').html(largeTitle);
   	  document.title = $('h1').text();
   	  $('#feature img').fadeTo('fast', 0.0, 
   	   function(){
   	     $('#feature img').attr({ src: largePath, alt: largeTitle, title: largeTitle });
		 var t=setTimeout("$('#feature img').fadeTo('slow',1.0)", 100);
   	   });
	   }
   	  return false;
	});
   var hash = (document.location.toString().split('#')[1]);
	if(hash){ //we have a passed hash
	   passed =  $('img[@alt='+hash+']');
	   pSample = passed.parent('a').attr('href');
	   pTitle =  passed.parent('a').attr('title');
      $('#feature img').attr({
         src: pSample,
         alt: pTitle, 
         title: pTitle 
         });   
	}else{
	  passed = $('#thumbs img[@alt='+$('#feature img').attr('title')+']')
      //pTitle = $('#feature img').attr('title');
	}
	$('h1 span').html(pTitle);	
	document.title = $('h1').text();
	passed.fadeTo('slow', 1.0);
   }
   
   $('.email').each(function() {
         var $email = $(this);
         var address = $email.text().replace(/\s*\[at\]\s*/, '@')
                                    .replace(/\s*\[dot\]\s*/g, '.');
         $email.html('<a href="mailto:' + address + '">'+ address +'</a>');
      });

});