  $.fn.wait = function(time, type) {
        time = time || 1000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };



 
 
 
 
 
 
 
 
 
 
 
 
 
var totale_offerte = 0;
var totale_news = 0;

function conta(){
 totale_offerte = $("#offerte_home li").length;
 totale_news = $("#news li").length;
 
 attiva();
}

 

function attiva(){

 setTimeout("offerte_home()", 0);
 setTimeout("news_home()", 300); 

}












var im = "/public/home_1.jpg";
var o=-1;
function offerte_home(){
	
	  o=o+1;
	 
   		if(o>=totale_offerte){o=0;}
	
		im = ""+$("#off_"+o).attr("title")+".jpg";
		$("#offerte_home").css("background","url("+im+") no-repeat center top");
		 
		$("#offerte_home").show(500);
		$("#off_"+o).fadeIn(1000);
   		$("#off_"+o).animate({"left": "+=0px", "top": "+=0px"}, 5000, function(){$("#offerte_home").fadeOut(1000);$("#off_"+o).fadeOut(1000, function(){$("#off_"+o).animate({"left": "-=0px", "top": "-=0px"}, "fast", offerte_home);})});
     
  } 
	 
	 

var im2 = "/public/home_1.jpg";
var n=-1;
function news_home(){
	
	  n=n+1;
	 
   		if(n>=totale_news){n=0;}
	
		im2 = "/public/"+$("#news_"+n).attr("title")+"_i.jpg";
		$("#news_home").css("background","url("+im2+") no-repeat center top");
		 
		$("#news_home").show(500);
		$("#news_"+n).fadeIn(1000);
   		$("#news_"+n).animate({"left": "+=0px", "top": "+=0px"}, 5000, function(){$("#news_home").fadeOut(1000);$("#news_"+n).fadeOut(1000, function(){$("#news_"+n).animate({"left": "-=0px", "top": "-=0px"}, "fast", news_home);})});
     
  } 	 
	 

	 







function offerta(){ location.href = $("#off_"+o+" a").attr("href");}

