//
// Fichier javascript créé par Jean-Marc SEBASTIEN
// Tous les scripts contenus dans ce fichier ont été développés par Jean-Marc SEBASTIEN
//

// nav netscape
function IsNetscape6()
{
var nav=0;

var i=navigator.appVersion;
var x=parseFloat(i);

if ( (navigator.appName=="Netscape") && (x>=5.0) )
	nav=1;

return (nav);
}

function IsNetscape()
{
var nav=0;

if (IsIE()==0)
	nav=1;

return (nav);
}

// nav IE
function IsIE()
{
var nav=0;
var i=navigator.appVersion;
var x=parseFloat(i);

if ( (navigator.appName=="Microsoft Internet Explorer") && (x>=4.0) )
	nav=1;
else
	nav=0;
return (nav);
}

// nav compatible DHTML
function IsNavDHTML()
{
var nav=0;
var i=navigator.appVersion;
var x=parseFloat(i);

if ( (IsIE()==1) || (IsNetscape()==1) )
	nav=1; 
return (nav);

}

function IsReady(Img)
{
var Ok=0;
if ( (IsIE()==1) && (Img.readyState=="complete") )
	Ok=1;

if ( (IsNetscape()==1) && (Img.complete==1) )
	Ok=1;
	
return (Ok);
}

function fmtTime(val)
{
var fmt;
if (val<10)
	fmt="0"+val.toString();
else
	fmt=val.toString();
return (fmt);
}

function ConvertJour(val)
{
  var d, day, x;
  var x = new Array("Dimanche", "Lundi", "Mardi");
  var x = x.concat("Mercredi","Jeudi", "Vendredi");
  var x = x.concat("Samedi");
  return(x[val]);
}

function ConvertMois(val)
{
  var d, day, x;
  var x = new Array("Janvier", "Fevrier", "Mars");
  var x = x.concat("Avril","Mai", "Juin");
  var x = x.concat("Juillet","Août","Septembre", "Octobre");
  var x = x.concat("Novembre","Décembre");
  return(x[val]);
}

// donne heure + date
function getTime()
{
var time = new Date();
var formatHeure;
formatHeure=getDate()+ ", " + fmtTime(time.getHours())
		+":"+ fmtTime(time.getMinutes());

var	str = formatHeure.toString();
return (str);
}

// donne la date
function getDate()
{
var time = new Date();
var formatHeure;
formatHeure=ConvertJour(time.getDay())+ " "+time.getDate() + " "
	+ ConvertMois(time.getMonth());
return (formatHeure);

}

// écrire dans un objet div
function writeDIV(div, string)
{
	if (div==null)
		return (1);

	if ( (IsIE()==1) && (document.all[div]!=null) )
		document.all[div].innerText=string;

    if (IsNetscape()==1)
	{
		if(document.layers.length!=0)
		{
  			document.layers[div.toString()].document.write(string.toString());
			document.layers[div.toString()].document.close();
		}
	}
	
	return (1);
}

function writeDIVHTML(div, string)
{
	if (div==null)
		return (1);

	if ( (IsIE()==1) && (document.all[div]!=null) )
		document.all[div].innerHtml=string;

    if (IsNetscape()==1)
	{
		writeDIV(div, string);
	}
	
	return (1);
}


// afficher image ds div
function afficherImageDIV(div, img1,desc,click)
{
	if (div==null)
		return (1);

	if (img1==null)
		return (1);

		// calcul dimensions
		var coef=1;
		var ImgHeight=img1.height*coef;
		var ImgWidth=img1.width*coef;


		if (IsIE()==1)
		{
		      var documentFrame = document;
			var windowFrame = documentFrame.documentElement;
			
			if (img1.width>windowFrame.offsetWidth)
			{
				coef=windowFrame.offsetWidth/img1.width;
			}
			ImgHeight=img1.height*coef;
			ImgWidth=img1.width*coef;


		}
		if (IsNetscape()==1)
		{
			var windowFrame=window;

			if (img1.width>windowFrame.innerWidth)
			{
				coef=windowFrame.innerWidth/img1.width;
			}
			ImgHeight=img1.height*coef;
			ImgWidth=img1.width*coef;

		}

		if (desc!="")
			desc="   "+desc;
		var str;
		str="<p align='justify'>";
		if (click!="")
			str=str+"<a href=\'javascript:"+click+"\' >";

            
		str=str+"<img border='0' src="+img1.src+" width="+ImgWidth+"  height="+ImgHeight;
		str=str+" >";
		if (click!="")
			str=str+"</a>";
        if (desc!="")
			str=str+desc.toString();
		str=str+"</p>";	
					
	if (IsIE()===1)
	{
	if (document.all[div]!=null)
		document.all[div].innerHTML=str;		
	}
	if (IsNetscape()==1)
		writeDIV(div,str);	
		
	return (1);
}

function showImgInDivAt(e,div,img1)
{

   var X=0;
   var Y=0;
   if ( (IsIE()==1) && (document.all[div]!=null) )
   {
   X=e.offsetX;
   Y=e.offsetY;
   document.all[div].style.width=img1.width;
   document.all[div].style.height=img1.height;
   document.all[div].style.pixelLeft=X-(img1.width/2);
   document.all[div].style.pixelTop=Y-(img1.height*1.2);
   
   }
   
   if (IsNetscape6()==1)
   {
	
	/*var str=div;
	alert(str);
	
	var element; var att; 
	element = document.getElementById(div); 
	if (element!=null)
	{ 
		element.clientTop=(e.pageY-(img1.height*1.2));
		element.clientLeft=(e.pageX-(img1.width/2));
	  	element.clientWidth=img1.width;
		element.clientHeight=img1.height;
		alert(element.Height.toString());	  	
	} */
	
		
   }		
   
   if ( (IsNetscape()==1) && (document.layers[div]!=null) )
   {
   document.layers[div].resizeTo(img1.width,img1.height);
   document.layers[div].left=(e.pageX-(img1.width/2));
   document.layers[div].top=(e.pageY-(img1.height*1.2));
   }

   afficherImageDIV(div, img1,"",0);
   return (1);
}

function MoveToOrigin(div)
{
 if (IsNetscape()==1)
 {
 document.layers[div].resizeTo(10,10);
 document.layers[div].left=20;
 document.layers[div].top=20;
   
 } 

 if (IsIE()==1)
 {
 document.all[div].style.width=20;
 document.all[div].style.height=20;
 document.all[div].style.pixelLeft=10;
 document.all[div].style.pixelTop=10;
 }

}


function effacerImageDIV(div)
{

    if (IsIE()==1)
	{
		document.all[div.toString()].innerHTML=" ";	
	}

	if (IsNetscape()==1)
	{
		writeDIV(div," ");
	}	
	
	return (1);
}


// afficher image 
function afficherImageSrc(index, src_image)
{
	document.images[index].src=src_image.toString();

	return (1);
}

// afficher image 
function afficherImage(index, Image)
{
	if ( (Image==null)  || (IsReady(Image)==0) )
		return (1);
	
	document.images[index].src=Image.src;

	return (1);
}

// afficher image 
function afficherImageByName(Name, Image)
{
	
	if ( (Image==null)  || (IsReady(Image)==0) )
		return (1);
	
	document.images[Name].src=Image.src;

	return (1);
}

// afficher image 
function afficherImageSrcByName(Name, src_image)
{
	document.images[Name].src=src_image.toString();

	return (1);
}



// url vide
function urlVide(){}  


// afficher image dans window (objet image)
function windowImage(Image1,  windowName, ImgWidthMax, ImgHeightMax)
{
  var offset;
  var ImgWidth;
  var	ImgHeight;
  var sizeFont;
  var SIZE_MAX=2;
  sizeFont=SIZE_MAX;
  offsetx=20;
  offsety=70;
  var coefx=1;
  var coefy=1;
  var coef=1;
  if (Image1==null)
	return (null);		

  ImgWidth=Image1.width; 
  ImgHeight=Image1.height;	
  
  if ( (ImgWidthMax<ImgWidth) && (ImgHeightMax<ImgHeight) )
  {
	coefx=ImgHeightMax/ImgHeight;
	coefy=ImgWidthMax/ImgWidth;
	if (coefx>coefy)
		coef=coefy;
	else
		coef=coefx;
	sizeFont=sizeFont/2;	

  }
  else
  {
	if (ImgWidthMax<ImgWidth)
	{
		coef=ImgWidthMax/ImgWidth;
		sizeFont=sizeFont/2;	
	}
	if (ImgHeightMax<ImgHeight)
	{
		coef=ImgHeightMax/ImgHeight;
		sizeFont=sizeFont/2;	
	}
  }


  ImgWidth=ImgWidth*coef;
  ImgHeight=ImgHeight*coef;
		
  var winHandle = window.open("" ,"Viewer","toolbar=no,scrollbars=no,resizable=no,width="
	+(ImgWidth+offsetx)+",height=" + (ImgHeight+offsety) );

  //winHandle.moveTo(posX,posY);
  while (windowName.search("_")!=(-1))
  {
  	windowName=windowName.replace("_"," ");
  }
  
  if ( (windowName.length>22) && (sizeFont==SIZE_MAX) )
  {
	sizeFont=sizeFont/2;
  }

  if(winHandle != null)
  {
    var htmlString = "<html><head><title>Picture</title></head>"  ;
    
    htmlString += "<body>";

    htmlString += "<p align='center'><font size="+sizeFont.toString()+" face='Comic Sans MS' color='#008080'>"
	+windowName+"</font></p>";

    htmlString += "<p align='center'><img border='0' src="+Image1.src+" width="+ImgWidth
		+"  height="+ImgHeight+" ></p></body></html>";
	
    winHandle.document.open();
    winHandle.document.write(htmlString);
    winHandle.document.close();
  }	
  if(winHandle != null)
	winHandle.focus();
  
return winHandle;
}


// afficher image dans window (nom du fichier)
function windowImageSrc(picName,  windowName, ImgWidthMax, ImgHeightMax)
{
	var Image1;
  	Image1 = new Image();
	Image1.src=picName.toString();
	return windowImage(Image1,  windowName, ImgWidthMax, ImgHeightMax);
}



// close window
function closeWindow(windowOpen)
{    
  if(windowOpen != null)
  { 
	windowOpen.close(); 
	windowOpen=null;
	
  }

  return (1);
}

// couleurs d'1 lien
var colorOver;
var colorOut;
colorOver="red";
colorOut="blue"

function linkColor(e)
{
	if( (IsIE()==1) && (window.event!=null) )
	{
		if(window.event.srcElement.className == "link")
		{
	       if (window.event.type=="mouseover")
			window.event.srcElement.style.color = colorOver;
		   else
			window.event.srcElement.style.color = colorOut;
		}

	}

	if (IsNetscape()==1) 
	{
			/*if (e.type=="mouseover")
				document.classes.link.all.color = colorOver.toString();
			else
				document.classes.link.all.color = colorOut.toString();

			if (e.type=="mouseover")
				{
				document.tags.a.color=colorOver.toString();
				window.alert(document.tags.a.color);
				}
			else
				{
				document.tags.a.color=colorOut.toString();
				window.alert(document.tags.a.color);
				}*/
	}
	
	if (IsNetscape()==1)
	{
		var retval = routeEvent(e);
		if (retval == false) return false;
		else return true;
	}	

}

function initLink()
{
	if (IsIE()==1)
	{
	document.onmouseover=linkColor;
	document.onmouseout=linkColor;

	}
	
	if (IsNetscape()==1)
	{
	window.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT);
	window.onmouseover=linkColor;
	window.onmouseout=linkColor;
	
	}
}

// ecrire dans barre d'état
function writeStatusBar(str,ajouterTexte)
{
	while (str.search("_")!=(-1))
  	{
  	str=str.replace("_"," ");
  	}
  

	if ( (IsIE()==1) && (window.status!=null) )
	{
		
           if (ajouterTexte==1)
			window.status=window.status+str.toString();
		else
			window.status=str.toString();
	}
}

// aperçu dans frame de gauche (si existe)
function apercuLeftTexte(strTitre,divTitre)
{
	if ( (strTitre==null) || (divTitre==null) )
		return (1);
	
	
	if (IsIE()==1)
	{
		
		if (document.parentWindow.parent.frames!=null)
		{
			if (document.parentWindow.parent.frames.length==0)
				return (1);

			var documentFrame = document.parentWindow.parent.frames[0].document;
			if ( (documentFrame!=null) && (documentFrame.all[divTitre.toString()]!=null) )
			{
			documentFrame.all[divTitre.toString()].innerText=strTitre.toString();	
			}
			else
				return (1);	 
	 
		}
		else
			return (1);
	}	
	
	if (IsNetscape()==1)
	{
		if (window.parent.frames["Sommaire"]!=null)
		{
		var documentFrame =window.parent.frames["Sommaire"].document;
		if (documentFrame!=null)
			{
			documentFrame.layers[divTitre.toString()].document.write(strTitre.toString());
			documentFrame.layers[divTitre.toString()].document.close();	
			}
			else
				return (1);	 

		}
		else
			return (1);	
	}
	
	return (1);
}

// aperçu dans frame de gauche (si existe)
function apercuLeftImage(e,Img, divImg, bShowImgInCurrentPage)
{
	if (Img==null)
		return (1);
	
	if ( (divImg==null)  || (IsReady(Img)==0) )
		return (1);
	
	if (IsIE()==1)
	{
		var htmlString;
		
		if (document.parentWindow.parent.frames!=null)
		{
			if (document.parentWindow.parent.frames.length==0)
			{
				if (bShowImgInCurrentPage==1)
					showImgInDivAt(e,divImg,Img);
				return (1);
			}

			var documentFrame = document.parentWindow.parent.frames[0].document;
			var windowFrame = documentFrame.documentElement;
			if ( (documentFrame!=null) && (windowFrame!=null) )
			{
			var coef=1;
			if (Img.width>windowFrame.offsetWidth)
			{
				coef=windowFrame.offsetWidth/Img.width;
			}
			var ImgHeight=Img.height*coef;
			var ImgWidth=Img.width*coef;
			htmlString = "<p align='center'><img border='0' src="+Img.src+" width="+ImgWidth
				+"  height="+ImgHeight+" ></p>";
			if (documentFrame.all[divImg.toString()]!=null)
				documentFrame.all[divImg.toString()].innerHTML=htmlString.toString();	
			}
			else
				return (1);	 
	 
		}
		else
			return (1);

	}	

	if (IsNetscape()==1)
	{
		if (window.parent.frames[0]!=null)
		{
		var htmlString="";
		var coef=1;
		var ImgHeight=0;
		var ImgWidth=0;
		var windowFrame=window.parent.frames[0].window;
		if (windowFrame!=null)
		{
			if (Img.width>windowFrame.innerWidth)
			{
				coef=windowFrame.innerWidth/Img.width;
			}
			ImgHeight=Img.height*coef;
			ImgWidth=Img.width*coef;
			htmlString = "<p align='center'><img border='0' src="+Img.src+" 							width="+ImgWidth+"  height="+ImgHeight+" ></p>";
		}
		else
			return (1);

		var documentFrame =window.parent.frames[0].document;
		if (documentFrame!=null)
			{
			documentFrame.layers[divImg.toString()].document.write(htmlString.toString());
			documentFrame.layers[divImg.toString()].document.close();	
			}
			else
				return (1);	 

		}
		else
		{
			if (bShowImgInCurrentPage==1)
					showImgInDivAt(e,divImg,Img);
			return (1);
		}


	}
	
	return (1);
}

// aperçu dans frame de gauche (si existe)
function effacerApercuLeftImage(divImg)
{
	
	if (divImg==null)
		return (1);
	
	if (IsIE()==1)
	{
		
		if (document.parentWindow.parent.frames!=null)
		{
			if (document.parentWindow.parent.frames.length==0)
			{
				effacerImageDIV(divImg);
				MoveToOrigin(divImg);
				return (1);
			}

			var documentFrame = document.parentWindow.parent.frames[0].document;
			if (documentFrame!=null)
				documentFrame.all[divImg.toString()].innerHTML="";	
			else
				return (1);	 
	 
		}
		else
			return (1);

	}

	if (IsNetscape()==1)
	{
		if (window.parent.frames["Sommaire"]!=null)
			apercuLeftTexte(" ",divImg);
		else
			{
			effacerImageDIV(divImg);
			MoveToOrigin(divImg);
			}
	}	
	
	return (1);
}

function isNoFrames()
{
var Rep=1;

if (IsIE()==1)
{
	if (document.parentWindow.parent.frames!=null)
	{
		if (document.parentWindow.parent.frames.length!=0)
			Rep=0;
	}
}

if (IsNetscape()==1)
{
	if (window.parent.frames!=null)
	{
		if (window.parent.frames.length!=0)
			Rep=0;
	}
}

return (Rep);
}

function versionSansCadres()
{

if (isNoFrames()==0)
{
	if (IsIE()==1)
		parent.location.href=document.parentWindow.parent.frames[1].location.href;

	if (IsNetscape()==1)
		parent.location.href=window.parent.frames[1].location.href;	
}

}

function RightFrameGoToUrl(url)
{
if (isNoFrames()==0)
{
	// version avec cadres
	if (IsIE()==1)
		document.parentWindow.parent.frames[1].location.href=url;

	if (IsNetscape()==1)
	{
		window.parent.frames[1].location.href=url;
		//alert("RightFrameGoToUrl("+url+")");
	}	
}
else
{
	// version sans cadres
	GoToUrl(url);
	
}

}

function GoToUrl(url)
{
	// version sans cadres
	if (IsIE()==1)
		parent.location.href=url;

	if (IsNetscape()==1)
	{
		parent.location.href=url;
		//alert("GotoUrl("+url+")");
	}
	

}



//////////////////////////////////////////////
// Sound ASF
// Initialisation Plug-In Windows Media Player dans Netscape
function InitPlugInWMPNetscape()
{
 /*	if ( IsNetscape() == 1 )
    	{
        navigator.plugins.refresh();
        document.write("\x3C" + "applet MAYSCRIPT Code=NPDS.npDSEvtObsProxy.class" )
        document.writeln(" WIDTH=5 HEIGHT=5 NAME=appObs\x3E \x3C/applet\x3E")
     }*/
}
//////////////////////////////////////////////