
    			//var promo=new imageRotator('promo');
    			//var images=[{src:'/img/rotate1.jpg',title:'Image 1',href:'/'},{src:'/img/rotate2.jpg',title:'Image 2'},{src:'/img/rotate3.jpg',title:'Image 3'},{src:'/img/rotate4.jpg',title:'Image 4'}];
    			//promo.init(5000,2,2,images,'rotator');

/*function imageRotator(varRef) {this.varRef=varRef;this.delay=2000;this.alphaSteps=5;this.timeSteps=2;this.images=[];this.container=null;this.index=0;this.loader=null;this.presenter=null;this.timer=null;this.init=init;this.loaded=loaded;this.faded=faded;this.next=next;function init(d,a,t,i,c) {if (d!==null) this.delay=d;if (a!==null) this.alphaSteps=a;if (t!==null) this.timeSteps=t;this.images=i;this.container=(typeof(c)=="string")?fob(c):c;this.index=0;this.container.innerHTML="<div id='iRPresentation' style='position:absolute'></div><div style='display:none;position:absolute' id='iRLoader'><img src='"+this.images[this.index].src+"' onload='"+this.varRef+".loaded();'/></div>";this.loader=fob('iRLoader');this.presenter=fob('iRPresentation');}function loaded() {fader(this.loader,0);this.loader.style.display='block';fadeObject.fade(this.loader,0,100,this.alphaSteps,this.varRef+".faded()");}function faded() {var ins="<img src='"+this.images[this.index].src+"' title='"+(this.images[this.index].title?this.images[this.index].title:"")+"'/>";if (this.images[this.index].href) ins="<a href='"+this.images[this.index].href+"'>"+ins+"</a>";this.presenter.innerHTML=ins;this.loader.style.display="none";this.timer=setTimeout(this.varRef+".next()",this.delay);}function next() {this.index++;if (this.index>=this.images.length) this.index=0;this.loader.innerHTML="<img src='"+this.images[this.index].src+"' onload='"+this.varRef+".loaded();'/>";}}*/

function imageRotator(varRef) {
    this.varRef = varRef;
    this.delay = 2000;
    this.alphaSteps = 5;
    this.timeSteps = 2;
    this.images = [];
    this.container = null;
    this.index = 0;
    this.loader = null;
    this.presenter = null;
    this.timer = null;
    this.init = init;
    this.loaded = loaded;
    this.faded = faded;
    this.next = next;
    this.imageText=imageText;

    function init(d, a, t, i, c) {
        if (d !== null) this.delay = d;
        if (a !== null) this.alphaSteps = a;
        if (t !== null) this.timeSteps = t;
        this.images = i;
        this.container = (typeof(c) == "string") ? fob(c) : c;
        this.index = 0;
        this.container.innerHTML = "<div id='iRPresentation' style='position:absolute'></div><div style='display:none;position:absolute' id='iRLoader'><img src='" + this.images[this.index].src + "' onload='" + this.varRef + ".loaded();'/>"+this.imageText(this.index)+"</div>";
        this.loader = fob('iRLoader');
        this.presenter = fob('iRPresentation');
    }
    function loaded() {
        fader(this.loader, 0);
        this.loader.style.display = 'block';
        fadeObject.fade(this.loader, 0, 100, this.alphaSteps, this.varRef + ".faded()");
    }
    function faded() {
        var ins = "<img src='" + this.images[this.index].src + "' title='" + (this.images[this.index].title ? this.images[this.index].title : "") + "'/>";
        ins+=this.imageText(this.index);
        if (this.images[this.index].href) ins = "<a href='" + this.images[this.index].href + "'>" + ins + "</a>";
        this.presenter.innerHTML = ins;
        this.loader.style.display = "none";
        this.timer = setTimeout(this.varRef + ".next()", this.delay);
    }
    function imageText(idx) {
	    var ins='';
        if (this.images[idx].text) {
        	var styles=[];
        	for(var key in this.images[idx].text) {
        		if (typeof(this.images[idx].text[key])=="string" && key!="text") {
        			if (this.images[idx].text[key]!="") {
        				styles.push(key+":"+((key!='color')?"":"#")+this.images[idx].text[key]+((key!='color')?"px":""));
        			}
        		}
        	}
        	ins+="<div style='"+styles.join(";")+"'>"+this.images[idx].text.text+"</div>";
        }
        return ins;
    }
    function next() {
        this.index++;
        if (this.index >= this.images.length) this.index = 0;
        this.loader.innerHTML = "<img src='" + this.images[this.index].src + "' onload='" + this.varRef + ".loaded();'/>"+this.imageText(this.index);
    }
}

