
scrollStep=1

timerLeft=""
timerRight=""

function affPlus() {
	if (document.getElementById('b1-ligne1').offsetWidth < document.getElementById('b1-ligne1').scrollWidth) {
		document.getElementById('b1-ligne1-ctl').style.visibility='visible';
	}
	/*if (document.getElementById('b1-ligne2').offsetWidth < document.getElementById('b1-ligne2').scrollWidth) {
		document.getElementById('b1-ligne2-ctl').style.visibility='visible';
	}*/
	if (document.getElementById('b2-ligne1').offsetWidth < document.getElementById('b2-ligne1').scrollWidth) {
		document.getElementById('b2-ligne1-ctl').style.visibility='visible';
	}
	if (document.getElementById('b3-ligne1').offsetWidth < document.getElementById('b3-ligne1').scrollWidth) {
		document.getElementById('b3-ligne1-ctl').style.visibility='visible';
	}
	if (document.getElementById('b4-ligne1').offsetWidth < document.getElementById('b4-ligne1').scrollWidth) {
		document.getElementById('b4-ligne1-ctl').style.visibility='visible';
	}
	/*if (document.getElementById('b4-ligne2').offsetWidth < document.getElementById('b4-ligne2').scrollWidth) {
		document.getElementById('b4-ligne2-ctl').style.visibility='visible';
	}*/
	if (document.getElementById('b5-ligne1').offsetWidth < document.getElementById('b5-ligne1').scrollWidth) {
		document.getElementById('b5-ligne1-ctl').style.visibility='visible';
	}
}

function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function sefct(id) {
	if (id == 'b1-ligne1') {
		var test = 'b1-ligne1-ctl';
	}
	if (id == 'b1-ligne2') {
		var test = 'b1-ligne2-ctl';
	}
	if (id == 'b2-ligne1') {
		var test = 'b2-ligne1-ctl';
	}
	if (id == 'b3-ligne1') {
		var test = 'b3-ligne1-ctl';
	}
	if (id == 'b4-ligne1') {
		var test = 'b4-ligne1-ctl';
	}
	if (id == 'b4-ligne2') {
		var test = 'b4-ligne2-ctl';
	}
	if (id == 'b5-ligne1') {
		var test = 'b5-ligne1-ctl';
	}
	if (document.getElementById(test).innerHTML == 'Más') { 
		clearTimeout(timerRight) 
		clearTimeout(timerLeft)
		scrollDivLeft(id);
	} else { 
		toLeft(id); 
	}
}

function toLeft(id){
	if (id == 'b1-ligne1') {
		var test = 'b1-ligne1-ctl';
	}
	if (id == 'b1-ligne2') {
		var test = 'b1-ligne2-ctl';
	}
	if (id == 'b2-ligne1') {
		var test = 'b2-ligne1-ctl';
	}
	if (id == 'b3-ligne1') {
		var test = 'b3-ligne1-ctl';
	}
	if (id == 'b4-ligne1') {
		var test = 'b4-ligne1-ctl';
	}
	if (id == 'b4-ligne2') {
		var test = 'b4-ligne2-ctl';
	}
	if (id == 'b5-ligne1') {
		var test = 'b5-ligne1-ctl';
	}
  document.getElementById(id).scrollLeft=0;
	clearTimeout(timerRight) 
	clearTimeout(timerLeft)
	document.getElementById(test).innerHTML = 'Más';
	document.getElementById(test).className = 'plusr';
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  var old = document.getElementById(id).scrollLeft;
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
  if (document.getElementById(id).scrollLeft == old && document.getElementById(id).scrollLeft != 0 ) {
	if (id == 'b1-ligne1') {
		var test = 'b1-ligne1-ctl';
	}
	if (id == 'b1-ligne2') {
		var test = 'b1-ligne2-ctl';
	}
	if (id == 'b2-ligne1') {
		var test = 'b2-ligne1-ctl';
	}
	if (id == 'b3-ligne1') {
		var test = 'b3-ligne1-ctl';
	}
	if (id == 'b4-ligne1') {
		var test = 'b4-ligne1-ctl';
	}
	if (id == 'b4-ligne2') {
		var test = 'b4-ligne2-ctl';
	}
	if (id == 'b5-ligne1') {
		var test = 'b5-ligne1-ctl';
	}
	clearTimeout(timerRight) 
  	clearTimeout(timerLeft)
	document.getElementById(test).innerHTML = 'Inicio';
	document.getElementById(test).className = 'debut';
	//document.getElementById(test).onclick = setTimeout(toLeft(id),30);
  }
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}
