// noConflict mode
jQuery.noConflict();



//script per l'altezza del titolo in base al monitor

// Posizionamento al caricamento della pagina
jQuery(document).ready(SetBarPosition);

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

function SetBarPosition() {
var WindowHt = jQuery(window).height(); // Altezza iniziale della finestra

//alert(WindowHt);
	if(WindowHt >= 720) {
		HeaderBottomMrg = 120;
		jQuery('.content-container').css('margin-top',HeaderBottomMrg + 'px');
		
	} else {
		HeaderBottomMrg = 60;
		jQuery('.content-container').css('margin-top',HeaderBottomMrg + 'px');
	}
	
}

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

jQuery.preloadImages("../img/gall/001.jpg", "../img/gall/002.jpg","../img/gall/003.jpg");
//preload delle immagini 

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







/*//Effetto fade applicato alle foto
jQuery(function () {
	
	// Opacità delle immagini impostate al 50%
	jQuery("#background img").css("opacity","0.0");
	
// 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(".example1").colorbox({width:"50%", inline:true, href:"#inline_example1"});
			jQuery(".example2").colorbox({width:"50%", inline:true, href:"#inline_example2"});
			jQuery(".example3").colorbox({width:"50%", inline:true, href:"#inline_example3"});
			jQuery(".example4").colorbox({width:"50%", inline:true, href:"#inline_example4"});
			
			//Example of preserving a JavaScript event for inline calls.			
});



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


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

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








jQuery(window).click(function() {
		/*	jQuery("bot_img0 a").click(function() {
				
				// Opacità delle immagini impostate al 50%
				jQuery("#background img").css("opacity","0.0");
				
			// 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");
					});
			});*/
			

		

			//alert("ccc");
			var pw = jQuery(window).width();  // page width
			var ph = jQuery(window).height(); // page height
			//resizeFooter(pw, ph, fh)
			
		  img = jQuery('#background img');
		 
		/*  iw = jQuery(img).width();			// image width
		  ih = img.height();			// image height*/
		  resizeBg(iw, ih, pw, ph);
		  
		  
		    
			
				
			
		  
			
		  setTimeout(function(){
			//  resizeBg(iw, ih, pw, ph);
		  },2000);
		  
		  
});















//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);
}


								




