positionImage = new Array();
var description = new Array();
var timers = new Array();
widthTotal = 0;
heightTotal = 0;
familleActuelle = 0;
widthElement = 0;
myposition = 0;


jSel = "jFlowSelectedLarge";

function clearAllTimeouts(){
  for(key in timers ){
    clearTimeout(timers[key]);
  }

}


function goLeft(el){


pos = jQuery(".liste_news_large").css("left");

if(widthTotal < 1 )
{
widthTotal = 0;
nbImage = 0;
widthImages = 0;
jQuery(".liste_news_large"+" div.slide-wrapper").each(function(i){
    widthElement = jQuery(this).outerWidth();
    marge = parseInt(jQuery(this).css("marginRight")) + parseInt(jQuery(this).css("marginLeft"));
    widthElement += marge;
    widthImages += jQuery(this).outerWidth() + marge;
nbImage++;
});


widthTotal = widthImages;
}


//alert(jQuery("#liste_news_large img:last-child").offset().left);
pos= parseInt(pos);
abspos = Math.abs(pos);

myposition = Math.abs(Math.floor(pos / widthElement)) - 1;
jQuery(".jFlowControlLarge").removeClass(jSel);
jQuery(".jFlowControlLarge").eq(myposition).addClass(jSel);


if( widthTotal - jQuery("#bloc_news_large").width() > abspos )
{
	newpos = pos-2;
	jQuery(".liste_news_large").css("left",newpos+"px");

	timers.pop;
	timers.push(setTimeout(function(){goLeft(el);}, 1));
}
}



function goRight(el){
pos = jQuery(".liste_news_large").css("left");
pos= parseInt(pos);

myposition = Math.abs(Math.floor(pos / widthElement)) - 1;
if(myposition<0)
{
    myposition = 0;
}


jQuery(".jFlowControlLarge").removeClass(jSel);
jQuery(".jFlowControlLarge").eq(myposition).addClass(jSel);
if(parseInt(pos)<0)
{
	newpos = parseInt(pos)+2;
	jQuery(".liste_news_large").css("left",newpos+"px");
	timers.pop;
	timers.push(setTimeout(function(){goRight(el);}, 1));
}
}

function goPosition(Position){

    if(widthTotal < 1 )
    {
        widthTotal = 0;
        nbImage = 0;
        widthImages = 0;
        jQuery(".liste_news_large"+" div.slide-wrapper").each(function(i){
            widthElement = jQuery(this).outerWidth();
            marge = parseInt(jQuery(this).css("marginRight")) + parseInt(jQuery(this).css("marginLeft"));
            widthElement += marge;
            widthImages += jQuery(this).outerWidth() + marge;
            nbImage++;
        });


        widthTotal = widthImages;
    }

    destination = widthElement * (Position-1) * (-1);
    pos = parseInt(jQuery(".liste_news_large").css("left"));

    if(destination < pos){
//         equivalent goLeft
        while(pos != destination){
            pos = pos-2;
            jQuery(".liste_news_large").css("left",pos+"px");
        }
    }
    else{
        //         equivalent goRight
        while(pos != destination){
            pos = pos+2;
            jQuery(".liste_news_large").css("left",pos+"px");
        }
    }


    // jQuery(".liste_news_large").css("left",destination+"px");

}


jQuery(window).load(function(){

    jQuery(".jFlowControlLarge").eq(0).addClass(jSel);


jQuery(".gauche").mouseover(function(){
goRight(jQuery(this));
});

jQuery(".gauche").mouseout(function(){
clearAllTimeouts();
});

jQuery(".droite").mouseover(function(){
goLeft(jQuery(this));
});

jQuery(".droite").mouseout(function(){

clearAllTimeouts();
});

jQuery(".jFlowControlLarge").each(function(i){
    jQuery(this).click(function(){
        goPosition(i+1);
        jQuery(".jFlowControlLarge").removeClass(jSel);
        jQuery(this).addClass(jSel);

    });
});

});



