// nakia js 12

$(function() 									// ready
{  // alert('begin ready'); 
  // open external references and pdfs in new tab/window 
	$("a[href^=http://]").attr("target" ,"_blank");
	$("a[href$=pdf]").attr("target" ,"_blank");
		  // add title matching the alt-attribute to all images
  $('img[alt]').attr('title', this.alt); 
		  // construct img.overlays from small imgs, hide, & insert in front of img.lead
  $('#side img')
       .clone()	
       .map ( function()                // add '-overlay' to name 	
										{  // var src = this.src.replace(/\.jpg/, '-overlay.jpg');
										   this.src = this.src.replace(/\.jpg/, '-754.jpg');
											 return this;    
										} ) 			 
      .addClass('overlay')
			.hide()															       	
		  .insertBefore('div.lead img:last');	

     var lead = -1; 
	 
$('#side li:has(img)')      // event handler's for list items with thumbnails 
		   .each( 
				function(i)
			  {  var over = $('img.overlay').eq(i);       // select matching overlay
						$(this)
						.hover(
						function() { $(over).fadeIn();  },
						function() { $(over).fadeOut();}
						)	  // hover				
						.click 
						( function()
							{ if( lead == -1)
							  { over.clone().show().insertBefore('div.lead img:last');
								   lead = i; 
								} else if ( lead == i)
								{ $('img.overlay:last').remove();
								  lead = -1;
								} else
								{ $('img.overlay:last').remove(); 
									over.clone().show().insertBefore('div.lead img:last'); 
									lead = i;
								};  
							}			 // click-function
				    ); 						
		 		});   // side li.each		

$('div.lead').click
  ( function()
  	{ $('img.overlay:last:visible').remove()
   	  lead = -1;
  	} ); 
/*
$('span#time-widget').replaceWith(
': <iframe src= "http://free.timeanddate.com/clock/i1m8lvoc/n82/tlau/fn17/tct/pct/ahl/avb/tt0" >
</ iframe>' ); 	
*/

$('span#time-widget').replaceWith(':<iframe src = "http://free.timeanddate.com/clock/i1m8lvoc/n82/tlau/fn17/tct/pct/ahl/avb/tt0"> </iframe>'); 

}  );          // $.ready  		

