var LightboxWindow;

function initLightboxes(){
	LightboxWindow = new Window({title: "Sample", destroyOnClose: false, recenterAuto:true, modal:true, zIndex:200, resizable: false, draggable: false, closable:true, minimizable:false, maximizable:false});
	$$('a.lightbox:not([class~=processed])').each(function(e){initLightbox(e)});
}
function initLightbox(target){
	target = $(target).addClassName('processed');
	target.onclick = function(){return false;};
	
	target.observe('click',function(){  
		var size = target.readAttribute('dimensions').split('x');
		var requestoptions = target.readAttribute('requestoptions');
							
		//var LightboxWindow = new Window({title: "Sample", destroyOnClose: true, recenterAuto:true, modal:true, zIndex:200, resizable: false, draggable: false, closable:true, minimizable:false, maximizable:false});
		
		if (!requestoptions || requestoptions.length == 0)
		{
		    requestoptions = null;
		}
				
		//window.js will not accept a JSON string by itself
		var evaldOptions = (requestoptions != null ? eval("(" + requestoptions + ")") : null);
		LightboxWindow.setSize(size[0],size[1]);
		
		if((index = target.href.indexOf('#')) > -1)
		{
		    id = target.href.substring(index + 1, target.href.length);		    		    
		    
		    ////console.log(id + " setContent");
		    LightboxWindow.setContent(id, false, false);
		    LightboxWindow.showCenter(true);
		}
		else
		{
		    ////console.log(target.href + " setAjaxContent");
    		LightboxWindow.setAjaxContent(target.href,evaldOptions,true,true);
		} 

	//	LightboxWindow.setAjaxContent(target.href,evaldOptions,true,true);
	//	LightboxWindow.showCenter(true);
	});
}