function initBooking()
{
	var yearOjb=document.getElementById('Year');
	var monthOjb=document.getElementById('Month');
	var dayOjb=document.getElementById('day');
	var time=new Date();
	var year=time.getYear();
	var month=time.getMonth();
	var day=time.getDate();
	if(yearOjb)
	{
		yearOjb.options.length=0;
		for(var y=year;y<year+5;y++)
		{
			var oOption =new Option(y,y);
			yearOjb.options[yearOjb.length]=oOption;
		}
	}
	if(monthOjb)
		monthOjb.selectedIndex=month;
	if(dayOjb)
		dayOjb.selectedIndex=day;
}
  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 bookingSubmit()
   {
        var frm=document.forms["frmbooking"];
        
        if(document.getElementById("username").value=="")
        {
            alert("用户名不能留空！");
            document.getElementById("username").focus();
            return false;
        }
        if(document.getElementById("tel").value=="")
        {
            alert("电话不能留空！");
            document.getElementById("tel").focus();
            return false;
        }
        frm.submit();
        return true;
   } 
   function bookingReset()
   {
   		document.forms["frmbooking"].reset();
   }
  function doctorKnowSubmit()
  {
  	var title=document.getElementById('title');
	if(title.value=='请输入您的问题标题!'||title.value=='')
	{
		alert('请输入您的问题标题!');
		title.focus();
		return false;
	}
	if(title.value.length>100)
	{
		alert("标题长度只能100个字内!");
		return false;
	}
  	var q=document.getElementById('content');
	if(q.value=='请提出您的问题,点击搜索答案!如果没有您满意的答案,请点击我要提问!'||q.value=='')
	{
		alert('请填写您要提问的内容!');
		q.focus();
		return false;
	}
	if(q.value.length>1000)
	{
		alert("提问内容长度只能1000个字内!");
		return false;
	}

	document.getElementById('frmdoctorknow').submit();
	return true;
  }

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 topMenuInit(index)
{
	
	this.indexId=index;
	
	var topmenu=document.getElementById("topmenu");
	var list=topmenu.getElementsByTagName("li");
	var sub=document.getElementById("submenu");
	var sublist=sub.getElementsByTagName("li");
	var count=0;
	this.templist=new Array();
	for(var i=0;i<list.length;i++)
	{
		if(list[i].className!='line')
		{
			templist[templist.length]=list[i];
			list[i].index=count;			
			count++;
		}
		
	}
    
	for(var i=0;i<list.length;i++)
	{
    		if(this.indexId!=null&&this.indexId>=0)
                break;
			list[i].onmouseover=function()
			{
				if(this.index==0||this.index==2||this.index==3)
					topmenu.className='topmenu1'
				else
					topmenu.className='topmenu'
					if(this.className!='line')
					{
						for(var j=0;j<list.length;j++)
						{
							
							if(list[j].className!='line')
							{
								list[j].className='';
							}
						}
						for(var k=0;k<sublist.length;k++)
						{
								sublist[k].className='';
						}
						sublist[this.index].className='cur';
						this.className='cur';
					}
			}
		
	}
	var active=function()
	{
		if(templist[this.indexId].index==0||templist[this.indexId].index==2||templist[this.indexId].index==3)
			topmenu.className='topmenu1'
		else
			topmenu.className='topmenu'
		for(var i=0;i<templist.length;i++)
		{	
			templist[i].className='';
			sublist[i].className='';
		}
		sublist[this.indexId].className='cur';
		templist[this.indexId].className='cur';

	}
	if(this.indexId!=null&&this.indexId>=0)
		active();
}
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;
			}
		}
		
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.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;
		    img.alt=this.imgs[i].title;
		    if(this.imgWidth)
			    img.width=this.imgWidth;
		    if(this.imgHeight)
			    img.height=this.imgHeight;
		    var a = document.createElement("a");
		    a.href = this.imgs[i].href;
		    a.target = "_blank";
		    a.appendChild(img);
		    flash_img_div.appendChild(a);
		}
		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();
		flash_title.href = fImgs[imageIndex].href;
		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);
	}
}
