

jQuery(document).ready(function(){
 
	jQuery('#alpha').fadeIn(1000);
 
});
 



var ih = 1500; // bacgrkound image height
var iw = 2000; // bacgrkound image width
var img; // bacgrkound image element
var fh; // footer height





jQuery("#foto").css("display:none");
// Posizionamento al caricamento della pagina
jQuery(document).ready(SetBarPosition);


// Posizionamento al ridimensionamento della finestra 
jQuery(window).resize(SetBarPosition);

jQuery(window).resize(function() {
  refreshPage();
});


// resize footer on window load
jQuery(window).load(function() {
   	 
	 img = jQuery('#background img');
    
	
	var pw = jQuery(window).width();  // page width
    var ph = jQuery(window).height(); // page height
    //resizeFooter(pw, ph, fh)
	
 

  iw = jQuery(img).width();			// image width
  ih = img.height();			// image height
   resizeBg(iw, ih, pw, ph);
	
  setTimeout(function(){
	  
     resizeBg(iw, ih, pw, ph);
  },6000);
  
 
});




//resize background image
function resizeBg(iw, ih, pw, ph) { //args: image width, image height, page width, page height */
	
	
  if (ih > ph && iw < pw) {
    img.css('width', pw+'px');
    img.css('height', ((ih*pw)/iw)+'px');
	
  } else if (ih < ph && iw > pw) {
    img.css('height', ph+'px');
    img.css('width', ((ph*iw)/ih)+'px');
	
  } else if (ih > ph && iw > pw) {
    if (((ih*pw)/iw) >= ph) {
      img.css('width', pw+'px');
      img.css('height', ((ih*pw)/iw)+'px');
    } else {
      img.css('height', ph+'px');
      img.css('width', ((ph*iw)/ih)+'px');
    }
  } else if (ih < ph && iw < pw) {
    if (((ih*pw)/iw) >= ph) {
      img.css('width', pw+'px');
      img.css('height', ((ih*pw)/iw)+'px');
    } else {
      img.css('height', ph+'px');
      img.css('width', ((ph*iw)/ih)+'px');
    }
  }
}



function refreshPage(){
    var pw = jQuery(window).width();  // page width
    var ph = jQuery(window).height(); // page height
    resizeBg(iw, ih, pw, ph);
    //resizeFooter(pw, ph, fh);
}



//preload delle immagini 
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

jQuery.preloadImages("img/bk03.jpg","gall/001.jpg","gall/002.jpg","gall/003.jpg","gall/004.jpg","gall/005.jpg","gall/006.jpg","gall/007.jpg");
//preload delle immagini 




//script per l'altezza del titolo in base al monitor
function SetBarPosition() {
		var WindowHt = jQuery(window).height(); // Altezza iniziale della finestra
		if(WindowHt >= 830) {
		HeaderBottomMrg = 120;
		jQuery('.titolo').css('margin-top',HeaderBottomMrg + 'px');
		
	} else {
		HeaderBottomMrg = 65;
		jQuery('.titolo').css('margin-top',HeaderBottomMrg + 'px');
	}
	
}









/*//Effetto fade applicato alle foto
jQuery(function () {
	
	// Opacità delle immagini impostate al 50%
	
	
// Al passaggio del mouse
	jQuery("#background img").load(function () {
	
	// imposta l'opacità al 100%
			jQuery(this).stop().animate({
			opacity: 1.0
			}, "slow");
},

// quando il mouse non è sull'elemento
function () {

		// imposta l'opacità al 50%
			jQuery(this).stop().animate({
			opacity: 0.5
			}, "slow");
		});
});
*/
//per il box di apertura del testo

jQuery(window).ready(function(){
				
			jQuery(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
			//Example of preserving a JavaScript event for inline calls.			
});









function bg(foto) {
	 var pw = jQuery(window).width();  // page width
    var ph = jQuery(window).height(); // page height
 img = jQuery('#background img');

  iw = jQuery(img).width();			// image width
  ih = img.height();			// image height
   resizeBg(iw, ih, pw, ph);
	
 
	
		  
		  
};









function cambia(foto) {
					
			switch (foto) {
										
				case "01":
					
					resizeBg();
					img = "<img src=\"gall/001.jpg\" alt=\"\" />";
				break;
				case "02":
					img = "<img src=\"gall/002.jpg\" alt=\"\" />";
					//refreshPage();
				break;
				case "03":
					img = "<img src=\"gall/003.jpg\" alt=\"\" />";
					//refreshPage();
				break;
				case "04":
					img = "<img src=\"gall/004.jpg\" alt=\"\" />";
					//refreshPage();
				break;
				case "05":
					img = "<img src=\"gall/005.jpg\" alt=\"\" />";
					//refreshPage();
				break;
				case "06":
					img = "<img src=\"gall/006.jpg\" alt=\"\" />";
					//refreshPage();
				break;
				case "07":
					img = "<img src=\"gall/007.jpg\" alt=\"\" />";
					//refreshPage();
				break;
				default:
				img = "<img src=\"../img/bk02\" alt=\"\" />";
			 }
		
		//document.getElementById("tit").innerHTML = titolo;
		 
		 
	
		 
	
document.getElementById("foto").innerHTML = img;
}













								




