/*-*-*-*-*-*-*-*-*-*-*-*-*-*-* AUTEUR: Matthieu Beunon    *-*-//-*-* SOCIETE : CYBER STUDIO            *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-* DATE DE CREATION: 02/11/00 *-*-//-*-* DERNIERE MISE A JOUR : 20/04/2000 version1.02 *-*-*-*-*-*-*-*-*-*/

/***************************************************************************/
/** DETECTION DU CLIENT ****************************************************/
function detection() {
     var nav = navigator.appName;
     var vers = navigator.appVersion;
     if (nav=="Microsoft Internet Explorer") this.nav = "ie";
     else if (nav=="Netscape") this.nav = "ns";
     else this.nav = nav;
     this.version = parseInt(vers);
     this.mac = (navigator.userAgent.indexOf("Mac")!=-1) ||(navigator.userAgent.indexOf("Macintosh")!=-1);
     this.win = (navigator.userAgent.indexOf("Windows")!=-1) ||(navigator.userAgent.indexOf("Win")!=-1);
     this.ie = (this.nav == "ie" && this.version >= 4);
     this.ie4 = (vers.indexOf('MSIE 4')>0);
     this.ie5 = (vers.indexOf('MSIE 5')>0);
     this.ns = (this.nav == "ns" && this.version >= 4);
     this.ns4 = (this.nav == "ns" && this.version == 4);
     this.ns6 = (this.nav == "ns" && this.version == 5);
     this.gen4 = (this.ie || this.ns);
}
estce = new detection();

/*******************************************************************************************************************/
/********************************************* FONCTIONS COMMUNES **************************************************/
/*******************************************************************************************************************/

/***********************************/
function precharge(iObj,iSrc) {
	if (document.images) {
		eval(iObj+' = new Image()');
		eval(iObj+'.src = "'+iSrc+'"');}
}
/***********************************/
function CCCalque(calque,cparent,contenu) {			
	if(estce.ns6)document.getElementById(calque).innerHTML = contenu;
	else if (estce.ns4){
		var objet = (cparent)? eval('document.'+cparent+'.document.'+calque+'.document') : document.layers[calque].document;
		objet.open();
		objet.write(contenu);
		objet.close();
	}
	else if (estce.ie) document.all[calque].innerHTML = contenu;
}
/***********************************/
function roll(nom,calque,iObj) {
	if (document.images){
	   if (estce.ns4 && calque!=null) eval('document.layers["'+calque+'"].document.images["'+nom+'"].src = '+iObj+'.src'); 	 
	   else document.images[nom].src = eval(iObj+".src");
	}
}
/***********************************/
function longueur(calque){
	var yPos;
	if(estce.ns6)yPos = document.getElementById(calque).style.height;
	else if(estce.ns)yPos = document.layers[calque].document.height;
	else if(estce.ie)yPos = document.all[calque].offsetHeight;
	return yPos;
}
/***********************************/
function largeur(calque){
	var xPos;
	if(estce.ns6)xPos = document.getElementById(calque).style.width;
	else if(estce.ns)xPos = document.layers[calque].document.width;
	else if(estce.ie)xPos = document.all[calque].offsetWidth;
	return xPos;
}
/***********************************/
function cssDiv(nom,top,left,zindex,vis){
	var v = (vis)? "visible" : "hidden";
	sty='#'+nom+'{position:absolute; top:'+top+'px; left:'+left+'px; z-index:'+zindex+'; visibility:'+v+';}\n';
	return sty;
}
/***********************************/
function cssDiv1(nom,top,left,width,height,zindex){
	sty='#'+nom+'{position:absolute; top:'+top+'px; left:'+left+'px; width:'+width+'px; height:'+height+'px; z-index:'+zindex+'; visibility:hidden;}\n';
	return sty;
}
/***********************************/
function cssDiv2(nom,top,left,width,height,BG,zindex){
	var CDM = "";
	var CDM2 = "";
	if(estce.ns){ 
		 CDM = "layer-";
		 CDM2 = ";layer-background-color:"+BG;
	}
	sty='#'+nom+'{position:absolute; top:'+top+'px; left:'+left+'px; width:'+width+'px; height:'+height+'px; '+CDM+'background:'+BG+CDM2+';z-index:'+zindex+'; visibility:hidden}\n';
	return sty;
}
/***********************************/
function openWindow(url,nom,large,haut)
{	
	var posX = parseInt((screen.availWidth-large)/2)-20;
	var posY = parseInt((screen.availHeight-haut)/2);	
	var MinWin, winOpts="width="+large+",height="+haut+",scrollbars=0,left="+posX+",top="+posY+",menubar=0,toolbar=0";
	MinWin = window.open(url, nom, winOpts);
	if (navigator.appVersion.indexOf("(X11") != -1 || navigator.appVersion.indexOf("(Mac") != -1)
	   MinWin = window.open(url, nom, winOpts);
	if (navigator.appName == "Netscape" && (parseInt(navigator.appVersion) >=3 ))
	   MinWin.focus();
}
/***********************************/
function navSelect(nameForm,nameSelect)
{
    var oForm = document.forms[nameForm];
    var oSelect = oForm.elements[nameSelect];
    var iSelect = oSelect.selectedIndex;
    var url = oSelect.options[iSelect].value;
    if (url != "") window.location = url;
}		   


/*******************************************************************************************************************/
/********************************************** CLASS CALQUE *******************************************************/
/*******************************************************************************************************************/
var ID_CALQUE = 0;

function Calque(nom,cparent,cparent2) {		
	ID_CALQUE++;
	if(estce.ie)
	{
		 this.doc = document;
		 this.cal = document.all[nom]; 
		 this.css = this.cal.style;
 		 this.h = this.cal.offsetHeight;
		 this.w = this.cal.offsetWidth;
		 this.x = this.css.pixelLeft;
		 this.y = this.css.pixelTop;
	}
    else if(estce.ns)
	{
   		 if(estce.ns4)
		 {
		  	  if (!cparent)cparent='';
			  else cparent='document.'+cparent+'.';
			  if (cparent2)cparent='document.'+cparent2+'.'+cparent;
		  	  this.css=eval(cparent+"document.layers." +nom);						
			  this.cal=this.css;
			  //this.doc = this.css.document;
		 }
         else if(estce.ns6)
		 {
			  this.doc = this.document;
			  this.cal = document.getElementById(nom);
			  this.css = this.cal.style;
		 } 		 
		 this.x = parseInt(this.css.left);
		 this.y = parseInt(this.css.top);
	}
	this.z = this.css.zIndex;
	this.cparent = cparent;
	this.nom = nom;
	this.objet = nom + "Calque";
	this.nom = nom.substring(0,nom.length-3);
	this.div = nom;
	this.id = ID_CALQUE;
	eval (this.objet + "=this");
}

/** IMPLEMENTATION méthodes **/
function methode_bougerA(x,y)  {this.x=x; this.y=y; this.css.left=this.x;this.css.T=this.y;}
function methode_bougerDe(x,y) {this.bougerA(this.x+x,this.y+y);}
function methode_montrer() {this.css.visibility = (estce.ns4)? "show" : "visible";}
function methode_cacher()  {this.css.visibility = (estce.ns4)? "hide" : "hidden";}
function methode_getLeft() {var l = (estce.ns)? parseInt(this.css.left) : this.css.pixelLeft;return l;}
function methode_getTop()  {var t = (estce.ns)? parseInt(this.css.left) : this.css.pixelLeft;return t;}	

/** PROTOTYPE métodes **/
Calque.prototype.montrer = methode_montrer;
Calque.prototype.cacher = methode_cacher;
Calque.prototype.bougerA = methode_bougerA;
Calque.prototype.bougerDe = methode_bougerDe;
Calque.prototype.getLeft = methode_getLeft;
Calque.prototype.getTop = methode_getTop;



/*******************************************************************************************************************/
/********************************************** GESTION EVENT ******************************************************/
/*******************************************************************************************************************/

/** CAPTURE EVENT **/
function DocEvent(){ document.onmousedown = mouseDown;document.onmousemove = mouseMove;document.onmouseup = mouseUp;if (estce.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);}

/** CAPTURE COORDONNEES **/
function getX(e) {X=(estce.ns)? e.pageX : event.x;return X;}
function getY(e) {Y=(estce.ns)? e.pageY : event.y;return Y;}
function getYdoc(e) {var Y=(estce.ns)? e.pageY : event.y+document.body.scrollT;return Y;}
function getXdoc(e) {var X=(estce.ns)? e.pageX : event.x+document.body.scrollLeft;return X;}

/***********************************/
function getWidth(){
	if(estce.ns) return window.innerWidth;
	else if(estce.ie) return document.body.clientWidth;
}
/***********************************/
function getHeight(){
	if(estce.ns) return window.innerHeight;
	else if(estce.ie) return document.body.clientHeight;
}


/*******************************************************************************************************************/
/************************************************* EDF VISA ********************************************************/
/*******************************************************************************************************************/

/*****************************/
function createImgObject(src){
	var img = new Image();
	img.src = src;
}
/*****************************/
function pix(width){
	width -= (estce.ns4)? 2 : ((estce.ns6)? 0 : 0);
	document.write('<IMG SRC="img/pix.gif" WIDTH="'+width+'" HEIGHT="1" BORDER="0">');
}
/*****************************/
function centrerAll(){
	var pos = (getWidth()-760)/2.0;
	pos -=(estce.ns4)? 1 : ((estce.ns6)? 0: 0);
	for(i=0;i<allCal.length;i++){
		var p = xPosTab[i]+pos;
		if(scrollingBar)p-=8
		if(home) p-=14		
		allCal[i].bougerA(p);
	}	
}
/*function centrerAll(){
	tmpTable=allCal
	for(j=0;j<allsousCal.length;j++)
	{
	tmpTable[tmpTable.length]=allsousCal[j];
	}
	var pos = (getWidth()-760)/2.0;
	pos -=(estce.ns4)? 1 : ((estce.ns6)? 0: 0);
	for(i=0;i<tmpTable.length;i++){
		if(i>xPosTab.length-1)
		var p = 0
		else
		var p = xPosTab[i]+pos;
		if(scrollingBar)p-=8
		if(home) p-=14		
		tmpTable[i].bougerA(p);
	}	
}*/
/*****************************/
function recentrer(value){
	var pos = (getWidth()-760)/2.0;	
	pos -=(estce.ns4)? 1 : ((estce.ns6)? 0: 0);
	var p = value+pos;
	if(scrollingBar)p-=8	
  	return Math.round(p);
}	
/*****************************/
function scrollNS(){
	if(estce.ns4){
		var h = document.layers.texteCal.document.height+42;
		if(h>=getHeight())isHtpage = true;
		pix(h);
	}
	else if(estce.ie){		
		var h = document.all["texteCal"].offsetHeight+39;
		if(h>=getHeight())isHtpage = true;
	}
	else if(estce.ns6)isHtpage = true;
}	
/*****************************/
function montrerAll(){
	for(i=0;i<allCal.length;i++)allCal[i].montrer();
}
/*****************************/
function montrerAllExcept(cal){
	for(i=0;i<allCal.length;i++){
		if(allCal[i]!=cal)allCal[i].montrer();
	}
}
/*****************************/
function cacherAll(){
	for(i=0;i<allCal.length;i++)allCal[i].cacher();	
}
/*****************************/
function writePhoto(width,height){
	var w = width-20-5;
	var h = height+16;
	if(w<=0)w=1;
	if(h<=0)h=1;
	document.write('<IMG SRC="img/pix.gif" BORDER=0 WIDTH='+w+' HEIGHT='+h+'>');
}
/*****************************/
function isResizable(){
	if(estce.ns4){
		if(window.innerHeight<433)scrollingBar = true;
		if(window.innerWidth<796)return true;
	}
	return false;
}
/*****************************/
function resizeNS(){
	window.moveTo(0,0);
	window.resizeTo(796,426);
	history.go(0);
}


/*******************************************************************************************************************/
/********************************************** INIT GENERALE ******************************************************/
/*******************************************************************************************************************/

function montrerAllContenu(){
	if (allsousCal) {
	for(i=0;i<allsousCal.length;i++)allsousCal[i].montrer();
	}
}

function resizeNS2()
{
flag=false
	if(estce.ns4||estce.ie4){
		if(window.innerWidth<796)flag= true;
		if(!flag)
			history.go(0);
	}
}

var monboolvisible=false
	function affichemenu()
	{
	if(monboolvisible)
		menucontext.cacher()
	else
		menucontext.montrer()
	monboolvisible=!monboolvisible
}

function changetaille()
{
resizeNS2();
cacherAll();
init();	
}

function WidthChange()
{
	if(lastwidth!=getWidth())
		changetaille()
	else
		setTimeout("WidthChange()",10)
}

var lastwidth

function initIE4Mac(){
if(estce.mac&&estce.ie4)
{
	lastwidth=getWidth()
	setTimeout("WidthChange()",10)
}
}