﻿var arr_pics = new Array();
var arr_stat = new Array();
var arr_pic = new Array();

function pic_change(i, code) {
    var loop = 0;

    if (arr_stat[code]) {
        while ((arr_pics[code][i] == 0 || i >= 11) && loop < 100) {
            if (i >= 11) { i = 0; }
            else {
                i++;
            }
            loop++;
        }

        if (arr_pic[code][i].complete) {
            document.getElementById(code).src = arr_pic[code][i].src;
            setTimeout("pic_change(" + (i + 1) + ",'" + code + "')", 750);
        }
        else {
            setTimeout("pic_change(" + i + ",'" + code + "')", 20);
        }
    }
}

function loadpic(url, code, x) {
    if (arr_stat[code]) { arr_pic[code][x].src = url; }
}

function _start(code, ta, te) {
    arr_stat[code] = 1;
    var xx, xxx;
    var first = 1;

    for (var x = 0; x < 12; x++) {
        if (arr_pics[code][x] == 1) {
            arr_pic[code][x] = new Image();
            xx = x + 1;
            if (xx >= 100) { xxx = "" + xx; }
            if (xx < 100 && xx >= 10) { xxx = xx; }
            if (xx < 10) { xxx = xx; }
            if (first) {
                first = 0; loadpic(ta + xxx + te, code, x);
            }
            else { setTimeout("loadpic('" + ta + xxx + te + "','" + code + "'," + x + ")", x * 50); }
        }
    }
    pic_change(0, code);
}

function _stop(code) {
    arr_stat[code] = 0;
}

