var flag = false;
function DrawImage(ImgD, mess) {
    var image = new Image();
    image.src = ImgD.src;
    if(image.width > 0 && image.height > 0) {
        flag=true;
        if(image.width / image.height >= 300 / 210) {
            if(image.width > 300) {
                ImgD.width = 300;
                ImgD.height = (image.height * 300) / image.width;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
            ImgD.alt = mess;
        } else {
            if(image.height > 210) {
                ImgD.height = 210;
                ImgD.width = (image.width * 210) / image.height;
            } else {
                ImgD.width = image.width;
                ImgD.height = image.height;
            }
            ImgD.alt = mess;
        }
    }
}

function opencat(cat, img) {
    cat = document.getElementById(cat);
    img = document.getElementById(img);
    if(cat.style.display == "none") {
        cat.style.display = "";
        img.src = "images/class1.gif";
    } else {
        cat.style.display = "none";
        img.src = "images/class0.gif";
    }
}

function checkspace(checkstr)
{
    var str = '';
    for(i=0; i<checkstr.length; i++)
    {
        str = str + ' ';
    }
    return (str == checkstr);
}

function bgColor(obj, color_a, color_b)
{
    var t = document.getElementById(obj).getElementsByTagName("tr");
    for(var i=0; i<t.length; i++)
    {
        t[i].style.backgroundColor = (t[i].sectionRowIndex % 2 == 0) ? color_a : color_b;
    }
}