function checkMail() {
    createRequest();

    var mail = getObj('mail').value;
    var url = '/ajax/editor.php?check=email&value=' + escape(mail);

    request.open("GET", url, true);

    request.onreadystatechange = updateNotice;
    request.send(null);

}

function updateNotice() {

    if (request.readyState == 4) {
        if (request.status == 200) {
            var response = request.responseText.split('|');
            var notice = getObj('notice');
            notice.innerHTML = response[0];
            notice.title = response[1];
            notice.className = response[2] + ' italic notice';
        }
    }

}

function cur_ins(field, startTag, endTag, offset) {
    
    field.focus();

    if (document.getSelection) {
        
        selStart = field.selectionStart;
        selEnd = field.selectionEnd;
        text = field.value.substring(selStart, selEnd);
        field.value = field.value.substring(0, selStart) + startTag + text + endTag + field.value.substring(selEnd);
        
        if (text.length > 0) {
            if (offset != 0) {
                field.selectionStart = selStart + startTag.length + text.length - offset;
            } else {
                field.selectionStart = selStart + startTag.length + text.length + endTag.length;
            }
        } else {
            field.selectionStart = selStart + startTag.length;
        }
        
        field.selectionEnd = field.selectionStart;
    
    } else {

        if (document.selection) {
            
            marker = document.selection.createRange();
            text = marker.text;
            marker.text = startTag+text+endTag;
            marker = document.selection.createRange();
            
            if (text.length > 0) {
            
                if (offset != 0) {
                    marker.move('character', startTag.length + text.length - offset);
                } else {
                    marker.move('character', startTag.length + text.length + endTag.length + offset);
                }
            
            } else {
                marker.move('character', -(endTag.length));
            }

            marker.select();
        }
    }
}


