function SwapFade(_img,_duration) {
	// *****************************************************
	// ORIGINAL DOM scripting by brothercake -- http://www.brothercake.com/
	//******************************************************
	
	var thisOBJ = this;// "this" object to allow private methods to call public methods
	
	var IMAGE = _img;
	var FADE_DURATION = _duration;
	var FADE_LENGTH = parseInt(FADE_DURATION,10) * 300;
	var FADE_RESOLUTION = parseInt(FADE_DURATION, 10) * 10;
	
	var CLOCK = null;
	var FADE = true;
	var COUNT = 1;
	var OPACITYTYPE = 'none';
	
	var newsrc = "";
	
	this.imgs = []; // {"name":"FILENAME.EXT","title":"","caption":"","url":"","target":""};
	var cache = []; // same as imgs
	
	/******************************
	PRIVATE Class Methods
	******************************/
	var init = function() {
		detectOpacity();
	}
	
	var detectOpacity = function() {
		if(typeof IMAGE.style.opacity != 'undefined') {
			OPACITYTYPE = 'w3c';
		} else if(typeof IMAGE.style.MozOpacity != 'undefined') {
			OPACITYTYPE = 'moz';
		} else if(typeof IMAGE.style.KhtmlOpacity != 'undefined') {
			OPACITYTYPE = 'khtml';
		} else if(typeof IMAGE.filters == 'object') {
			//weed out win/ie5.0 by testing the length of the filters collection (where filters is an object with no data)
			//then weed out mac/ie5 by testing first the existence of the alpha object (to prevent errors in win/ie5.0)
			//then the returned value type, which should be a number, but in mac/ie5 is an empty string
			OPACITYTYPE = (IMAGE.filters.length > 0 &&
							typeof IMAGE.filters.alpha == 'object' &&
							typeof IMAGE.filters.alpha.opacity == 'number') ? 'ie' : 'none';
		} else {
			OPACITYTYPE = 'none';
		}
		//alert(OPACITYTYPE);
	};
	
	//swapfade timer function
	var doSwap = function() {
		//increase or reduce the counter on an exponential scale
		COUNT = (FADE) ? COUNT * 0.9 : (COUNT * (1/0.9)); 
		
		//if the counter has reached the bottom
		if(COUNT < (1/FADE_RESOLUTION)) {
			//clear the timer
			clearInterval(CLOCK);
			CLOCK = null;
			//do the image swap
			IMAGE.src = newsrc;
			//reverse the fade direction flag
			FADE = false;
			//restart the timer
			CLOCK = setInterval(doSwap, FADE_LENGTH/FADE_RESOLUTION);
		}
		
		//if the counter has reached the top
		if(COUNT > (1 - (1/FADE_RESOLUTION))) {
			//clear the timer
			clearInterval(CLOCK);
			CLOCK = null;
			//reset the fade direction flag
			FADE = true;
			//reset the counter
			COUNT = 1;
		}
	
		//set new opacity value on element
		//using whatever method is supported
		switch(OPACITYTYPE) {
			case 'ie' :
				IMAGE.filters.alpha.opacity = COUNT * 100;
				break;
			case 'khtml' :
				IMAGE.style.KhtmlOpacity = COUNT;
				break;
			case 'moz' : 
				//restrict max opacity to prevent a visual popping effect in firefox
				IMAGE.style.MozOpacity = (COUNT == 1 ? 0.9999999 : COUNT);
				break;
			default : 
				//restrict max opacity to prevent a visual popping effect in firefox
				IMAGE.style.opacity = (COUNT == 1 ? 0.9999999 : COUNT);
		}
	};
	
	/******************************
	PUBLIC	Class Methods
	******************************/
	this.swapfade = function(_newsrc,_newalt) {
		newsrc = _newsrc;
		//change the image alt text if defined
		if(typeof _newalt != 'undefined' && _newalt != '') {
			IMAGE.alt = _newalt;
		}
		//if the timer is not already going
		if(CLOCK === null) {
			//if any kind of opacity is supported
			if(OPACITYTYPE != 'none') {
				CLOCK = setInterval(doSwap, FADE_LENGTH/FADE_RESOLUTION);
			}
			
			//otherwise if opacity is not supported
			else {
				//just do the image swap
				IMAGE.src = newsrc;
			}
			
		}
	};
	
	this.cacheImages = function() {
		var imgslen = this.imgs.length;
		for(var i=0; i<imgslen; i++) {
			cache[i] = new Image;
			cache[i].src = this.imgs[i].name;
		}
	};
	
	this.showCache = function() {
		var msg = "";
		for(var i=0; i<cache.length; i++) {
			msg += "(" + i + ") " + cache[i].src + "\n";
		}
		alert(msg);
	}
	
	this.fadeInProgress = function() {
		var ip = true;
		if(CLOCK === null) {
			ip = false;
		}
		return ip;
	}
	
	/******************************
	CALL TO "CONSTRUCTOR"
	******************************/
	init();
}


