function preload(){
	$(".warning").remove();
	$.preloadCssImages();
}

function setMovie(element,movie){
	$(element).flash({ 
		swf: movie+'.swf',
		params: { 
			play: true, 
			loop: true,
			wmode: 'transparent',
			menu: false
		},
		height: '100%', 
		width: '100%', 
		hasVersion: 9,
		expressInstaller: 'expressInstall.swf' // optional and temporary 
	});
}
	
	
function setSlideshow(element){
	$(element).cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
}


function setTicker(element){
	var ticker = $(element);
	ticker.children(":first").css("marginTop", 50);
	function animator(currentItem) {
		var distance = currentItem.height();
		duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.018;
		currentItem.animate({ marginTop: -distance }, duration, "linear", function() {
		currentItem.appendTo(currentItem.parent()).css("marginTop", 20);
			animator(currentItem.parent().children(":first"));
		}); 
	}
	animator(ticker.children(":first"));
	ticker.mouseenter(function() {
		ticker.children().stop();
	});
	ticker.mouseleave(function() {
		animator(ticker.children(":first"));
	});
}	


function setLightbox(element){
	$(element+' a').lightBox({fixedNavigation:true});
}


function svuota(element){
	element.select();
	element.focus();
}

function fn_accordion(element){
	$(element+" li form").hide();
	$(element+" li a").click(function() { 
    	$(this).addClass("current"); 
      	var $modulo = $(this).next(); 
        if($modulo.is(":visible")) {
        	$modulo.animate({height: "toggle"}, 750, "easeInOutExpo").prev().removeClass("current"); 
        } 
        if(!$modulo.is(":visible")) { 
       		$(element+" li form:visible").animate({height: "toggle"}, 750, "easeInOutExpo").prev().removeClass("current"); 
        	$modulo.animate({height: "toggle"}, 750, "easeInOutExpo"); 
        } 
    });
	$("#listform li:first form").show();
}
function secureform(){
	$.post('req/token.php?rand='+escape(Math.random()),function(txt){
		$('.secure').each(function(intIndex){
			$(this).append('<input type="hidden" name="ts" value="'+txt+'" />');
		});
	});
}

function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2){
  var x = Math.round(num * Math.pow(10,dec));
  if (x >= 0) n1=n2='';
 
  var y = (''+Math.abs(x)).split('');
  var z = y.length - dec;
 
  if (z<0) z--;
 
  for(var i = z; i < 0; i++) 
    y.unshift('0');
 
  y.splice(z, 0, pnt);
  if(y[0] == pnt) y.unshift('0');
 
  while (z > 3) 
  {
    z-=3;
    y.splice(z,0,thou);
  } 
 
  var r = curr1+n1+y.join('')+n2+curr2;
  return r;
}

function elimina(tabella,id,nome){
	$.ajax({
		type: "GET",
		url: "req/uploadify.php",
		data: "tabella="+tabella+"&id="+id+"&nome="+nome+"&cancel=on",
		success: function(msg){
			var dati = msg.split("|");
			if(dati[0] == "ok"){
				$(".filefield").remove();
				$("#filejobUploader").css("height","25");
				$("#filejobUploader").css("width","105px");
				$(".labelFileJob").css("margin-top","2px");
				$(".labelFileJob").css("margin-top","0px");
			}else{
				alert(dati[1]);
			}
		}
	});
}

function init_anchor(){
	if($.url.attr("anchor") != ""){
		var ancora = $.url.attr("anchor");
		$("#info-servizi-right a#"+ancora+" h3").css({"color":"#D51A1F", "text-transform":"uppercase"});
	}
}
$(window).load(function(){
	$(".warning").remove();
});
