$(document).ready(function(){
	//$(".items").reorder();
	
	/* MAINMENU - BACKGROUND POSITION */
	/* PRINCIPAL MENU */
	$('#principalmenu a').css( {backgroundPosition: "0px 36px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:300});
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px 36px)"}, {duration:600});
	});
	/* SECOND MENU */
	$('#secondmenu a').css( {backgroundPosition: "0px -50px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:300});
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px -50px)"}, {duration:300});
	});
	
	$('#secondmenu').localScroll();

	//popup x il download
	$("a[rel='.popup_download']").overlay({ 
  	//expose: 'darkred', 
  	//effect: 'apple', 
		onBeforeLoad: function() { 
		// grab wrapper element inside content 
			var wrap = this.getContent().find(".webcollateral"); 
			// load the page specified in the trigger 
			wrap.load(this.getTrigger().attr("href")); 
		} 
  }); 
	
	/* JQUERY TOOLS */
	/* TOOLTIPS */
	$(".trigger").css("opacity",0.5);
	$(".trigger").mouseover(function(){
		$(this).fadeTo("fast", 1);
	})
	.mouseout(function(){
		$(this).fadeTo("fast", 0.5);
	});
	/* Facebook */
	$("#lanchtooltip1").tooltip({
		position: "bottom center",
		offset: [10, 0],
		effect: 'slide',
		delay: 30,
		tip:'#tooltipfacebook'
	});
	/* Flickr */
	$("#lanchtooltip2").tooltip({
		position: "bottom center",
		offset: [10, 0],
		effect: 'slide',
		delay: 30,
		tip:'#tooltipflickr'
	});
	/* Deviant */
	$("#lanchtooltip3").tooltip({
		position: "bottom center",
		offset: [10, 0],
		effect: 'slide',
		delay: 30,
		tip:'#tooltipdeviant'
	});
	/* Twitter */
	$("#lanchtooltip4").tooltip({
		position: "bottom center",
		offset: [10, 0],
		effect: 'slide',
		delay: 30,
		tip:'#tooltiptwitter'
	});
		
	jQuery.preLoadImages($('#tooltipfacebook').css('background-image'));
	jQuery.preLoadImages($('#tooltipflickr').css('background-image'));
	jQuery.preLoadImages($('#tooltipdeviant').css('background-image'));
	jQuery.preLoadImages($('#tooltiptwitter').css('background-image'));
	//portfolio
	jQuery.preLoadImages('images/casesicure_cover.png');
	jQuery.preLoadImages('images/avis_cover.png');
	jQuery.preLoadImages('images/sandronegri_cover.png');
});
