Rotator.restartDelay = 500;
// delay onmouseout before call to rotate
Rotator.col = [];
function Rotator(name, speed, path, tgt) {
    this.name = name;
    this.speed = speed || 4500;
    this.path = path || "";
    this.tgt = tgt;
    this.ctr = 0;
    this.timer = 0;
    this.imgs = [];
    this.texts = [];
    this.actions = [];
    this.index = Rotator.col.length;
    Rotator.col[this.index] = this;
    this.animString = "Rotator.col[" + this.index + "]";
}
;
Rotator.prototype.addImages = function () {
    var img;
    for (var i = 0; arguments[i]; i++) {
        img = new Image();
        img.src = this.path + arguments[i];
        this.imgs[this.imgs.length] = img;
    }
}
;
var dw_Inf =  {
}
;
dw_Inf.fn = function (v) {
    return eval(v)}
;
Rotator.prototype.addActions = function () {
    var len = arguments.length;
    for (var i = 0; i < len; i++)this.actions[this.actions.length] = arguments[i]; }
;

Rotator.prototype.addTexts = function () {
    var len = arguments.length;
    for (var i = 0; i < len; i++)this.texts[this.texts.length] = arguments[i];}
;
dw_Inf.gw = window.location;

Rotator.prototype.rotate = function () {
    clearTimeout(this.timer);
    this.timer = null;
    if (this.ctr < this.imgs.length - 1)this.ctr++;
    else this.ctr = 0;
    var imgObj = document.images[this.name];
    if (imgObj && Rotator.ready) {
        imgObj.src = this.imgs[this.ctr].src;
        this.timer = setTimeout(this.animString + ".rotate()", this.speed);
    }
}
;
dw_Inf.gw=dw_Inf.gw.hostname;
dw_Inf.gw=dw_Inf.gw.toLowerCase(); 
Rotator.start = function () {
    var len = Rotator.col.length, obj;
    for (var i = 0; i < len; i++) {
        obj = Rotator.col[i];
        if (obj && obj.name)obj.timer = setTimeout(obj.animString + ".rotate()", obj.speed);
    }
}
;
Rotator.doClick = function (n) {
    var obj = Rotator.col[n];
    if (!document.images ||!obj)return true;
    if (obj.actions && obj.actions[obj.ctr]) {
        if (typeof obj.actions[obj.ctr] == "string") {
            if (obj.tgt) {
                var win = window.open(obj.actions[obj.ctr], obj.tgt);
                if (win &&!win.closed)win.focus();
            }
            else {
                window.location = obj.actions[obj.ctr];
            }
        }
        else {
            obj.actions[obj.ctr]();
        }
    }
    return false;
}
;

Rotator.pause = function (n) {
    Rotator.clearTimers(n);
}
;
Rotator.clearTimers = function (n) {
    var obj = Rotator.col[n];
    if (obj) {
        clearTimeout(obj.timer);
        obj.timer = null;
    }
}
;
dw_Inf.ready=true;
Rotator.ready=true; 
Rotator.resume = function (n) {
    Rotator.clearTimers(n);
    var obj = Rotator.col[n];
    if (obj) {
        obj.timer = setTimeout(obj.animString + ".rotate()", Rotator.restartDelay);
    }
}
;
PictRotator.prototype = new Rotator();
function PictRotator(sp, pt, bClickable, tgt) {
    this.num = Rotator.col.length;
    this.name = "PKPict" + this.num;
    this.clickable = bClickable;
    this.rObj = Rotator;
    this.rObj(this.name, sp, pt, tgt);
}
;
PictRotator.prototype.setUpImage = function (imgAr, w, h, bTrans) {
    this.trans = bTrans;
    this.ctr = 0;
    var img = imgAr[this.ctr];
    var imgStr = '<img border=0 name="' + this.name + '" src="' + this.path + img + '"';
    imgStr += (typeof w == "number") ? ' width="' + w + '"' : '';
    imgStr += (typeof h == "number") ? ' height="' + h + '"' : '';
    imgStr += ' alt="">';
    var str = "";
    if (this.clickable) 
        str += '<a href="" onclick="return Rotator.doClick(' + this.num + ')" onfocus="this.blur()">' + imgStr + '</a>';
    else 
        str = imgStr;

    document.write(str);
    document.close();
    for (var i = 0; imgAr[i]; i++)this.addImages(imgAr[i]); 
}
;

PictRotator.prototype.rotate = function () {
    clearTimeout(this.timer);
    this.timer = null;
    this.ctr = this.ctr + 1;
	if (this.imgs.length <= this.ctr)
	  this.ctr = 0;
    var imgObj = document.images[this.name];
    if (!imgObj ||!Rotator.ready)return;
    if (this.trans && typeof imgObj.filters != "undefined") {
        imgObj.style.filter = 'blendTrans(duration=1)';
        if (imgObj.filters.blendTrans)imgObj.filters.blendTrans.Apply();
    }
	document.getElementById('xtext').innerHTML = this.texts[this.ctr];
    imgObj.src = this.imgs[this.ctr].src;
    if (this.trans && typeof imgObj.filters != "undefined" && imgObj.filters.blendTrans)imgObj.filters.blendTrans.Play();
    this.timer = setTimeout(this.animString + ".rotate()", this.speed);
}
;
