var DestChoice = new DestinataireChoice();


function DestChoiceInit(o_win, o_doc) {
        this.win = o_win;
        this.doc = o_doc;
}

function DestChoicePopup(page, numLigne,doc, val) {
        this.numLigne = numLigne;
        this.inputname = 'valeur' + numLigne;
        this.docsource = doc;
        var w = 800, h = 500,
        move = screen ?
                ',left=' + ((screen.width - w) >> 1) + ',top=' + ((screen.height - h) >> 1) : '',
        win = window.open(page+'?listerelation='+val+'&page=1', null, "help=no,status=no,scrollbars=yes,resizable=yes" + move + ",width=" + w + ",height=" + h + ",dependent=yes", true);
        win.opener = window;
        win.focus();
}

function DestChoiceSelect(email) {
    dest = this.docsource.getElementById(this.numLigne).value;
    if(dest.length > 0){
    	if(dest.indexOf(";") == -1 || dest.indexOf(";", dest.lastIndexOf("@")) == -1){
    		dest = dest + ";"
        }
    }
            
    this.docsource.getElementById(this.numLigne).value = dest + email;
    this.win.close();
}

function DestinataireChoice() {
   this.Popup = DestChoicePopup;
   this.Select = DestChoiceSelect;
   this.Init = DestChoiceInit;
}
