﻿//Image Changer


function ImageChanger(strFileName, imgId, imgScrDir, Seconds)
{
 	    this.pointer = 0;
		this.seconds = Seconds;
		this.strFile = strFileName;
		this.img = imgId;
		this.imgsrc = imgScrDir;
		this.imgEl = document.getElementById(imgId)
		var a = document.createElement("A");
		a.target = "_blank";
		this.imgEl.parentNode.appendChild(a)
		a.style.border = "0px";
		a.appendChild(this.imgEl);
		this.imgEl.code = this;
		this.start = function()
		{
		    if(!this.setStop) {
		        if (this.innerHTML)
		        {
		            var strs = this.innerHTML.split("\n");
			        var strss = strs[this.pointer].split(",");
		            this.imgEl.src = this.imgsrc + strss[0].replace(/ /g,"");;
		            if (strss.length > 1)
		            {
		            
			            this.imgEl.parentNode.href = strss[1].replace(/ /g,"");
			            this.imgEl.parentNode.onclick = null;     
			        }
			        else
			        {   this.imgEl.parentNode.href = "/";
			            this.imgEl.parentNode.onclick = function (){ return false;};
			        }
			        this.pointer++;
			        if  (this.pointer >= this.innerHTML.split("\n").length) this.pointer = 0;
			    }
			    setTimeout("document.getElementById('"+this.img+"').code.start();",this.seconds*1000);
			}
		}
		this.stop = function ()
		{
		    this.setStop = true;
		}
		gettext(this.strFile,this);
}		