//
// Prefetch images
//
var myimages = new Array();
function preloading(){
for (x=0; x<preloading.arguments.length; x++){
myimages[x] = new Image();
myimages[x].src = preloading.arguments[x];
}
}

preloading(
           
 //    '/static/images/interface/bg.png',
 //    '/static/images/interface/home_bg.png',
 //    '/static/images/interface/home_bg.png',
 //    '/static/images/interface/nav1.png',
 //    '/static/images/interface/nav2_off.png',
 //    '/static/images/interface/nav2.png'
     
           
           );


//
// NAV
//

$(document).ready(function(){
  $("ul.nav>li>a>img").not('.current').hover(
    function () {
//      $(this).attr('src', 'txt2png.php?color=141A0A&text=' + $(this).attr('alt'));
//      $(this).attr('src', 'static/images/nav/'  + $(this).attr('alt') + 'chalet.otf18141A0AB1C476.png');
      
      
    },
    function () {
   //   $(this).attr('src', 'txt2png.php?text=' + $(this).attr('alt'));
//        $(this).attr('src', 'static/images/nav/'  + $(this).attr('alt') + 'chalet.otf18FFFFFFB1C476.png');
    }
  );
  
  
});

//
// LOGIN FORM
//

$(document).ready(function(){


  
  
  $("#client_login>a").click(
      
      function(){
        if(document.getElementById('logout')) {
          return true;  
        }
      
        $("#nav2>ul").fadeOut(
          'slow', 
          function() {
            
            $("#nav2>ul#login_form").fadeIn();
          }
        );
        return false;
      }
    );
  
});


//
// HOME
//

$(document).ready( 
  function() { 
    $('#home_visuel').innerfade(
      {   
        speed: 'slow', 
         timeout: 2000
      }
    );
  }
);


//
// PORTFOLIO
//

$(document).ready(function(){

  // Load first item :
 
  var first = $("#carousel>ul>li>a>img.carousel_thumb:first").attr('alt');
  if(document.getElementById("portfolio_div")) {

    //$("#portfolio_div").load('ajax.php' , { id : first   } );
  }
  // Carousel :
  
  title="Previous"
  $("#carousel").jCarouselLite({
      btnNext: "#carousel_next",
      btnPrev: "#carousel_prev",
      visible : 5,
      scroll : 1,
      circular : false
  });
  
  $('a.button').click(function(){return false;})

  // Ajax loading :
    $("ul>li>a>img.carousel_thumb").click(
      function(){
        $("#portfolio_div").html('<div id="portfolio_loading">  </div>');
        //$("#portfolio_div").load('ajax.php' , { id :    $(this).attr('alt') } );
        return false;
      }
    );

  
  
  $('ul>li>a>img.carousel_thumb').hover(function() {
  $(this).fadeTo("fast",0.7);
}, function() {
  $(this).fadeTo("fast",1);
});
  
   
});


