/*==================================顶部导航=========================================*/

function TopicTopMenu(key,index)
{
	
	this.indexId=index;
	this.key=key;
	var mainmenu=document.getElementById("mainmenu");
	var mainlist=mainmenu.getElementsByTagName("li");
	var submenu=document.getElementById("submenu");
	var sublist=submenu.getElementsByTagName("ul");
    var projectData=[
    {key:'内科',data:
        ['10000125','10000126','10000127','10000129','10000130','10000131'
        ] 
    },
    {key:'外科',data:
        ['10000005','10000010','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ] 
    },
   {key:'妇科',data:
        ['10000050','10000051','10000054','10000057','10000060','10000069',
                  '10000085','10000065','10000089','10000092','10000093'
        ] 
    },
   {key:'产科',data:
        ['10063149','10063182','10063161','10000212','10000210','10000209'
        ] 
    },
   {key:'儿科',data:
        ['10000217','10000216','10000215','10000214','10000213'
        ] 
    },
   {key:'中医科',data:
        ['10000213','10000214','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ] 
    },
   {key:'五官科',data:
        ['10000226','10000227','10063452','10063453','10063454'
        ] 
    },
   {key:'泌尿外科',data:
        ['10000179','10000182','10000117','10000116','10000115','10000188',
                  '10000185'
        ] 
    },
    {key:'男科',data:
        ['10000122','10000121','10000119','10000118','10000200','10000201'
        ] 
    }, 
   {key:'健康管理',data:
        ['10000005','10000010','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ] 
    },
   {key:'中医康复',data:
        ['10000005','10000010','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ] 
    },
   {key:'血液净化',data:
        ['10000005','10000010','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ] 
    },
   {key:'急诊科',data:
        ['10000005','10000010','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ] 
    },
   {key:'口腔科',data:
        ['10000005','10000010','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ] 
    },
   {key:'手外科',data:
        ['10000005','10000010','10000013','10000017','10000020','10000023',
                  '10000026','10000027','10000032','10000033','10000034','10000035' 
        ]
   },
       { key:'糖尿病诊疗中心',data:
        ['10063549','10063551','10063552'
        ]
       }          
    ];

	for(var i=0;i<mainlist.length;i++)
	{
		    mainlist[i].index=i;
			mainlist[i].onmouseover=function()
			{
				for(var j=0;j<mainlist.length;j++)
				{
						mainlist[j].className='';
				}
				for(var k=0;k<sublist.length;k++)
				{
						sublist[k].className='';
				}
				sublist[this.index].className='cur';
				this.className='cur';
			}
		
	}
	var active=function()
	{
		           
		for(var i=0;i<mainlist.length;i++)
		{	
			mainlist[i].className='';
			sublist[i].className='';
		}
		if(key=='首页')
		{
		            sublist[this.indexId].className='cur';
		            mainlist[this.indexId].className='cur';
		}
		else
		{
		    for(var i=0,len=projectData.length;i<len;i++)
		    {
		        if(projectData[i].key==this.key)
		       {
		             for(var j=0,jlen=projectData[i].data.length;j<jlen;j++)
		             {
		                 if(projectData[i].data[j]==this.indexId.toString())
		                 { 
		                    sublist[j].className='cur';
		                    mainlist[j].className='cur';
		                    return;
		                 }      
		           }  
		      }  
		  }  
        }
	}
	if(this.indexId!=null&&this.indexId>=0)
		active();
}
/*===================================================================================*/


/*==================================在线预约=========================================*/
function initBooking()
{
	var yearObj=document.getElementById('Year');
	var monthObj=document.getElementById('Month');
	var dayObj=document.getElementById('Day');
	var time=new Date();
	var year=time.getYear();
	var month=time.getMonth();
	var day=time.getDate();
	if(yearObj)
	{
		yearObj.options.length=0;
		for(var y=year;y<year+5;y++)
		{
			var oOption =new Option(y,y);
			yearObj.options[yearObj.length]=oOption;
		}
	}
	if(monthObj)
	{
		for(var m=1;m<=12;m++)
		{
			var oOption =new Option(m,m);
			monthObj.options[monthObj.length]=oOption;
		}
	    if(month)
	    {
		    monthObj.selectedIndex=month;
	    }

	}
	if(dayObj)
	{
		for(var d=1;d<=31;d++)
		{
			var oOption =new Option(d,d);
			dayObj.options[dayObj.length]=oOption;
		}
	    if(day)
		    dayObj.selectedIndex=day-1;
	}
	var department=document.getElementById('Department');
	if(department)
	{
		department.length=0;
		department.options[department.length] = new Option('选择科室', '');
		department.options[department.length] = new Option('泌尿外科', '泌尿外科');
		department.options[department.length]=new Option('妇产科','妇产科');
		department.options[department.length]=new Option('外科','外科');
		department.options[department.length]=new Option('内科','内科');
		department.options[department.length]=new Option('中医科','中医科');
		department.options[department.length]=new Option('男科','男科');
		department.options[department.length]=new Option('儿科','儿科');
		department.options[department.length]=new Option('五官科','五官科');
		department.options[department.length]=new Option('急诊科','急诊科');
		department.options[department.length] = new Option('健康管理中心', '健康管理中心');
		department.options[department.length] = new Option('消化肝病中心', '消化肝病中心');
		department.options[department.length] = new Option('糖尿病诊疗中心', '糖尿病诊疗中心');
		department.options[department.length] = new Option('口腔科', '口腔科');
		department.options[department.length]=new Option('中医康复','中医康复');
		department.options[department.length]=new Option('血透中心','血透中心');
		department.options[department.length]=new Option('体检科','体检科');//这个首页上面科室没有
	}
	var hour=document.getElementById('Hour');
	if(hour)
	{
		hour.length=0;
		hour.options[hour.length]=new Option('==选择时段==','');
		hour.options[hour.length]=new Option('8:30-10:00','8:30-10:00');
		hour.options[hour.length]=new Option('10:00-12:00','10:00-12:00');
		hour.options[hour.length]=new Option('12:00-14:00','12:00-14:00');
		hour.options[hour.length]=new Option('14:00-17:00','14:00-17:00');
		hour.options[hour.length]=new Option('17:00-21:00','17:00-21:00');
	}
	var message=document.getElementById('message1');
	if(message)
	{
		message.value='若需要网上定券，请写上“网上定券”。若需要其他帮助，也请留言。';
		message.onblur=function()
		{
			if (this.value =='')
			{
				this.value='若需要网上定券，请写上“网上定券”。若需要其他帮助，也请留言。';
			}
		}
		message.onmouseover=function()
		{
			this.focus()
		}
		message.onfocus=function()
		{
			this.select();
		}
		message.onclick=function()
		{

			if(this.value=='若需要网上定券，请写上“网上定券”。若需要其他帮助，也请留言。') this.value=''
		}
	}
	var message=document.getElementById('message');
	if(message)
	{
		message.value='若需要指定就诊医生，请写上医生姓名。若需要其他帮助，也请留言。';
		message.onblur=function()
		{
			if (this.value =='')
			{
				this.value='若需要指定就诊医生，请写上医生姓名。若需要其他帮助，也请留言。';
			}
		}
		message.onmouseover=function()
		{
			this.focus()
		}
		message.onfocus=function()
		{
			this.select();
		}
		message.onclick=function()
		{

			if(this.value=='若需要指定就诊医生，请写上医生姓名。若需要其他帮助，也请留言。') this.value=''
		}
	}
	var btnBooking=document.getElementById('btnBooking');
	if(btnBooking)
	{
		btnBooking.onclick=function()
		{
			bookingSubmit();
		}
	}
	var btnBookingReset=document.getElementById('btnBookingReset');
	if(btnBookingReset)
	{
		btnBookingReset.onclick=function()
		{
			return bookingReset();
		}
	}

}
function bookingReset()
{
	document.forms["frmbooking"].reset();
}
function bookingSubmit()
{
	var frm=document.forms["frmbooking"];
	
	if(document.getElementById("username").value=="")
	{
		alert("请输入您的姓名！");
		document.getElementById("username").focus();
		return false;
	}
	if(document.getElementById("tel").value=="")
	{
		alert("请输入您联系电话，固话格式：02785761888 手机格式：137*****123！");
		document.getElementById("tel").focus();
		return false;
	}
   var msg=document.getElementById("message"); 
	if(msg.value=="")
	{
		alert("请输入您的预约信息！");
		msg.focus();
		return false;
	}
	if(msg.value=="若需要指定就诊医生，请写上医生姓名。若需要其他帮助，也请留言。")
	{
		alert("请输入您的预约信息！");
		msg.focus();
		return false;
	}        
   frm.submit();
	return true;
} 

/*===========================================================================*/
/*===========================================================================*/
function picChange(n)
{
	for(var i=0;i<4;i++)
	{
		var expert_uldata=	document.getElementById('expert_uldata'+(i+1).toString());
		var experts_item=document.getElementById('experts_item'+(i+1).toString());
		if((i+1)==n)
		{
			expert_uldata.className='show';
			experts_item.className='experts_t_bg1';
		}
		else
		{
			expert_uldata.className='hide';
			experts_item.className='experts_t_bg2';
		}
	}
}

/*口腔科新首页begin*/
function KQKpicChange(n)
{
	for(var i=0;i<5;i++)
	{
		var expert_uldata=	document.getElementById('expert_uldata'+(i+1).toString());
		var experts_item=document.getElementById('experts_item'+(i+1).toString());
		if((i+1)==n)
		{
			expert_uldata.className='show';
			experts_item.className='guai_center_r_2';
		}
		else
		{
			expert_uldata.className='hide';
			experts_item.className='guai_center_r_3';
		}
	}
}
/*口腔科新首页end*/

function gloryChange(n,glink)
{
	for(var i=0;i<2;i++)
	{
		var glory=document.getElementById('glory'+(i+1).toString());
		var glorylink=document.getElementById('glorylink');
		if(glorylink!=null&&glink!='')
		{
			glorylink.href=glink;
		}
		if((i+1)==n)
		{
			glory.className='show';
		}
		else
		{
			glory.className='hide';
		}
	}
}


/*===========================================================================*/

/*==================================搜索=========================================*/

function searchSubmit()
  {
  	var k=document.getElementById('wd');
	if(k.value=='')
	{
		alert('请填写您要搜索的关键字!');
		k.focus();
		return false;
	}
	document.getElementById('frmsearch').submit();
	return true;
  }
  function searchReset()
  {
	document.getElementById('frmsearch').reset();
  }
/*===================================================================================*/


/*==================================搜索=========================================*/

function searchSubmit2()
  {
  	var k=document.getElementById('wd2');
	if(k.value=='')
	{
		alert('请填写您要搜索的关键字!');
		k.focus();
		return false;
	}
	document.getElementById('frmsearch2').submit();
	return true;
  }
  function searchReset2()
  {
	document.getElementById('frmsearch2').reset();
  }
/*===================================================================================*/



/*==================================医生知道=========================================*/

  function initDoctorKnow()
  {
	  var title=document.getElementById('title');
	  var content=document.getElementById('content');
	  if(title)
	  {
		var t='请输入您的问题标题/关键字!';
	    title.value=t;
		title.onblur=function()
		{
			if (this.value =='')
			{
				this.value=t;
			}
		}
		title.onmouseover=function()
		{
			this.focus()
		}
		title.onfocus=function()
		{
			this.select();
		}
		title.onclick=function()
		{

			if(this.value==t) this.value=''
		}
	  }
	  if(content)
	  {
		var c='请提出您的问题,点击搜索答案!如果没有您满意的答案,请点击我要提问!';
	    content.value=c;
		content.onblur=function()
		{
			if (this.value =='')
			{
				this.value=c;
			}
		}
		content.onmouseover=function()
		{
			this.focus()
		}
		content.onfocus=function()
		{
			this.select();
		}
		content.onclick=function()
		{

			if(this.value==c) this.value=''
		}
	  }
	  var btndkSubmit=document.getElementById('btndkSubmit');
	  if(btndkSubmit)
	  {
		  btndkSubmit.onclick=function()
		  {
			  doctorKnowSubmit();
		  }
	  }
  }
  function doctorKnowSubmit()
  {
  	var title=document.getElementById('title');
	if(title.value=='请输入您的问题标题/关键字!'||title.value=='')
	{
		alert('请输入您的问题标题!');
		title.focus();
		return false;
	}
	if(title.value.length>20)
	{
		alert("标题长度只能20个字内!");
		return false;
	}
  	var q=document.getElementById('content');
	if(q.value=='请提出您的问题,点击搜索答案!如果没有您满意的答案,请点击我要提问!'||q.value=='')
	{
		alert('请填写您要提问的内容!');
		q.focus();
		return false;
	}
	if(q.value.length>200)
	{
		alert("提问内容长度只能200个字内!");
		return false;
	}

	document.getElementById('frmdoctorknow').submit();
	return true;
  }
function doctorKnowReset()
{
    	document.getElementById('frmdoctorknow').reset();
}
/*===================================================================================*/

function newsTab(n)
{
	for(var i=0;i<3;i++)
	{
		var uldata=	document.getElementById('uldata'+(i+1).toString());
		var tabitem=document.getElementById('tabitem'+(i+1).toString());
		if((i+1)==n)
		{
			uldata.className='show';
			tabitem.className='curitem';
		}
		else
		{
			uldata.className='hide';
			tabitem.className='item';
		}
	}
}
function searchTab(n)
{
	for(var i=0;i<4;i++)
	{
		var tabitem=document.getElementById('srch'+(i+1).toString());
		if((i+1)==n)
		{
			tabitem.className='curitem';
		}
		else
		{
			tabitem.className='item cursor';
		}
	}
}
/*=============================TabTag===================================*/
function TabTag()
{
	this.tabID;
	this.contentID;
	this.curTabIndex=0;
	this.curTabClassName;
	this.tabClassName;
	this.curContentClassName='show';
	this.contentClassName='hide';
	this.tabTag='li';
	this.contentTag='div';
	this.tabevent='click';
}
TabTag.prototype.Start=function(showIndex)
{
	if(showIndex!=null&&showIndex>=0)
		this.curTabIndex=showIndex;
	if(this.tabID)
	{
		var tabObj=document.getElementById(this.tabID);
		if(this.contentID)
		{
			var contentObj=document.getElementById(this.contentID);
		}
		
		var tabs=tabObj.getElementsByTagName(this.tabTag);
		var tem=contentObj.childNodes;
		var contents=tem;
		for(var i=0;i<tabs.length;i++)
		{
			tabs[i].index=i;			

		}
		var context=this;
		for(var i=0;i<tabs.length;i++)
		{
			if(this.tabevent=='click')
			{	
				tabs[i].onclick=function()
				{
					for(var j=0;j<tabs.length;j++)
					{
						contents[j].className=context.contentClassName;
						tabs[j].className=context.tabClassName;
					}
						contents[this.index].className=context.curContentClassName;
						tabs[this.index].className=context.curTabClassName;
				}
			}
			if(this.tabevent=='mouse')
			{
				tabs[i].onmouseover=function()
				{
					for(var j=0;j<tabs.length;j++)
					{
						contents[j].className=context.contentClassName;
						tabs[j].className=context.tabClassName;
					}
						contents[this.index].className=context.curContentClassName;
						tabs[this.index].className=context.curTabClassName;
				}
			}
		}
		for(var j=0;j<tabs.length;j++)
		{
			contents[j].className=context.contentClassName;
			tabs[j].className=context.tabClassName;
		}
			contents[this.curTabIndex].className=context.curContentClassName;
			tabs[this.curTabIndex].className=context.curTabClassName;
	}
}
/*====================================================================*/
/*===========================ScrollBar=====================================*/

var pos='left';
function initScrollBar()
{
    
     var tongdao = document.getElementById("tongdao"); 
     var toptel=document.getElementById("toptel");
     if(document.body.scrollWidth>980)
     {
	     if(window.screen.width==1280)
	     {
		     tongdao.style[pos]="136px";
		     toptel.style[pos]="136px";
    		 
	     }
	     else if(window.screen.width==1400)
	     {
		         tongdao.style[pos]="199px";
		         toptel.style[pos]="199px";
	     } 
	    else if(window.screen.width==1440)
	     {
		         tongdao.style[pos]="219px";
		         toptel.style[pos]="219px";
	     }  
	    else if(window.screen.width==1680)
	     {
		         tongdao.style[pos]="339px";
		         toptel.style[pos]="339px";
	     }  
	     else
	     {
		     tongdao.style[pos]="11px";
		     toptel.style[pos]="11px";
	     }
     }
     else
     {
		     tongdao.style[pos]="0px";
		     toptel.style[pos]="0px";
     }
}
function scrollBar(p,isInit)
{
 pos=p;
 if(isInit==null) 
    initScrollBar();
 var tongdao = document.getElementById("tongdao");  
     var toptel=document.getElementById("toptel");
 
 tongdao.style.top =document.documentElement.scrollTop+toptel.clientHeight+100+"px"; 
 setTimeout(function(){scrollBar();},50); 
}
function fixupBar(p,isInit)
{
 pos=p;
 if(isInit==null) 
    initScrollBar();
}
function chickIt()
{
        var detect = navigator.userAgent.toLowerCase();
	    return detect.indexOf('msie') + 1;
}
/*=========================================================================*/
/*===========================FocusImage=====================================*/

function FocusImage()
{
	this.showImageIndex = -1;
	this.imageTimer;
	this.imgcontainerid='flash_img';
	this.titlecontainerid='flash_title';
	this.msgcontainerid='flash_show_ctl_msg';
	this.btncontainerid='flash_btn';
//	this.isShowLink=true;
//	this.linkTarget="_blank";
	this.imgs;
	this.time=7000;
	this.imgWidth;
	this.imgHeight;
	var flash_img_div = document.getElementById(this.imgcontainerid);
	var flash_title = document.getElementById(this.titlecontainerid);	
	var flash_msg= document.getElementById(this.msgcontainerid);	
	var flash_btns=document.getElementById('flash_btn');
	var btns=flash_btns.getElementsByTagName("span");
	this.init=function()
	{
	    flash_img_div.style.filter='progid:DXImageTransform.Microsoft.Fade(Overlap=1.00);';
	    flash_msg.style.filter='progid:DXImageTransform.Microsoft.Fade(Overlap=1.00); ';

	    for(var i=0;i<this.imgs.length;i++)
	    {
	        var img = new Image();
		    img.border = "0";
		    img.src = this.imgs[i].img;
		    if(this.imgWidth)
			    img.width=this.imgWidth;
		    if(this.imgHeight)
			    img.height=this.imgHeight;
			if(this.imgs[i].href!="")
			{
		        var a = document.createElement("a");
		        a.href = this.imgs[i].href;
		            a.target = "_blank";
			    if(this.imgs[i].tip)
			    {
			        img.alt=this.imgs[i].tip;
		            a.title=this.imgs[i].tip;
		        } 
		        a.appendChild(img);
		        flash_img_div.appendChild(a);
		    }
		    else
		    {
		        flash_img_div.appendChild(img);
		    } 
		    
		}
		var context=this;
        for(var i=0;i<btns.length;i++)
        {
                btns[i].index=i;
        }
        for(var i=0;i<btns.length;i++)
        {
            btns[i].onclick=function()
            {
                context.showImage(this.index);return false;
            }
        }
	}
	this.showImage=function(imageIndex)
	{
		if(!this.exist())
			return;
		if(imageIndex>this.imgs.length-1)
			imageIndex = 0;
		if(!this.imgs[imageIndex] || imageIndex==this.showImageIndex)
			return false;	
		flash_img_div.filters && flash_img_div.filters[0].Apply();
		for(i=0; i<flash_img_div.childNodes.length; i++){
			flash_img_div.childNodes[i].style.display = "none";
		}
		flash_img_div.childNodes[imageIndex].style.display='';
		if(btns)
		{
			for(i=0;i<btns.length;i++)
				btns[i].className='';
			btns[imageIndex].className='cur';
		}
		
		flash_img_div.filters && flash_img_div.filters[0].Play();
		var flash_show_ctl_msg = document.getElementById(this.msgcontainerid);
		flash_show_ctl_msg.filters && flash_show_ctl_msg.filters[0].Apply();
		if(fImgs[imageIndex].href!="")
		{
		    flash_title.href = fImgs[imageIndex].href;
		    flash_title.target = "_blank";
		}
		flash_title.innerHTML = fImgs[imageIndex].title;
		flash_show_ctl_msg.filters && flash_show_ctl_msg.filters[0].Play();
		this.showImageIndex = imageIndex;
		return true;
	}
	this.exist=function()
	{
		if(!this.imgs)
		{
			flash_title.style.display='none';
			flash_btns.style.display='none';
			flash_img_div.innerHTML='没有焦点图片新闻';
			this.imageTimer=null;
			return false;
		}
		return true;
	}
	this.imagePlay=function ()
	{
		if(!this.exist())
			return;
		if(this.imageTimer) return;
		if(this.showImageIndex>=this.imgs.length-1)
			showImageIndex = -1;
		this.showImage(this.showImageIndex+1);
		var context=this;
		this.imageTimer = setInterval(function(){
						var stat = context.showImage(context.showImageIndex+1);
						if(!stat){
							context.imageStop();
						}	
					},context.time);
		}
	this.imageStop=function(){
		clearInterval(this.imageTimer);
		this.imageTimer = null;
	}
	this.nextImage=function(){
		this.showImage(this.showImageIndex+1);
	}
	this.prevImage=function(){
		this.showImage(this.showImageIndex-1);
	}
}
/*=========================================================================*/

/*==============================Marquee=====================================*/

function Marquee()
{
	this.ID = document.getElementById(arguments[0]);
	if(!this.ID)
	{
		alert("您要设置的\"" + arguments[0] + "\"初始化错误\r\n请检查标签ID设置是否正确!");
		this.ID = -1;
		return;
	}
	this.Direction = this.Width = this.Height = this.DelayTime = this.WaitTime = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
	this.Step = 1;
	this.Timer = 30;
	this.DirectionArray = {"top":0 , "up":0 , "bottom":1 , "down":1 , "left":2 , "right":3};
	if(typeof arguments[1] == "number" || typeof arguments[1] == "string")this.Direction = arguments[1];
	if(typeof arguments[2] == "number")this.Step = arguments[2];
	if(typeof arguments[3] == "number")this.Width = arguments[3];
	if(typeof arguments[4] == "number")this.Height = arguments[4];
	if(typeof arguments[5] == "number")this.Timer = arguments[5];
	if(typeof arguments[6] == "number")this.DelayTime = arguments[6];
	if(typeof arguments[7] == "number")this.WaitTime = arguments[7];
	if(typeof arguments[8] == "number")this.ScrollStep = arguments[8];
	this.ID.style.overflow = this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
	this.ID.noWrap = true;
	this.IsNotOpera = (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
	if(arguments.length >= 7)this.Start();
}

Marquee.prototype.Start = function()
{
	if(this.ID == -1)return;
	if(this.WaitTime < 800)this.WaitTime = 800;
	if(this.Timer < 20)this.Timer = 20;
	if(this.Width == 0)this.Width = parseInt(this.ID.style.width);
	if(this.Height == 0)this.Height = parseInt(this.ID.style.height);
	if(typeof this.Direction == "string")this.Direction = this.DirectionArray[this.Direction.toString().toLowerCase()];
	this.HalfWidth = Math.round(this.Width / 2);
	this.HalfHeight = Math.round(this.Height / 2);
	this.BakStep = this.Step;
	this.ID.style.width = this.Width + "px";
	this.ID.style.height = this.Height + "px";
	if(typeof this.ScrollStep != "number")this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
	var templateLeft = "<table cellspacing='0' cellpadding='0' style='border-collapse:collapse;display:inline;'><tr><td noWrap=true style='white-space: nowrap;word-break:keep-all;'>MSCLASS_TEMP_HTML</td><td noWrap=true style='white-space: nowrap;word-break:keep-all;'>MSCLASS_TEMP_HTML</td></tr></table>";
	var templateTop = "<table cellspacing='0' cellpadding='0' style='border-collapse:collapse;'><tr><td>MSCLASS_TEMP_HTML</td></tr><tr><td>MSCLASS_TEMP_HTML</td></tr></table>";
	var msobj = this;
	msobj.tempHTML = msobj.ID.innerHTML;
	if(msobj.Direction <= 1)
	{
		msobj.ID.innerHTML = templateTop.replace(/MSCLASS_TEMP_HTML/g,msobj.ID.innerHTML);
	}
	else
	{
		if(msobj.ScrollStep == 0 && msobj.DelayTime == 0)
		{
			msobj.ID.innerHTML += msobj.ID.innerHTML;
		}
		else
		{
			msobj.ID.innerHTML = templateLeft.replace(/MSCLASS_TEMP_HTML/g,msobj.ID.innerHTML);
		}
	}
	var timer = this.Timer;
	var delaytime = this.DelayTime;
	var waittime = this.WaitTime;
	msobj.StartID = function(){msobj.Scroll()}
	msobj.Continue = function()
				{
					if(msobj.MouseOver == 1)
					{
						setTimeout(msobj.Continue,delaytime);
					}
					else
					{	clearInterval(msobj.TimerID);
						msobj.CTL = msobj.Stop = 0;
						msobj.TimerID = setInterval(msobj.StartID,timer);
					}
				}

	msobj.Pause = function()
			{
				msobj.Stop = 1;
				clearInterval(msobj.TimerID);
				setTimeout(msobj.Continue,delaytime);
			}

	msobj.Begin = function()
		{
			msobj.ClientScroll = msobj.Direction > 1 ? msobj.ID.scrollWidth / 2 : msobj.ID.scrollHeight / 2;
			if((msobj.Direction <= 1 && msobj.ClientScroll <= msobj.Height + msobj.Step) || (msobj.Direction > 1 && msobj.ClientScroll <= msobj.Width + msobj.Step))			{
				msobj.ID.innerHTML = msobj.tempHTML;
				delete(msobj.tempHTML);
				return;
			}
			delete(msobj.tempHTML);
			msobj.TimerID = setInterval(msobj.StartID,timer);
			if(msobj.ScrollStep < 0)return;
			msobj.ID.onmousemove = function(event)
						{
							if(msobj.ScrollStep == 0 && msobj.Direction > 1)
							{
								var event = event || window.event;
								if(window.event)
								{
									if(msobj.IsNotOpera)
									{
										msobj.EventLeft = event.srcElement.id == msobj.ID.id ? event.offsetX - msobj.ID.scrollLeft : event.srcElement.offsetLeft - msobj.ID.scrollLeft + event.offsetX;
									}
									else
									{
										msobj.ScrollStep = null;
										return;
									}
								}
								else
								{
									msobj.EventLeft = event.layerX - msobj.ID.scrollLeft;
								}
								msobj.Direction = msobj.EventLeft > msobj.HalfWidth ? 3 : 2;
								msobj.AbsCenter = Math.abs(msobj.HalfWidth - msobj.EventLeft);
								msobj.Step = Math.round(msobj.AbsCenter * (msobj.BakStep*2) / msobj.HalfWidth);
							}
						}
			msobj.ID.onmouseover = function()
						{
							if(msobj.ScrollStep == 0)return;
							msobj.MouseOver = 1;
							clearInterval(msobj.TimerID);
						}
			msobj.ID.onmouseout = function()
						{
							if(msobj.ScrollStep == 0)
							{
								if(msobj.Step == 0)msobj.Step = 1;
								return;
							}
							msobj.MouseOver = 0;
							if(msobj.Stop == 0)
							{
								clearInterval(msobj.TimerID);
								msobj.TimerID = setInterval(msobj.StartID,timer);
							}
						}
		}
	setTimeout(msobj.Begin,waittime);
}

Marquee.prototype.Scroll = function()
{
	switch(this.Direction)
	{
		case 0:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollTop >= this.ClientScroll)
				{
					this.ID.scrollTop -= this.ClientScroll;
				}
				this.ID.scrollTop += this.Step;
			}
		break;

		case 1:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollTop <= 0)
				{
					this.ID.scrollTop += this.ClientScroll;
				}
				this.ID.scrollTop -= this.Step;
			}
		break;

		case 2:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollLeft >= this.ClientScroll)
				{
					this.ID.scrollLeft -= this.ClientScroll;
				}
				this.ID.scrollLeft += this.Step;
			}
		break;

		case 3:
			this.CTL += this.Step;
			if(this.CTL >= this.ScrollStep && this.DelayTime > 0)
			{
				this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL;
				this.Pause();
				return;
			}
			else
			{
				if(this.ID.scrollLeft <= 0)
				{
					this.ID.scrollLeft += this.ClientScroll;
				}
				this.ID.scrollLeft -= this.Step;
			}
		break;
	}
}
/*=========================================================================*/

/*==========================ScrollText=======================================*/

function ScrollText(content,btnPrevious,btnNext,autoStart)
{
    this.Delay = 10;
    this.LineHeight = 20;
	this.Amount = 1;//注意:LineHeight一定要能整除Amount.
	this.Direction = "up";
    this.Timeout = 1500;
    this.ScrollContent = this.$(content);
    this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
    //this.ScrollContent.scrollTop = 0;
    if(btnNext)
    {
        this.NextButton = this.$(btnNext);
        this.NextButton.onclick = this.GetFunction(this,"Next");
        this.NextButton.onmouseover = this.GetFunction(this,"Stop");
        this.NextButton.onmouseout = this.GetFunction(this,"Start");
    }
    if(btnPrevious)
    {
        this.PreviousButton = this.$(btnPrevious);
        this.PreviousButton.onclick = this.GetFunction(this,"Previous");
        this.PreviousButton.onmouseover = this.GetFunction(this,"Stop");
        this.PreviousButton.onmouseout = this.GetFunction(this,"Start");
    }
    this.ScrollContent.onmouseover = this.GetFunction(this,"Stop");
    this.ScrollContent.onmouseout = this.GetFunction(this,"Start");
    if(autoStart)
    {
        this.Start();
    }
}

ScrollText.prototype.$ = function(element)
{
    return document.getElementById(element);
}

ScrollText.prototype.Previous = function()
{
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("up");
}

ScrollText.prototype.Next = function()
{
    clearTimeout(this.AutoScrollTimer);
    clearTimeout(this.ScrollTimer);
    this.Scroll("down");
}

ScrollText.prototype.Start = function()
{
    clearTimeout(this.AutoScrollTimer);
    this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
}

ScrollText.prototype.Stop = function()
{
    clearTimeout(this.ScrollTimer);
    clearTimeout(this.AutoScrollTimer);
}

ScrollText.prototype.AutoScroll = function()
{
    if(this.Direction == "up")
    {
        if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
        }
        this.ScrollContent.scrollTop += this.Amount;
    }
    else
    {
        if(parseInt(this.ScrollContent.scrollTop) <= 0)
        {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
    {
        this.ScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Delay);
    }
    else
    {
        this.AutoScrollTimer = setTimeout(this.GetFunction(this,"AutoScroll"), this.Timeout);
    }
}

ScrollText.prototype.Scroll = function(direction)
{
    if(direction=="up")
    {
        if(this.ScrollContent.scrollTop == 0)
        {
            this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
        }
        this.ScrollContent.scrollTop -= this.Amount;
    }
    else
    {
        this.ScrollContent.scrollTop += this.Amount;
    }
    if(parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2)
        {
            this.ScrollContent.scrollTop = 0;
        }
    if(parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0)
    {
        this.ScrollTimer = setTimeout(this.GetFunction(this,"Scroll",direction), this.Delay);
    }
}

ScrollText.prototype.GetFunction = function(variable,method,param)
{
    return function()
    {
        variable[method](param);
    }
}
/*=========================================================================*/
/*==============================专家轮播=====================================*/

function ExFocus(json)
  {
  	this.startitem=0;
	this.maxpicid='maxexs';
	this.minpicid='minexs';
	this.piclen=0;
  	if(json!=null)
	{
		if(json.startNum=='undefined')
  			this.startitem=json.startNum;
		if(json.maxPicId=='undefined')
  			this.maxpicid=json.maxPicId;
		if(json.minPicId=='undefined')
		{
  			this.minpicid=json.minPicId;
		}
	}
	var context=this;
    var minexs=document.getElementById(context.minpicid).getElementsByTagName('a');
	var maxexs=document.getElementById(context.maxpicid).getElementsByTagName('li');
  	this.init=function()
	{
	    if(minexs)
	   { 
	        this.piclen=minexs.length;
		    context.switchMinPic();
		    context.switchMaxPic();
		}
	}
	this.switchMinPic=function()
	{
		if(minexs!=null)
		{
		    var len=maxexs.length;
	        for(var i=0;i<minexs.length;i++)
	        {
	          minexs[i].index=i%len;
	          minexs[i].onmouseover=function()
	          {
	  	        context.startitem=this.index;
		        context.switchMaxPic();
	          }
	        }
		 } 
	}
	this.switchMaxPic=function()
	{
		if(maxexs!=null)
		{
			for(var i=0;i<maxexs.length;i++)
			{
				if(i==context.startitem)
					maxexs[i].style.display='block';
				else
					maxexs[i].style.display='none';
			}
		}
	}
	this.start=function()
	{
		if(this.startitem>=this.piclen)
			this.startitem=0;
		context.switchMinPic();
		context.switchMaxPic();
		window.setTimeout(function(){context.startitem++;context.start();},5000);
	}
  }
/*=========================================================================*/

  function changeMarquee(d1, d2, d3, speed, rows, stim) {
      var demo = document.getElementById(d3);
      var demo1 = document.getElementById(d1);
      var demo2 = document.getElementById(d2);
      var speed = speed; //滚动速度
      var rows = rows; //每行高度
      var stim = stim; //停留时间倍数 * speed
      var stop = 0; //初始化值，不管
      demo2.innerHTML = demo1.innerHTML
      function Marquee() {
          //if(demo.scrollTop%rows==0 && stop<=stim){
          if (demo.scrollTop % rows == 0 && stop <= stim) {
              stop++;
              return;
          }
          stop = 0;
          if (demo2.offsetTop - demo.scrollTop <= 0)
              demo.scrollTop -= demo1.offsetHeight
          else {
              demo.scrollTop++
          }
      }
      var MyMar = setInterval(Marquee, speed)
      demo.onmouseover = function () { clearInterval(MyMar) }
      demo.onmouseout = function () { MyMar = setInterval(Marquee, speed) }
  }
