/* SCROLL */
function resizeScroll(){
	var _size = $("#mainContent").height();
	var _size2 = $("#menu").height();
	var _total = ($(window).height())-170;
	var _max = Math.max(_size,_size2);

    if (_total < _max){
      $(function(){
          $(".scrollBlock").css("overflow", "auto");
          $(".scrollBlock").css("height", _total);
          $(".scrollBlock").jScrollPane({verticalDragMinHeight: 50,verticalDragMaxHeight: 50});
    });
  }
}
//resizeScroll();
/* /SCROLL */

/* BG EXTENSIBLE */
//$(document).ready(function(){
/* background resizable */ 
  function redimensionnement(){
	var image_width = $('.bg').width();
	var image_height = $('.bg').height();   
	  
	var over = image_width / image_height;
	var under = image_height / image_width;
	  
	var body_width = $(window).width();
	var body_height = $(window).height();
	  
	if (body_width / body_height >= over) {
	  $('.bg').css({
		'width': body_width + 'px',
		'height': Math.ceil(under * body_width) + 'px',
		'left': '0px',
		'top': Math.abs((under * body_width) - body_height) / -2 + 'px'
	  });
	}
	  
	else {
	  $('.bg').css({
		'width': Math.ceil(over * body_height) + 'px',
		'height': body_height + 'px',
		'top': '0px',
		'left': Math.abs((over * body_height) - body_width) / -2 + 'px'
	  });
	}
  }
		  
  /*if(!$.browser.webkit){
	  redimensionnement();
  }*/
	
  $(window).resize(function(){
	  redimensionnement();
  });
//});

/*if($.browser.webkit){
	redimensionnement();
}*/
/* /BG EXTENSIBLE */

setTimeout("resizeScroll();",1000);

/*  PRELOAD RANDOM BACKGROUNDS */
var preload=new Array();
for (n=0;n<randomimages.length;n++){
    preload[n]=new Image();
    preload[n].src=randomimages[n];
}
/*  /PRELOAD RANDOM BACKGROUNDS */

/* REDIMENSIONNEMENT BG */
$(window).load(function(){
	redimensionnement();
	//setTimeout("redimensionnement();",200);
});
/* /REDIMENSIONNEMENT BG */

/* PRELOAD IMAGES */
$.fn.preload = function(){
    this.each(function(){
        $('<img/>')[0].src = this;
    });
}
// Images list
$(['/img/bkgd/hp.jpg','/img/bkgd/bruxelles.jpg','/img/bkgd/downloadzone.jpg']).preload();
/* /PRELOAD IMAGES */
