

function check_digit(obj) {
    var str = obj.value;
    var tmp = "";
    var ch;
    var idx;
    for(idx = 0; idx < str.length; idx++) {
        ch = str.substring(idx, idx+1);
        if (!isNaN(ch))
            tmp = tmp + ch;
    }
    obj.value = tmp;
}
function check_double(obj) {
    var str = obj.value;
    var tmp = "";
    var ch;
    var idx;
    chsize = 0;
    for(idx = 0; idx < str.length; idx++) {
        ch = str.substring(idx, idx+1);
        if (!isNaN(ch) || (ch=="." && chsize == 0))
            tmp = tmp + ch;
        if (ch == ".")
            chsize ++;
    }
    obj.value = tmp;
}
function get_objTop(thisobj){
    if(typeof(thisobj)!='object') thisobj=document.getElementById(thisobj);
    if (thisobj.offsetParent==document.body) return thisobj.offsetTop;
    else return thisobj.offsetTop + get_objTop(thisobj.offsetParent) - thisobj.scrollTop;
}

function get_objLeft(thisobj){
    if(typeof(thisobj)!='object') thisobj=document.getElementById(thisobj);
    if (thisobj.offsetParent==document.body) return thisobj.offsetLeft;
    else return thisobj.offsetLeft + get_objLeft(thisobj.offsetParent) - thisobj.scrollLeft;
}

function check_image(filename) {
    if (filename == "") return true;
    var ext = filename.substring(filename.length-3, filename.length);
    ext = ext.toLowerCase();
    if (ext == "jpg" || ext =="bmp" || ext =="png" || ext == "gif")
        return true;
    else
        return false;
}

function go_page(page, p) {
    var form = document.mainForm;
    if (form) {
        form.p.value = p;
        if (form.action) {
            form.action.value = "";
        }
        if (form.page) {
            form.page.value = 1;
        }
        form.submit();
    }
    else {
        top.location.href=page + "?p=" + p;
    }
}

function set_alert(msg, div_id) {
    var div;
    if (div_id)
        div = document.getElementById(div_id);
    else
        div = document.getElementById("div_alert");
    if (div) {
        div.innerHTML = msg;
    }
}

function validateEmail(email) {
    if(email.length < 1)
        return false;
                
    var match = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/.test(email);
    return match;                
}

function go_pagenum(page) {
    var form = document.mainForm;
    if (form) {
        form.page.value = page;
        form.submit();
    }
}