var img = new Array ();
var NewImg = new Array ();
var Labels = new Array();
var ImgNum = 0;
//Time delay between Slides in milliseconds
var delay = 3000;

var automode = false;

function Images (org, swap)
{
	if (document.images)
	{
	   this.org = new Image();
	   this.org.src = org;
	   this.swap = new Image();
	   this.swap.src = swap;
	}
}
	
function Add (iid,dir)
{
	img[iid] = new Images(dir+iid+".gif", dir+iid+"_on.gif");
}
	
function Swap(iid,imgsrc)
{
	/*if ( document.images[iid].src != img[iid].org.src)
		document.images[iid].src = img[iid].org.src;
	else document.images[iid].src = img[iid].swap.src;*/
	document.getElementById(iid).src = imgsrc;
}

function chgImg(direction,_path) {
	if (document.images) {
		ImgNum = ImgNum + direction;
		if (ImgNum > ImgLength) {
			ImgNum = 0;
		}
		if (ImgNum < 0) {
			ImgNum = ImgLength;
		}
		document.slideshow.src = NewImg[ImgNum];
		document.getElementById('img_label').innerHTML = Labels[ImgNum]+'&nbsp;';
	}
}

function _stop(_path) {
	if (automode == true) {
		automode = false;
		window.clearInterval(run);
		document.getElementById('btn_pause').src = _path+"btn_play.gif";
	}
}

function _start(_path) {
	if (automode == false) {
		automode = true;
		run = setInterval("chgImg(1)", delay);
		if (document.getElementById('btn_pause'))
			document.getElementById('btn_pause').src = _path+"btn_pause.gif";
	 }
}

function _switch(_path) {
	if (automode == true) _stop();
	else if (automode == false) _start();
}

function checkPlayStatus(ev,_path)
{
	if (automode == true) {
		if (ev =='over')
		Swap('btn_pause',_path+'btn_pause_on.gif');
		else Swap('btn_pause',_path+'btn_pause.gif');
	}
	else {
		if (ev =='over')
		Swap('btn_pause',_path+'btn_play_on.gif');
		else Swap('btn_pause',_path+'btn_play.gif');
	}
}
