		
		var stageH = $(window).height();
		var stageW = $(window).width();
		var link_Array = new Array () 
		
function colonna(){
	
	minHeight  = $('.content_outer').height();
	

	$('.colonna').css({
		
		'min-height':minHeight+'px',
		'height':'auto !important',
		'height':minHeight+'px'
	})
	
	$('<div class="colonna_image"></div>').appendTo('.colonna');
	
	
	
	

 

 
	
}		
		
		
function start(){
 	
	// faetano_ita // faetano_eng // serravalle_ita // serravalle_eng
	link_Array.push($('.faetano_ita').attr('href'),$('.faetano_eng').attr('href'),$('.serravalle_ita').attr('href'),$('.serravalle_eng').attr('href'));
	
	
 	$('.faetano_ita, .faetano_eng, .serravalle_ita, .serravalle_eng').attr('href','#');
 	
 
 	$('<div class="blackDIV"></div>').appendTo('body.home');
	$('<div class="whiteDIV"></div>').appendTo('body.home');
	
	$('.blackDIV').css({
			'top':'0px',
			'left':'0px',
			'z-index':0,
			'width':stageW/2+'px',
			'height':stageH+'px',
			'position':'absolute',
			'background-color':'black'
	})
	$('.whiteDIV').css({
			
			'top':'0px',
			'right':'0px',
			'z-index':0,
			'width':stageW/2+'px',
			'height':stageH+'px',
			'position':'absolute',
			'background-color':'white'
	})
	
	//$('<div class="controllo" style="color:#fff"></div>').prependTo('body');
	
	var count = 0;
	
	$('.entera, .enterb, .A, .B, .logoIntro').css({'display':'none'});
	
		int = window.setInterval(function () {
					intro(1);
		},10);
	/*
	$('.entera').click(function() {
 		intro(2);
	});
	$('.enterb').click(function() {
 		intro(3);
	});
	*/
	$('.faetano_ita').click(function() {
 		intro(2);
	});
	$('.faetano_eng').click(function() {
 		intro(3);
	});
	
	$('.serravalle_ita').click(function() {
 		intro(4);
	});
	$('.serravalle_eng').click(function() {
 		intro(5);
	});
	
	
	function intro(seqpass){
	
	count++
	if(seqpass==1){
		if(count == 1){
		$('.logoIntro').fadeIn('slow', function() {
		// Animation complete
		});
		}	
		else if(count == 10){
		$('.A').fadeIn('slow', function() {
		// Animation complete
		});
		}
		else if(count == 25){
		$('.B').fadeIn('slow', function() {
		// Animation complete
		});
	
		}
		else if(count == 40){
		$('.entera').fadeIn('slow', function() {
		// Animation complete
		});
		}
		else if(count == 55){
		$('.enterb').fadeIn('slow', function() {
		// Animation complete
		clearInterval(int);
		count = 0;
		});
		}
	}
	else if(seqpass==2){
		var sposta =  $(window).width() / 2;
		$('.wrap').fadeOut('fast', function() {
		// Animation complete
		//$(".img_"+0).animate({width:"960px", opacity:'toggle', left:"0px" },tempoTransizione);
			$('.logoIntro').fadeOut('fast', function() {
				$('.blackDIV').animate({width:stageW+"px"},500,'swing', function() {
    						curlink = link_Array[0]
							open(curlink,'_self');
  				}).css('z-index','2');
			})	
				
		})
		
	}
	else if(seqpass==3){
		var sposta =  $(window).width() / 2;
		$('.wrap').fadeOut('fast', function() {
		// Animation complete
		//$(".img_"+0).animate({width:"960px", opacity:'toggle', left:"0px" },tempoTransizione);
			$('.logoIntro').fadeOut('fast', function() {
				$('.blackDIV').animate({width:stageW+"px"},500,'swing', function() {
    						curlink = link_Array[1]
							open(curlink,'_self');
  				}).css('z-index','2');
			})	
				
		})
		
	}
	else if(seqpass==4){
		var sposta =  $(window).width() / 2;
		$('.wrap').fadeOut('fast', function() {
		
			$('.logoIntro').fadeOut('fast', function() {
				$('.whiteDIV').animate({width:stageW+"px"},500,'swing', function() {
    						curlink = link_Array[2]
							open(curlink,'_self');
  				}).css('z-index','2');
			})	
		})
		
	}
	else if(seqpass==5){
		var sposta =  $(window).width() / 2;
		$('.wrap').fadeOut('fast', function() {
		
			$('.logoIntro').fadeOut('fast', function() {
				$('.whiteDIV').animate({width:stageW+"px"},500,'swing', function() {
    						curlink = link_Array[3]
							open(curlink,'_self');
  				}).css('z-index','2');
			})	
		})
		
	}}

}


function posizionaElementiHome(){
		stageH = $(window).height();
		stageW = $(window).width();

		var logotop = 200;
		var logoheight = 237;
		var logofset = 137;
		var limitspace = ( logotop+logoheight+logofset);
		var wraptop = 470;
		var logoTopNEW = logotop - (limitspace-stageH);
		var wrapTopNew = wraptop - (limitspace-stageH);
		var offsetTop = 30;
		var offsetTopWrap = 300;
		
		if(stageH <= limitspace){
			
			//$('.controllo').text(stageH+'px ' +   logoTopNEW);
			$('.logoIntro').css({'top':logoTopNEW+'px'})
			$('.wrap').css({'top':wrapTopNew+'px'})
		
		}
		if(logoTopNEW <= offsetTop){
			
			$('.logoIntro').css({'top':offsetTop+'px'})
			$('.wrap').css({'top':offsetTopWrap+'px'})
		
		}
		
		$('.blackDIV').css({
		
			'width':stageW/2+'px',
			'height':stageH+'px'
		
		})
		$('.whiteDIV').css({
		
			'width':stageW/2+'px',
			'height':stageH+'px'
		
		})

		//$('.controllo').text(stageH+'px ' +   logoTopNEW);
}
$(window).resize(function() {
	posizionaElementiHome();
});


function esiste(idPassato){
		if ($(idPassato).length)return true;
}


$(document).ready(function(){
		posizionaElementiHome();
		start();

		if(esiste('.homepage')){
			$('.home_color').css({
				'display':'none'
			});
			$('body, html').css({
				'background-image':'none'
			})
		}
})

$(window).load( 

	function (){
		
		colonna();
		
		if(esiste('.homepage')){
			
			$('.home_color').fadeIn('slow')
		}

});


