var image_numbers = 118; var init_loop = "true"; var loop_interval = "15000"; //recuperation des variables GET var page='acceuil'; function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return unescape(pair[1]); } } return false; } // Tootlips jQuery.fn.Tooltip = function() { // For each instance of this element return this.each(function(){ // Add the new attribute with title's current value and then remove the title attribute jQuery(this).attr({'data-tooltip': jQuery(this).attr("title")}).removeAttr("title"); }); }; //lecture du cookie pour savoir di on fait un slideshow pour l'image de fond. !readCookie('sanigros_loop_background') ? createCookie('sanigros_loop_background', init_loop, 7) : null; //generation d'un numero aleatoire entre MinV et MaxV. function randomBetween(MinV, MaxV) { var formated_result = MinV + Math.floor((MaxV - MinV + 1) * (Math.random() % 1)); if (formated_result <= 9) formatted_result = '000' + formated_result; else if (formated_result <= 99) formatted_result = '00' + formated_result; else if (formated_result <= 999) formatted_result = '0' + formated_result; return formatted_result; } //demarrage du slideshow. function startLoop(){ looping = setInterval(function (){changeBackground('big_' + randomBetween(0, image_numbers) + '.jpg');}, loop_interval); eraseCookie('sanigros_loop_background'); createCookie('sanigros_loop_background', 'true', 7); //$('#loop').text('Arrêter'); $('#loop img').attr("src", 'images/wallpaper_on.png'); } //arret du slideshow. function stopLoop(){ clearInterval(looping); eraseCookie('sanigros_loop_background'); createCookie('sanigros_loop_background', 'false', 7); //$('#loop').text('Démarrer'); $('#loop img').attr("src", 'images/wallpaper_off.png'); } //toggle (oui/non) du slideshow. function toggleLoop(){ readCookie('sanigros_loop_background') == 'false'? startLoop() : stopLoop(); } //fonction pour l'agrandissement/retrecissement maxi du fond de la page function FullScreenBackground(theItem){ var winWidth=$(window).width(); var winHeight=$(window).height(); var imageWidth=$(theItem).width(); var imageHeight=$(theItem).height(); var picHeight = imageHeight / imageWidth; var picWidth = imageWidth / imageHeight; if ((winHeight / winWidth) < picHeight) { $(theItem).css("width",winWidth); $(theItem).css("height",picHeight*winWidth); } else { $(theItem).css("height",winHeight); $(theItem).css("width",picWidth*winHeight); }; $(theItem).css("margin-left", winWidth / 2 - $(theItem).width() / 2); $(theItem).css("margin-top", winHeight / 2 - $(theItem).height() / 2); } //fonction pour le changement du fond de la page. function changeBackground(imagename){ $('#data_loading').html('Image de fond…'); $('#data_loading').fadeIn('fast'); $('#bgimg').fadeOut('fast').remove(); var img = new Image(); $(img).load(function() { $(this).css('display', 'none'); $('#bg').append(this); $(this).fadeIn('slow'); FullScreenBackground(this); $('#data_loading').fadeOut('slow'); }).attr({ src: "images/background/" + imagename, id: "bgimg"}); } //s'il y a redimentionnement de la fenetre. $(window).resize(function() { FullScreenBackground('#bgimg'); }); $('#container').imagesLoaded( function(){ BuildWall(); }); function BuildWall(){ $('#container').masonry({ itemSelector : '#bloc', isFitWidth: true, isAnimated: true }); } //charger les "boites" function loadcontent(content, datatype, post_data){ if (!datatype) { var datatype = 'text'; } if (!post_data) { var post_data = ''; } $('#data_loading').html('Données…'); $('#data_loading').fadeIn('fast'); $('#container').fadeOut('slow', function(){ $('#bloc').removeClass(); if (datatype == 'text') { $(this).masonry( 'remove', $('#bloc')); $(this).append("
texte: " + content + "
"); $(this).fadeIn('slow').masonry('reload'); $('#data_loading').fadeOut('fast'); } else if (datatype == 'data'){ $(this).masonry( 'remove', $('#bloc')); $(this).load(content, post_data, function(response, status, xhr) { if (status == "error") { //var msg = "Sorry but there was an error: "; //alert(msg + xhr.status + " " + xhr.statusText); loadcontent('pages/patience.php', 'data'); } else { $('#container').fadeIn('slow').masonry('reload'); $('#data_loading').fadeOut('fast'); } }); } }); } $(document).ready(function() { //creation Menu $(".myMenu").buildMenu({ template:"menu.php", additionalData:"pippo=1", menuWidth:200, openOnRight:false, menuSelector: ".menuContainer", iconPath:"images/menu_icons/", hasImages:false, fadeInTime:100, fadeOutTime:300, adjustLeft:2, minZindex:"auto", adjustTop:10, opacity:.93, shadow:true, shadowColor:"#555", hoverIntent:0, openOnClick:false, closeOnMouseOut:true, closeAfter:500, submenuHoverIntent:100 }); //Image de fond grand ecran "random" changeBackground('big_' + randomBetween(0, image_numbers) + '.jpg'); //avec slideshow? << info du cookie readCookie('sanigros_loop_background') == 'true' ? startLoop() : $('#loop img').attr("src", 'images/wallpaper_off.png'); //fondu d'entrée des 3 parties arriere tete et pied de page. $("#header").delay(500).fadeIn('slow'); $("#header_back").delay(500).fadeIn('slow'); $("#container").delay(800).fadeIn(); $("#footer").delay(1000).fadeIn('slow'); //jQuery masonry plugin (blocs a positionnement automatique. setTimeout(function(){ BuildWall(); }, 800); $('#footer').hover( function () { $('#footer_back').slideDown('fast');}, function () { $('#footer_back').slideUp('fast');} ); //Affichage du tooltip pour le wallpaper $("a.tooltip").Tooltip(); loadcontent('pages/'+page+'.php', 'data'); //effet onmouseOver des blocs de données.. $('#bloc').hover( function () { $(this).css("background-color", "#FFF");}, function () { $(this).css("background-color", "transparent");} ); });