function GDPage(objName,pageCount,pageSpeed,isScroll,scrollH){
    this.currObjName=objName;
    this.gdMaxPage=pageCount;
    this.speed=pageSpeed;
    this.isScroll=isScroll;
    this.scrollH=scrollH;
}
GDPage.prototype={
    currObjName:null,
    perPageId:0,
    gdMaxPage:0,
    speed:3000,
    gdTimer:null,
    scrollTimer:null,
    isScroll:false,
    scrollH:0,
    //显示当前页，isGD为true时则一段时间后自动翻向下一页，有触发按钮时则改变按钮的样式
	ShowPage:function(id,isGD){
	    if(id<0 || this.gdMaxPage<1 || id>=this.gdMaxPage)
	        return;
        var tri=null;   
        if(this.perPageId>-1){
            tri=document.getElementById(this.currObjName+"Trigger"+this.perPageId);
            if(tri)
                tri.className="";
            if(!this.isScroll)
                document.getElementById(this.currObjName+this.perPageId).style.display="none";
        }
        if(!this.isScroll)
            document.getElementById(this.currObjName+id).style.display="block";
        tri=document.getElementById(this.currObjName+"Trigger"+id);
        if(tri)
            tri.className="Current";
        if(this.isScroll)
            this.PageScroll(this.perPageId,id,this.scrollH,(window.ActiveXObject ? 1 : 1));
        this.perPageId=id;
        this.ResumePage(isGD,this.speed);
	},
	//每隔一段时间连续向下翻页
	TurnPage:function(){
	    this.ShowPage(0,true);
	},
	//是否自动翻向下一页
	ResumePage:function(isGD,customSpeed){
		this.StopAutoPage();
		if(isGD){
            var id=this.perPageId;
            id++;
            if(id>=this.gdMaxPage)
                id=0;
		    this.gdTimer=setTimeout(this.currObjName+".ShowPage("+id+",true)", customSpeed);
		}
	},
	//停止自动翻页
	StopAutoPage:function(){
		  if(this.gdTimer)
            clearTimeout(this.gdTimer);
	},
	//向上翻一页
	PerPage:function(isGD){
	    if(this.gdMaxPage<1)
	        return;
	    var currId=this.perPageId-1;
	    if(currId<0)
	        currId=this.gdMaxPage-1;
	    this.ShowPage(currId,isGD);
	},
	//向下翻一页
	NextPage:function(isGD){
	    if(this.gdMaxPage<1)
	        return;
	    var currId=this.perPageId+1;
	    if(currId>=this.gdMaxPage)
	        currId=0;
	    this.ShowPage(currId,isGD);
	},
	//减速效果
	PageScroll:function(perId,currId,h,s){
		if(this.scrollTimer)
		    window.clearInterval(this.scrollTimer);
		s=Math.abs(perId-currId)*s;
		var ul=document.getElementById(this.currObjName+currId).parentNode;
		if(ul.style.top=="")
		    ul.style.top="0px";
		var cTop=parseInt(ul.style.top.replace("px",""));
		var toTop=0-currId*h;
		if(cTop>toTop)
		s=0-s;
		var index=18;
		var reSet = function(){
				if(cTop != toTop){
					cTop = Math.ceil(cTop+s*index);
					if((s<0 && (cTop<toTop)) || (s>0 && (cTop>toTop)))
                		cTop=toTop;
					ul.style.top = cTop+"px";
					if(index>1)
					index--;
				}else
					window.clearInterval(this.scrollTimer);
		}
		this.scrollTimer = window.setInterval(reSet,10);
  }
}