lightbox = {	// NOTA: le opzioni sono comuni a tutte le lightbox per uniformita'	options : {		speed : 'slow', 		animationSpeed : 800,		animated: false,		loadingImage: '/img2007/lightbox/loading.gif',		delay: 4000,		defaultHeight: 540,		defaultWidth: 994,		min_imgHeight: 288, // l'altezza minima delle immagini nella lightbox.		paginationModule: 11, 		iframeSpotUrl: '',		templateUrl: '/includes/lightbox.php', // url del template html della lightbox		iframeSpotUrl: "/includes/spot_include.html",		sitecensus: {			url: '//secure-it.imrworldwide.com/cgi-bin/m?ci=ilsole-it&cg=0&si=',			completeurl: '',			//lboxparam: 'lb=1'			lboxparam: ''		}	},	flags : {		pageLoaded: false,		activeSlideshow: false,		active: false	},		slider: {		slider_id: '#slider2',		boxcontainer_id: '#cnt_lbox .scroller_container',		ul_selector: '#cnt_lbox ul.list_Picture',		li_selected: 'li_Selected'	},		browser: {		msie6: $.browser.msie && ($.browser.version == "6.0"),		msie7: $.browser.msie && ($.browser.version == "7.0"),		ffox: $.browser.mozilla,		safari: $.browser.safari,		opera: $.browser.opera	},	keyboard: { // i tasti per cui supportiamo eventi		left_arrow: 37,		right_arrow: 39,		esc_key: 27	},	windowload : function(){		lightbox.flags.pageLoaded = true;	},		initialize : function(json, caller){		if (lightbox.flags.pageLoaded && !lightbox.flags.active) {			lightbox.flags.active = true;			lightbox.caller = caller; // id del link che ha chiamato la lightbox			lightbox.loadSuccess = false;			lightbox.getGallery(json);		}	},		getGallery : function(url){		$.ajax({			url: url,			type: 'GET',			datatype: 'script', 			success: function(responseText){				lightbox.loadSuccess = true;				eval(responseText);				lightbox.galleryItems = galleryItems;				lightbox.launch();			},			error: function(){				lightbox.loadSuccess = false;			}		});	},	launch: function(){		lightbox.flags.activeSlideshow = false;		if ($(lightbox.caller).attr("rel") != undefined){			lightbox.startIndex = parseInt($(lightbox.caller).attr("rel"));			lightbox.currentIndex = parseInt($(lightbox.caller).attr("rel"));			lightbox.prevIndex = -1		} else {			lightbox.currentIndex = 0;			lightbox.startIndex = 0;			lightbox.prevIndex = -1		}		lightbox.hideFlash();		var myoverlay = '<div id="overlay" style="display:none"> </div>';		$('body').append(myoverlay);		$('#overlay').height($(document).height())		.width($(document).width())		.css('opacity','0.85')		.bind('click',function(){			lightbox.close();			return false;		});		$('html').css("overflow-x", "hidden");		if (lightbox.loadSuccess) lightbox.launchSuccess();		else lightbox.launchFailure();				$(window).bind('resize', function(){			if ($('#cnt_lbox').height() > 0) lightbox.alignCenter($('#cnt_lbox').height());			else lightbox.alignCenter(lightbox.options.defaultHeight);		});	},	launchFailure: function(){		$('#overlay').show();		window.alert("ERROR getting Gallery Items");		lightbox.close();	},		launchSuccess: function(){		if (lightbox.options.animated)			$('#overlay').fadeIn(lightbox.options.speed, function(){				$('#overlay').before('<div id="lightbox"><div id="cnt_lbox"  style="width: 1px; height: 1px;" class="clearfix"> </div></div>');				lightbox.createLightbox();				lightbox.alignCenter(lightbox.options.defaultHeight);			});		else {			$('#overlay').show();			lightbox.createLightbox(); 			lightbox.alignCenter(lightbox.options.defaultHeight);		}		lightbox.setupSitecensus();	},	setupSitecensus: function(){		loc = escape(document.location.href);		if(lightbox.options.sitecensus.lboxparam == "")			lightbox.options.sitecensus.completeurl = lightbox.options.sitecensus.url + loc;		else {			if(document.location.href.indexOf("?") > 0) 				lightbox.options.sitecensus.completeurl = lightbox.options.sitecensus.url + loc + escape("&" + lightbox.options.sitecensus.lboxparam);			else 				lightbox.options.sitecensus.completeurl = lightbox.options.sitecensus.url + loc + escape("?" + lightbox.options.sitecensus.lboxparam);		}	},		alignCenter : function(height){		var leftval = ($(window).width() / 2 ) - (lightbox.options.defaultWidth / 2);		var topval = ($(window).height() / 2) - (height / 2) + $(document).scrollTop();		$('#overlay').height($(document).height()).width($(document).width())		if (leftval < 0) leftval = 0;		if (topval < 0) topval = 0;		if (lightbox.options.animated)			$('#lightbox').css('left', leftval + 'px').animate({'top' : topval + 'px'});		else $('#lightbox').css('left', leftval + 'px').css('top', topval + 'px');	},		resizeLightbox : function(init) {		var heightDiff = 0;		var height = 0;		var padding = 34;		lightbox.resizeImageBox();		if($(".rightbox").height() > $('.cnt_image').height())			height = $(".rightbox").height() + $('#cnt_lbox .header').outerHeight() + padding;		else height = $('#cnt_lbox .cnt_image').outerHeight() + $('#cnt_lbox .header').outerHeight() + padding;		if (lightbox.options.animated){			$('#cnt_lbox')			.animate({"width": lightbox.options.defaultWidth + "px", 'opacity': '1'}, lightbox.options.animationSpeed)			.animate({'height' : height + 'px'}, lightbox.options.animationSpeed, function(){				$('#current_image .int').show();				$('.lightbox_navigation').css('visibility', 'visible');			});		} else {			$('#cnt_lbox').width(lightbox.options.defaultWidth).height(height);			$('#current_image .int').show();			$('.lightbox_navigation').css('visibility', 'visible');		}			},		resizeImageBox : function() {		h = lightbox.galleryItems.images[lightbox.currentIndex].height;		$('#current_image .ext').height(h);		$('#current_image .int').width(lightbox.galleryItems.images[lightbox.currentIndex].width);	},	createLightbox : function() {		var current_height = 0;		if (!lightbox.options.animated){			$('body').append('<div id="lightbox"><div id="cnt_lbox"  style="display:none;" class="clearfix"> </div></div>');			$('#cnt_lbox').show();		}		$('#cnt_lbox').css('opacity', '1');		$('#cnt_lbox').append(lightbox.injectGalleryHtml());		$('#gallery_title').append(lightbox.galleryItems.title);		$('#spot').append('<iframe id="bannerLB" scrolling="no" frameborder="0" allowtransparency="true" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" src="" ></iframe>');		$('a#close_lbox').bind('click', lightbox.close);		$('#prevLink').click(function(){			lightbox.showImage(-1, false, true);			return false;		});		$('#nextLink').click(function(e){			lightbox.showImage(1, false, true);			return false;		});		$('#startShow')			.bind('click', lightbox.startSlideshow)			.hover(function(){				$(this).toggleClass('hovering')			}, function(){				$(this).toggleClass('hovering')			});		// paginazione con scroller		$('.box_ThumbList').clone().insertAfter('#prevLink');		if(lightbox.galleryItems.images.length > 6)			sliderStartUp(lightbox.slider.slider_id, lightbox.slider.ul_selector, lightbox.slider.boxcontainer_id, lightbox.slider.li_selected);		else {			$('#' + lightbox.slider.ul_selector).css('left', '0px');			$('.lightbox_navigation .box_ThumbList').css('text-align', 'left');		}		$(lightbox.slider.ul_selector + ' li a')			.attr('href', 'javascript:void(0)')			.click(function(){				index = $(lightbox.slider.ul_selector + ' li a').index(this)				lightbox.showImage(index, true, true);			})			.hover(function(){					$(this).css("cursor", "pointer");				}, function(){					$(this).css("cursor", "default");				});		$(document).keydown(lightbox.keyboard_navigation);		lightbox.showImage(lightbox.startIndex, true, false); // e' la prima volta che lo faccio partire		//return false;	},	keyboard_navigation: function(e){		switch(e.keyCode){			case lightbox.keyboard.left_arrow:				lightbox.showImage(-1, false, false);				break;			case lightbox.keyboard.right_arrow:				lightbox.showImage(1, false, false);				break;			case lightbox.keyboard.esc_key:				lightbox.close();				break;		}	},	injectGalleryHtml : function(){		var html = $.ajax({			url: lightbox.options.templateUrl + "?" + new Date().valueOf(),			type: 'GET',			datatype: 'html', 			async: false,			error: function(){				window.alert("Errore caricamento template");				lightbox.close();			}		}).responseText;		return html;	},	refreshSitecensus: function(){		if(lightbox.options.sitecensus.completeurl == "") lightbox.setupSitecensus();		$('img#sitecensus').attr('src', lightbox.options.sitecensus.completeurl + "&rnd=" + new Date().getTime());		/* ominiture */		var tmparray = s.pageName.split(":");		tmparray[tmparray.length-1] = lightbox.currentIndex+1;		s.pageName = tmparray.join(":");				tmparray = s.prop4 .split(":");		tmparray[tmparray.length-1] = lightbox.currentIndex+1;		s.prop4  = tmparray.join(":");				tmparray = s.hier1.split(",");		tmparray[tmparray.length-1] = lightbox.currentIndex+1;		s.hier1 = tmparray.join(",");		/* Tracking */		s.t()	},		countVisits: function(){		if(typeof uuid != "undefined") {		    var serviceUrl="/php/piuletti/artratingsvc.php";		    var title = escape(document.title);		    var DocRulesView = 'Libero';		    var url = escape(document.URL);		    var dataUrl = "uuid=" + uuid;		    dataUrl += "&title=" + title;		    dataUrl += "&DocRulesView=" + DocRulesView;		    dataUrl += "&type=gallery&channel=MediaCenter";		    dataUrl += "&url=".concat(url);			dataUrl += "&rnd="+new Date().valueOf();						if(uuid.length > 0 && title.length > 0) {				$.ajax({				   type: "GET",				   url: serviceUrl,				   data:dataUrl,				   success: function(msg){					$(document.body).append(msg);				   }				 });			}		}	},		loading: function(){		$('#current_image .int img').replaceWith('<img id="loadingImage" src="' + lightbox.options.loadingImage + '" />');	},		startSlideshow : function(){		lightbox.flags.activeSlideshow = true;		$('#current_image .int img').unbind();		$(document).unbind('keydown');		$('#startShow').unbind('click', lightbox.startSlideshow);		$('#startShow').hide();		$('#stopShow').show();		$('#stopShow').bind('click', lightbox.stopSlideshow);		lightbox.timerControl('start');		return false;	},	stopSlideshow : function(){		lightbox.timerControl('stop');		$('#stopShow').unbind('click', lightbox.stopSlideshow);		$('#stopShow').hide();		$('#startShow').show();		$('#startShow')			.bind('click', lightbox.startSlideshow);		$('#current_image .int img')			.click(function(){				lightbox.showImage(1, false, false);			})			.hover(function(){				$(this).css("cursor", "pointer");			}, function(){				$(this).css("cursor", "default");			});		$(document).keydown(lightbox.keyboard_navigation);		lightbox.flags.activeSlideshow = false;		return false;	},		timerControl : function(action) {		if (action == 'start') {			lightbox.timer = self.setInterval("lightbox.showImage(1, false, false)", lightbox.options.delay)		} else {			lightbox.timer = clearInterval(lightbox.timer);			lightbox.timer = null;		}	},	showImage : function(value, absolute, fromPagination){		if (fromPagination) lightbox.stopSlideshow();		if (!absolute) index = parseInt(lightbox.currentIndex) + parseInt(value);		else index = value;		index = lightbox.checkIndex(index);		lightbox.prevIndex = lightbox.currentIndex;		lightbox.currentIndex = index;		if(document.location.href.indexOf("#/photo/") == -1) document.location.href += "#/photo/" + lightbox.currentIndex;		else {			var splitted = document.location.href.split("#/photo/")			document.location.href = splitted[0] + "#/photo/" + lightbox.currentIndex;		}		$('#current_image .int').hide();		$('#cnt_lbox .lightbox_navigation').css('visibility', 'hidden');		$('#current_image .int img').replaceWith('<img src="' + lightbox.galleryItems.images[index].src + '" width="' + lightbox.galleryItems.images[index].width + '" height="' + lightbox.galleryItems.images[index].height + '" />');		if(!lightbox.flags.activeSlideshow)			$('#current_image .int img')				.click(function(){					lightbox.showImage(1, false, false);				})				.hover(function(){					$(this).css("cursor", "pointer");				}, function(){					$(this).css("cursor", "default");				});		var caption = lightbox.galleryItems.images[index].title + " - " + lightbox.galleryItems.images[index].caption;		if(lightbox.galleryItems.images[index].title == "") caption = lightbox.galleryItems.images[index].caption;		$('#image_caption').html(caption);		if(lightbox.prevIndex == lightbox.currentIndex) lightbox.resizeLightbox(true);		else lightbox.resizeLightbox(false);		lightbox.setPagination();		lightbox.setCounter(index);		lightbox.refreshADV();		lightbox.refreshSitecensus();		lightbox.countVisits();	},	setPagination : function(){		//paginazione con slider dobbiamo cambiare classe al selezionato e spostare lo slider.		$(lightbox.slider.ul_selector + ' li.' + lightbox.slider.li_selected).removeClass(lightbox.slider.li_selected);		$(lightbox.slider.ul_selector + ' li').get(lightbox.currentIndex).className = lightbox.slider.li_selected;		slider_start_position(lightbox.slider.slider_id, lightbox.slider.ul_selector, lightbox.slider.li_selected);	},		refreshADV : function(){		if(lightbox.browser.msie6){			$('#bannerLB').attr('src',lightbox.options.iframeSpotUrl)				.load(function(){					$('#cnt_lbox')						.focus(function(){							$(document).focus();						})						.focus();				});		} else $('#bannerLB').attr('src',lightbox.options.iframeSpotUrl);	},		preloadImages : function (index){},		checkIndex : function(index){		if (index < 0) index = lightbox.galleryItems.images.length - 1;		if (index >= lightbox.galleryItems.images.length) index = 0;		return index;	},		setCounter : function(index) {		index = parseInt(index);		$('#counter').empty();		$('#counter').append("Immagine <strong>" + (index + 1) + "</strong> di " + lightbox.galleryItems.images.length);	},	hideFlash: function(){		$('iframe,object,embed,select').css('visibility', 'hidden');	},	showFlash: function(){		$('iframe,object,embed,select').css('visibility', 'visible');			},	close: function(){		if (!lightbox.loadSuccess)			$('#overlay').empty().remove();		else {			if (lightbox.timer != null)				lightbox.stopSlideshow();			$(window).unbind('resize');			$(document).unbind('keydown');			if (lightbox.options.animated){			$('#cnt_lbox').empty();			$('#cnt_lbox').animate({'height': '1px',	'opacity': '1'}, lightbox.options.animationSpeed).				animate({'width' : '1px'}, lightbox.options.animationSpeed, function(){					$('#lightbox').empty().remove();					$('#overlay').fadeOut(lightbox.options.speed, function(){						$('#overlay').remove();						lightbox.showFlash();					});				});			} else {				$('#lightbox').empty().remove();				$('#overlay').remove();				lightbox.showFlash();			}			$('html').css("overflow-x", "auto");		}		lightbox.flags.active = false;	} } // lightbox
