var leNomNavigateur = navigator.appName;
var laVersion = navigator.appVersion;
leNomNavigateur = leNomNavigateur.toUpperCase();
if (leNomNavigateur.substring(0,8) == "NETSCAPE")
	gNavig = "N"	// NETSCAPE
else
	gNavig = "M"	// MICROSOFT

var gOuverture = false;

function FermerFenetre ()
{
  if (!gFenetreAux.closed)
  {
    if (gNavig == "M")
      gFenetreAux.close();
    else
		{
    	gFenetreAux.document.clear();
			gFenetreAux.focus();
		}
	}
}

function test (p)
{
	if (p == "") p = "coucou";
alert (p);
}

function OuvrirFenetre (pURL, pLargeur, pHauteur)
{
	var lPt = pURL.indexOf("//");
	var lNomFichier = pURL.substring(lPt + 2, pURL.length)
	if (lNomFichier.charAt(0) == "/")
		lNomFichier = pURL.substring(lPt + 3, pURL.length)

	if (gOuverture)
  	FermerFenetre();
	// Préparation de la fenêtre
  // -- Dimensions du browser (taille et modification)--
  var lOptions = "width =" + pLargeur;
  lOptions += ",height =" + pHauteur;
  lOptions += ",Resizable = 0";
  // -- Outils du browser --
  lOptions += ",Menubar = 0";
  lOptions += ",Toolbar = 0";
  lOptions += ",Location = 0";
  lOptions += ",Directories = 0";
  lOptions += ",Status = 0";
  // -- options diverses --
  lOptions += ",Scrollbars = 0";
  lOptions += ",Copyhistory = 0";
  gOuverture = true;
  gFenetreAux = window.open("", "", lOptions);

	gFenetreAux.document.write("<body bgcolor='black'>\n");
	gFenetreAux.document.write("<center><img src='" + pURL + "' name='im' border='0'></center>\n");
	gFenetreAux.document.write("</body>\n");
	gFenetreAux.document.write("<scri");
	gFenetreAux.document.write("pt>\n");
	gFenetreAux.document.write("var w = document.im.width + 50;\n");
	gFenetreAux.document.write("var h = document.im.height + 60;\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("window.resizeTo(w, h);\n");
	gFenetreAux.document.write("self.focus();\n");
	gFenetreAux.document.write("window.moveTo((screen.width - w) / 2, (screen.height - h) / 2);\n");
	gFenetreAux.document.write("</scri");
	gFenetreAux.document.write("pt>\n");
}

function popimage (img)
{
	titre="Agrandissement";
	w = open("",'image','width=1,height=1,toolbar=no,scrollbars=yes,resizable=no');
	w.document.write("<script type='text/javascript'> ");
	w.document.write("function checksize () ");
//	w.document.write("{alert('toto')};");

	w.document.write("{	if (document.images[0].complete) ");
	w.document.write("{ window.resizeTo(document.images[0].width+20,document.images[0].height+85); ");
	w.document.write("window.focus();} ");
	w.document.write("else { settimeout('checksize()',250); } } ");
w.document.write("window.moveTo(0,0);\n");
	w.document.write("</"+"script>");

	w.document.write("<body bgcolor='black' onload='checksize()' onblur='window.close()' onclick='window.close()' topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>");

	w.document.write("<img src='" + img + "' border='0' alt='image' />");
	w.document.close();
}

function zipper (pRep, pNbFichiers)
{
	var lst = "";
	var lNbChk = 0;
	for (var lIdx = 0; lIdx < pNbFichiers; ++lIdx)
	{
//		var lIdent = eval('chk' + lIdx);
		if (document.getElementById('chk' + lIdx).checked)
		{
//			lst += "~" + document.getElementById(lIdent.name).value;
			lst += "~" + document.getElementById('chk' + lIdx).value;
			++lNbChk;
			if (lNbChk > 100)
			{
				alert("Ne pas cocher plus de 100 fichiers");
				return;
			}
		}
	}
	if (lNbChk == 0)
	{
		alert("Cocher au moins 1 fichier");
		return;
	}
	document.getElementById('lst').value = lst;
	document.getElementById('rep').value = pRep;
	document.forms[0].action = "../zipper.php";
	document.forms[0].method = "Post";
	document.forms[0].submit();
}

function SelectionPar15 (pNum)
{
	var lDeb = pNum * 15;
	var lFin = lDeb + 15;
	for (var lIdx = lDeb; lIdx < lFin; ++lIdx)
		document.getElementById('chk' + lIdx).checked = document.getElementById('selchk' + pNum).checked;
}

function DoubleQuote (pTexte)
{
	var lCarac;
	var lTexte = "";

	for (var lIdx = 0; lIdx < pTexte.length; ++lIdx)
	{
		lCarac = pTexte.charAt(lIdx);
		if (lCarac == "'")
			lTexte = lTexte + lCarac;
		if (pTexte.charCodeAt(lIdx) == 34)
			lCarac = "\\" + lCarac;
		lTexte = lTexte + lCarac;
	}
	return lTexte;
}

function InitAlbumPhoto (unRepPhoto, uneExtension)
{
	if (uneExtension == null)
		uneExtension = "gif"
	gPhoto = new Array();
	gPhotoMini = new Array();

	for (var leIndex = 1; leIndex <= gNbPhoto; ++leIndex)
	{
		var leFichierImage = "";

		if (leIndex < 100)
			leFichierImage += "0";
		if (leIndex < 10)
			leFichierImage += "0";
		leFichierImage += leIndex + "." + uneExtension;

		gPhoto[leIndex] = new Image;
		gPhoto[leIndex].src = unRepPhoto + leFichierImage;

		gPhotoMini[leIndex] = new Image;
		gPhotoMini[leIndex].src = unRepPhoto + "m" + leFichierImage;
	}
}

function AfficherPlancheContact (unTitreAlbum, unNbPhoto)
{
	document.writeln("<tr>");
	document.writeln("<td align=center valign=center halign=center width=160 height=160><h3>");
	document.writeln(unTitreAlbum);
	document.writeln("</h3></td>");
	for (var leIndex = 1; leIndex <= unNbPhoto; ++leIndex)
	{
		if ((leIndex & 3) == 0)
			document.writeln("</tr><tr>");
		document.writeln("<td align=center valign=center halign=center width=160 height=160>");
		document.writeln("<a href=\"javascript:OuvrirFenetre('" + gPhoto[leIndex].src + "', 660, 660)\">");
		document.writeln("<img src=" + gPhotoMini[leIndex].src + " border=0></a>");
		document.writeln("</td>");
	}
	document.writeln("</tr>");
}

function JouerFichier (unFichier)
{
	sx.addVariable('file',unFichier);
	sx.addVariable("autostart","true")
	sx.write('audiopreview');
	lTexte = "Vous écoutez : " + unFichier;
	SetDiv("commentaire", lTexte);
}

function SetDiv(pId, pContenu)
{
	document.getElementById(pId).innerHTML = pContenu;
}

/*
// ATTENTION: Fonction PHP dans "fg.php"
function AfficherPlancheContact640 ($pTitreAlbum, $pNbPhoto, $pRepPhoto, $pExtension)
{
	echo "<tr>";
	echo "<td align=center valign=center halign=center width=160 height=160><h3>";
	echo $pTitreAlbum;
	echo "</h3></td>";
	for ($lIndex = 1; $lIndex <= $pNbPhoto; ++$lIndex)
	{
		$lFichierImage = "";
		if ($lIndex < 100)
			$lFichierImage = $lFichierImage . "0";
		if ($lIndex < 10)
			$lFichierImage = $lFichierImage . "0";
		$lFichierImage = $lFichierImage . $lIndex . "." . $pExtension;
		if (($lIndex & 3) == 0)
			echo "</tr><tr>";
		echo "<td align=center valign=center halign=center width=160 height=160>";
		$lFichierImageDest = "./temp/" . $lFichierImage;
		resize($pRepPhoto . $lFichierImage, $lFichierImageDest, 640, "imagecopyresampled", 2);
		echo "<a href=\"javascript:OuvrirFenetre('" . $pRepPhoto . $lFichierImage . "', 660, 660)\">";
		echo "<img src='" . $lFichierImage . "' border=0></a>";
		echo "</td>";
	}
	echo "</tr>";
}

// ATTENTION: Fonction PHP dans "fg.php"
function AfficherPlancheContactMini ($pTitreAlbum, $pNbPhoto, $pRepPhoto, $pExtension)
{
	echo "<tr>";
	echo "<td align=center valign=center halign=center width=160 height=160><h3>";
	echo $pTitreAlbum;
	echo "</h3></td>";
	for ($lIndex = 1; $lIndex <= $pNbPhoto; ++$lIndex)
	{
		$lFichierImage = "";
		if ($lIndex < 100)
			$lFichierImage = $lFichierImage . "0";
		if ($lIndex < 10)
			$lFichierImage = $lFichierImage . "0";
		$lFichierImage = $lFichierImage . $lIndex . "." . $pExtension;
		if (($lIndex & 3) == 0)
			echo "</tr><tr>";
		echo "<td align=center valign=center halign=center width=160 height=160>";
		$lFichierImageMini = $pRepPhoto . "m" . $lFichierImage;
		resize($pRepPhoto . $lFichierImage, $lFichierImageMini, 160, "imagecopyresampled", 2);
		echo "<a href=\"javascript:OuvrirFenetre('" . $pRepPhoto . $lFichierImage . "', 660, 660)\">";
		echo "<img src='" . $lFichierImageMini . "' border=0></a>";
		echo "</td>";
	}
	echo "</tr>";
}
*/