/*!
 * Affichage d'images aléatoires pour jquery
 * Copyright 2010, Maxence Leret D'Aubigny et Sébastien Dellapina pour Datagif
 */
largeurmax=700;
largeurmaxright=-600;
hauteurmax=400;
		
function AnimationStop() {
	varstop=1;	
}
function shuffle(o){ 
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);  
	return o;   
}
function rand(l,u){
    return Math.floor((Math.random() * (u-l+1))+l);
}
function afficheimgleft(classe, classenot) {
	varstop=0;
	$(document).ready(function() {  
		var tabid = new Array(); 	
		$('.'+classe).each(function(indexx) { 
			tabid[indexx]=$(this).attr('id'); 
		}); 
		tabid=shuffle(tabid); 
	    var ii = 0; 
	    var intId = setInterval(aff,100);
	    function aff(){
	    	if(varstop!=1){
		        if (ii < tabid.length) {
		        	
		        	if(ii<6 && ii>2){
		        		posy=rand(hauteurmax/3-200,hauteurmax*(1/3));
						posx=rand(largeurmax/3+500,largeurmax*(1/1));
		        	}else if(ii<2){
		        		posy=rand(hauteurmax/2-200,hauteurmax*(1/2));
						posx=rand(largeurmax/3+500,largeurmax*(1/2));
		        	} else {
				        posy=rand(1,hauteurmax);
						posx=rand(1,largeurmax);
		        	}
		        	$('#'+tabid[ii]).css('top',posy-50+'px');
					$('#'+tabid[ii]).css('left',posx-90+'px');
					$('#'+tabid[ii]).fadeIn('fast');
		            ii++;
		        } else {
		            clearInterval(intId);  
		        }
	        }else {
	        	 clearInterval(intId); 
	        }
    	}
    });
}

function afficheimgright(classe, classenot) {
	varstop=0;
	$(document).ready(function() {  
		var tabid = new Array(); 	
		$('.'+classe).each(function(indexx) { 
			tabid[indexx]=$(this).attr('id'); 
		}); 
		tabid=shuffle(tabid); 
	    var ii = 0; 
	    var intId = setInterval(aff,100);
	    function aff(){
	    	if(varstop!=1){
		        if (ii < tabid.length) {
		        	
		        	if(ii<6 && ii>2){
		        		posy=rand(hauteurmax/3-200,hauteurmax*(1/3));
						posx=rand(largeurmaxright/3+500,largeurmaxright*(1/1));
		        	}else if(ii<2){
		        		posy=rand(hauteurmax/2-200,hauteurmax*(1/3));
						posx=rand(largeurmaxright/3+500,largeurmaxright*(1/2));
		        	} else {
				        posy=rand(1,hauteurmax);
						posx=rand(1,largeurmaxright);
		        	}
		        	$('#'+tabid[ii]).css('top',posy-50+'px');
					$('#'+tabid[ii]).css('left',posx+200+'px');
					$('#'+tabid[ii]).fadeIn('fast');
		            ii++;
		        } else {
		            clearInterval(intId);  
		        }
	        }else {
	        	 clearInterval(intId); 
	        }
    	}
    });
}
