var photos = new Spry.Data.XMLDataSet("partenaires/partenaires.xml.php", "photosplash/image");
Spry.Data.Region.addObserver("Partenaires", iniImages);

var carousselImageProduits;
carousselImageProduits=null;
function iniImages(){
	
if (Ext.get("Partenaires") && carousselImageProduits==null) {

		//slideS=Ext.query("div.Partenaires");
	 	//for (var x = 0 ; x < slideS.length; x ++){
		//alert('a');
		var tmp=Ext.get("Partenaires").query("div.imgPartenaire");
		if(tmp.length>0){
		carousselImageProduits = new caroussel( tmp,'Visible',0.10 );
		carousselImageProduits.rotation();
		}
	}
}

function caroussel(elsIni,clsIni,cronoIni){
			this.els=elsIni;
			this.cls=clsIni;
			this.crono=cronoIni;
			this.current=-1;
			this.timerID=null;
	
			this.rotation=function()	{	
			var actif=false;
			if (this.current==(this.els.length-1)) this.current=-1;
			
			 for (var x = 0 ; x < this.els.length; x ++){
				
                       var el = Ext.get(this.els[x]);
					  
                          if (el) { 
						 
                             if (el.hasClass(this.cls)) {
                                var Box=el.getBox(); 
								el.removeClass(this.cls);
								
								// if (x==(this.els.length-1)) x=0;
								//el.fadeOut(); 
                                   }else if (x>this.current && actif==false){
									
									el.addClass(this.cls);
									if (Box) el.setBox(Box);
									el.fadeIn();
								
									this.current=x;
									actif=true;
                                  }    
                              }
             }
			if (this.els.length>1) autoplay(this);
			}
			
			autoplay=function(obj){
				if (obj.timerID) obj.timerID = null;
				obj.timerID=setTimeout(function() { obj.rotation(); }, (obj.crono*1000)*60);	
			}
		
 }    
