function jsSaisieDateOK(sDate) 
{
	var sDateSaisie;
	var sChaine;
	var sAnnee, sMois, sJour;
	var sAnnee2, sMois2, sJour2;
	var dDate = new Date;
	
	if ( ( sDate.length != 10 && sDate.length != 0) || (sDate.indexOf(".")>-1) ){
		alert("Le format de la date doit etre du type JJ/MM/AAAA");		
		return false;
	}else{
		sDateSaisie = sDate;
	}	
	if (sDate.length != 0){	
	 sChaine = jsReplace(sDateSaisie, "/",",");
	 sChaine = sChaine.split(",") ;
	 sAnnee= sChaine[2];
	 sMois= sChaine[1]-1 + ""; 
	 sJour= sChaine[0]
	 dDate = new Date(sAnnee, sMois, sJour);
	 sAnnee2 = dDate.getFullYear();
	 sMois2  = dDate.getMonth();
	 sJour2  = dDate.getDate();
	 
	 if ( (sAnnee2 != sAnnee) || (sMois2 != sMois) || (sJour2 != sJour) )
	 {
			 	return false;
	 }
	} 
	 
	 return true;
}

function jsReplace(sChaine, sRecherche, sRemplace)
{
var sChaine = sChaine + "";
var Resultat = "";
var Debut = 0;
var i;
	
	if( jsReplace.arguments.length < 3)
	{
		alert("manque arguments!");
		return;
	}
		
	for (i = 0; i<sChaine.length; i++)
	{ 
		Caractere = sChaine.charAt(i);
		if (Caractere == sRecherche)
		{
			Caractere = sRemplace;
		}
		Resultat += Caractere;
	}
		
	return Resultat;
}

function jsD1InfD2(sDate1, sDate2) 
{
	var sChaine;
	var sAnnee, sMois, sJour;
	var sAnnee3, sMois3, sJour3;
	var dDate = new Date;
	var dDate2 = new Date;

	if( (sDate1 == "") || (sDate2 == "")){
		return false
	}
	
	if( (sDate1.length != 10) || (sDate2.length !=10)){
		return false;
	}

	 // date 1
	 sChaine = jsReplace(sDate1, "/",",");
	 sChaine = sChaine.split(",") ;
	 sAnnee= sChaine[2];
	 sMois= sChaine[1];
	 sJour= sChaine[0]
	 
	 dDate = new Date(sAnnee, sMois, sJour);
	 
	 // date 2
	 sChaine = jsReplace(sDate2, "/",",");
	 sChaine = sChaine.split(",") ;
	 sAnnee3= sChaine[2];
	 sMois3= sChaine[1]; 
	 sJour3= sChaine[0]
	 
	 dDate2 = new Date(sAnnee3, sMois3, sJour3);
	 
	 if (dDate >= dDate2){
		return false;
	 }else{
		return true
	 }
	 
}

function navIE(){
	var IE = false;
	var sUserAgent = navigator.userAgent;
	var iDebut = sUserAgent.indexOf("(",0);
	var iFin = sUserAgent.indexOf(")",0);
	var sDebut = sUserAgent.substring(0,iDebut);
	var sContenu = sUserAgent.substring(iDebut, iFin);
	var iFin = sUserAgent.substring(iFin);
	
	if(sContenu.indexOf("MSIE 7") != -1)
	 IE = true;
	else if(sContenu.indexOf("MSIE 6") != -1)
	 IE = true;
	 
	 return IE;
}
 
function affichePhoto(evt){
	/*
	var sSrc= "";
	if (navIE()){
		sSrc= window.event.srcElement.src;
	}else{
		sSrc= evt.target.src;
	}
	*/
	var sSrc=(!document.all)?evt.target.src:event.srcElement.src;

	
	var iPosChaine = sSrc.indexOf("petites/") + 8;
	var sNomPhoto  = sSrc.substring(iPosChaine);
	var sNomFic    = 'images/grandes/' + sNomPhoto;
	//alert(sNomPhoto);
	//var iTop = 200;
	//var iLeft = 200;
	//var iLeft = (screen.width - iDimension)/2
  //var iTop =  (screen.height - iDimension)/2

  /*window.open("zoom.php?nomFic="+sNomFic, "Agrandissement","width="+iDimension
       +", height="+iDimension+", left="+iLeft+", top="+iTop
       + "resizable=no, scrollbars=no, status=no, toolbar=no, menubar=no, location=no");
	*/
	titre="AGRANDISSEMENT";
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no'); 
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>"); 
	w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>"); 
	w.document.write("<BODY onload='checksize()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
	w.document.write("<TD valign='middle' align='center'><IMG src='"+sNomFic+"' border=0 alt=' Image dans pop-up '>"); 
	w.document.write("</TD></TR></TABLE>");
	w.document.write("</BODY></HTML>"); 
	w.document.close();
}

function PopupImage(img) { 
	titre="Agrandissement"; 
	w=open("",'image','width=400,height=400,toolbar=no,scrollbars=no,resizable=no'); 
	w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>"); 
	w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();} else { setTimeout('checksize()',250) } }</"+"SCRIPT>"); 
	w.document.write("<BODY onload='checksize()' onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
	w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
	w.document.write("<TD valign='middle' align='center'><IMG src='"+img+"' border=0 alt=' Image dans pop-up '>"); 
	w.document.write("</TD></TR></TABLE>");
	w.document.write("</BODY></HTML>"); 
	w.document.close(); 
} 
