mbLeft=new Array(); //viene creato l'array
mbLeft[0]="0";
mbLeft[1]="87";
mbLeft[2]="217";
mbLeft[3]="347";
mbLeft[4]="477";
mbLeft[5]="607";

mbWidth=new Array(); //viene creato l'array
mbWidth[0]="0";
mbWidth[1]="71";
mbWidth[2]="67";
mbWidth[3]="74";
mbWidth[4]="43";
mbWidth[5]="66";

var spegni;

$(document).ready(function(){

	setTimeout('dimensiona()',200);
	
	if ($("#cursore").length>0) {
		$("#cursore").animate({opacity: 0},0);	
	}

	if ($("#header ol li span").length>0) {
		//alert("eccolo");
		var mbNowId=$("#header ol li span").attr('id');
		var tmp=mbNowId.split("-");
		id=tmp[1];
		//alert(id);
		$("#mbLink-"+id+" big").css('width', (mbWidth[id]-4)+"px")		
		//$("#cursore").css('width',mbWidth[id]+"px");
		//$("#cursore").css('left',mbLeft[id]+"px");*/		
	} else {
		$("#cursore").hide();		
	}

	$("#header ol li a").mouseenter(function() {
		var id=$(this).attr('id');
		var tmp=id.split("-");
		id=tmp[1];
		//$("#cursore");
		$("#cursore").show().stop(true, false).animate({opacity: 1, width: mbWidth[id], left: mbLeft[id]}, 200);	
	});
			
	$("#header ol li a").mouseleave(function() {
		var id=$(this).attr('id');
		var tmp=id.split("-");
		id=tmp[1];
		$("#cursore").stop(true, false).animate({opacity: 0}, 200);
	});

	
	$(".portfolio .listato li").mouseenter(function() {
		var myId=$(this).attr('id');
		$("#"+myId+" span").stop(true, false).animate({top: 188}, 300);
		$("#"+myId+" .cover").stop(true, false).animate({opacity: 0}, 300);
	}); 

	$(".portfolio .listato li").mouseleave(function() {
		var myId=$(this).attr('id');
		$("#"+myId+" span").stop(true, false).animate({top: 100}, 200);
		$("#"+myId+" .cover").stop(true, false).animate({opacity: 1}, 200);
	});
	
	$(".anchorLink").click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		$.scrollTo( this.hash, 1000);
		return false;
	});

	if ($(".capture").length>0) {
		$(".capture").fancybox({
			'autoScale' : false,
			'autoDimensions' : false
		});	
	}
	
	if ($(".myToggle").length>0) {
		$('.myToggle').click(function(event) {
		    $("#borsaviaggi").slideToggle();
			event.preventDefault();
			var scrolla=setTimeout('gotoBorsa()',400);
		});
	}

	if ($(".fancyVideo").length>0) {
		$(".fancyVideo").fancybox({
			'width' : 300,
			'height' : 250,
			'autoScale' : false,
			'autoDimensions' : false
		});
	};

});


function gotoBorsa() {
	$.scrollTo("#footer", 600);
	return false;
}

function dimensiona() {
	
	if ($("#headline p").length>0) {
		var paragrafoWidth=$("#headline h6").width();
		$("#headline p").css('width',paragrafoWidth+'px');
	}

	if ($(".portfolio").length>0) {
		var listaWidth=$(".portfolio").width();
		$(".portfolio ul").css('width',(listaWidth-211)+'px');
	}

	
}
