$(window).load(function() { /*--------------- Menu slide ---------------*/ if(document.getElementById('navigation')){ $('.menu_custom_slide').each(function(){ $(this).css({marginLeft:-($(this).width()/2)}).attr('id', $(this).height()); }); $('.menu_slide').hover(function(){ $(this).children('.menu_custom_slide').stop().css({height:$(this).children('.menu_custom_slide').attr('id')}).slideDown(); }, function(){ $(this).children('.menu_custom_slide').stop().css({height:$(this).children('.menu_custom_slide').attr('id')}).slideUp(); }); } /*-------------------- MONNAIE --------------------------------*/ var selectedcurrency = $("#selectCurrency ul li.selectedCurrency").html();//takes the value of the actual currency //takes the actual currency value out of the hidden ul and puts it in a visible span at the start of li.currency $("#selectCurrency li.selectedCurrency").remove(); $("#selectCurrency ul li.currency").prepend(""+ selectedcurrency +""); //when the created span (i.e. the actual currency) is clicked the ul with all currencies appears $("#selectCurrency li.currency span").click(function() { $("#selectCurrency li.currency ul").slideDown('fast',function() { //here if it doesnt exist I create a clickout div all around and under the dropdown menu //when mouseover event over clickout div is triggered the dropdown menu closes and the clickout div is removed if ($('#clickout').length == 0) { $("#currency").prepend('
'); $("#clickout").mouseover(function() { $("#selectCurrency li.currency ul").slideUp('fast',function() { $("#clickout").remove(); }); }); } }); }); $("#selectCurrency li.currency ul li").click(function() { //get the class value of the clicked li var classelected = $(this).attr('class'); //the last character of the class is indeed the option value (cf PHP in sidebar_currency.php) var optionvalue = classelected.substring(classelected.length-1); //we remove any previously selected option and set selected the corresponding option in the select form $("#devise option:selected").removeAttr('selected'); $('#devise option[value='+optionvalue+']').attr("selected","selected"); $('#mycur').submit(); }); /*--------------- Séléction slide ---------------*/ if(document.getElementById('home_slide')){ $('#puces_home img.puce_home#0').css({opacity:"0.3"}); 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 img').animate({opacity:"1"}); //$('#puces_home img').css({filter:"alpha(opacity=100)"}); $('#puces_home img.puce_home#'+img_num).animate({opacity:"0.3"}); //$('#puces_home img.puce_home#'+img_num).css({filter:"alpha(opacity=30)"}); clearTimeout(int_home); int_home = window.setTimeout(function(){slide_home('right');}, 6000); }; $('#puces_home img.puce_home').click(function(){slide_home($(this).attr('id'))}); int_home = window.setTimeout(function(){slide_home('right');}, 6000); } /*--------------- Séléction rent ---------------*/ if(document.getElementById('home_slide_rent')){ var box_width_rent = $('.slider_container_rent .home_box_rent').width(); var slide_width_rent = $('.slider_container_rent .home_box_rent #home_slide_rent').width(); var nbr_home_rent = slide_width_rent/box_width_rent; var destination_rent=0; var slide_rent=function(direction){ pos_actu_home=destination_rent; speed_home = 800; if(direction == "left" && pos_actu_home < 0 ){ destination_rent=Number(pos_actu_home)+box_width_rent; }else if(direction == "left" && pos_actu_home >= 0){ destination_rent=-box_width_rent*nbr_home_rent; speed_home = 1500; }else if(direction == "right" && pos_actu_home > -(slide_width_rent-box_width_rent)){ destination_rent=pos_actu_home-box_width_rent; }else if(direction == "right" && pos_actu_home <= -(slide_width_rent-box_width_rent)){ destination_rent=0; speed_home = 0; }else{ destination_rent=-Number(direction)*box_width_rent; } img_num=Math.abs(destination_rent/box_width_rent); $('.home_box_rent #home_slide_rent').stop(); $('.home_box_rent #home_slide_rent').animate({marginLeft:destination_rent}, speed_home); clearTimeout(int_rent); int_rent = window.setTimeout(function(){slide_rent('right');}, 6000); }; int_rent = window.setTimeout(function(){slide_rent('right');}, 6000); } /*--------------- Séléction SALE ---------------*/ if(document.getElementById('home_slide_sale')){ var box_width_sale = $('.slider_container_sale .home_box_sale').width(); var slide_width_sale = $('.slider_container_sale .home_box_sale #home_slide_sale').width(); var nbr_home_sale = slide_width_sale/box_width_sale; var destination_sale=0; var slide_sale=function(direction){ pos_actu_home=destination_sale; speed_home = 800; if(direction == "left" && pos_actu_home < 0 ){ destination_sale=Number(pos_actu_home)+box_width_sale; }else if(direction == "left" && pos_actu_home >= 0){ destination_sale=-box_width_sale*nbr_home_sale; speed_home = 1500; }else if(direction == "right" && pos_actu_home > -(slide_width_sale-box_width_sale)){ destination_sale=pos_actu_home-box_width_sale; }else if(direction == "right" && pos_actu_home <= -(slide_width_sale-box_width_sale)){ destination_sale=0; speed_home = 0; }else{ destination_sale=-Number(direction)*box_width_sale; } img_num=Math.abs(destination_sale/box_width_sale); $('.home_box_sale #home_slide_sale').stop(); $('.home_box_sale #home_slide_sale').animate({marginLeft:destination_sale}, speed_home); clearTimeout(int_sale); int_sale = window.setTimeout(function(){slide_sale('right');}, 6000); }; int_sale = window.setTimeout(function(){slide_sale('right');}, 6000); } /*--------------- SECTEUR SOCIETY ---------------*/ $("#linkSecteur1").click(function(){ showSecteur("linkSecteur1", "secteur1"); }) $("#linkSecteur2").click(function(){ showSecteur("linkSecteur2", "secteur2"); }) $("#linkSecteur3").click(function(){ showSecteur("linkSecteur3", "secteur3"); }) $("#linkSecteur4").click(function(){ showSecteur("linkSecteur4", "secteur4"); }) function showSecteur(link, details){ $('.society_link').removeClass('selected'); $('#'+link).addClass('selected'); $(".secteur").removeClass('on'); $('#'+details).addClass('on'); } /*--------------- ADVICE ---------------*/ $("#juriste_link1").click(function(){ if($(this).hasClass('selected')){ closeAdvice("juriste_link1", "juriste_text1"); }else{ showAdvice("juriste_link1", "juriste_text1"); } }) $("#juriste_link2").click(function(){ if($(this).hasClass('selected')){ closeAdvice("juriste_link2", "juriste_text2"); }else{ showAdvice("juriste_link2", "juriste_text2"); } }) $("#juriste_link3").click(function(){ if($(this).hasClass('selected')){ closeAdvice("juriste_link3", "juriste_text3"); }else{ showAdvice("juriste_link3", "juriste_text3"); } }) $("#juriste_link4").click(function(){ if($(this).hasClass('selected')){ closeAdvice("juriste_link4", "juriste_text4"); }else{ showAdvice("juriste_link4", "juriste_text4"); } }) function closeAdvice(link, details){ $('h4').removeClass('selected'); $(".text").removeClass('on'); } function showAdvice(link, details){ $('h4').removeClass('selected'); $('#'+link).addClass('selected'); $(".text").removeClass('on'); $('#'+details).addClass('on'); } /*--------------- LOGIN ---------------*/ if ($(".loginButton").hasClass('itIsOpen')) { $("#global").prepend(''); $("#totalCover").fadeIn('fast'); actOnClickOut(); } $(".loginButton").click(function(){ if ($(this).hasClass('itIsOpen')) { $("#totalCover").fadeOut('slow',function(){ $(this).remove(); }); } else { $("#global").prepend(''); $("#totalCover").fadeIn('slow'); actOnClickOut(); } $("#showHideLogin").toggle("fast",function(){ $(".loginButton").toggleClass('itIsOpen'); $("#login_error").remove(); }); return false; }); /*close automatically on click out if has errors*/ $("#totalCover").click(function(){ $("#showHideLogin").toggle("fast",function(){ $(".loginButton").toggleClass('itIsOpen'); $("#login_error").remove(); $("#totalCover").fadeOut('slow',function(){ $(this).remove(); }); }); }); /*close automatically on click out if has errors*/ $("#closeLogin").click(function(){ $("#showHideLogin").toggle("fast",function(){ $(".loginButton").toggleClass('itIsOpen'); $("#login_error").remove(); $("#totalCover").fadeOut('slow',function(){ $(this).remove(); }); }); }); /*fade automatically the error message*/ setTimeout(function(){ $("#login_error").fadeOut('slow',function(){ $("#login_error").hide(); }); },1800); function actOnClickOut(){ /*close automatically on click out if no errors*/ $("#totalCover").click(function(){ $("#showHideLogin").toggle("fast",function(){ $(".loginButton").toggleClass('itIsOpen'); $("#login_error").remove(); $("#totalCover").fadeOut('slow',function(){ $(this).remove(); }); }); }); }; /*--------------- REFERENCES SEARCH ---------------*/ $(".SearchButton").click(function(){ if ($(".loginButton").hasClass('itIsOpen')) { $("#showHideLogin").toggle("fast",function(){ $(".loginButton").toggleClass('itIsOpen'); $("#login_error").remove(); $("#totalCover2").fadeOut('slow',function(){ $(this).remove(); }); }); } if ($(this).hasClass('itIsOpen')) { $("#totalCover2").fadeOut('slow',function(){ $(this).remove(); }); } else { $("#global").prepend(''); $("#totalCover2").fadeIn('slow'); actOnClickOut(); } $("#showHideSearch").toggle("fast",function(){ $(".SearchButton").toggleClass('itIsOpen'); }); return false; }); /*close automatically on click out if has errors*/ $("#totalCover2").click(function(){ $("#showHideSearch").toggle("fast",function(){ $(".SearchButton").toggleClass('itIsOpen'); $("#totalCover2").fadeOut('slow',function(){ $(this).remove(); }); }); }); /*close automatically on click out if has errors*/ $("#closeSearch").click(function(){ $("#showHideSearch").toggle("fast",function(){ $(".SearchButton").toggleClass('itIsOpen'); $("#totalCover2").fadeOut('slow',function(){ $(this).remove(); }); }); }); function actOnClickOut(){ /*close automatically on click out if no errors*/ $("#totalCover2").click(function(){ $("#showHideSearch").toggle("fast",function(){ $(".SearchButton").toggleClass('itIsOpen'); $("#login_error").remove(); $("#totalCover").fadeOut('slow',function(){ $(this).remove(); }); }); }); }; }); //END OF DOCUMENT READY