$(document).ready(function() { /*--------------- Menu slide ---------------*/ if(document.getElementById('navigation')){ $('.menu_custom_slide').each(function(){ $(this).css({marginLeft:-($(this).width()/2)}).attr('id', $(this).height()); $(this).children('.menu_slide_margin').attr('id', $(this).width()); }); $('.menu_slide').hover(function(){ $(this).children('.menu_custom_slide').stop().css({height:$(this).attr('id'), width:$(this).children(".menu_custom_slide").children(".menu_slide_margin").attr('id')}).slideDown(); }, function(){ $(this).children('.menu_custom_slide').stop().css({height:$(this).attr('id'), width:$(this).children(".menu_custom_slide").children(".menu_slide_margin").attr('id')}).slideUp(); }); } /*--------------- Référence slide ---------------*/ var box_width = $('.mask_images').width(); var slide_width = $('.slide_images').width()-5; /*largeur cachée*/ var pos_max = box_width-slide_width; if (slide_width > box_width) { $('.detail_slide').show(); $('.detail_slide_right').addClass('active'); /* slide right */ $('.detail_slide_right').hover(function(){ box_width = $('.mask_images').width(); pos_max = box_width-slide_width; if($(this).hasClass('active')) { $('.detail_slide_left').addClass('active'); $('.slide_images').animate({left:pos_max}, slide_width, function(){ $('.detail_slide_right').removeClass('active'); }); } }, function(){ $('.slide_images').stop(); }); /* slide left */ $('.detail_slide_left').hover(function(){ box_width = $('.mask_images').width(); pos_max = box_width-slide_width; if($(this).hasClass('active')) { $('.detail_slide_right').addClass('active'); $('.slide_images').animate({left:0}, slide_width, function(){ $('.detail_slide_left').removeClass('active'); }); } }, function(){ $('.slide_images').stop(); }); } /*--------------- Séléction slide ---------------*/ if(document.getElementById('home_slide')){ $('#puces_home .puces_box#0').addClass('selected'); var box_width = $('.slider_container .home_box').width(); var slide_width = $('.slider_container .home_box #home_slide').width(); var nbr_home = slide_width/box_width; var destination=0; var slide_home=function(direction){ pos_actu_home=destination; speed_home = 800; if(direction == "left" && pos_actu_home < 0 ){ destination=Number(pos_actu_home)+box_width; }else if(direction == "left" && pos_actu_home >= 0){ destination=-box_width*nbr_home; speed_home = 1500; }else if(direction == "right" && pos_actu_home > -(slide_width-box_width)){ destination=pos_actu_home-box_width; }else if(direction == "right" && pos_actu_home <= -(slide_width-box_width)){ destination=0; speed_home = 2000; }else{ destination=-Number(direction)*box_width; } img_num=Math.abs(destination/box_width); $('.home_box #home_slide').stop(); $('.home_box #home_slide').animate({marginLeft:destination}, speed_home); $('#puces_home img').stop(); $('#puces_home .puces_box ').removeClass('selected'); $('#puces_home .puces_box#'+img_num).addClass('selected') clearTimeout(int_home); int_home = window.setTimeout(function(){slide_home('right');}, 6000); }; $('#puces_home .puces_box').click(function(){slide_home($(this).attr('id'))}); int_home = window.setTimeout(function(){slide_home('right');}, 6000); } if(document.getElementById('home')){ $("#home .box").mouseover(function(){ $(this).toggleClass('detailsOn'); }) $("#home .box").mouseout(function(){ $(this).toggleClass('detailsOn'); }) } /*-------------------- LOCALISATION --------------------------------*/ var selectedlocalisation = $("#selectLocalisation ul li.selectLocalisation").html(); $("#selectLocalisation li.selectLocalisation").hide(); $("#selectLocalisation ul li.localisation").prepend("" + selectedlocalisation +""); $("#selectLocalisation ul li.localisation span").click(function() { //alert("Kliknula si!!!"); $("#selectLocalisation li.localisation ul").slideDown('fast',function() { if ($('#clickout2').length == 0) { $("#localisation").prepend('
'); $("#clickout2").mouseover(function() { $("#selectLocalisation li.localisation ul").slideUp('fast',function() { $("#clickout2").remove(); }); }); } }); }); $.fn.selectOptions = function(value, clear) { var v = value; var vT = typeof(value); // handle arrays if(vT == "object" && v.constructor == Array) { var $this = this; $.each(v, function() { $this.selectOptions(this, clear); } ); }; var c = clear || false; // has to be a string or regular expression (object in IE, function in Firefox) if(vT != "string" && vT != "function" && vT != "object") return this; this.each( function() { if(this.nodeName.toLowerCase() != "select") return this; // get options var o = this.options; // get number of options var oL = o.length; for(var i = 0; i< oL; i++) { if(v.constructor == RegExp) { if(o[i].value.match(v)) { o[i].selected = true; } else if(c) { o[i].selected = false; } } else { s=parseInt(v); if(o[i].value == s) { o[i].selected = true; } else if(c) { o[i].selected = false; } } } } ); return this; }; $("#selectLocalisation li.localisation ul li").click(function() { var classelected = $(this).attr('class'); var t = $(this).html(); var optionvalue = $(this).attr('id');; $("select#country option:selected").removeAttr("selected"); var s = optionvalue.replace('\\"',""); $('input#country').val(optionvalue); $.ajax( { type : 'GET', url : 'setSession', data : 'id='+$('#country').val(), success: function(msg) { return false; } // error : function() { // alert('Error'); // } } ); $("#selectLocalisation li.selectLocalisation").show(); $("#selectLocalisation li.selectLocalisation").removeClass('selectLocalisation'); $(this).addClass('selectLocalisation'); $(this).hide(); $("#selectLocalisation ul li.localisation span").text(t); $("select.cats").selectOptions("0"); $("#selectLocalisation li.localisation ul").slideUp('fast',function() { $("#clickout2").remove(); }); $('#searchform').submit(); }); /*-------------------- RADIUS --------------------------------*/ if($("#selectRadius ul li.selectRadius").html()== null){ var selectedradius = $("#selectRadius ul li#noSelection").html(); }else{ var selectedradius = $("#selectRadius ul li.selectRadius").html(); } $("#selectRadius li.selectRadius").remove(); $("#selectRadius ul li.radius").prepend("" + selectedradius +""); $("#selectRadius li.radius span").click(function() { $(this).addClass('Open'); $("#selectRadius li.radius ul").slideDown('fast',function() { if ($('#clickout2').length == 0) { $("#radius").prepend(''); $("#clickout2").mouseover(function() { $("#selectRadius li.radius ul").slideUp('fast',function() { $("#clickout2").remove(); }); }); } }); }); $("#selectRadius li.radius ul li").click(function() { var classelected = $(this).attr('class'); var t = $(this).html(); var optionvalue = classelected; $("#radius option:selected").removeAttr('selected'); var s = optionvalue.replace('\\"',""); $("select#radius").selectOptions(s); $("#selectRadius li.selected").show(); $("#selectRadius li.selected").removeClass('selected'); $(this).addClass(' selected'); //$(this).hide(); var sub = t.replace(/( )*/g,""); $("#selectRadius ul li.radius span").text(sub); $("#selectRadius li.radius ul").slideUp('fast',function() { $("#clickout3").remove(); }); //$('#searchform').submit(); }); })