function makeFieldEmpty(fieldID){
    if(is_numeric(document.getElementById(fieldID).value)===false){
        document.getElementById(fieldID).value='';
    }
}

function is_numeric(mixed_var) {
    return (typeof(mixed_var) === 'number' || typeof(mixed_var) === 'string') && mixed_var !== '' && !isNaN(mixed_var);
}

function makeEmpty(arrInput){
    if(arrInput.defaultValue=='jjjj'){
        if(arrInput.value=='jjjj'){
            arrInput.value='';
        }
    }else if(arrInput.defaultValue=='mm'){
        if(arrInput.value=='mm'){
            arrInput.value='';
        }
    }else if(arrInput.defaultValue=='dd'){
        if(arrInput.value=='dd'){
            arrInput.value='';
        }
    }
}

function doKey(intKey){
    alert(intKey);
}

function insert(emoticonString){
    replaceText(emoticonString ,document.forms.sendMessage.message);
    return false;
}

function replaceText(text, textarea,blnFocus){
    // Attempt to create a text range (IE).
    if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange){
        var caretPos = textarea.caretPos;

        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
        caretPos.select();
    }
    // Mozilla text range replace.
    else if (typeof(textarea.selectionStart) != "undefined"){
        var begin = textarea.value.substr(0, textarea.selectionStart);
        var end = textarea.value.substr(textarea.selectionEnd);
        var scrollPos = textarea.scrollTop;

        textarea.value = begin + text + end;

        if (textarea.setSelectionRange){
            textarea.focus();
            textarea.setSelectionRange(begin.length + text.length, begin.length + text.length);
        }
        textarea.scrollTop = scrollPos;
    }
    // Just put it on the end.
    else
    {
        textarea.value += text;
        textarea.focus(textarea.value.length - 1);
    }
    if(blnFocus == '|'){
        var lengte = ( textarea.value.length - 4 );
        //textarea.select(lengte,lengte);
        js_setCursorPosition(textarea,lengte);
    }
}

function js_setCursorPosition(textArea, cursorPos) {
    if (document.selection) {
        var sel = textArea.createTextRange();
        sel.collapse(true);
        sel.moveStart("character", cursorPos);
        sel.moveEnd("character", cursorPos);
        sel.select();
    } else if (textArea.selectionStart || (textArea.selectionStart == "0")) {
        textArea.selectionStart = cursorPos;
        textArea.selectionEnd = cursorPos;
    }
    textArea.focus();
}

function insertBBCode(bbCode){
    replaceText(bbCode ,document.forms.sendMessage.message,'|');
    return false;
}

function sort(info,intID,intParentID,strDatabase){
    var value = info.value;
    updateSortField(value,intID,intParentID,strDatabase);
}
