﻿// copyright - The Intersoft Group, Inc. 2011
var xcnt=0;
var rotators;

function ImgRotator(mode,  hrefid, imgid) {
    var x;
    this.currentPos = 0;
    this.mode = mode;
    this.hrefid = hrefid;
    this.imgid = imgid;
    this.Alt = [];
    this.Link = [];
    this.ImgPaths = [];
    this.fire = function () {
        if (this.ImgPaths[this.currentPos] != undefined) {
            $("#" + this.imgid)[0].src = this.ImgPaths[this.currentPos];
        }
        if (this.Alt[this.currentPos] != undefined) {
            $("#" + this.imgid)[0].alt = this.Alt[this.currentPos];
        }
        if (this.Link[this.currentPos] != undefined) {
            $("#" + this.hrefid)[0].href = this.Link[this.currentPos];
        }
        this.currentPos += 1;
        if (this.currentPos >= this.ImgPaths.length) this.currentPos = 0;
    }
}

function RotatorControl(interval, rotatorlist) { //interval is in seconds
    var x;
    this.interval = interval * 1000;
    rotators = rotatorlist;
    this.run = function () {
        for(x=0;x<rotators.length;x++) rotators[x].fire(); //fire initial
        window.setInterval("fireRotators()", this.interval);
    }
 }

function fireRotators() {
   rotators[xcnt].fire();      //   $("#parea")[0].innerHTML = "fire " + xcnt + rotators[xcnt].hrefid + "<br/>"
   xcnt += 1;
   if (xcnt >= rotators.length) xcnt = 0;
}


