/*******************************************************************/
/* Attention  :fichier genere automatiquement : ne pas modifier    */
/*******************************************************************/

function str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
 
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;
 
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    };
 
    return sa ? s : s[0];
}/****** carte ******/


function ft_WriteFontPreview()
    {
        // On creer l'element img
        img = document.createElement('img');
        img.setAttribute('id', "font_preview");
        img.setAttribute('title', "Aperçu de la police");
        img.setAttribute('alt', "Aperçu de la police");

        // On declare l'element img comme enfant de l'element field
        field = document.getElementById('preview_div');
        field.appendChild(img);
    } // ft_WriteFontPreview()
    
    function ft_ChangeFontPreview()
    // Affichage de l'image
    {
        font_dir = '/medias/police/prev/';
        font_ext = '.gif';
        police = document.forms['form_texte'].elements['police'];
        couleur = document.forms['form_texte'].elements['couleur'];
        img_path = font_dir + police.options[police.selectedIndex].value +"_";
        img_path += couleur.options[couleur.selectedIndex].value + font_ext;
        
        if (!document.getElementById('font_preview'))
            ft_WriteFontPreview()
        
        document.getElementById('font_preview').src = img_path;
    } // ft_ChangeFontPreview()
    
	/* Ajout des evenements aux pages */
function init_events()
{
   
    
    if (document.forms['form_texte']) {
        // On est sur la page d'entrée du texte
        ft_ChangeFontPreview();
        document.forms['form_texte'].elements['police'].onchange = ft_ChangeFontPreview;
        document.forms['form_texte'].elements['couleur'].onchange = ft_ChangeFontPreview;
    }


} // init_events()
/****** fin carte ******/





/****** contact ******/

function remplaceEmails()
{
	$("span.email").each(
  function(i)
  {
   var temp;
   temp=$(this).text();
   temp=str_replace('[a]','@',temp);
   $(this).html('<a href="mailto:'+temp+'">'+temp+'</a>');
  }
	);
}

$(document).ready(
  function()
  {
  init_events();
  remplaceEmails();
  }
);  
  

/****** fin contact ******/





