function imgStack(imgPath, containerId, width, height, timeOut) {
	var imgStackPath = "/modules/imgStack";
	
	/*  get size from container
	var width = parseInt(document.getElementById(containerId).style.width);
	var height = parseInt(document.getElementById(containerId).style.height); */
	
	// autoSpeed Default: 5 seconds
	if(!timeOut) timeOut = 5;
		
	$.getScript(imgStackPath + "/swfobject.js", function () {
		var fo = new SWFObject(imgStackPath + "/imgStack.swf", containerId, width, height, "7");
		if(imgPath.substr(0, 1) != "/") {
			imgPath = document.URL.substring(0, document.URL.lastIndexOf("/")) + "/" + imgPath;
		}
		fo.addVariable("imgPath", imgPath);
		fo.addParam("wmode", "transparent");
		if(!fo.write(containerId)) {
			$("#" + containerId).load(imgStackPath + "/imgStack-getData.php?imgPath=" + imgPath + "&id=" + containerId + "Imgs");
			$(document).ready(function() {
				$.getScript(imgStackPath + "/jquery.cycle.all.js", function () {
					// cycle plug-in is loaded
					// embed "next/previous image" links
					$("#" + containerId).append('<a href="#" id="' + containerId + 'Prev" style="position: absolute; width: 50%; height: 100%; left: 0;"><img src="' + imgStackPath + '/img/prev.png" /></a><a href="#" id="' + containerId + 'Next" style="position: absolute; width: 50%; height: 100%; right: 0;"><img src="' + imgStackPath + '/img/next.png" /></a>');
					$("#" + containerId + 'Imgs').cycle({ 
					    fx:     'fade', 
					    speed:  500, 
					    timeout: timeOut * 1000, 
					    prev:   '#' + containerId + 'Prev', 
					    next:   '#' + containerId + 'Next', 
						nowrap: 0
					});
					$("#" + containerId).css({ position: "relative" });
					//  pull links to the front
					var z = $("#" + containerId + "Imgs img:first").css("z-index") * 1 + 1;
					$("#" + containerId + "Prev, #" + containerId + "Next").css("z-index", z)
					// prevent firefox dotted borders for active links
					$("#" + containerId + "Prev, #" + containerId + "Next").bind("focus", function() {
						if(this.blur) this.blur();
					});
					// style links
					$("#" + containerId + "Next img").css({position: "absolute", right: "0", top: (height-40) / 2, border: 0});
					$("#" + containerId + "Prev img").css({position: "absolute", left: "0", top: (height-40) / 2, border: 0});
					// link behaviour
					$("#" + containerId + "Prev, #" + containerId + "Next").bind("click", function() {
						$("#" + containerId + 'Imgs').cycle("pause");
					});
					$("#" + containerId + "Prev, #" + containerId + "Next").bind("click mouseout", function() {
						$("#" + containerId + "Prev img, #" + containerId + "Next img").fadeOut("fast");
					});
					$("#" + containerId + "Prev, #" + containerId + "Next").bind("mousemove", function() {
						$("#" + containerId + "Prev img, #" + containerId + "Next img").fadeIn("fast");
					});
					
				});
			});
		}
	});
}
