/* THINGS TO DO IMMEDIATELY */


/* THEN THINGS TO DO ON READY */


$(document).ready(
	function()
	{
		$("*").not(".categoriaPromozioneList_instanceListBox, .categoriaUsatoList_instanceListBox").removeAttr("title");
	}
);

	
//FINALLY THINGS TO DO ON LOAD (AFTER ALL IMAGES ARE LOADED)
	
$(window).load(
	function()
	{
		//ripeto allinemaneto elementi quando tutte le immagini sono state caricate
		//centerContent();

		//activate nivo slider
		$('#slider').nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:800, //Slide transition speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:true, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			controlNavThumbsFromRel:false, //Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', //Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){}, //Triggers after all slides have been shown
			lastSlide: function(){}, //Triggers when last slide is shown
			afterLoad: function(){} //Triggers when slider has loaded
		});
		
		$("#easySlider").easySlider({
			auto: true,
			continuous: true,
			pause: 4000,
			speed: 1000,
			controlsShow: false
		});
		
		$("#easySlider_news").easySlider({
			auto: true,
			continuous: true,
			pause: 4000,
			speed: 1000,
			controlsShow: false
		});
		
		$("#easySlider_usato").easySlider({
			auto: true,
			pause: 4000,
			continuous: true,
			speed: 1000,
			controlsShow: false
		});
		
		$("#easySlider_promozioni").easySlider({
			auto: true,
			pause: 4000,
			continuous: true,
			speed: 1000,
			controlsShow: false
		});
		
		
		//animazioni
		/*
		//poi inizio l'animazione di ingresso nella pagina
		$('h1').delay( 200 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
		$('h2').delay( 400 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
		$('h3').delay( 600 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
		$('h4').delay( 800 ).animate(
			{
				left: 0,
				opacity: 1
			}, 
			500
		);
			
		//anche le immagini
		$('figure').delay( 1000 ).animate(
			{
				opacity: 1
			}, 
			500
		);
		*/
			
		//blinking su tutti i link
		//$('a').delay( 1000 ).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10).fadeOut(10).fadeIn(10);
			
		/*
		$('h2').delay( 1000 ).animate
		(
			{
				left: 0,
				opacity: 1
			}, 
			1000,
			function()
			{
				$('h4').animate
				(
					{
						left: 0,
						opacity: 1
					}, 
					1000
				);
			}
		);
			
		$('h1, h2, h3, h4').each(function(){
			$(this).animate(
				{
					left: 0,
					opacity: 1
				}, 
				2000
			);
		});
		*/
		
		/*
		$('h1, h2, h3, h4').animate(
			{
				left: 0,
				opacity: 1
			}, 
			2000
		);
		*/
		
		/*
		$('h1').fadeOut(200).fadeIn(500);
		$('h2').fadeOut(200).fadeIn(500);
		$('h3').fadeOut(200).fadeIn(500);
		$('h4').fadeOut(200).fadeIn(500);
		*/
		
		//$('h5').delay( 1800 ).fadeOut(300).fadeIn(300);
		//$('h6').delay( 2200 ).fadeOut(200).fadeIn(200);
	}
);
	
function centerContent()
{
	//allineo tutto, solo se non sono su IE
	if ( !window.aaaargh )
	{
		$('body > div').centerXY(); 
		$('body > div').centerXY();
		$('.vAlignMiddle').vAlignMiddle();
		$('.vAlignBottom').vAlignBottom();
	}
}

function ceeboxOnRelatedListLinks( genericImagesRelated )
{
	for ( var i in genericImagesRelated )
	{
		if ( $(genericImagesRelated[i]).length !== 0 )
		{
			// leggo l'url dell'<img> contenuto nell'<a> in questione
			imgUrl = $(genericImagesRelated[i]+' img').attr('src');
			// sostituisco le misure
			imgUrl = replaceQueryString(imgUrl,'width','');
			imgUrl = replaceQueryString(imgUrl,'height','');
			imgUrl = replaceQueryString(imgUrl,'widthheight','1000');
			imgUrl = imgUrl+'&allowZoom=no';
			// tutto questo url lo piazzo come href dell' <a>
			$(genericImagesRelated[i]).attr('href',imgUrl);			
			// aggiungo la property "rel='image'"
			$(genericImagesRelated[i]).attr('rel','image');			
			// aggiungo la classe css "popupImage"
			//$(genericImagesRelated[i]).addClass('popupImage');
			$(genericImagesRelated[i]).addClass('popupImageAddedAfter');
		}
		
	}
	//alla fine ri-attivo il ceebox
	$(".popupImageAddedAfter").ceebox({titles:false,margin:"20",padding:"10"});
	
}
