//calcolo versione browser

var nVer = navigator.appVersion;
var nAgt = navigator.userAgent;
var browserName  = navigator.appName;
var fullVersion  = ''+parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion,10);
var nameOffset,verOffset,ix;

var ie=0;
var ie8=0;
 
if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
 browserName = "Microsoft Internet Explorer";
 fullVersion = nAgt.substring(verOffset+5);
 if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix);
	if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix);
	 
	majorVersion = parseInt(''+fullVersion,10);
	if (isNaN(majorVersion)) {
	 fullVersion  = ''+parseFloat(navigator.appVersion);
	 majorVersion = parseInt(navigator.appVersion,10);
	}
 if (majorVersion<8){
 	ie=1;
 }
 if (majorVersion<9){
 	ie8=1;
 }
}

//animazione trasparenze

$(document).ready(function() {
     
        //configure the animations
        $('#infob').mouseover(function() {
            $(this).animate( { left:"0px" }, { queue:false, duration:300 } );
            $(this).animate( { opacity:"1" }, { queue:false, duration:300 } );
        }).mouseout(function() {
            $(this).animate( { left:"-14px" }, { queue:true, duration:300 } );
            $(this).animate( { opacity:"0.6" }, { queue:false, duration:300 } );
        });
		
		$('#galle img').mouseover(function() {
            $(this).animate( { opacity:"1" }, { queue:false, duration:300 } );
        }).mouseout(function() {
            $(this).animate( { opacity:"0.6" }, { queue:false, duration:300 } );
        });
		
		if (ie8==0) {
			$('.opa').mouseover(function() {
	            $(this).animate( { opacity:"1" }, { queue:false, duration:300 } );
	        }).mouseout(function() {
	            $(this).animate( { opacity:"0.7" }, { queue:false, duration:300 } );
	        });
	    };
		
		$('#piedi2 img').mouseover(function() {
            $(this).animate( { opacity:"1" }, { queue:false, duration:300 } );
        }).mouseout(function() {
            $(this).animate( { opacity:"0.7" }, { queue:false, duration:300 } );
        });
             
    }); 

//Slideshow titolo (non lo fa per ie 6 e 7)
if (ie==0){
	$('#slideshow').crossSlide({
	  fade: 1
	}, [
	  {
	    src:  'image/1.jpg',
	    alt:  'Il Ristorante',
	    from: '100% 80% 1x',
	    to:   '100% 0% 1.2x',
	    time: 4
	  }, {
	    src:  'image/2.jpg',
	    alt:  'L\'inverno',
	    from: 'top left',
	    to:   'bottom right 1.1x',
	    time: 4
	  }, {
	    src:  'image/3.jpg',
	    alt:  'L\'estate',
	    from: 'top right 1.1x',
	    to:   'top left 1.1x',
	    time: 3
	  }, {
	    src:  'image/4.jpg',
	    alt:  'L\'estate',
	    from: 'top left',
	    to:   'bottom right 1x',
	    time: 4
	  }
	], function(idx, img, idxOut, imgOut) {
	  if (idxOut == undefined)
	  {
	    $('div.caption').text(img.alt).animate({ opacity: .7 })
	  }
	  else
	  {
	    $('div.caption').fadeOut()
	  }
	});
}	

//Galleria immagini con pirobox
	
	$(document).ready(function() {
	    $().piroBox_ext({
	        piro_speed : 500,
	        bg_alpha : 0.7,
	        piro_scroll : false 
	    });
	});


//news e last minut slide

	var headline_count;
    var headline_interval;
    var old_headline = 0;
    var current_headline = 0;
	var window_focus=true;
	
	$(window).focus(function() {
	    window_focus = true;
	})
	    .blur(function() {
	        window_focus = false;
	    });

    $(document).ready(function(){
      headline_count = $("div.headline").size();
      $("div.headline:eq("+current_headline+")").css('top', '0px');
     
      headline_interval = setInterval(headline_rotate,5000);
      $('#scrollup').hover(function() {
        clearInterval(headline_interval);
      }, function() {
        headline_interval = setInterval(headline_rotate,5000); 
        //headline_rotate();
      });
    });
    
    function headline_rotate() {
    	//alert(window_focus);
    	if (window_focus) {//alert("ciao");
	      current_headline = (old_headline + 1) % headline_count;
	      $("div.headline:eq(" + old_headline + ")")
	        .animate({top: -205},"slow", function() {
	          $(this).css('top', '250px');
	        });
	      $("div.headline:eq(" + current_headline + ")")
	        .animate({top: 0},"slow");  
	      old_headline = current_headline;
	    }
    }


//trasparenza png per ie

	function fixPNGs(){
		
	  if(jQuery.browser.msie && jQuery.browser.version < 9){
	 var i;
	 for(i in document.images){
	   if(document.images[i].src){
	  var imgSrc = document.images[i].src;
	  if(imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG'){
	  document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
	  }
	   }
	 }
	  }
	}

//modulo date

$.datepicker.setDefaults($.datepicker.regional['it']);

$(function() {
		$( "#datepicker" ).datepicker({
			changeMonth: true,
			changeYear: true
		});
	});

/* Italian initialisation for the jQuery UI date picker plugin. */
/* Written by Apaella (apaella@gmail.com). */
jQuery(function($){
	$.datepicker.regional['it'] = {
		closeText: 'Chiudi',
		prevText: '&#x3c;Prec',
		nextText: 'Succ&#x3e;',
		currentText: 'Oggi',
		monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno',
		'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'],
		monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu',
		'Lug','Ago','Set','Ott','Nov','Dic'],
		dayNames: ['Domenica','Luned&#236','Marted&#236','Mercoled&#236','Gioved&#236','Venerd&#236','Sabato'],
		dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'],
		dayNamesMin: ['Do','Lu','Ma','Me','Gio','Ve','Sa'],
		dateFormat: 'dd/mm/yy', firstDay: 1,
		isRTL: false};
	$.datepicker.setDefaults($.datepicker.regional['it']);
});

fixPNGs();




