var wait = false; var i = 2; var images = new Array('images-titre/Poster_machine_titre.jpg', 'images-titre/Autocs_titre.jpg', 'images-titre/Panneau_boucanier_titre.jpg', 'images-titre/Stand_N_titre.jpg', 'images-titre/expo_bakclite2.jpg', 'images-titre/decoupe_photo_1_frizz.jpg', 'images-titre/finitions_titre2.jpg', 'images-titre/vehicule_titre.jpg', 'images-titre/Stand_parapluie_Titre.jpg', 'images-titre/aucuneimage.jpg', 'images-titre/autoc_armoir_titre.jpg', 'images-titre/Roll-up_titre.jpg', 'images-titre/bache_titre.jpg', 'images-titre/presentoire-titre.jpg', 'images-titre/impression_sur_bois.jpg', 'images-titre/images_perso_produit.jpg', 'images-titre/', 'images-titre/images_perso_produit.jpg', 'images-titre/', 'images-titre/aucuneimage.jpg', 'images-titre/photolitho.jpg', 'images-titre/aucuneimage.jpg', 'images-titre/aucuneimage.jpg', 'images-titre/aucuneimage.jpg', 'images-titre/aucuneimage.jpg', 'images-titre/aucuneimage.jpg'); var titles = new Array('Affiches', "Autocollants", "Panneaux", "Stands", "Backlite", "Découpe ", "Finitions", "Véhicule", "Stand Parapluie", "Drapeau", "Signalétique", "Roll-up", "Bâches", "Présentoirs", "Impression sur bois", "Images perso", "MetalFX", "Offset UV / Vernis UV", "Hexachromie", "Photographie", "Photolithographie", "Brochures", "Livres", "Dépliants", "Set administratif", "Flyers"); var ids = new Array(1, 9, 17, 21, 12, 3, 15, 22, 16, 18, 19, 20, 23, 24, 38, 39, 40, 42, 41, 32, 31, 33, 36, 34, 35, 37); var m = titles.length; // Preload des images var preLoadedImages = new Array(); var u = 0; var n; var p; while(u < m){ preLoadedImages[u] = ''; n = i + 1; p = i - 1; if(p < 0){ p = m; } if(n > m){ n = 0; } if(u == i || u == p || u == n){ preLoadedImages[u] = new Image(); preLoadedImages[u].src = images[u]; } u += 1; } // TODO : Pre-chargement des images function navClicked(cla){ if(wait == false){ // Si une animation n'est pas dŽjˆ en cours if(cla != "selected"){ // Si le lien n'est pas la page actuelle if(cla == "left"){ wait = true; i = i-1; if(i < 0){ i = m - 1; } if(i >= 1){ preLoadedImages[i-1] = new Image(); preLoadedImages[i-1].src = images[i-1]; } // -- GESTION DE L'IMAGE DE TITRE -- // $("#imagecontainer img").before(""); $("#imagecontainer img").not(":first").css("bottom", "257px"); $("#imagecontainer").css("background", "url("+images[i]+") no-repeat"); $("#imagecontainer img").animate( {"right": "-=800px"}, 600, "swing", function(){ $("#imagecontainer img").not(":first").remove(); wait = false; } ); // -- GESTION DU MENU -- // $("#nav a").not(":first, :last").filter(":first").parent().animate({"width": "0px"}, 600, "swing", function(){ $("#nav a").not(":first, :last").filter(":first").parent().remove(); }); $("#nav a.selected").attr("class", "right"); if(i >= 1){ text = titles[i-1]; } else{ text = titles[m-1]; } $("#nav a.left:first").attr("class", "selected").parent().after("
  • "+text+"
  • "); $("#nav a.left:first").parent().animate({"width": "180px"}, 600, "swing"); } if(cla == "right"){ wait = true; i = i+1; if(i >= m){ i = 0; } if(i < m-1){ preLoadedImages[i+1] = new Image(); preLoadedImages[i+1].src = images[i+1]; } // -- GESTION DE L'IMAGE DE TITRE -- // $("#imagecontainer img").after(""); $("#imagecontainer img").not(":first").css("bottom", "257px"); $("#imagecontainer").css("background", "url("+images[i]+") no-repeat"); $("#imagecontainer img").animate( {"right": "+=800px"}, 600, "swing", function(){ $("#imagecontainer img").css("bottom", "0px"); $("#imagecontainer img").not(":last").remove(); wait = false; } ); // -- GESTION DU MENU -- // $("#nav a").not(":first, :last").filter(":last").parent().animate({"width": "0px"}, 600, "swing", function(){ $("#nav a").not(":first, :last").filter(":last").parent().remove(); }); $("#nav a.selected").attr("class", "left"); if(i < m - 1){ text = titles[i+1]; } else{ text = titles[0]; } $("#nav a.right:last").attr("class", "selected").parent().before("
  • "+text+"
  • "); $("#nav a.right:first").parent().next().animate({"width": "180px"}, 600, "swing"); } // -- CHARGEMENT DU CONTENU PAR AJAX -- // $(".box:first").contents("h1").text("Chargement..."); $.ajax({ type: "POST", url: "ajax/get-products.php", data: "id="+ids[i], success: function(msg){ $(".box:first").empty().html(msg); } }); } } return false; }; $(document).ready(function(){ $("#nav a").click(function(){ return navClicked($(this).attr("class")); }); });