$(document).ready(function()
{     
      //préchargement des images ---
      var img_preloader = new Image;
      img_preloader.src = "images/interface/preloader.gif";
      
      // form type I > FRANCE =======================================================================================================
      
      $("input[@name='geoloc']").click(function()
      {
         $(this).val("").css({background:"white"});
      });

      var choice = null;
      
      $(".checkbox").click(function()
      {    
           var index = parseInt($(this).parent("dt").prevAll().children(".checkbox").length)+1;  
           if(index == choice)
           {
                choice = null;
                $(this).css({background:"url(http://www.trouver-un-logement-neuf.com/new_site/images/interface/checkbox.gif) 0 0"});
           }   
           else
           {
                choice = index;
                $(".checkbox").css({background:"url(http://www.trouver-un-logement-neuf.com/new_site/images/interface/checkbox.gif) 0 0"});
                $(this).css({background:"url(http://www.trouver-un-logement-neuf.com/new_site/images/interface/checkbox.gif) 0 18px"});
           }
           
           
      });
      
      $("#search").click(function()
      {     
            var message = "";
            var geoloc = $("input[@name='geoloc']").val();
            
            if(choice == null)
            {
                message = "Veuillez cocher le type de produit qui vous intéresse.\n";
            }
            
            if(geoloc == "" || geoloc == "Ville, département, code postal")
            {
                message += "Veuillez préciser la localisation (ville, déaprtement, code postal) qui vous intéresse.\n";
                $("input[@name='geoloc']").css({background:"#FFD8D8"});
            }
            
            if(message != "")
            {
                alert(message);
                
            }
            else
            {   

                    $("#form_recherche fieldset").hide();
                    $("#form_recherche").append("<img src='"+img_preloader.src+"' />").children("img").css({margin:"100px 0 0 100px"});
                      //données du formulmaire ---
                     var formData = {formGeoloc:geoloc, formProd:choice}
                      
                    $.ajax({
                       type: "POST",
                       url: "http://www.trouver-une-location.fr/recherche/analyse_crossDomain_TULN_dev.php",
                       data: formData,
                       dataType: "html",
                       success: function(msg)
                       {
                            window.location.href = msg;
                            $("#form_recherche").children("img,a").remove();
                            $("#form_recherche fieldset").fadeIn("slow");                                
                       }
                  });
            }
            
            return false;
      });
      
      // animation des dernières annonces ===========================================================================================
      
      $('#scroll_annonces').cycle({ 
            fx: 'turnRight',
            pause: 1, 
            speed:    500, 
            timeout:  3000
      });
      
      // ajoute un target = blank pour liens vers exterieur
      
      $("#list_site a:lt(2), .biens_immobiliers a, #scroll_annonces a, #zoom_sur a, #footer_menu a:eq(1),#footer_menu a:eq(2),#menu a:eq(1)").attr({target:"_blank"}); 
      
      function liquidCol()
      {
         var wHeight = $(document).height();
         $("#main").css({height:wHeight}); 
      }
      
      var fixHeight = setTimeout(liquidCol,100);
      $(window).resize(function(){liquidCol();});
      
      //ajout style current sur #menu 
      /*
      $("#menu a").click(function()
      {
         $("#menu a").removeClass("current");
         $(this).addClass("current");
      });
      */
      
});