// ?2000-2003 Surveyor Corporation
// All rights reserved world wide
Timeout = 250;
refresh = 1000;
imgURL = parent.url;
lURL = "vloading2.gif";
eURL = "/testpattern.gif";
pURL = "testpattern2.gif";
nTime = 0;
tTime = 0;
gTime = 0;
count = 0;
eCount = 0;
iLoaded = false;
vid_playing = true;
var frames = false;
var image = false;
me = true;
if (top.me) {
    nothing=0;
} else {
    frames=true;
}

function global_timer() {
    get_time();
    if (vid_playing) {
        if(tTime < gTime) {
            if (iLoaded) {
                tTime = gTime + refresh;
                iLoaded = false;
                if (image) {
                    document.images.imagerefresh.src=imgURL;
                } else {
                    document.images.imagerefresh.src=imgURL+"&NUMBER="+count + "&time=" + gTime;
                }
                eCount = 0;
                count++;
            }
        }
    }
    window.setTimeout("global_timer()", Timeout);
}

function get_time() {
    nTime = new Date();
    gTime = nTime.getTime();
}

function imgError() {
    if (eCount > 5) {
        eCount = 0;
        vid_playing = false;
           document.images.imagerefresh.src=eURL;
       } else {
           eCount++;
           iLoaded = true;
       }
}

function switchVid() {
    if (vid_playing) {
        vid_playing = false;
        document.images.imagerefresh.src=pURL;
    }
    else {
        vid_playing = true;
    }
}

function imgLoaded() {
    iLoaded=true;
}

function createImage(imageURL,rfrsh,wdth,hght) {
    if (imageURL) imgURL=imageURL;
    if (isNaN(rfrsh))
        { refresh=1000; }
    else
        { refresh=rfrsh; }
    if (isNaN(wdth))
        { width=320; }
    else
        { width=wdth; }
    if (isNaN(hght))
        { height=240; }
    else
        { height=hght; }
    var tmp_len = imgURL.length;
    var tmp_str = imgURL.substr(tmp_len-3, tmp_len);
    if ((tmp_str == "jpg") || (tmp_str == "jpg")) { image = true; }
    document.write("<a href=\"javascript: switchVid();\"><img src=\""+lURL+"\" name=\"imagerefresh\" width=\""+width+"\" height=\""+height+"\" border=\"0\" onload=\"imgLoaded();\" onerror=\"imgError()\"></a>");
}

