﻿var showImageIndex = -1;
var imageTimer;
function showImage(imageIndex)
{
	var flash_img_div = document.getElementById("flash_img_div");
	var flash_title = document.getElementById("flash_title");	
	
	if(imageIndex>fImgs.length-1){
		imageIndex = 0;//	翻到最后一张时转到第一张
	}
	
	if(!fImgs[imageIndex] || imageIndex==showImageIndex)
	return false;//	向前翻到第一张结束

	var imgId = "__fImg"+imageIndex;
	flash_img_div.filters && flash_img_div.filters[0].Apply();
	for(i=0; i<flash_img_div.childNodes.length; i++){
		flash_img_div.childNodes[i].style.display = "none";
	}
	
			var img = new Image();
			img.border = "0";
			img.src = fImgs[imageIndex].img;
			img.className = "flash_flimg";
			
			var a = document.createElement("a");
			a.href = fImgs[imageIndex].href;
			a.target = "_blank";
			a.title = fImgs[imageIndex].title;
			a.id = imgId;
			a.appendChild(img);
			flash_img_div.appendChild(a);

	flash_img_div.filters && flash_img_div.filters[0].Play();
	var flash_show_msg = document.getElementById("flash_show_msg");
	flash_show_msg.filters && flash_show_msg.filters[0].Apply();
	flash_title.href = fImgs[imageIndex].href;
	flash_title.target = "_blank";
	flash_title.innerHTML = fImgs[imageIndex].title;
	flash_show_msg.filters && flash_show_msg.filters[0].Play();
	showImageIndex = imageIndex;
	return true;
}
function imagePlay()
{
	if(imageTimer) return;
	if(showImageIndex>=fImgs.length-1){
		showImageIndex = -1;
	}
	showImage(showImageIndex+1);
	imageTimer = setInterval(function(){
					var stat = showImage(showImageIndex+1);
					if(!stat){
						stop();
					}	
				},2500);
}
function stop(){
	clearInterval(imageTimer);
	imageTimer = null;
}
function showNextImage(){
	showImage(showImageIndex+1);
}
function showPrevImage(){
	showImage(showImageIndex-1);
}