jQuery(window).load(function(){
	
    var windowH = 0;
    var windowW = 0;
    
    function setWindowSizes(){
	    if (navigator.appName.indexOf("Microsoft")!=-1) {
	  		windowH = document.documentElement.offsetHeight;
	  		windowW = document.documentElement.offsetWidth;
	 	}
	 	else{
			windowH = window.innerHeight;
			windowW = window.innerWidth;
		}
		$("#col-left").height(windowH);
		if($("#col-middle").length == 1){
			$("#col-middle").height(windowH);
			var marginTop = getCssAttrVal($("#wrapper-linksList"),"margin-top");
			$("#wrapper-linksList").height(windowH - (marginTop*2));
		}
		$('#wrapper-linksList').jScrollPane();
		
	}
	
	
	setWindowSizes();
		
	// resize de la fenetre 
    $(window).resize(function(){
		setWindowSizes();
    });
    
    
	var _w = $("#col-middle").outerWidth();
	var marginLeftMain = getCssAttrVal($("#col-main"),"margin-left");
	
	$("#toggle-middle").live("click", function(){
		if($(this).hasClass('close')){
			$("#col-middle").animate({"margin-left": 0}, 300);
			$(this).removeClass('close').addClass('open');
			$("#col-main").delay(50).animate({"margin-left": marginLeftMain-_w}, 300);
		}
		else{
			$("#col-middle").animate({"margin-left": _w}, 300);
			$(this).removeClass('open').addClass('close');
			$("#col-main").delay(50).animate({"margin-left": marginLeftMain}, 300);
		}
	});
	
	$(".no-link").click(function(e){ e.preventDefault(); });
	
	
	function getCssAttrVal(elt, attr){
		return $(elt).css(attr).substr(0, ($(elt).css(attr).length-2));
	}
	
	
	
	
	$.fn.scrollToTop=function(){
			
		$("#backtotop").hide().removeAttr("href");
		
		if($(window).scrollTop()!="0"){
			$(this).stop(true, true).fadeIn("slow")
		}
		var scrollDiv=$(this);
		
		$(window).scroll(function(){
								  
			if($(window).scrollTop()=="0"){
				$(scrollDiv).stop(true, true).fadeOut("slow")
			}else{
				$(scrollDiv).stop(true, true).fadeIn("slow")
			}
		
		});
		
		$(this).click(function(){
			$("html, body").animate({scrollTop:0},"slow");
		});
	
	}

	$("#backtotop").scrollToTop();
	
	
	
});
