// JavaScript Document
$(document).ready(function () {
        
          // Definizioni 
	
	var fade = 100;
	var sposta = 500;
	
	// Campi input	
	$('input,textarea').emuPlaceholder();
	
	// Spot homepage
	$('.link-spot').mouseenter( function () { 
		apri( $(this).attr("id") );
	});
	
	$('.link-spot').mouseleave( function () {
		chiudi();
	});
	
	
	// Apre uno spot
	function apri (id) {
				
		var selectedItem;
		var arrayPosition = new Array();
		var arrayWidth = new Array();
			
		switch(id) {
			
			case "link-spot-1":
				selectedItem = 1; 
				arrayPosition =  ["0","580","755"];
				arrayWidth = ["580","175","175"];
			break;
			
			case "link-spot-2":
				selectedItem = 2; 
				arrayPosition =  ["0","175","755"];
				arrayWidth = ["175","580","175"];
			break;
			
			case "link-spot-3":
				selectedItem = 3; 
				arrayPosition =  ["0","175","350"];
				arrayWidth = ["175","175","580"];
			break;
		}
				
		$('#link-spot-1').stop().animate({  left: arrayPosition[0] + 'px' , width: arrayWidth[0] + 'px' }, sposta );
		$('#link-spot-2').stop().animate({  left: arrayPosition[1] + 'px' , width: arrayWidth[1] + 'px' }, sposta );
		$('#link-spot-3').stop().animate({  left: arrayPosition[2] + 'px' , width: arrayWidth[2] + 'px' }, sposta );
	}
	
	
	// Chiude gli spot e torna alla situazione di origine
	function chiudi () {
		
		var arrayPosition = new Array("0","310","620");
		for (t=1; t<4;t++) {
			$('#link-spot-'+t).stop().animate({  left: arrayPosition[(t-1)] + 'px' , width: '310px'}, sposta );// Movimento
		}
			
	}
	
	/* shadow IE */
	
	if ($.browser.msie) {
		
		var count = 0;
		$(".page-content img").each (function () {
		
			var pos = $(this).position();	
			var str = $(this).attr("class");
			if (str.indexOf("alignright") != -1) {
				pos.left += 20;	
			}
			
			if (str.indexOf("alignleft") != -1) {
				pos.left -= 4;
			}
			
			$(this).after("<div id='ie-shadow" + count + "' class='ie-shadow'></div>");
			$("#ie-shadow" + count).width( $(this).width() ) .height( $(this).height() ).css("left", (pos.left + 4) + "px").css("top",(pos.top + 4) + "px");
			$(this).css("position" , "relative").css("z-index" , "100");
			count++;
			
		});
		
		
	}

	
});


