var nomPartSelected = "";
var tabNom = new Array();
var idMinPage = 0;
var tabImage = null;
function setFocus() {
if (document.getElementById('login').value != "") {
document.getElementById('pwd').focus();
} else {
document.getElementById('login').focus();
}
}
function ouvrirImage(idPhoto,nomPhoto,codeTheme) {
top.frames['bas'].frames['centre'].location.replace("fotoweb73.php?id="+idPhoto+"&pathPhoto="+nomPhoto);
if (top.frames['bas'].frames['gauche'] != null)
top.frames['bas'].frames['gauche'].location.replace("fotoweb56.php?img="+nomPhoto);
}
function rolloverIn(nameImg) {
nom = String(nameImg);
image2 = new Image;
image2.src = "ergonomie/_images/"+nom+"_over.gif";
document.getElementById(nom).src = image2.src;
}
function rolloverOut(nameImg) {
nom = String(nameImg);
image1 = new Image;
image1.src = "ergonomie/_images/"+nom+".gif";
document.getElementById(nom).src = image1.src;
}
function suivante(idTheme, nbPhotos, idMin, nbResult,nbPage,pano,chrono) {

idMin = eval(idMin) + eval(nbPhotos);
if (pano == 1)
top.frames['bas'].frames['basPano'].location.replace("fotoweb59.php?codeTheme="+idTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult+"&chrono="+chrono);
else
if (idTheme==0)
top.frames['menuDroiteBas'].location.replace("fotoweb60.php?nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult+"&chrono="+chrono);
else
top.frames['menuDroiteBas'].location.replace("fotoweb58.php?codeTheme="+idTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult+"&chrono="+chrono);
updateNavigation(idTheme,nbPhotos,nbResult,nbPage,"suivant",pano,chrono);
}
function precedente(idTheme, nbPhotos, idMin, nbResult,nbPage,pano,chrono) {
idMin = eval(idMin) - eval(nbPhotos);
if (idMin < 0) idMin = 0;
if (pano == 1)
top.frames['bas'].frames['basPano'].location.replace("fotoweb59.php?codeTheme="+idTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult+"&chrono="+chrono);
else
if (idTheme==0)
top.frames['menuDroiteBas'].location.replace("fotoweb60.php?nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult+"&chrono="+chrono);
else
top.frames['menuDroiteBas'].location.replace("fotoweb58.php?codeTheme="+idTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult+"&chrono="+chrono);
updateNavigation(idTheme,nbPhotos,nbResult,nbPage,"precedent",pano,chrono);
}
function deplacerAscenceur(codeTheme,nbPhotos,nbResult,nbPage,sens,pano) {
var str = "";
if (pano=='' || pano=='undefined') pano=0;

var idIm = top.frames['menuDroiteHaut'].document.images[1].id;
var numPageEnCours = 0;
if ( pano==1)
numPageEnCours = top.frames['bas'].frames['basPano'].document.getElementById('txtNumPage').value;
else
numPageEnCours = top.frames['menuDroiteBas'].document.getElementById('txtNumPage').value;

var idMinPage = 0;
var idMaxPage= 0;

if (sens == "suivant") {
if (idIm.substring(0,8) == "imSelect") {
idMinPage  = parseInt(idIm.substring(8,idIm.length)) + 1;
} else {
idMinPage = parseInt(idIm.substring(2,idIm.length)) + 1;
}
} else if (sens == "precedent") {
if (idIm.substring(0,8) == "imSelect") {
idMinPage  = parseInt(idIm.substring(8,idIm.length)) - 1;
} else {
idMinPage = parseInt(idIm.substring(2,idIm.length)) - 1;
}
idMinPage = (idMinPage == 0 ? 1 : idMinPage);
} else {
if (idIm.substring(0,8) == "imSelect") {
idMinPage  = parseInt(idIm.substring(8,idIm.length));
} else {
idMinPage = parseInt(idIm.substring(2,idIm.length));
}
}
idMaxPage = parseInt(idMinPage) + 4;
if (idMaxPage <= parseInt(nbPage) + 1) {
for (i = idMinPage; i < idMaxPage; i++) {
idMin = (i-1) * nbPhotos;
numPage = i;
if (numPageEnCours == numPage)
nomImg = "imSelect"+numPage;
else
nomImg = "im"+numPage;
str += "<img src=ergonomie/_images/"+nomImg+".gif onClick=majListePhotos("+codeTheme+","+nbPhotos+","+idMin+","+nbResult+","+pano+") id=im"+numPage+" style='cursor:pointer;cursor:hand' alt=Page "+numPage+">";
if (i != idMinPage+3) str += " ";
}
top.frames['menuDroiteHaut'].location.replace("fotoweb65.php?codeTheme="+codeTheme+"&nbPhotos="+nbPhotos+"&nbResult="+nbResult+"&nbPage="+nbPage+"&pano="+pano+"&str="+str);
} else {
alert("Dernière page.");
}
}
/* @param codeTheme	: le code du thème
* @param nbPhotos	: le nombre de vignettes par page (10)
* @param nbResult	: le nombre de photos accessibles du thème
* @param nbPage		: le nombre de page maxi pour le thème
* @param sens			: sens de la navigation (suivant ou precedent)
* @param numPageEnCours : le numéro de page en cours
*/
function updateNavigation(codeTheme,nbPhotos,nbResult,nbPage,sens,pano,chrono) {
var str = "";

if (pano=='' || pano=='undefined') pano=0;

if (sens == "") {
top.frames['menuDroiteHaut'].location.replace("fotoweb64.php?codeTheme="+codeTheme+"&nbPhotos="+nbPhotos+"&nbResult="+nbResult+"&pano="+pano+"&chrono="+chrono);
} else if (nbPage > 1) {

var numPageEnCours = 0;
if ( pano==1)
numPageEnCours = top.frames['bas'].frames['basPano'].document.getElementById('txtNumPage').value;
else
numPageEnCours = top.frames['menuDroiteBas'].document.getElementById('txtNumPage').value;

if (sens == "suivant") {
numPageEnCours ++;
} else if (sens == "precedent") {
numPageEnCours --;
}
var str = "";
var idIm = "";
if (nbPage >= 5)
idIm = top.frames['menuDroiteHaut'].document.images[1].id;
else
idIm = top.frames['menuDroiteHaut'].document.images[0].id;

if (idIm.substring(0,8) == "imSelect") {
idMinPage  = idIm.substring(8,idIm.length);
} else {
idMinPage = idIm.substring(2,idIm.length);
}

idMaxPage = parseInt(idMinPage) + 4;
if (idMaxPage > nbPage)
idMaxPage =  parseInt(nbPage) + 1;

for (i = idMinPage; i < idMaxPage; i++) {
idMin = (i- 1) * nbPhotos;
numPage = i;
if (numPageEnCours == numPage)
nomImg = "imSelect"+numPage;
else
nomImg = "im"+numPage;
str += "<img src=ergonomie/_images/"+nomImg+".gif onClick=majListePhotos("+codeTheme+","+nbPhotos+","+idMin+","+nbResult+","+pano+") id=im"+numPage+" style=cursor:pointer;cursor:hand alt=Page "+numPage+">";
if (i != parseInt(idMinPage)+3) str += " ";
}
top.frames['menuDroiteHaut'].location.replace("fotoweb65.php?codeTheme="+codeTheme+"&nbPhotos="+nbPhotos+"&nbResult="+nbResult+"&nbPage="+nbPage+"&pano="+pano+"&chrono="+chrono+"&str="+str);
}
}
function majListePhotos(codeTheme,nbPhotos,idMin,nbResult,pano) {

if (pano==1)
top.frames['bas'].frames['basPano'].location.replace("fotoweb59.php?codeTheme="+codeTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult);
else
if (codeTheme==0)
top.frames['menuDroiteBas'].location.replace("fotoweb60.php?nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult);
else
top.frames['menuDroiteBas'].location.replace("fotoweb58.php?codeTheme="+codeTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult);

pageEnCours = (eval(idMin) / nbPhotos) + 1;
for(var i=0;i<15;++i) {
var numImg = (i+1);
var imgTmp = document.getElementById(''+'im'+numImg+'');
if (imgTmp != null) {
imgTmp.src = "ergonomie/_images/im"+numImg+".gif";
}
}
var imgSelected = document.getElementById(''+'im'+pageEnCours+'');
if (imgSelected != null)
imgSelected.src = "ergonomie/_images/imSelect"+pageEnCours+".gif";


}
function majListePhotosOrdre(codeTheme,nbPhotos,idMin,nbResult,pano,chrono) {

if (pano==1)
top.frames['bas'].frames['basPano'].location.replace("fotoweb59.php?codeTheme="+codeTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult +"&chrono="+chrono);
else
if (codeTheme==0)
top.frames['menuDroiteBas'].location.replace("fotoweb60.php?nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult +"&chrono="+chrono);
else	top.frames['menuDroiteBas'].location.replace("fotoweb58.php?codeTheme="+codeTheme+"&nbPhotos="+nbPhotos+"&idMin="+idMin+"&nbResult="+nbResult +"&chrono="+chrono);

pageEnCours = (eval(idMin) / nbPhotos) + 1;
for(var i=0;i<15;++i) {
var numImg = (i+1);
var imgTmp = document.getElementById(''+'im'+numImg+'');
if (imgTmp != null) {
imgTmp.src = "ergonomie/_images/im"+numImg+".gif";
}
}
var imgSelected = document.getElementById(''+'im'+pageEnCours+'');
if (imgSelected != null)
imgSelected.src = "ergonomie/_images/imSelect"+pageEnCours+".gif";


}
function authentifier() {
document.getElementById('res').value=screen.width+'*'+screen.height;

try{
loadScript("log_in","users/fotoweb87.php");
}catch(e){
window.location="users/fotoweb87.php?OldNav=true";
}

}
function checkEnter(e) {
gk=window.Event?1:0;

var touche=gk?e.which:window.event.keyCode;
if(touche ==13)
authentifier();

}
// ex:http://www.fotoweb.com	=> http://login:password@www.fotoweb.com
function getUrlBase(login,pwd) {
var ur = String(window.location);										// l'url en cours (http://www.fotoweb.com)
var suite = ur.substring(7,ur.length);									// on retire 'http://' (www.fotoweb.com)
if (suite.indexOf("@") != -1) {
suite = suite.substring(suite.indexOf("@")+1,suite.length);
}
var entete = "http://";
var lastSlash = suite.lastIndexOf("application/");
suite = suite.substring(0,lastSlash) + "application";
var result = entete + login + ":" + pwd +"@" + suite;
return result;
}
function selectionnerTheme(codeTheme,nbPhoto) {
top.frames['bas'].location.replace("fotoweb67.php?codeTheme="+codeTheme+"&nbPhoto="+nbPhoto);
}
function lienOver(id) {
id.className = "lienthemeHover";
}
function lienOut(id) {
id.className = "lientheme";
}
function cacherNavigation() {
top.frames['menuDroiteHaut'].location.replace("fotoweb66.html");
top.frames['menuDroiteBas'].location.replace("fotoweb66.html");
}
function updateMenu(page,codeTheme) {
if (page == 'A') {
window.parent.parent.location='../index.php';

} else {
if (page == 'X')
window.parent.parent.location='fotoweb.php?logout=true';
else{
top.frames['menu'].location.replace("fotoweb63.php?menu="+page+"&codeTheme="+codeTheme);
cacherNavigation();
}
}
}
function loginPublic() {
document.getElementById('res').value=screen.width+'*'+screen.height;
document.getElementById('formAuthent').submit();
}
function initPwd() {
document.getElementById('txtPwd').value = "";
document.getElementById('txtConfirm').value = "";
document.getElementById('txtLogin').select()
}
function selectChamp(idChamp) {
document.getElementById(idChamp).select();
}
function filtreParticipant(nbPhotos,nom,filter,ord) {
parent.frames['basAdmin'].location.replace("fotoweb23.php?nbPhotos="+nbPhotos+"&nom="+nom+"&filter="+filter+"&ord="+ord);
}
function filtreRobots(nbPhotos,nom,filter,ord) {
parent.frames['basAdmin'].location.replace("fotoweb24.php?nbPhotos="+nbPhotos+"&nom="+nom+"&filter="+filter+"&ord="+ord);
}
function filtreVisiteurs(nbLignes,nom,critDate,critNbVisit,critReferer,critResol,critHostname,critIP,critIdPhoto,critUserAgent) {
parent.frames['basAdmin'].location.replace("fotoweb25.php?nbLignes="+nbLignes+"&nom="+nom +"&critReferer="+critReferer  +"&critResol="+critResol +"&critHostname="+critHostname +"&critIP="+critIP +"&critIdPhoto="+critIdPhoto +"&critUserAgent="+critUserAgent +"&critDate="+critDate+"&critNbVisit="+critNbVisit);
}
function controleDate(pEvent,idDate) {
var date = document.getElementById('idDate').value;
if (((pEvent.keyCode < 96) || (pEvent.keyCode > 105))
&& ((pEvent.keyCode < 35) || (pEvent.keyCode > 39))
&& (pEvent.keyCode != 8)
&& (pEvent.keyCode != 9)
&& (pEvent.keyCode != 13)
&& (pEvent.keyCode != 16)
&& (pEvent.keyCode != 17)
&& (pEvent.keyCode != 45)
&& (pEvent.keyCode != 46)
&& (pEvent.keyCode != 32)) {
var tmpDate = date.substring(0,date.length-1);
document.getElementById('idDate').value = tmpDate;
}
}
function formatteDate(idDate) {
var date = document.getElementById('idDate').value;
if ((date.length != 8) && (date != "")) {
alert("Erreur de saisie.\nVeuillez saisir une date au format jj/mm/yyyy.");
idDate.focus();
} else if (date.length == 8) {
var jour = date.substring(0,2);
var mois = date.substring(2,4);
var year = date.substring(4,8);
var dateFormat = jour + "/" + mois + "/" +year;
document.getElementById('idDate').value = dateFormat;
}
}
function deFormatteDate(idDate) {
var date = document.getElementById('idDate').value;
if (date.length == 10) {
var jour = date.substring(0,2);
var mois = date.substring(3,5);
var year = date.substring(6,10);
var dateFormat = jour + mois + year;
document.getElementById('idDate').value = dateFormat;
}
function modifierIptc() {
document.getElementById('formAdmin').submit();
}
}
function showIPTC() {
var table = document.getElementById("tbIPTC");
if (table.style.display == "none") {
table.style.display = "block";
document.getElementById("scriptCookie").setAttribute('src',"fotoweb50.php?value=yes");

} else if (table.style.display == "block") {
table.style.display = "none";
document.getElementById("scriptCookie").setAttribute('src',"fotoweb50.php?value=no");

}

}
function updateOrdre(codeTheme,nbPhotos,nbResult,nbPage,sens,pano,chrono) {

majListePhotosOrdre(codeTheme,nbPhotos,'0',nbResult,pano,chrono);
updateNavigation(codeTheme,nbPhotos,nbResult,1,'',pano,chrono);
}
function ajouterMessage(message,nom) {
if (nom == "") {
alert("Veuillez saisir un nom");
document.getElementById('nom').focus();
} else if (message == "") {
alert("Veuillez saisir un message");
document.getElementById('idMessage').focus();
} else {
document.getElementById('formLivre').submit();
}
}
function compterCaractere() {
var txtMessage = document.getElementById('idMessage');
if (txtMessage.value.length > 430) {
txtMessage.value = txtMessage.value.substring(0,430);
} else {
var compteur = txtMessage.value.length;
document.getElementById('spCarac').innerHTML = compteur;
}
}
function modifierValeursPhoto() {

document.getElementById('formAdminPhoto').submit();

}
function logout() {
try{
loadScript("log_out","users/fotoweb88.php");
}catch(e){
window.location="index.php";

}

}
function loadScript(idScript,source) {
/* On créé l'attribut Id et on lui affecte la valeur "idScript" */
MyID = document.createAttribute("id");
MyID.nodeValue = idScript;
/* On créé l'attribut language=javascript  */
MyLanguage = document.createAttribute("language");
MyLanguage.nodeValue = "javascript";
/* On créé l'attribut type=text/javascript  */
MyType = document.createAttribute("type");
MyType.nodeValue = "text/javascript";
/* On créé l'attribut Src et on lui affecte le chemin du fichier source */
MySrc = document.createAttribute("src");
MySrc.nodeValue = source;
/* On créé la nouvelle balise <script> et lui attribut MyID et MySrc */
MyScript = document.createElement("script");
MyScript.setAttributeNode(MyLanguage);
MyScript.setAttributeNode(MyType);
MyScript.setAttributeNode(MyID);
MyScript.setAttributeNode(MySrc);
/* On place la balise dans le document */
document.documentElement.appendChild(MyScript);
}
