var _currentItem = 0;
var showNewsLatestId = 0;

function autoChange() {
  showNewsLatestId = setInterval ( "viewLatest()", 8000 );
}

function viewLatest() {
	if ($('latest_place')==undefined) return false;
  _currentItem++;
  if ($('lastest'+_currentItem)==undefined) _currentItem = 0;
  new Effect.Opacity('latest_place', {from:1.0, to:0});
  setTimeout("$('latest_place').innerHTML = $('lastest"+_currentItem+"').innerHTML;" +
              "new Effect.Opacity('latest_place', {from:0, to:1.0,duration:2.0});", 1000);

}
autoChange ();

function startAnimation(){
	animateImagesIn('albumslides');
}
var element1, element2, currentImage = -1, imgList, value = 0;
function animateImagesIn(elementId){
	var element = $(elementId);
	imgList = element.getElementsByTagName("img");
	for (var i=0;i<imgList.length;i++)
		imgList[i].parentNode.style.display = "none";
	currentImage = i-1;
	startTransition();
}
function startTransition(){
	try {
		if(currentImage>=imgList.length) currentImage = 0;
		element1 = (element2)?element2:imgList[currentImage].parentNode;
		element2 = (imgList[++currentImage])?imgList[currentImage].parentNode:imgList[currentImage = 0].parentNode;
		element2.style.display = element1.style.display = "block";
		value = 1;
		fader();
  } catch (e) {}
}
function fader(){
	value = value - 0.05;
	value = parseInt(value*100)/100;

	element1.style.opacity = value;
	element2.style.opacity = (1-value);
	element1.style.filter = "alpha(opacIty="+(value*100)+")";
	element2.style.filter = "alpha(opacity="+(100-(value*100))+")";
	if(value>0 && value<1){
		window.setTimeout(fader, 100);
	} else {
		element1.style.display = "none";
		window.setTimeout(startTransition, 2600);
	}
}
