function RetourSuite(form, valeur ) { 
		if (form.ID) form.ID.value="";
		if (form.RechercheCach) form.RechercheCach.value="";
		if (form.NumPage) form.NumPage.value=valeur;
		// EN FONCTION DE LA METHODE UTILISEE DANS LE FORMULAIRE
		if (form.method.toLowerCase() == 'get') {
			var URLTempo=""
			for (var i=0;i<form.elements.length;i++){ 
				if (form.elements[i].name && form.elements[i].value && form.elements[i].name.slice(0,6) != "check_"){
					//alert("form.elements[i]="+form.elements[i].name+"  -*-> "+form.elements[i] +"="+ form.elements[i].value )
					if (URLTempo!="" ) URLTempo+="&"
					URLTempo+= form.elements[i].name + "=" + escape(form.elements[i].value)
				}
			
			}
			var URLtempo2=document.location + ""
			if (URLtempo2.indexOf("?")>0)	URLtempo2=URLtempo2.substring(0,URLtempo2.indexOf("?"))
			document.location=URLtempo2+"?"+URLTempo
		} else {
			form.submit();
		}
}


function ScreenBig() { // Parametres: ID (identifiant de l'image) , W_width, W_height (taille de la fenetre) 
	var ID=ScreenBig.arguments[0]
	var Formulaire = document.FormRecherche;
	if (ScreenBig.arguments.length>0){
		W_width=ScreenBig.arguments[1]
		W_height=ScreenBig.arguments[2]
	}else{
		W_width=400
		W_height=400
	}
	
	var SPC=""
	if(Formulaire.SPC && Formulaire.SPC.value){
		SPC=Formulaire.SPC.value;
	}
	
	var OrderBySpecifique=""
	if(Formulaire.OrderBySpecifique){
		if (Formulaire.OrderBySpecifique.options) {
			OrderBySpecifique=Formulaire.OrderBySpecifique.options[Formulaire.OrderBySpecifique.selectedIndex].value;
		} else {
			OrderBySpecifique=Formulaire.OrderBySpecifique.value;
		}
	}
	
	var NewImages="";
	if(Formulaire.NewImages && Formulaire.NewImages.value){
		NewImages=Formulaire.NewImages.value;
	}
	
	var NombreNouvelleImage="";
	if(Formulaire.NombreNouvelleImage && Formulaire.NombreNouvelleImage.value){
		NombreNouvelleImage=Formulaire.NombreNouvelleImage.value;
	}
	
	var MotRechercheID="";
	if(Formulaire.MotRechercheID && Formulaire.MotRechercheID.value){
		MotRechercheID=Formulaire.MotRechercheID.value;
	}
	
	tempo="/" + "Consulter" + "/" + "GrandEcran" + "." + "a" + "s" + "p" + "?" + "ID="+ID+"&ListeAnd="+escape(document.FormRecherche.ListeAnd.value)+"&ListeOr="+escape(document.FormRecherche.ListeOr.value)+"&ListeNot="+escape(document.FormRecherche.ListeNot.value)+"&MotRecherche="+escape(document.FormRecherche.MotRecherche.value)+"&TypeRecherche="+escape(document.FormRecherche.TypeRecherche.value)+"&SPC="+SPC+"&OrderBySpecifique="+OrderBySpecifique+"&NewImages="+NewImages+"&NombreNouvelleImage="+NombreNouvelleImage+"&MotRechercheID="+MotRechercheID;
	if (document.FormRecherche){
		document.FormRecherche.RechercheCach.value="";
		document.FormRecherche.ID.value=ID;
		
		
		ObjDocumentApercu=document
		obj=RechercheFrame(top , "GrandFormat")
		if (obj) {
			obj.document.location=tempo
		}else{
			cartGrandFormat = window.open(tempo,"cartGrandFormat","toolbar=no, resizable=yes,status=yes,scrollbars=no,width="+W_width+",height="+W_height);
			//cart.focus();
			//mywinname02=openIT(tempo, W_width, W_height, 200, 100, 'GrandFormat', 'Grand Format')
		}
	}
}

function Detail() { // Parametres: ID (identifiant de l'image) , W_width, W_height (taille de la fenetre) , formulaire , Chemin
	var ID=Detail.arguments[0];
	var Chemin = '';
	var Formulaire = document.FormRecherche;
	if (Detail.arguments.length>0){
		W_width=Detail.arguments[1]
		W_height=Detail.arguments[2]
		
		if (Detail.arguments.length>=3 && typeof(Detail.arguments[3])!='undefined' && Detail.arguments[3] != '') {Formulaire=Detail.arguments[3]}
		if (Detail.arguments.length>=4 && typeof(Detail.arguments[4])!='undefined') {Chemin=Detail.arguments[4]}
	}else{
		W_width=400
		W_height=400
	}
	
	var SPC=""
	if(Formulaire.SPC && Formulaire.SPC.value){
		SPC=Formulaire.SPC.value;
	}
	
	var OrderBySpecifique=""
	if(Formulaire.OrderBySpecifique){
		if (Formulaire.OrderBySpecifique.options) {
			OrderBySpecifique=Formulaire.OrderBySpecifique.options[Formulaire.OrderBySpecifique.selectedIndex].value;
		} else {
			OrderBySpecifique=Formulaire.OrderBySpecifique.value;
		}
	}
	
	var NewImages="";
	if(Formulaire.NewImages && Formulaire.NewImages.value){
		NewImages=Formulaire.NewImages.value;
	}
	
	var NombreNouvelleImage="";
	if(Formulaire.NombreNouvelleImage && Formulaire.NombreNouvelleImage.value){
		NombreNouvelleImage=Formulaire.NombreNouvelleImage.value;
	}
	
	var MotRechercheID="";
	if(Formulaire.MotRechercheID && Formulaire.MotRechercheID.value){
		MotRechercheID=Formulaire.MotRechercheID.value;
	}
	
	if (document.getElementById('MotRecherche')) {
		tempo= Chemin + "Detail" + "." + "a" + "s" + "p" + "?" + "GalerieID="+Formulaire.GalerieID.value+"&ID="+ID+"&ListeAnd="+escape(Formulaire.ListeAnd.value)+"&ListeOr="+escape(Formulaire.ListeOr.value)+"&ListeNot="+escape(Formulaire.ListeNot.value)+"&MotRecherche="+escape(document.getElementById('MotRecherche').value)+"&TypeRecherche="+escape(document.getElementById('TypeRecherche').value)+"&SPC="+SPC+"&OrderBySpecifique="+OrderBySpecifique+"&NewImages="+NewImages+"&NombreNouvelleImage="+NombreNouvelleImage+"&MotRechercheID="+MotRechercheID;
	} else {
		tempo= Chemin + "Detail" + "." + "a" + "s" + "p" + "?" + "GalerieID="+Formulaire.GalerieID.value+"&ID="+ID+"&ListeAnd="+escape(Formulaire.ListeAnd.value)+"&ListeOr="+escape(Formulaire.ListeOr.value)+"&ListeNot="+escape(Formulaire.ListeNot.value)+"&MotRecherche="+escape(Formulaire.MotRecherche.value)+"&TypeRecherche="+escape(Formulaire.TypeRecherche.value)+"&SPC="+SPC+"&OrderBySpecifique="+OrderBySpecifique+"&NewImages="+NewImages+"&NombreNouvelleImage="+NombreNouvelleImage+"&MotRechercheID="+MotRechercheID;
	}
	if (Formulaire){

	// Guillaume 7 septembre 2007 : j'ai enlevé les 2 lignes suivantes 
	// Je ne vois pas a quoi ca sert et ca provoque un bug si on clique sur une vignette et que l'on change le numero de page dans un champs text puis [Entrée] 
	//	=> ca s'affiche alors comme une page détail !
	//	Formulaire.RechercheCach.value="";
	//	Formulaire.ID.value=ID;
		if ( (obj=RechercheFrame(top , "frame_1")) ) {
			obj2=RechercheFrame(top , "onglets");
			if (obj2) {obj2.showFrame(1);}
			obj.location="/Consulter/"+tempo;
		} else {
			ObjDocumentApercu=document
			if ( (obj=RechercheFrame(top , "Detail")) ) {
				obj.document.location=tempo
			}else{
				cartDetail = window.open(tempo,"cartDetail","toolbar=no, resizable=yes,status=yes,scrollbars=yes,width="+W_width+",height="+W_height);
				//window.focus();
				//Guillaume : pourquoi il y avait ce window.focus(); ???
				
				//mywinname01=openIT(tempo, W_width, W_height, 200, 100, 'cartDetail', 'Détail')
			}
		}
	}
}

function DetailVideo() { // Parametres: ID (identifiant de l'image) , W_width, W_height (taille de la fenetre) , formulaire , Chemin
	ID=DetailVideo.arguments[0]
	var Chemin = '';
	var Formulaire = document.FormRecherche;
	if (DetailVideo.arguments.length>0){
		W_width=DetailVideo.arguments[1]
		W_height=DetailVideo.arguments[2]
		
		if (DetailVideo.arguments.length>=3 && typeof(DetailVideo.arguments[3])!='undefined' && DetailVideo.arguments[3] != '') {Formulaire=DetailVideo.arguments[3]}
		if (DetailVideo.arguments.length>=4 && typeof(DetailVideo.arguments[4])!='undefined') {Chemin=DetailVideo.arguments[4]}
	}else{
		W_width=400
		W_height=400
	}
	
	var SPC=""
	if(Formulaire.SPC && Formulaire.SPC.value){
		SPC=Formulaire.SPC.value
	}
	
	var OrderBySpecifique=""
	if(Formulaire.OrderBySpecifique && Formulaire.OrderBySpecifique.options){
		OrderBySpecifique=Formulaire.OrderBySpecifique.options[Formulaire.OrderBySpecifique.selectedIndex].value;
	}
	
	tempo= Chemin + "/Consulter/Detail" + "." + "a" + "s" + "p" + "?" + "Video=1&GalerieID="+Formulaire.GalerieID.value+"&ID="+ID+"&ListeAnd="+escape(Formulaire.ListeAnd.value)+"&ListeOr="+escape(Formulaire.ListeOr.value)+"&ListeNot="+escape(Formulaire.ListeNot.value)+"&MotRecherche="+escape(Formulaire.MotRecherche.value)+"&TypeRecherche="+escape(Formulaire.TypeRecherche.value)+"&SPC="+SPC+"&OrderBySpecifique="+OrderBySpecifique
	if (Formulaire){

	// Guillaume 7 septembre 2007 : j'ai enlevé les 2 lignes suivantes 
	// Je ne vois pas a quoi ca sert et ca provoque un bug si on clique sur une vignette et que l'on change le numero de page dans un champs text puis [Entrée] 
	//	=> ca s'affiche alors comme une page détail !
	//	Formulaire.RechercheCach.value="";
	//	Formulaire.ID.value=ID;
		if ( (obj=RechercheFrame(top , "frame_1")) ) {
			obj2=RechercheFrame(top , "onglets");
			if (obj2) {obj2.showFrame(1);}
			obj.location="/Consulter/"+tempo;
		} else {
			ObjDocumentApercu=document
			
			if ( (obj=RechercheFrame(top , "Detail")) ) {
				obj.document.location=tempo
			}else{
				cartDetail = window.open(tempo,"cartDetail","toolbar=no, resizable=yes,status=yes,scrollbars=yes,width="+W_width+",height="+W_height);
				//window.focus();
				//Guillaume : pourquoi il y avait ce window.focus(); ???
				
				//mywinname01=openIT(tempo, W_width, W_height, 200, 100, 'cartDetail', 'Détail')
			}
		}
	}
}

function FermeDetail() {
		obj=RechercheFrame(top , "frame_1");
		obj2=RechercheFrame(top ,'onglets');
		if ((obj) || (obj2)) {
			obj2.hideFrame(4);
		} else {
			top.window.close();
		}
}

function Apercu(form,NumPage) {
	
		form.NomGabarit.value = "Apercu";
		form.NbreParPage.value = NbreParPageMaxi
		
		if (form.NumPage){
			form.NumPage.value = Math.ceil(NumPage/NbreParPageMaxi);
		}
		
		form.ID.value = "";
		form.RechercheCach.value="";
		form.submit();
}



function RechercheApercu(info){ // document, ListeAND,GalerieID
	var GalerieID
	var ListeAND
	a=RechercheApercu.arguments;
	ListeAND = (a[1])?a[1]:"";
	GalerieID = (a[2])?a[2]:"";
	var ObjDocumentApercu=false
	//recherche de la frame Apercu
	var tempo_Obj
	if (top.frames.length==0){// pas de frames
		//Y a t-il un window.opener ?
		if (!window.opener) {
			ObjDocumentApercu= document
		}
		else{
			// SI ON A 2 FRAMES (UNE FENETRE SANS FRAME EST CONSIDERE COMME UNE FRAME, window.opener.top.frames.length EST FORCEMENT AU MOINS EGAL A 1)
			if ((window.opener.top.frames.length == 1) || (window.opener.top.frames.length == 2 && window.opener.top.frames[0].name == 'gauche')){
				if (window.opener.SearchLaunchMotsCles || window.opener.chargePageNextNavigationOn) {
					window.opener.document.FormRecherche.TypeRecherche.value = '-99';
					window.opener.document.FormRecherche.MotRecherche.value = '';
					if (window.opener.document.FormRecherche.MotRechercheID) window.opener.document.FormRecherche.MotRechercheID.value = '';
					window.opener.document.FormRecherche.ListeAnd.value = ListeAND;
					window.opener.document.FormRecherche.ListeOr.value = '';
					window.opener.document.FormRecherche.ListeNot.value = '';
					window.opener.document.FormRecherche.ListeMotsClesOK.value = '1';
					window.opener.document.FormRecherche.GalerieID.value = GalerieID;
					if (window.opener.document.FormRecherche.NewImages) window.opener.document.FormRecherche.NewImages.value = '';
					if (window.opener.document.FormRecherche.NombreNouvelleImage) window.opener.document.FormRecherche.NombreNouvelleImage.value = '';
					if (window.opener.SearchLaunchMotsCles) {
						window.opener.SearchLaunchMotsCles();
					} else {
						window.opener.chargePageNextNavigationOn(1);
					}
					return false;
				}
			} else {
				obj=RechercheFrame(window.opener.top , "Apercu")
				if (obj) ObjDocumentApercu= obj.document
				
				
				if (!ObjDocumentApercu) {
					obj=RechercheFrame(window.opener.top , "principal")
					if (obj) ObjDocumentApercu= obj.document
				}
				if (!ObjDocumentApercu) {
					obj=RechercheFrame(window.opener.top , "Site")
					if (obj) ObjDocumentApercu= obj.document
				}
				if (false && !ObjDocumentApercu) {
					obj=RechercheFrame(window.opener.top , "contenuFrameSet")
					if (obj) ObjDocumentApercu= obj.document
				}
			}
		} 
	}
	else{	//il y a des frames
		obj=RechercheFrame(top , "Apercu")
		if (obj) ObjDocumentApercu= obj.document
	} 
	if (!ObjDocumentApercu) {
		obj=RechercheFrame(top , "principalFrame")
		if (obj) ObjDocumentApercu= obj.document
	}
	if (!ObjDocumentApercu) {
		obj=RechercheFrame(top , "Site")
		if (obj) ObjDocumentApercu= obj.document
	}

	if (!ObjDocumentApercu) {
		if ( (top.opener) && (!top.opener.closed) ) { 
			if (top.opener.window && top.opener.window.top ){
				if (!obj) {obj=RechercheFrame( top.opener.window.top , "Apercu")}
				if (!obj) {obj=RechercheFrame( top.opener.window.top , "principal")}
				if (!obj) {obj=RechercheFrame( top.opener.window.top , "Site")}
				if (obj) {
					ObjDocumentApercu= obj.document
					top.opener.window.focus();
					top.window.blur()
					
				}
			}
		}
	}

	if (!ObjDocumentApercu) {
		//alert("Bouh, j'trouve pas:");
		ObjDocumentApercu=document
	}
	
	ObjDocumentApercu.location="/" + "consulter" + "/" + "apercu" + "." + "a" + "s" + "p" + "?" + "GalerieID="+GalerieID+"&ListeAND="+ListeAND+"&TypeRecherche=-99"
}

function erreurGestionRecherche() {
	BRechercheFrameOK=false
	return true 
}

BRechercheFrameOK=true
function RechercheFrame(Objet , nom){
	//***********************************************************************************
	//**attention a bien avoir des frames contenant effectivement un CONTENU et un NOM **
	//***********************************************************************************
	if (Objet){ 
		var obj
		for (var i=0; i<Objet.frames.length;i++){
			if ((obj=RechercheFrame(Objet.frames[i] , nom))!=false) return obj
			BRechercheFrameOK=true
			self.window.onerror=erreurGestionRecherche;
			if (BRechercheFrameOK && Objet.frames[i]){
				//self.window.onerror=erreurGestionRecherche;
				//alert(nom+"=="+Objet.frames[i].name)
				self.window.onerror=erreurGestionRecherche;
				if (BRechercheFrameOK && Objet.frames[i].name){
					self.window.onerror=erreurGestionRecherche;
					if (BRechercheFrameOK && Objet.frames[i].name==nom)  return Objet.frames[i]
				}
			}
			
		}
	}
	return false
}





function ValidChaine(Chaine,ValidCar){
	var allValid = true;
	LenChaineOK = ValidCar.length;
	
	while (LenChaineOK>0 && ValidChaine) {
		LenChaineOK--;
		Car = ValidCar.charAt(0);
		
		if (Chaine.indexOf(Car) == -1) {
			allValid = false;
			break;
		} else {
			ValidCar = ValidCar.substr(1)
		}
	}
  return allValid;
}


