	/* special sfx styles */
var sfx = {
	
	slideshowImageDir 	: "images/slideshow/",
	slideshowTarget		: "colimg",
	slideshowImages 	: [],
	slideshowSlide 		: 0,
	slideshowSpeed		: 500,
	slideshowDelay		: 3000,
	slideshowPause		: false,
	
	expandFps           : 25,
	expanding			: false,
	
	preloadSlideshow : function(images)
	{
		for(i = 0; i < images.length; i++){
			//	preload the images		
			var img 	= new Image();
				img.src = sfx.slideshowImageDir + images[i];
				//dom.debug(img.src);
			//	add to stored image array
			sfx.slideshowImages.push(img);
		}
	},	
	
	
	slideshow : function()
	{
		//	is slide show paused
		if( sfx.slideshowPause ) return false;
		
		sfx.slideshowSlide++;
		if( sfx.slideshowSlide == sfx.slideshowImages.length  ){
			sfx.slideshowSlide = 0;
		}
		setTimeout(
			function(){ 
				//	is slide show paused
				if( sfx.slideshowPause ) return false;
		
				sfx.fade( dom.byId(sfx.slideshowTarget), 100, 0, sfx.slideshowSpeed );
				setTimeout(
					function(){ 
						dom.byId(sfx.slideshowTarget).src = sfx.slideshowImages[sfx.slideshowSlide].src;
						sfx.fade( dom.byId(sfx.slideshowTarget), 0, 100, sfx.slideshowSpeed );
						sfx.slideshow();
					}, sfx.slideshowSpeed); 
			}, sfx.slideshowDelay);
	},
	
	
	pauseSlideshow : function()
	{	
		sfx.slideshowPause = true;
	},
	
	
	playSlideshow : function()
	{
		if( sfx.slideshowPause ){
			sfx.slideshowPause = false;
			sfx.slideshow();
		}
	},
	
	
	autoSlideshow : function()
	{
		if( sfx.slideshowPause ){
			sfx.playSlideshow();
		}else{
			sfx.pauseSlideshow();
		}	
	},
	
	/* *********************************************
	set opacity of oject via inline style
	********************************************* */
	setOpacity : function( obj, value )
	{
		if( obj ){
			obj.style.opacity 	   = (value/101).toFixed(2);  
			obj.style.MozOpacity   = (value/101).toFixed(2);
			obj.style.KhtmlOpacity = (value/100).toFixed(2);
			obj.style.filter = "alpha(opacity=" + value + ")"; 
		}
	},
	
	
	/* *********************************************
	gets opacity of object, inline stlye or by class
	********************************************* */
	getOpacity : function(obj)
	{
		//	ensure that a number is returned
		var opac = parseFloat(obj.style.opacity);
		//	if opacity is not set
		if( isNaN(opac) ){
			sfx.setOpacity(obj, 100);
			return sfx.getOpacity(obj);
		}
		return opac;
	},

	
	fade : function(obj, start, end, millisec)
	{	    //speed for each frame	    var speed = Math.round(millisec/100);	    var timer = 0;		
		//	ensure that opacity is set on object
		sfx.getOpacity(obj);
			    //determine the direction for the blending, if start and end are the same nothing happens	    if(start > end) {
	    	 for(var i = start; i >= end; i--){
	        	setTimeout(function(){ sfx.setOpacity(obj, start--) }, (timer*speed));
	        	timer++;	        }	    }else if(start < end) {	        for(var i = start; i <= end; i++){	            setTimeout(function(){ sfx.setOpacity(obj, start++) }, (timer*speed));	            timer++;	        }	    }
	},
	
	
	fadeIn : function(obj, millisec)
	{
		if( !millisec ){
	    	millisec = sfx.slideshowSpeed;
	    }
	    sfx.fade(obj, 0, 100, millisec);
	}, 
	
	fadeOut : function(obj)
	{
		if( !millisec ){
	    	millisec = sfx.slideshowSpeed;
	    }
	    sfx.fade(obj, 100, 0, millisec);
	}, 
	
	
	expandOpen : function(obj, expandToHeight)
	{
		var offset = obj.offsetHeight;
		var pixels = sfx.expandFps;
		sfx.expanding     = true;
		
		if( obj.style.display == "none" ){
			obj.style.height   = "0px";
			obj.style.display  = "block";
		}
		
		if( (expandToHeight - offset) < pixels ){
			//	deaccelerate
			pixels = Math.floor((expandToHeight - offset) / 2);	
			//	ensure that overflow pixels aren't encountered
			if( pixels <= 1 ){
				obj.style.height = expandToHeight + 'px';
				sfx.expanding    = false;
				return;
			}
		}
		obj.style.height = (obj.offsetHeight + pixels) + 'px';
		var t = setTimeout(function(){ sfx.expandOpen(obj, expandToHeight) }, sfx.expandFps);
		 
	},
	
	
	expandClose : function(obj)
	{
		var offset = obj.offsetHeight;
		var pixels = sfx.expandFps;
		sfx.expanding     = true;
		
		if( offset <= pixels ){
			pixels = Math.floor(offset / 2);
			if( pixels <= 1 ){
				obj.style.height  = "0px";
				obj.style.display = "none";
				sfx.expanding     = false;
				return;
			}
		}
		obj.style.height = (obj.offsetHeight - pixels ) + 'px';
		setTimeout(function(){ sfx.expandClose(obj) }, sfx.expandFps);
	},
	
	
	expandPanes : function(closeObj, openObj, openTo)
	{
		if( closeObj != openObj && !sfx.expanding ){
			sfx.expanding     = true;
			sfx.expandClose(closeObj);
			sfx.expandOpen(openObj, openTo);
		}
	}
}

