var clock=null;
var speed = 20;
var t_coord_left=0;
var scrollIt=false;

function startScrolling(d) {
clearTimeout(clock);
clock = setTimeout("scroll("+d+")",20);
scrollIt=true;
}

function stopScrolling() {
clock=null;
scrollIt=false;
}

function scroll(d) {
	if (!scrollIt) return;
var t=document.getElementById('scrollingTable');
var t_width = t.clientWidth;
var zS_width = document.getElementById('zoneScroll').clientWidth;

	if (t_coord_left!=0) t_coord_left = num(t.style.left);

	if (d>0) {
	
		if (parseInt(t_width+t_coord_left-speed) < parseInt(zS_width-18)){		
		return;
		}
		
	//l(parseInt(t_width) + " " + parseInt(t_width+t_coord_left-speed) + " " + parseInt(zS_width) );
	t_coord_left-=speed;
	}
	else {
		if (t_coord_left==0) return;
	t_coord_left+=speed;
	}
	
t.style.left = t_coord_left + "px";

	if (scrollIt) startScrolling(d);	
}

function num(str) {
var r = new RegExp(/px/);

	if (str.match(r)) {
	str = str.replace(r, "");
	}
return parseInt(str);
}

function l(str) {
document.getElementById('log').innerHTML=str;
}

function panorama_show(div_to_show) {
var div_galerie = document.getElementById('galerie_photo');
	if (div_galerie) {
		for (var i=0; i<div_galerie.getElementsByTagName('div').length;i++) {
		var div=div_galerie.getElementsByTagName('div')[i];
		
			if (!div.getAttribute('id')||div.getAttribute('id').indexOf('photo')<0) continue;
			else {
			div.style.display='none';	
			}		
		}		
	}else alert('div galerie_photo manquant');
	
	if (document.getElementById(div_to_show)) {
	document.getElementById(div_to_show).style.display='block';	
	}else alert('div '+div_to_show+' manquant');
}

// popup images réel //

var newWin = null;
function closeWin(){
if (newWin != null){
if(!newWin.closed)
newWin.close();
}
}
function popUp(strURL,strType,strHeight,strWidth) {
closeWin();
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="resizable,height="+strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
} 