function opendiapo(modediapo,typealbum,photo,album,title_album,tri,sens,q,nbsec,indice,pause,special){
empty_cache();
if(nbsec!=''){
	if (modediapo=='POPUP')
	window.open('diapo.php?typealbum='+typealbum+'&album='+album+'&title_album='+title_album+'&tri='+tri+'&sens='+sens+'&q='+q+'&nbsec='+nbsec+'&indice='+indice+'&pause='+pause+''+special,'photos','width=820,height=720,top=5,left=100')
	else
	window.location='./?p=photos&display=diapo&typealbum='+typealbum+'&album='+album+'&title_album='+title_album+'&tri='+tri+'&sens='+sens+'&q='+q+'&nbsec='+nbsec+'&indice='+indice+'&pause='+pause+''+special
	} //if(nbsec!=''){
}

function display_album(modediapo,typealbum,photo,album,title_album,tri,sens,q,nbsec,indice,pause,special,display){

empty_cache();
if(!isNaN(nbsec))
opendiapo(modediapo,typealbum,photo,album,title_album,tri,sens,q,nbsec,indice,pause,special);

else{

window.location='./?p=photos&typealbum='+typealbum+'&album='+album+'&title_album='+title_album+'&tri='+tri+'&sens='+sens+'&pause='+pause+'&display='+display+special;//,'photos','width=800,height=680,top=3,left=100')

}
}
function nbphotos(NB,sens){
document.getElementById("IF_ACTION").src='action.php?action=nbphotos&nb='+NB+'&sens='+sens;
}

function nbphotos_custom(nb_X,nb_Y){
	document.getElementById("IF_ACTION").src='action.php?action=nbphotos_custom&nb_X='+nb_X+'&nb_Y='+nb_Y;
}


function empty_cache(){
document.getElementById('cache').innerHTML='';
}

function checkUncheckAll(theElement,nameElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name == nameElement){
	  theForm[z].checked = theElement.checked;
	  }
     }
 }

function toProperCase(s)
{
  return s.toLowerCase().replace(/^(.)|\s(.)/g, 
          function($1) { return $1.toUpperCase(); });
}


function deletealbumperso(id_albumperso){
if(confirm('Supprimer cet album perso')){
document.getElementById('id_albumperso').value=id_albumperso;
document.getElementById('actionpost').value='delete';
document.form_albumperso.submit();
}
}


function editalbumperso(id_albumperso){
document.getElementById('id_albumperso_'+id_albumperso).className='';
document.getElementById('btnsav_'+id_albumperso).style.display='block';
document.getElementById('btnedit_'+id_albumperso).style.display='none';
}


function savealbumperso(id_albumperso){
document.getElementById('id_albumperso').value=id_albumperso;
document.getElementById('actionpost').value='update';
document.getElementById('nom_albumperso').value=document.getElementById('id_albumperso_'+id_albumperso).value;
if (verifNomAlbum('nom_albumperso')){
document.form_albumperso.submit();}
}


// fonction du click droit 
function addtoalbum(id,typealbum){
addphototoalbum(id,document.getElementById('input_id_photo').value,typealbum)
}

function rmvtoalbum(id,typealbum){
delphotofromalbum(id,document.getElementById('input_id_photo').value,typealbum)
}


function addphototoalbum(id,id_photo,typealbum){
document.getElementById("IF_ACTION").src='action.php?id_photo='+id_photo+'&id_album'+typealbum+'='+id+'&action=addtoalbum'+typealbum;
}

function delphotofromalbum(id,id_photo,typealbum){
document.getElementById("IF_ACTION").src='action.php?id_photo='+id_photo+'&id_album'+typealbum+'='+id+'&action=delfromalbum'+typealbum;
}


// pour le mode diapo
function addphototoalbumperso(id_albumperso,id_photo){
document.getElementById("IF_ACTION").src='action.php?id_photo='+id_photo+'&id_albumperso='+id_albumperso+'&action=addtoalbumperso';
}

function delphotofromalbumperso(id_albumperso,id_photo){
document.getElementById("IF_ACTION").src='action.php?id_photo='+id_photo+'&id_albumperso='+id_albumperso+'&action=delfromalbumperso';
}

function mailphoto(id_photo){
window.open('mailphoto.php?id_photo='+id_photo,'mailphoto','width=650,height=400,top=250,left=300');
}

function email(id_photo){
id_photo=(id_photo==null)?document.getElementById('input_id_photo').value:id_photo;
mailphoto(id_photo);
}

function negatif(id_photo){
id_photo=(id_photo==null)?document.getElementById('input_id_photo').value:id_photo;
window.open('./action.php?id_photo='+id_photo+'&action=negatif');
}

function printphoto(id_photo){
id_photo=(id_photo==null)?document.getElementById('input_id_photo').value:id_photo;
window.open('./action.php?id_photo='+id_photo+'&action=print');
}

function createcard(id_photo){
id_photo=(id_photo==null)?document.getElementById('input_id_photo').value:id_photo;
window.location='./?p=createcard.form&id_photo='+id_photo;
}

function infos(id_photo){
id_photo=(id_photo==null)?document.getElementById('input_id_photo').value:id_photo;
document.getElementById("IF_ACTION").src='./action.php?id_photo='+id_photo+'&action=infos';
}

function mailfile(file){
window.open('mailphoto.php?filepath='+file,'mail','width=650,height=350,top=250,left=300');
}

function cache(cache){	
	document.getElementById('cache').innerHTML=cache;	
}

function deletefile(fichier){
if(confirm('Voulez vous supprimer ce fichier ?'))
document.getElementById("IF_ACTION").src='./action.php?fichier='+fichier+'&action=deletezip';
}

function home(){
window.location='./'
}


//////////////
function show_selected_action(action_number,is_admin,nb,display){
if (action_number!='' ){
action_max=(is_admin)?9:6;

for(i=1;i<action_max;i++){
	document.getElementById('action_'+i).style.display='none';
	if (display=='page' || display=='oldbook') hideshow_check(nb,'none')
	}
	
	if (action_number>=1 ){
	document.getElementById('action_'+action_number).style.display='';
	//document.getElementById.('id_photo[]').style.display='';
	if (display=='page' || display=='oldbook') hideshow_check(nb,'')
	}
	//document.getElementById('actiontodo').value=action_number;
}
}

function hideshow_check(nb,action){


for (var i = 0; i < nb; i ++)
{
   document.getElementById('span_'+i).style.display=action;  
   
}
}


function int_blur(id,valeur,strict){

if(isNaN(valeur)){
alert('La valeur ' +id+' n\'est pas correct.');
document.getElementById(id).focus();return;
}
else {
if(valeur<0 ){
alert('La valeur ' +id+' doit être positive.');
document.getElementById(id).focus();return;
}

if(valeur==0 && strict){
alert('La valeur ' +id+' doit être positive.');
document.getElementById(id).focus();return;
}
}
}


function verif_selected_photos(){
//return false;
theForm=document.forms['action_form'];
nameElement='id_photo[]';
for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name == nameElement){
	  if (theForm[z].checked==true) {;return true;}
	  }
     }
alert('Vous n\'avez sélectionné aucune photos.');
return false;
}


/////////////////util
function getRadioValue(radio) {
      for (var i=0; i<radio.length;i++) {
         if (radio[i].checked) {
            return radio[i].value;
         }
      }
   }
   
   
function isOKKeyPress(champ,e){

key = window.event ? e.keyCode : e.which;


if (!((key <=122 && key>=97)|| (key <=90 && key>=65) || (key <=57 && key>=48) || key==95 || key==32 || key==8 || key==46 || key==37 || key==39)) {
if(window.event) e.keyCode=0;
else e.preventDefault();

} 

} // function

// vérification nom panier ou theme
function nomAlbum (texte) {
	 // on teste ici si la chaine ne contient bien
	 // que des caractères alphanum&eacute;rique, minuscules ou majuscules
	 // sur 255 caractères
	if (texte=='') {alert('Veuillez saisir le nom .');return false};
	var comparaison = /^[a-zA-Z0-9_ /]{0,255}$/g;
	if ( comparaison.test(texte))
	{
	  return true;
	} 
	else
	{
	  alert('Les seuls charactères autorisés  sont \n  .les chiffres,\n  .les lettres sans accent, \n  .le charactère underscore : _,\n  .le charactère slash : /');
	  return false;
	}
	}
	function verifNomAlbum(idChamp){
		if(document.getElementById(idChamp).value==''){
		alert('veuillez choisir un nom');
		return false;
		}
		else{
		return nomAlbum(document.getElementById(idChamp).value);
		}
		return true;
	}
