var defaultId = 1;

function hideAllTitle(){
	var i=0;
	for(i=0 ; i< 20 ; i++){
		var titre = document.getElementById("title_" + i);
		var subtitle = document.getElementById("subtitle_" + i);
		if(titre != null){
			titre.style.display = "none";
		}
		if(subtitle != null){
			subtitle.style.display = "none";
		}
		
		var vignette = document.getElementById("vignette_" + i);
		if(vignette != null){
			vignette.style.opacity = 1;
			vignette.style.filter = 'alpha(opacity=' + (1 * 100) + ')'; 
		}
	}
}


function hideAllText(){
	var i=0;
	for(i=0 ; i< 20 ; i++){
		var text = document.getElementById("text_" + i);
		if(text != null){
			text.style.display = "none";
		}
	}
}

function showTitle( id ){
	hideAllTitle();
	var titre = document.getElementById("title_" + id);
	if(titre != null){
		titre.style.display = "";
	}
	var soustitre = document.getElementById("subtitle_" + id);
	if(soustitre != null){
		soustitre.style.display = "";
	}
	
	var vignette = document.getElementById("vignette_" + id);
	if(vignette != null){
	   	vignette.style.opacity = 0.6;
		vignette.style.filter = 'alpha(opacity=' + (0.6 * 100) + ')'; 
	}
}


function showText( id ){
	hideAllText();
	var text = document.getElementById("text_" + id);
	if(text != null){
		text.style.display = "";
	}
	
	defaultId = id;
}

//function vignettes

function hideAllTitleV(){
	var i=0;
	for(i=0 ; i< 20 ; i++){
		var titreV = document.getElementById("titleV_" + i);
		if(titreV != null){
			titreV.style.display = "none";
		}
		
		var vignette = document.getElementById("petite_vignette_" + i);
		if(vignette != null){
			vignette.style.opacity = 0.4;
			vignette.style.filter = 'alpha(opacity=' + (0.4 * 100) + ')'; 
		}
	}
}

function showTitleV( id ){
	hideAllTitleV();
	var titreV = document.getElementById("titleV_" + id);
	if(titreV != null){
		titreV.style.display = "";
	}
	
	var vignette = document.getElementById("petite_vignette_" + id);
	if(vignette != null){
   		vignette.style.opacity = 1;
		vignette.style.filter = 'alpha(opacity=' + (1 * 100) + ')'; 
	}
}


//function tab

function hideAllcontent(){
	var i=0;
	for(i=0 ; i< 5 ; i++){
		var content = document.getElementById("content_" + i);
		if(content != null){
			content.style.display = "none";
		}
	}
}

function showcontent( id ){
	hideAllcontent();
	var content = document.getElementById("content_" + id);
	if(content != null){
		content.style.display = "block";
	}
}




function loseFocus(){
 	document.getElementById("menu").focus()
	document.getElementById("menu").blur()
}






// fonction pour le deffilement di'images

	
	
	var TT_MOVING_DIV_ID = "";
	var TT_FIX_DIV_ID = "";
	var TT_INTERVAL = 0;
	var TT_MOUSE_POS = {};

	function defilement( parentDivId, movingDivId,MovingTableauId  ){
		
		var parentDiv = document.getElementById(parentDivId);
		var movingDiv = document.getElementById( movingDivId);
		var MovingTableau = document.getElementById( MovingTableauId);
		
		if ((movingDiv != undefined)&&(parentDiv != undefined)&&(MovingTableau != undefined)) {
			
			if (movingDiv.width != ""){
				TT_FIX_DIV_ID = parentDivId;
				TT_MOVING_DIV_ID = movingDivId

				movingDiv.style.marginLeft = "0px";
				
				MovingTableau.onmouseover = function(){
					this.onmousemove = mouseMove;
					TT_INTERVAL = self.setInterval("PanMoveDiv()",50)
				}
				parentDiv.onmouseout = function (){
					this.onmousemove = null;
					window.clearInterval(TT_INTERVAL);				
				}
				MovingTableau.onmouseout = function(){
					this.onmousemove = null;
					window.clearInterval(TT_INTERVAL);
				}
			}
		}
	}
	
	

	function PanMoveDiv()
	{
//		var t=new Date()
//		document.getElementById("clock").value=t
		var movingDiv = document.getElementById(TT_MOVING_DIV_ID);
		var fixDiv = document.getElementById(TT_FIX_DIV_ID);
		if((movingDiv != undefined) && (fixDiv != undefined)){
			var fixDivPos = findPos(fixDiv);
			var movingDivPos = findPos(movingDiv);
			
			//debug( "moveRelativePos X :" + (mousePos.x - movingDivPos[0])  + "  -  Y : " + (mousePos.y - movingDivPos[1]) );
			
			var localPosition = {x: TT_MOUSE_POS.x - fixDivPos[0], y: TT_MOUSE_POS.y - fixDivPos[1]}
			
			//debug( "localPosition X :" + localPosition.x  + "  -  Y : " + localPosition.y );
			//debug(" fix width : " + fixDiv.style.width )
			
			var fixWidth = fixDiv.style.width.replace("px", "");
			var movingWidth = movingDiv.style.width.replace("px", "");
			
			var vitesse = 10;
			
			var leftPos = movingDiv.style.marginLeft.replace("px", "");
			var minLeft  =  (fixWidth - movingWidth ) ;
			
//			alert("moving : " + movingWidth + "   -   fixWidth : " + fixWidth);
			
		//	debug("MIN : " + minLeft + " < " + leftPos + " < MAX : " + 0);
			
			
			if( localPosition.x < (fixWidth/3) ){
				if ( leftPos >= 0 ){
					movingDiv.style.marginLeft = "0px"
				}else{
					movingDiv.style.marginLeft =  (parseInt(leftPos) + vitesse) + "px";
					
				}
			}else if (localPosition.x > fixWidth*2/3){
				if ( leftPos <= minLeft){
					movingDiv.style.marginLeft = minLeft + "px" ;
				}else{
					movingDiv.style.marginLeft =  (parseInt(leftPos) - vitesse) + "px";
				}
			}else{
//				debug ("No Move");
			}
		}else{
			debug("Moving div not found : '"+TT_MOVING_DIV_ID+ "'" );
			this.onmousemove = null;
		}
		
		
	}

	
	
	function mouseMove(e){
		if (!e) var e = window.event;
		TT_MOUSE_POS = getMousePos(e);
	}
	

	
	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	}
	
	
	function getMousePos(e) {
		var posx = 0;
		var posy = 0;
		if (!e) var e = window.event;
		
		if (e.pageX || e.pageY) 	{
			posx = e.pageX;
			posy = e.pageY;
		}else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft
				+ document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop
				+ document.documentElement.scrollTop;
		}
		
		//debug( "posX : " + posx  + "  -  posY : " + posy);
		
		return {x:posx, y:posy}
	}
	
	
	
	function debug(string){
	
		var logDiv = document.getElementById("log");
		if(logDiv != undefined){
//			logDiv.innerHTML = string + "<br>" + logDiv.innerHTML;
		}
	}


