// JavaScript Document
var w = null;

function wClose() {
	if ( w != null ) {
		w.close();
		w = null;
	}
}

function fOpen( fImage, fWidth, fHeight ) {
	var wMargin = 20, hMargin = 30;
	
	wClose();
	
	fWidth = parseInt( fWidth );
	fHeight = parseInt( fHeight );
	
	w = window.open( fImage, "photo", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + ( fWidth + wMargin ) + ',height=' + ( fHeight + hMargin ) );
	
	return false;
}

function preview( thumbnail ) {
	document.getElementById( 'photo_preview' ).src = thumbnail;
	return false;
}

function setDelPhotosList() {
	var field    = document.forms['photosForm'].elements['photosDelList'];	
	var cbArray  = document.forms['photosListForm'].elements['checkboxesArray'];
	var lstField = document.forms['photosForm'].elements['photosDelList'];
	var str      = '';
	// var result;
	
	// Recuperation de la liste des photos cochees,
	for ( var i = 0; i < cbArray.length; i++ ) {
		if ( cbArray[i].checked ) {
			if ( str.length > 0 ) {
				str += ',';
			}
			str += cbArray[i].value;
		}
		
	}
	
	// Fixation de la liste dans le champs cache pour postage par formulaire
	lstField.value = str;
	
	return( str.length > 0 );
}

// 
function confirmGalleryDeletion() {
	var msg = "Confirmez-vous la suppression de cette galerie et de tout son contenu (photos et sous-galeries) ?";
	return( confirm( msg ) );
}