function getById(id) {
    return document.getElementById(id);
}

function is_empty(str) {
    return (str.replace(/\s+/,'') == '');
}

function is_integer(str) {
    var reg_int = /^(-)?\d+$/;
    return reg_int.test(str);
}

function is_natural_integer(str) {
    var reg_int = /^\d+$/;
    return reg_int.test(str);
}

function is_decimal(str) {
    var reg_decimal = /^\d+(.)?(\d+)?$/;
    return reg_decimal.test(str); 
}

function is_email(str) {
    var reg_email = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
    return reg_email.test(str);
}

function get_random(lbound, ubound) {
    return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
}

function generate_password(length) {
    var numberChars = "0123456789";
    var lowerChars = "abcdefghijklmnopqrstuvwxyz";
    var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var otherChars = "!@#$%^&";
    var charSet = numberChars + lowerChars + upperChars + otherChars;
    var rc = "";
    for (var idx = 1; idx <= length; ++idx) {
        rc += charSet.charAt(get_random(0, charSet.length));
    }
    return rc;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
