//@author:caizhl
//Í¼Æ¬µÄ»ÃµÆÆ¬ÏÔÊ¾
var img_list = new Array();
var num_of_img;
var t_img;
var t_link;

var status = 1;
var img_index = 0;
var timerID = null;
var t_name;
var bt_run = "/images/v3_picgo.gif";
var bt_stop = "/images/v3_picpause.gif";
var image = new Array();
function preLoad(p_img_list, p_id_img, p_id_link, p_id_name)
{	
	img_list = p_img_list;
	num_of_img = img_list.length;

	t_img	 = oo(p_id_img);
	if(t_img == null) return;
	
	t_link	 = oo(p_id_link);
	t_name	 = p_id_name;

	for(var i = 0; i < num_of_img; i++)
	{
   		image[i] = new Image();
		image[i].src = img_list[i][0];
	}
	
}

function play()
{
	nextImg(1);
	if(num_of_img == 1) return;
	timerID = setTimeout("play();", 4000);
}

function nextImg(next)
{
	if(isIE())
	{
		t_img.filters.revealTrans.transition=23;
		t_img.filters[0].Apply();
	}

	img_index = (img_index+next) % num_of_img;
	if(img_index < 0) 
	{
		img_index = num_of_img - 1;
	}
	t_img.src = image[img_index].src;//img_list[img_index][0];
	//resetImage(t_img)
//	if(t_link != null)
//	{
//		t_link.href = get_source_img(img_list[img_index][0]);
//	}
	
	if(t_name != null)
	{
		oo(t_name).innerHTML = img_list[img_index][1];
	}

	if(isIE())
	{	
		t_img.filters[0].Play();
	}
}

function playOrPause(b_id)
{
	if(status == 1)
	{
		if(timerID!=null) clearTimeout(timerID);
		oo(b_id).src = bt_run;
		oo(b_id).title = "¼ÌÐø";
		status = 0;
	}
	else if(status == 0)
	{
		timerID = setTimeout("play();", 4000);
		oo(b_id).src = bt_stop;
		oo(b_id).title = "ÔÝÍ£";
		status = 1;
	}
}