function addEvent(object,eventName,do_function) {
    if(typeof(object) == 'string') object = document.getElementById(object);
    if(!object) {
        alert('No object in function addEvent!');
        return;
    }
    if(object.addEventListener) {
        object.addEventListener(eventName, do_function, false);
    } else {
        object.attachEvent('on'+eventName, do_function);
    }
}

function setSelectionRange(obj) {
    if(obj && typeof(obj) == 'object' && (obj.type == 'text' || obj.type == 'textarea')) {
        if(obj.createTextRange) {
            var range = obj.createTextRange();
            range.moveStart('character', 0);
            range.moveEnd('character', obj.value.lengh-1);
            range.select();
        } else {
            if(obj.setSelectionRange) {
                obj.setSelectionRange(0,obj.value.length);
            }
        }
        obj.focus();
    }
    if(obj && typeof(obj) == 'object' && obj.options) {
        obj.focus();
    }
}