// look2002/FR/commun/script_open.js: les diverses fonctions d'ouverture de fenêtres annexes
// ATTENTION: il existe un fichier quasi identique mais distinct yahoo_script_open.js en mode portail2002!!!

// Affichage de l'écran InfoVille
function OpenInfoVille(form,onglet,acces) {
	var popup_name = "INFO_VILLE_POPUP";
        form.target = popup_name;
	    form.ONGLET.value = onglet;
	    form.TYPE_CINE.value="";
			form.NUM_IG.value="";
			form.NUM_APP.value="";
			form.NUM_LO.value="";
			form.NUM_LS.value="";
			form.IV_ACCES.value=acces;
        //w=window.open("", popup_name, "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=640,height=600");
        window.name="main";
        w=window.open("", popup_name, "scrollbars=yes,resizable=no,width=740,height=571");
        w.focus();
        form.submit();
}
function OpenInfoVilleCine(form,num_IG,num_App,num_Lo,num_Ls,codeloc,libloc,cp,nom_PJ) {
	var popup_name = "INFO_VILLE_POPUP";
  form.target = popup_name;
	form.ONGLET.value = "cinema";
	form.TYPE_CINE.value="insc";
	form.NUM_IG.value=num_IG;
	form.NUM_APP.value=num_App;
	form.NUM_LO.value=num_Lo;
	form.NUM_LS.value=num_Ls;
	form.NOM_SALLE.value=nom_PJ;
	form.IV_CODE_LOC.value=codeloc;
	form.IV_NOM.value=libloc;
	if  (form.IV_CP.value!="")
	{
		form.IV_CP.value=cp;
	}


  //w=window.open("", popup_name, "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=640,height=600");
  window.name="main";
  w=window.open("", popup_name, "scrollbars=yes,resizable=no,width=740,height=571");
  w.focus();
  form.submit();
}
function OpenInfoVilleSpec(form,num_IG,num_App,num_Lo,num_Ls,codeloc,libloc,cp,nom_PJ) {
	var popup_name = "INFO_VILLE_POPUP";
  form.target = popup_name;
	form.ONGLET.value = "spectacle";
	form.TYPE_SPEC.value="insc";
	form.NUM_IG.value=num_IG;
	form.NUM_APP.value=num_App;
	form.NUM_LO.value=num_Lo;
	form.NUM_LS.value=num_Ls;
	form.NOM_SALLE.value=nom_PJ;
	form.IV_CODE_LOC.value=codeloc;
	form.IV_NOM.value=libloc;
	if  (form.IV_CP.value!="")
	{
		form.IV_CP.value=cp;
	}
  //w=window.open("", popup_name, "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=640,height=600");
  window.name="main";
  w=window.open("", popup_name, "scrollbars=yes,resizable=no,width=740,height=571");
  w.focus();
  form.submit();
}

// Affichage de l'écran PHOTO
function OpenPHOTOS(url_photo) {
	var popup_name = "PHOTO_POPUP";
      //w=window.open("", popup_name, "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=640,height=600");
        window.name="main";
        w=window.open(url_photo, popup_name, "scrollbars=yes,resizable=no,width=800,height=600");
        w.focus();
}


// LOOK 2002
function OpenIG( form_name ) {
  // Activation de la fenêtre annexe des IG
  // Ouverture d'une fenêtre vide avec les bonnes propriétés et dimensions
  // Le nom est imposé: PJI_IG, ne pas le changer
  w = window.open( "", "PJI_IG", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes,width=510,height=400" );
  w.focus(); // Passage en avant-plan
  // Soumission du formulaire dont le nom est passé en paramètre
  // (son target est forcément "PJI_IG")
  f = eval( "document." + form_name );
  f.submit();
}
function OpenIG2( form_name ) {
  // Activation de la fenêtre annexe des IG
  // Ouverture d'une fenêtre vide avec les bonnes propriétés et dimensions
  // Le nom est imposé: PJI_IG, ne pas le changer
  w = window.open( "", "PJI_IG", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes,width=510,height=400" );
  w.focus(); // Passage en avant-plan
  // Soumission du formulaire dont le nom est passé en paramètre
  // (son target est forcément "PJI_IG")
  form_name.submit();
}

// tempo clip TV PJ
function launchpopstatic(TheURL,fenetre,features){
newwin=window.open(TheURL,fenetre,features)
if(navigator.appName == 'Netscape')
        {
                var navigator_version = navigator.appVersion.charAt(0);
                if(navigator_version >= '3') newwin.focus();
        }
}

//------------------------------------
function WOpen( url, name, param ) {
  // 1- Fermer la fenêtre ayant ce nom:
  // - Double avantage: en MSIE, la fenêtre annexe passe en avant-plan
  // - Même si le serveur externe est long a répondre, on n'a pas le contenu précédent,
  // mais une fenêtre vierge.
  // NB: il y a des problèmes sur MAC, et avec MSIE4 et antérieurs,
  // et également avec Opera: il sont donc exclus de la refermeture
  var nv = navigator.appName + navigator.appVersion;
  var MAC = (nv.indexOf( "Mac" ) != -1);
  var MSIE4=((nv.indexOf( "MSIE 6" ) != -1) || (nv.indexOf( "MSIE 5" ) != -1) || (nv.indexOf( "MSIE 4" ) != -1) || (nv.indexOf( "MSIE 3" ) != -1) || (nv.indexOf( "MSIE 2" ) != -1));
  var Opera = (nv.indexOf( "Opera" ) != -1);
  var Crazy = (nv.indexOf( "Crazy" ) != -1);
  var Netscape = (nv.indexOf( "Netscape" ) != -1);
  var Avant = (nv.indexOf( "Avant" ) != -1);
  var AOL = (nv.indexOf( "AOL" ) != -1);
  // alert( "MAC=" + MAC + ", MSIE4=" + MSIE4 + ", Opera=" + Opera )
  if ( !MAC && !MSIE4 && !Opera && !Crazy && !Avant && !Netscape && !AOL ) {
    // On est obligé d'ouvrir pour avoir un identifiant de fenêtre
    w = window.open( "", name, param );
    w.close(); // afin de pouvoir fermer
  }

    // page pub pseudo-frame (TRANSITOIRE)
  if (curwinname == "pjipub_inscription")
    if ( (url.indexOf("../../") == -1) && (url.indexOf("http://") == -1))
      url = "../../" + url;

  // 2- Ouverture de la fenêtre demandée
  w = window.open( url,name, param );
  // focus, si supporté (pas par MSIE4 et antérieurs; devrait être OK sur MAC)
  if ( !MSIE4 ) w.focus();
}

//------------------------------------
function ReEncodeURL( url_in ) {
  // Fonction pour pallier au pb de MSIE qui interprète les %xx qu'il reçoit en paramètre
  // et envoie une URL mal encodée, qui est refusée au niveau du serveur NS4!
  // entrée: l'url à ré-encoder (les accents sont ou non de la forme %xx)
  // sortie: les valeurs des paramètres sont ré-encodées (accents en %xx)
  // NB: utile pour MSIE, mais compatible NN (noop dans ce cas)

  // Cas particulier d'un client ayant un ".." dans son URL!
  if ( url_in.indexOf( ".." ) != -1 ) {
    url_in = url_in.replace( /\.\./gi, "%252e%252e" )
    }

  // Découper sur le ? qui introduit des paramètres
  index = url_in.indexOf( "?" )
  if ( index == -1 ) // Pas de paramètre: rien à faire
    return url_in;
  url = url_in.slice( 0, index + 1 );
  params = url_in.slice( index + 1 );

  // Obtenir un tableau de paramètres et le traiter
  param_array = params.split( "&" );
  for ( var i = 0 ; i < param_array.length ; i++ ) {
    param = param_array[i];
    name = param.slice( 0, param.indexOf( "=" ));
    value = param.slice( param.indexOf( "=" ) + 1 );
    url = url + name + "=" + escape( unescape( value )) + "&";
    }
  return url;
}

//------------------------------------
// Ouverture d'une page plan
var URL_PLAN = "";
function OpenPlan( theURL ) {
  url = ReEncodeURL(URL_PLAN + theURL);

    // traitement spécial si on est en page PUB, sinon NN7 n'appelle pas la bonne URL...
  if ( curwinname == "pjipub_inscription" ) {   // page PUB
    if ( url.indexOf( "http://" ) == -1 ) url = DocumentBase() + "../../" + url;
    }

  WOpen(url, "PJI_PLANS", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=640,height=480" );
}

//------------------------------------
// Ouverture d'une page photo
function OpenPhoto( theURL ) {
  url = ReEncodeURL(theURL);

    // traitement spécial si on est en page PUB, sinon NN7 n'appelle pas la bonne URL...
  if ( curwinname == "pjipub_inscription" ) {   // page PUB
    if ( url.indexOf( "http://" ) == -1 ) url = DocumentBase() + "../../" + url;
    }

  WOpen(url, "PJI_PLANS", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=640,height=480" );
}

//------------------------------------
// Ouverture d'une page MMS+

function OpenMMS( theURL ) {
  url = ReEncodeURL(theURL);
  if ( curwinname == "pjipub_inscription" ) {   // page PUB
    if ( url.indexOf( "http://" ) == -1 ) url = DocumentBase() + "../../" + url;
    }
  WOpen(url, "PJI_PLANS", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=640,height=480" );
}

//------------------------------------
// Ouverture d'un site web externe
function OpenWeb( theURL ) {
  WOpen( ReEncodeURL( theURL ), "PJI_WEB", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,width=630,height=460" );
}

//------------------------------------
// Ouverture d'un site mairie
function OpenMairie( theURL ) {
  WOpen( ReEncodeURL( theURL ), "PJI_MAIRIE", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,width=630,height=460" );
}

//------------------------------------
// Lecture de l'URL du document courant, de la forme "http://.../src/files/tmp/xxx.html"
// et on coupe au dernier "/"
function DocumentBase() {
    cur_url = document.URL;
    document_base = cur_url.substring( 0, cur_url.lastIndexOf( "/" )) + "/";
    return document_base;
}

//------------------------------------
// Ouverture d'une page publicitaire (CIP, DiapoFlash, SpotInfo et prochains objets pub)
var curwinname = ""; // pour que la variable soit toujours disponible
function OpenPub( theURL ) {
  // ATTENTION: agir différemment suivant que la fenêtre courante est publicitaire, photo ou non
  // (NB: la fenêtre multiframe pub est nommée PJI_PUB, mais le frame courant est alors
  // "pjipub_inscription" ) ==> on ajoute "../../" devant l'URL pour compenser le
  // répertoire temporaire des frames
  url = ReEncodeURL( theURL );
  params = "toolbar=no,status=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=500,height=550";
  if ( curwinname == "pjipub_inscription" ) {   // page PUB
    if ( url.indexOf( "http://" ) == -1 ) url = DocumentBase() + "../../" + url;
    w = window.open( url, "PJI_PUB", params );
    }
  else if ( curwinname == "inscription" ) { // page photo/plan
    url = DocumentBase() + "../../" + url;
    WOpen( url, "PJI_PUB", params );
    }
  else WOpen( url, "PJI_PUB", params );
}

//------------------------------------
// Ouverture d'une page d'information
function OpenTextInfo( template,w,h ) {
  theURL = "pj.cgi?html=" + template;
  WOpen( ReEncodeURL( theURL ), "PJI_INFO", "toolbar=no,menubar=no,location=no,scrollbars=auto,resizable=yes,width="+w+",height="+h );
}

//------------------------------------
// Ouverture de la page des tarifs telecom
function OpenTarif( theURL ) {
  WOpen( ReEncodeURL( theURL ), "PJI_TARIF", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=550,height=400" );
}

//------------------------------------
// Ouverture de la page des tarifs exact telecom
function OpenTarifExact( theURL ) {
//  for ( i = 0; i < theURL.length; i++ ) {
//  if ( theURL.charCodeAt( i ) > 127 )
//    alert( "Car : " + theURL.charAt( i ) + " ; Code = " + theURL.charCodeAt( i ));
//  }
  WOpen( ReEncodeURL( theURL ), "PJI_TARIF", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=330,height=150" );
}

//------------------------------------
// Ouverture d'une page de mention obligatoire gratuite (MOG) générique
function OpenMog( template ) {
  theURL = "pj.cgi?html=" + template;
  WOpen( ReEncodeURL( theURL ), "PJI_MOG", "toolbar=no,menubar=no,location=no,scrollbars=auto,resizable=yes,width=225,height=200" );
}

// Ouverture d'une page de mention obligatoire de Domiciliation (MOD) générique
function OpenMod( texte ) {
  theURL = "pj.cgi?html=commun/MOD.html&TEXTE_MOD=" + texte;
  WOpen( ReEncodeURL( theURL ), "PJI_MOG", "toolbar=no,menubar=no,location=no,scrollbars=auto,resizable=yes,width=550,height=300" );
}

//------------------------------------
// Ouverture d'une page de "dossier" (objet éditorial en marge droite des pages réponses)
function PJDossier( url ) {
  WOpen( ReEncodeURL( url ), "PJI_DOSSIER", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=550,height=400" );
}

//------------------------------------
// Ouverture de la page d'envoi de mail
function OpenSAM( params ) {
  theURL = params;
  WOpen( ReEncodeURL( theURL ), "PJI_SAM", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=640,height=480" );
}

//------------ LOOK 2002 ----------------
// à voir plus tard si on laisse ces fonctions ici ou si on la déplace dans un autre .js

//------------------------------------
// Choix d'un élément dans une ambiguïté géo ou un guide géo
// du fait qu'on utilise maintenant un lien textuel au lieu d'une image cliquable.
// Hypothèse: le formulaire a envoyer se nomme toujours "form1"
// NB: chaque "form1" doit maintenant comporter un champ caché de nom "input_image"
function ChoixGeo( code ) {
  document.form1.input_image.value = code;
  document.form1.submit();
  return true;
}
//------------ LOOK 2002 ----------------
// à voir plus tard si on laisse ces fonctions ici ou si on la déplace dans un autre .js

//------------------------------------
// Choix d'un élément dans une ambiguïté géo ou un guide géo
// du fait qu'on utilise maintenant un lien textuel au lieu d'une image cliquable.
// Hypothèse: le formulaire a envoyer se nomme toujours "form1"
// NB: chaque "form1" doit maintenant comporter un champ caché de nom "input_image"
function ChoixGeoL( code ) {
  document.form1.input_image.value = code;
  lg = code.length;
  if (document.form1.IV_ACTIVATION.value=="oui") {
     if ((code.indexOf( "GV_" ) != -1) || (code.indexOf( "GO_" ) != -1) || (code.indexOf( "GL_" ) != -1))
         { // Renseignement pour info ville : recherche localité si choix toutes les localités on prend la 1ère localité
           document.form1.INFO_VILLE.value="oui";
           document.form1.CODE_LOC_INFO_VILLE.value=code.slice(3,lg);
         }
     else
         {
           document.form1.INFO_VILLE.value="non";
           document.form1.CODE_LOC_INFO_VILLE.value="00000000";
         }
  }
  document.form1.submit();
  return true;
}

//------------------------------------
// Fonctions pour colorer le fond du libellé de levée d'ambiguïté
var clrOver = "FFED00";
function mOvr( src ) {
  var nv = navigator.appName + navigator.appVersion;
  var MSIE=(nv.indexOf( "MSIE" ) != -1);
  if ( MSIE && !src.contains( event.fromElement) ) {
    src.style.cursor = 'hand';
    src.bgColor = clrOver;
    }
}

function mOut( src ) {
  var nv = navigator.appName + navigator.appVersion;
  var MSIE=(nv.indexOf( "MSIE" ) != -1);
  if ( MSIE && !src.contains( event.toElement )) {
    src.style.cursor = 'default';
    src.bgColor = "";
    }
}

//------------------------------------
// Les boutons GUIDE sont extraits des <FORM>
// et les guides sont remplacés par un appel à cette fonction qui prend en paramètre le
// nom du bouton guide d'origine et optionnellement le FORM à utiliser
function AppelGuide( id, form ) {
  if ( form == null ) form = document.form;
  input_image_old = form.input_image.value;
  form.input_image.value = id;
  form.faire.value = "decode_input_image";
  form.submit();
  if(form.srv.value == "RP")
	form.input_image.value = input_image_old;
  return true;
}


//------------------------------------
// fonction permettant l'ouverture de la fenêtre d'achat séparée
var flagSMSactif = 0;
function AchatReponseRoot(id, form, lang, mode, marchand) {

	if ("WHA" == mode)
	{
	        flagSMSactif = 1;
		form.HA.value="WHA";
	}
	if ("KML" == marchand)
	{
		form.marchand.value="KML";
	}
	AchatReponse(id, form, lang);
}
function AchatReponse(id, form, lang) {
    // version FEC058:
    form.input_image.value = id;
    form.faire.value="decode_input_image";

    // sauvegarde du nom courant de fenetre
    save_window_name = window.name;
    window.status="save_window_name="+save_window_name;
    form.WNAME.value = save_window_name;

    // renommage de la fenetre PJI en MerchantWindow, nom imposé par WHA
    if (1 != flagSMSactif)
    {
    	window.name="MerchantWindow";
    }

/**** ANCIEN CODE *********** conservé par sécurité *********
    // ouverture de la fenetre WHA


    WOpen("", "PJI_WHA", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=560,height=370");
    // activation de la requete dans la fenetre WHA
    form.target="PJI_WHA";
    form.submit();
    // mise à jour de la fenetre courante avec le message d'attente, retardé de 1/10 seconde
    theURL = "pj.cgi?html=commun/attente_achat.html&SRV=" + form.srv.value + "&lang=" + lang + "&portail=" + form.portail.value ;
    setTimeout("window.location.href=theURL", 100);
********* FIN ANCIEN CODE *********/

// NOUVEAU CODE: on va tenter de ne pas faire de submit, mais de construire une URL en mode GET
// au cas bien incertain ou cela changerait effectivement quelque chose...

    var bPrenom = false;
    var bPId = false;
    var bPortail = false;
    // on boucle sur chaque champ INPUT du formulaire form
    len=form.elements.length;
    url1=form.action+"?";
    for (i=0; i<len; i++)
        {
            elem = form.elements[i];
            if(1 == flagSMSactif && "WNAME" == elem.name)
            {
        	form.WNAME.value = "MerchantWindow";
            }
            url1+= elem.name + "=" + escape(unescape(elem.value)) + "&";

            if("FRM_PRENOM" == elem.name)
            {
        	bPrenom = true;
            }
            if("pId" == elem.name)
            {
        	bPId = true;
            }
            if("portail" == elem.name)
            {
        	bPortail = true;
            }
        }
    // ouverture de la fenetre WHA (l'appel wha est généré par le CI-Web via une redirection)
    // eglca WOpen(url1, "PJI_WHA", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=660,height=470");
    // debeglca
    // al20041202 ne plus ouvrir une fenetre pour un achat via portail AOL
        if (form.HA.value == "AOL") {

            window.location.href=url1;
            return;
    }
    if (form.HA.value != "LCA") {
//        WOpen(url1, "PJI_WHA", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=660,height=470");
// LCH 260204 : activation nouvelle fenetre wha
        if (form.HA.value == "SMS")
        {
            var action = "pi.cgi";
    	    var path = "pages_inverses";
	    if ("NFR" == form.srv.value)
	    {
	       action = "nfr.cgi";
    	       path = "nom_france_entiere";
	       theURL = action + "?html="+path+"/paiement_choix_smsaudio.html&SRV=" + form.srv.value + "&lang=" + lang
	       + "&HA=" + form.HA.value + "&faire=" + "&SESSION_ID=" + form.SESSION_ID.value + "&VID=" + form.VID.value
	       + "&pays=" + form.pays.value + "&TYPE_RECHERCHE=" + form.TYPE_RECHERCHE.value + "&OBJ_GEO=" + form.OBJ_GEO.value
	       + "&FRM_NOM=" + form.FRM_NOM.value + "&FRM_TYPE_PUB=" + form.FRM_TYPE_PUB.value + "&input_image=" + form.input_image.value;
	       if (true == bPrenom)
	       {
	           theURL += "&FRM_PRENOM=" + form.FRM_PRENOM.value;
	       }
	    } else {
	       theURL = action + "?html="+path+"/paiement_choix_smsaudio.html&SRV=" + form.srv.value + "&lang=" + lang
	       + "&HA=" + form.HA.value + "&faire=" + "&SESSION_ID=" + form.SESSION_ID.value + "&VID=" + form.VID.value
	       + "&pays=" + form.pays.value + "&TYPE_RECHERCHE=" + form.TYPE_RECHERCHE.value + "&OBJ_GEO=" + form.OBJ_GEO.value
	       + "&FRM_TYPE_PUB=" + form.FRM_TYPE_PUB.value + "&input_image=" + form.input_image.value
	       + "&FRM_TEL=" + form.FRM_TEL.value;
            }
    	    if (true == bPId)
    	    {
	         theURL += "&pId=" + form.pId.value;
    	    }
    	    if (true == bPortail)
    	    {
	         theURL += "&portail=" + form.portail.value;
    	    }
            WOpen(theURL, "iPIN_PaymentPanel", "toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=yes,width=660,height=470");

        } else
        {
	    if (1 == flagSMSactif)
	    {
                WOpen(url1, "iPIN_PaymentPanel", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=660,height=470");
                return;
	    }
           else
            {
                if (form.portail.value == "aol") {
                        WOpen(url1, "", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=660,height=470");
                        } else {
                	WOpen(url1, "iPIN_PaymentPanel", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=660,height=470");
		}
            }
        }
    }
    else {
        window.location.href=url1;
        return;
    }
    // fineglca

    // mise à jour de la fenetre courante avec le message d'attente, retardé de 0.5 seconde (au lieu de 1/10s précédemment)
    theURL = "pj.cgi?html=commun/attente_achat.html&SRV=" + form.srv.value + "&lang=" + lang + "&HA=" + form.HA.value;
    if (true == bPortail)
    {
	 theURL += "&portail=" + form.portail.value;
    }
    if (1 == flagSMSactif)
    {
    	setTimeout("window.opener.location.href=theURL", 500);
    }
    else setTimeout("window.location.href=theURL", 500);

// FIN NOUVEAU CODE
}

//------------------------------------
// Ouverture du template D'informations sur WHA
function OpenInfoWHA( theURL ) {
  //WOpen( ReEncodeURL( theURL ), "PJI_InfoWHA", "toolbar=yes,menubar=no,location=yes,scrollbars=yes,resizable=yes,width=440,height=420" );
WOpen( ReEncodeURL( theURL ), "PJI_InfoWHA", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=440,height=420" );
}

function OpenInfoLOR() {
window.open( "pj.cgi?faire=aide&page=aide.html#opp", "PJI_InfoLOR", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=600,height=300" );
}

//------------------------------------
// Ouverture d'une fenêtre d'alerte avec conseils (pas disponible en mode portail)
function OpenAlerte( form, numero ) {
  lang=form.lang.value;
  // Dans certains cas (rares et non reproductibles) form.lang.value vaut UNDEFINED...
  if (( lang.toUpperCase() != "FR" ) && ( lang.toUpperCase() != "EN" )) lang = "FR";
  theURL = "pj.cgi?html=commun/popup_alerte.html&num_alerte=" + numero + "&SRV=" + form.srv.value + "&lang=" + lang;
  WOpen( ReEncodeURL( theURL ), "PJI_Alerte", "toolbar=no,menubar=no,location=no,scrollbars=auto,resizable=yes,width=380,height=260" );
}

//------------------------------------
// SPECIFIQUE portails: ouverture d'une page "carnet d'adresse"
var URL_CARNET = "";
function OpenCarnet( theURL ) {
  theURL = URL_CARNET + theURL;
  WOpen( ReEncodeURL( theURL ), "PJI_CARNET", "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,width=480,height=520" );
}

//------------------------------------
// Les évenement sont extraits des <FORM>
function AppelEvent(form, eventActif ) {
    if ("actif" == eventActif)
    {
        form.submit();
        return true;
    }
}

// Ouverture indicatifs ANUMONDE
function OpenIndicatif(theURL) {
w=window.open(theURL,"PJI_WEB","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=no,width=500,height=555");
MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
VERS=parseInt(navigator.appVersion);
if ((!MSIE) || (VERS >=5))
w.focus();
}

//------------------------------------
// Ouverture d'une fenetre Infos Contact
function OpenInfoContact( theURL ) {
  if (window.name == "infocontact")
  {
    window.parent.location = ReEncodeURL( theURL );
    return;
  }

  WOpen( ReEncodeURL( theURL ), "PJI_INFO_CONTACT", "toolbar=no,status=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=500,height=500" );
}
// ouverture de la fenêtre d'aide depuis AIDE PJ
function OpenHelp(theURL) {
  WOpen(ReEncodeURL(theURL), "QD_AIDE",
        "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=620,height=670");
}
//------------------------------------
// Activation d'une carte flash (evol carte flash)
function OpenCarteFlash(carteActif, url, form) {
    if ("actif" == carteActif  && "" != form)
    {
        construireURL = url;
        nb = form.elements.length;

        for (i=0; i<nb; i++)
        {
            construireURL +="&" + form.elements[i].name + "=" + form.elements[i].value ;
        }
        WOpen(ReEncodeURL( construireURL ), "PJ_CARTE_NFR", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=640,height=480");
    }
    else if ("actif" == carteActif)
    {
        construireURL = url;
        construireURL +="&" + "faire=get_carte_flash_demo"
        WOpen(ReEncodeURL( construireURL ), "PJ_CARTE_NFR", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes,width=640,height=480");
    }
}


// CLE debut evol paiement SMS+
//------------------------------------
// fonction permettant l'ouverture de la fenêtre intermediaire de choix de peiement
function VerifierCodeSMS(id, form) {
    form.input_image.value = id;
    form.faire.value="verifier_code_sms";

    // on boucle sur chaque champ INPUT du formulaire form
    var bPrenom = false;
    var bPortail = false;
    var theURL = "";
    len=form.elements.length;
    for (i=0; i<len; i++)
        {
            elem = form.elements[i];
            if("FRM_PRENOM" == elem.name)
            {
        	bPrenom = true;
            }
            if("portail" == elem.name)
            {
        	bPortail = true;
            }
        }
    var action = "pi.cgi";
    if ("NFR" == form.srv.value)
    {
    	action = "nfr.cgi";
    	theURL = action + "?faire=" + form.faire.value + "&SRV=" + form.srv.value + "&lang=" + form.lang.value
    	+ "&HA=" + form.HA.value + "&SESSION_ID=" + form.SESSION_ID.value
    	+ "&VID=" + form.VID.value + "&pays=" + form.pays.value + "&TYPE_RECHERCHE=" + form.TYPE_RECHERCHE.value
    	+ "&OBJ_GEO=" + form.OBJ_GEO.value + "&FRM_NOM=" + form.FRM_NOM.value + "&smsmode=" + form.SMSMODE.value
    	+ "&FRM_TYPE_PUB=" + form.FRM_TYPE_PUB.value + "&input_image=" + form.input_image.value
    	+ "&smscode=" + form.smscode.value;
    	if (true == bPrenom)
    	{
	   theURL += "&FRM_PRENOM=" + form.FRM_PRENOM.value;
    	}
    }
    else
    {
    	theURL = action + "?faire=" + form.faire.value + "&SRV=" + form.srv.value + "&lang=" + form.lang.value
    	+ "&HA=" + form.HA.value + "&SESSION_ID=" + form.SESSION_ID.value
    	+ "&VID=" + form.VID.value + "&pays=" + form.pays.value + "&TYPE_RECHERCHE=" + form.TYPE_RECHERCHE.value
    	+ "&OBJ_GEO=" + form.OBJ_GEO.value + "&smsmode=" + form.SMSMODE.value + "&FRM_TYPE_PUB=" + form.FRM_TYPE_PUB.value
    	+ "&input_image=" + form.input_image.value + "&smscode=" + form.smscode.value + "&FRM_TEL=" + form.FRM_TEL.value;
    }
    if (true == bPortail)
    {
	 theURL += "&portail=" + form.portail.value;
    }
    form.action=theURL;
    form.submit();
}

//------------------------------------
// Ouverture du template D'informations sur SMS
function OpenInfoSMS( theURL ) {
WOpen( ReEncodeURL( theURL ), "PJI_InfoSMS", "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=440,height=420" );
}

//------------------------------------
// Ouverture de la page d'achat Audiotel
function OpenAchatAudio( form ) {
    len=form.elements.length;
    var bPrenom = false;
    var bPId = false;
    var bPortail = false;
    for (i=0; i<len; i++)
        {
            elem = form.elements[i];
            if("FRM_PRENOM" == elem.name)
            {
        	bPrenom = true;
            }
            if("pId" == elem.name)
            {
        	bPId = true;
            }
            if("portail" == elem.name)
            {
        	bPortail = true;
            }
        }
    	var action = "pi.cgi";
    	var path = "pages_inverses";
    	if ("NFR" == form.srv.value)
    	{
    	   action = "nfr.cgi";
    	   path = "nom_france_entiere";
    	   theURL = action + "?html="+path+"/achat_RNF_audio.html&SRV=" + form.srv.value + "&lang=" + form.lang.value
    	   + "&HA=" + form.HA.value + "&faire=" + "&SESSION_ID=" + form.SESSION_ID.value + "&VID=" + form.VID.value + "&pays=" + form.pays.value
    	   + "&TYPE_RECHERCHE=" + form.TYPE_RECHERCHE.value + "&OBJ_GEO=" + form.OBJ_GEO.value + "&FRM_NOM=" + form.FRM_NOM.value
    	   + "&FRM_TYPE_PUB=" + form.FRM_TYPE_PUB.value + "&input_image=" + form.input_image.value;
    	   if (true == bPrenom)
    	   {
		theURL += "&FRM_PRENOM=" + form.FRM_PRENOM.value;
    	   }
    	} else {
    	   theURL = action + "?html="+path+"/achat_RI_audio.html&SRV=" + form.srv.value + "&lang=" + form.lang.value
    	   + "&HA=" + form.HA.value + "&faire=" + "&SESSION_ID=" + form.SESSION_ID.value + "&VID=" + form.VID.value + "&pays=" + form.pays.value
    	   + "&TYPE_RECHERCHE=" + form.TYPE_RECHERCHE.value + "&OBJ_GEO=" + form.OBJ_GEO.value
    	   + "&FRM_TYPE_PUB=" + form.FRM_TYPE_PUB.value + "&input_image=" + form.input_image.value
    	   + "&FRM_TEL=" + form.FRM_TEL.value;
    	}
    	if (true == bPId)
    	{
	     theURL += "&pId=" + form.pId.value;
    	}
    	if (true == bPortail)
    	{
	     theURL += "&portail=" + form.portail.value;
    	}


   window.location=theURL;
}

// CLE fin evol paiement SMS+

// CLE debut Evol Impression
//------------------------------------
function NameEcranImpression(form)
{
        var window = "PJ_ECRAN_PRINT_" + form.srv.value;
	if ("RP" == form.srv.value)
	{
	    var num_page = (form.PAGE_N * 10) +1;
	    window += "_" + num_page;
	}
	else
	{
		if (null != form.first_rep)
		{
	    	window += "_" + form.first_rep.value;
	    }
		else if (null != form.first_rep_print_exa)
		{
	    	window += "_" + form.first_rep_print_exa.value;
	    }
		else if (null != form.first_rep_print_ap1)
		{
	    	window += "_" + form.first_rep_print_ap1.value;
	    }
		else if (null != form.first_rep_print_ap2)
		{
	    	window += "_" + form.first_rep_print_ap2.value;
	    }
	}
	return(window);

}

// Affichage de l'écran d'impression
function OpenEcranImpression(form) {
	var construireURL = "";
	if ("PB" == form.srv.value)
	{
	    construireURL = "pb.cgi?html=commun/page_vide.html";
	}
	else if ("PJ" == form.srv.value)
	{
	    construireURL = "pj.cgi?html=commun/page_vide.html";
	}
	else if ("RP" == form.srv.value)
	{
	    construireURL = "rp.cgi?html=proximite/liste_print_inscriptions.html";
	}
        var popup_name = NameEcranImpression(form);
        form.target = popup_name;
        WOpen(ReEncodeURL( construireURL ), popup_name, "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=820,height=600");
}

// CLE fin Evol Impression

// Affichage de la page avec jauge
function AffichePage(form,page,nb_inscription, liste_choix) {

	    if ("NONE" == form.CUR_ORTHO_PRINT.value)
	      {
           form.FIRST_REP_PRINT_NONE.value=((page-1)*nb_inscription)+1 ;
           form.LAST_REP_PRINT_NONE.value=((page-1)*nb_inscription)+nb_inscription ;
           if ( (((page-1)*nb_inscription)+nb_inscription) > form.NB_REP_TOTAL_NONE.value) {
                form.LAST_REP_PRINT_NONE.value = form.NB_REP_TOTAL_NONE.value ;
                }
          }
	    if ("EXA" == form.CUR_ORTHO_PRINT.value)
	      {
           form.FIRST_REP_PRINT_EXA.value=((page-1)*nb_inscription)+1 ;
           form.LAST_REP_PRINT_EXA.value=((page-1)*nb_inscription)+nb_inscription ;
           if ( (((page-1)*nb_inscription)+nb_inscription) > form.NB_REP_TOTAL_EXA.value) {
                form.LAST_REP_PRINT_EXA.value = form.NB_REP_TOTAL_EXA.value ;
                }
          }
	    if ("AP1" == form.CUR_ORTHO_PRINT.value)
	      {
           form.FIRST_REP_PRINT_AP1.value=((page-1)*nb_inscription)+1 ;
           form.LAST_REP_PRINT_AP1.value=((page-1)*nb_inscription)+nb_inscription ;
           if ( (((page-1)*nb_inscription)+nb_inscription) > form.NB_REP_TOTAL_AP1.value) {
                form.LAST_REP_PRINT_AP1.value = form.NB_REP_TOTAL_AP1.value ;
                }
          }
	    if ("AP2" == form.CUR_ORTHO_PRINT.value)
	      {
           form.FIRST_REP_PRINT_AP2.value=((page-1)*nb_inscription)+1 ;
           form.LAST_REP_PRINT_AP2.value=((page-1)*nb_inscription)+nb_inscription ;
           if ( (((page-1)*nb_inscription)+nb_inscription) > form.NB_REP_TOTAL_AP2.value) {
                form.LAST_REP_PRINT_AP2.value = form.NB_REP_TOTAL_AP2.value ;
                }
          }
        form.IMPR.value="NON" ;
        form.LISTE_CHOIX.value=liste_choix ;
}

//------------------------------------
// Activation d'une réponse avertissement orthographe approchée
function OpenReponseOrthoApp( form_name ) {
  // Activation de la fenêtre
  // Ouverture d'une fenêtre vide avec les bonnes propriétés et dimensions
  w = window.open( "", "PJ_PAGE_ORTHO_APP", "toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=yes,width=510,height=330" );
  w.focus(); // Passage en avant-plan
  // Soumission du formulaire dont le nom est passé en paramètre
  f = eval( "document." + form_name );
  f.submit();
}

//liens local
function open_aideappel(url_aideappel)
{
	aideappel = WOpen(url_aideappel, 'eStara','width=700,status=no,resizable=yes,toolbar=no,scrollbars=yes,menubar=no,location=no');
	aideappel.focus();
}
//------------------------------------
//liens local
function open_cguappel(url_cguappel)
{
	cguappel = WOpen(url_cguappel, 'eStara2','width=700,status=no,resizable=yes,toolbar=no,scrollbars=yes,menubar=no,location=no');
	cguappel.focus();
}
