//Javascript Document MM_functions : Fonctions Maromedia
<!--
_d=document;
opra=(navigator.userAgent.indexOf("Opera")!=-1)?true:false;
ie4=(!_d.getElementById&&_d.all)?true:false;
ie55=((navigator.appVersion.indexOf("MSIE 6.0")!=-1||navigator.appVersion.indexOf("MSIE 5.5")!=-1))?true:false;
if(ie55&&opra)ie55=false;

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_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];}
}
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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

function actionmenuliens(form){
    var URL = document.formmenuliens.autres_sites.options[document.formmenuliens.autres_sites.selectedIndex].value;
    window.location.href = URL;
}

function actionRechercher( frm , image )
{   
    if (image!='')
      frm.actionimage[2].checked = true;
    else
      frm.actionimage[0].checked = true;
}

function checkForm( frm ) {
    // initialisation des tableaux
    var tab_nom_intitule    = new Array;
    var tab_champ           = new Array;
    var tab_nom_champ       = new Array;
    var tab_champ_obligatoire = new Array;
    var tab_id_champ        = new Array;
    // initialisation des compteurs
    var j=0,k=0,l=0,m=0;
    
    for (var i=0 ; i<frm.elements.length ; i++ ) {      
        if (frm.elements[i].name.substr(0,12) == 'nom_intitule') {
            tab_nom_intitule[j] = frm.elements[i].value;
            j++;
        }       
        
        if (frm.elements[i].name.substr(0,5) == 'champ') {
            tab_champ[k]        = frm.elements[i].value;
            tab_nom_champ[k]    = frm.elements[i].name;
            k++;
        }
        
        // on ne récupère tous les champs obligatoires
        if (frm.elements[i].name.substr(0,8) == 'ch_oblig') {
            tab_champ_obligatoire[l]    = frm.elements[i].value;
            l++;
        }
        
        // récupération des noms des champs des tables SQL
        if (frm.elements[i].name.substr(0,7) == 'champs_') {
            tab_id_champ[m]=frm.elements[i].value;
            m++;
        }

    }
    
    count_tab_champ = tab_champ.length;
    for (var n=0 ; n < count_tab_champ; n++ ) {
        // on compare le contenu des champs remplis avec celui des champs obligatoires
        if (tab_champ_obligatoire[n] == 'oui' && tab_champ[n] == '') {
            alert ('Vous devez remplir tous les champs obligatoires !');
            return false;
        }
    }
    
    // vérification de saisie d'une adresse mail
    if (!frm.adresse_mail.value) {
        alert ('La saisie d\'une adresse mail est obligatoire.');
        return false;
    }
    
    // vérification du format de l'adresse mail
    var reg = new RegExp('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$', 'i');
    if (!(reg.test(frm.adresse_mail.value)) && frm.adresse_mail.value) {
        alert (frm.adresse_mail.value+' n\'est pas une adresse mail valide.');
        return false;
    }
    
}
var toggle = true;
function cocher( idForm , button ){
    var frm = document.getElementById(idForm);
    for (var i=0; i < frm.elements.length; i++)
        if ( frm.elements[i].type == "checkbox" ){var e = frm.elements[i];e.checked = toggle; } 
    if (toggle) button.value="Décocher toutes les cases";
    else        button.value="Cocher toutes les cases";
    toggle = !toggle;
}

function changeClass( obj ,  id){
    var currObj, currID;    
    
    if (obj)    currObj = obj;
    else        currObj = document.getElementById(id);

    if (obj.className == 'fold')    newClass = 'unfold'
    else                            newClass = 'fold';

    if (currObj)    currObj.className = newClass;       
        
    currID = document.getElementById(id);
    if (currID.style.display == 'block' || currID.style.display == '')  currID.style.display = 'none'
    else                                                                currID.style.display = 'block';
}

function copyClipboardData(data){
    if(ie55)
        window.clipboardData.setData("Text", data);
    else
        alert('Utilisation du Presse-papier impossible.\nVeuillez utiliser Internet Explorer 6.0 ou supérieur.');
}
function pasteClipboardData(obj){
    if(ie55 && window.clipboardData.getData("Text")){
        obj.value = window.clipboardData.getData("Text");
    }
    else
        alert('Utilisation du Presse-papier impossible.\nVeuillez utiliser Internet Explorer 6.0 ou supérieur.');
}
function changeWorkflow(obj, idWorkflow, oldValue)
{
    var newValue;
    newValue = obj.options[obj.selectedIndex].value;
    if ( newValue != oldValue)
    {       
        if ( confirm('Etes-vous sûr de vouloir changer le type de ce Workflow ?') )
        {
            document.location.href='/index.php?module=member&page=actionWorkflow&cmd=update&workflow_id='+idWorkflow+'&newValue='+newValue+'&admin=1';
        }
        else
        {
            for (i=0; i<obj.options.length; i++){
                if ( obj.options[i].value == oldValue)
                    obj.options[i].selected = true;
            }
        }
    }           
}

function getSuggestions($keyword)
{
    $suggestions = array();
    $url = 'http://www.google.com/complete/search?hl=en&js=true&qu=[keyword]';
    $url = str_replace('[keyword]', $keyword, $url);
    $sAll = implode( ' ', file($url) );
    list($sStart, $sSuggestions, $sPagecount) = explode('new Array', $sAll);

    $sSuggestions = str_replace('(', '', $sSuggestions);
    $sSuggestions = str_replace(')', '', $sSuggestions);
    $sSuggestions = str_replace(',', '', $sSuggestions);
    $sSuggestions = str_replace('" "', ';', $sSuggestions);
    $sSuggestions = str_replace('.', '', $sSuggestions);
    $sSuggestions = str_replace('"', '', $sSuggestions);
    $suggestions = explode(';', $sSuggestions);

    return $suggestions;
}
//  -->
