function initLightbox() { 
//	console.log('initLightbox');
	myLightbox = new Lightbox();
	myLightbox.fullyLoaded = false;
	
	

	// Initialize history plugin.
	// The callback is called at once by present location.hash. 
	jQuery.historyInit(pageload);
	// set onlick event for buttons

	jQuery("a[@rel='lightbox[images]']").click(function(){
		// moves to a new page. 
		// pageload is called at once. 
		jQuery.historyLoad('gallery');
		return false;
	});
	
	function pageload(hash) {
	//	console.log('running pageload: hash='+hash+', fullyLoaded='+(myLightbox.fullyLoaded?'true': 'false'));
		// hash doesn't contain the first # character.
		if(hash != "gallery" && myLightbox.fullyLoaded) {
			myLightbox.end();
			myLightbox.fullyLoaded = false;
//			jQuery.historyLoad('');
		}
	}
		
 }
Event.observe(window, 'load', initLightbox, false);
