// JavaScript Document

function testDate(year,month,day){
	month = month - 1; // javascript month range : 0- 11
		var tempDate = new Date(year,month,day);
		
		if (!((year == tempDate.getFullYear()) && (month == tempDate.getMonth()) &&	(day == tempDate.getDate()))){
			return false;
		}
		return true;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function printit(){
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




//Vérifie la syntaxe d'une adresse email
function checkMail(email) {
 return email.match(/^[A-Za-z0-9_.-]+@([A-Za-z0-9_]+\.)+[A-Za-z]{2,4}$/)!=null;
}

//Vérifie que la chaine passée finie par .jpg pou .jpeg
function checkJpegExtension(fileName) {
	return fileName.match(/^(.)*(.jpg|.jpeg|.JPG|.JPEG)$/)!=null;
}

//Ouvre une popup pour afficher un screenshot
function popUpImg(num_img)
{
	w=open("",'image','weigth=toolbar=no,scrollbars=no,resizable=no, width='+screen.width+', height='+screen.height+'');  
 	w.document.write("<HTML><BODY onclick=\"window.close();\"><center><a href=\"javascript:\/\/\" onclick=\"window.close()\">Fermer la fenetre</a></center><br><IMG src=\""+img+"\">");
  	w.document.write("</BODY></HTML>");
  	w.document.close();
}

//Ouvre une popup centré à l'écran aux dimensions données
function OpenPopUpApercu(root_url,img,_width,_height) 
{
	_left=(screen.width/2)-(_width/2);
	_top=(screen.height/2)-(_height/2);
	window.open(root_url+img, "Carte","toolbar=no,scrollbars=no,directories=no,copyhistory=no,location=no,statusbar=no,menubar=no,resizable=no,width="+_width+",height="+_height+",left ="+_left+",top ="+_top + "");
}

//Affiche ou non une zone DIV
function show_hideDiv(divId) { 

  // Booléen reconnaissant le navigateur (vu en partie 2)
  isIE = (document.all) 
  isNN6 = (!isIE) && (document.getElementById)

  // Compatibilité : l'objet DIV est détecté selon le navigateur
  if (isIE) DIV = document.all[divId];
  if (isNN6) DIV = document.getElementById(divId);

  // On affiche ou on cache
  if (DIV.style.display == "none"){
    // Cas ou le tableau est caché
    DIV.style.display = ""
  } else {
    // On le cache
    DIV.style.display = "none"
   }
}

//Fonction modifiée pour afficher le popup au centre de l'écran
function openCenteredWindow(theURL,winName,width,height,features) { //v2.0
	var top=(screen.height-height)/2;
    var left=(screen.width-width)/2;
	window.open(theURL,winName,"top="+top+",left="+left+",width="+width+",height="+height+","+features);
}

//Vérifie la validité d'une date
function isDate (year, month, day) {
	// month argument must be in the range 1 - 12
	month = month - 1; // javascript month range : 0- 11
	var tempDate = new Date(year,month,day);
	
	if (!((year == tempDate.getFullYear()) && (month == tempDate.getMonth()) &&	(day == tempDate.getDate()))){
		return false;
	}
	return true;
}

//afficher/masquer un DIV
function show_DIV(param){
	 // Booléen reconnaissant le navigateur (vu en partie 2)
  isIE = (document.all) ;
  isNN6 = (!isIE) && (document.getElementById);
  if (isIE) DIV = document.all[param];
  if (isNN6) DIV = document.getElementById(param);	
  DIV.style.display = "";
  return false;
}
function hide_DIV(param){
  isIE = (document.all) ;
  isNN6 = (!isIE) && (document.getElementById);
  if (isIE) DIV = document.all[param];
  if (isNN6) DIV = document.getElementById(param);	
  DIV.style.display = "none";
  return false;
}
