//seconds down timeout
function secendsDown(secs, value, id)
{
    var element ;
    element = document.getElementById(id);
    if (element == null) {
        element = document.getElementsByName(id)[0];
    }

    if (element != null) {
        if (element.nodeName == "INPUT") {
            element.value = secs;
        }
        else {
            element.innerHTML = secs;
        }

        if (--secs >= 0) {

            element.disabled = true;
            setTimeout("secendsDown(" + secs + ",'" + value + "','" + id + "')", 1000);
        }
        else {
            element.disabled = false;
            element.value = value;
        }
    }
}

function DrawImage(ImgD, imageWidth, imageHeight)
{
    var image = new Image();
    image.src = ImgD.src;

    if (imageWidth == undefined || imageWidth == null || imageHeight == undefined || imageHeight == null) {
        imageWidth = 130;
        imageHeight = 170;
    }

    if (image.width > 0 && image.height > 0) {
        if (image.width / image.height >= imageWidth / imageHeight) {
            if (image.width > imageWidth) {
                ImgD.width = imageWidth;
                ImgD.height = (image.height * imageWidth) / image.width;
            }
            else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
        else {
            if (image.height > imageHeight) {
                ImgD.height = imageHeight;
                ImgD.width = (image.width * imageHeight) / image.height;
            }
            else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
        }
    }
}

/**
 * 验证用户密码
 * @param password 用户密码
 */
function checkPassword(password)
{
    var reg = /^[_a-zA-Z0-9]+$/;
    return reg.test(password);
}
