// JavaScript Document
$(document).ready(function() {	

//immagine singola
$(".imm_singola").fancybox({
				'overlayOpacity'	: 0.75,
				'overlayColor'		: '#000',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'inside',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				    return title;
				}
			});
//galleria
$("a[rel=imm_galleria]").fancybox({
				'overlayOpacity'	: 0.75,
				'overlayColor'		: '#000',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'inside',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				    return title;
				}
			});
//galleria2 nel caso di 2 gallerie nella stessa pag
$("a[rel=imm_galleria2]").fancybox({
				'overlayOpacity'	: 0.75,
				'overlayColor'		: '#000',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'inside',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
				    return title;
				}
			});
$(".meteo_ext").fancybox({
				'width'				: 510,
				'height'			: 500,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'overlayOpacity'	: 0.75,
				'overlayColor'		: '#000'
			});
				
$("#meteo_ext").fancybox({
				'width'				: 510,
				'height'			: 500,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'overlayOpacity'	: 0.75,
				'overlayColor'		: '#000'
			});	
			
			
$("#autoscout_lnk").fancybox({
				'width'				: 800,
				'height'			: 600,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'overlayOpacity'	: 0.75,
				'overlayColor'		: '#000'
			});	

//video
$(".video_YT").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 680,
			'height'		: 495,
			'overlayOpacity'	: 0.75,
			'overlayColor'		: '#000',
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

	return false;
});

$(".variehtml").fancybox({
				'width'				: 500,
				'height'			: 400,
		        'autoScale'     	: false,
		        'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'overlayOpacity'	: 0.75,
				'overlayColor'		: '#000'
			});	
	
	});
	
	
	//banner

function bannerx1(maxban1){	
		
var ar_adessobn1=1; //banner di partenza
var ar_proxbn1=1; //banner di partenza
var ar_maxbanbn1=maxban1; //numero banner
var timefadebn1=3000; //5 secondi
var durationfadebn1=800;

//setto timer timer
//var set_tmbn1=1;
var timerrbn1 = setInterval(showDivbn1, timefadebn1);


//fade out
function showDivbn1() {	
	 
	if(ar_proxbn1!=ar_maxbanbn1){ ar_proxbn1++; }else{ar_proxbn1=1}//aumenta numero articolo
		
 		//document.getElementById("bn1_"+ar_adessobn1).style.display="none";
		//document.getElementById("bn1_"+ar_proxbn1).style.display="block";
		$("#bn1_"+ar_adessobn1).fadeOut(durationfadebn1, function(){ //fade
		//fai qualcosa
		});	
		
		$("#bn1_"+ar_proxbn1).fadeIn(durationfadebn1, function(){ //fade
		//fai qualcosa
		});	

		if(ar_adessobn1!=ar_maxbanbn1){ ar_adessobn1++; }else{ar_adessobn1=1}//aumenta numero articolo
		}
	}
	
	
	
	//sostituisci carattere
function changecar(text) {
    text = text.replace('&','e');
	
    return(text);
}
