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);
  }
}

//通栏变换图片
function slideLine(ul, delay, speed, lh) {
var slideBox = (typeof ul == 'string')?document.getElementById(ul):ul;
var delay = delay||1000, speed=speed||20, lh = lh||20;
var tid = null, pause = false;
var start = function() {
tid=setInterval(slide, speed);
}
var slide = function() {
if (pause) return;
slideBox.scrollTop += 2;
if (slideBox.scrollTop % lh == 0) {
clearInterval(tid);
slideBox.appendChild(slideBox.getElementsByTagName('li')[0]);
slideBox.scrollTop = 0;
setTimeout(start, delay);
}
}
slideBox.onmouseover=function(){pause=true;}
slideBox.onmouseout=function(){pause=false;}
setTimeout(start, delay);
}

//新闻切换
function tab_Change(currentnum,tab,content,fleet,deep,sum){
	for(var i=1;i<=sum;i++){document.getElementById(content+i).style.display="none";}
	for(var i=1;i<=sum;i++){document.getElementById(tab+i).className=fleet;}
	document.getElementById(tab+currentnum).className=deep;
	document.getElementById(content+currentnum).style.display="block";
}
//地区切换
function areaChange(currentnum,area,sum){
	for(var i=1;i<=sum;i++){
		document.getElementById(area+i).style.display="none";
		}
	document.getElementById(area+currentnum).style.display="block";
}
//横向滚动
function HGD(Top20View, Top20View1, Top20View2,speed)
{ 
	 var Top20Viewspeed=speed;
	 var Top20View2 = document.getElementById(Top20View2);
	 var Top20View1 = document.getElementById(Top20View1);
	 var Top20View = document.getElementById(Top20View);
     Top20View2.innerHTML=Top20View1.innerHTML;
     function Top20ViewMarquee(){
     if(Top20View2.offsetWidth-Top20View.scrollLeft<=0)
     Top20View.scrollLeft-=Top20View1.offsetWidth;
     else{
     Top20View.scrollLeft++;
     }
     }
     var Top20ViewMar=setInterval(Top20ViewMarquee,Top20Viewspeed);
     Top20View.onmouseover=function() {clearInterval(Top20ViewMar);};
     Top20View.onmouseout=function() {Top20ViewMar=setInterval(Top20ViewMarquee,Top20Viewspeed);};
}
//纵向滚动
function VGD(Top20View, Top20View1, Top20View2,speed)
{ 
	 var Top20Viewspeed=speed;
	 var Top20View2 = document.getElementById(Top20View2);
	 var Top20View1 = document.getElementById(Top20View1);
	 var Top20View = document.getElementById(Top20View);
     Top20View2.innerHTML=Top20View1.innerHTML;
     function Top20ViewMarquee(){
     if(Top20View2.offsetHeight-Top20View.scrollTop<=0)
     Top20View.scrollTop-=Top20View1.offsetHeight;
     else{
     Top20View.scrollTop++;
     }
     }
     var Top20ViewMar=setInterval(Top20ViewMarquee,Top20Viewspeed);
     Top20View.onmouseover=function() {clearInterval(Top20ViewMar);};
     Top20View.onmouseout=function() {Top20ViewMar=setInterval(Top20ViewMarquee,Top20Viewspeed);};
}

//新闻自动切换
function auto_Change(area,tab,content,fleet,deep,sum,speed){
	var currentnum = 1;
	var Area = document.getElementById(area);
	function change(){
		for(var i=1; i<=3; i++){document.getElementById(content+i).style.display="none";}
		for(var i=1; i<=3; i++){document.getElementById(tab+i).className=fleet;}
		if(currentnum == 3){currentnum = 1}
		else{currentnum += 1;}
		document.getElementById(tab+currentnum).className =deep;
		document.getElementById(content+currentnum).style.display="block";
	}
	var autoScroll = setInterval(change,speed);
	Area.onmouseover = function(){clearInterval(autoScroll);};
	Area.onmouseout = function(){autoScroll = setInterval(change,speed);}	;
}
