/*--- 
Copyright (c) Enigma Interactive 2005
Project:		SOM2 Lipstix
Filename:  		rotation.js
Description:	Featured Employers Javascript controller module

History
ver date  		who     	comment
-----------------------------------------------------------------------------
1	08Nov06		AL/CT		Created for mulitiple rotation areas on one page
---*/
function printfire()
{
    if (document.createEvent)
    try {
        printfire.args = arguments;
        var ev = document.createEvent("Events");
        ev.initEvent("printfire", false, true);
        dispatchEvent(ev);
    } catch(e) {}
}

var LOCAL = LOCAL || { };
LOCAL.fePause = 6000; // milliseconds
LOCAL.feWidth = 120;

LOCAL.feController = function() {
	this.inherit(OO.Timer);
}
LOCAL.feController.prototype = {
	initSelf: function() {
		this.images = [];
		//this.doFade();
	},
	
	start: function(id) {
		var image,i = 1;
		this.id = id;
		while (image = DHTML.bind(this.id+i, DHTML.Anim)) { this.images.push(image); image.O(0); i++; }
		this.current = 0;
		
		this.setTimeout('fade', LOCAL.fePause, this.doFade);	
	},
	
	doFade: function() {
		var image, next;
		printfire("fade");
		for (var i=0; i<1; i++) {
			image = this.images[this.current++];
			image.animate({O: 0}, 500);
			image.zIndex(1);
			if (this.current >= this.images.length) this.current = 0;
		}
		next = this.current;

		for (var i=0; i<1; i++) {
			image = this.images[next++];
			image.O(0);
			image.X(i * LOCAL.feWidth);
			image.zIndex(10);
			image.animate({O: 100}, 500);
			if (next >= this.images.length) next = 0;
		}

		this.setTimeout('fade', LOCAL.fePause, this.doFade);
	}
}

LOCAL.imageIDs = [ ];

LOCAL.addImage = function(id) { LOCAL.imageIDs.push(id); }

PAGE.onload(function() {
	var ele;
	LOCAL.animators = [ ];
	
	for (var i=0,id;(id=LOCAL.imageIDs[i]);i++) {
		ele = OO.create(LOCAL.feController);
		ele.start(id);
		LOCAL.animators.push(ele);
	}
});
