// JavaScript Document

var holdMenu = "";
var oldH;
var tailleDefil = 110;
var mult = 0;

function menu(etat, no){ 
	if(navigator.appVersion.indexOf('MSIE 8.0') != -1){
		//
	} else {
		var obj2 = document.getElementById("im_" + no);
		if(etat == 1) {
			obj2.style.visibility="visible";
		} else {
			obj2.style.visibility="hidden";
		}
	}
}

function test_size(){
		var obj = document.getElementById("tab");
		//alert(obj.offsetHeight);
		window.parent.resisze(obj.offsetHeight);
	}

function montre(id){
	
	if(holdMenu){
		var objHold = document.getElementById(holdMenu);
		sizeTween = new Tween(objHold.style,'height',Tween.regularEaseInOut,oldH,0,0.3,'px');
		sizeTween.start();
	}
	
	if(holdMenu != id){
	
		var obj = document.getElementById(id);
		var h = obj.scrollHeight;
		holdMenu = id;
		oldH = h;
		
		//sizeTween = new Tween(obj.style,'height',Tween.elasticEaseOut,0,h,1.2,'px');
		sizeTween = new Tween(obj.style,'height',Tween.regularEaseInOut,0,h,0.7,'px');
		sizeTween.start();	
	} else {
		holdMenu = "";
	}
}

function open_pop(path){
	var url="view_photo.php?path=" + path;
	window.open(url, 'pop', 'toolbar=0, location=0,  directories=0, status=0, scrollbars=0, resizable=1, copyhistory=0, menuBar=0, width=600, height=450');
}

function defil(sens){
	
	var obj = document.getElementById("div_2");	
	var testHeight = obj.scrollHeight;
	if(testHeight>=(tailleDefil+50)){

		var posActuel = parseInt(mult) * parseInt(tailleDefil);
		
		if(sens == "h"){
			mult = parseInt(mult) - 1;
		} 
		if(sens == "b"){
			mult = parseInt(mult) + 1;
		}
		var newPos = parseInt(mult) *  parseInt(tailleDefil) ;
		newpos = parseInt(newPos);
		
		sizeTween = new Tween(obj.style,'top',Tween.regularEaseInOut,parseInt(posActuel),newPos,0.9,'px');
		sizeTween.start();
		
		posActuel = obj.style.top;
		posActuel = parseInt(posActuel.substring(0, posActuel.indexOf("px")));
		
		if(newPos >= 0) {
			sens = 'h';
		} else if(-(newPos - parseInt(tailleDefil)) <= obj.offsetHeight) {
			sens = 'b';
		} 
		//document.getElementById("test").innerHTML=newPos;
		window.setTimeout("defil('" + sens + "')",6000);
	}
}