function Rotator(xml_url, div, width, height, delay) {
	// set default properties
	var filenames = new Array();
	var links = new Array();
	var length = 0;
	var obj = this;
	
	// get filenames and links
	jQuery.ajax({
		type: "GET",
		url: xml_url,
		dataType: "xml",
		success: function(xml) {
			jQuery(xml).find("image").each(function() {
				filenames[length] = jQuery(this).find("filename").text();
		   		links[length] = jQuery(this).find("link").text();
				length++;
			});
			
			// add navigation buttons
			document.getElementById(div).innerHTML = '<div class="rotator-nav"><a href="javascript:' + div + '.prev()"><img class="rotator-arrow arrow-left" src="' + ROTATOR_INSTALL_DIR + '/images/left.gif" alt="Previous" /></a><a href="javascript:' + div + '.next()"><img class="rotator-arrow arrow-right" src="' + ROTATOR_INSTALL_DIR + '/images/right.gif" alt="Next" /></a></div>';
			<!--onMouseOver="this.src="' + ROTATOR_INSTALL_DIR + '/images/right_arrow2_over.png" onMouseOut="' + ROTATOR_INSTALL_DIR + '/images/right_arrow2.png"-->
			// create the link and picture nodes and set the default values
			var img = document.createElement('img');
			img.setAttribute('id', div + '_pic');
			img.setAttribute('src','');
			img.setAttribute('height',height);
			img.setAttribute('width',width);
			img.setAttribute('class','rotator-image');
			var a = document.createElement('a');
			a.setAttribute('id', div + '_link');
			a.setAttribute('href','#');
			a.setAttribute('target','_blank');
			// add the picture to the link
			a.appendChild(img);
			// add the link to the div
			document.getElementById(div).appendChild(a);
			
			obj.filenames = filenames;
			obj.links = links;
			obj.ubound = length - 1;
			obj.reset_time();
			obj.name = div;
			obj.delay = delay;
			obj.timeout = null;
			obj.current = 0;
			
			// preload pictures
			preloadImages(obj.filenames);
			
			// show the picture
			obj.update();
			
			//start automatic rotate
			obj.reset_time();
		}
	});
}

Rotator.prototype.reset_time = function() {
	if (this.delay > 0) {
		clearTimeout(this.timeout);
		this.timeout = setTimeout(this.name + '.next()', this.delay);
	}
}

Rotator.prototype.next = function() {
	this.reset_time();
	this.current++;
	if (this.current > this.ubound) {
		this.current = 0;
	}
	this.update();
}

Rotator.prototype.prev = function() {
	this.reset_time();
	this.current--;
	if (this.current < 0) {
		this.current = this.ubound;
	}
	this.update();	
}

Rotator.prototype.update = function() {
	document.getElementById(this.name + '_pic').src = this.filenames[this.current];
	document.getElementById(this.name + '_link').href = this.links[this.current];
}

function preloadImages(filenames) {
	for (var i=1; i<filenames.length; i++) {
		img = new Image();
		img.src = filenames[i];
	}
}