/*	ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3 */
(function(c){function r(b,d){d=d==="x"?m.width():m.height();return typeof b==="string"?Math.round(b.match(/%/)?d/100*parseInt(b,10):parseInt(b,10)):b}function M(b){b=c.isFunction(b)?b.call(i):b;return a.photo||b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function Y(){for(var b in a)if(c.isFunction(a[b])&&b.substring(0,2)!=="on")a[b]=a[b].call(i);a.rel=a.rel||i.rel;a.href=a.href||i.href;a.title=a.title||i.title}function Z(b){i=b;a=c(i).data(q);Y();if(a.rel&&a.rel!=="nofollow"){g= c(".cboxElement").filter(function(){return(c(this).data(q).rel||this.rel)===a.rel});j=g.index(i);if(j<0){g=g.add(i);j=g.length-1}}else{g=c(i);j=0}if(!B){C=B=n;N=i;N.blur();c(document).bind("keydown.cbox_close",function(d){if(d.keyCode===27){d.preventDefault();e.close()}}).bind("keydown.cbox_arrows",function(d){if(g.length>1)if(d.keyCode===37){d.preventDefault();D.click()}else if(d.keyCode===39){d.preventDefault();E.click()}});a.overlayClose&&s.css({cursor:"pointer"}).one("click",e.close);c.event.trigger(aa); a.onOpen&&a.onOpen.call(i);s.css({opacity:a.opacity}).show();a.w=r(a.initialWidth,"x");a.h=r(a.initialHeight,"y");e.position(0);O&&m.bind("resize.cboxie6 scroll.cboxie6",function(){s.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll.cboxie6")}P.add(D).add(E).add(t).add(Q).hide();R.html(a.close).show();e.slideshow();e.load()}var q="colorbox",F="hover",n=true,e,x=!c.support.opacity,O=x&&!window.XMLHttpRequest,aa="cbox_open",H="cbox_load",S="cbox_complete", T="resize.cbox_resize",s,k,u,p,U,V,W,X,g,m,l,I,J,K,Q,P,t,E,D,R,y,z,v,w,i,N,j,a,B,C,$={transition:"elastic",speed:350,width:false,height:false,innerWidth:false,innerHeight:false,initialWidth:"400",initialHeight:"400",maxWidth:false,maxHeight:false,scalePhotos:n,scrolling:n,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:n,current:"Photo {current} sur {total}",previous:"précédent",next:"suivant",close:"fermer",open:false,overlayClose:n,slideshow:false, slideshowAuto:n,slideshowSpeed:2500,slideshowStart:"Démarrer le diaporama",slideshowStop:"Arret",onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};e=c.fn.colorbox=function(b,d){var h=this;if(!h.length)if(h.selector===""){h=c("<a/>");b.open=n}else return this;h.each(function(){var f=c.extend({},c(this).data(q)?c(this).data(q):$,b);c(this).data(q,f).addClass("cboxElement");if(d)c(this).data(q).onComplete=d});b&&b.open&&Z(h);return this};e.init=function(){function b(d){return c('<div id="cbox'+ d+'"/>')}m=c(window);k=c('<div id="colorbox"/>');s=b("Overlay").hide();u=b("Wrapper");p=b("Content").append(l=b("LoadedContent").css({width:0,height:0}),J=b("LoadingOverlay"),K=b("LoadingGraphic"),Q=b("Title"),P=b("Current"),t=b("Slideshow"),E=b("Next"),D=b("Previous"),R=b("Close"));u.append(c("<div/>").append(b("TopLeft"),U=b("TopCenter"),b("TopRight")),c("<div/>").append(V=b("MiddleLeft"),p,W=b("MiddleRight")),c("<div/>").append(b("BottomLeft"),X=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"}); I=c("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");c("body").prepend(s,k.append(u,I));if(x){k.addClass("cboxIE");O&&s.css("position","absolute")}p.children().bind("mouseover mouseout",function(){c(this).toggleClass(F)}).addClass(F);y=U.height()+X.height()+p.outerHeight(n)-p.height();z=V.width()+W.width()+p.outerWidth(n)-p.width();v=l.outerHeight(n);w=l.outerWidth(n);k.css({"padding-bottom":y,"padding-right":z}).hide();E.click(e.next);D.click(e.prev);R.click(e.close);p.children().removeClass(F); c(".cboxElement").live("click",function(d){if(d.button!==0&&typeof d.button!=="undefined")return n;else{Z(this);return false}})};e.position=function(b,d){function h(A){U[0].style.width=X[0].style.width=p[0].style.width=A.style.width;K[0].style.height=J[0].style.height=p[0].style.height=V[0].style.height=W[0].style.height=A.style.height}var f=m.height();f=Math.max(f-a.h-v-y,0)/2+m.scrollTop();var o=Math.max(document.documentElement.clientWidth-a.w-w-z,0)/2+m.scrollLeft();b=k.width()===a.w+w&&k.height()=== a.h+v?0:b;u[0].style.width=u[0].style.height="9999px";k.dequeue().animate({width:a.w+w,height:a.h+v,top:f,left:o},{duration:b,complete:function(){h(this);C=false;u[0].style.width=a.w+w+z+"px";u[0].style.height=a.h+v+y+"px";d&&d()},step:function(){h(this)}})};e.resize=function(b){function d(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function h(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}function f(G){e.position(G,function(){if(B){if(x){A&&l.fadeIn(100);k[0].style.removeAttribute("filter")}if(a.iframe)l.append("<iframe id='cboxIframe'"+ (a.scrolling?" ":"scrolling='no'")+" name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+a.href+"' "+(x?"allowtransparency='true'":"")+" />");l.show();Q.show().html(a.title);if(g.length>1){P.html(a.current.replace(/\{current\}/,j+1).replace(/\{total\}/,g.length)).show();E.html(a.next).show();D.html(a.previous).show();a.slideshow&&t.show()}J.hide();K.hide();c.event.trigger(S);a.onComplete&&a.onComplete.call(i);a.transition==="fade"&&k.fadeTo(L,1,function(){x&&k[0].style.removeAttribute("filter")}); m.bind(T,function(){e.position(0)})}})}if(B){var o,A,L=a.transition==="none"?0:a.speed;m.unbind(T);if(b){l.remove();l=c('<div id="cboxLoadedContent"/>').html(b);l.hide().appendTo(I).css({width:d(),overflow:a.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(p);c("#cboxPhoto").css({cssFloat:"none"});O&&c("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("cbox_cleanup",function(){this.style.visibility="inherit"});a.transition=== "fade"&&k.fadeTo(L,0,function(){f(0)})||f(L);if(a.preloading&&g.length>1){b=j>0?g[j-1]:g[g.length-1];o=j<g.length-1?g[j+1]:g[0];o=c(o).data(q).href||o.href;b=c(b).data(q).href||b.href;M(o)&&c("<img />").attr("src",o);M(b)&&c("<img />").attr("src",b)}}else setTimeout(function(){var G=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=G.height();l.css({height:a.h});G.replaceWith(G.children());e.position(L)},1)}};e.load=function(){var b,d,h,f=e.resize;C=n;i=g[j];a=c(i).data(q);Y();c.event.trigger(H); a.onLoad&&a.onLoad.call(i);a.h=a.height?r(a.height,"y")-v-y:a.innerHeight?r(a.innerHeight,"y"):false;a.w=a.width?r(a.width,"x")-w-z:a.innerWidth?r(a.innerWidth,"x"):false;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=r(a.maxWidth,"x")-w-z;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=r(a.maxHeight,"y")-v-y;a.mh=a.h&&a.h<a.mh?a.h:a.mh}b=a.href;J.show();K.show();if(a.inline){c('<div id="cboxInlineTemp" />').hide().insertBefore(c(b)[0]).bind(H+" cbox_cleanup",function(){c(this).replaceWith(l.children())}); f(c(b))}else if(a.iframe)f(" ");else if(a.html)f(a.html);else if(M(b)){d=new Image;d.onload=function(){var o;d.onload=null;d.id="cboxPhoto";c(d).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){h=function(){d.height-=d.height*o;d.width-=d.width*o};if(a.mw&&d.width>a.mw){o=(d.width-a.mw)/d.width;h()}if(a.mh&&d.height>a.mh){o=(d.height-a.mh)/d.height;h()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";f(d);g.length>1&&c(d).css({cursor:"pointer"}).click(e.next); if(x)d.style.msInterpolationMode="bicubic"};d.src=b}else c("<div />").appendTo(I).load(b,function(o,A){A==="success"?f(this):f(c("<p>Request unsuccessful.</p>"))})};e.next=function(){if(!C){j=j<g.length-1?j+1:0;e.load()}};e.prev=function(){if(!C){j=j>0?j-1:g.length-1;e.load()}};e.slideshow=function(){function b(){t.text(a.slideshowStop).bind(S,function(){h=setTimeout(e.next,a.slideshowSpeed)}).bind(H,function(){clearTimeout(h)}).one("click",function(){d();c(this).removeClass(F)});k.removeClass(f+ "off").addClass(f+"on")}var d,h,f="cboxSlideshow_";t.bind("cbox_closed",function(){t.unbind();clearTimeout(h);k.removeClass(f+"off "+f+"on")});d=function(){clearTimeout(h);t.text(a.slideshowStart).unbind(S+" "+H).one("click",function(){b();h=setTimeout(e.next,a.slideshowSpeed);c(this).removeClass(F)});k.removeClass(f+"on").addClass(f+"off")};if(a.slideshow&&g.length>1)a.slideshowAuto?b():d()};e.close=function(){c.event.trigger("cbox_cleanup");a.onCleanup&&a.onCleanup.call(i);B=false;c(document).unbind("keydown.cbox_close keydown.cbox_arrows"); m.unbind(T+" resize.cboxie6 scroll.cboxie6");s.css({cursor:"auto"}).fadeOut("fast");k.stop(n,false).fadeOut("fast",function(){c("#colorbox iframe").attr("src","about:blank");l.remove();k.css({opacity:1});try{N.focus()}catch(b){}c.event.trigger("cbox_closed");a.onClosed&&a.onClosed.call(i)})};e.element=function(){return c(i)};e.settings=$;c(e.init)})(jQuery);
//fin colorbox
//jquery cycle plugin
(function(D){var A="Lite-1.0";D.fn.cycle=function(E){return this.each(function(){E=E||{};if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=0;this.cyclePause=0;var I=D(this);var J=E.slideExpr?D(E.slideExpr,this):I.children();var G=J.get();if(G.length<2){if(window.console&&window.console.log){window.console.log("terminating; too few slides: "+G.length)}return }var H=D.extend({},D.fn.cycle.defaults,E||{},D.metadata?I.metadata():D.meta?I.data():{});H.before=H.before?[H.before]:[];H.after=H.after?[H.after]:[];H.after.unshift(function(){H.busy=0});var F=this.className;H.width=parseInt((F.match(/w:(\d+)/)||[])[1])||H.width;H.height=parseInt((F.match(/h:(\d+)/)||[])[1])||H.height;H.timeout=parseInt((F.match(/t:(\d+)/)||[])[1])||H.timeout;if(I.css("position")=="static"){I.css("position","relative")}if(H.width){I.width(H.width)}if(H.height&&H.height!="auto"){I.height(H.height)}var K=0;J.css({position:"absolute",top:0,left:0}).hide().each(function(M){D(this).css("z-index",G.length-M)});D(G[K]).css("opacity",1).show();if(D.browser.msie){G[K].style.removeAttribute("filter")}if(H.fit&&H.width){J.width(H.width)}if(H.fit&&H.height&&H.height!="auto"){J.height(H.height)}if(H.pause){I.hover(function(){this.cyclePause=1},function(){this.cyclePause=0})}D.fn.cycle.transitions.fade(I,J,H);J.each(function(){var M=D(this);this.cycleH=(H.fit&&H.height)?H.height:M.height();this.cycleW=(H.fit&&H.width)?H.width:M.width()});J.not(":eq("+K+")").css({opacity:0});if(H.cssFirst){D(J[K]).css(H.cssFirst)}if(H.timeout){if(H.speed.constructor==String){H.speed={slow:600,fast:200}[H.speed]||400}if(!H.sync){H.speed=H.speed/2}while((H.timeout-H.speed)<250){H.timeout+=H.speed}}H.speedIn=H.speed;H.speedOut=H.speed;H.slideCount=G.length;H.currSlide=K;H.nextSlide=1;var L=J[K];if(H.before.length){H.before[0].apply(L,[L,L,H,true])}if(H.after.length>1){H.after[1].apply(L,[L,L,H,true])}if(H.click&&!H.next){H.next=H.click}if(H.next){D(H.next).bind("click",function(){return C(G,H,H.rev?-1:1)})}if(H.prev){D(H.prev).bind("click",function(){return C(G,H,H.rev?1:-1)})}if(H.timeout){this.cycleTimeout=setTimeout(function(){B(G,H,0,!H.rev)},H.timeout+(H.delay||0))}})};function B(J,E,I,K){if(E.busy){return }var H=J[0].parentNode,M=J[E.currSlide],L=J[E.nextSlide];if(H.cycleTimeout===0&&!I){return }if(I||!H.cyclePause){if(E.before.length){D.each(E.before,function(N,O){O.apply(L,[M,L,E,K])})}var F=function(){if(D.browser.msie){this.style.removeAttribute("filter")}D.each(E.after,function(N,O){O.apply(L,[M,L,E,K])})};if(E.nextSlide!=E.currSlide){E.busy=1;D.fn.cycle.custom(M,L,E,F)}var G=(E.nextSlide+1)==J.length;E.nextSlide=G?0:E.nextSlide+1;E.currSlide=G?J.length-1:E.nextSlide-1}if(E.timeout){H.cycleTimeout=setTimeout(function(){B(J,E,0,!E.rev)},E.timeout)}}function C(E,F,I){var H=E[0].parentNode,G=H.cycleTimeout;if(G){clearTimeout(G);H.cycleTimeout=0}F.nextSlide=F.currSlide+I;if(F.nextSlide<0){F.nextSlide=E.length-1}else{if(F.nextSlide>=E.length){F.nextSlide=0}}B(E,F,1,I>=0);return false}D.fn.cycle.custom=function(K,H,I,E){var J=D(K),G=D(H);G.css({opacity:0});var F=function(){G.animate({opacity:1},I.speedIn,I.easeIn,E)};J.animate({opacity:0},I.speedOut,I.easeOut,function(){J.css({display:"none"});if(!I.sync){F()}});if(I.sync){F()}};D.fn.cycle.transitions={fade:function(F,G,E){G.not(":eq(0)").css("opacity",0);E.before.push(function(){D(this).show()})}};D.fn.cycle.ver=function(){return A};D.fn.cycle.defaults={timeout:4000,speed:1000,next:null,prev:null,before:null,after:null,height:"auto",sync:1,fit:0,pause:0,delay:0,slideExpr:null}})(jQuery)
//

$(document).ready(function(){
//====Pour le diapo
$("#cboxSlideshow").live("click",function(){
if($(this).html()=="Arret")
    {
       $(this).attr('title',"Mettre en Pause"); 
    }
    else
    {
        $(this).attr('title',"Démarrer le diaporama");
    }
});
$("#cboxPrevious").attr('title',"Photo précédente");
$("#cboxNext").attr('title',"Photo suivante");
$("#cboxClose").attr('title',"Fermer le Diaporama");
$("#cboxLoadedContent").attr('title',"Cliquez pour voir la suite"); 
//Pour le diapo====
//====Pour le bandeau
$("#animation").css({"height":"100px","overflow":"hidden","width":"450px"});
$("#animation").cycle({ 
    delay:  2000, 
    speed:  800
}); 
$(".imgcontenu").css({"overflow":"hidden"});
$('.imgcontenu').cycle({ 
    delay:  2000, 
    speed:  800 
    //before: onBefore 
});
//Pour le bandeau====
//====Annonce seule
if($('#annonceseule').size())
{
$("#photosannonce").css({"overflow":"hidden"});
for(var j=5;j<10;j++)
{
$("#photosannonce img").eq(j).css({"display":"none"});
}
$("#photosannonce img").not(".icone").each(function(){var d=$(this).attr('src');var reg=new RegExp("(120-100/)", "g");var x=d.replace(reg,"");var lienslide='<a href="'+x+'" rel="grandephoto" title="'+$(this).attr('alt')+'"></a>';$(this).wrap(lienslide);});
$("a[rel=grandephoto]").colorbox({"title":"Cliquez autour (zone blanche translucide) ou sur la croix, ou appuyer sur Echap pour fermer la fenêtre","current":"Photo {current} sur {total} : "+this.title.split(':')[1],"slideshow":true,"speed":500,"open":true,"opacity":0.8,"slideshowSpeed":3000,"onOpen":function(){$("#cboxSlideshow").attr('title',"Mettre en Pause")}});
$(".plusphotos").click(function(){$("#photosannonce").find("img:eq(1)").click();});
$("#photosannonce h3").click(function(){var d=$(this).parent("div");d.find("img:eq(1)").click();});
}
//Annonce seule==== 
//====LISTINGS
if($('.annonce').size())
{
$(".icone.maison").each(function(){
$(this).attr('title','Cliquez pour voir toutes les maisons');
$(this).css('cursor','pointer');
$(this).click(function(){
    var idliste=$(".liste_annonces").attr('id');
    if(idliste=="liste_annonces_ventes")
    {
    window.location.href="http://www.vente-immobilier-var.fr/achat-immobilier/maisons-villas.html";
    }
    else
    {
     if(idliste=="liste_annonces_locations")
    {
    window.location.href="http://www.vente-immobilier-var.fr/locations-immobilieres/maisons-villas.html";
    }
    }
});
});
$(".icone.appartement").each(function(){
$(this).attr('title','Cliquez pour voir tous les appartements');
$(this).css('cursor','pointer');
$(this).click(function(){
    window.location.href="http://www.vente-immobilier-var.fr/achat-immobilier/appartements-studios.html";
    });
});
$(".icone.terrain").each(function(){
$(this).attr('title','Cliquez pour voir tous les terrains');
$(this).css('cursor','pointer');
$(this).click(function(){
    window.location.href="http://www.vente-immobilier-var.fr/achat-immobilier/terrains.html";
    });
});
$(".icone.commerce").each(function(){
$(this).attr('title','Cliquez pour voir tous les commerces');
$(this).css('cursor','pointer');
$(this).click(function(){
    window.location.href="http://www.vente-immobilier-var.fr/achat-immobilier/commerces.html";
    });
});
$("#critere_tri").change(function(){
var val=this.value;
var type=$("#donnees").val();
if(val!="sans")
{
if(type=="get")
{
   var url=$("#urlget").val();
   window.location.href=url+'-'+val+'.html';}
else
{
    if(type=="post")
    {
      $("#formtri").submit();
    }
}
}
else{$("#critere_tri").val(val);}
});
if($("input.boutonspages").size())
{
$("input.boutonspages").click(function(){$("#formtri").submit();});
}
$(".photos_annonce").css({"overflow":"hidden"});
$('.photos_annonce').each(function(){$(this).cycle({ 
    delay:  3500, 
    speed:  900 
});})

$('.annonce p').each(function(){
    $(this).css({"height":"75px","overflow":"hidden"});
    var text=$(this).html();
    $(this).after('<span class="fade suite" style="position:relative;top:-2px;right:-30px;font-size:11px;font-style:italic;cursor:pointer;"> ... (lire la suite)</span>');
    $(this).after('<img class="icone zoom suite" style="cursor:pointer;border:none;position:relative;top:-5px;left:142px;" alt="zoomer sur cette annonce" title="zoomer sur cette annonce" src="http://www.vente-immobilier-var.fr/images/vide.png" />');
    var div=$(this).parent("div");
    var cond=div.attr('class');
    var detail;
    if(cond=="annonce marketing"){
    var images=div.find("div.photos_annonce").html();
    var regexp=new RegExp("(120-100)", "g");
    var images=images.replace(regexp,"200-180");
    var regexp=new RegExp("(style)", "g");
    var images=images.replace(regexp,"");
    var h3=$(this).parent("div").find("h3").text();
    var a=$(this).parent("div").find("form").html();
    var prix=$(this).parent("div").find("span.prixannonce").text();
    var html='<div class="zoomdiv"><p style="text-align:center;background:transparent !important;margin:10px 15px;font-weight:bold;font-size:15px;">'+prix+' : '+h3+'</p><div class="diapoimg">'+images+'</div><p class="zoomp">'+text+'</p><form  method="post" action="http://www.vente-immobilier-var.fr/contact-agence/index.html" ><img class="icone ecrire" id="lienversannonce" style="cursor:pointer;border:none;" alt="voir le bien" title="voir le bien" src="http://www.vente-immobilier-var.fr/images/vide.png" />'+a+'</form></div>';
    
    }
    else{detail="Détails du bien &gt;&gt;";
    var images=div.find("div.photos_annonce").html();
    var regexp=new RegExp("(120-100)", "g");
    var images=images.replace(regexp,"200-180");
    var regexp=new RegExp("(style)", "g");
    var images=images.replace(regexp,"");
    var h3=$(this).parent("div").find("h3").text();
    var a=$(this).parent("div").find("a:last").attr('href');
    var prix=$(this).parent("div").find("span.prixannonce").text();
    var html='<div class="zoomdiv"><p style="text-align:center;background:transparent !important;margin:10px 15px;font-weight:bold;font-size:15px;">'+h3+' à '+prix+'</p><div class="diapoimg">'+images+'</div><p class="zoomp">'+text+'<br /><a href="'+a+'"  style="float:right;margin-top:20px;"><img class="icone plusdinfos" id="lienversannonce" style="cursor:pointer;border:none;" alt="voir le bien" title="voir le bien" src="http://www.vente-immobilier-var.fr/images/vide.png" />'+detail+'</a></p></div>';
    }
    $(this).colorbox({
    "title":"Cliquez autour (zone blanche translucide) ou sur la croix, ou appuyer sur Echap pour fermer la fenêtre",
    "html":html,
    "onComplete":function (){
            $(".diapoimg").cycle({ 
        delay:  2000, 
        speed:  700 
    });
    $(".diapoimg").click(function(){
    if(cond=="annonce marketing"){
    $(this).parent("div").find("form").submit();
    }
    else{window.location.href=a;}
    });
    $(".zoomp").click(function(){if(cond=="annonce marketing"){
    $(this).parent("div").find("form").submit();
    }
    else{window.location.href=a;}});
    }
    });
});
$(".suite").click(function(){
var ori=$(this).parent("div").find("p");
ori.click();
});

$(".photos_annonce").click(function(){
var ori=$(this).parent("div").find("p");
ori.click();
});
$(".plusphotos").click(function(){var d=$(this).parent("div");var ori=$(d).parent("div").find("a.lienplusinfos");var vers=$(ori).attr('href');window.location.href=vers;
ori.click();});
}
//LISTINGS====
//====MENU
$("ol.sousmenu").css({"height":"auto","width":"250px","overflow":"visible"});
$("ol.sousmenu").slideUp();
$("#menu ul li").not("ol li").mouseover(function(){
    var n=$(this).find("ol.sousmenu");
    $("ol.sousmenu").not(n).slideUp();
    if(n.css('display')=='none')
	{
	n.slideDown(function(){
	if($(this).find('a.fermesousmenu').size()<1)
	{
		var x='<a href="javascript:void(0)" style="float:right;color:#CCC;" class="fermesousmenu" title="fermer">X</a>';
		n.prepend(x);
	}
	$("a.fermesousmenu").mouseover(function(){$(this).parent().slideUp();});
	});
	
	}
});

//MENU====

if($("#moteur").size() || $("#pagedecontenu").size())
{
if($("#moteur").size())
{
//==========FORMULAIRE DE RECHERCHE
$("#formlocation").hide();
$("#moteur").css("overflow","hidden");$("#legende").hide();
$("label img").click(function(){var l=$(this).parent("label");$(l).next("input").click();});
$(".faq a").colorbox({inline:true,href:"#contenulegende"});
$("#radiovente").click(function(){$("#formlocation").hide();$("#formvente").slideDown("slow");});
$("#radioloc").click(function(){$("#formvente").hide();$("#formlocation").slideDown("slow");});
$("div.souscriteres").hide();
$("input[name='type_bien_vente']").click(function(){
$("div.souscriteres").hide();
var type=$(this).val();
$("#"+type).show();
$("#choix_ville").show();
$("#choix_ville").prev("label").show();
});
$("#radio_vente_f").click(function(){$("#choix_ville").hide();$("#choix_ville").prev("label").hide();});
$("#radio_vente_t").click(function(){$("#choix_ville").hide();$("#choix_ville").prev("label").hide();});
$("#radiovente").click();
$("#radio_vente_m").click();
$("#maisons-villas").show();
//FORMULAIRE DE RECHERCHE=======
}
//SLIDESHOW
  // manageControls: Cache ou montre les flêches de controle en fonction de la position courante
function manageControls(position){
    // Cache la fleche "précédent" si on est sur le premier slide
	if(position==0){$('#leftControl').show();} else{$('#leftControl').show();}
	// Cache la fleche "suivant" si on est sur le dernier slide (et que le retour automatique n'est pas activé)
    if(position==numberOfSlides-1 && retour == false){
		$('#rightControl').hide();
	} else{
		$('#rightControl').show();
	}
	if(position == numberOfSlides && retour == true){
		currentPosition = 0;
		 $('#leftControl').hide();
	}
  }
function suivant(){
	$('#rightControl').click();
	}
function start() {
  	lectureEnCours = true;
    interval = setInterval(suivant, tempsAttente );
  }
function pause() {
  	lectureEnCours = false;
   clearInterval(interval);
  }
//======Configuration
		  var retour = true;
		  var tempsTransition = 1000;
		  var affichePlayPause;
		  var title_navig;
		  var lectureAutomatique;
		  if($("#pagedecontenu").size()){
          affichePlayPause = false;
          title_navig="Article ";
          lectureAutomatique = false;
          var slideWidth = 600;
          $(".slide img").each(function(){
              var src=$(this).attr('src');
              var regex=new RegExp("(200-180/|120-100/)", "g");
              src=src.replace(regex," ");
              $(this).colorbox({
                "href":src
                });
          });
          }
          else{
          affichePlayPause = true;
          title_navig="Coup de coeur ";
          lectureAutomatique = true;
          var slideWidth = 520;
          }
		  var tempsAttente = 6000;
		  var icones = new Array();
		  icones['play'] = 'http://www.vente-immobilier-var.fr/images/vide.png';
		  icones['classplay']="play";
		  icones['pause'] = 'http://www.vente-immobilier-var.fr/images/vide.png';
          icones['classpause']="pause";	
		  var currentPosition = 0;
		  var slides = $('.slide');
		  var numberOfSlides = slides.length;
		  var interval;
		  var lectureEnCours = false;
//Configuration======
  // Supprime la scrollbar en JS
  $('#slidesContainer').css('overflow', 'hidden');
  // Attribue  #slideInner  à toutes les div .slide
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });
  // Longueur de #slideInner égale au total de la longueur de tous les slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);
  // Insert controls in the DOM
  if(numberOfSlides>1)
  {
  $('#slideshow')
    .prepend('<span class="control gauche" id="leftControl" title="'+title_navig+'précédent">Précédent</span>')
    .append('<span class="control droite" id="rightControl" title="'+title_navig+'suivant">Suivant</span>');
  }
  // Hide left arrow control on first load
  manageControls(currentPosition);
  //Crée un écouteur d'évènement de type clic sur les classes .control
  $('.control')
    .bind('click', function(){
    // Determine la nouvelle position
if($(this).attr('id')=='rightControl'){
  if(currentPosition==numberOfSlides-1){currentPosition = 0;}
  else{currentPosition++;}
}
else{
    if(currentPosition == 0){currentPosition=numberOfSlides-1;}
    else{currentPosition=currentPosition-1;}
  }
// Cache ou montre les controles
    manageControls(currentPosition);
    // Fais bouger le slide
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    },tempsTransition);
  });
 //Si le diapo est activé 
if(lectureAutomatique == true){
  start();
}
if(affichePlayPause == true){
	$('#slideshow').append('<img id="navDiapo" src=""  alt="Navigation diaporama" />');
	if(lectureAutomatique == true){
		$('#navDiapo').attr('src',icones['pause']);$('#navDiapo').attr('class',icones['classpause']);
		$('#navDiapo').attr('title',"Cliquez pour arrêter le diaporama de coups de coeurs");
	}else{
		$('#navDiapo').attr('src',icones['play']);$('#navDiapo').attr('class',icones['classplay']);
        $('#navDiapo').attr('title',"Cliquez pour lancer le diaporama de coups de coeurs");	
	}
	$('#navDiapo').bind('click', function(){
		if(lectureEnCours == true){
			$(this).attr('src',icones['play']);
			$(this).attr('class',icones['classplay']);
			$(this).attr('title',"Cliquez pour lancer le diaporama de coups de coeurs");	
			pause();
		}else{
			$(this).attr('src',icones['pause']);
			$(this).attr('class',icones['classpause']);
			$(this).attr('title',"Cliquez pour arrêter le diaporama de coups de coeurs");
			start();
		}
	});
}
}
if($(".slide").size())
{
$('img.imgannonce').bind("click",function(){
var p=$(this).parent("p");
var d=p.parent("div");
var a=d.find("a.lienplusinfos");
var href=a.attr('href');
window.location.href=href;
});

$(window).keydown(function(e){ 
        switch (e.keyCode) { 
            case 37: // flèche gauche 
                $('#leftControl').click();
                break; 
            case 39: // flèche droite 
                $('#rightControl').click(); 
                break; 
        } 
    }); 
function clicksuiv(id)
{
var posencours=currentPosition;
if(id>posencours)
{
    $('#rightControl').click();
    posencours++;
}
else
{
        $('#leftControl').click();
        posencours--;
}
if(id>posencours || id<posencours){clicksuiv(id);}
}
if($("a.testpge").size()>0)
{
$(".testpge").click(function(){
if($(this).attr('id'))
{
var id=$(this).attr('id');
}
else{var id=$(this).attr('rel');}
var reg=new RegExp("(lienpage)", "g");
id=id.replace(reg,"");
if(id>currentPosition || id<currentPosition){clicksuiv(id);}
});
}
}
$(".fade").fadeTo('slow',0.5);
$(".fade").bind("mouseout",function(){var d=$(this);setTimeout(function(){d.fadeTo('slow',0.5)},2000);});
$(".fade").bind("mouseover",function(){if($(this).css("opacity")!=1){$(this).fadeTo('fast',1);}});
}); //fin doc ready


