﻿
function popUpCirculaire(url) {
    //newWin = window.open(url, "Circulaire", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=550');
    //newWin = window.open(url, "Circulaire", 'fullscreen=yes,scrollbars=auto,resize=yes');
    //newWin.name = "Circulaire";
    
    var options = 'scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no';
    options += ',width=' + (screen.availWidth-15) + ',height=' + (screen.availHeight-40);
    options += ',screenX=0,screenY=0,top=0,left=0';
    var win = window.open(url, '', options);
    if (win != null){
        win.focus();
        win.name = "Circulaire";
    }
}


function popUpConditions(url) {
    newWin = window.open(url, "conditions", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=700,height=550');
    newWin.name = "conditions";
}


function popUpCursus(url) {
    //newWin = window.open(url, "cursus", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=735,height=495');
    //newWin.name = "cursus";
    var options = 'scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no';
    options += ',width=' + (screen.availWidth - 15) + ',height=' + (screen.availHeight - 40);
    options += ',screenX=0,screenY=0,top=0,left=0';
    var win = window.open(url, '', options);
    if (win != null) {
        win.focus();
        win.name = "Cursus";
    }
}

function popUpPub(url) {
    var options = 'scrollbars=yes,resizable=yes,status=no,toolbar=no,menubar=no,location=no';
    //options += ',width=' + (screen.availWidth - 15) + ',height=' + (screen.availHeight - 40);
    options += ',width=700,height=420';
    options += ',screenX=100,screenY=100,top=100,left=100';
    var win = window.open(url, '', options);
    if (win != null) {
        win.focus();
        win.name = "Pub";
    }
}


//Pour masquer un élément passé en paramêtre
//utilisé par exemple pour masquer les messages de
//validation affichés par les contrôles de validation
//quand le user tape dans le contrôle validé pour corriger
//l'erreur de validation
function masquerElement(element) {
    elementAMasquer = document.getElementById ? document.getElementById(element) : document.all[element];
    if (elementAMasquer != null) {
            elementAMasquer.style.display = 'none'; 
        }
}

function checkRadio(element) {
    rb = document.getElementById ? document.getElementById(element) : document.all[element];
    if (rb != null) {
        rb.checked = true;
    }
}

function uncheckRadio(element) {
    rb = document.getElementById ? document.getElementById(element) : document.all[element];
    if (rb != null) {
        rb.checked = false;
    }
}

//inscrire une valeur dans un champs
function inscrireValeur(element, valeur) {
    elementAModifier = document.getElementById ? document.getElementById(element) : document.all[element];
    if (elementAModifier != null) {
        elementAModifier.value = valeur;
    }
}

function obtenirValeur(element) {
    elementALire = document.getElementById ? document.getElementById(element) : document.all[element];
    if (elementALire != null) {
        return elementALire.value;
    }
}



function effacerChamp(element) {
    elementAModifier = document.getElementById ? document.getElementById(element.id) : document.all[element.id];
    if (elementAModifier != null) {
        elementAModifier.value = "";
    }
}


//function CancellerBoutonEnter(event) {
//    if (event.keyCode == 13 || event.charCode == 13)
//        return false;
//    return true;
//}


function codePostalAutoTab(element, elementFocusTo) {
    elementSource = document.getElementById ? document.getElementById(element.id) : document.all[element.id];
    if (elementSource.value.length == 3) {
        elementAFocuser = document.getElementById ? document.getElementById(elementFocusTo.id) : document.all[elementFocusTo.id];
        elementAFocuser.focus();
    }
}

function focusBackspace(e, element, elementFocusTo) {
    elementSource = document.getElementById ? document.getElementById(element.id) : document.all[element.id];
    if (elementSource.value.length == 0) {
        //si la touche est backspace
        var evenement = window.event || e; //IE || FF
        if (evenement.keyCode) {
            if (evenement.keyCode == 8) {
                elementAFocuser = document.getElementById ? document.getElementById(elementFocusTo.id) : document.all[elementFocusTo.id];
                elementAFocuser.focus();
                elementAFocuser.value = elementAFocuser.value; //pour que le curseur se positionne à la fin du champ
            }
        }
        else if (evenement.charCode) {
            if (evenement.charCode == 8) {
                elementAFocuser = document.getElementById ? document.getElementById(elementFocusTo.id) : document.all[elementFocusTo.id];
                elementAFocuser.focus();
            }
        }
    }
}

