var t_id = setInterval(animate, 20);
var pos = 0;
var dir = 2;
var len = 0;
function animate() {
    var elem = document.getElementById('progress');
    if (elem != null) {
        if (pos == 0) len += dir;
        if (len > 32 || pos > 179) pos += dir;
        if (pos > 179) len -= dir;
        if (pos > 179 && len == 0) pos = 0;
        elem.style.left = pos;
        elem.style.width = len;
    } 
}
function remove_loading() {
    this.clearInterval(t_id);
    var targelem = document.getElementById('loader_container');
    targelem.style.display = 'none';
    targelem.style.visibility = 'hidden';
}
function RedrawImageSize(divId, maxWidth, maxHeight) {
    var divcontent = document.getElementById(divId);
    if (divcontent) {
        var arrSites = divcontent.getElementsByTagName("img");
        for (var j = 0; j < arrSites.length; j++) {
            arrSites[j].onload = function() { DrawImage(this, maxWidth, maxHeight); }
        }
    }
};
function DrawImage(ImgD, iwidth, iheight) {
    var image = new Image();
    //    var iwidth=520;
    //    var iheight=1000;
    image.src = ImgD.src;
    if (image.width > 0 && image.height > 0) {
        flag = true;
        // ΏνΆΘΣΕΟΘ
        if (image.width > iwidth) {
            ImgD.width = iwidth;
            ImgD.height = (image.height * iwidth) / image.width;
            ImgD.alt = ImgD.alt + ' ' + image.width + 'x' + image.height;
            ImgD.onclick = function() { window.open(ImgD.src.toString(), '_blank'); }
            //window.location=ImgD.src.toString();
            ImgD.style.cursor = 'pointer';
        }
        else {
            ImgD.width = image.width;
            ImgD.height = image.height;
        }
    }
};
function historyButton() {
    var btnReturn = document.getElementById('btnReturn');
    if (window.history.length == 0) {
        btnReturn.style.display = 'none';
    }
    else {
        btnReturn.style.display = 'inline';
    }
};