function showDialog(tag) {
	$('lightbox_content_'+tag).show();
	new Effect.Appear("overlay",{from : 0, to: 0.8,duration : 0.5});
	new Effect.Appear("lightbox",{from : 0, to: 1,duration : 0.5});
}

function closeDialog() {
	$$(".lightbox_content").each(function(e) {e.hide(); });
	new Effect.Fade("lightbox",{from : 0.8, to: 0,duration : 0.5});
	new Effect.Fade("overlay",{from : 1, to: 0,duration : 0.5});
}


document.observe("dom:loaded", function() {
	if($("picture_gallery")) {
		var curPosition = 0;
		// 4 is the most right margin	
		var next = $("picture_gallery_window").getWidth()+4;
		$("sfeer_next_button").observe("click", function() {
			if (Math.abs(curPosition-next) >= $('picture_gallery').getWidth()) return;
			new Effect.Move("picture_gallery", { x: -1*next, mode :"relative"});
			curPosition -= next;
		});
		$("sfeer_prev_button").observe("click", function() {
			if (curPosition >= 0) return;
			new Effect.Move("picture_gallery", { x: next, mode :"relative"});
			curPosition += next;
		});
		
		$$(".picture_thumb").each(function(e){
			e.observe("click",function(elm) {
				var id = e.readAttribute("id").substring("picture_thumb_".length);
				$$(".picture_view").each(function(el){
					if (el.style.display != "none") {
						new Effect.Fade(el, {
							duration : 0.4,
							afterFinish : function() {
								new Effect.Appear("picture_view_"+id, {duration : 0.5});
							}
						});
					}
				});
			}); 
		});
		 
	} 

});

