/*
 *
 * viewer v1.1 by Raphael AGUIRRE - REALISTIC-DESIGN
 *
 *
 *
 *
 *
 */
 //------------------------------------------------------VIEWER---------------------------------------------------------------------------------------------
 
function imgviewer(Parent, container_id){
 	 
	if(typeof Parent=="object"){
		this._parent = Parent;
	}else{
		if((Parent && Parent == "body") || !Parent){ this._parent = document.body; }
		else{ this._parent = document.getElementById(Parent); }
	}
	this._container_id 	= container_id || 'viewerDivM';
	this.type		= "imgviewer";
	//this.childNodes 	= new Array();
	this.built 		= false;
	//this.hasChild		= false;
	this.Xml		= false;
	this.inload		= false;
	this.hidded		= true;
 	this.selected		= false;
 	this.nbImg		= false;
 	this.flyMenu		= false;
 	this.skinedcadre	= true;
 	this.bottomMenu		= true;
}
 
imgviewer.prototype.make = function(){
  	
  	this.Div 			= document.createElement("DIV");
  	this.Div.id			= this._container_id;
  	this.Div.verticalAlign		= "middle";
 	this.Div.align			= "center";
  	
	this.DivC 			= document.createElement("DIV");
	this.DivC.id			= "viewerDivContainer";
	
	if(this.skinedcadre){
		this.DivC.style.top = "0px";
		this.DivC.style.left = "0px";
		this.DivC.style.visibility = "hidden";
		this.DivC.style.position = "absolute";
		this.DivC.style.zIndex = "16";
		
	}else{
		this.DivC.className = "viewerDivContainer";
	}
	this.DivC.verticalAlign		= "top";
	if(document.all){
		this.DivC.onselectstart		= function(){ return false; };
	}
	
	if(this.skinedcadre){
		//--------------------------CREATION DU CADRE---------------------------------------------
		
		this.CmainTable		 	= document.createElement("TABLE");
		this.CmainTable.cellSpacing 	= "0";
		this.CmainTable.cellPadding 	= "0";
		this.CmainTable.border		= "0";
		//this.CmainTable.width		= "100%";
		//this.CmainTable.height		= "100%";
		
		//-------------------TOP--------------------------
		this.CmtR1	= this.CmainTable.insertRow(0);
		
		//CELLULE
		this.CmtTL			= document.createElement("TD");
		this.CmtTL.width		= "12";		
		this.CmtTL.height		= "33";
		this.CmtR1.appendChild(this.CmtTL);
		
		//IMAGE
		this.CmtTLI 			= document.createElement("IMG");
		this.CmtTLI.src 		= "images/viewer/cadre_hg.png";
		this.CmtTL.appendChild(this.CmtTLI);
		
		//CELLULE
		this.CmtTM 			= document.createElement("TD");
		this.CmtTM.height		= "33";
		this.CmtTM.className		= "cadreHaut";
		this.CmtR1.appendChild(this.CmtTM);


		this.CmtTMTable		 	= document.createElement("TABLE");
		this.CmtTMTable.cellSpacing 	= "0";
		this.CmtTMTable.cellPadding 	= "0";
		this.CmtTMTable.border		= "0";
		this.CmtTMTable.width		= "100%";
		
		this.CmdtTMTR1			= this.CmtTMTable.insertRow(0);
		//CELLULE
		this.CmdtTMTL 			= document.createElement("TD");
		this.CmdtTMTL.width		= "61";
		this.CmdtTMTR1.appendChild(this.CmdtTMTL);
		//IMAGE
		this.CmdtTMTLI 	= document.createElement("IMG");
		this.CmdtTMTLI.src = "images/viewer/cadre_title.gif";
		this.CmdtTMTL.appendChild(this.CmdtTMTLI);
		//CELLULE
		this.CmdtTMTR 			= document.createElement("TD");
		this.CmdtTMTR.align		= "right";
		this.CmdtTMTR1.appendChild(this.CmdtTMTR);
		//IMAGE
		this.CmdtTMTRI 			= document.createElement("IMG");
		this.CmdtTMTRI.src 		= "images/viewer/cadre_close_out.gif";
		this.CmdtTMTRI.style.cursor	= "pointer";
		this.CmdtTMTRI.nodeElement	= this;
		this.CmdtTMTRI.onmouseover 	= function(){
		
			this.src = "images/viewer/cadre_close_over.gif";
		};
		this.CmdtTMTRI.onmouseout 	= function(){
		
			this.src = "images/viewer/cadre_close_out.gif";
		};
		this.CmdtTMTRI.onclick 		= function(){
		
			this.nodeElement.hide();
		};
		this.CmdtTMTR.appendChild(this.CmdtTMTRI);
		
		
		this.CmtTM.appendChild(this.CmtTMTable);
		
		//CELLULE
		this.CmtTR			= document.createElement("TD");
		this.CmtTR.height		= "33";
		this.CmtR1.appendChild(this.CmtTR);
		
		//IMAGE
		this.CmtTRI 			= document.createElement("IMG");
		this.CmtTRI.src 		= "images/viewer/cadre_hd.png";
		this.CmtTR.appendChild(this.CmtTRI);
		//-------------------TOP--------------------------
		
		//-------------------MIDDLE-----------------------
		this.CmtR2			= this.CmainTable.insertRow(1);
		
		this.CmtML			= document.createElement("TD");
		this.CmtML.width		= "12";	
		this.CmtML.className		= "cadreLeft";
		this.CmtR2.appendChild(this.CmtML);
		
		this.CmtMM			= document.createElement("TD");
		this.CmtMM.vAlign		= "top";
		this.CmtMM.className		= "cadreBackground";
		this.CmtR2.appendChild(this.CmtMM);
		
		
		this.Img			= document.createElement("IMG");
		this.Img.border			= 0;
		this.Img.nodeElement		= this;
		//this.Img.style.position="absolute";
	
		this.Img.onload 		= function(){ 
		
			this.nodeElement.CmtMM.innerHTML = "";
			this.nodeElement.CmtMM.appendChild(this);
			if(!this.nodeElement.hidded){
				this.style.visibility = "visible";
			}
			
			//this.nodeElement.setInfo();
			this.nodeElement.resize();

		};
		this.Img.oncontextmenu 		= function(){ return false; };
		this.Img.onclick		= function(){ this.nodeElement.hide(); };
		this.CmtMM.appendChild(this.Img);
		
		
		
		this.CmtMR			= document.createElement("TD");
		this.CmtMR.width		= "12";	
		this.CmtMR.className		= "cadreRight",
		this.CmtR2.appendChild(this.CmtMR);
		//-------------------MIDDLE-----------------------
		
		//-------------------BOTTOM1-----------------------
		this.CmtR3			= this.CmainTable.insertRow(2);
		
		this.CmtBL			= document.createElement("TD");
		this.CmtBL.width		= "12";	
		this.CmtBL.height		= "15";	
		this.CmtBL.className		= "cadreBottom1";
		this.CmtR3.appendChild(this.CmtBL);
		
		this.CmtBM			= document.createElement("TD");
		this.CmtBM.height		= "15";	
		this.CmtBM.className		= "cadreBottom1";
		this.CmtR3.appendChild(this.CmtBM);
		
		this.CmtBR			= document.createElement("TD");
		this.CmtBR.height		= "15";	
		this.CmtBR.width		= "12";	
		this.CmtBR.className		= "cadreBottom1";
		this.CmtR3.appendChild(this.CmtBR);
		//-------------------BOTTOM1-----------------------
		
		//-------------------BOTTOM2-----------------------
		this.CmtR4			= this.CmainTable.insertRow(3);
		
		this.CmtBL			= document.createElement("TD");
		this.CmtBL.width		= "12";	
		this.CmtBL.height		= "11";	
		this.CmtR4.appendChild(this.CmtBL);
		
		this.CmtBLI			= document.createElement("IMG");
		this.CmtBLI.src 		= "images/viewer/cadre_bg.png";
		this.CmtBL.appendChild(this.CmtBLI);
		
		this.CmtBM			= document.createElement("TD");
		this.CmtBM.className		= "cadreBottom2";
		this.CmtBM.height		= "11";	
		this.CmtR4.appendChild(this.CmtBM);
		
		this.CmtBR			= document.createElement("TD");
		this.CmtBR.width		= "12";	
		this.CmtBR.height		= "11";	
		this.CmtR4.appendChild(this.CmtBR);
		
		this.CmtBRI			= document.createElement("IMG");
		this.CmtBRI.src 		= "images/viewer/cadre_bd.png";
		this.CmtBR.appendChild(this.CmtBRI);
		//-------------------BOTTOM2-----------------------
		
		
		this.DivC.appendChild(this.CmainTable);
		
		//--------------------------CREATION DU CADRE---------------------------------------------
		
	}else{
	
	
		this.Img			= document.createElement("IMG");
		this.Img.border			= 0;
		this.Img.nodeElement		= this;
		//this.Img.style.position="absolute";
		
		this.Img.onload 		= function(){ 
			
			this.nodeElement.DivC.innerHTML = "";
			this.nodeElement.DivC.appendChild(this);
			if(!this.nodeElement.hidded){
				this.style.visibility = "visible";
			}
			
			//this.nodeElement.resize();
			//this.nodeElement.setInfo();
			this.nodeElement.resize();

		};
		this.Img.oncontextmenu 		= function(){ return false; };		
		this.Img.onclick		= function (){ this.nodeElement.hide(); };
		this.DivC.appendChild(this.Img);
	}

//--------------------------------------BOTTOMMENU---------------------------------------------------------

	if(this.bottomMenu){
	
		this.bmenuDiv			= document.createElement("DIV");
		this.bmenuDiv.id		= "viewerBMenuDiv";
		this.bmenuDiv.nodeElement	= this;
		this.bmenuDiv.show		= function(){
			this.style.visibility = "visible";
		}
		this.bmenuDiv.hide		= function(){
			this.style.visibility = "hidden";
		}
		if(document.all){
			this.bmenuDiv.onselectstart = function(){ return false; };
		}
	
		this.bmenuMT			= document.createElement("TABLE");
		this.bmenuMT.cellSpacing 	= "0";
		this.bmenuMT.cellPadding 	= "0";
		this.bmenuMT.border		= "0";
		this.bmenuMT.width		= "100%";
		this.bmenuMT.height		= "41";
		this.bmenuDiv.appendChild(this.bmenuMT);
		
		this.bmenuMTR1			= this.bmenuMT.insertRow(0);
		
		this.bmenuMTD1			= document.createElement("TD");
		//this.bmenuMTD1.width		= "100";
		if(is_ie7){
			this.bmenuMTD1.background	= "images/viewer/viewer_bg.png";
			this.bmenuMTD1.innerHTML 	= "&nbsp;";
		}
		this.bmenuMTR1.appendChild(this.bmenuMTD1);
		
		if((document.all && !is_ie7) || !document.all){
		
			this.bmenuMTD1I			= document.createElement("IMG");
			//this.bmenuMTD1I.width		= "100";
			this.bmenuMTD1I.height		= "41";
			this.bmenuMTD1I.src		= "images/viewer/viewer_bg.png";
			this.bmenuMTD1.appendChild(this.bmenuMTD1I);
		}
		this.bmenuMTD2			= document.createElement("TD");
		this.bmenuMTD2.width		= "312";
		this.bmenuMTR1.appendChild(this.bmenuMTD2);
		
		//------------------------TABLE MENU--------------------------------------------------
		
		this.bmenuD2T			= document.createElement("TABLE");
		this.bmenuD2T.cellSpacing 	= "0";
		this.bmenuD2T.cellPadding 	= "0";
		this.bmenuD2T.border		= "0";
		this.bmenuD2T.width		= "100%";
		this.bmenuD2T.height		= "41";
		this.bmenuMTD2.appendChild(this.bmenuD2T);
		
		this.bmenuD2TR1 		= this.bmenuD2T.insertRow(0);
		
		this.bmenuD2TD1			= document.createElement("TD");
		this.bmenuD2TD1.width		= "121";
		this.bmenuD2TD1.nodeElement	= this;
		this.bmenuD2TD1.style.position = "relative";
		this.bmenuD2TD1.onmouseover	= function(){
		
			this.nodeElement.bmenuD2TD1I.src		= "images/viewer/viewer_bgprevious_over.gif";
			this.nodeElement.bmenuD2TD1D.className		= "cadreTextFocus";
		};
		this.bmenuD2TD1.onmouseout	= function(){
		
			this.nodeElement.bmenuD2TD1I.src		= "images/viewer/viewer_bgprevious_out.png";
			this.nodeElement.bmenuD2TD1D.className		= "cadreTextBlur";
		};
		this.bmenuD2TD1.onclick	= function(){
		
			this.nodeElement.prevImg();
		};
		this.bmenuD2TR1.appendChild(this.bmenuD2TD1);
		
		this.bmenuD2TD1I		= document.createElement("IMG");
		this.bmenuD2TD1I.width		= "121";
		this.bmenuD2TD1I.height		= "41";
		this.bmenuD2TD1I.vAlign		= "top";
		this.bmenuD2TD1I.nodeElement	= this;
		this.bmenuD2TD1I.style.position = "absolute";
		this.bmenuD2TD1I.style.top	= "0";
		this.bmenuD2TD1I.style.cursor	= "pointer";
		this.bmenuD2TD1I.src		= "images/viewer/viewer_bgprevious_out.png";		
		this.bmenuD2TD1.appendChild(this.bmenuD2TD1I);
				
		this.bmenuD2TD1D		= document.createElement("DIV");
		this.bmenuD2TD1D.className	= "cadreTextBlur";
		if(document.all){this.bmenuD2TD1D.style.top="9px"; }
		this.bmenuD2TD1D.innerHTML	= "Previous";
		this.bmenuD2TD1.appendChild(this.bmenuD2TD1D);
		
		this.bmenuD2TD2			= document.createElement("TD");
		this.bmenuD2TD2.width		= "70";
		this.bmenuD2TD2.height		= "41";
		if(is_ie7){
			this.bmenuD2TD2.background	= "images/viewer/viewer_bg.png";
		}
		this.bmenuD2TR1.appendChild(this.bmenuD2TD2);
		
		if((document.all && !is_ie7) || !document.all){
			this.bmenuD2TD2I		= document.createElement("IMG");
			this.bmenuD2TD2I.width		= "70";
			this.bmenuD2TD2I.height		= "41";
			this.bmenuD2TD2I.style.position = "absolute";
			this.bmenuD2TD2I.style.top	= "0";
			this.bmenuD2TD2.appendChild(this.bmenuD2TD2I);
			this.bmenuD2TD2I.src		= "images/viewer/viewer_bg.png";
		}
		
		this.bmenuD2TD2D		= document.createElement("DIV");
		this.bmenuD2TD2D.className	= "cadreTextCentre";
		//if(document.all){this.bmenuD2TD2D.style.top="8px"; }
		this.bmenuD2TD2D.width		= "70";
		this.bmenuD2TD2D.align		= "center";
		//this.bmenuD2TD2D.innerHTML	= "Next";
		this.bmenuD2TD2.appendChild(this.bmenuD2TD2D);
		
		this.bmenuD2TD3			= document.createElement("TD");
		this.bmenuD2TD3.width		= "121";
		this.bmenuD2TD3.nodeElement	= this;
		this.bmenuD2TD3.onmouseover	= function(){
		
			this.nodeElement.bmenuD2TD3I.src		= "images/viewer/viewer_bgnext_over.gif";
			this.nodeElement.bmenuD3TD3D.className		= "cadreTextFocus";
		};
		this.bmenuD2TD3.onmouseout	= function(){
		
			this.nodeElement.bmenuD2TD3I.src		= "images/viewer/viewer_bgnext_out.png";
			this.nodeElement.bmenuD3TD3D.className		= "cadreTextBlur";
		};
		this.bmenuD2TD3.onclick	= function(){
		
			this.nodeElement.nextImg();
		};
		this.bmenuD2TR1.appendChild(this.bmenuD2TD3);
		
		this.bmenuD2TD3I		= document.createElement("IMG");
		this.bmenuD2TD3I.width		= "121";
		this.bmenuD2TD3I.height		= "41";
		this.bmenuD2TD3I.nodeElement	= this;
		this.bmenuD2TD3I.style.position = "absolute";
		this.bmenuD2TD3I.style.top	= "0";
		this.bmenuD2TD3I.style.cursor	= "pointer";
		this.bmenuD2TD3I.src		= "images/viewer/viewer_bgnext_out.png";
		this.bmenuD2TD3.appendChild(this.bmenuD2TD3I);
		
		this.bmenuD3TD3D		= document.createElement("DIV");
		this.bmenuD3TD3D.className	= "cadreTextBlur";
		//if(document.all){this.bmenuD3TD3D.style.top="-3px"; }
		this.bmenuD3TD3D.innerHTML	= "Next";
		this.bmenuD2TD3.appendChild(this.bmenuD3TD3D);
		
		//------------------------TABLE MENU--------------------------------------------------
		
		this.bmenuMTD3			= document.createElement("TD");
		//this.bmenuMTD3.width		= "100";
		if(is_ie7){
			this.bmenuMTD3.background	= "images/viewer/viewer_bg.png";
			this.bmenuMTD3.innerHTML 	= "&nbsp;";
		}
		this.bmenuMTR1.appendChild(this.bmenuMTD3);
		
		if((document.all && !is_ie7) || !document.all){
			this.bmenuMTD3I			= document.createElement("IMG");
			//this.bmenuMTD1I.width		= "100";
			this.bmenuMTD3I.height		= "41";
			this.bmenuMTD3I.style.position	= "relative";
			this.bmenuMTD3I.src		= "images/viewer/viewer_bg.png";
			this.bmenuMTD3.appendChild(this.bmenuMTD3I);
		}
		this.bmenuDiv.appendChild(this.bmenuMT);
		
		//-----------------------TABLE CLOSE------------------------------------------------
		this.bmenuMTD4			= document.createElement("TD");
		this.bmenuMTD4.width		= "100";
		this.bmenuMTD4.style.cursor	= "pointer";
		

		this.bmenuMTR1.appendChild(this.bmenuMTD4);
		
		if((document.all && !is_ie7) || !document.all){
			this.bmenuMTD4I		= document.createElement("IMG");
			this.bmenuMTD4I.width		= "100";
			this.bmenuMTD4I.height		= "41";
			this.bmenuMTD4I.style.position = "absolute";
			this.bmenuMTD4I.style.top	= "0";
			this.bmenuMTD4.appendChild(this.bmenuMTD4I);
			this.bmenuMTD4I.src		= "images/viewer/viewer_bg.png";

		}else{
		
			this.bmenuMTD4.background	= "images/viewer/viewer_bg.png";
		}
		
		this.bmenuMTD4T			= document.createElement("TABLE");
		this.bmenuMTD4T.cellSpacing 	= "0";
		this.bmenuMTD4T.cellPadding 	= "0";
		this.bmenuMTD4T.border		= "0";
		this.bmenuMTD4T.nodeElement	= this;
		this.bmenuMTD4T.style.position	= "relative";
		this.bmenuMTD4T.width		= "100%";
		this.bmenuMTD4T.height		= "41";
		this.bmenuMTD4T.onmouseover	= function(){
			this.nodeElement.bmenuMTD4D.className	= "cadreTextFocus";
			this.nodeElement.bmenuMTD4CI.src = "images/viewer/viewer_bgclose_over.png";
		};
		this.bmenuMTD4T.onmouseout	= function(){
			this.nodeElement.bmenuMTD4D.className	= "cadreTextBlur";
			this.nodeElement.bmenuMTD4CI.src = "images/viewer/viewer_bgclose_out.png";
		};
		this.bmenuMTD4T.onclick		= function(){
		
			this.nodeElement.hide();
			return true;
		};
		this.bmenuMTD4.appendChild(this.bmenuMTD4T);
		
		this.bmenuMTD4TR1		= this.bmenuMTD4T.insertRow(0);
		
		this.bmenuMTD4TD1		= document.createElement("TD");
		this.bmenuMTD4TD1.width		= "70";
		this.bmenuMTD4TR1.appendChild(this.bmenuMTD4TD1);
		
		this.bmenuMTD4D			= document.createElement("DIV");
		this.bmenuMTD4D.className	= "cadreTextBlur";
		//if(document.all){this.bmenuMTD4D.style.top="-3px"; }
		this.bmenuMTD4D.style.left	="10px";
		//this.bmenuMTD4D.style.width	="100px";
		this.bmenuMTD4D.innerHTML	= "Close";
		this.bmenuMTD4TD1.appendChild(this.bmenuMTD4D);
		
		this.bmenuMTD4TD2		= document.createElement("TD");
		this.bmenuMTD4TD2.align		= "left";
		this.bmenuMTD4TD2.vAlign	= "top";
		this.bmenuMTD4TR1.appendChild(this.bmenuMTD4TD2);
		
		this.bmenuMTD4CI		= document.createElement("IMG");
		this.bmenuMTD4CI.width		= "20";
		this.bmenuMTD4CI.height		= "41";
		//this.bmenuMTD4CI.style.position = "relative";
		//this.bmenuMTD4CI.style.top	= "0";
		//this.bmenuMTD4CI.style.left	= "100";
		this.bmenuMTD4TD2.appendChild(this.bmenuMTD4CI);
		this.bmenuMTD4CI.src		= "images/viewer/viewer_bgclose_out.png";



		//this.bmenuDiv.appendChild(this.bmenuMT);
		//-----------------------TABLE CLOSE------------------------------------------------
	
	}



//--------------------------------------BOTTOMMENU---------------------------------------------------------


	if(this.flyMenu){
//--------------------------------------FLYMENU---------------------------------------------------------
	
	//----------------menu backgroung------------------------

	this.menuDiv			= document.createElement("DIV");
	this.menuDiv.id			= "viewerMenuDiv";
	//this.menuDiv.innerHTML		= "[X] - Fermer";
	this.menuDiv.nodeElement	= this;
	if(document.all){
		this.menuDiv.onselectstart = function(){ return false; };
	}
	//this.menuDiv.onclick		= function(){ this.nodeElement.hide(); };
	

	this.menuBg			= document.createElement("IMG");
	this.menuBg.src			= "images/viewer/menu_bg.gif";
	this.menuDiv.appendChild(this.menuBg);

	//----------------menucontainer--------------------------
	this.menuContainer		= document.createElement("DIV");
	this.menuContainer.id		= "viewerMenuContainer";
	this.menuContainer.nodeElement	= this;
	this.menuDiv.appendChild(this.menuContainer);

	//----------------dragbar--------------------------------
	this.menuCdragbar		= document.createElement("DIV");
	this.menuCdragbar.id		= "viewerMenuCdrag";
	this.menuCdragbar.nodeElement	= this;
	this.menuDiv.appendChild(this.menuCdragbar);
	
	//---evenements----dragbar--------------------------------
	addeventHandler(this.menuCdragbar);
	this.menuCdragbar.addMouseDown(mousedowndrag);
	this.menuCdragbar.addMouseMove(mousemovedrag);
	this.menuCdragbar.addMouseUp(mouseupdrag);
	
	//---------------SUIVANT/PRECENT--------------------------
	this.menuPrec			= document.createElement("IMG");
	this.menuPrec.id		= "viewerMenuPrec";
	this.menuPrec.src		= "images/viewer/prec_out.gif";
	this.menuPrec.nodeElement	= this;
	this.menuPrec.alt		= "Previous";
	this.menuPrec.onclick		= function (){ this.nodeElement.prevImg(); };
	this.menuPrec.onmouseover	= function(){
		this.src = "images/viewer/prec_over.gif";
	};
	this.menuPrec.onmouseout	= function(){
		this.src = "images/viewer/prec_out.gif";
	};
	this.menuDiv.appendChild(this.menuPrec);
	
	this.menuSuiv			= document.createElement("IMG");
	this.menuSuiv.id		= "viewerMenuSuiv";
	this.menuSuiv.src		= "images/viewer/suiv_out.gif";
	this.menuSuiv.nodeElement	= this;
	this.menuSuiv.alt		= "Next";
	this.menuSuiv.onclick		= function (){ this.nodeElement.nextImg(); };
	this.menuSuiv.onmouseover	= function(){
		this.src = "images/viewer/suiv_over.gif";
	};
	this.menuSuiv.onmouseout	= function(){
		this.src = "images/viewer/suiv_out.gif";
	};
	this.menuDiv.appendChild(this.menuSuiv);
	
	//----------------CLOSE----------------------------------
	this.menuClose			= document.createElement("IMG");
	this.menuClose.id		= "viewerMenuClose";
	this.menuClose.src		= "images/viewer/close_out.gif";
	this.menuClose.nodeElement	= this;
	this.menuClose.onclick		= function (){ this.nodeElement.hide(); };
	this.menuClose.onmouseover	= function(){
		this.src = "images/viewer/close_over.gif";
	};
	this.menuClose.onmouseout	= function(){
		this.src = "images/viewer/close_out.gif";
	};
	this.menuDiv.appendChild(this.menuClose);

	//----------------DOCK-----------------------------------
	this.menuDock			= document.createElement("IMG");
	this.menuDock.id		= "viewerMenuDock";
	this.menuDock.src		= "images/viewer/dock_out.gif";
	this.menuDock.nodeElement	= this;
	//this.menuDock.onclick		= function (){ this.nodeElement.hide(); };
	this.menuDock.onmouseover	= function(){
		this.src = "images/viewer/dock_over.gif";
	};
	this.menuDock.onmouseout	= function(){
		this.src = "images/viewer/dock_out.gif";
	};
	this.menuDiv.appendChild(this.menuDock);


	//---------------separateur------------------------------
	this.menuSep1			= document.createElement("IMG");
	this.menuSep1.className		= "viewerMenuSeparateur";
	this.menuSep1.style.top		= "103px";
	this.menuSep1.src		= "images/viewer/separation.gif";
	this.menuDiv.appendChild(this.menuSep1);
	
	this.menuSep2			= document.createElement("IMG");
	this.menuSep2.className		= "viewerMenuSeparateur";
	this.menuSep2.style.top		= "123px";
	this.menuSep2.src		= "images/viewer/separation.gif";
	this.menuDiv.appendChild(this.menuSep2);
	
	this.menuSep3			= document.createElement("IMG");
	this.menuSep3.className		= "viewerMenuSeparateur";
	this.menuSep3.style.top		= "143px";
	this.menuSep3.src		= "images/viewer/separation.gif";
	this.menuDiv.appendChild(this.menuSep3);
	
	this.menuSep4			= document.createElement("IMG");
	this.menuSep4.className		= "viewerMenuSeparateur";
	this.menuSep4.style.top		= "163px";
	this.menuSep4.src		= "images/viewer/separation.gif";
	this.menuDiv.appendChild(this.menuSep4);
	
	//--------------puces------------------------------------
	this.menuPuce1			= document.createElement("IMG");
	this.menuPuce1.className	= "viewerMenuPuce";
	this.menuPuce1.style.top	= "111px";
	this.menuPuce1.src		= "images/viewer/puce.gif";
	this.menuDiv.appendChild(this.menuPuce1);
	
	this.menuPuce2			= document.createElement("IMG");
	this.menuPuce2.className	= "viewerMenuPuce";
	this.menuPuce2.style.top	= "131px";
	this.menuPuce2.src		= "images/viewer/puce.gif";
	this.menuDiv.appendChild(this.menuPuce2);
	
	this.menuPuce3			= document.createElement("IMG");
	this.menuPuce3.className	= "viewerMenuPuce";
	this.menuPuce3.style.top	= "151px";
	this.menuPuce3.src		= "images/viewer/puce.gif";
	this.menuDiv.appendChild(this.menuPuce3);
	
	//-------------NOM---------------------------------------
	this.menuTName			= document.createElement("DIV");
	this.menuTName.className	= "viewerMenuText";
	this.menuTName.innerHTML	= "&nbsp;";
	this.menuTName.style.top	= "105px";
	this.menuDiv.appendChild(this.menuTName);
	
	//-------------Taille---------------------------------------
	this.menuTTaille			= document.createElement("DIV");
	this.menuTTaille.className	= "viewerMenuText";
	this.menuTTaille.innerHTML	= "&nbsp;";
	this.menuTTaille.style.top	= "125px";
	this.menuDiv.appendChild(this.menuTTaille);
	
	//-------------Poids---------------------------------------
	this.menuTPoids			= document.createElement("DIV");
	this.menuTPoids.className	= "viewerMenuText";
	this.menuTPoids.innerHTML	= "&nbsp;";
	this.menuTPoids.style.top	= "145px";
	this.menuDiv.appendChild(this.menuTPoids);
	
 //--------------------------------------FLYMENU---------------------------------------------------------
 	}
 	
 	
  	this._parent.appendChild(this.Div);
  	this._parent.appendChild(this.DivC);
  	if(this.flyMenu){ this._parent.appendChild(this.menuDiv); }
  	if(this.bottomMenu){ this._parent.appendChild(this.bmenuDiv); }
};

imgviewer.prototype.hide = function(){

	if(!this.hidded){

		var Obj 		= document.getElementById('divContainer');
		Obj.style.height	= '';
		if(document.all){
			Obj.style.overflowY 	= '';
		}
		document.body.style.overflowY = "";
		this.Img.src = null;

		this.Div.style.visibility = "hidden";
		this.DivC.style.visibility = "hidden";
		this.Img.style.visibility = "hidden";
		if(this.flyMenu){
			this.menuDiv.style.visibility = "hidden";
		}
		if(this.bottomMenu){
			this.bmenuDiv.hide();
		}
		this.hidded = true;
	}
};

imgviewer.prototype.show = function(){
	
	if(this.hidded){
	
		var Obj 		= document.getElementById('divContainer')
		if(document.all){
			Obj.style.overflow 	= 'hidden';
			document.body.style.overflowY = "hidden";
		}
		if(document.all){
			var decal = 0;
		}else{
			var decal = 2;
		}
		Obj.style.height	= (Obj.offsetHeight-decal)+"px";
	
		this.Div.style.visibility = "visible";
		this.DivC.style.visibility = "visible";
		
		if(this.flyMenu){
			this.menu
		}
		if(this.bottomMenu){
			this.bmenuDiv.show();
		}
		this.hidded = false;
		this.resize();
		
	}
};
/*
 imgviewer.prototype.reset = function(){

 	if(this.built){
		this._parent.removeChild(this.Div);
		this._parent.removeChild(this.DivC);
		this._parent.removeChild(this.closeDiv);
		this.Div = null;
		this.DivC = null;
		this.closeDiv = null;
		this.make();
 	}
 	this.built = false;
 };
*/

imgviewer.prototype.clearContent = function(){

 	if(this.built){
		this.Img.style.visibility = "hidden";
		this.Img.src = null;
 	}
 	this.Xml = false;
 	this.built = false;
};
 
imgviewer.prototype.setContent = function(Xml, Selected){
 
	//if(!this.inload){ return false; }else{ this.inload = false; };
	
	this.clearContent();
	
	this.Xml 	= Xml.getElementsByTagName("viewer")[0];
	this._XmlParent	= Xml;
	this._caption	= this.Xml.getAttribute("pagetitle");
	this._imgfolder	= this.Xml.getAttribute("imgfolder");
	this.nbImg	= Xml.getElementsByTagName("image").length;
	if(arguments.length > 1){ 
		this.setImg(Selected); 
	} 
	this.built 	= true;
	this.setimgnbInfo();
	//if(this.hidded){
	//	this.show();
		//this.resize();
	//}
	return true;
};

imgviewer.prototype.refreshImg = function(){

	this.setImg(this.selected);
};

imgviewer.prototype.setImg = function(Id){
 	
 	if(this.Xml){
 	
 		var mainDiv = document.getElementById('divContainer');
 		this.selected = Id;
 		
		var flashLoad 	= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100" height="100">';
		flashLoad	+= '<param name="movie" value="images/viewer/loading.swf" />';
		flashLoad	+= '<param name="quality" value="high" />';
		flashLoad	+= '<param name="wmode" value="transparent" />';
		flashLoad	+= '<embed src="images/viewer/loading.swf" width="100" height="100" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>';
		flashLoad	+= '</object>';
		
		if(this.skinedcadre){
			//this.CmtMM.removeChild(this.Img);
			//mainDiv.appendChild(this.CmtMM.removeChild(this.Img));
			//this.CmtMM.innerHTML = "";
			this.CmtMM.innerHTML = flashLoad;

		}else{
			//mainDiv.appendChild(this.DivC.removeChild(this.Img));
			this.DivC.innerHTML = flashLoad;
		}
		
 		var Element = this.Xml.getElementsByTagName("image")[Id];
 		if(this.flyMenu){
 			this.menuTName.innerHTML = "Loading image...";
 			this.menuTTaille.innerHTML = "";
 			this.menuTPoids.innerHTML = "";
 		}

		this.Img.src = "pages/resize.php?width="+(eval(mainDiv.offsetWidth) - 40)+"&height="+(eval(mainDiv.offsetHeight) - 80)+"&name="+this._imgfolder+Element.getElementsByTagName("source")[0].firstChild.nodeValue;

 		this.setimgnbInfo();
		this.resize();
		if(this.hidded){
			this.show();
		}
		
 	}
};

imgviewer.prototype.setInfo = function(Id){

	var Current = Id || this.selected;
	if(this.Xml){
	
 		var Element = this.Xml.getElementsByTagName("image")[Current];
 		if(this.flyMenu){
 			this.menuTName.innerHTML = Element.getElementsByTagName("title")[0].childNodes[0].nodeValue;
 			this.menuTTaille.innerHTML = Element.getElementsByTagName("width")[0].childNodes[0].nodeValue+' x '+Element.getElementsByTagName("height")[0].childNodes[0].nodeValue+' px';
 			this.menuTPoids.innerHTML = Element.getElementsByTagName("poids")[0].childNodes[0].nodeValue;
 		}
	}
};

imgviewer.prototype.resize = function(){

		var Obj 		= document.getElementById('divContainer');
		if(!this.hidded){
			
			Obj.style.overflow 	= 'hidden';
			Obj.style.height	= "100%";
		}
		if(this.skinedcadre){
			var Element = this.CmainTable;
		}else{
			var Element = this.Img;
		}

		
		//var Element = this.Xml.getElementsByTagName("image")[this.selected];
		//this.Img.src = "actions/resize.php?width="+(eval(Obj.offsetWidth) - 40)+"&height="+(eval(Obj.offsetHeight) - 80)+"&name="+this._imgfolder+Element.getElementsByTagName("source")[0].firstChild.nodeValue;
 		
		var Dec = 0;
		if(this.bottomMenu){
			Dec = 20;
			this.bmenuDiv.style.top = eval(Obj.offsetHeight)-eval(this.bmenuDiv.offsetHeight)-1+"px";
			
			var BMtdSize = (eval(Obj.offsetWidth)-eval(this.bmenuMTD2.width))/2;
			if(!is_ie7){
				this.bmenuMTD1I.width = BMtdSize;
				this.bmenuMTD3I.width = BMtdSize-eval(this.bmenuMTD4.offsetWidth);
			}else{
				//this.bmenuMTD1.width = BMtdSize;
			}
		}
		this.DivC.style.width = eval(Element.offsetWidth)+"px";
		this.DivC.style.height = eval(Element.offsetHeight)+"px";
		this.DivC.style.top = (eval(Obj.offsetHeight)/2)-(eval(this.DivC.offsetHeight)/2)-Dec+"px";
		this.DivC.style.left = (eval(Obj.offsetWidth)/2)-(eval(this.DivC.offsetWidth)/2)+"px";
		
		//alert((eval(Obj.offsetHeight)/2)-(eval(this.DivC.offsetHeight)/2)-Dec+"px");

};

imgviewer.prototype.setimgnbInfo = function(){

	if(this.bottomMenu){
	
		this.bmenuD2TD2D.innerHTML = (this.selected+1)+" / "+this.nbImg;
	}
};

imgviewer.prototype.nextImg = function(){
	
 	if(this.Xml){
 		if(this.selected+1 >= this.nbImg){
 		 	this.selected = 0;
 		 	this.setImg(this.selected);
 		}else{
 			this.selected++;
 			this.setImg(this.selected);
 		}
 		this.setimgnbInfo();
 	}
};

imgviewer.prototype.prevImg = function(){
	
 	if(this.Xml){
 		if(this.selected <= 0){
			this.selected = this.nbImg-1;
 			this.setImg(this.selected);
 		}else{
 			this.selected--;
 			this.setImg(this.selected);
 		}
 		this.setimgnbInfo();
 	}
};


document.setviewerContent = function(Id){
	if(document.imgViewer){
		document.imgViewer.setImg(Id);
	}
};

window.onresize = function(){

	if((document.imgViewer || imgViewer) && !document.imgViewer.hidded){
		document.imgViewer.refreshImg();
}
};