$(document).ready(function() {

	// gestione IMG HOVER
	$(".icsmMouseOver").each(function() {
		var src = $(this).attr('src');
		var extension = src.substring(src.lastIndexOf('.'),src.length);
		$(this).mouseover(function() {
			$(this).attr('src',src.replace(extension,'-on' + extension));
		});
		$(this).mouseout(function() {
			$(this).attr('src',src);
		});
	});
	
	//Replace Font
	FLIR.init({ path: '/facelift/' });
	$(".flir").each(function() {
		FLIR.replace(this);
	});	
	
	//Galleria fotografica	
	if ($(".photogallery").length > 0) {
		var	imageVisible = 1
		var totImageGallery = parseInt($("#totImgGallery").html());
		var timeFade = 1000;
				
		$(".imgNumeration").not(":first").each(function() {
			$(this).hide();
		});
				
		//Prev e Next
		$(".next").click(function() {
			if (imageVisible < totImageGallery) {
				$("#ph"+imageVisible).fadeOut(timeFade);
				$("#numPag"+imageVisible).hide();
				imageVisible++;
				$("#ph"+imageVisible).fadeIn(timeFade);
				$("#numPag"+imageVisible).show();
			}
		});
		$(".prev").click(function() {
			if (imageVisible > 1) {
				$("#ph"+imageVisible).fadeOut(timeFade);
				$("#numPag"+imageVisible).hide();
				imageVisible--;
				$("#ph"+imageVisible).fadeIn(timeFade);
				$("#numPag"+imageVisible).show();
			}
		});	
	}
	
	//Apertura in nuova finestra
	$(".tBlank").click(function() {
		var url = $(this).attr('href');
		//window.open(url, "", "width=1000,height=600");
		window.open(url);
		return false;
    });
    
    //Fancybox
	$("a.fancybox").fancybox({
		  'titleShow'		   : false
		, 'overlayOpacity'	   : 0.65
		, 'overlayColor'	   : '#fff'
		, 'padding'			   : 0
//		, 'centerOnScroll'     : true
		, 'hideOnOverlayClick' : false		
	});
	
	$(".concorsoIframe.iframe").fancybox({
		  'titleShow'		   : false
		, 'overlayOpacity'	   : 0.65
		, 'overlayColor'	   : '#fff'
		, 'padding'			   : 0
		, 'centerOnScroll'     : true
		, 'hideOnOverlayClick' : false
		, 'width'  			   : 418	
		, 'height'			   : 510
		, 'scrolling'          : 'yes'
		, 'padding'			   : 0
		, 'margin'             : 0
	});
	
	$("a.fancybox.iframe").fancybox({
		  'titleShow'		   : false
		, 'overlayOpacity'	   : 0.65
		, 'overlayColor'	   : '#fff'
		, 'padding'			   : 0
//		, 'centerOnScroll'     : true
		, 'hideOnOverlayClick' : false
		, 'width'  			   : 400	
		, 'height'			   : 370
		, 'scrolling'          : 'no'
		, 'padding'			   : 0		
		, 'margin'             : 0
	});
		
	//Fancybox
	$("a.social").fancybox({
		  'titleShow'		   : false
		, 'overlayOpacity'	   : 0.75
		, 'overlayColor'	   : '#000'
		, 'padding'			   : 0
//		, 'centerOnScroll'     : true
		, 'hideOnOverlayClick' : false
		, 'width'  			   : 500	
		, 'height'			   : 240
		, 'scrolling'          : 'no'
		, 'padding'			   : 0
		, 'margin'             : 0
	});

});