function AnimatePNG(obj, name, count, delay) {
var list = new Array();
for (var n = 0; n < count; n++) {
list.push(name + '_' + n + '.png');
}
return new Animate(obj, list.join(','), delay);
}
function Animate(obj, srclist, delayval) {
this.object = obj;
this.index = 0;
this.delay = delayval;
this.interval = 0;
this.reverse = false;
this.links = srclist.split(',');
this.slides = new Array();
this.count = 0;
for (var n in this.links) {
var image = new Image();
image.src = 'images/' + this.links[n];
this.slides.push(image);
this.count++;
}
this.stop = function() {
if (this.interval)
{
self.clearInterval(this.interval);
this.interval = 0;
}
}
this.start = function() {
if (this.interval == 0) {
var instance = this;
this.interval = self.setInterval(function() { instance.next(); },
this.delay);
}
}
this.next = function() {
if (this.reverse)
this.index = (this.index + this.count - 1) % this.count;
else
this.index = (this.index + 1) % this.count;
this.object.src = this.slides[this.index].ssrc;
}
}
function ModulatePNG(rootImagePath, imageobj, maximum, image_count,
curvalue, reverse) {
//strip away any non-numeric characters, such as from the Units Label
curvalue = parseFloat(curvalue);
var step_size = maximum / image_count;
if (reverse) {
for (i = 0; i < image_count; i++) {
if (curvalue < step_size*i) {
imageobj.src = rootImagePath + i + ".png";
break;
}
}
}
else {
for (i = 0; i < image_count; i++) {
if (curvalue > step_size*(image_count-i-1)) {
imageobj.src = rootImagePath + i + ".png";
break;
}
}
}
}