// ============================ APPLETS STANDARD AMFNET V4.0.6 om=01 ================================== 22-08-05
// JAVASCRIPT T COSQUER
// ================================================================================== S A I S I E   /    F O R M
// ================================ CHAMPS DE SAISIE
// test la présence de non alphanumérique nom de domaine par exemple sans le TLD
function if_no_alpha(s){
       var re,r ,err,s;
	 re = new RegExp("[^A-Za-z0-9\\-]","i");
	 r  = new RegExp("[.]","i");
	 err = s.match(re);
	//alert('Code ' + err);
	 return(err);
}
// test
function selected_all(champ){
champ.select();
}

// Positionne l'attribut obligatoire à true pour tous les champs spécifiés
function requiredFields(frm)
{
	for (var i=1; i<requiredFields.arguments.length; i++)
	{
		frm[requiredFields.arguments[i]].required = true;
	}
}

// Positionne l'attribut numérique à true pour tous les champs spécifiés
function numericalFields(frm)
{
	for (var i=1; i<numericalFields.arguments.length; i++)
	{
		frm[numericalFields.arguments[i]].numerical = true;
	}
}

// Positionne l'événement onfocus pour gérer l'autoselect pour tous les champs spécifiés
function autoselectFields(frm)
{
	for (var i=1; i<autoselectFields.arguments.length; i++)
	{
		frm[autoselectFields.arguments[i]].onfocus = selectField;
	}
}

// Positionne l'attribut format au format spécifié pour tous les champs spécifiés
function formatedFields(frm)
{
	for (var i=1; i<formatedFields.arguments.length; i+=2)
	{
		frm[formatedFields.arguments[i]].format = formatedFields.arguments[i+1];
	}
}

// ============================Vérifie tous les chamsp de la form
function checkAll(frm)
{
	for (var i=0; i<frm.elements.length; i++)
	{
		var fld = frm.elements[i];
		if (fld.required && !checkRequired(fld))
		{
			return fldError(fld, "Le champ " + fld.name + " est obligatoire!")
		}
		if (fld.numerical && !checkNumerical(fld))
		{
			return fldError(fld, "Le champ " + fld.name + " est numérique!")
		}
		if ((fld.format != null) && !checkFormat(fld))
		{
			return fldError(fld, "Le champ " + fld.name + " a le format suivant : " + fld.format + "\n\nRappel :\nX = Caractère quelconque\nA = Lettre\n9 = Chiffre")
		}
	}
	return true
}
// ===========================Vérifie tous les chamsp du formulaire en mode multilingue
function checkAll_lang(frm,txt_tab,name_tab)
{ // positionner les tabindex sur les input de formulaire
// et déclarer les tableau
	for (var i=0; i<frm.elements.length; i++)
	{
		var fld = frm.elements[i];
		
		if(name_tab){
		idx = fld.tabIndex;
		field_name = name_tab[idx];
		}else{
		idx = i;
		field_name = fld.name;
		}
		
		if (fld.required && !checkRequired(fld))
		{
			return fldError(fld, idx + " : " + txt_tab[0] + field_name + txt_tab[1])
		}
		if (fld.numerical && !checkNumerical(fld))
		{
			return fldError(fld, idx + " : " + txt_tab[0] + field_name + txt_tab[2])
		}
		if ((fld.format != null) && !checkFormat(fld))
		{
			return fldError(fld, idx + " : " + txt_tab[0] + field_name + txt_tab[3] + ": " + fld.format + txt_tab[4])
		}
	}
	return true
}

// ========================================Regarde si le champ est vide
function checkRequired(fld)
{
	if (fld.value.length == 0 )
	{
		return false
	}
	return true
}

// =================================Vérifie si le champ a le bon format
function checkFormat(fld)
{
	var val = fld.value;

	// S'il est vide, c'est ok
	if (val.length == 0)
	{
		return true
	}
	// Si la longueur n'est pas bonne, pas la peine d'aller plus loin
	if (val.length != fld.format.length)
	{
		return false
	}
	// Vérifie chaque caractère en fonction de son format
	for (var i=0; i<val.length; i++)
	{
		fchar = fld.format.charAt(i);
		vchar = val.charAt(i);
		switch(fchar)
		{
			case "A" :
				if (isDigit(vchar))
				{
					return false
				}
				break;
			case "9" :
				if (!isDigit(vchar))
				{
					return false
				}
				break;
			case "X" :
				break;
			default :
				if (fchar != vchar)
				{
					return false
				}
		}
	}
	return true
}

// ==================================Regarde si le champ est un nombre
function checkNumerical(fld)
{
	var val = fld.value;

	// Retire le signe s'il est présent
	if (val.charAt(0) == "-" || val.charAt(0) == "+")
	{
		val = val.slice(1)
	}

	// Retire le point (on pourrait utiliser un autre séparateur)
	val = val.replace(/\./, "");

	// Verifie chaque caractère
	for (var i=0; i<val.length; i++)
	{
		if (!isDigit(val.charAt(i)))
		return false
	}
	return true
}

// ================================Affiche l'erreur et sélectionne le champ
function fldError(fld, msg)
{
	fld.focus();
	fld.select();
	alert(msg);
}

// =================================Pour l'autoselect, sélectionne le champ
function selectField()
{
	this.select();
}

// =============================Retourne true si le caratère est un chiffre
function isDigit(digit)
{
	// Tous les caratères accéptés
	var charOk = "0123456789";
	return !(charOk.indexOf(digit) == -1)
}

// =====================================Sélectionne la valeur dans la liste
function selectValue(fld, val)
{
	for (var i=0; i < fld.options.length; i++)
	{
		if (fld.options[i].value == val)
		{
			fld.options[i].selected = true;
		}
	}
}
// ========================Test si une valeur est selectionnée dans un SELECT
function selectTest(fld,valeur_vide)
{  	if (fld.value == valeur_vide)
		{
			return true;
		}else{
	      	return false;
		}
}
// =====================================test si un bouton radio est coché?
function testerRadio(radio) {
	
      for (var i=0; i < radio.length;i++) {
         if (radio[i].checked) {
            return 'oui';
         }
      }
	return 'non';
}
//========================================teste si une checkbox est coché?
function testercheckbox(check_box) {
      for (var i=0; i < check_box.length;i++) {
         if (check_box[i].checked) {
            return true;
         }
      }
	return false;
}
//===============================assigne une coche au bouton radio 
function assignRadio(radio,val) {
      for (var i=0; i < radio.length; i++) {
           
	   if (radio[i].value==val) {
         
            radio[i].checked=true;
         }
      }return;
}
//==============================retourne la valeur du bouton radio coché
function valueRadio(radio) {
      for (var i=0; i < radio.length; i++) {
         if (radio[i].checked) {
            return radio[i].value;
         }
      }return false;
}
// Verifie une Adresse EMAIL

//================================vérifie l'adresse mail d'un formulaire
function CheckEmail(str) {
	// support des regular expressions par le browser ?
	var supported = 0;
	if (window.RegExp) {
	var tempStr = "a";
	var tempReg = new RegExp(tempStr);
	if (tempReg.test(tempStr)) supported = 1;
	}
	// si non, test de la presence d'un . et d'un @
	if (!supported) return (str.indexOf(".") < 2) && (str.indexOf("@") > 0);
	
	// si oui, test syntaxique de l'email
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function effacer_form(formulaire,hid){
for (var i=0; i<formulaire.length; i++){
if (formulaire.elements.type=="radio" || formulaire.elements[i].type=="checkbox") {formulaire.elements[i].checked=false;}
else if (formulaire.elements[i].type=="select-one") {formulaire.elements[i].options[0].selected=true;}
else if (formulaire.elements[i].type=='hidden' && !hid) { formulaire.elements[i].value="";}
else if (!(formulaire.elements[i].type=='reset' || formulaire.elements[i].type=='submit' || formulaire.elements[i].type=='button')) {formulaire.elements[i].value="";}
}
}


// ================================================================================FUNCTIONS INTERACTIVES / SITE

var posBan4=0, ban4, delaiBan4, msgBan4; 

function banniere4(delai) { 
delaiBan4 = delai; 
if (posBan4 >= msgBan4.length) posBan4 = 0; 
else if (posBan4 == 0) { msgBan4 = ' ' + msgBan4; while (msgBan4.length < 128) 
msgBan4 += ' ' + msgBan4; } 
window.status = msgBan4.substring(posBan4,posBan4+msgBan4.length); 
posBan4++; 
ban4 = setTimeout("banniere4(delaiBan4)",delai);

}

// ========================================creation d'un COOKIE
function set_cookie(nom,valeur,heures){
	var expireDate = new Date();
	expireDate.setTime(expireDate.getTime() + ( heures * 3600 * 1000));
	document.cookie = nom + "=" +escape(valeur) + ";expires=" + expireDate.toGMTString();
	return;
}
function EcrireCookie(nom, valeur)
{
var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}
function getCookieVal(offset)
{
var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function LireCookie(nom)
{
var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{
var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;

}
return null;
}//-->
// ======================================= Fonction d'appel de traducteur
function open_translate(mode,champ_pere,formulaire,champ_fils){
 
 var datas_in=false;
 if(champ_pere){
 datas_in = document.forms[formulaire].elements[champ_pere].value;
 }
 if(datas_in){
 //var datas_out = showModalDialog( "../include/translate.php?mode="+ mode + "&text=" + datas_in, '', "font-family:Verdana; font-size:12; dialogWidth:736px; dialogHeight:912px;status:0" );
 var datas_out = amf_popup("trans","../include/translate.php?mode="+ mode + "&text=" + datas_in,560,690, 'resizable=1, menubar=no, status=no, scrollbars=yes');

if(datas_out) {
  if(champ_fils){
   document.forms[formulaire].elements[champ_fils].value	=	date_out;	
  }
 }
 }else{
	alert("Aucun texte n'est présent dans le champ origine (Origine = Français pour la traduction vers l'anglais, l'italien, l'espagnol, l'allemand ou Anglais pour la traduction vers le russe)"); 
 }
}

// ===============================================mise en page de démarrage

function HomePage(obj,lien)
{ 
  if (nav()=="IE") { 

	obj.style.behavior='url(#default#homepage)';
	obj.setHomePage(lien);
	
  }else if(window.sidebar){
	
    alert("Désolé cette fonction n'est pas supportée par votre navigateur\nSorry, this function is not available on your Internet browser");	
	
  }
}
//============================================================ BOOKMARK
function addbookmark (siteNOM, siteURL ) { 

/*-- MESSAGE --*/ 
    function myMessage (raccourciClavier) { 
        alert ("Utilisez '" + raccourciClavier + "'\npour ajouter " + siteNOM + " dans vos favoris !" + "\nUse '" + raccourciClavier + "'\nto add  " + siteNOM + " in your bokkmarks !"); 
    } 
     
  
    /*-- TRAITEMENT DES NAVIGATEURS --*/ 
  
    //Konqueror 
    if (navigator.userAgent.indexOf('Konqueror') >= 0) { 
    /*Test a effectuer avant tout les autres car repond TRUE aux differents tests sans pouvoir les exploiter*/ 
        myMessage("CTRL + B"); 
    } 
     
    else if (nav()=="IE") { 
        /* Internet Explorer, et ses dérivés (Crazy Browser, Avent Browser ...) */ 
	 window.external.AddFavorite(siteURL,siteNOM); 
    } 
  
    else if (document.all && (navigator.userAgent.indexOf('Win') < 0)) { 
        /* Internet Explorer Mac */ 
        myMessage("POMME + D - APPLE + D"); 
    } 
     
    else if (window.opera && window.print) { 
        /* Opera 6+ */ 
        myMessage("CTRL + T"); 
    } 
     
    else if (window.sidebar) { 
        /* Netscape 6+ ; Mozilla, FireFox et compagnie (K-Meleon ...) */ 
        window.sidebar.addPanel(siteNOM,siteURL,""); 
    } 
     
    else if (nav()=="NS") { 
        /* Netsccape 4 */ 
        myMessage("CTRL + D"); 
    } 
     
    else alert ("Cette fonction n'est pas disponible pour votre navigateur. This function is not avaliable for your web browser"); 
} 

// CHANGEMENT  360
function change_pano(number){
document.ptviewer.newPanoFromList(number);
}

//====================================================================================== FONCTIONS d'IMPRESSION



// =================================== PRINT avec MESSAGE 

function print_on(what,parm,bouton1,bouton2,bouton3,bouton4,bouton5){
var what,parm,bouton1,bouton2,bouton3,bouton4,bouton5;
if(bouton1){document.getElementById(bouton1).style.visibility = 'hidden';}
if(bouton2){document.getElementById(bouton2).style.visibility = 'hidden';}
if(bouton3){document.getElementById(bouton3).style.visibility = 'hidden';}
if(bouton4){document.getElementById(bouton4).style.visibility = 'hidden';}
if(bouton5){document.getElementById(bouton5).style.visibility = 'hidden';}
if(what=='imp'){if(comfirm('Voulez-vous imprimer cette page ?')){print_it();}}
if(what=='view'){print_preview(parm);}
if(bouton1){document.getElementById(bouton1).style.visibility = '';}
if(bouton2){document.getElementById(bouton2).style.visibility = '';}
if(bouton3){document.getElementById(bouton3).style.visibility = '';}
if(bouton4){document.getElementById(bouton4).style.visibility = '';}
if(bouton5){document.getElementById(bouton5).style.visibility = '';}
}
// =======================================  Print DIRECT

function print_it(){  // directement
		window.print();

}

// ==============================IMPRESSION DU CONTENU D'UNE ZONE
function print_inner_zone(){ 
 
	if (navigator.appName == "Netscape") {
		window.print();
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		zone_inner.innerHTML = "<head></head><body>" + document.getElementById('zone').innerHTML + "</body></html>";
		alert(zone_inner);
		zone_inner.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box
		WebBrowser1.outerHTML = "";
	}
}

// PRINT PREVIEW
// Test de l'objet WebBrowser
// 1 ? ouvrir document ou adresse internet
// 4 ? enregistrer document
// 6 0 imprimer avec choix imprimante 
// 6 6 imprimer directement
// 7 0 aperçu avant impression
// 8 0 mise en page
// 10 ? propriétés du document

function print_preview( intOLEcmd, intOLEparam ) { 
 var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>'; 
 document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 
 	if (!intOLEparam || intOLEparam < -1 || intOLEparam > 1 ) { 
 		intOLEparam = 1; 
 	} 
 		WebBrowser1.ExecWB( intOLEcmd, intOLEparam ); 
 		WebBrowser1.outerHTML = ""; 
}
// ===================================================================================== FONCTIONS   E V E N T S
function init_position(){
<!--
	if (document.layers) 
	document.captureEvents(Event.position); 
	if (document.layers || document.all) 
	document.onmousemove = position; 
	if (document.addEventListener) 
	document.addEventListener('position', position, true);
}
// affiche la position de la souris dans la barre de status
function position (posit) { 
			var A=0; var B=0;
		if (document.layers) {
		A=posit.x; B=posit.y;
		} 
		if (document.all) {
		A=event.clientX; B=event.clientY;
		} else {
			if (document.getElementById) {
			A=posit.clientX; B=posit.clientY; 
			}
		}
			window.status = "X="+A + '; Y=' + B; 
}

// clic droit PC et MAC
function init_clic_droit(){
// en fonction du navigateur...
if ( document.all ) {

// sur Internet Explorer on intercepte le 'Menu Contextuel'
document.oncontextmenu = clic_droit;
}
if ( document.layers ) {

// sur Netscape on intercepte le clic de la souris pour l'analyser ensuite...
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = clic_droit;
}

}
function clic_droit(evenement) {

// action pour Internet Explorer (sur 'Menu Contextuel')
if ( document.all ) {
alert('Vous utilisez Internet Explorer sur PC');
return false;
}
else if ( document.layers ) {

// pour Netscape, si le clic a été effectué sur le bouton droit (which == 3)
if ( evenement.which == 3 ) {
alert('Vous utilisez Netscape sur PC');
return false;
}

// si le clic standard a été accompagné d'une touche (touche 2 = Control, nécessaire pour le 'clic-droit' sur les souris à 1 bouton des Macs)
if ( evenement.modifiers == 2 ) {
alert('Vous utilisez Netscape sur Mac');
return false;
}
}
return true;
}

//======================================================================================== FONCTIONS DE FENETRE
//
//
//
//
//=============================== SEO =========== RECONSTRUCTION DE FRAME  
function verif_ORT(url,titre){
	// alert(window.name);
		if(window.name=="ORT"){
		
		parent.document.title=titre;
		//top.location.href=url;
		
	}

}
// =============================================== RECONSTRUCTION DE PAGE

function rebuild(site,page,frame_name){

var frms 		= 	parent.frames;
var nb_frame	= 	frms.length;

   if(page !=''){
    var url_retour 	= 	site +'?ret=' + page ;
   }else{
    var url_retour 	= 	site;
   }
	     
         if(nb_frame < 1){
                document.location.href = url_retour;
	     }else{
		 // recupère l'indice des frames:
		 
		  for(i=0;i < nb_frame;i++){
		  if(frms(i).name=='principal'){ var p=i;}
		  if(frms(i).name=='haut'){ var h=i;}
		  if(frms(i).name=='bas'){ var b=i;}
		  if(frms(i).name=='sommaire'){ var s=i;}
		  }
		  
	            switch(frame_name){
        		case 'principal' :
	     		   if (frms(p).name != frame_name){document.location.href = url_retour;}
	     		   break;
        		case 'haut' :
	     		   if (frms(h).name != frame_name){document.location.href = url_retour;}
	     		   break;
        		case 'bas' :
	     		   if (frms(b).name != frame_name){document.location.href = url_retour;}
	     		   break;
        		case 'sommaire' :
	     		   if (frms(s).name != frame_name){document.location.href = url_retour;}
	     		   break;
				}
				
	     }
  
}
//================================================================================================ F E N E T R E 

//============================================ POPUP

function amf_popup(name,proc,f_width,f_height,param){
	
	if(!param){
		var param = 'menubar=no, status=no, scrollbars=yes';
	}
	
        var vo_Pop = window.open(proc, name, 'resizable=1, location=no, width='+f_width+', height='+f_height+',' + param );
        
	  if((!vo_Pop) || (vo_Pop.closed)){
              alert("La configuration de votre ordinateur n'autorise pas l'ouverture de cette page en pop-up.Merci de vérifier la configuration de votre ordinateur.\nYour computer configuration does not allow pop-ups.");
	  }else{
               vo_Pop.focus();
        }
	
}

// ================================= POPUP COPYWRITE

function tribute(largeur,hauteur,url){
var page= '../include/tribute.php';
amf_popup("tribute",page,largeur,hauteur,"'_blank','toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=1,copyhistory=0,menuBar=0'")

}


// ==========================================redimentionnement automatique d'une iframe  

// le calcul de la hauteur peut etre réalisé par une zone tableau avec id et passé en parametre
//
// EXEMPLE :
// <script language="javascript" type="text/javascript">
// H = document.getElementById("zone1").clientHeight + 40;
// iframe_resize("principal",680,H);
// document.getElementById("top_p").focus();
// 
function windowresize2adm(table_out,majoh,majow){
	if(!majoh) majoh=70;
	if(!majow) majow=20;
	
	H = document.getElementById(table_out).clientHeight + majoh;
      W = document.getElementById(table_out).clientWidth + majow;
      this.resizeTo(W,H);
	this.focus();
return ;	
}

function iframe_remote_resize(frame_name,L,H){
//alert(H);
      if(window.document.getElementById(frame_name)){
      fenetre 		= 	window.document.getElementById(frame_name);
	fenetre.height	=	H;
	fenetre.width	=	L;
      }
	
}

function iframe_resize(frame_name,L,H,mother_table_id){
if(typeof(majopx)=='undefined') majopx=0;

	if(!mother_table_id) mother_table_id="body";
		  
	if(H==0){ // calcul automatique
 	     H=document.getElementById(mother_table_id).clientHeight;

	}
	if(L==0){ // calcul automatique
 	     L=document.getElementById(mother_table_id).clientWidth;

	}
	
	//compense en fonction du NAVIGATEUR utilisé
	 switch(NAVOK()){
  	 case '1' : //IE
   		var compensation = 20; break;
   	 case '2' : //FF
   		var compensation = 20; break;
   	 case '3' : // SAFARI
   		var compensation = 10; break;
   	 } 

      if(window.parent.document.getElementById(frame_name)){
	fenetre 		= 	window.parent.document.getElementById(frame_name);
	fenetre.height	=	H + compensation + majopx;
	fenetre.width	=	L;
	}
}

function iframe_autoresize(frame_name,marge){
 H = document.body.clientHeight - marge;
 if(window.document.getElementById(frame_name)){
 window.document.getElementById(frame_name).height = H ;
 }
}

function bodyresize(frame_name,different){
var bodyh						      = document.body.clientHeight;
document.getElementById(frame_name).height 	= bodyh - different;
return bodyh;	
}

function windowresize2element(table_out){
var bodyh						      = window.document.getElementById(table_out).clientHeight;
var bodyw						      = window.document.getElementById(table_out).clientWidth;
var dim =  bodyh+' '+bodyw;
window.resizeTo(bodyw,bodyh);
return dim;	
}
// ==============================================taille de l'ecran h ou l
function size_ecran(cote){
if(cote=='h'){
cote=screen.height;
}else{
cote=screen.width;
}
return cote;
}

function rechargement(){ window.history.go(0);}


function largeur_fenetre()
{
 if (window.innerWidth) return window.innerWidth;
 else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
 else return 0;
}

function hauteur_fenetre()
{
 if (window.innerHeight) return window.innerWidth;
 else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
 else return 0;
}

// ================================ POSITIONNE LA FENETRE EN COUR AU MILIEU
function to_center_screen(){
	var H = (screen.height - window.outerHeight) / 2;
	var L = (screen.width - window.outerWidth) / 2;
	window.moveTo(H,L);
}

// ================================= Maximize le navigateur
function maximiser()
{
	window.moveTo(0,0);
	window.resizeTo(screen.width,screen.height);
}

// ======================================================================================TEST DANS LE NAVIGATEUR
// test du navigateur
function nav(){
	
var NAV =navigator.appName;
	if (NAV == "Netscape") {
		return "NS";
	} else {
		return "IE";
	}
}
// TEST SI NAVIGATEUR OK
function NAVOK(){ // test compatibilité AMFNET 

if(window.navigator.appVersion.indexOf("Safari")>-1) {return '3';}
	
 if(window.navigator.appName=="Netscape"){
	return '2';
 } else { 
  if (window.navigator.appVersion.indexOf("MSIE")>-1){return '1';}else{return false;}
 }
 
}

//===================================== DIVERS ======================================================AUDIO VIDEO
// dans la page HTML
//<script language="JavaScript">var status=true; </ script> 
//<script language="JavaScript" src="include/applets.js">< /script>
//<p align="center">
//
//<DIV id="mediaplayer" name="mediaplayer">
//<EMBED SRC="pages/musique/theme1.mp3" id="music" HIDDEN=TRUE LOOP=true AUTOSTART=true></DIV> 
//<a href='javascript:music_ctrl("pages/musique/theme1.mp3",'include');'><img alt="Music Off" name="img_hp" src="../../images/form/hp_off.gif" border="0"></a>
//-->
function music_ctrl(mp3_file,path,check){
	
 obj_music=document.getElementById('mediaplayer');
 
 if(check){ // check au chargement de la page
	 //alert(LireCookie("music"));
	 if(LireCookie("music")=="off"){ // aret si off
		obj_music.innerHTML='';
		document.img_hp.src=path +"/hp.gif";
		document.img_hp.alt="Music On";
		music_status=false;
       }
 }else{
 
      if(music_status){ // arret  
	//obj_music.setAttribute('AUTOSTART',false,false);
	obj_music.innerHTML='';
	document.img_hp.src=path +"/hp.gif";
	document.img_hp.alt="Music On";
	EcrireCookie("music","off");
	music_status=false;
	}else{ 		//demarrage
	EcrireCookie("music","on");
	//obj_music.setAttribute('AUTOSTART',true,true);
	obj_music.innerHTML='<EMBED id="music" SRC="../include/'+mp3_file+'" hidden=true autostart=true LOOP=false ></EMBED>';
	document.img_hp.src=path +"/hp_off.gif";
	document.img_hp.alt="Music Off";
	music_status=true;
	}
 }
}
//===================================== TEST LA PRESENCE D'UN PLUGIN REAL PLAYER===============================
function getReal() {

	// If IE4 Mac, plugins can't be detected
	if(plgIe4Mac) {return false}

	// Check for Plug-in presence
	plugInFound = getPlugIn("RealPlayer","G2","Plug-In")
	// Check for RealPlayer ActiveX
	try {
		testObject = new ActiveXObject("rmocx.RealPlayer G2 Control.1")

		// Since G2 (Real 6), all Real player version numbers begin by 6
		embedVersion = testObject.GetVersionInfo()

		// First version supported : 6.0.6.131 = G2 Gold
		versionArray = embedVersion.split(".")
		conditionA = versionArray[0]>=6
		conditionB = versionArray[1]>=0
		conditionC = versionArray[2]>=6
		conditionD = versionArray[3]>=131
		
		if (conditionA && conditionB && conditionC && conditionD) {
				activeXFound = true
		} else {
			activeXFound = false
		}		

	} catch(e) {
		activeXFound = false
	}
	
	if (plugInFound || activeXFound) {return true} else {return false}	
}

// Parse plugins collection with strings to find
// User has to pass strings to be found in plugin name and description
// Ex. "Shockwave","Flash","5"
function getPlugIn() {

	// search for the right plugin among all those have been installed
	allFound = false
      plugInsCollection = navigator.plugins
	
	for (i=0;i<plugInsCollection.length;i++) {

		// Get plugin description
            plugInDescription = " " + plugInsCollection[i].description
		plugInName = " " + plugInsCollection[i].name
		
		for (j=0;j<arguments.length;j++) {
		
			if (plugInDescription.indexOf(" " + arguments[j])!=-1 || plugInName.indexOf(" " + arguments[j])!=-1) {
				allFound = true
			} else {
				allFound = false
				break
			}
		}
		
		// Send back the search result
		if (allFound) {return true}
    }

	// Send back the search result
	return false
}
// ===================DOWNLOAD FILE
function download_file(level,rep,fichier){
location=level + 'include/download.php?fichier='+fichier+'&rep='+rep;

}	

function img_popup(proc,f_width,f_height){
var prog=proc + "&w="+f_width + "&h="+f_height;
var param = 'menubar=no, status=no, scrollbars=yes';
window.open(prog, 'IMG', 'resizable=yes, location=no, width='+f_width+', height='+f_height+',' + param );
}

function inframe_run(appli,frameid){
document.getElementById(frameid).src=appli;
return;
}

// Removes leading whitespaces
function LTrim( value ) {
	
	var re = "/\s*((\S+\s*)*)/";
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = "/((\s*\S+)*)\s*/";
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function bisextile(an){
if(eval(an%4)==0){
  if(eval(an%100)==0){ 
     if(eval(an%400)==0){ return true;} else { return false;}
  } else {  return true; }

  }else { return false; }

}
	
//============================================= FIN ===========================================================================