 /*! \file fonctions.js
* Fonctions Javascript communes
* 
* Iconeweb - Sogeprom
* Application : Sogeprom
* \date 08/03/2007
* \author Iconeweb 2002-2006
*/

/* Ce programme est la propriété exclusive de la société Iconeweb Multimedia
* Toute modification, diffusion et utilisation sous quelle que forme que ce
* soit, ainsi que l'effacement de cet en-tête sont formellement interdits
* sans autorisation écrite de la société.
* Iconeweb Immobilier - 21, rue de Cléry 75002 Paris
* 33 1 45 85 30 45 - contact@iconeweb.com - http://www.iconeweb-immobilier.com
*/ 

// Traducation en FR d'Ext
if(c_langue == 'fr')
{
	Ext.MessageBox.buttonText.yes = 'Oui';
	Ext.MessageBox.buttonText.no = 'Non';
	Ext.MessageBox.buttonText.cancel = 'Annuler';
}

//fonction de changement de la langue en cours 
function p_set_lang(lang) 
{
	if (lang == '')
		return;
		
	var cur_url = new String(window.location);
	
	regex = /(.*)([&?]l=)[a-z]{2}(.*)$/;
	regex2 = /\?/;
	
	if ((regex.test(cur_url))) {
		cur_url = cur_url.replace(regex, "$1$2" + lang + "$3");
	} else { 
		if (regex2.test(cur_url))
			cur_url += "&l=" + lang;
		else 
			cur_url += "?l=" + lang; 
	}
	window.location = cur_url;
}

// fonction d'ajout / modification de paramètre dans un URL
// @ p_param : nom du paramètres
// @p_valeur : valeur du paramètre 

function f_set_param(p_param, p_valeur) 
{
	var cur_url = new String(window.location);
	if (p_valeur == '') {
		window.location = cur_url;
		return;	
	}
	r_tmp = "(.*)([&?]"+p_param+"=)[a-z]{2}(.*)$";
	r_regex = new RegExp (r_tmp, "gi");
	r_regex2 = /\?/;
	
	if ((r_regex.test(cur_url))) {
		cur_url = cur_url.replace(r_regex, "$1$2" + p_valeur + "$3");
	} else { 
		if (r_regex2.test(cur_url))
			cur_url += "&"+p_param+"=" + p_valeur;
		else
			cur_url += "?"+p_param+"=" + p_valeur;
	}
	window.location = cur_url;
} // Fin donction p_set_param (...)

//******************************************************************************
//**   Confirmation de suppression
//******************************************************************************
function f_ConfirmerSuppression(URL)
{
    if (confirm("Etes-vous sûr de vouloir supprimer cet enregistrement (cette opération est irréversible) ?"))
    {
        window.location = URL ;
    }
} // fin f_ConfirmerSuppression

//******************************************************************************
//**   Confirmation de copie récursive
//******************************************************************************
function f_ConfirmerCopieRecursive(URL)
{
    if (confirm("Etes-vous sûr de vouloir faire une copie récursive de cet enregistrement ?"))
    {
        window.location = URL ;
    }
} // fin f_ConfirmerCopieRecursive

//******************************************************************************
//**   Test si une valeur ne contient que les caractères a-z et 0-9
//******************************************************************************
function f_TestCode(p_code)
{
    var reg = /^[a-zA-Z0-9_]+$/ ;
    if (!reg.test(p_code))
    {
        return false ;
    }
    return true ;
} // f_TestCode

//******************************************************************************
//**   Test si une valeur est numérique uniquement
//******************************************************************************
function f_TestChiffres(entree)
{
      var seulement_ca ="0123456789.,-" ;
      for (a = 0; a < entree.length; a++)
       {
           if (seulement_ca.indexOf(entree.charAt(a))<0 ) return false;
    }
      return true ;
} // fin f_TestChiffres

//******************************************************************************
//**   Test si une valeur est un e-mail valide
//******************************************************************************
function f_TestEmail(entree)
{
    var supported = 0 ;
    if (window.RegExp)
    {
        var tempStr = "a" ;
        var tempReg = new RegExp(tempStr) ;
        if (tempReg.test(tempStr))
        {
            supported = 1 ;
        }
      }
      if (!supported)
    {
        return (str.indexOf(".") > 2) && (str.indexOf("@") > 0) ;
    }
      var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)") ;
      var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$") ;
      return (!r1.test(entree) && r2.test(entree)) ;
    
} // fin f_TestEmail

//******************************************************************************
//**   Test si une valeur est une date valide
//******************************************************************************
function f_TestDate(entree)
{
    expression_regulaire=/^[0123]{1}\d{1}\/[01]{1}\d{1}\/\d{4}$/ ;

    if (expression_regulaire.test(entree))
    {
        return true ;
    }
    else
    {
        return false ;
    }
} // fin f_TestDate

//******************************************************************************
//**   Test la validité de noms d'images
//******************************************************************************
function f_TestImage(entree)
{
    tableau=entree.split(".")
    if ((tableau[tableau.length-1] != "jpg") && (tableau[tableau.length-1] != "gif") && (tableau[tableau.length-1] != "png") && (tableau[tableau.length-1] != "JPG") && (tableau[tableau.length-1] != "GIF") && (tableau[tableau.length-1] != "PNG")&&(tableau[tableau.length-1] != "jpeg")&&(tableau[tableau.length-1] != "JPEG"))
    {
        return false ;
    }
    else
    {
        return true ;
    }
} // fin f_TestImage

//******************************************************************************
//**   Test la longueur d'une chaîne
//******************************************************************************
function f_TestTaille(entree,longueur)
{
    expression_regulaire=new RegExp("^[a-zA-Z0-9]{0,"+longueur+"}$") ;
    if (expression_regulaire.test(entree))
    {
        return true ;
    }
    else
    {
        return false ;
    }

} // fin f_TestTaille

//******************************************************************************
//**   Fonction de l'administration rapide permettant l'affichage de l'arbre
//******************************************************************************
function f_arbre_deplier(p_entree,p_action)
{
    if (p_action=="deplier")
    {
        if ((document.form_arbre.elements[p_entree].value=="deplier") || (document.form_arbre.elements[p_entree].value=="depliertout"))
        {
            document.form_arbre.elements[p_entree].value="repliertout" ;
        }
        else
        {
            document.form_arbre.elements[p_entree].value="deplier" ;
        }
    }
    else
    {
        if ((document.form_arbre.elements[p_entree].value=="deplier") || (document.form_arbre.elements[p_entree].value=="depliertout"))
        {
            document.form_arbre.elements[p_entree].value="repliertout" ;
        }
        else
        {
            document.form_arbre.elements[p_entree].value="depliertout" ;
        }
    }

    document.form_arbre.action="#" + p_entree ;
    
    document.form_arbre.submit() ;
    
} // f_arbre_deplier

//******************************************************************************
//**   Fonction qui permet d'appliquer une valeur a plusieurs variables de type form1.v_val1, form1.v_val2, form1.v_val3... 
//******************************************************************************
function f_appliquer_a_tout(form_in, form_val)
{
    var i=1;
    while(1)
    {
        if(eval(form_in+i))
        {
            eval(form_in+i+".value="+form_val+".value") ;
            i++ ;
        }
        else
            break ;
    }
} // f_appliquer_a_tout

//******************************************************************************
//**   Permet dans recherche rapide de faire des search replace dans une colonne entiere
//******************************************************************************
function f_rech_rempl_a_tout(form_in, form_rech, form_rempl)
{
    var i=1;
    
    if (eval("val_rech = "+form_rech+".value") != "")
    {
        while(1)
        {
            if(eval(form_in+i))
            {
                eval("val_res = "+form_in+i+".value") ;
                eval("val_rech = "+form_rech+".value") ;
                eval("val_rempl = "+form_rempl+".value") ;
                eval("var n = val_res.replace(/"+val_rech+"/,\""+val_rempl+"\")") ;
                eval(form_in+i+".value = n" ) ;
                i++ ;
            }
            else
                break ;
        }
    }
    else
        alert("Vous devez d'abord indiquer une valeur à rechercher") ;

} // f_rech_rempl_a_tout

//******************************************************************************
//**   
//******************************************************************************
function f_popup_aide(p_texte,p_chemin_serveur)
{
    tableau_aide='<table width="200" border="0" cellspacing="0" cellpadding="0">' ;
    tableau_aide+='  <tr height="11">' ;
    tableau_aide+='    <td width="21" colspan="2"><img src="aide/coin_hg.gif" width="21" height="11"></td>' ;
    tableau_aide+='    <td valign="top"><img src="aide/pixel_orange.gif" width="100%" height="1"></td>' ;
    tableau_aide+='    <td width="21" colspan="2"><img src="aide/coin_hd.gif" width="21" height="11"></td>' ;
    tableau_aide+='  </tr>' ;
    tableau_aide+='  <tr>' ;
    tableau_aide+='    <td width="1" bgcolor="#FF3300"><img src="aide/pixel_orange.gif" width="1" height="1"></td>' ;
    tableau_aide+='    <td width="20">&nbsp;</td>' ;
    tableau_aide+='    <td width="100%">' + p_texte + '</td>' ;
    tableau_aide+='    <td width="20">&nbsp;</td>' ;
    tableau_aide+='    <td align="right" width="1" bgcolor="#FF3300"><img src="aide/pixel_orange.gif" width="1" height="1"></td>' ;
    tableau_aide+='  </tr>' ;
    tableau_aide+='  <tr height="22">' ;
    tableau_aide+='    <td colspan="2"><img src="aide/coin_bg.gif" width="21" height="22"></td>' ;
    tableau_aide+='    <td valign="bottom"><img src="aide/pixel_orange.gif" width="100%" height="1"></td>' ;
    tableau_aide+='    <td colspan="2"><img src="aide/coin_bd.gif" width="21" height="22"></td>' ;
    tableau_aide+='  </tr>' ;
    tableau_aide+='</table>' ;

    document.write(tableau_aide) ;
} // f_popup_aide

//******************************************************************************
//**   Fonction de cochage et décochage des cases à cocher
//******************************************************************************
function f_checkboxes(p_form, p_valeur)
{
    var elts      = document.forms[p_form].elements['selected_tbl[]'] ;
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0 ;
    
    if (elts_cnt)
    {
        for (var i = 0; i < elts_cnt; i++)
        {
            if (p_valeur == "inverser")
            {
                if (elts[i].checked == true)
                    elts[i].checked = false ;
                else
                    elts[i].checked = true ;
            }
            else
                elts[i].checked = p_valeur;
        } // end for
    }
    else
    {
        elts.checked        = p_valeur ;
    } // end if... else

    return true ;
} // f_checkboxes

//******************************************************************************
//**   Fonction d'ouverture d'un popup
//******************************************************************************
function f_popup(p_url, p_nom, p_width, p_height, p_left, p_top, p_menu, p_scroll, p_tool, p_status, p_resizable, p_location)
{
    var strProperties ;
    var wbg_popup ;
    
    if (p_top == "center")
        p_top = (screen.height - p_height) / 2 ;
    
    if (p_left == "center")
        p_left = (screen.width - p_width) / 2 ;
    
    strProperties = 'width=' + p_width + ',height=' + p_height ;
    strProperties = strProperties + ',left='+ p_left +',top='+ p_top +',directories=0,hotkeys=1' ;
    strProperties = strProperties + ',menubar='+p_menu +',scrollbars='+p_scroll+',toolbar='+p_tool+',status='+p_status ;
    strProperties = strProperties + ',resizable='+p_resizable+',location='+p_location ;
    wbg_popup = window.open(p_url, p_nom, strProperties) ;
    return ;
}
//******************************************************************************
//**   Popup diaporama
//******************************************************************************
function f_popup_diaporama(p_chemin,code_diaporama)
{
    // Définition de la largeur et de la hauteur de la fenêtre, à modifier selon les cas
    LargeurFenetre = 400;
    HauteurFenetre = 350;
    // Calcul des coordonnées du point supérieur gauche de la fenêtre
    PixelsDepuisHaut = (screen.height - HauteurFenetre) / 2 ;
    PixelsDepuisGauche = (screen.width - LargeurFenetre) / 2 ;
    // Construction des paramètres du window.open
    ParametresOuverture = "width=" + LargeurFenetre + " ,height=" + HauteurFenetre + " ,top=" + PixelsDepuisHaut + " ,left =" + PixelsDepuisGauche ;
    // Ouverture de la fenêtre, à gérer ensuite comme n'importe quelle fenêtre (en utilisant son nom ;-))
    url_diaporama = p_chemin+"pages/diaporama.php?s_code="+code_diaporama+"&action=1";
    windowscreencenter = window.open(url_diaporama,"Diaporama",ParametresOuverture).focus() ;
} // f_popup_diaporama

//******************************************************************************
//**   f_affecte_valeur_champ
//******************************************************************************
function f_affecte_valeur_champ(p_form,p_champ_source,p_champ_cible)
{
    var form = document.forms[p_form];
    var source = form.elements[p_champ_source];
    var cible = form.elements[p_champ_cible];
    
    cible.value = source.value;
} // f_affecte_valeur_champ

//******************************************************************************
//**   Fonction de lecteur d'un cookie
//******************************************************************************
function getCookie(name)
{
    var cname = name + "=";               
    var dc = document.cookie;             
    
    if (dc.length > 0)
    {              
        begin = dc.indexOf(cname);       
        if (begin != -1)
        {
            begin += cname.length;
            end = dc.indexOf(";", begin);
            if (end == -1) end = dc.length;
            return unescape(dc.substring(begin, end));
         } 
    }
} // getCookie

//******************************************************************************
//**   Fonction d'écriture d'un cookie : on passe en paramètre son nom, sa valeur, et
//**   une date d'expiration en milisecondes (1 jour = 1000 * 60 * 60 * 24)
//**
//**   Exemple :     var expdate = new Date ();
//**                   expdate.setTime (expdate.getTime() + (12 * 60 * 60 * 1000));
//**                   setCookie("memento",TexteCookie,expdate) ;
//**
//******************************************************************************
function setCookie(name, value, expires)
{
    document.cookie = name + "=" + escape(value) + 
    ((expires != null) ? "; expires=" + expires.toGMTString() : "")
    + "; path=/";
} // setCookie

//******************************************************************************
//**   Fonction de recherche remplace (p_recherche est un regexp)
//******************************************************************************
function f_recherche_remplace(p_recherche,p_remplace,p_var)
{
    resultat=p_var.search(eval(p_recherche))
    if(resultat != -1)
    {
        p_var = p_var.replace(eval(p_recherche),p_remplace) ;
        p_var = f_recherche_remplace(p_recherche,p_remplace,p_var) ;
    }
    
    return p_var ;
} // f_recherche_remplace

//******************************************************************************
//**   RollOver Macromedia
//******************************************************************************
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}//RollOver Macromedia

//******************************************************************************
//**   Converti une date au format jjmmaa au format jj/mm/aaaa
//******************************************************************************
function f_date_formatage(p_date)
{
    resultat = p_date.search("/") ;
    
    if(resultat == -1)
    {
        jour = p_date.substr(0,2) ;
        mois = p_date.substr(2,2) ;
        annee = p_date.substr(4,2) ;
        
        if (annee < 10)
            annee = "20" + annee ;
        else
            annee = "19" + annee ;
        
        v_date = jour + "/" + mois + "/" + annee ;
    }
    else
        v_date = p_date ;
    
    return v_date ;
}

// f_listedyn
function f_listedyn(p_param,p_liste_1,p_champ_1,p_champ_2)
{
    //***************************** NE PAS EFFACER *****************************//
    /*menu=new Array() ;
    menu[1]=new Array() ;
    menu[1][0]=new Option("","") ;
    <select name="choix_table" onChange="f_listedyn(this.form,this.name,'tri_table','tri_champs')"
    <option value="Javascript:f_listedyn_change('form_commande','choix_table','tri_champs','menu',1)">*/
    //***************************** NE PAS EFFACER *****************************//

    if (eval("p_param."+p_liste_1+".selectedIndex") == 0)
    {
        eval("p_param."+p_champ_1+".value = \"\"") ;
        eval("p_param."+p_champ_2+".value = \"\"") ;
    }
    else
    {
        window.top.location.href = eval("p_param."+p_liste_1+".options["+eval("p_param."+p_liste_1+".selectedIndex")+"].value") ;
        eval("p_param."+p_champ_1+".value = p_param."+p_liste_1+".options["+eval("p_param."+p_liste_1+".selectedIndex")+"].text") ;
        eval("p_param."+p_champ_2+".value = \"\"") ;
    }
}// f_listedyn

// f_listedyn_change
function f_listedyn_change(p_form,p_champ_1,p_champ_2,p_var_tableau,z)
{
    for (a = eval("document." + p_form + "." + p_champ_2 + ".options.length-1") ; a>0 ; a--)
    {
        eval("document." + p_form + "." + p_champ_2 + ".options[a]=null") ;
    }
    
    for (a=0;a<eval(p_var_tableau+"["+z+"].length");a++)
    {
        eval("document." + p_form + "." + p_champ_2 + ".options["+a+"] = new Option('"+eval(p_var_tableau+"["+z+"]["+a+"].text")+"','"+eval(p_var_tableau+"["+z+"]["+a+"].value")+"')") ;
    }
    eval("document." + p_form + "." + p_champ_2 + ".selectedIndex = 0") ;
}// f_listedyn_change

//****************************************************************************** 
//** Teste si une valeur est un entier positif 
//****************************************************************************** 
function f_TestEntierPositif(entree) 
{ 
var seulement_ca ="0123456789"; 
for (a = 0; a < entree.length; a++) 
{ 
if (seulement_ca.indexOf(entree.charAt(a))<0 ) return false; 
} 
return true; 
} // fin f_TestEntierPositif 

//****************************************************************************** 
//** Teste si une valeur contient au moins un chiffre 
//****************************************************************************** 
function f_TestContientChiffre(entree) 
{ 
var seulement_ca ="0123456789"; 
for (a = 0; a < entree.length; a++) 
{ 
if (seulement_ca.indexOf(entree.charAt(a))>0 ) return true; 
} 
return false; 
} // fin f_TestContientChiffre 

//****************************************************************************** 
//** Test la validité d'une date, y compris l'adéquation mois / jour / année 
//****************************************************************************** 
function f_TestDateEtendu(d) { 

if (d == "") // si la variable est vide on retourne faux 
return false; 

e = new RegExp("^[0-9]{1,2}\/[0-9]{1,2}\/([0-9]{2}|[0-9]{4})$"); 

if (!e.test(d)) // On teste l'expression régulière pour valider la forme de la date 
return false; // Si pas bon, retourne faux 

// On sépare la date en 3 variables pour vérification, parseInt() converti du texte en entier 
j = parseInt(d.split("/")[0], 10); // jour 
m = parseInt(d.split("/")[1], 10); // mois 
a = parseInt(d.split("/")[2], 10); // année 

// Si l'année n'est composée que de 2 chiffres on complète automatiquement 
if (a < 1000) { 
if (a < 89) a+=2000; // Si a < 89 alors on ajoute 2000 sinon on ajoute 1900 
else a+=1900; 
} 

// Définition du dernier jour de février 
// Année bissextile si annnée divisible par 4 et que ce n'est pas un siècle, ou bien si divisible par 400 
if (a%4 == 0 && a%100 !=0 || a%400 == 0) fev = 29; 
else fev = 28; 

// Nombre de jours pour chaque mois 
nbJours = new Array(31,fev,31,30,31,30,31,31,30,31,30,31); 

// Enfin, retourne vrai si le jour est bien entre 1 et le bon nombre de jours, idem pour les mois, sinon retourn faux 
return ( m >= 1 && m <=12 && j >= 1 && j <= nbJours[m-1] ); 
} 

//******************************************************************************
//*** permet de tester si une date est bien dans le futur par rapport à la date du jour
//******************************************************************************
function f_TestDateFutur(d)
{
    aujourdhui = new Date() ; 
    d = document.form_creation.s_date_maj.value ; 
    j = parseInt(d.split("/")[0], 10); // jour 
    m = parseInt(d.split("/")[1], 10); // mois 
    a = parseInt(d.split("/")[2], 10); // année 
    datemaj = new Date(a,m-1,j,23,59,59) ; 

    if (datemaj.getTime() < aujourdhui.getTime()) 
        return false;

    return true;
}   //f_TestDateFutur

//*****************************************************
//** Affiche ou masque un élément et change une image
//** en correspondance (facultatif)
//****************************************************
function f_Affiche(p_Element,p_Image,p_Image2,p_chemin)
{

	var elem = document.getElementById(p_Element);

	if( elem.style.display == '')
	{
		elem.style.display='none';
		if (p_Image != '') {
			document.images[p_Image].src = p_chemin + "img/display/" + p_Image2 + ".gif";
		}
	}
	else
	{
		elem.style.display='';
		if (p_Image != '') {
			document.images[p_Image].src = p_chemin + "img/display/" + p_Image2 + "2.gif";
		}
	}
}
//*****************************************************
//** Affiche ou masque un groupe d'éléments et change une image
//** en correspondance (facultatif)
//****************************************************
function f_Affiche2(p_Element,p_Image,p_Image2,p_chemin)
{
	for (i = 1 ; i < p_Element.length ; i++)
	{
		
		var elem = document.getElementById(p_Element[i]);
		
		if (elem == null) 
			continue;
		
		if( elem.style.display == '')
		{
			elem.style.display='none';
			if (p_Image != '') {
			document.images[p_Image].src = p_chemin + "img/display/" + p_Image2 + ".gif";
			}
		}
		else
		{
			elem.style.display='';
			if (p_Image != '') {
			document.images[p_Image].src = p_chemin + "img/display/" + p_Image2 + "2.gif";
			}
		}
	}
}

// Cette fonction est utilisé pour les boutons "suite" qui affichent leur contenu sur une ligne inférieure.

function ChangeText(text, p_chemin, tableau_valeur, ligne, colonne)
{

var elemTR1 = document.getElementById("L" + ligne);
var elemTD1 = document.getElementById("ligne_aveugle" + ligne);
var elemImg1 = document.getElementById("img_" + colonne + "_" + ligne);
if (elemTD1.innerHTML.indexOf(text) == -1)
	{
for (i = 0 ; i < tableau_valeur.length ; i++) //RAZ
{
		var elemTR = document.getElementById("L" + ligne);
		var elemTD = document.getElementById("ligne_aveugle" + ligne);
		var elemImg = document.getElementById("img_" + tableau_valeur[i] + "_" + ligne);
		elemTD.innerHTML = '';
		elemImg.src = p_chemin+"suite.gif";
		elemTR.style.display='none';
	}

	elemTD1.innerHTML = "<img src='"+p_chemin+"suite2.gif' border='0' align='bottom'>"+elemImg1.alt;
	elemTR1.style.display='';
	elemImg1.src = p_chemin+"suite2.gif";
	}

else
{
	for (i = 0 ; i < tableau_valeur.length ; i++) //RAZ
{
		var elemTR = document.getElementById("L" + ligne);
		var elemTD = document.getElementById("ligne_aveugle" + ligne);
		var elemImg = document.getElementById("img_" + tableau_valeur[i] + "_" + ligne);
		elemTD.innerHTML = '';
		elemImg.src = p_chemin+"suite.gif";
		elemTR.style.display='none';
	}

	
	}

}

// Fonction pour preloader des images. Utilisée pour les regroupements / degroupements et les icones de texte "suite"...

function preload_em() { 
img_1 = new Image
img_2 = new Image
img_3 = new Image
img_4 = new Image
 
img_1.src = "../img/defaut/suite2.gif"
img_2.src = "../img/defaut/suite.gif"
img_3.src = "../../themes/defaut/img/display/plus2.gif"
img_4.src = "../../themes/defaut/img/display/plus.gif"

}

//************************************************************************//
//*************** Fonctions de protection des emails**********************//
//************************************************************************//

// echange un caractere
function replaceChar(theString, oldChar, newChar) {
	var i = 0;
	var j = theString.length;

	for(i=0; i < theString.length; i++) {
		if(theString.charAt(i) == oldChar) {
			theString = theString.substring(0,i) + newChar +
			theString.substring(i+1,theString.length);
			if(i > j) { // loop-killer, just in case we mess with the code
				break;
			}
		}
	}
return theString;
}

// lien mailto avec ("mail|domaine.com")
function protected_mail_display(mail){
	if(mail.length !=0){
		
		var i=0;
		for (i=0;i<=mail.length;i++){
			if (mail.charAt(i) == "|"){
				mail = replaceChar(mail,"|","@");			
			}
		}		
			document.write("<a href=\"mailto:"+mail+"\">"+mail+"</a>");
	}
		
}
// lien mailto avec ("mail|domaine.com")
function protected_mail_display_text(mail,text,classss){
	
	
	if(mail.length !=0){
		
		if (text == mail) { text = "" ;}
		var i=0;
		for (i=0;i<=mail.length;i++){
			if (mail.charAt(i) == "|"){
				mail = replaceChar(mail,"|","@");			
			}
		}
		if (text == "") { text = mail ;}		
			document.write("<a class="+classss+" href=\"mailto:"+mail+"\">"+text+"</a>");
	}		
}

// lien mailto avec ("mail|domaine.com",subject)
// sans le texte correspondant 
// util pour placer des images 
// !!!  fermer la balise </a>!!!

function protected_mail_display2(mail,subject){

	if(mail.length !=0){
		
		var i=0;
		for (i=0;i<=mail.length;i++){
			if (mail.charAt(i) == "|"){
				mail = replaceChar(mail,"|","@");			
			}
		}
		document.write("<a href=\"mailto:"+mail+"?subject="+subject+"\">");
	}
		
}

// lien mailto avec ("mail|domaine.com",subject)
// avec le texte correspondant
function protected_mail_display3(mail,subject){

	if(mail.length !=0){
		
		var i=0;
		for (i=0;i<=mail.length;i++){
			if (mail.charAt(i) == "|"){
				mail = replaceChar(mail,"|","@");
			}
		}
		document.write("<a href=\"mailto:"+mail+"?subject="+subject+"\">"+mail+"</a>");
	}
		
}
// -------------------------------------------------------------------------------------------------------------------
// Fonctions de lecture et d'écriture d'un cookie
// -------------------------------------------------------------------------------------------------------------------

// Fonction de lecteur d'un cookie
function f_getCookie(name)
{

var cname = name + "=";
var dc = document.cookie;
//alert(dc.length);
if (dc.length > 0)
{
begin = dc.indexOf(cname);
if (begin != -1)
{
begin += cname.length;
end = dc.indexOf(";", begin);
	if (end == -1) {
		end = dc.length;
		return unescape(dc.substring(begin, end));
	}
}
return "";
}
}
// Fonction d'écriture d'un cookie : on passe en paramètre son nom, sa valeur, et
// une durée de validité en minutes
function f_setCookie(name, value, duree)
{
	var expires=new Date() ;
	expires.setTime(expires.getTime() + (1000 * 60 * duree)) ;
	document.cookie = name + "=" + escape(value) +
	((expires != null) ? "; expires=" + expires.toGMTString() : "")
	+ "; path=/";
}

function opencarte(url){
		if(screen.width >= 1024){
			var w = 1020;
			var h = 642;
		}
		else{
			var w = 796;
			var h = 474;
		}
		window.open(url,'','width='+w+', height='+h+', scrollbars=0, resizable=yes, menubar=yes');
}

function infoslegales(url){
		window.open(url,'','width=520, height=650, scrollbars=yes, resizable=yes, menubar=no');
}
function openmeteo(){
	if(document.getElementById('Layer1').style.display == 'block') {
		document.getElementById('Layer1').style.display = 'none';
	}else{
		document.getElementById('Layer1').style.display = 'block';
	}
}

function popup() {
	alert('(^_^)');
}

// changement de la racine sur le select en haut de page dans l'entete.inc.php.
// chemin (parametre pour avoir l'url du site)
function change_index (chemin){
	var page_cible = chemin + "index.php?r="+document.getElementById('choix_index').value;
	document.getElementById('hidden_r').value=document.getElementById('choix_index').value;
	
	document.getElementById('form_choix_index').action=page_cible;
	//alert ("action="+document.getElementById('form_choix_index').action);
	document.getElementById('form_choix_index').submit();		
}

// ouvre le lien choisi dans une nouvelle fenetre.
function ouvre_lien (){
	//alert(document.getElementById('choix_lien').value);
	if ("" != document.getElementById('choix_lien').value){
		var tab_lien = document.getElementById('choix_lien').value.split("##");
		if (tab_lien[1] == "_Blank") {
			window.open(tab_lien[0]);	
		}
		if (tab_lien[1] == "_Self") {
			window.location = tab_lien[0];	
		}		
	}	
}
 
 /*! \brief Enlève les espaces avant / après une chaîne
* description détaillée
* \author ablavot (en fait Olivier Brouckaert, soyons honnête)
* \param $p_Chaine La chaîne...
* \return La chaîne sans espaces avant et après
*/
function f_Trim(p_Chaine)
{
  if (p_Chaine != null) {
    return p_Chaine.replace(/(^\s*)|(\s*$)/g,'');  
  } else {
    return "" ;
  }
} // f_Trim

/*
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*								Début des fonctions alert2
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*/

function alert2Close(o, e)
{
	//Effet lors de la disparition
	//alerteWeb20PopUp = this.getEl();
	//alerteWeb20PopUp.frame("#6B6B70");

	//Disparition
	this.destroy();
}

/**
 * Popup d'alert JS en web 2.0 (comme "alert" du JS standard, mais en HTML)
 *
 * Calcul de la taille du body auto
 *
 * @param title : Le titre de la fenetre (possibilité d'inclure une image en 16*16 dans le titre, <img src="..." />)
 * @param msg : le body de la fenetre
 * @param sizeMinX : le minimum de la fenetre en X (c'est une option)
 * @param sizeMinY : le minimum de la fenetre en Y (c'est une option)
 * @author gmocquet
 */
function alert2(title, msg, sizeMinX, sizeMinY) 
{
	unikId = Ext.id();
	
	if (sizeMinX == "")
	{
		sizeMinX = 0;
	}

	if (sizeMinY == "")
	{
		sizeMinY = 0;
	}
	
	var alerteWeb20PopUp = new Ext.BasicDialog('alerte2PopUp_' + unikId, 
		{
			autoCreate: true,
		 	autoScroll: true,
			buttonAlign: 'center',
		    modal: true,
		    minHeight: sizeMinY, 
		    minWidth: sizeMinX,
		    proxyDrag: false,
	    	shadow: true,
	    	collapsible: false,
    	 	closable: true,
	    	syncHeightBeforeShow: true,
	    	title: title
		});
	
	alerteWeb20PopUp.addKeyListener([27, 13], alert2Close, alerteWeb20PopUp); // ESC ou ENTER can also close the dialog
	alerteWeb20PopUp.addButton('OK', alert2Close, alerteWeb20PopUp);    		// Could call a save function instead of hiding
	alerteWeb20PopUp.body.update(msg);

	//Calcul de la taille
	//Stockage en temp.
	alerteWeb20PopUp_tempContainer = document.createElement("DIV");
	alerteWeb20PopUp_tempContainer.style.display = "block";
	alerteWeb20PopUp_tempContainer.style.visibility = "hidden";
	alerteWeb20PopUp_tempContainer.style.position = "absolute";
	alerteWeb20PopUp_tempContainer.style.top = "0px";
	alerteWeb20PopUp_tempContainer.style.left = "0px";		
	alerteWeb20PopUp_tempContainer.id = 'alerte2PopUp_' + unikId + '_tempContainer';
	document.body.appendChild(alerteWeb20PopUp_tempContainer);
	document.getElementById('alerte2PopUp_' + unikId + '_tempContainer').innerHTML = msg;

	//Calcul (quand ready)
	YAHOO.util.Event.onContentReady('alerte2PopUp_' + unikId + '_tempContainer', function(o) 
	{
		alerteWeb20PopUp = o.alerteWeb20PopUp;
		dataSizeX = document.getElementById('alerte2PopUp_' + unikId + '_tempContainer').offsetWidth;
		dataSizeY = document.getElementById('alerte2PopUp_' + unikId + '_tempContainer').offsetHeight;			
		
		alerteWeb20PopUp.setContentSize(dataSizeX, dataSizeY);
	    alerteWeb20PopUp.center();
		alerteWeb20PopUp.show();
			
	}, {alerteWeb20PopUp: alerteWeb20PopUp});
}

/**
 * Popup d'alert JS en web 2.0 (comme "alert" du JS standard, mais en HTML)
 *
 * dérivée de alert2 pour les affichages de retour d'ajax
 *
  * @param phpMsg : le body de la fenetre
  * @param msgIsError : "true" : le msg est de type erreur | "false" : c'est un succès
 * @author gmocquet
 */
function alert2MsgPHP(phpMsg, msgIsError)
{
	img_ext = 'png';
	if(Ext.isIE)
	{
		img_ext = 'gif';
	}

	if (msgIsError)
	{
		title = 'Error';
		img = 'croix.'+img_ext;
		infoCss = 'info_error';
	}
	else
	{
		title = 'Success';
		img = 'ok.'+img_ext;
		infoCss = 'info_success';
	}

	title = '<img src="' + c_chemin_img + 'action/warning_16.'+img_ext+'" align="absmiddle" alt="" />&nbsp;' + title;
	data = '<table class="popupAlerte2PhpMsgContener"><tr align="center"><td class="popupAlerte2PhpMsgImgSector"><img src="' + c_chemin_img + 'action/' + img +'" alt="" /></td><td class="popupAlerte2PhpMsgTxtSector '+infoCss+'">' + phpMsg + '</td></tr></table>';
	
	alert2(title, data);
}

/**
 * Popup d'alert JS en web 2.0 (comme "alert" du JS standard, mais en HTML)
 *
 * dérivée de alert2 pour les affichages d'erreures JSON
 *
  * @param msg : le body de la fenetre
 * @author gmocquet
 */
function alert2JSONError(msg)
{
	img_ext = 'png';
	if(Ext.isIE)
	{
		img_ext = 'gif';
	}
	
	title = 'PHP Error &raquo; Corrupted JSON Data';
	img = 'croix.'+img_ext;
	infoCss = 'info_error';
	
	//msg = 'Data written by PHP Script :<br />' + msg;
	
	title = '<img src="' + c_chemin_img + 'action/warning_16.'+img_ext+'" align="absmiddle" alt="" />&nbsp;' + title;
	data = '<table class="popupAlerte2PhpMsgContener"><tr align="center"><td class="popupAlerte2PhpMsgImgSector"><img src="' + c_chemin_img + 'action/' + img +'" alt="" /></td><td class="popupAlerte2PhpMsgTxtSector '+infoCss+'">' + msg + '</td></tr></table>';
	
	alert2(title, data);
}

/**
 * Popup d'alert JS en web 2.0 (comme "alert" du JS standard, mais en HTML)
 *
 * dérivée de alert2 pour les affichages d'erreures AJAX (Framework YUI)
 *
  * @param o : l'objet YUI AJAX
 * @author gmocquet
 */
function y_ajax_error(o) 
{
	img_ext = 'png';
	if(Ext.isIE)
	{
		img_ext = 'gif';
	}
	
	//Stop ajax
	YAHOO.util.Connect.abort(o);
	
	//Affichage d'un msg
	if (o.status == 0)
	{
		//Serveur Error

		alert2('<img src="' + c_chemin_img + 'action/warning_16.'+img_ext+'" align="absmiddle" alt="" />&nbsp;Server/Connection Troubles', '<div class="popupAlerte2ErrorContener"><div class="popupAlerte2ErrorImgSector"><img src="' + c_chemin_img + 'action/exclamation.'+img_ext+'" alt="" /></div><div class="popupAlerte2ErrorTxtSector"><div class="popupAlerte2ErrorTxtUp">Server error</div><div class="popupAlerte2ErrorTxtDown">Refresh your browser or retry later...</div></div></div>');
	}
	else if(o.status == -1)
	{
		//Time out...
		
		alert2('<img src="' + c_chemin_img + 'action/warning_16.'+img_ext+'" align="absmiddle" alt="" />&nbsp;Server/Connection Troubles', '<div class="popupAlerte2ErrorContener"><div class="popupAlerte2ErrorImgSector"><img src="' + c_chemin_img + 'action/reload.'+img_ext+'" alt="" /></div><div class="popupAlerte2ErrorTxtSector"><div class="popupAlerte2ErrorTxtUp">Connection Timeout</div><div class="popupAlerte2ErrorTxtDown">Refresh your browser or retry later...</div></div></div>');
	}
	else
	{
		//Server Error
		
		if (o.status)
		{
			//xxx Error (Server)
			dataWindows = '<div class="popupAlerte2ErrorContener"><div class="popupAlerte2ErrorImgSector"><img src="' + c_chemin_img + 'action/exclamation.'+img_ext+'" alt="" /></div><div class="popupAlerte2ErrorTxtSector"><div class="popupAlerte2ErrorTxtUp">Server error</div><div class="popupAlerte2ErrorTxtDown">';
			
			dataWindows += 'ERROR&nbsp;' + o.status + '&nbsp;-&nbsp;';
			
			switch(o.status)
			{
				case 404: dataWindows += 'Not Found'; break;
				case 500: dataWindows += 'Internal Server Error'; break;
				case 501: dataWindows += 'Not Implemented'; break;
				case 502: dataWindows += 'Bad Gateway'; break;
				case 503: dataWindows += 'Service Unavailable'; break;
				case 504: dataWindows += 'Gateway Timeout'; break;
				case 505: dataWindows += 'HTTP Version not supported'; break;
				case 403: dataWindows += 'Forbidden'; break;
				case 301: dataWindows += 'Moved Permanently'; break;
				case 307: dataWindows += 'Temporary Redirect';	 break;			
				default : dataWindows += 'Unknow'; break;
			}
			
			dataWindows += '</div></div></div>';
	
			
		
			alert2('<img src="' + c_chemin_img + 'action/warning_16.'+img_ext+'" align="absmiddle" alt="" />&nbsp;Server/Connection Troubles', dataWindows);
		}
		else
		{
			//Unknow Error
		
			alert2('<img src="' + c_chemin_img + 'action/warning_16.'+img_ext+'" align="absmiddle" alt="" />&nbsp;Server/Connection Troubles', '<div class="popupAlerte2ErrorContener"><div class="popupAlerte2ErrorImgSector"><img src="' + c_chemin_img + 'action/exclamation.'+img_ext+'" alt="" /></div><div class="popupAlerte2ErrorTxtSector"><div class="popupAlerte2ErrorTxtUp">Unknow error</div><div class="popupAlerte2ErrorTxtDown">Refresh your browser or retry later...</div></div></div>');
		}
	}
}

/*
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*								Fin des fonctions alert2
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*/

/*
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*								Début des fonctions captcha-Ajax
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*/
/*! \brief f_creer_XmlHttpRequestObject: fonction qui sert à créer un objet XMLHttpRequest
*
* fonction qui sert à créer un objet XMLHttpRequest en réspectant les incompatibilité des fruteurs (IE, Firefox, etc.)
* \author akahlaoui <céation de la fonction>
* \return crée et retourne un objet XMLHttpRequest
*/ 
// stocker la référence de l'objet XMLHttpRequest
var xmlHttp = f_creer_XmlHttpRequestObject();
// retrouver l'objet XMLHttpRequest
function f_creer_XmlHttpRequestObject() {
	// stocker la référence de l'objet XMLHttpRequest
	var xmlHttp;
	// si on est dans un environnement Internet Explorer
	if(window.ActiveXObject) {
		try	{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) {
			xmlHttp = false;
		}
	}
	// si on est dans un environnement Mozilla or other browsers
	else {
		try	{
			xmlHttp = new XMLHttpRequest();
		}
		catch (e) {
			xmlHttp = false;
		}
	}
	// retourner l'objet créé ou afficher un message d'erreur dans le cas echéant
	if (!xmlHttp)
		alert("Error creating the XMLHttpRequest object.");
	else
		return xmlHttp;
}

/*! \brief f_verifier_captcha: fonction qui sert à faire une requête HTTP asynchrone en utilisant l'object  XMLHttpRequest
*
* la fonction utilise l'objet XMLHttpRequest, créé par la fonction f_creer_XmlHttpRequestObject, pour etablir une connexion ave le programme distant sur le serveur et en envoir des reqêttes
* \author akahlaoui <céation de la fonction>
 * \param chemin_serveur: indique le chemin serveur du programme à executer sur le serveur
* \return la fonction retourne un objet XMLHttpRequest
*/

function f_verifier_captcha(chemin_serveur) {
	// avant de procéder, on vérifie d'abord que l'objet xmlHttp et libre
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)	{
		// retrrouver le code_captcha saisi par l'usager
		code_captcha = encodeURIComponent(document.getElementById("s_code_captcha").value);
		// executer le programme distant sur le serveur
		xmlHttp.open("GET", chemin_serveur + "captcha/verifier_captcha.php?code_captcha=" + code_captcha, true);
		// spécifier la fonction qui prendra en charge les réponses du serveur
		xmlHttp.onreadystatechange = f_traiter_reponse_serveur;
		// envoyer la requêtte
		xmlHttp.send(null);
	}
	else
		// si l'objet xmlHttp est occupé, on réessaie dans une seconde
		setTimeout('f_verifier_captcha()', 1000);
}

/*! \brief f_traiter_reponse_serveur: fonction qui sert à créer un objet XMLHttpRequest
*
* fonction qui sert à créer un objet XMLHttpRequest en réspectant les incompatibilité des fruteurs (IE, Firefox, etc.)
* la fonction est exécutée automatiqument quand un message est reuçu du serveur
* \author akahlaoui <céation de la fonction>
* \return crée et retourne un objet XMLHttpRequest
*/ 

function f_traiter_reponse_serveur() {
	if (xmlHttp.readyState == 4) {
		// status de 200 indique que la transaction terminée avec succès
		if (xmlHttp.status == 200) {
			// extraire le XML reçu du serveur
			xmlResponse = xmlHttp.responseXML;
			// obtenir la racine du document XML
			xmlDocumentElement = xmlResponse.documentElement;
			// récupérer le texte du message, qui est stocké dans le premier enfant
			reponse_serveur = xmlDocumentElement.firstChild.data;
			// vérifier la réponse du serveur
			if (reponse_serveur == "OK")
				document.getElementById("h_drapeau_captcha").value = 'true';
			else
				document.getElementById("h_drapeau_captcha").value = 'false';
		}
		// si le status HTTP est different de 200 -> signaler une erreur
		else {
			alert("There was a problem accessing the server: " +
			xmlHttp.statusText + "--" + xmlHttp.status);
		}
	}
}

/*! \brief bon_captcha: fonction qui sert à tester l'exactitude de la saisie du code captcha 
*
* fonction qui sert à tester l'exactitude de la saisie du code captcha
* \author akahlaoui <céation de la fonction>
* \return retourne un boulean
*/
function captcha_est_correct() {
	if (document.getElementById("h_drapeau_captcha").value == 'true')
		return true;
	else
		return false;
}

/*! \brief f_tri_par: fonction qui sert à remplir le deuxième menu de tri (desc ou asc ...)
*
* fonction qui sert à remplir le deuxième menu de tri (desc ou asc ...) selon la valeur du champ de tri sélectionné
* \author aelattar <céation de la fonction>
* \return retourne un menu déroulant
*/
function f_tri_par(champ, formName) {
	eval("document."+formName+".s_OrdreTri_perso").options.length=0;
	if(champ=="surf"){
		var option = new Option(" < 5000 m² ", "SURF1", false, false);
		eval("document."+formName+".s_OrdreTri_perso").options[1]=option;
		var option = new Option(" entre 5000 et 10000 m² ", "SURF2", false, false);
		eval("document."+formName+".s_OrdreTri_perso").options[2]=option;
		var option = new Option(" > 10000 m² ", "SURF3", false, false);
		eval("document."+formName+".s_OrdreTri_perso").options[3]=option;
	}
	if(champ=="parTrim" || champ=="dpt"){
		var option = new Option(" Croissant ", "ASC", false, false);
		eval("document."+formName+".s_OrdreTri_perso").options[1]=option;
		var option = new Option(" Décroissant ", "DESC", false, false);
		eval("document."+formName+".s_OrdreTri_perso").options[2]=option;
	}
	eval("document."+formName+".s_OrdreTri_perso").style.display = '';
	if(champ=="bat_neufs" || champ=="bat_renoves" || champ==""){
		eval("document."+formName+".s_OrdreTri_perso").style.display = 'none';
	}
}
 
/*
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*								Fin des fonctions captcha-Ajax
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------------------------------------------------------------------------
*/



function affichePopup(code)
{
	
	popupv2_withoutengine(c_chemin+"pages/popup/detail_prj_europark.php?s_id_ville="+code+"&s_wbg_menu=206");
}


function popupv2_withoutengine(urlToLoad__180)
{
	var dialog__180;
	var ts=new Date().getTime();
	//Les bordures de la fenêtre en fonction des navigateurs
	windows_border_X = 26;
	windows_border_Y = 47;
	if(Ext.isGecko)
	{
		windows_border_X = 30;
		windows_border_Y = 51;                      
	}       
	windows_body = '';
	
	windows_dataTitle = 'Loading...';
	windows_dataData = document.createElement("IMG");
	windows_dataData.src = c_chemin+'lib/engine/engine_windows/img/loading_1.gif';
	windows_dataData.alt = 'Loading...';    
	
	windows_tempContainer = document.createElement("DIV");
	windows_tempContainer.style.display = "block";
	windows_tempContainer.style.visibility = "hidden";
	windows_tempContainer.style.position = "absolute";
	windows_tempContainer.style.top = "0px";
	windows_tempContainer.style.left = "0px";       
	windows_tempContainer.id = 'windowsTempContainer__'+ts;
	document.body.appendChild(windows_tempContainer);
	
	windows_container = document.createElement("DIV");
	windows_container.id = 'windows__'+ts;
	windows_container.style.visibility = 'hidden';
	windows_container.style.position = 'absolute';
	windows_container.style.top = '0px';
	document.body.appendChild(windows_container);
	
	windows_titleDiv = document.createElement("DIV");
	windows_titleDiv.className = "x-dlg-hd";
	windows_container.appendChild(windows_titleDiv);
	windows_titleData = document.createTextNode(windows_dataTitle);
	windows_titleDiv.appendChild(windows_titleData);
	
	windows_borderDiv = document.createElement("DIV");
	windows_borderDiv.className = "x-dlg-bd";
	windows_container.appendChild(windows_borderDiv);
	
	windows_dataDiv = document.createElement("DIV");
	windows_dataDiv.id = 'windowsData__'+ts;
	windows_dataDiv.className = "inner-tab";
	windows_borderDiv.appendChild(windows_dataDiv);
	windows_dataDiv.appendChild(windows_dataData);      
		
	dialog__180 = new Ext.BasicDialog('windows__'+ts, 
	{ 
	   autoCreate: true, 
	   title: 'Loading...', 
	   width: 100 + windows_border_X,
	   height: 100 + windows_border_Y,
	   animateTarget: null,
	   resizable: true,
	   resizeHandles: 'all',
	   minWidth: 0 + windows_border_X,
	   minHeight: 0 + windows_border_Y,
	   modal: false,
	   autoScroll: true,
	   closable: true,
	   constraintoviewport: true,
	   syncHeightBeforeShow: false,
	   syncWidthBeforeShow: false,
	   draggable: true,
	   autoTabs: false, 
	   tabTag: 'div', 
	   proxyDrag: false, 
	   fixedcenter: false,
	   shadow: false,
	   buttonAlign: 'right',
	   minButtonWidth: 75,
	   shim: true  
	});

	var load_ajaxContent = function(dialog)  
	{
		if(document.getElementById('windowsTempContainer__'+ts).hasChildNodes() === false || false)
		{ 
			var url = urlToLoad__180;
			var param = '';

			var sUrl = url;
	
			function showPage(o)
			{
				dialog = o.argument.o_windows;
				windows_border_X = o.argument.windows_border_X;
				windows_border_Y = o.argument.windows_border_Y;
				
				document.getElementById('windowsTempContainer__'+ts).innerHTML = o.responseText;
			
				YAHOO.util.Event.onContentReady('windowsTempContainer__'+ts, function(o) 
				{
					dialog = o.o_windows;
					windows_border_X = o.windows_border_X;
					windows_border_Y = o.windows_border_Y;
					
					windows_new_sizeX = document.getElementById('contenu').offsetWidth;
					windows_new_sizeY = document.getElementById('contenu').offsetHeight;          
					
					// if(0 > 0)
					// {
						// windows_new_sizeX = 0;
					// }
					
					// if(0 > 0)
					// {
						// windows_new_sizeY = 0;
					// }
					
					// if (windows_new_sizeX > 650)
					// {
						// windows_new_sizeX = 650;
					// }
					
					// if(windows_new_sizeY > 430)
					// {
						// windows_new_sizeY = 430;
					// }
					// max_y = Math.min(windows_new_sizeY + windows_border_Y,document.body.clientHeight-50);
					dialog.resizeTo(windows_new_sizeX, windows_new_sizeY+12);
					//dialog.center();
					dialog.alignTo('contenu','tl-tl');
					document.getElementById('windowsData__'+ts).innerHTML = o.o_ajax_responseText;
					document.getElementById('windowsTempContainer__'+ts).innerHTML = '<div>&nbsp;</div>';
					dialog.setTitle('<img src="'+c_chemin+'lib/engine/engine_windows/img/windows_standardPicto.png" alt="" />&nbsp;SOGEPROM');
						
				}, {o_windows: dialog, o_ajax_responseText: o.responseText, windows_border_X: windows_border_X, windows_border_Y: windows_border_Y});
			}
					
			function reportError(o)
			{
				dialog = o.argument.o_windows;
				
				dialog.hide();
				dialog = null;
				
				ajax_error(o); //dans /js/fonctions.js - fonction générique
			}
		
			var callback = 
			{ 
				success: showPage,
				failure: function(o) { y_ajax_error(o); },
				timeout: 5000,
				argument: { o_windows: dialog, windows_border_X: windows_border_X, windows_border_Y: windows_border_Y }
			};
			
			pattern = new RegExp("^(http|https):\/\/" + location.hostname); 
			if(pattern.test(sUrl) && !false)
			{
				//C'est une page interne
				
				dynamicLoad = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
			}
			else
			{
				//C'est une page externe
				
				sUrl = 'http://validation.iconeweb.com/www_sogeprom_fr/lib/engine/engine_windows/loader/iframe_loader.php?iframe_sizeX=650&iframe_sizeY=430&url=' + base64_encode(sUrl);
				dynamicLoad = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
			}   
			
			var close_windows = function (o) { ajax_error(o.events.hide.listeners[o.events.hide.listeners.length - 1].scope.o_ajax, true); o = null; };
			dialog.addListener('hide', close_windows, {o_ajax: dynamicLoad});
		}   
	}//fin du "var load_ajaxContent"
	
	//Au 1er affichage, chargement Ajax des données
	dialog__180.addListener('show', load_ajaxContent);
		
	dialog__180.show('contenu');
}
