
//Variables
var couleurNormale;
var regExpBeginning = /^\s+/;
var regExpEnd = /\s+$/;

function executeLoadFunctions() {    
}
/******************************************************/
/* AFFICHAGE DES MESSAGES D'ERREUR DU COTE JAVASCRIPT
/******************************************************/

//Messages pour erreurs sur les dates
function messageDate(e) {
    alert('Les dates sont incorrectes');
    if (navigator.appName=="Netscape") e.preventDefault(); 
    else if (navigator.appName=="Microsoft Internet Explorer") event.returnValue = false;
}

//Message d'erreur sur les noms
function messageNoms(e){
     alert('Noms incorrects');
     if (navigator.appName=="Netscape") e.preventDefault(); 
     else if (navigator.appName=="Microsoft Internet Explorer")event.returnValue = false;
 }
/************************************************************/

 /***************************************************************************/
 /* GESTION DE LA COULEUR DES LIGNES SELECTIONNEES SUR LE CRAN DE RECHERCHE
 /***************************************************************************/
function selectionLigneGrid(element) {
    couleurNormale = element.style.backgroundColor;
    element.style.backgroundColor='#00C000';
    element.style.cursor='hand';
    element.style.textDecoration='underline';
}

function deselectionLigneGrid(element) {
    element.style.backgroundColor = couleurNormale;
    element.style.textDecoration = 'none';
}

/******************************************************************************/


//Fonction pour empecher la saisie des lettres dans les contrôles réservés aux chiffres
function texteInterdit(e) {
    // Internet Explorer
    if (isMSIE()) {
        if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false; 
    }
    else {
        var keyCode = e.keyCode ? e.keyCode : e.charCode;
        if (e.ctrl) {
            if (keyCode != 120 && keyCode != 99 && keyCode != 118) {
                e.preventDefault();
            }
        }
        else if (!(keyCode >= 48 && keyCode <= 57) &&
                !(keyCode >= 35 && keyCode <= 40) && keyCode != 8 && keyCode != 9 && keyCode != 46) {
           e.preventDefault();
        }
    }
}

//Renvoi "true"  si le navigateur est internet explorer
function isMSIE() {
    return (navigator.userAgent.toLowerCase().indexOf("msie") >= 0);
}


/******************************************************************/
/* Fonctions ouvrant les poup des actes, des commandes, des membres
/******************************************************************/
function ouvrirActeNaiss (regNaiss,refNaiss) {
window.open('acte_ns.aspx?va=' + regNaiss + '&va1=' + refNaiss +'&va2=rch','ActeNaiss','width=720,height=560,menubar=no,toolbar=no,location=no,status=no');
}

function ouvrirActeMariage (regMa,refMa) {
window.open('acte_ma.aspx?va=' + regMa + '&va1=' + refMa +'&va2=rch','ActeNaiss','width=720,height=490,menubar=no,toolbar=no,location=no,status=no');
}

function ouvrirActeDeces (regDc,refDc) {
window.open('acte_dc.aspx?va=' + regDc + '&va1=' + refDc +'&va2=rch','ActeNaiss','width=720,height=560,menubar=no,toolbar=no,location=no,status=no');
}
function ouvrirActeGenerique(regGen, numGen) {
    window.open('acte_gen.aspx?va=' + regGen + '&va1=' + numGen + '&va2=rch', 'ActeGen', 'width=720,height=590,menubar=no,toolbar=no,location=no,status=no');
}

function ouvrirActeNaissCde (regNaiss,refNaiss,source) {
window.open('acte_ns.aspx?va=' + regNaiss + '&va1=' + refNaiss +'&va2=' + source,'ActeNaiss','width=720,height=560,menubar=no,toolbar=no,location=no,status=no');
}

function ouvrirActeMariageCde (regMa,refMa,source) {
window.open('acte_ma.aspx?va=' + regMa + '&va1=' + refMa +'&va2=' + source,'ActeNaiss','width=720,height=490,menubar=no,toolbar=no,location=no,status=no');
}

function ouvrirActeDecesCde (regDc,refDc,source) {
window.open('acte_dc.aspx?va=' + regDc + '&va1=' + refDc +'&va2=' + source,'ActeNaiss','width=720,height=560,menubar=no,toolbar=no,location=no,status=no');
}
function ouvrirActeGenCde(regGen, refGen, source) {
    window.open('acte_gen.aspx?va=' + regGen + '&va1=' + refGen + '&va2=' + source, 'ActeNaiss', 'width=720,height=590,menubar=no,toolbar=no,location=no,status=no');
}
function ouvrirCommande (numCde,numMbre,statut) {
window.open('commande.aspx?va=' + numCde + '&va1=' + numMbre + '&va2=' + statut,'cde','width=800,height=820,menubar=no,toolbar=no,location=no,status=no');
}

function AjoutMbre (numMbre)
{
window.open('membre.aspx?va=new&num=' + numMbre ,'NewMbre', 'width=740,height = 720,menubar=no,toolbar=no,location=no,status=no');
}

function OuvrirMbre (numMbre) {
window.open('membre.aspx?va=' + numMbre ,'Membre', 'width=740,height = 680,menubar=no,toolbar=no,location=no,status=no');
}

function CdeMbre (numMbre) {
window.open('historique_cde.aspx?va=' + numMbre ,'Historique', 'width=540,height = 720,menubar=no,toolbar=no,location=no,status=no');
}
/***********************************************************/

//Actes de décès- commenatire d'ajout au panier
function dcCommentChk(chkbx) {    
    if (chkbx.checked) {
        document.getElementById('divCommentText').className = 'normal';
        document.getElementById('conjointText').disabled = false;
        document.getElementById('dateDeces').disabled = false;
        document.getElementById('autreInfo').disabled = false;
    } else {
        document.getElementById('divCommentText').className = 'texteGris';
        document.getElementById('conjointText').disabled = 'disabled';
        document.getElementById('dateDeces').disabled = 'disabled';
        document.getElementById('autreInfo').disabled = 'disabled';
        document.getElementById('conjointText').value = '';
        document.getElementById('dateDeces').value = '';
        document.getElementById('autreInfo').value = '';
    }
    BtnAjoutActifInactif();
}

//Actes de naissance- commenatire d'ajout au panier
function nsCommentChk(chkbx) {
    if (chkbx.checked) {
        document.getElementById('divCommentText').className = 'normal';
        document.getElementById('enf2').disabled = false;
        document.getElementById('enf1').disabled = false;
        document.getElementById('dateNs').disabled = false;
        document.getElementById('autreInfo').disabled = false;
    } else {
        document.getElementById('divCommentText').className = 'texteGris';
        document.getElementById('enf2').disabled = 'disabled';
        document.getElementById('enf1').disabled = 'disabled';
        document.getElementById('dateNs').disabled = 'disabled';
        document.getElementById('autreInfo').disabled = 'disabled';
        document.getElementById('enf2').value = '';
        document.getElementById('enf1').value = '';
        document.getElementById('dateNs').value = '';
        document.getElementById('autreInfo').value = '';
    }
    BtnAjoutActifInactif();
}

//Actes de naissance- commenatire d'ajout au panier
function genCommentChk(chkbx) {
    if (chkbx.checked) {
        document.getElementById('divCommentText').className = 'normal';
        document.getElementById('enf2').disabled = false;
        document.getElementById('enf1').disabled = false;
        document.getElementById('dateGen').disabled = false;
        document.getElementById('autreInfo').disabled = false;
    } else {
        document.getElementById('divCommentText').className = 'texteGris';
        document.getElementById('enf2').disabled = 'disabled';
        document.getElementById('enf1').disabled = 'disabled';
        document.getElementById('dateGen').disabled = 'disabled';
        document.getElementById('autreInfo').disabled = 'disabled';
        document.getElementById('enf2').value = '';
        document.getElementById('enf1').value = '';
        document.getElementById('dateGen').value = '';
        document.getElementById('autreInfo').value = '';
    }
    BtnAjoutActifInactif();
}
// Supprime les espaces inutiles en début et fin de la chaîne passée en paramètre.
function trim(aString) {
    return aString.replace(regExpBeginning, "").replace(regExpEnd, "");
}

//Fonctions pour POPUP 
function ouvrirPopup(idContenu) {
    $('popupDiv').style.display = 'block';
    $('contentPopup').innerHTML = $(idContenu).innerHTML;
}

function fermerPopup() {
    $('popupDiv').style.display = 'none';
    $('contentPopup').innerHTML = '';
}

function trim (myString) { 
    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
}

/*Génération des boutons*/
function buttonEnregistrer(id,label,action) {
    var returnCode = "<div class='saveBtn " + id + " link' onclick='" + action + "'>";
    returnCode += "<div class='left_btn'></div><div class='btn_text' > " + label + "</div><div class='right_btn'></div>";
    returnCode += "</div>";
    $(id).innerHTML = returnCode;
}
function buttonAjouterPhoto(id, label, action) {
    var returnCode = "<div class='photoBtn " + id + " link' onclick='" + action + "'>";
    returnCode += "<div class='left_btn'></div><div class='btn_text' > " + label + "</div><div class='right_btn'></div>";
    returnCode += "</div>";
    $(id).innerHTML = returnCode;
}
function buttonFermer(id,label,action) {
    var returnCode = "<div  class='closeBtn "+ id + " link' onclick='" + action + "'>";
    returnCode += "<div class='left_btn'></div><div class='btn_text' >" + label + "</div><div class='right_btn'></div>";
    returnCode += "</div>";
    $(id).innerHTML = returnCode;
}

function buttonSupprimer(id,label,action) {
    var returnCode = "<div class='suppBtn " + id + " link' onclick='" + action + "'>";
    returnCode += "<div class='left_btn'></div><div class='btn_text' >" + label + "</div><div class='right_btn'></div>";
    returnCode += "</div>";
    $(id).innerHTML = returnCode;
}

function openImage(src) {
    $('bigImageContent').style.display = 'block';
    $('bigImageData').innerHTML = '<center><div style="clear:both;"><img class="bigpict" src ="' + src + '" onclick="fermerImage();"/></div><div style="width:500px;"><img alt="' + fermerlbl + '" title="' + fermerlbl + '" style="float:left;" class="link" src ="../images/fileclose.png" onclick="fermerImage();"/></div></center>';
}
function fermerImage() {
    $('bigImageContent').style.display = 'none';
    $('bigImageData').innerHTML = "";    
}
