var _boxCurrentX = 0;
var _boxCurrentY = 0;
var _maxBoxHeightInRow = 0;
var _boxContentHeight = 0;
var _boxExited = 0;
var _boxShowed = 0;
var _lastBoxesInRow = null;
var _intervalIDHeaderSlideshow = null;
var _currentHeaderSlideshowImg = 0;
var _idMenuToLoad = 1;
var _menuGhost = 0;
var _idDetailToLoad = 0;
var _idProductToLoad = "";

/* GESTIONE TAG PRODOTTI */
var TIME_TO_TAG_RESET = 4000;
var TIME_TO_MOVE_OVERLAYER = 400;
var _idTagBoxClosed = new Array();
var _idTagBoxClosedTimeout = new Array();

function ricreaArray(array, indice)
{
	var newArray = new Array();
	if(indice == 0)
	{
		if(array.length > 1)
			newArray = array.slice(1, array.length);
	}else
	{
		newArray = array.slice(0, indice);
		if(indice < array.length)
		{
			var array1 = array.slice(indice + 1, array.length);
			for(var i = 0; i < array1.length; i++)
				newArray.push(array1[i]);
		}
	}
	return newArray;
}

function checkID(tmpID)
{
	var i=0;
	var ok = false;
	while((i < _idTagBoxClosed.length)&&(!ok))
	{
		if(_idTagBoxClosed[i] == tmpID)
		{
			ok = true;	
		}else
		{
			i = i + 1;
		}
	}
	return i;
}

function loadContentData(pIdMenu, pIdDetail, pIdProduct)
{
	stopIntervalHeaderSlideshow();

	//SETTO IL MARGIN-TOP DEL CONTENT
	if((pIdDetail > 0 || pIdProduct != "") && pIdMenu != 999) 
	{
		if(jQuery.browser.msie && jQuery.browser.version <= 7)
			jQuery("#overbox-content-ie7").css('margin-top', '262px');
		jQuery("#content").css('margin-top', '262px');
		//jQuery("#smile_tag_social").css('margin-top', '148px');
	}else 
	{
		if(jQuery.browser.msie && jQuery.browser.version <= 7)
			jQuery("#overbox-content-ie7").css('margin-top', '262px');
		jQuery("#content").css('margin-top', '262px');
		//jQuery("#smile_tag_social").css('margin-top', '262px');
	}
	//jQuery("#content").css('overflow', 'hidden');
	jQuery("#background_center").show();
	
	_boxCurrentX = jQuery(".menu").width();
	_boxCurrentY = 0;
	_maxBoxHeightInRow = 0;
	_boxContentHeight = parseInt(jQuery("#content").css("margin-top"), 10) + parseInt(jQuery("#content").css("margin-bottom"), 10);
	_lastBoxesInRow = null;
	_currentHeaderSlideshowImg = 0;
	
	jQuery("#sfondo").css('visibility', 'visible');
	
	var currUrl = window.location.href.replace("#", "?");

	if(jQuery.browser.msie && jQuery.browser.version <= 7)
		jQuery("#overbox-content-ie7").html('');
	
	var sectionToTrack = window.location.hash.replace("#","");
	//traccio la sezione su analytics
	trackAnalytics(sectionToTrack);
	
	
	jQuery.ajax({
	    type: "POST",
	    url: "section_content.php",
	    data: "IdMenu=" + pIdMenu + "&IdDetail=" + pIdDetail + "&IdProduct=" + pIdProduct + "&Url=" + currUrl,
	    cache: false,
	    async: false,
	    success: function(xmlData)
	    {		
		 	if (jQuery(xmlData).find('sfondo').length > 0)
			{
				//carico tutte le immagini dello sfondo
				loadBackgroundImage(jQuery(xmlData).find('sfondo').find('bkgTop').text(), jQuery(xmlData).find('sfondo').find('bkgBottom').text());
			}

		 
	 		//controllo se devo cambiare l'header della pagina
	 		var headerHtml = "";
	 		if (jQuery(xmlData).find('header').find('image').length > 0)
	 		{
	 			jQuery(xmlData).find('header').find('image').each(function(){
	 				headerHtml += "<img src=\"" + jQuery(this).text() + "\" style=\"display:none;\">";
	 			});
	 		}
	 		if (jQuery(xmlData).find('header').find('video').length > 0)
	 		{
				headerHtml = '<div style="background-image:url(img/gradient_header.png); background-repeat:no-repeat; background-position:bottom; height:132px; width:980px; position:absolute; top:418px;"></div>'
                headerHtml += '<div class="box_video_cnt">' +
					         '   <div class="head_video_cnt box_video_file" id="head_video" file="' + jQuery(xmlData).find('header').find('video').text() + '" hideControls="1" loop="1">' +
							 '	    <a href="http://www.adobe.com/go/getflashplayer">' +
			                 '    		<img src="img/get_flash_player.gif" border="0" alt="Get Adobe Flash player" border="0" />' +
			                 '    	</a>' +
		    				 '	</div>' +
		        			 '</div>';							 
	 		}
			
			var headerButton = "";
			//controllo se ci sono bottoni da mettere nell'header
			if (jQuery(xmlData).find('header').find('button').length > 0)
	 		{
	 			jQuery(xmlData).find('header').find('button').each(function(){
	 				headerButton += "<a class='button_header' target='"+jQuery(this).attr("target")+"' style='top:"+jQuery(this).attr("posy")+"px; left:"+jQuery(this).attr("posx")+"px;' href='"+jQuery(this).attr("link")+"'><img src=\"" + jQuery(this).text() + "\" border='0'></a>";
	 			});
	 		}
	 		
			var titlePage = "";
			//controllo se nella pagina è presente un titolo
			if (jQuery(xmlData).find('pageTitle').length > 0)
			{
				titlePage = '<div class="container_title_page">'+jQuery(xmlData).find('pageTitle').text()+'</div>'
				//jQuery("#wrap_title").css("display","inline");
				jQuery("#wrap_title").fadeIn();
				jQuery("#wrap_title").html(titlePage);
				
				//SETTO IL MARGIN-TOP DEL CONTENT SE HO UN TITOLO IN PAGINA E UNA SEZIONE GHOST
				if(jQuery(".title_page").attr("isGhostPage") == "1" )
				{
					if(jQuery.browser.msie && jQuery.browser.version <= 7)
						jQuery("#overbox-content-ie7").css('margin-top', '440px');
					jQuery("#content").css('margin-top', '440px');
					//jQuery("#smile_tag_social").css('margin-top', '440px');
					_boxContentHeight = parseInt(jQuery("#content").css("margin-top"), 10) + parseInt(jQuery("#content").css("margin-bottom"), 10);
				}
			}
			else
			{
				//jQuery("#wrap_title").fadeOut();
				jQuery("#wrap_title").hide();
				jQuery("#wrap_title").html("");
			}
			
	 		if (headerHtml != "")
	 		{
		 		jQuery("#video_img_container").html(headerHtml);
		 	}
			
			if(headerButton != "")
			{
				jQuery("#button_header_container").hide();
				jQuery("#content").html(headerButton);
				
				//jQuery("#content").fadeIn();
				jQuery("#content").show();
				
				//jQuery("#button_header_container").html(headerButton);
				//jQuery("#button_header_container").fadeIn();
			}
						
			var contamiIlBox = 0;
			var rowNum = 0;
			var tagTimeout;

			jQuery(xmlData).find('box').each(function()
			{
				//calcolo il delay utilizzato per la visualizzazione del box
				var show_delay = (DELAY_MAX_RANDOM_BOX_SHOW * Math.random()) + DELAY_MIN_RANDOM_BOX_SHOW;
				var hide_delay = (DELAY_MAX_RANDOM_BOX_HIDE * Math.random()) + DELAY_MIN_RANDOM_BOX_HIDE;
			
				var nodoHtml = "";
				var nodoHtmlIE7 = "";

				if (jQuery(this).find("htmlproduct").length > 0)
				{
					nodoHtml = '<div id="b_' + contamiIlBox + '" row="' + rowNum + '" class="box box_show_hide_delay" showdelay="' + show_delay + '" hidedelay="' + hide_delay + '" style="left:' + _boxCurrentX + 'px;top:' + _boxCurrentY + 'px;z-index:' + (jQuery(xmlData).find('box').length - jQuery("#content").children(".box").length) + '>' + jQuery(this).find("htmlproduct").text() + '</div>';
				}
				else
				{
					var backgroundImage = "";
					if (jQuery(this).attr("backgroundImage") != null && jQuery.trim(jQuery(this).attr("backgroundImage")) != "")
						backgroundImage = ";background-image: url('" + jQuery(this).attr("backgroundImage") + "');";
						
					var directLink = "";
					if (jQuery(this).attr("directLink") != null && jQuery.trim(jQuery(this).attr("directLink")) != "")
						directLink = " directlink='" + jQuery(this).attr("directLink") + "'";
					
					nodoHtml = '<div id="b_' + contamiIlBox + '" ' + directLink + ' row="' + rowNum + '" class="box ' + jQuery(this).attr('class') + ' box_show_hide_delay" showdelay="' + show_delay + '" hidedelay="' + hide_delay + '" style="left:' + _boxCurrentX + 'px;top:' + _boxCurrentY + 'px;z-index:' + (jQuery(xmlData).find('box').length - jQuery("#content").children(".box").length) + backgroundImage + '"' + (jQuery(this).attr("idContent") != null ? ' idContent="' + jQuery(this).attr("idContent") + '"' : '') + (jQuery(this).attr("hashName") != null ? ' hashName="' + jQuery(this).attr("hashName") + '"' : '') + (jQuery(this).attr("codiceProdotto") != null ? ' codiceProdotto="' + jQuery(this).attr("codiceProdotto") + '"' : '') + (jQuery(this).attr("gallerygroup") != null ? ' gallerygroup="' + jQuery(this).attr("gallerygroup") + '"' : '') + (jQuery(this).attr("gallerysource") != null ? ' gallerysource="' + jQuery(this).attr("gallerysource") + '"' : '') + (jQuery(this).attr("galleryvideosource") != null ? ' galleryvideosource="' + jQuery(this).attr("galleryvideosource") + '"' : '') + (jQuery(this).attr("galleryindexgroup") != null ? ' galleryindexgroup="' + jQuery(this).attr("galleryindexgroup") + '"' : '') + '>' + 
										'<div class="box_content">';
											  		
					if (jQuery(this).find("video").length > 0)
					{
						nodoHtml += 		'<div id="box_' + jQuery("#content").children(".box").length + '" class="box_frame_video box_html_content" overEnabled="1">' +
		                					'    <a class="player_video" href="javascript:void(0)"></a>' +
					               			    '    <img src="' + jQuery(this).find("preview").text() + '" />' +
		                    				'</div>' + 
											'<div class="box_html_over"></div>' +
						                    '<div class="box_video_cnt">' +
	    							        '    <div id="box_video_content_' + jQuery("#content").children(".box").length + '" class="box_video_cnt box_video_file" file="' + jQuery(this).find("video").text() + '">' +
	                    					'	    <a href="http://www.adobe.com/go/getflashplayer">' +
			            	                '    		<img src="img/get_flash_player.gif" border="0" alt="Get Adobe Flash player" border="0" />' +
		    				                '    	</a>' +
	        	            				'	</div>' +
			                    			'</div>';
					}
					else
					{													  	
						nodoHtml += 		'<div id="box_' + jQuery("#content").children(".box").length + '" class="box_html_content" overEnabled="1">' + jQuery(this).find('html').text() + '</div>' +
											'<div class="box_html_over"></div>';
					}

					
					if (jQuery(this).attr("codiceProdotto") != null && jQuery.trim(jQuery(this).attr("codiceProdotto")) != "")
					{
						//nodoHtml += 		'<a href="javascript:void(0)" title="social networks" class="smile"></a>';
					}
					
					
					nodoHtml +=		'</div>' +
								'</div>';
								
					if(jQuery.browser.msie && jQuery.browser.version <= 7)
					{
						nodoHtmlIE7 = '<div style="left:' + _boxCurrentX + 'px;top:' + _boxCurrentY + 'px;" class="box_over_ie7 ' + jQuery(this).attr('class') + '" idel="' + jQuery("#content").children(".box").length + '">';
						nodoHtmlIE7 = nodoHtmlIE7 + '</div>';
					}
				}		
				jQuery("#content").append(nodoHtml);
				//serve per rifare il parser degli elementi XFBML (bottoni mi piace)
				
				if(jQuery.browser.msie && jQuery.browser.version <= 7 && jQuery.trim(nodoHtmlIE7) != '')
					jQuery("#overbox-content-ie7").append(nodoHtmlIE7);
				
				contamiIlBox++;
				
				var lastBox = jQuery("#content").children(".box:eq(" + (jQuery("#content").children(".box").length - 1) + ")");
				
				//calcolo la height per i box di dettaglio che hanno l'altezza variabile
				if (jQuery(lastBox).hasClass("box_3xauto"))
				{
					jQuery(lastBox).find(".box_html_content").attr("overEnabled", "0");
					jQuery(lastBox).find(".box_html_content").css("cursor", "default");
					
					jQuery(lastBox).css("visibility", "hidden").css("display", "block");
					var hB = 0;				
					jQuery(lastBox).find(".box_html_content").children().each(function()
					{
						if(!jQuery(this).hasClass("hide"))
							hB += jQuery(this).height() + parseInt(jQuery(this).css("padding-top"), 10) + parseInt(jQuery(this).css("padding-bottom"), 10) + parseInt(jQuery(this).css("margin-top"), 10) + parseInt(jQuery(this).css("margin-bottom"), 10);
					});

					jQuery(lastBox).find(".box_html_content").css("height", hB + "px");		
					jQuery(lastBox).css("height", hB + "px");			
					jQuery(lastBox).css("display", "none").css("visibility", "visible");
				}
				
				_boxCurrentX += jQuery(lastBox).width() + BOX_BORDER_SIZE;
				
				if (_boxCurrentX > jQuery("#content").width() || (jQuery(lastBox).height() > _maxBoxHeightInRow && _maxBoxHeightInRow > 0) || jQuery(this).attr("forceLineFeed") == "1")
				{
					if (_lastBoxesInRow == null)
						_lastBoxesInRow = new Array();
					if (contamiIlBox > 0)
						_lastBoxesInRow.push(jQuery("#b_" + (contamiIlBox - 2)));
					
					_boxCurrentX = jQuery(".menu").width();
					_boxCurrentY += _maxBoxHeightInRow + BOX_BORDER_SIZE;
					rowNum++;
					
					_boxContentHeight += _maxBoxHeightInRow + BOX_BORDER_SIZE;
					
					_maxBoxHeightInRow = 0;

					jQuery(lastBox).css("left", _boxCurrentX + "px");
					jQuery(lastBox).css("top", _boxCurrentY + "px");
					jQuery(lastBox).attr("row", rowNum);
					
					if(jQuery.browser.msie && jQuery.browser.version <= 7)
					{
						var lastBoxIE6 = jQuery("#overbox-content-ie7").children(".box_over_ie7:eq(" + (jQuery("#overbox-content-ie7").children(".box_over_ie7").length - 1) + ")");
						jQuery(lastBoxIE6).css("left", _boxCurrentX + "px");
						jQuery(lastBoxIE6).css("top", _boxCurrentY + "px");
					}
					
					//attacco lo smile
					//alert(jQuery(lastBox).attr("codiceProdotto") + " || " + jQuery(lastBox).attr("id"))
					if (jQuery(lastBox).attr("codiceProdotto") != null && jQuery.trim(jQuery(lastBox).attr("codiceProdotto")) != "")
					{
						jQuery("#smile_tag_social").append('<a href="javascript:void(0)" parent="'+jQuery(lastBox).attr('id')+'" title="tags" class="smile" style="left:' + (_boxCurrentX + jQuery(lastBox).width() - 25) + 'px;top:' + (_boxCurrentY + 7) + 'px;"></a>');
					}
					
					_boxCurrentX += jQuery(lastBox).width() + BOX_BORDER_SIZE;
				}
				else
				{
					
					//controllo se effettuare un allineamento bottom in caso di box più basso dell'altezza della riga
					if (jQuery(lastBox).height() < _maxBoxHeightInRow)
					{
						//jQuery(lastBox).css("top", (_boxCurrentY + _maxBoxHeightInRow - jQuery(lastBox).height()) + "px");
						jQuery(lastBox).css("top", _boxCurrentY + "px");
						jQuery(lastBox).css("margin-top", (_maxBoxHeightInRow - jQuery(lastBox).height()) + "px");
						
						if(jQuery.browser.msie && jQuery.browser.version <= 7)
						{
							var lastBoxIE6 = jQuery("#overbox-content-ie7").children(".box_over_ie7:eq(" + (jQuery("#overbox-content-ie7").children(".box_over_ie7").length - 1) + ")");
							jQuery(lastBoxIE6).css("top", _boxCurrentY + "px");
							jQuery(lastBoxIE6).css("margin-top", (_maxBoxHeightInRow - jQuery(lastBox).height()) + "px");
						}
						//attacco lo smile
						//alert(jQuery(lastBox).attr("codiceProdotto") + " || " + jQuery(lastBox).attr("id"))
						if (jQuery(lastBox).attr("codiceProdotto") != null && jQuery.trim(jQuery(lastBox).attr("codiceProdotto")) != "")
						{
							jQuery("#smile_tag_social").append('<a href="javascript:void(0)" parent="'+jQuery(lastBox).attr('id')+'" title="tags" class="smile" style="left:' + (_boxCurrentX - 25) + 'px;top:' + (_boxCurrentY + 7) + 'px; margin-top:'+(_maxBoxHeightInRow - jQuery(lastBox).height())+'px"></a>');
							//jQuery("#smile_tag_social").append('<a href="javascript:void(0)" parent="'+jQuery(lastBox).attr('id')+'" title="social networks" class="smile" style="left:' + (_boxCurrentX + jQuery(lastBox).width() - 25) + 'px;top:' + (_boxCurrentY + 7) + 'px; margin-top:'+(_maxBoxHeightInRow - jQuery(lastBox).height())+'"></a>');
						}
					}else
					{
						if (jQuery(lastBox).attr("codiceProdotto") != null && jQuery.trim(jQuery(lastBox).attr("codiceProdotto")) != "")
						{
							jQuery("#smile_tag_social").append('<a href="javascript:void(0)" parent="'+jQuery(lastBox).attr('id')+'" title="tags" class="smile" style="left:' + (_boxCurrentX - 25) + 'px;top:' + (_boxCurrentY + 7) + 'px;"></a>');
							//jQuery("#smile_tag_social").append('<a href="javascript:void(0)" parent="'+jQuery(lastBox).attr('id')+'" title="social networks" class="smile" style="left:' + (_boxCurrentX + jQuery(lastBox).width() - 25) + 'px;top:' + (_boxCurrentY + 7) + 'px; margin-top:'+(_maxBoxHeightInRow - jQuery(lastBox).height())+'"></a>');
						}	
					}
				}
				
				if (jQuery(lastBox).height() > _maxBoxHeightInRow)
					_maxBoxHeightInRow = jQuery(lastBox).height();
					
				//controllo se devo attaccare eventuali overlayers
				if (jQuery(this).find('overlayers').length > 0)
				{
					jQuery(this).find('overlayers').find('overlayer').each(function()
					{
						jQuery("#overlayers_content").append('<div showdelay="' + (show_delay + DELAY_BOX_OVERLAYER_SHOW) + '" hidedelay="' + hide_delay + '" parent="box_' + (jQuery("#content").children(".box").length - 1) + '" class="box_overlayer box_show_hide_delay" style="z-index:' + jQuery(lastBox).css("z-index") + '">' +
																jQuery(this).text() +
															 '</div>');

						var lastOverlayerBox = jQuery("#overlayers_content").children(".box_overlayer:eq(" + (jQuery("#overlayers_content").children(".box_overlayer").length - 1) + ")");
					
						jQuery(lastOverlayerBox).css("left", (parseInt(jQuery(lastBox).css("left"), 10) + parseInt(jQuery(this).attr("left"), 10)) + 'px');
						jQuery(lastOverlayerBox).css("top", (parseInt(jQuery(lastBox).css("top"), 10) + parseInt(jQuery(this).attr("top"), 10)) + 'px');
						
						
						//attacco tutti gli over e i click sull'overlayer
						jQuery(".box_overlayer").click(function()
						{
							doClickOnBox(jQuery("#" + jQuery(this).attr("parent")).parent());
						});
					});
				}
				
				if(jQuery.browser.msie && jQuery.browser.version <= 7 && jQuery(".box_over_ie7").length > 0)
				{
					jQuery(".box_over_ie7").each(function()
					{
						jQuery(this).hover(
							function()
							{
								var idel = jQuery(this).attr('idel');
								if(jQuery("#b_"+idel).length > 0 && jQuery("#b_"+idel).find(".box_html_content").attr("overenabled") != null 
									&& jQuery("#b_"+idel).find(".box_html_content").attr("overenabled") != "undefined" 
									&& parseInt(jQuery("#b_"+idel).find(".box_html_content").attr("overenabled"), 10) == 1)
								{
									jQuery("#b_"+idel).find(".box_html_over").show();
								}
							},
							function() 
							{ 
								var idel = jQuery(this).attr('idel');
								if(jQuery("#b_"+idel).length > 0 && jQuery("#b_"+idel).find(".box_html_content").attr("overenabled") != null 
									&& jQuery("#b_"+idel).find(".box_html_content").attr("overenabled") != "undefined" 
									&& parseInt(jQuery("#b_"+idel).find(".box_html_content").attr("overenabled"), 10) == 1)
								{
									jQuery("#b_"+idel).find(".box_html_over").hide();
								}
							});
					});
					
					jQuery(".box_over_ie7").each(function()
					{
						jQuery(this).click(
							function()
							{
								var idel = jQuery(this).attr('idel');
								if(jQuery("#b_"+idel).length > 0)
									doClickOnBox(jQuery("#b_"+idel).children(".box_content"));			
							});
					});
				}
				
				if(lastBox.attr("codiceProdotto") != null && jQuery.trim(lastBox.attr("codiceProdotto")) != "")
				{
					jQuery(".smile").click(function(ev)
						{
							ev.stopImmediatePropagation();
							if(jQuery("#"+jQuery(this).attr('parent')).children(".box_content").children(".box_html_content").children(".product-content-tag").length > 0
							  && jQuery.trim(jQuery("#"+jQuery(this).attr('parent')).children(".box_content").children(".box_html_content").children(".product-content-tag").css('display')) != 'none')
							{
								var tmpID = jQuery("#"+jQuery(this).attr('parent')).children(".box_content").children(".box_html_content").attr('id');
								
								if(_idTagBoxClosedTimeout[tmpID] != null && _idTagBoxClosedTimeout[tmpID] != "undefined")
								{
									_idTagBoxClosed = ricreaArray(_idTagBoxClosed, tmpID);
									clearTimeout(_idTagBoxClosedTimeout[tmpID]);
									_idTagBoxClosedTimeout[tmpID] = null;
									_idTagBoxClosedTimeout = ricreaArray(_idTagBoxClosedTimeout, tmpID);
								}
								
								//alert("tmpID: " + tmpID + " || id parent box: " + jQuery("#"+tmpID).parents(".box").attr("id"))
								var boxTop = parseInt(jQuery("#"+jQuery(this).attr('parent')).css('top'), 10) + parseInt(jQuery("#"+jQuery(this).attr('parent')).css('margin-top'), 10);
								var boxLeft = parseInt(jQuery(lastBox).css('left'), 10) + jQuery(lastBox).width() - jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").width(); //parseInt(jQuery("#"+jQuery(this).attr('parent')).css('left'), 10);
								
								//controllo se l'overlayer di un altro box "copre" i tag
								var overlayer = jQuery(".box_overlayer");
								
								var i = 0;
								var overlayerTop = 0;
								var overlayerLeft = 0;
								var overlayerTop1 = 0;
								var overlayerLeft1 = 0;
								var found = false;
								var overlayerObj = null;
								var moveTop = false;
								var moveLeft = true;
								while(i < overlayer.length && !found)
								{
									if(jQuery.trim(jQuery(overlayer[i]).attr('parent')) != tmpID)
									{
										overlayerTop = parseInt(jQuery(overlayer[i]).attr('inittop'), 10); //+ parseInt(jQuery("#"+jQuery(overlayer[i]).attr('parent')).css('top'), 10);
										overlayerLeft = parseInt(jQuery(overlayer[i]).attr('initleft'), 10); // + jQuery("#"+jQuery(overlayer[i]).attr('parent')).offset().left;
										overlayerTop1 = overlayerTop + jQuery(overlayer[i]).height();
										overlayerLeft1 = overlayerLeft + jQuery(overlayer[i]).width();
										
										var rectBox = {x: boxLeft, y: boxTop, width: jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").width(), height: jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").height()};
										var rectOverlayer = {x: overlayerLeft, y: overlayerTop, width: jQuery(overlayer[i]).width(), height: jQuery(overlayer[i]).height()};
										
										if(rectOverlap(rectBox, rectOverlayer))
										{
											overlayerObj = jQuery(overlayer[i]);  
											found = true;	
											
											moveLeft = rectOverlapX(rectBox, rectOverlayer);
											moveTop = rectOverlapY(rectBox, rectOverlayer);
										}
									}
									i = i + 1;
								}
								
								if(overlayerObj != null)
								{
									if(moveLeft && moveTop)
									{
										jQuery(overlayerObj).delay(300).animate({top: jQuery(overlayerObj).attr('inittop'), left: jQuery(overlayerObj).attr('initleft')}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint",
											function()
											{
												jQuery(this).removeAttr('initleft');			
												jQuery(this).removeAttr('inittop');			
											});
									}else if(!moveLeft && moveTop)
									{
										jQuery(overlayerObj).delay(300).animate({top: jQuery(overlayerObj).attr('inittop')}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint",
											function()
											{
												jQuery(this).removeAttr('initleft');			
												jQuery(this).removeAttr('inittop');			
											});
									}else if(moveLeft && !moveTop)
									{
										jQuery(overlayerObj).delay(300).animate({left: jQuery(overlayerObj).attr('initleft')}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint",
											function()
											{
												jQuery(this).removeAttr('initleft');			
												jQuery(this).removeAttr('inittop');			
											});
									}
								}
								
								jQuery("#"+tmpID).css('cursor', 'pointer');
								jQuery("#"+tmpID).attr('overEnabled', 1);
								
								for(var i = 0; i < jQuery(".box_overlayer[parent=" + tmpID + "]").length; i++)
									jQuery(".box_overlayer[parent=" + tmpID + "]:eq(" + i + ")").delay(300).show();
								
								jQuery("#"+tmpID).find(".product-content-tag").hide();
								var id = jQuery("#"+tmpID).find(".product-content-tag").parents(".box").attr('id');
								jQuery("#smile_tag_social").children("a[parent="+id+"]").attr('title', 'social networks');
								jQuery("#smile_tag_social").children("a[parent="+id+"]").removeClass("smile_close");
								
								/*jQuery("#"+tmpID).find(".product-content-tag").animate({right: -jQuery("#"+tmpID).find(".product-content-tag")}, 600, "easeInOutQuint", function() 
									{ 
										jQuery(this).hide(); 
										var id = jQuery(this).parents(".box").attr('id');
										jQuery("#smile_tag_social").children("a[parent="+id+"]").attr('title', 'social networks');
										jQuery("#smile_tag_social").children("a[parent="+id+"]").removeClass("smile_close");
									});*/
							}else
							{
								jQuery("#"+jQuery(this).attr('parent')).parent(".box_content").children(".box_html_content").css('cursor', 'default');
								jQuery("#"+jQuery(this).attr('parent')).parent(".box_content").children(".box_html_content").attr('overEnabled', 0);
								
								jQuery(this).parent(".box_content").children(".box_html_over").hide();
								
								ev.stopImmediatePropagation();
								
								var tmpID = jQuery("#"+jQuery(this).attr('parent')).children(".box_content").children(".box_html_content").attr('id');
	
								var boxTop = parseInt(jQuery("#"+jQuery(this).attr('parent')).css('top'), 10) + parseInt(jQuery("#"+jQuery(this).attr('parent')).css('margin-top'), 10);
								var boxLeft = parseInt(jQuery(lastBox).css('left'), 10) + jQuery(lastBox).width() - jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").width(); //parseInt(jQuery("#"+jQuery(this).attr('parent')).css('left'), 10);
								
								//controllo se l'overlayer di un altro box "copre" i tag
								var overlayer = jQuery(".box_overlayer");
								
								var i = 0;
								var overlayerTop = 0;
								var overlayerLeft = 0;
								var overlayerTop1 = 0;
								var overlayerLeft1 = 0;
								var found = false;
								var overlayerObj = null;
								var moveLeft = true;
								var moveTop = false;
								while(i < overlayer.length && !found)
								{
									if(jQuery.trim(jQuery(overlayer[i]).attr('parent')) != tmpID)
									{
										overlayerTop = parseInt(jQuery(overlayer[i]).css('top'), 10); // + parseInt(jQuery("#"+jQuery(overlayer[i]).attr('parent')).css('top'), 10);
										overlayerLeft = parseInt(jQuery(overlayer[i]).css('left'), 10); // + jQuery("#"+jQuery(overlayer[i]).attr('parent')).offset().left;
										overlayerTop1 = overlayerTop + jQuery(overlayer[i]).height();
										overlayerLeft1 = overlayerLeft + jQuery(overlayer[i]).width();
										
										var rectBox = {x: boxLeft, y: boxTop, width: jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").width(), height: jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").height()};
										var rectOverlayer = {x: overlayerLeft, y: overlayerTop, width: jQuery(overlayer[i]).width(), height: jQuery(overlayer[i]).height()};
										if(rectOverlap(rectBox, rectOverlayer))
										{
											jQuery(overlayer[i]).attr('inittop', parseInt(jQuery(overlayer[i]).css('top'), 10));
											jQuery(overlayer[i]).attr('initleft', parseInt(jQuery(overlayer[i]).css('left'), 10));
											overlayerObj = jQuery(overlayer[i]);  
											found = true;
											
											moveLeft = rectOverlapX(rectBox, rectOverlayer);
											if(moveLeft)
											{
												var rectOverlayer1 = {x: overlayerLeft - rectOverlayer.width, y: overlayerTop, width: jQuery(overlayer[i]).width(), height: jQuery(overlayer[i]).height()};
												moveTop = rectOverlapY(rectBox, rectOverlayer1); // && rectOverlap(rectBox, rectOverlayer1);
											}else
												moveTop = rectOverlapY(rectBox, rectOverlayer);
										}
									}
									i = i + 1;
								}
								
								if(overlayerObj != null)
								{
									if(moveLeft && moveTop)
										jQuery(overlayerObj).delay(100).animate({top: parseInt(jQuery(lastBox).css('top'), 10) - jQuery(overlayerObj).height(), left: (parseInt(jQuery(overlayerObj).css('left'), 10) - jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").width() - 20)}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint");
									else if(!moveLeft && moveTop)
										jQuery(overlayerObj).delay(100).animate({top: parseInt(jQuery(lastBox).css('top'), 10) - jQuery(overlayerObj).height()}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint");
									else if(moveLeft && !moveTop)
										jQuery(overlayerObj).delay(100).animate({left: (parseInt(jQuery(overlayerObj).css('left'), 10) - jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").width() - 20)}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint");
									
									/*if(moveLeft && moveTop)
										jQuery(overlayerObj).delay(100).animate({top: parseInt(jQuery(lastBox).css('top'), 10) - jQuery(overlayerObj).height(), left: jQuery(".menu").width() + jQuery("#"+jQuery(overlayerObj).attr('parent')).width() - jQuery(overlayerObj).width()}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint");
									else if(!moveLeft && moveTop)
										jQuery(overlayerObj).delay(100).animate({top: parseInt(jQuery(lastBox).css('top'), 10) - jQuery(overlayerObj).height()}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint");
									else if(moveLeft && !moveTop)
										jQuery(overlayerObj).delay(100).animate({left: jQuery(".menu").width() + jQuery("#"+jQuery(overlayerObj).attr('parent')).width() - jQuery(overlayerObj).width()}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint");*/
								}
								
								
								for(i = 0; i < jQuery(".box_overlayer[parent=" + tmpID + "]").length; i++)
								{
									jQuery(".box_overlayer[parent=" + tmpID + "]:eq(" + i + ")").delay(100).fadeOut(350);
								}
								
								//jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").css('left', -jQuery("#"+jQuery(this).attr('parent')).children(".box_content").children(".box_html_content").width());
								jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").show(function(){});
								jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").css('right', -jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").width());
								
								jQuery("#"+jQuery(this).attr('parent')).children(".box_content").show();
								var id = jQuery("#"+jQuery(this).attr('parent')).children(".box_content").parents(".box").attr('id');
								jQuery("#smile_tag_social").children("a[parent="+id+"]").attr('title', 'chiudi');
								jQuery("#smile_tag_social").children("a[parent="+id+"]").addClass("smile_close");
								
								/*jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").animate({right: 0}, 600, "easeInOutQuint", function() 
									{ 
										var id = jQuery(this).parents(".box").attr('id');
										jQuery("#smile_tag_social").children("a[parent="+id+"]").attr('title', 'chiudi');
										jQuery("#smile_tag_social").children("a[parent="+id+"]").addClass("smile_close");
									});*/
									
								/*tagTimeout = setTimeout('resetBoxTag()', 3000);
								_idTagBoxClosed.push(tmpID);
								_idTagBoxClosedTimeout = tagTimeout;*/
							}
						});
				}
				
				if(lastBox.find(".product-content-tag").length > 0)
				{
					var w = 146; // lastBox.width()
					var h = 146; // lastBox.height()
					lastBox.find(".product-content-tag").width(146);
					lastBox.find(".product-content-tag").height(146);
					lastBox.find(".product-content-tag").css('left', (lastBox.width() - 146));
					
					var tmp = parseInt(lastBox.find(".product-content-tag-share").css('height'), 10) + parseInt(lastBox.find(".product-content-tag-share").css('padding-top'), 10) + parseInt(lastBox.find(".product-content-tag-share").css('padding-bottom'), 10);
					lastBox.find(".product-content-tag-box").height(h - parseInt(lastBox.find(".product-content-tag-box").css('padding-top'), 10) - tmp);	
					lastBox.find(".product-content-tag-box").width(w - jQuery(".smile").width() - (parseInt(lastBox.find(".product-content-tag-box").css('padding-left'), 10) * 2));	
					//lastBox.find(".product-content-tag-box").height(lastBox.height() - parseInt(lastBox.find(".product-content-tag-box").css('padding-top'), 10) - tmp);	
					//lastBox.find(".product-content-tag-box").width(lastBox.width() - jQuery(".smile").width() - (parseInt(lastBox.find(".product-content-tag-box").css('padding-left'), 10) * 2));	
				}
			});
			
			
			//aggiungo l'ultimo box
			if (_lastBoxesInRow == null)
				_lastBoxesInRow = new Array();
			_lastBoxesInRow.push(jQuery("#b_" + (jQuery(".box").length - 1)));
			
			tagTimeout = null;
			
			jQuery(".smile").each(function()
			{
				jQuery(this).hover(function()
					{
						var tmpID = jQuery("#"+jQuery(this).attr('parent')).children(".box_content").children(".box_html_content").attr('id');
						if(_idTagBoxClosedTimeout[tmpID] != null && _idTagBoxClosedTimeout[tmpID] != "undefined")
						{
							_idTagBoxClosed = ricreaArray(_idTagBoxClosed, tmpID);
							clearTimeout(_idTagBoxClosedTimeout[tmpID]);
							_idTagBoxClosedTimeout[tmpID] = null;
							_idTagBoxClosedTimeout = ricreaArray(_idTagBoxClosedTimeout, tmpID);
						}
					},
					function()
					{
						if(jQuery.trim(jQuery("#"+jQuery(this).attr('parent')).children(".box_content").find(".product-content-tag").css('display')) == 'none') return;

						var tmpID = jQuery("#"+jQuery(this).attr('parent')).children(".box_content").children(".box_html_content").attr('id');
						tagTimeout = setTimeout('resetBoxTag()', TIME_TO_TAG_RESET);
						_idTagBoxClosed.push(tmpID);
						_idTagBoxClosedTimeout.push(tagTimeout);
					});
			});
			
			jQuery(".product-content-tag").each(function()
			{
				jQuery(this).hover(function()
					{
						var tmpID = checkID(jQuery(this).parents(".box_content").children(".box_html_content").attr('id'));
						
						_idTagBoxClosed = ricreaArray(_idTagBoxClosed, tmpID);
						
						clearTimeout(_idTagBoxClosedTimeout[tmpID]);
						_idTagBoxClosedTimeout[tmpID] = null;
						
						_idTagBoxClosedTimeout = ricreaArray(_idTagBoxClosedTimeout, tmpID);
					},
					function()
					{
						var tmpID = jQuery(this).parents(".box_content").children(".box_html_content").attr('id');
						
						if(_idTagBoxClosedTimeout[tmpID] != null && _idTagBoxClosedTimeout[tmpID] != "undefined")
						{
							_idTagBoxClosed = ricreaArray(_idTagBoxClosed, tmpID);
							clearTimeout(_idTagBoxClosedTimeout[tmpID]);
							_idTagBoxClosedTimeout[tmpID] = null;
							_idTagBoxClosedTimeout = ricreaArray(_idTagBoxClosedTimeout, tmpID);
						}
						
						tagTimeout = setTimeout('resetBoxTag()', TIME_TO_TAG_RESET);
						_idTagBoxClosed.push(tmpID);
						_idTagBoxClosedTimeout.push(tagTimeout);
					});
			});
			
			//attacco tutti gli over e i click sui box
			jQuery(".box_html_content, .box_html_over").click(function()
			{
				if(jQuery(this).children(".product-content-tag").length > 0 && jQuery.trim(jQuery(this).children(".product-content-tag").css('display')) != "none") return;
				
				if (jQuery(this).css("cursor") != "pointer")
					return;
					
				doClickOnBox(jQuery(this).parent());
			});					
			
			//PNG FIX IE 6
			if (jQuery.browser.msie && jQuery.browser.version == 6) 
				jQuery(document).pngFix();
				
			
			//PNG FIX IE per poter eseguire i fade sulle trasparenze	
			if (jQuery.browser.msie && jQuery(".product-detail-popup-container").length == 0)
			{
				jQuery("img").each(function()
				{
					if (jQuery(this).attr("src").toLowerCase().lastIndexOf(".png") != -1)
						jQuery(this).css("filter", "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='image',src='" + jQuery(this).attr("src") + "')");
				});
			}

			_boxContentHeight += _maxBoxHeightInRow;
			setMainHeight();

						
			//visualizzo i box con un effetto
			_boxShowed = 0;
			jQuery(".box_show_hide_delay").each(function()
			{
			
				//prima volta che carica la sezione
				/*
				if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
					return;*/
				
				
				if (jQuery(this).offset().top + jQuery(this).height() < 0 || jQuery(this).offset().top > jQuery(window).height())
				{
					//è fuori dallo schermo quindi NON lo visualizzo 
					//jQuery(this).show();
					_boxShowed++;
					if (_boxShowed >= jQuery(".box_show_hide_delay").length)
					{
						//controllo se ho un video nell'header lo faccio partire
						if (jQuery("#video_img_container .box_video_cnt").length > 0)
						{
							if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
							{
								if (jQuery(this).parents(".box").length > 0)
								{
									if(document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != null && document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != "undefined")
										document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).play();
								}else
								{
									jQuery(".box_video_cnt").children(".box_video_file").css('display', 'block');
									if(document.getElementById("flash_gallery_video_swf_header") != null && document.getElementById("flash_gallery_video_swf_header") != "undefined")
										document.getElementById("flash_gallery_video_swf_header").play();
								}
							}else
							{
								if (jQuery(this).parents(".box").length > 0)
								{
									if(document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != null && document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != "undefined")
										document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).startMediaElementToJS();
								}else
								{
									if(jQuery("#flash_gallery_video_swf_header").length > 0 && document.getElementById("flash_gallery_video_swf_header") != null && document.getElementById("flash_gallery_video_swf_header") != "undefined")
										document.getElementById("flash_gallery_video_swf_header").startMediaElementToJS();
								}
							}
						}
						
						if (jQuery.trim(_idProductToLoad) == "" && _idMenuToLoad == parseInt(jQuery(xmlData).find("idmenu").text(), 10))
							showTagCloud();
					}
				}
				else
				{
					if(jQuery.browser.msie && jQuery.browser.version <= 7)
					{
						jQuery(this).delay(parseInt(jQuery(this).attr("showdelay"), 10)).show(function(){
							_boxShowed++;
							if (_boxShowed >= jQuery(".box_show_hide_delay").length)
							{
								//controllo se ho un video nell'header lo faccio partire
								if (jQuery("#video_img_container .box_video_cnt").length > 0)
								{
									if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
									{
										if (jQuery(this).parents(".box").length > 0)
										{
											if(document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != null && document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != "undefined")
												document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).play();
										}else
										{
											if(jQuery("#flash_gallery_video_swf_header").length > 0 && document.getElementById("flash_gallery_video_swf_header") != null && document.getElementById("flash_gallery_video_swf_header") != "undefined")
												document.getElementById("flash_gallery_video_swf_header").play();
											jQuery(".box_video_cnt").children(".box_video_file").css('display', 'block');
										}
									}else
									{
										if (jQuery(this).parents(".box").length > 0)
										{
											if(document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != null && document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != "undefined")
												document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).startMediaElementToJS();
										}else
										{
											if(jQuery("#flash_gallery_video_swf_header").length > 0 && document.getElementById("flash_gallery_video_swf_header") != null && document.getElementById("flash_gallery_video_swf_header") != "undefined")
												document.getElementById("flash_gallery_video_swf_header").startMediaElementToJS();
										}
									}
								}
								
								if (jQuery.trim(_idProductToLoad) == "" && _idMenuToLoad == parseInt(jQuery(xmlData).find("idmenu").text(), 10))
									showTagCloud();
							}
						});
					}else
					{
						jQuery(this).delay(parseInt(jQuery(this).attr("showdelay"), 10)).fadeIn(400, function(){
							_boxShowed++;
							if (_boxShowed >= jQuery(".box_show_hide_delay").length)
							{
								//controllo se ho un video nell'header lo faccio partire
								if (jQuery("#video_img_container .box_video_cnt").length > 0)
								{
									if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
									{
										if (jQuery(this).parents(".box").length > 0)
										{
											if(document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != null && document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != "undefined")
												document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).play();
										}else
										{
											if(jQuery("#flash_gallery_video_swf_header").length > 0 && document.getElementById("flash_gallery_video_swf_header") != null && document.getElementById("flash_gallery_video_swf_header") != "undefined")
												document.getElementById("flash_gallery_video_swf_header").play();
											jQuery(".box_video_cnt").children(".box_video_file").css('display', 'block');
										}
									}else
									{
										if (jQuery(this).parents(".box").length > 0)
										{
											if(document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != null && document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")) != "undefined")
												document.getElementById("flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).startMediaElementToJS();
										}else
										{
											if(jQuery("#flash_gallery_video_swf_header").length > 0 && document.getElementById("flash_gallery_video_swf_header") != null && document.getElementById("flash_gallery_video_swf_header") != "undefined")
												document.getElementById("flash_gallery_video_swf_header").startMediaElementToJS();
										}
									}
								}
								
								if (jQuery.trim(_idProductToLoad) == "" && _idMenuToLoad == parseInt(jQuery(xmlData).find("idmenu").text(), 10))
									showTagCloud();
							}
						});
					}
				}
				//per rifare il parse degli elementi fbml in pagina (bottoni fb)
				try{
					FB.XFBML.parse(); 
				}catch(ex){}
			});
			
			//controllo se nell'header ho + immagini faccio partire lo slideshow
			if (jQuery("#video_img_container .box_video_cnt").length > 0)
			{
				jQuery(".background_img_header").css("visibility", "hidden");
				jQuery("#video_img_container").css('display', 'block');
				doPlayVideo(jQuery("#video_img_container"));
			}
			else if (jQuery("#video_img_container img").length > 0)
			{		
				//mostro la prima immagine
				jQuery("#video_img_container").fadeIn(200);
				jQuery("#video_img_container img:eq(" + _currentHeaderSlideshowImg + ")").fadeIn(400, function(){
					jQuery(".background_img_header").css("visibility", "hidden");
				});
				
				startIntervalHeaderSlideshow();
			}
			else
				jQuery(".background_img_header").css("visibility", "visible");
			
			setTimeout('visibleSmileTagSocial()', (DELAY_MAX_RANDOM_BOX_SHOW + DELAY_MIN_RANDOM_BOX_SHOW));
	    }
	});
}

function visibleSmileTagSocial()
{
	jQuery("#smile_tag_social").css('visibility', 'visible');	
}

function increaseY(width, bottomEdge, Max)
{
	return (bottomEdge + width < Max);
}

function valueInRange(value, min, max)
{
	return (value <= max) && (value >= min);
}

function rectOverlap(A, B)
{
	var xOverlap = valueInRange(A.x, B.x, B.x + B.width) ||
	valueInRange(B.x, A.x, A.x + A.width);
	
	var yOverlap = valueInRange(A.y, B.y, B.y + B.height) ||
	valueInRange(B.y, A.y, A.y + A.height);
	//alert(xOverlap + "||" + yOverlap)
	
	return xOverlap && yOverlap;
}

function rectOverlapX(A, B)
{
	return valueInRange(A.x, B.x, B.x + B.width) ||
	valueInRange(B.x, A.x, A.x + A.width);
}

function rectOverlapY(A, B)
{
	return valueInRange(A.y, B.y, B.y + B.height) ||
	valueInRange(B.y, A.y, A.y + A.height);
}

function resetBoxTag()
{
	if(_idTagBoxClosed.length == 0) return;
	var tmpID = _idTagBoxClosed[0];
	_idTagBoxClosed = ricreaArray(_idTagBoxClosed, 0);
	clearTimeout(_idTagBoxClosedTimeout[0]);
	_idTagBoxClosedTimeout[0] = null;
	_idTagBoxClosedTimeout = ricreaArray(_idTagBoxClosedTimeout, 0);

	//alert("tmpID: " + tmpID + " || id parent box: " + jQuery("#"+tmpID).parents(".box").attr("id"))
	//var boxTop = parseInt(jQuery("#"+tmpID).parents(".box").css('top'), 10) + parseInt(jQuery("#"+tmpID).css('margin-top'), 10);
	//var boxLeft = parseInt(jQuery("#"+tmpID).parents(".box").css('left'), 10);
	
	var boxTop = parseInt(jQuery("#"+tmpID).parents(".box").css('top'), 10) + parseInt(jQuery("#"+tmpID).parents(".box").css('margin-top'), 10);
	var boxLeft = parseInt(jQuery("#"+tmpID).parents(".box").css('left'), 10) + jQuery("#"+tmpID).parents(".box").width() - jQuery("#"+tmpID).parents(".box").children(".box_content").find(".product-content-tag").width(); //parseInt(jQuery("#"+jQuery(this).attr('parent')).css('left'), 10);

	//controllo se l'overlayer di un altro box "copre" i tag
	var overlayer = jQuery(".box_overlayer");
	
	var i = 0;
	var overlayerTop = 0;
	var overlayerLeft = 0;
	var overlayerTop1 = 0;
	var overlayerLeft1 = 0;
	var found = false;
	var overlayerObj = null;
	var moveTop = false;
	var moveLeft = true;
	while(i < overlayer.length && !found)
	{
		if(jQuery.trim(jQuery(overlayer[i]).attr('parent')) != tmpID)
		{
			overlayerTop = parseInt(jQuery(overlayer[i]).attr('inittop'), 10); //+ parseInt(jQuery("#"+jQuery(overlayer[i]).attr('parent')).css('top'), 10);
			overlayerLeft = parseInt(jQuery(overlayer[i]).attr('initleft'), 10); // + jQuery("#"+jQuery(overlayer[i]).attr('parent')).offset().left;
			overlayerTop1 = overlayerTop + jQuery(overlayer[i]).height();
			overlayerLeft1 = overlayerLeft + jQuery(overlayer[i]).width();
			
			//var rectBox = {x: boxLeft, y: boxTop, width: jQuery("#"+tmpID).width(), height: jQuery("#"+tmpID).height()};
			//var rectOverlayer = {x: overlayerLeft, y: overlayerTop, width: jQuery(overlayer[i]).width(), height: jQuery(overlayer[i]).height()};
			
			var rectBox = {x: boxLeft, y: boxTop, width: jQuery("#"+tmpID).parents(".box").children(".box_content").find(".product-content-tag").width(), height: jQuery("#"+tmpID).parents(".box").children(".box_content").find(".product-content-tag").height()};
			var rectOverlayer = {x: overlayerLeft, y: overlayerTop, width: jQuery(overlayer[i]).width(), height: jQuery(overlayer[i]).height()};
			
			if(rectOverlap(rectBox, rectOverlayer))
			{
				overlayerObj = jQuery(overlayer[i]);  
				found = true;	
				
				moveLeft = rectOverlapX(rectBox, rectOverlayer);
				moveTop = rectOverlapY(rectBox, rectOverlayer);
			}
		}
		i = i + 1;
	}

	if(overlayerObj != null)
	{
		if(moveLeft && moveTop)
		{
			jQuery(overlayerObj).delay(300).animate({top: jQuery(overlayerObj).attr('inittop'), left: jQuery(overlayerObj).attr('initleft')}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint",
				function()
				{
					jQuery(this).removeAttr('initleft');			
					jQuery(this).removeAttr('inittop');			
				});
		}else if(!moveLeft && moveTop)
		{
			jQuery(overlayerObj).delay(300).animate({top: jQuery(overlayerObj).attr('inittop')}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint",
				function()
				{
					jQuery(this).removeAttr('initleft');			
					jQuery(this).removeAttr('inittop');			
				});
		}else if(moveLeft && !moveTop)
		{
			jQuery(overlayerObj).delay(300).animate({left: jQuery(overlayerObj).attr('initleft')}, TIME_TO_MOVE_OVERLAYER, "easeInOutQuint",
				function()
				{
					jQuery(this).removeAttr('initleft');			
					jQuery(this).removeAttr('inittop');			
				});
		}
	}
	
	jQuery("#"+tmpID).css('cursor', 'pointer');
	jQuery("#"+tmpID).attr('overEnabled', 1);
	
	for(var i = 0; i < jQuery(".box_overlayer[parent=" + tmpID + "]").length; i++)
		jQuery(".box_overlayer[parent=" + tmpID + "]:eq(" + i + ")").delay(300).show();
	
	jQuery("#"+tmpID).find(".product-content-tag").hide();
	var id = jQuery("#"+tmpID).find(".product-content-tag").parents(".box").attr('id');
	jQuery("#smile_tag_social").children("a[parent="+id+"]").attr('title', 'social networks');
	jQuery("#smile_tag_social").children("a[parent="+id+"]").removeClass("smile_close");
		
	/*jQuery("#"+tmpID).find(".product-content-tag").animate({right: -jQuery("#"+tmpID).find(".product-content-tag").width()}, 600, "easeInOutQuint", function() 
		{ 
			jQuery(this).hide(); 
			var id = jQuery(this).parents(".box").attr('id');
			jQuery("#smile_tag_social").children("a[parent="+id+"]").attr('title', 'social networks');
			jQuery("#smile_tag_social").children("a[parent="+id+"]").removeClass("smile_close");
		});*/
}

function startIntervalHeaderSlideshow()
{
	stopIntervalHeaderSlideshow();
	
	if (jQuery("#video_img_container img").length > 1)
		_intervalIDHeaderSlideshow = setTimeout(startHeaderSlideshow, HEADER_SLIDESHOW_INTERVAL);
		//_intervalIDHeaderSlideshow = setInterval(startHeaderSlideshow, HEADER_SLIDESHOW_INTERVAL);
}

function stopIntervalHeaderSlideshow()
{
	if (_intervalIDHeaderSlideshow != null)
		clearTimeout(_intervalIDHeaderSlideshow);
		//clearInterval(_intervalIDHeaderSlideshow);
	_intervalIDHeaderSlideshow = null;
}

function startHeaderSlideshow()
{
	var tmp = _currentHeaderSlideshowImg;
	_currentHeaderSlideshowImg++;
	if (_currentHeaderSlideshowImg > jQuery("#video_img_container img").length - 1)
		_currentHeaderSlideshowImg = 0;
	jQuery("#video_img_container img:eq(" + _currentHeaderSlideshowImg + ")").css('z-index', 20);
	jQuery("#video_img_container img:eq(" + tmp + ")").css('z-index', 30);
	jQuery("#video_img_container img:eq(" + _currentHeaderSlideshowImg + ")").show();
	if((jQuery.browser.msie && jQuery.browser.version > 7) || !jQuery.browser.msie)
		jQuery("#video_img_container img:eq(" + tmp + ")").fadeOut(400, function(){});
	else
		jQuery("#video_img_container img:eq(" + tmp + ")").hide();
	
	stopIntervalHeaderSlideshow();
	_intervalIDHeaderSlideshow = setTimeout(startHeaderSlideshow, HEADER_SLIDESHOW_INTERVAL);
}

jQuery(document).ready(function()
{
	$(document).mousemove(function(e)
	{
		if(jQuery.browser.msie && jQuery.browser.version <= 7) 
			return;
		
		if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1) return;
		// , .box_overlayer
		jQuery(".box_html_content").each(function()
		{
			if (jQuery.trim(jQuery("#layer_opacity").css('display')) != 'none') 
				return;
			if (jQuery(this).attr("overEnabled") == "1" || jQuery("#"+jQuery(this).attr("parent")).attr("overEnabled") == "1" )
			{
				var objOver;
				if (jQuery(this).attr("parent") != null && jQuery.trim(jQuery(this).attr("parent")) != "")				
					objOver = jQuery("#"+(jQuery(this).attr("parent"))).parent().children(".box_html_over");
				else
					objOver = jQuery(this).parent().children(".box_html_over");
	
				if (e.pageX >= jQuery(this).offset().left && e.pageX <= jQuery(this).offset().left + jQuery(this).width() && 
				    e.pageY >= jQuery(this).offset().top && e.pageY <= jQuery(this).offset().top + jQuery(this).height())
				{
					//dentro...
					
					//controllo se sono su un video che è già in riproduzione: in tal caso non gestisco l'over
					if (jQuery(this).parents(".box").find("#flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).length == 0)
					{
						jQuery(objOver).attr("overOnIt", "1");
						//jQuery(objOver).fadeIn(200);
						jQuery(objOver).show();
					}
				}
				else
				{
					//controllo se sono uscito sia dagli overlayer che dal box principale prima di "spengere" il rollover
					var numBox = -1;
					if (jQuery(this).attr("id").indexOf("box_") == 0)
					{
						//ho un box principale: ricerco il numero di box
						numBox = parseInt(jQuery(this).attr("id").substring("box_".length));
					}
					else if (jQuery(this).attr("parent").indexOf("box_") == 0)
					{
						//ho un overlayer: ricerco il numero di box
						numBox = parseInt(jQuery(this).attr("parent").substring("box_".length));
					}
					
					
					if (numBox >= 0)
					{
						var overBoxCorrelato = false;
						//controllo che il mouse non sia sopra ad un altro elemento dello stesso contesto
						//, .box_overlayer[parent=box_" + numBox + "]
						jQuery(".box_html_content[id=box_" + numBox + "]").each(function(){
							if (jQuery(this) != objOver)
							{
								if (e.pageX >= jQuery(this).offset().left && e.pageX <= jQuery(this).offset().left + jQuery(this).width() && 
				    				e.pageY >= jQuery(this).offset().top && e.pageY <= jQuery(this).offset().top + jQuery(this).height())
								{
									overBoxCorrelato = true;
								}
							}
						});
						
						if (!overBoxCorrelato)
							jQuery(objOver).attr("overOnIt", "0");	
					}
					else
						jQuery(objOver).attr("overOnIt", "0");
				}
			}
		});
		
		jQuery(".box_html_over[overOnIt=0]").each(function(){
			//jQuery(this).delay(DELAY_BOX_ROLLOVER).fadeOut(200);
			jQuery(this).hide();
		});
  	}); 
});

function doClickOnBox(pObj)
{
	if (jQuery(pObj).find(".box_frame_video").length > 0)
	{
		doPlayVideo(pObj);
	}
	else
	{
		if (jQuery(pObj).parents(".box").attr("directlink") != null  && jQuery(pObj).parents(".box").attr("directlink") != "undefined" && jQuery(pObj).parents(".box").attr("directlink") != "")
		{
			window.open(jQuery(pObj).parents(".box").attr("directlink"), "");
		}else if (jQuery(pObj).parents(".box").attr("gallerygroup") != null  && jQuery(pObj).parents(".box").attr("gallerygroup") != "undefined" && jQuery(pObj).parents(".box").attr("gallerygroup") != "")
		{
			initialLoadGallery(jQuery(pObj).parents(".box").attr("gallerygroup"), jQuery(pObj).parents(".box").attr("galleryindexgroup"));
		}
		else
		{
			if (jQuery.trim(jQuery(pObj).parents(".box").attr("hashName")) != "")
			{
				jQuery.historyLoad(jQuery.trim(jQuery(pObj).parents(".box").attr("hashName")) + 
								  (jQuery.trim(jQuery(pObj).parents(".box").attr("idContent")) != "" ? "/id=" + jQuery(pObj).parents(".box").attr("idContent") : "") +
								  (jQuery.trim(jQuery(pObj).parents(".box").attr("codiceProdotto")) != "" ? "/idp=" + jQuery(pObj).parents(".box").attr("codiceProdotto") : ""));
			}
		}
	}
}

function resetHeader()
{
	//controllo se l'header è visibile oppure no
	if (jQuery("#video_img_container").offset().top + jQuery("#video_img_container").height() < 0)
	{
		//sono fuori....
		//fermo eventuali video e slideshow
		stopIntervalHeaderSlideshow();
		
//		@@@
	}
	else
	{
		//controllo se far ripartire il video o lo slideshow
		if (_intervalIDHeaderSlideshow == null && jQuery("#video_img_container img").length > 1)
			startIntervalHeaderSlideshow();
			
//		@@@@
	}
}

function checkAllClippedBox()
{
	//se sono su piattaforma iphone, ipad e android non facio niente
	if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1 || navigator.userAgent.indexOf('Android') != -1)
		return;
	
	jQuery(".box").each(function(){
		if (jQuery(this).offset().top + jQuery(this).height() < 0 || jQuery(this).offset().top > jQuery(window).height())
		{
			if (jQuery(this).css("visibility") == "visible")
			{
				jQuery(this).css("visibility", "hidden");
				
				//nascondo anche (eventualmente) l'overlayer
				var numBox = parseInt(jQuery(this).attr("id").substring("b_".length));
				var ovr = jQuery(".box_overlayer[parent=box_" + numBox + "]");
				if (jQuery(ovr).length > 0)
				{
					jQuery(ovr).css("visibility", "hidden");
				}
			}
		}
		else
		{
			if (jQuery(this).css("visibility") == "hidden")
			{
				jQuery(this).css("display", "none");				
				jQuery(this).css("visibility", "visible");
				//jQuery(this).fadeIn(200);
				jQuery(this).show();
				
				//mostro anche (eventualmente) l'overlayer
				var numBox = parseInt(jQuery(this).attr("id").substring("b_".length));
				var ovr = jQuery(".box_overlayer[parent=box_" + numBox + "]");
				if (jQuery(ovr).length > 0)
				{
					jQuery(ovr).css("display", "none");				
					jQuery(ovr).css("visibility", "visible");
					//jQuery(ovr).fadeIn(200);
					jQuery(ovr).show();
				}
			}
		}
	});
}

function resetAllBoxVideo()
{
	jQuery(".box .box_video_cnt").each(function()
	{
		if (jQuery(this).parents(".box").offset().top + jQuery(this).parents(".box").height() < 0 || jQuery(this).parents(".box").offset().top > jQuery(window).height())
		{	
			if (jQuery(this).parents(".box").find("#flash_gallery_video_swf_" + jQuery(this).parents(".box").attr("id")).length > 0)
			{
				resetBoxVideo(jQuery(this).parents(".box"));
			}
		}
	});
}

function resetBoxVideo(pObj)
{
	//rimette l'img di preview del video e stacca l'oggetto flash
	if (jQuery(pObj).find(".box_video_cnt").length > 0)
	{
		jQuery(pObj).find(".box_video_cnt").css('display', 'none');
	}
	
	jQuery(pObj).find(".box_video_file").html("");
	
	jQuery(pObj).find(".box_frame_video").show();
}

function doPlayVideo(pObj)
{
	//faccio partire il video
	if (jQuery(pObj).find(".box_video_cnt").length > 0)
	{
		jQuery(pObj).find(".box_video_cnt").css('visibility', 'hidden');
		jQuery(pObj).find(".box_video_cnt").css('display', 'block');
	
		jQuery(pObj).find(".box_html_over").css('display', 'none');
	}


	if(navigator.platform.indexOf("iPad") != -1 || navigator.platform.indexOf("iPhone") != -1)
	{
		if(jQuery(pObj).parents(".box").length == 0)
		{
			var arrAppoggioVideo = jQuery(pObj).find(".box_video_file").attr('file').split("/");
			
			jQuery(pObj).find(".box_video_file").html('<video id="flash_gallery_video_swf_header" src="' + jQuery(pObj).find(".box_video_file").attr('file') + '" type="video/mp4" loop width=980 height=550 />');
			if(document.getElementById('flash_gallery_video_swf_header') != null && document.getElementById('flash_gallery_video_swf_header') != "undefined")
				document.getElementById('flash_gallery_video_swf_header').play();
		}else
		{
			var arrAppoggioVideo = jQuery(pObj).find(".box_video_file").attr('file').split("/");
			
			jQuery(pObj).find(".box_video_file").html('<video id="flash_gallery_video_swf_' + jQuery(pObj).find(".box_video_file").attr('id') + '" src="' + jQuery(pObj).find(".box_video_file").attr('file') + '" type="video/mp4" width=738 height=415 controls="controls" />');
			if(document.getElementById('flash_gallery_video_swf_' + jQuery(pObj).find(".box_video_file").attr('id')) != null && document.getElementById('flash_gallery_video_swf_' + jQuery(pObj).find(".box_video_file").attr('id')) != "undefined")
				document.getElementById('flash_gallery_video_swf_' + jQuery(pObj).find(".box_video_file").attr('id')).play();
		}
	}else
	{
		if (swfobject.hasFlashPlayerVersion("10.0.0")) 
		{
			//stoppo tutti gli altri eventuali video in play	
	//		@@@
			
			var arrAppoggioVideo = jQuery(pObj).find(".box_video_file").attr('file').split("/");
			trackEventAnalytics(arrAppoggioVideo[(arrAppoggioVideo.length)-1]);
			
			var flashvars = {};
			flashvars.autoPlay = (jQuery(pObj).find(".box_html_over").length != 0 ? "1" : "0");
			flashvars.video = '../' + jQuery(pObj).find(".box_video_file").attr('file');
			flashvars.loop = (jQuery(pObj).find(".box_video_file").attr('loop') == "1" ? "1" : "0");
			flashvars.hideControls = (jQuery(pObj).find(".box_video_file").attr('hideControls') == "1" ? "1" : "0");
	
			var params = {};
			params.menu = "false";
			params.quality = "high";
			params.wmode = "transparent";
			params.align = "top";
			params.allowscriptaccess = "sameDomain";
			params.allowfullscreen = "true";
			var attributes = {};
			if(jQuery(pObj).parents(".box").length == 0)
			{
				attributes.id = "flash_gallery_video_swf_header";
				attributes.name = "flash_gallery_video_swf_header";
			}
			else
			{
				attributes.id = "flash_gallery_video_swf_" + jQuery(pObj).parents(".box").attr("id");
				attributes.name = "flash_gallery_video_swf_" + jQuery(pObj).parents(".box").attr("id");
			}
			swfobject.embedSWF("img/AdactoVideoPlayer.swf", jQuery(pObj).find(".box_video_file").attr("id"), "100%", "100%", "10.0.0", false, flashvars, params, attributes);
		} 
	}

	if (jQuery(pObj).find(".box_video_cnt").length > 0)
	{
		jQuery(pObj).find(".box_video_cnt").css('visibility', 'visible');
		jQuery(pObj).find(".box_frame_video").hide();
	}
}

function doRemoveAllBoxes()
{
	var _emptySection = true;
	
	jQuery("#smile_tag_social").css('visibility', 'hidden');
	if(jQuery(".smile").length > 0)
		jQuery(".smile").remove();
	
	//nascondo i box con un effetto
	_boxExited = jQuery(".box").length;
	if (_boxExited > 0)
	{
		jQuery("#content").find(".button_header").remove();
		_emptySection = false;
		jQuery(".box_show_hide_delay").each(function()
		{
			if((jQuery.browser.msie && jQuery.browser.version > 7) || !jQuery.browser.msie)
			{
				jQuery(this).delay(parseInt(jQuery(this).attr("hidedelay"), 10)).fadeOut(200, function()
				{
					jQuery(this).remove();
					
					if (jQuery(this).hasClass("box"))
					{
						_boxExited--;
						if (_boxExited <= 0)
						{
							//nascondo l'header
							jQuery(".background_img_header").css("visibility", "visible");
							jQuery("#video_img_container").delay(300).fadeOut(400, function(){
			
								jQuery("#video_img_container").html("");
								
								continueLoadSection();
							});
						}
					}
				});
			}else
			{
				jQuery(this).delay(parseInt(jQuery(this).attr("hidedelay"), 10)).hide(200, function()
				{
					jQuery(this).remove();
					
					if (jQuery(this).hasClass("box"))
					{
						_boxExited--;
						if (_boxExited <= 0)
						{
							//nascondo l'header
							jQuery(".background_img_header").css("visibility", "visible");
							jQuery("#video_img_container").delay(300).hide();			
							jQuery("#video_img_container").html("");
							continueLoadSection();
						}
					}
				});	
			}
		});
	}
	
	if (jQuery(".google-map-content").length > 0)
	{
		_emptySection = false;
		if((jQuery.browser.msie && jQuery.browser.version > 7) || !jQuery.browser.msie)
		{
			jQuery(".google-map-content").delay(300).fadeOut(400, function()
			{
				jQuery("#content").html('');
				if (jQuery.trim(DirectPage) != '')
				{	
					if(DirectPage == "documenti.php")
						loadDirectPage(frameToGoAreaRiservata);
					else
						loadDirectPage();
				}
				else 
					loadContentData(_idMenuToLoad, _idDetailToLoad, _idProductToLoad);
			});
		}else
		{
			jQuery(".google-map-content").delay(300).hide();
			jQuery("#content").html('');
			if (jQuery.trim(DirectPage) != '')
			{	
				if(DirectPage == "documenti.php")
					loadDirectPage(frameToGoAreaRiservata);
				else
					loadDirectPage();
			}
			else 
				loadContentData(_idMenuToLoad, _idDetailToLoad, _idProductToLoad);
		}
	}
	
	if (jQuery(".wrap_form").length > 0)
	{
		_emptySection = false;
		if((jQuery.browser.msie && jQuery.browser.version > 7) || !jQuery.browser.msie)
		{
			jQuery(".wrap_form").delay(300).fadeOut(400, function()
			{
				jQuery("#content").html('');
	
				continueLoadSection();
			});
		}else
		{
			jQuery(".wrap_form").delay(300).hide();
			jQuery("#content").html('');
			continueLoadSection();
		}
	}
	
	//GESTIONE TEMPORANEA PER LE SEZIONI SENZA CONTENUTI
	if (_emptySection)
	{
		continueLoadSection();
	}
}

function continueLoadSection()
{
	//rimuovo tutte le nuvole
	jQuery("#background_center").html("");
	//rimuovo gli eventuali bottoni sull'header
	jQuery("#button_header_container").fadeOut();
		
	if(jQuery.trim(DirectPage) != '')
	{
		if(DirectPage == "documenti.php")
			loadDirectPage(frameToGoAreaRiservata);
		else
			loadDirectPage();
	}
	else if (_idMenuToLoad > 0 && _idMenuToLoad != 998)
		loadContentData(_idMenuToLoad, _idDetailToLoad, _idProductToLoad);	
	else if(_idMenuToLoad == 998)
		loadMap();
}

function loadBackgroundImage(bkgTop, bkgBottom)
{
	jQuery("#sfondo").children("#background").children("img").removeAttr('src');
	jQuery("#sfondo").children("#background").children("img").attr('src', bkgTop);	
	jQuery("#sfondo").children("#background").children("img").attr('source', bkgTop);	
	
	//if(jQuery.trim(jQuery(xmlData).find('sfondo').find('bkgCenter').text()) != '')
		//jQuery("#sfondo").children("#background_center").attr('style', 'background-image:url('+jQuery(xmlData).find('sfondo').find('bkgCenter').text()+')');
	//alert(bkgBottom)
	if (jQuery.trim(bkgBottom) != '' && jQuery.trim(bkgBottom) != 'img/')
	{
		jQuery("#sfondo").children("#background_bottom").children("img").removeAttr('src');
		jQuery("#sfondo").children("#background_bottom").children("img").attr('src', bkgBottom);	
		jQuery("#sfondo").children("#background_bottom").children("img").attr('source', bkgBottom);
	}else
	{
		jQuery("#sfondo").children("#background_bottom").children("img").removeAttr('source');
	}
}

function condividiFB(hashname,idp)
{
	//alert(window.location)
	
	//hashString = window.location.hash;
	//hashString = hashString.substring(1, hashString.length);
	var data = new Date();
	var date = data.getHours() + ":" + data.getMinutes() + ":" + data.getSeconds() + ":" + data.getMilliseconds() + ":";
	//alert(window.location + "||" + hashname + "||" + idp)
	//var urlSite = window.location.href;
	//http://debian.adacto.it/sammontana/#prodotti||prodotti/bar/adulti|0244
	
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url_site+"procedure/redirect_like_facebook.php?par="+hashname + "|" + idp)+'&d='+date,'sharer','toolbar=0,status=0,width=626,height=436');
	//window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent("<%=url_site%>jsp/redirect_facebook.php?idRichiesta=<%=idProgetto%>")+'&d='+date,'sharer','toolbar=0,status=0,width=626,height=436');
	return;
}

function trackAnalytics(page)
{
  var pageTracker = _gat._createTracker(analytics_id);
  //pageTracker.setAllowLinker(true); 
  pageTracker._trackPageview(page);
}

function trackEventAnalytics(element)
{
  _gaq.push(['_trackEvent','video-comunicazione-'+element,'PLAY-VIDEO',element]);
}
