/* -----------------------------------------------------------------------------------
 *
 *
 * Atilla Moen-Duran 2008
 *
 * 2008.05.01: Init slide-type: hard
 * 2008.05.09: Added new slide-type: fade
 *
 ------------------------------------------------------------------------------------- */


/*
 * Common function
 */
function slideshow_check_imageno(settings) {
		  if (isNaN(parseInt(settings['imageno'])) || settings['imageno'] >= settings['imagearray'].length-1) {
					 settings['imageno'] = 0;
		  } else {
					 settings['imageno']++;
		  }
}


/*
 * Fade
 */
function slideshow_fade_do(settings,opac) {
		  if (opac==100) {
					 slideshow_check_imageno(settings);
					 settings['slide'].style.backgroundImage = 'url('+settings['imagearray'][(settings['imageno'])]+')';
		  }
		  
		  settings['slideimage'].style.opacity = (opac / 100);
		  settings['slideimage'].style.MozOpacity = (opac / 100);
		  settings['slideimage'].style.KhtmlOpacity = (opac / 100);
		  settings['slideimage'].style.filter = "alpha(opacity=" + opac + ")";

		  if (opac==1) {
					 settings['slideimage'].src = settings['imagearray'][(settings['imageno'])];
					 settings['slideimage'].style.opacity = 1;
					 settings['slideimage'].style.MozOpacity = 1;
					 settings['slideimage'].style.KhtmlOpacity = 1;
					 settings['slideimage'].style.filter = "alpha(opacity=100)";
					 setTimeout('slideshow_fade(settings)', settings['refresh']);
		  }
}

function slideshow_fade(settings) {
		  timer = 0;
		  for (i=100; i > 0; i--) {
					 timer++;
					 setTimeout('slideshow_fade_do(settings,'+i+')', (timer * 10));
		  }
}





/*
 * Hardshift - just shift
 */
function slideshow_hard(settings)  {
		  slideshow_check_imageno(settings);
		  settings['slideimage'].src = settings['imagearray'][(settings['imageno'])];
		  setTimeout('slideshow_hard(settings)', settings['refresh']);
}


/*
 * Slideshow main
 */
 function slideshow (sets) {
		  settings = sets;

		  /*
			* Check if imageno is set || if imageno is higher than array length
			*/
		  if (isNaN(parseInt(settings['imageno'])) || settings['imageno'] >= settings['imagearray'].length) {
					 settings['imageno'] = 0;
		  }


		  /*
			* Start slideshow
			*/
		  setTimeout('slideshow_'+settings['type']+'(settings)', settings['refresh']);
}

