addLoadEvent(Navbox);
addLoadEvent(woyao);

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function $(id){ return document.getElementById(id); }

function Navbox(){
	var NavId=$("KeShi1");
	var NavList=NavId.getElementsByTagName("li");
	for(i=0;i<NavList.length;i++){
		var NavDiv=get_lastChild(NavList[i]);
		if(NavList[i].className.indexOf("Disease")!==1){
			NavDiv.onmouseover=function(){
				this.style.border="#fc8c2a 1px solid";
				this.style.borderTop="#fc8c2a 2px solid";
				this.style.backgroundColor="#fff1d1";
			}
				NavDiv.onmouseout=function(){
				this.style.border="#fff 1px solid";
				this.style.borderTop="#fff 2px solid";
				this.style.backgroundColor="";
			}
		}
				
		if(NavList[i].className.indexOf("Disease")!=-1) continue;
			
		NavDiv.onmouseover=function()
		{
		//alert (this.nodeName)
		this.style.borderTop="#fc8c2a 2px solid";
		this.style.borderBottom="#fc8c2a 1px solid";
		this.style.borderLeft=this.style.borderBottom;
		this.style.position="relative";
		this.style.backgroundColor="#fff1d1";
		var hiddenBox=get_lastChild(this);
		hiddenBox.style.position="absolute";
		hiddenBox.style.zIndex="1000";
		hiddenBox.style.left="197px";
		hiddenBox.style.top="-2px";
		hiddenBox.style.display="block";
		hiddenBox.style.border="#fc8c2a 1px solid";
		hiddenBox.style.borderTop="#fc8c2a 2px solid";
		}
		NavDiv.onmouseout=function()
		{

		this.style.borderTop="#fff 2px solid";
		this.style.borderBottom="#fff 1px solid";
		this.style.borderLeft=this.style.borderBottom;
		this.style.position="relative";
		this.style.backgroundColor="";
		var hiddenBox=get_lastChild(this);
		hiddenBox.style.display="none";
		}
		
	}
}
function get_lastChild(n){
	var x=n.lastChild;
	while(x.nodeType!=1){
	 x=x.previousSibling;
	}
	return x;
}

function woyao(){
	var woyao=$("woyao");
	var woda=$("woda");
	woyao.onmouseover=function(){
		this.style.cursor="pointer";
		this.style.background="url(images/home/new_ask001.gif) left top no-repeat"
		}
	woyao.onmouseout=function(){
		this.style.background="url(images/home/new_ask.gif) left top no-repeat"

		}
	woyao.onclick=function(){
		window.open("http://www.120ask.com/ask.asp","_blank")
		//window.location
		}
		
	woda.onmouseover=function(){
		this.style.cursor="pointer";
		this.style.background="url(images/home/new_da001.gif) left top no-repeat"
		}
	woda.onmouseout=function(){
		this.style.background="url(images/home/new_da.gif) left top no-repeat"

		}		
		
	woda.onclick=function(){
		window.open("http://www.120ask.com/noans.asp","_blank")
		}		
}

function tabDiv(obj,num,len,cn){
	var cssname=cn;
	for(var id = 1;id<=len;id++){
		var ss = obj+id;
		var snav = obj+"nav"+id;
		var More = obj+"link";
		var BoxDiv = document.getElementById(ss);
		var ClassDiv = document.getElementById(snav);
		var MoreLink = document.getElementById(More);
		if(id == num){
			try {BoxDiv.style.display="block";	ClassDiv.className=cssname; MoreLink.href=ClassDiv.childNodes[0].href;}catch(e){};
		}else{
			try {BoxDiv.style.display="none"; ClassDiv.className="";}catch(e){};
		}
	}
}

//最新加入医院滚动
function startmarquee(lh,speed,delay,index){ 
	var t; 
	var p=false; 
	var o=$("marqueebox"+index); 
	o.innerHTML+=o.innerHTML; 
	o.onmouseover=function(){p=true} 
	o.onmouseout=function(){p=false} 
	o.scrollTop = 0; 
	function start(){ 
		t=setInterval(scrolling,speed); 
		if(!p) o.scrollTop += 1; 
	} 
	function scrolling(){ 
		if(o.scrollTop%lh!=0){ 
			o.scrollTop += 1; 
			if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0; 
		}else{ 
			clearInterval(t); 
			setTimeout(start,delay); 
		} 
	} 
	setTimeout(start,delay); 
} 
startmarquee(56,30,3000,0); 

// 医生推荐滚动
var sid=((new Date()).getTime()+"_"+Math.round(Math.random()*2147483637));
function sendPfScrollStat() { if(document.images){(new Image()).src='/js/blank.js?func=pfscroll&sid='+sid+'&t='+(new Date()).getTime();} }
	var Slider=(function() {
	var speed = 12;
	var space = 6;
	var slideWidth = 125;
	var moveLock = false;
	var moveTimer;
	var dist = 0;
	var slideTimer=null;
	var isScroll = false;
	var holder1 = $("holder1");
	var slidePic = $("slidePic");
	$("holder2").innerHTML = holder1.innerHTML;
	slidePic.scrollLeft = holder1.scrollWidth;
	function slidePlay(){
		clearInterval(slideTimer);
		slideTimer = setInterval(function(){slideDown();slideStopDown();},3000);
	}
	function slideStop(){
		clearInterval(slideTimer);
	}
	function slideUp(){
		if(moveLock) return;
		clearInterval(slideTimer);
		moveLock = true;
		moveTimer = setInterval(function(){scrollUp();},speed);
	}
	function slideStopUp(){
		if(isScroll){return};
		clearInterval(moveTimer);
		if(slidePic.scrollLeft % slideWidth != 0){
			dist = -(slidePic.scrollLeft % slideWidth);
			setDist();
		}else{
			moveLock = false;
		}
		slidePlay();
	}
	function scrollUp(){
		if(slidePic.scrollLeft <= 0){slidePic.scrollLeft = holder1.offsetWidth}
		slidePic.scrollLeft -= space;
	}
	function slideDown(){
		clearInterval(moveTimer);
		if(moveLock) return;
		clearInterval(slideTimer);
		moveLock = true;
		scrollDown();
		moveTimer = setInterval(function(){scrollDown();},speed);
	}
	function slideStopDown(){
		if(isScroll){return};
		clearInterval(moveTimer);
		if(slidePic.scrollLeft % slideWidth != 0 ){
			dist = slideWidth - slidePic.scrollLeft % slideWidth;
			setDist();
		}else{
			moveLock = false;
		}
		slidePlay();
	}
	function scrollDown(){
		if(slidePic.scrollLeft >= holder1.scrollWidth){slidePic.scrollLeft = 0;}
		slidePic.scrollLeft += space ;
	}
	function setDist(){
		if(dist == 0){
			moveLock = false;
			isScroll = false;
			return;
		}
		var num;
		var tempSpeed = speed,tempDist = space;
		if(Math.abs(dist)<slideWidth/5){
			tempDist =  Math.round(Math.abs(dist/5));
			if(tempDist<1){tempDist=1};
		}
		if(dist < 0){
			if(dist < -tempDist){
				dist += tempDist;
				num = tempDist;
			}else{
				num = -dist;
				dist = 0;
			}
			slidePic.scrollLeft -= num;
			setTimeout(function(){setDist();},tempSpeed);
		}else{
			if(dist > tempDist){
				dist -= tempDist;
				num = tempDist;
			}else{
				num = dist;
				dist = 0;
			}
			slidePic.scrollLeft += num;
			setTimeout(function(){setDist();},tempSpeed);
		}
	}
	function init() {
		var p=$('slidePic');
		p.onmouseover=function(){Slider.stop();};
		p.onmouseout=function(){Slider.play();};
		var l=$('slide_left'),r=$('slide_right');
		l.onmouseover=function(){Slider.stop();this.className='arr_bg';};
		r.onmouseover=function(){Slider.stop();this.className='arr_bg01';};
		l.onmouseout=r.onmouseout=function(){this.className='';Slider.play();};
		var lb=$('arrow_left');
		lb.onmousedown=function(){this.className='arr_left';Slider.up();};
		lb.onmouseup=function(){Slider.stopUp();};
		lb.onmouseout=function(){Slider.stopUp();this.className='';};
		var rb=$('arrow_right');
		rb.onmousedown=function(){this.className='arr_right';Slider.down();};
		rb.onmouseup=function(){Slider.stopDown();};
		rb.onmouseout=function(){Slider.stopDown();this.className='';};
		lb.onclick=rb.onclick=function(){setTimeout(sendPfScrollStat,1000);};
		slidePlay();
	}
	return {
		init:init,
		play:slidePlay,
		stop:slideStop,
		up:slideUp,
		stopUp:slideStopUp,
		down:slideDown,
		stopDown:slideStopDown
	}
})();

addLoadEvent(Slider.init);


// JavaScript Document 在线医生数
var indexMain = function(){
	this.initial.apply(this,arguments);
}
indexMain.prototype = {
	initial : function(frameId,textareaId,boderDiv,isGG){
		this.setOnlineNum();
	},
	$ : function(id){
		return document.getElementById(id);
	},
	setOnlineNum : function(){
		var numY;
		var numP;
		var D = new Date();
		hours = D.getHours();
		switch(hours){
			case 0:
			numP = 90300;	
			numY = 5000;
			break;
			case 1:
			numP = 35100;	
			numY = 2500;
			break;
			case 2:
			numP = 18300;	
			numY = 1600;
			break;
			case 3:
			numP = 18300;	
			numY = 1600; 
			break;
			case 4:
			numP = 11700;	
			numY = 900; 
			break;
			case 5:
			numP = 12000;	
			numY = 900; 
			break;
			case 6:
			numP = 30900;	
			numY = 2500;
			break;
			case 7:
			numP = 36900;	
			numY = 2800;
			break;
			case 8:
			numP = 76200;	
			numY = 6500;
			break;
			case 9:
			numP = 102000;	
			numY = 7500;
			break;
			case 10:
			numP = 110100;	
			numY = 8000;
			break;
			case 11:
			numP = 154800;	
			numY = 10000;
			break;
			case 12:
			numP = 120300;	
			numY = 9000;
			break;
			case 13:
			numP = 96900;	
			numY = 8200; 
			break;
			case 14:
			numP = 120000;	
			numY = 9500; 
			break;
			case 15:
			numP = 128400;	
			numY = 10000; 
			break;
			case 16:
			numP = 157500;	
			numY = 12000; 
			break;
			case 17:
			numP = 126300;	
			numY = 11000; 
			break;
			case 18:
			numP = 96900;	
			numY = 8000;
			break;
			case 19:
			numP = 105000;	
			numY = 8000; 
			break;
			case 20:
			numP = 117900;	
			numY = 9000; 
			break;
			case 21:
			numP = 160500;	
			numY = 11000; 
			break;
			case 22:
			numP = 121500;	
			numY = 9000; 
			break;
			case 23:
			numP = 94500;	
			numY = 6000; 
			break;
			default:
			num = 0
			break;
		}
		this.$("doctorOnlineNum").innerHTML=numY+parseInt(100*Math.random());
		//this.$("userOnlineNum").innerHTML=numP+parseInt(Math.random()*1000);
	}
}

var indexObj = new indexMain();