var ImageScroller=function(e,f)
{
	e=getElem(e);
	f=getElem(f);
	var g=new Array();
	var h=new Array();
	var j=new Array();
	var k=new Array();
	var l=new Array();
	var m=1;
	var n=0;
	var o=0;
	var p;
	var q=0;
	var r=0;
	var s=0;
	var t=0;
	var u=true;
	var v=0;
	var w=2000;
	var x=1;
	var y=1;
	var z=1;
	var A=0;
	var B=0;
	var C=0;
	var D=0;
	var E=1;
	var F=false;
	var G="";
	var H="";
	var I=3;
	var J=7;
	var K;
	this.THUMB_HEIGHT=80;
	this.THUMB_WIDTH=80;
	this.THUMB_PADDING=4;
	this.AutoLoop=true;
	var L=1;
	var M=0;
	var N=0;
	var O=0;
	var P=false;
	this.enableMultiSizeThumbnails=function()
	{
		F=true
	};
	this.setNumOfImageToScroll=function(a)
	{
		E=parseInt(a)
	};
	this.enableThumbnailDescription=function(a)
	{
		C=1;
		H=a	
	};
	this.setScrollType=function(a)
	{
		if(a==0)
		{
			z=0
		}
		else
		{
			z=1
		}
	};
	this.getScrollType=function()
	{
		return z
	};
	this.setScrollSpeed=function(a)
	{
		if(a>0||a<1000)
		{
			I=a
		}
		else
		{
			I=7
		}
	};
	this.setScrollAmount=function(a)
	{
		if(a>0||a<1000)
		{
			J=a
		}
		else
		{
			J=7
		}
	};
	this.setAutoLoop=function(a)
	{
		u=a;
		this.AutoLoop=u
	};
	this.getAutoLoop=function()
	{
		return this.AutoLoop
	};
	this.setClickOpenType=function(a)
	{
		if(a==0||a==1)
		{
			D=a
		}
	};
	this.enableCurrentCount=function(a)
	{
		B=1;
		G=a
	};
	this.enableThumbBorder=function(a)
	{
		A=a
	};
	this.setThumbsShown=function(a)
	{
		m=parseInt(a)
	};
	this.getThumbsShown=function()
	{
		return m
	};
	this.addThumbnail=function(a,b,c,d)
	{
		h[h.length]=a;
		k[k.length]=b;
		j[j.length]=c;
		l[l.length]=d
	};
	this.setThumbnailHeight=function(a)
	{
		this.THUMB_HEIGHT=a
	};
	this.getThumbnailHeight=function()
	{
		return this.THUMB_HEIGHT
	};
	this.setThumbnailWidth=function(a)
	{
		this.THUMB_WIDTH=a
	};
	this.getThumbnailWidth=function()
	{
		return this.THUMB_WIDTH
	};
	this.setThumbnailPadding=function(a)
	{
		this.THUMB_PADDING=a
	};
	this.getThumbnailPadding=function()
	{
		return THUMB_PADDING
	};
	this.getCurrentThumbIndex=function()
	{
		return L
	};
	this.getThumbnailCount=function()
	{
		return p
	};
	this.getScrollerHeight=function()
	{
		return this.iNumOfThumbsShownHeightTotal_
	};
	this.getScrollerWidth=function()
	{
		return n
	};

	this.iNumOfThumbsShownHeightTotal_=0;

	this.renderScroller=function()
	{
		p=h.length;
		if(m>p)
		{
			m=p
		}
		var a;
		var b;
		a=document.createElement("a");
		b=document.createElement("img");
		for(i=0;i<p;i++)
		{
			a=document.createElement("a");
//			a.title=j[i];
			b=document.createElement("img");
			b.src=h[i];
//			b.alt=j[i];
			b.border=0;
			b.onclick=stopRotator;
			b.onmouseover=pauseRotator;
			b.onmouseout=unpauseRotator;
			b.width=this.THUMB_WIDTH;
			b.height=this.THUMB_HEIGHT;
			if(j[i].indexOf("javascript:")>-1)
			{
				a.href=j[i]
			}
			else if(j[i]=="")
			{
			
			}
			else
			{
				a.href=j[i];
				if(D==1)
				{
					a.target="_blank"
				}
			}
			if(document.all)
			{
				b.style.padding=this.THUMB_PADDING
			}
			else
			{
				b.style.padding=this.THUMB_PADDING+"px"
			}
			if(b.height>q)
			{
				q=b.height
			}
			if(b.width>r)
			{
				r=b.width
			}
			s=s+(0+b.width);
			if(i<m)
			{
				n=n+(0+b.width)
			}
			t=t+(0+b.height);
			if(i<m)
			{
				o=o+(0+b.height)
			}
			a.appendChild(b);
			b.style.verticalAlign="middle";
			b.style.align="center";
			if(F==true)
			{
				_tbl=document.createElement("table");
				_body=document.createElement("tbody");
				_row=document.createElement("tr");
				_cell=document.createElement("td");
				_div=document.createElement("div");
				f.appendChild(a)
			}
			else
			{
				f.appendChild(a)
			}
		}
		var c=2;
		if(document.all)
		{
			c=4
		};
		p=h.length;
		if(m>p)
		{
			m=p
		}
		s=s+((this.THUMB_PADDING*2)*p);
		n=n+((this.THUMB_PADDING*2)*m);
		t=t+((this.THUMB_PADDING*2)*p);
		o=o+((this.THUMB_PADDING*2)*m);
		this.iNumOfThumbsShownHeightTotal_=o;
		if(z==0)
		{
			N=(n-s);
			if(document.all)
			{
			
			}
			e.style.width=n+"px";
			if(A==1)
			{
				e.style.width=(parseInt(e.style.width)+(p*4))+"px"
			}
			e.style.height=(q+(this.THUMB_PADDING*2))+"px";
			if(A==1)
			{
				e.style.height=(parseInt(e.style.height)+4)+"px"
			}
			f.style.width=s+"px";
			if(A==1)
			{
				f.style.width=(parseInt(f.style.width)+(p*4))+"px"
			}
		}
		else if(z==1)
		{
			N=0-((t-o));
			e.style.width=(r+(this.THUMB_PADDING*2))+"px";
			if(A==1)
			{
				e.style.width=(parseInt(e.style.width)+(4))+"px"
			}
			e.style.height=o+"px";
			if(A==1)
			{
				e.style.height=(parseInt(e.style.height)+(m*4))+"px"
			}
			f.style.width=(r+(this.THUMB_PADDING*2))+"px";
			if(A==1)
			{
				f.style.width=(parseInt(f.style.width)+4)+"px"
			}
		}
		if(B==1)
		{
			addAnEvent(window,"load",this.updateCurrentCount)
		}
		if(C==1)
		{
			addAnEvent(window,"load",this.updateCurrentDescription)
		}
		this.scrollBegin();
	};
	this.smoothScrollUp=function()
	{
		_origOffset=parseInt(f.style.top);
		_currentOffset=parseInt(f.style.top);
		_newOffset=_currentOffset-J;
		if(this.THUMB_PADDING>0)
		{
			_newOffset=_newOffset-(2*this.THUMB_PADDING)
		}
		if(A==1)
		{
			_newOffset=_newOffset-4
		}
		if(P==false&&_newOffset>=N)
		{
			O=_newOffset;
			smoothMoveScrollerUp()
		}

	};
	this.scrollUp=function()
	{
		_origOffset=parseInt(f.style.top);
		_currentOffset=parseInt(f.style.top);
		_newOffset=_currentOffset-(this.THUMB_HEIGHT*E);
		if(this.THUMB_PADDING>0)
		{
			_newOffset=_newOffset-(2*this.THUMB_PADDING)
		}
		if(A==1)
		{
			_newOffset=_newOffset-4
		}
		if(P==false&&_newOffset>=N)
		{
			O=_newOffset;
			moveScrollerUp()
		}
	};
	this.smoothScrollDown=function()
	{
		_origOffset=parseInt(f.style.top);
		_currentOffset=parseInt(f.style.top);
		_newOffset=_currentOffset+J;
		if(this.THUMB_PADDING>0)
		{
			_newOffset=_newOffset+(2*this.THUMB_PADDING)
		}
		if(A==1)
		{
			_newOffset=_newOffset+4
		}
		if(_newOffset<=0)
		{
			if(_currentOffset>(_origOffset-this.THUMB_HEIGHT))
			{
				if(P==false&&_newOffset>=N)
				{
					M=_newOffset;
					smoothMoveScrollerDown()
				}
			}
		}
	};
	this.scrollDown=function()
	{
		_origOffset=parseInt(f.style.top);
		_currentOffset=parseInt(f.style.top);
		_newOffset=_currentOffset+(this.THUMB_HEIGHT*E);
		if(this.THUMB_PADDING>0)
		{
			_newOffset=_newOffset+(2*this.THUMB_PADDING)
		}
		if(A==1)
		{
			_newOffset=_newOffset+4
		}
		if(_newOffset<=0)
		{
			if(_currentOffset>(_origOffset-this.THUMB_HEIGHT))
			{
				if(P==false&&_newOffset>=N)
				{
					M=_newOffset;
					moveScrollerDown()
				}
			}
		}
	};
	this.scrollTop=function()
	{
		if(P==false)
		{
			O=(N);
			L=p-m;
			moveScrollerUp()
		}
	};
	this.scrollBottom=function()
	{
		if(P==false)
		{
			M=0;
			L=p-m;
			moveScrollerDown()
		}
	};
	this.smoothScrollReverse=function()
	{
		_origOffset=parseInt(f.style.left);
		_currentOffset=parseInt(f.style.left);
		_newOffset=_currentOffset+J;
		if(this.THUMB_PADDING>0)
		{
			_newOffset=_newOffset+(this.THUMB_PADDING*(2*E))
		}
		if(A==1)
		{
			_newOffset=_newOffset+4
		}
		if(_newOffset<=0)
		{
			if(_currentOffset>(_origOffset-(this.THUMB_WIDTH*E)))
			{
				if(P==false)
				{
					M=_newOffset;
					smoothMoveScrollerRight()
				}
			}
		}
	};
	this.scrollReverse=function()
	{
		if (L==1)
		{
			this.scrollEndOffset();
		}
		if(z==0)
		{
			_origOffset=parseInt(f.style.left);
			_currentOffset=parseInt(f.style.left);
			_newOffset=_currentOffset+(this.THUMB_WIDTH*E);
			if(this.THUMB_PADDING>0)
			{
				_newOffset=_newOffset+(this.THUMB_PADDING*(2*E))
			}
			if(A==1)
			{
				_newOffset=_newOffset+4
			}
			if(_newOffset<=0)
			{
				if(_currentOffset>(_origOffset-(this.THUMB_WIDTH*E)))
				{
					if(P==false)
					{
						M=_newOffset;
						moveScrollerRight();
					}
				}
			}
			else if (P==false)
			{
				this.scrollEnd();
			}
		}
		else
		{
			this.scrollDown()
		}
	};
	this.smoothScrollForward=function()
	{
		_origOffset=parseInt(f.style.left);
		_currentOffset=parseInt(f.style.left);
		_newOffset=_currentOffset-J;
		if(this.THUMB_PADDING>0)
		{
			_newOffset=_newOffset-((2*E)*this.THUMB_PADDING)
		}
		if(A==1)
		{
			_newOffset=_newOffset-4
		}
		if(P==false&&_newOffset>=N)
		{
			O=_newOffset;
			smoothMoveScrollerLeft()
		}
	};
	this.scrollForward=function()
	{
		if (L==p-3)
		{
			this.scrollBeginOffset();
		}
		if(z==0)
		{
			_origOffset=parseInt(f.style.left);
			_currentOffset=parseInt(f.style.left);
			_newOffset=_currentOffset-(this.THUMB_WIDTH*E);
			if(this.THUMB_PADDING>0)
			{
				_newOffset=_newOffset-((2*E)*this.THUMB_PADDING)
			}
			if(A==1)
			{
				_newOffset=_newOffset-4
			}
			if(P==false&&_newOffset>=N)
			{
				O=_newOffset;
				moveScrollerLeft()
			}
			else if (P==false)
			{
				this.scrollBegin();
			}
		}
		else
		{
			this.scrollUp()
		}
	};
	this.scrollEnd=function()
	{
		if(z==0)
		{
			if(P==false)
			{
				O=N+(3*(this.THUMB_WIDTH+(2*this.THUMB_PADDING)));
				L=p-m;
				L=L-3;
//				moveScrollerLeft()
				_ElementObj=f;
				_currentOffset=parseInt(_ElementObj.style.left);
				_ElementObj.style.left=O;
				P=true;
				P=false;
				L++;
				if(C==1)
				{
					getElem(H).innerHTML=l[L-1]
				}
				if(B==1)
				{
					getElem(G).innerHTML=L+"/"+p
				}
			}
		}
		else
		{
			this.scrollTop()
		}
	};
	this.scrollEndOffset=function()
	{
		if(z==0)
		{
			if(P==false)
			{
				O=N+(2*(this.THUMB_WIDTH+(2*this.THUMB_PADDING)));
				L=p-m;
				L=L-2;
//				moveScrollerLeft()
				_ElementObj=f;
				_currentOffset=parseInt(_ElementObj.style.left);
				_ElementObj.style.left=O;
				P=true;
				P=false;
				L++;
				if(C==1)
				{
					getElem(H).innerHTML=l[L-1]
				}
				if(B==1)
				{
					getElem(G).innerHTML=L+"/"+p
				}
			}
		}
		else
		{
			this.scrollTop()
		}
	};
	this.scrollBegin=function()
	{
		if(z==0)
		{
			if(P==false)
			{
				M=0-(3*(this.THUMB_WIDTH+(2*this.THUMB_PADDING)));
				L=2;
				L=L+3;
//				moveScrollerRight()
				_ElementObj=f;
				_currentOffset=parseInt(_ElementObj.style.left);
				_ElementObj.style.left=M;
				P=true;
				P=false;
				L--;
				if(C==1)
				{
					getElem(H).innerHTML=l[L-1]
				}
				if(B==1)
				{
					getElem(G).innerHTML=L+"/"+p
				}
			}
		}
		else
		{
			this.scrollBottom()
		}
	};
	this.scrollBeginOffset=function()
	{
		if(z==0)
		{
			if(P==false)
			{
				M=0-(2*(this.THUMB_WIDTH+(2*this.THUMB_PADDING)));
				L=2;
				L=L+2;
//				moveScrollerRight()
				_ElementObj=f;
				_currentOffset=parseInt(_ElementObj.style.left);
				_ElementObj.style.left=M;
				P=true;
				P=false;
				L--;
				if(C==1)
				{
					getElem(H).innerHTML=l[L-1]
				}
				if(B==1)
				{
					getElem(G).innerHTML=L+"/"+p
				}
			}
		}
		else
		{
			this.scrollBottom()
		}
	};
	this.stopSmoothScroll=function()
	{
		P=false;
		window.clearTimeout(K)
	};
	this.updateCurrentDescription=function()
	{
		getElem(H).innerHTML=l[L-1]
	};
	this.updateCurrentCount=function()
	{
		getElem(G).innerHTML=L+"/"+p
	};
	function smoothMoveScrollerUp()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.top);
		if(_currentOffset>N&&(_currentOffset-J)>=N)
		{
			_ElementObj.style.top=_currentOffset-J+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerUp,I)
		}
		else if(_currentOffset>N)
		{
			_ElementObj.style.top=_currentOffset-1+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerUp,I)
		}
		else
		{
			P=false;
			window.clearTimeout(K)
		}
	};
	function moveScrollerUp()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.top);
		if(_currentOffset>O&&(_currentOffset-J)>=O)
		{
			_ElementObj.style.top=_currentOffset-J+"px";
			P=true;
			K=window.setTimeout(moveScrollerUp,I)
		}
		else if(_currentOffset>O)
		{
			_ElementObj.style.top=_currentOffset-1+"px";
			P=true;
			K=window.setTimeout(moveScrollerUp,I)
		}
		else
		{
			P=false;
			L++;
			window.clearTimeout(K);
			if(C==1)
			{
				getElem(H).innerHTML=l[L-1]
			}
			if(B==1)
			{
				getElem(G).innerHTML=L+"/"+p
			}
		}
	};
	function smoothMoveScrollerDown()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.top);
		if(_currentOffset<0&&(_currentOffset+J)<=0)
		{
			_ElementObj.style.top=_currentOffset+J+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerDown,I)
		}
		else if(_currentOffset<0)
		{
			_ElementObj.style.top=_currentOffset+1+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerDown,I)
		}
		else
		{
			P=false;
			window.clearTimeout(K)
		}
	};
	function moveScrollerDown()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.top);
		if(_currentOffset<M&&(_currentOffset+J)<=M)
		{
			_ElementObj.style.top=_currentOffset+J+"px";
			P=true;
			K=window.setTimeout(moveScrollerDown,I)
		}
		else if(_currentOffset<M)
		{
			_ElementObj.style.top=_currentOffset+1+"px";
			P=true;
			K=window.setTimeout(moveScrollerDown,I)
		}
		else
		{
			P=false;
			L--;
			window.clearTimeout(K);
			if(C==1)
			{
				getElem(H).innerHTML=l[L-1]
			}
			if(B==1)
			{
				getElem(G).innerHTML=L+"/"+p
			}
		}
	};
	function smoothMoveScrollerRight()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.left);
		if(_currentOffset<0&&(_currentOffset+J)<=0)
		{
			_ElementObj.style.left=_currentOffset+J+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerRight,I)
		}
		else if(_currentOffset<0)
		{
			_ElementObj.style.left=_currentOffset+1+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerRight,I)
		}
		else
		{
			P=false;
			window.clearTimeout(K)
		}
	};
	function moveScrollerRight()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.left);
		if(_currentOffset<M&&(_currentOffset+J)<=M)
		{
			_ElementObj.style.left=_currentOffset+J+"px";
			P=true;
			K=window.setTimeout(moveScrollerRight,I)
		}
		else if(_currentOffset<M)
		{
			_ElementObj.style.left=_currentOffset+1+"px";
			P=true;
			K=window.setTimeout(moveScrollerRight,I)
		}
		else
		{
			P=false;
			L--;
			window.clearTimeout(K);
			if(C==1)
			{
				getElem(H).innerHTML=l[L-1]
			}
			if(B==1)
			{
				getElem(G).innerHTML=L+"/"+p
			}
			if (boolRotate)
			{
				eval(k[L-1]);
			}
		}
	};
	function smoothMoveScrollerLeft()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.left);
		if(_currentOffset>N&&(_currentOffset-J)>=N)
		{
			_ElementObj.style.left=_currentOffset-J+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerLeft,I)
		}
		else if(_currentOffset>N)
		{
			_ElementObj.style.left=_currentOffset-1+"px";
			P=true;
			K=window.setTimeout(smoothMoveScrollerLeft,I)
		}
		else
		{
			P=false;
			window.clearTimeout(K)
		}
	};
	function moveScrollerLeft()
	{
		_ElementObj=f;
		_currentOffset=parseInt(_ElementObj.style.left);
		if(_currentOffset>O&&(_currentOffset-J)>=O)
		{
			_ElementObj.style.left=_currentOffset-J+"px";
			P=true;
			K=window.setTimeout(moveScrollerLeft,I)
		}
		else if(_currentOffset>O)
		{
			_ElementObj.style.left=_currentOffset-1+"px";
			P=true;
			K=window.setTimeout(moveScrollerLeft,I)
		}
		else
		{
			P=false;
			L++;
			window.clearTimeout(K);
			if(C==1)
			{
				getElem(H).innerHTML=l[L-1]
			}
			if(B==1)
			{
				getElem(G).innerHTML=L+"/"+p
			}
			if (boolRotate)
			{
				eval(k[L-1]);
			}
		}
	}
};

var iRetryAttempt=0;
var iMaxAttachRetry=3;
function addAnEvent(a,b,c)
{
	if(a!=null&&a!="undefined")
	{
		if(window.addEventListener)
		{
			a.addEventListener(b,c,false)
		}
		else
		{
			a.attachEvent("on"+b,c)
		}
		iRetryAttempt=0
	}
	else
	{
		if(iRetryAttempt<iMaxAttachRetry)
		{
			try
			{
				iRetryAttempt++;
				window.setTimeout(addAnEvent(a,b,c),1000)
			}
			catch(Exceptions)
			{
				return
			}
		}
	}
};

function getElem(a)
{
	return document.getElementById(a)
};

