$(document).ready(function(){$(".box").bind("contextmenu",function(e){return false;})
init_loader();loader='<div class="loader"><div>chargement en cours</div><img src="assets/images/home/loader.gif" alt="loader"/></div>'
buffer=new Array();$(".box").bind("click",function(){$(this).html(loader)
$(this).css("background-color","#000000");etat=parseInt($(this).attr("state"))+1;img_ldr=etat+1;attr_nom=$(this).attr("nom");i=$.inArray(attr_nom,projet_id);if((!mem[i][img_ldr])&&(img_ldr<=fichiers[i].length)&&(fichiers[i][img_ldr])){temp=new Image;temp.src=fichiers[i][img_ldr];temp.alt=alts[i];buffer.unshift(new Array(temp,parseInt(i),parseInt(img_ldr),projet_id[i]));$(buffer[0][0]).load(function(){for(j=0;(j>=0)&&(j<buffer.length);j++){if(this.src==buffer[j][0].src){p1=buffer[j][1];p2=buffer[j][2];p3=buffer[j][3];mem[p1][p2]=buffer[j][0];j='-2';if(p2==$('.box[nom='+p3+']').attr("state")){$('.box[nom='+p3+']').html(mem[p1][p2]);}}}})}
if(parseInt($(this).attr("state"))==(fichiers[i].length-1)){$(this).html(mem[i][0]);$(this).attr("state",0);}
else{$('.box[nom='+attr_nom+']').html(mem[i][etat])
$('.box[nom='+attr_nom+']').attr("state",etat)}})
$(".box").bind("contextmenu",function(){etat=parseInt($(this).attr("state"));attr_nom=$(this).attr("nom");i=$.inArray(attr_nom,projet_id);if(etat>0){$('.box[nom='+attr_nom+']').html(mem[i][etat-1])
$('.box[nom='+attr_nom+']').attr("state",(etat-1))}})});function init_loader(){$.ajax({type:"GET",url:"http://www.les-graphiquants.fr/index.php?id=1508",dataType:"xml",success:function(xml){projet=$("projet",xml);fichiers=new Array();projet_id=new Array();mem=new Array();alts=new Array();for(i=0;i<projet.length;i++){alts[i]=projet.eq(i).find("alternative").eq(0).text();projet_id[i]=projet.eq(i).attr("name");fichiers[i]=new Array();mem[i]=new Array();for(j=0;j<projet.eq(i).find("fichier").length;j++){fichiers[i][j]=projet.eq(i).find("fichier").eq(j).text();}}
for(k=0;k<fichiers.length;k++){mem[k][0]=new Image;mem[k][0].src=fichiers[k][0];mem[k][0].alt=alts[k];$(".box[nom="+projet_id[k]+"]").html(mem[k][0])
$(mem[k][0]).load(function(){for(i=0;i<projet_id.length;i++){$(".box[nom="+projet_id[i]+"]").css("height",mem[i][0].height).css("width",mem[i][0].width)}})
image_cache_new=new Image;image_cache_new.src=fichiers[k][1];image_cache_new.alt=alts[k];mem[k][1]=image_cache_new;}}})};
