var $ = function(id){
	return document.getElementById(id);
};


//复制代码
function Copytxt(id)
{
 var txt = document.body.createTextRange();
 txt.moveToElementText($(id));
 txt.select();
 document.execCommand("Copy"); 
}

//加入IM群
function button10_onclick(aa) 
{
    try{
		var im  = new ActiveXObject("HCLogin.DetectHcIM");
		var groupid=aa;
		var ret = im.join_qun(groupid);
	}
	catch(e)
	{
		return false;//提示用户不是最新的版本，请重新登陆IM！
	}
	return true;
}

//与用户聊天
function sjb_CallFriend(toTmUsr){
  try{//安装
  	var xmlhttp1 = new ActiveXObject("HCLogin.DetectHcIM");
  	var ret;
	ret = xmlhttp1.IMIsStart();
	if(ret == 1)
	{
		alert("买卖通IM未运行，请先运行买卖通IM！");
	}
	else
	{
		xmlhttp1.chat_with_friend(toTmUsr);	
	}
  }
  catch(e){//没安装 

  	window.open("http://www.im.hc360.com/pop3.htm", "","toolbar=no,location=no,directories=no,status=no,menubar=no, scrollbars=no,resizable=no,copyhistory=no,width=310,height=156");
  	//window.open("http://www.im.hc360.com/IM/files/help.html");
  }
  return false;
}

//删除双重BR
function delbr(id,num){
	var dobj = $(id);
	var tdobj = dobj.getElementsByTagName("td");
	var con,temcon,tcode;
	for(i=0;i<tdobj.length;i++){
		con = tdobj[i].innerHTML;
		if(num==1)
			tdobj[i].innerHTML = con.substring(0,con.length-4);
		else
			tdobj[i].innerHTML = con.replace(/(\<br\>)+/gi,"<br>");		
	}
}


//控制页面广告后载
function endAdv(str1,str2,initheight){
	$(str1).style.height = initheight + "px";
	$(str1).innerHTML = $(str2).innerHTML;
	$(str2).innerHTML = "";
}


//文本框获取焦点//针对:好耶iframe广告抢走input=text焦点
/*function inputFocus(obj){
	     $(obj).focus();
	      var objT=$(obj).createTextRange();   
          objT.moveStart("character",$(obj).value.length);   
          objT.moveEnd("character",0);   
          objT.select();  
}*/


//顶部浮层64个行业
function ShowAllChannel(_this,id,bgleft,bgtop1,bgtop2){
	$(id).style.display="block";
	var bgpos1 = bgleft + " " + bgtop1;
	var bgpos2 = bgleft + " " + bgtop2;
	$(id).onmouseover=function(){this.style.display="block";_this.style.backgroundPosition=bgpos1;}
	$(id).onmouseout=function(){this.style.display="none";_this.style.backgroundPosition=bgpos2;}
	_this.style.backgroundPosition=bgpos1;
	_this.onmouseout=function(){$(id).style.display="none";_this.style.backgroundPosition=bgpos2;}
}

window.onerror=function (){
return true;
}

//行业焦点图
var _t1 = 0; //打开页面时等待图片载入的时间，单位为秒，可以设置为0
var _t2 = 5; //图片轮转的间隔时间
var _tnum = 2; //焦点图个数
var _tn = 1;//当前焦点
var _tl =null;
_tt1 = setTimeout('change_img()',_t1*1000);
function change_img(){
setFocus(_tn);
_tt1 = setTimeout('change_img()',_t2*1000);
}
function setFocus(i){
if(i>_tnum){_tn=1;i=1;}
_tl?document.getElementById('hcFocusPic'+_tl).style.display='none':'';
document.getElementById('hcFocusPic'+i).style.display='block';
_tl=i;
_tn++;
}
function stopDefault(){
	var hcFocus=document.getElementById('hcFocus');
	var links=hcFocus.getElementsByTagName('a');
	for(var i=0;i<links.length;i++){
		if( links[i].parentNode.className=="index_page"){
			links[i].onclick=function(){
				return false;
			}
		}
	}
}

//滚动
// Useage: HCmarquee(滚动对象id, 可见范围宽度, 可见范围高度, 滚动速度, 停留时间, 方向); 方向有left和up两种
function HCmarquee(id,mw,mh,mr,ms,pause,dr){
	
	var obj=document.getElementById(id);
	obj.ss=false; //stop tag
	obj.mr=mr; //marquee rows
	obj.mw=mw; //marquee width
	obj.mh=mh; //marquee height
	obj.ms=ms; //marquee speed
	obj.pause=pause; //pause time
	obj.pt=0; //pre top
	obj.st=0; //stop time
	obj.dr=dr; //direction

	with(obj){
		style.width=mw+"px";
		style.height=mh+"px";
		noWrap=false;
		onmouseover=stopm;
		onmouseout=startm;
		scrollTop=0+"px";
		scrollLeft=0+"px";
	}
	
	if(obj.mr!=1){
		switch(obj.dr){
			case("up"):
				obj.tt=mh*mr;
				obj.ct=mh; //current top
				obj.innerHTML+=obj.innerHTML;
				setInterval(scrollUp,obj.ms); break;
			default://("left"):
				obj.tt=mw*mr;
				obj.ct=mw;
				obj.innerHTML='<div style="width:'+(obj.tt*2)+'px;"><div style="float:left;">'+obj.innerHTML+'</div><div style="float:right;">'+obj.innerHTML+'</div></div>';
				document.write('<style type="text/css">#'+id+' table{width:'+mw*mr+'px;} #'+id+' td{width:'+mw+'px;}</style>');
				setInterval(scrollLeft,obj.ms); break;
		}
	}

	function scrollUp(){
		if(obj.ss==true) return;
		obj.ct+=1;
		if(obj.ct==obj.mh+1){
			obj.st+=1; obj.ct-=1;
			if(obj.st==obj.pause){obj.ct=0; obj.st=0;}
		}else {
			obj.pt=(++obj.scrollTop);
			if(obj.pt==obj.tt){obj.scrollTop=0;}
		}
	}

	function scrollLeft(){
		if(obj.ss==true) return;
		obj.ct+=1;
		if(obj.ct==obj.mw+1){
			obj.st+=1; obj.ct-=1;
			if(obj.st==obj.pause){obj.ct=0; obj.st=0;}
		}else {
			obj.pt=(++obj.scrollLeft);
			if(obj.pt==obj.tt){obj.scrollLeft=0;}
		}
	}

	function stopm(){obj.ss=true;}
	function startm(){obj.ss=false;}
}

//鲜活度,5分钟刷新
function clickTime() 
{
	var thistime = new Date();
	var years = thistime.getYear();
	var days = thistime.getDay();
	var hours = thistime.getHours();
	var minutes = thistime.getMinutes();
	var seconds = thistime.getSeconds();

	var lastDate = new Date(thistime.getYear(), thistime.getMonth(), thistime.getDate(),hours,5*parseInt(minutes/5));
		if(hours>17||hours<9){
			document.getElementById("mainbody").parentNode.className="row11";
			
			if(hours>=18){
				document.getElementById("mainbody").innerHTML = "<span style='font-size:12px; line-height:110%;'>下次更新时间是明日9:00</span>";
			}else{
				document.getElementById("mainbody").innerHTML = "<span style='font-size:12px; line-height:110%;'>下次更新时间是今日9:00</span>";
			}
			document.getElementById("lastTime").innerHTML="<span style='color:#333; line-height:50%;'>上次更新时间18:00</span>";
		}else{
			document.getElementById("mainbody").parentNode.className="row1";
			minutes = 4 - minutes % 5;
			seconds = 59 - seconds;
			var smin = lastDate.getMinutes();
			if(smin<10)smin="0"+smin;
			document.getElementById("lastTime").innerHTML="上次更新时间"+(lastDate.getHours())+":"+smin;
			if(minutes == 0 && seconds == 0){
				//window.location.reload();
				//document.getElementById('timeIframe').src='http://info.pharmacy.hc360.com/list/iframe_0711gun.shtml';
			}else{
				if(minutes<10)minutes="0"+minutes;
				if(seconds<10)seconds="0"+seconds;
				thistime ='<span style="font-weight:bold; font-size:16px; padding-top:15px; ">'+ minutes + ":" + seconds+'</span>';
				document.getElementById("mainbody").innerHTML = thistime;
			}
		}
	setTimeout("clickTime()",1000);
}
//]]>

//页面之间传递关键词
function sendword(o){
	word = $("word").value;
	if(word.substring(0,3)!="请输入" && word.length>0){
		ohref=o.href;
		para = encodeURIComponent(word);
		o.href = ohref + "?w=" + para;
	}

}
para = location.search;
if(para!=""){
	npara = decodeURIComponent(para).substring(3);
	$("word").value=npara;
}
