function ufoAD()
{
this.obj=null,
this.scrollobj=null,
this.height=0,
this.width=0,
this.childNum=0,
this.pageObj=null,
this.currentIndex=1,
this.setting=null,
this.timer=0,
this.timer1=0
this.init=function(setting)  //³υΚΌ»―
{
    window["Cache-ufoAD-"+setting.id] = this;
    this.setting = setting;
    this.obj = document.getElementById(setting.id);
    this.scrollobj = document.getElementById("scroll-" + setting.id);
	this.height = this.obj.offsetHeight;
	this.width = this.obj.offsetWidth;
	this.childNum = parseInt(this.scrollobj.scrollHeight / this.height);
	if(this.scrollobj.scrollHeight>this.height*this.childNum+10)this.childNum++;
	this.pageObj = document.getElementById("page-" + setting.id);
	var html='';
    for(var i=1;i<=this.childNum;i++)
    {
        html += '<a href="javascript:void(0);">' + i + '</a>';
    }
    this.pageObj.innerHTML = html;
    var o = this.pageObj.getElementsByTagName("A");
    var cacheObj = this;
    for(var i=0;i<o.length;i++)
    {
        o[i].setAttribute("rel","Cache-ufoAD-"+setting.id);
        o[i].setAttribute("page",i);
        o[i]["on"+setting.revealtype]=function(){window[this.getAttribute("rel")].rotate(parseInt(this.getAttribute("page"))+1);};
    }
	this.setpage(1);
	if(setting.autorotate[0])
	    this.timer=setTimeout(function(){window["Cache-ufoAD-"+setting.id].rotate()}, setting.autorotate[1]);
},
this.rotate=function(cIndex)  //ΗΠ»»
{
	clearTimeout(this.timer1);
	if(typeof cIndex != "undefined")
		this.MoveTo(cIndex-1);
	else
		this.MoveTo(this.currentIndex>=this.childNum?0:this.currentIndex);

    if(typeof cIndex!='undefined'){this.currentIndex=cIndex-1;clearTimeout(this.timer);}
    var o = window["Cache-ufoAD-"+this.setting.id];
	this.currentIndex=this.currentIndex>=this.childNum?1:++this.currentIndex;
	this.setpage(this.currentIndex);
	if(this.setting.autorotate[0])
	    this.timer=setTimeout(function(){o.rotate()}, this.setting.autorotate[1]);
},
this.MoveTo=function(cIndex)
{
	var currentHeight = this.scrollobj.scrollTop;
	var targetHeight = cIndex * this.height;
	if(currentHeight<targetHeight)
		this.scrollobj.scrollTop = Math.ceil(targetHeight - (targetHeight - currentHeight) / 1.2);
	else
		this.scrollobj.scrollTop = Math.floor(targetHeight + (currentHeight - targetHeight) / 1.1);
	var o = window["Cache-ufoAD-"+this.setting.id];
	if(this.scrollobj.scrollTop % this.height!=0)
		this.timer1=setTimeout(function(){o.MoveTo(cIndex)}, 10);
},
this.setpage=function(index)
{
    
    var o = this.pageObj.getElementsByTagName("A");
    for(var i=0;i<o.length;i++)
    {
        o[i].className="";
    }
    o[index-1].className="on";
}
};