


function odderRandomizer(id, filelist, widths) {
	
	this.filelist = [];
	this.widths = widths;
	this.id = id;
	this.pElement = jQuery("#c" + id + " .randomizerTarget");
	this.switchDelay = 5000;
	this.initialSwitchDelay = 1500;
	this.switchSpeed = 750;
	this.zIndexFinal = 2;
	this.zIndexInitial = 1;
	
	
	this.switchImage = function(element) {
		try {
			var newFileSource = this.filelist[element];
			var newFile = newFileSource[ Math.floor(Math.random() * newFileSource.length) ];
			
			var outputSource = this.pElement.find("> div").eq(element);
			
			var newImg = jQuery("<img>");
			var oldImg = outputSource.find("img");
			var p = this;
			newImg
				.css("z-index", this.zIndexInitial)
				.load(function(){
					oldImg.stop().fadeOut(500, function() {
						jQuery(this).remove();
						newImg.css("z-index", p.zIndexFinal);
					});
				})
				.attr("src", newFile)
			;
			
			outputSource.append(newImg);
			
			window.setTimeout("oRand_" + this.id + ".switchImage(" + element + ")", this.switchDelay);
		} catch(e){};
	}
	
	
	this.init = function(filelist) {
		try {
			
			var iteration = 1;
			var usedWidth = 0;
			
			for (folder in filelist) {
				var tOutput = [];
				for (i = 0; i < filelist[folder].length; i++) {
					tOutput.push( folder + filelist[folder][i]);
				}
				this.filelist.push(tOutput);
				
				var randomImage = tOutput[ Math.floor(Math.random() * tOutput.length) ];
				
				var imgHolder = jQuery("<div class='image'>");
				imgHolder.css({
					"width" : this.widths[ iteration - 1] + "px",
					"left" : usedWidth + "px"
				});
				
				usedWidth += this.widths[ iteration - 1];
				
				var img = jQuery("<img/>");
				img.attr("src", randomImage).css('z-index', this.zIndexFinal);
				
				imgHolder.append(img);
				
				this.pElement.append(imgHolder);
				
				window.setTimeout("oRand_" + this.id + ".switchImage(" + (iteration-1) + ")", (iteration * this.initialSwitchDelay));
				
				iteration++;
			}
		
		} catch(e){};
		
	}
	
	
	
	this.init(filelist);
	
};
