		addNamespace("KY.Web.DynaMarquee2");

		KY.Web.DynaMarquee2 = Class.create();
		
		Object.extend(KY.Web.DynaMarquee2.prototype, {
			state: null,
			array: null,
			pager: "",
			classname: "",
			pos: 0,
			timer: null,
			slideTimer: null,
			slideDirection: 1,
			isRunning: false,
			timerInterval: 10000,
			w: 0,
			show: function(i) {
				if (this.isRunning) { return; }
				this.isRunning = true;
				this.clearClass();

				document.getElementById(this.state).innerHTML = this.array[i];
				//document.getElementById(this.pager + "_td_" + i).className = this.classname + "show";
				if (i+1 > this.array.length) { this.pos = 0; }
				else { this.pos = i+1; }
				this.showSlide();
			},
			clearClass: function() {
				var i = 0;
				for (i = 0; i < this.array.length ; i++)
				{
					document.getElementById(this.pager.id + "_img_" + i).src = "/resim/dugme/dugme_" + (i+1) + ".gif";
				}
			},
			onnext: function(e) {
				if (this.isRunning) { return; }
				this.isRunning = true;
				this.slideDirection = 1;
				
				if (this.pos > this.array.length-1) { this.pos=0; }

				this.clearClass();
				document.getElementById(this.state).innerHTML = this.array[this.pos];
				document.getElementById(this.pager.id + "_img_" + this.pos).src = "/resim/dugme/dugme_" + ( this.pos+1) + "_hover.gif";
				if (this.pos+1 >= this.array.length) { this.pos = 0; }
				else { this.pos++; }
				 
				this.showSlide();
			},
			showSlide: function() {
				var curObj = document.getElementById(this.state); 
				var nextObj = document.getElementById((this.state == this.ele.id + "_div1")? this.ele.id + "_div2" : this.ele.id + "_div1"); 
				if (this.slideDirection == 1) { this.curpos = this.w; }
				else { this.curpos = -1 * this.w; }
				curObj.style.left = this.curpos + "px";
				curObj.style.yIndex++;
				curObj.style.display = nextObj.style.display = "inline";

				if (curObj.filters) {
					curObj.filters.alpha.opacity = nextObj.filters.alpha.opacity = 40;
				}
				else if (document.getElementById(this.state).style.MozOpacity) {			
					curObj.style.MozOpacity = nextObj.style.MozOpacity =0.4;
				}
				this.timerSlide = setInterval(this.moveSlide.bind(this), 50);
			},
			moveSlide: function() {
				var curObj = document.getElementById(this.state); 
				var nextObj = document.getElementById((this.state == this.ele.id + "_div1")? this.ele.id + "_div2" : this.ele.id + "_div1"); 

				if (this.curpos > 0 && this.slideDirection == 1)
				{
					this.curpos = Math.max(this.curpos-25,0);
					curObj.style.left = this.curpos + "px";
				}
				else if (this.curpos < 0 && this.slideDirection == 0)
				{
					this.curpos = Math.min(this.curpos+25,0);
					curObj.style.left = this.curpos + "px";
				}
				else
				{
					clearInterval(this.timerSlide);
					if (curObj.filters) {
						curObj.filters.alpha.opacity = 100;
					}
					else if (curObj.style.MozOpacity) {
						curObj.style.MozOpacity = 1;
					}
					this.state = (this.state == this.ele.id + "_div1")? this.ele.id + "_div2" : this.ele.id + "_div1";
					nextObj.style.display = "none";
					this.isRunning = false;
				}
			},
			onmouseover: function(e) {
				var obj;
				if (e == null) { obj = window.event.toElement; }
				else { obj = e.target; }
				var i = eval(obj.id.substring(obj.id.lastIndexOf("_")+1));
				obj.src = "/resim/dugme/dugme_" + (i+1) + "_hover.gif";
				if (this.timer != null)  { clearInterval(this.timer);}
			},
			onmouseout: function(e) {
				var obj;
				if (e == null) { obj = window.event.fromElement; }
				else { obj = e.target; }
				var i = eval(obj.id.substring(obj.id.lastIndexOf("_")+1));
				var y = eval(this.pos);
				if (y-1 <0) { y = this.array.length-1; }
				else { y = y - 1; }
				if (y == i) { obj.src = "/resim/dugme/dugme_" + (i+1) + "_hover.gif"; }
				else { obj.src = "/resim/dugme/dugme_" + (i+1) + ".gif"; }
				this.timer = setInterval(this.onnext.bind(this), this.timerInterval);
			},
			onmainmouseover: function(e) {
				if (this.timer != null)  { clearInterval(this.timer);}
			},
			onmainmouseout: function(e) {
				this.timer = setInterval(this.onnext.bind(this), this.timerInterval);
			},
			onclick: function(e) {
				var obj;
				var i = 0;
				if (e == null) { obj = window.event.srcElement; }
				else { obj = e.target; }

				i = obj.id.substring(obj.id.lastIndexOf("_")+1);
				this.show(eval(i));				
			},
			initialize: function(objId, pager, a, classname, interval, w, h) {
				this.array = a;
				//this.pager = pager;
				this.classname = classname;
				this.timerInterval = interval;
				this.ele = $(objId);
				this.ele.innerHTML = "";

				this.curpos = w;
				this.w = w;
				
				this.ele.innerHTML = '<div style="position:relative;width:'+w+'px;height:'+h+'px;overflow:hidden"><div id="'+objId+'_div1" style="position:absolute;background-color:#EAEFF4;width:'+w+'px;height:'+h+'px;left:'+w+'px;filter:alpha(opacity=40);-moz-opacity:0.4;"></div><div id="'+objId+'_div2" style="position:absolute;background-color:#EAEFF4;width:'+w+'px;height:'+h+'px;left:'+w+'px;filter:alpha(opacity=40);-moz-opacity:0.4;"></div></div>';

				var i = 0;
				this.pager = document.createElement("div");
				
				this.pager.id = objId + "_pager";
				this.pager.style.width = w+"px";
				this.pager.style.height = "22px";
				this.pager.style.position = "absolute";
				this.pager.style.overflow = "hidden";
				document.body.appendChild(this.pager);
		
				var r = MS.Position.getLocation(this.ele);
				r.left += 10;
				r.top += h-25;
				MS.Position.setLocation(this.pager, r);

				var tablePager = document.createElement("table");
				var tbodyPaper = document.createElement("tbody");				
				
				var trPager = document.createElement("tr");
				for (i = 0; i < a.length ; i++)
				{
					var tdPager = document.createElement("td");
					var tdImg = document.createElement("img");

					tdPager.id = this.pager.id + "_td_" + i;
					tdImg.id = this.pager.id + "_img_" + i;
					tdImg.src = "/resim/dugme/dugme_" + i + ".gif" 
					//tdPager.innerHTML = (i+1);
					//tdPager.className = this.classname;
					tdImg.onmouseover = this.onmouseover.bind(this);
					tdImg.onmouseout = this.onmouseout.bind(this);
					tdImg.onclick = this.onclick.bind(this);
					tdPager.appendChild(tdImg);
					trPager.appendChild(tdPager);
				}

				tbodyPaper.appendChild(trPager);
				tablePager.appendChild(tbodyPaper);
				this.pager.appendChild(tablePager);

				this.state = this.ele.id + "_div1";

				addEvent(this.ele, "mouseover", this.onmainmouseover.bind(this));
				addEvent(this.ele, "mouseout", this.onmainmouseout.bind(this));
					
				this.onnext();
				this.timer = setInterval(this.onnext.bind(this), this.timerInterval);

			}
		}, false);