jQuery.preloadImages = function()
{
	for(var i = 0; i<arguments.length; i++)
	{
		jQuery("<img>").attr("src", arguments[i]);
	}
}

$.preloadImages(	"templates/d_desktop.tpl/ing_spenta.jpg"
					,"templates/d_desktop.tpl/ing_accesa.jpg"
					,"templates/d_desktop.tpl/ita_accesa.jpg"
					,"templates/d_desktop.tpl/ita_spenta.jpg"
					,"templates/d_desktop.tpl/deu_accesa.jpg"
					,"templates/d_desktop.tpl/deu_spenta.jpg"
					);

$(document).ready(function() {
	$(".imgrollover img").hover(
		function() {
			this.src = this.src.replace("_spenta","_accesa");
		},
		function() {
			this.src = this.src.replace("_accesa","_spenta");
		}
	);

	$("a.thumbnails").fancybox({overlayOpacity: 0.8, overlayColor: '#000'});
	
	function addMega(){
		$(this).addClass("hovering");
	}

	function removeMega(){
		$(this).removeClass("hovering");
	}

	var megaConfig = {    
		interval: 50,
		sensitivity: 4,
		over: addMega,
		timeout: 100,
		out: removeMega
	};
	
	$("li.mega").hoverIntent(megaConfig);

 
	$('a.thumb').click(function() { 
		$('#fotocamera img').attr('src', $('img', this).attr('alt'));
		return false; 
	});
	 
	if($('a.thumb img:first').length) {
		$('#fotocamera img').attr('src', $('a.thumb img:first').attr('alt'));
	}
	
	Initialization();
	DoPageLoad();
});
