/*Funzioni Per Jquery*/
$(document).ready(
	function () {
		fadeOfferte();
	
		$("#testo_scorrevole div").marquee().mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        });
	
		hoverDiv('');
		filtraArticoli('');
	}
);

function filtraArticoli(idElemento){
	$("#filtraAdimen").change(function(){
		$("#ffiltra").submit();
	});
}

function hoverDiv(idElemento){
	$(".boxClasse").hover(function(){
		div=$(this);
		linka=$(div).find("a").attr("href");
		qs=linka.substring(linka.indexOf("?"));
		$.ajax({
			url: "ajax/elencoFamiglie.asp"+ qs,
			data: ({}),
			dataType: "html",
			cache: false,
			beforeSend: function(msg){
				$("#tmpVelina").hide().remove();
				$("div.fixBugIe").hide().remove();
			},
			success: function(msg){
				/*$("#container").append("<div id=\"tmpVelina\"></div>");
				cssMessaggio();*/
				$(div).after("<div class=\"fixBugIe\"><div class=\"layerPop\">"+ msg +"</div></div>");
				
				
				$(".fixBugIe").hover(function(){
				},function(){$("div.fixBugIe").hide().remove();});
				
				
				/*$("#tmpVelina").hover(function(){
					$("#tmpVelina").empty().remove();
					$("div.fixBugIe").hide().remove();
				},function(){});*/
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				$(div).children("div.fixBugIe").remove();
				$("#tmpVelina").hide().remove();
			}
		});
	},function(){});
}

function fadeOfferte(){
	setTimeout(function(){
		id=$("#campoId").val();
		$.ajax({
			url: "ajax/boxSx.asp?id="+ id,
			data: ({}),
			dataType: "html",
			cache: false,
			beforeSend: function(msg){
			},
			success: function(msg){
				$("#boxNew div").fadeOut(2000,function(){
					$("#boxNew").html(msg);$("#boxNew div").fadeIn(2000,function(){fadeOfferte();});
				});
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				//alert("Si è verificato un errore");
			}
		});
	},5000);	
}

function cssMessaggio(){
	altoPage=$("#container").height();			largoPage=$("#container").width();
	$("#tmpVelina").css({ 
		width: largoPage, height: altoPage
	});
}
