// JavaScript Document

var mvt=false;


//--- effet mouvement
jQuery.extend( jQuery.easing,
{
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	}
});


//--- fin du mouvement
function callback(){
	mvt=false;
}

//---init
function f_init_push_home(longueur){

	//var step =  $("#push ul").width();
	//var longueur=868;
	


	if (navigator.appVersion.indexOf("MSIE 6")!=-1){
		var longueur=longueur + 129;	
	}
	
	var step = 868;

	var marge = 15; //marge right entre les LI
	var moveX = 2*(129 + marge);
	var $subnav = $("#push ul");
	
	subListItems = $subnav.find("li").size();
	

	$subnav.width(longueur+(subListItems*marge));

	
	
	if($subnav.css("marginLeft") == 0+"px"){
		$("a.lessthumbz").css({display: "none"})
	}
	//if($subnav.css("marginLeft").replace("px", "") <= -($subnav.width()+step)){
	if 	($subnav.width() <= step){
		$("a.morethumbz").css({display: "none"})
	}
	
	
	
		
	
	$("a.morethumbz").click(function () {
		
		
		if (mvt==false){
			mvt=true;
			
			
			$subnav.filter("ul:not(:animated)").animate({ marginLeft: parseInt($subnav.css("marginLeft").replace("px", "")) - moveX }, 500, "easeOutSine",callback);
			
			
			
			if($subnav.css("marginLeft").replace("px", "") <= -$subnav.width() + step + 2*moveX ){
			//if (d >= tab_li.length - 1){
				$(this).fadeOut("slow");
			}
			if($subnav.css("marginLeft") <= 0+"px"){
			//if (g>0){	
				$("a.lessthumbz").fadeIn("slow");
			}
			return false;
		}
	});
	
	
	$("a.lessthumbz").click(function () { 

		if (mvt==false){
			mvt=true;
	
	
			$subnav.filter("ul:not(:animated)").animate({ marginLeft: parseInt($subnav.css("marginLeft").replace("px", "")) + moveX }, 500, "easeOutSine", callback);
			
			if($subnav.css("marginLeft").replace("px", "") <= $subnav.width()+ moveX){
			//if (d < tab_li.length){	
				$("a.morethumbz").fadeIn("slow");
			}
			
			if($subnav.css("marginLeft").replace("px", "") >= -moveX){
			//if (g==0){	
				$(this).fadeOut("slow");
			}
			return false;
		}
	});




}; // ends ready

