var tipTimer;
function locateObject(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=locateObject(n,d.layers[i].document); return x;
}

function hideTooltip(object)
{
if (document.all)
{
	locateObject(object).style.visibility="hidden"
	locateObject(object).style.left = 1;
	locateObject(object).style.top = 1;
return false
}
else if (document.layers)
{
	locateObject(object).visibility="hide"
	locateObject(object).left = 1;
	locateObject(object).top = 1;
	return false
}
else
	return true
}

function showTooltip(object,e, tipContent, backcolor, bordercolor, textcolor, displaytime)
{
	window.clearTimeout(tipTimer)
	
	if (document.all)
		{
			locateObject(object).style.top=document.body.scrollTop+event.clientY+20
			
			locateObject(object).innerHTML='<table  style="line-height:150%"; style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; border: '+bordercolor+'; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; background-color: '+backcolor+'" width="50%" border="0" cellspacing="1" cellpadding="4"><tr><td nowrap><font style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table> '

			if ((e.x + locateObject(object).clientWidth) > (document.body.clientWidth + document.body.scrollLeft))
				{	
					locateObject(object).style.left = (document.body.clientWidth + document.body.scrollLeft) - locateObject(object).clientWidth-10;
				}
			else
			{
			locateObject(object).style.left=document.body.scrollLeft+event.clientX
			}
		locateObject(object).style.visibility="visible"
		//tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
		return true;
		}
	else if (document.layers)
		{
		locateObject(object).document.write('<table width="100%" border="0" cellspacing="1" cellpadding="1"><tr bgcolor="'+bordercolor+'"><td><table width="10" border="0" cellspacing="0" cellpadding="2"><tr bgcolor="'+backcolor+'"><td nowrap><font style="font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 11px; color: '+textcolor+'">'+unescape(tipContent)+'</font></td></tr></table></td></tr></table>')
		locateObject(object).document.close()
		locateObject(object).top=e.y+20

		if ((e.x + locateObject(object).clip.width) > (window.pageXOffset + window.innerWidth))
			{
				locateObject(object).left = window.innerWidth - locateObject(object).clip.width-10;
			}
		else
			{
			locateObject(object).left=e.x;
			}
		locateObject(object).visibility="show"
		//tipTimer=window.setTimeout("hideTooltip('"+object+"')", displaytime);
		return true;
	}
	else
	{
		return true;
	}
}

function textarea_Size(num,objname)
{
	var obj=document.getElementById(objname)
	if (parseInt(obj.rows)+num>=3) {
		obj.rows = parseInt(obj.rows) + num;	
	}
	if (num>0)
	{
		obj.width="90%";
	}
}
///双击滚屏函数
     var currentpos,timer;
    
     function initialize()
     {
     timer=setInterval("scrollwindow()",10);
     }
     function sc(){
     clearInterval(timer);
     }
     function scrollwindow()
     {
     currentpos=document.body.scrollTop;
     window.scroll(0,++currentpos);
     if (currentpos != document.body.scrollTop)
     sc();
     }
     document.onmousedown=sc
     document.ondblclick=initialize
///双击滚屏函数结束
function openScript(url, width, height){
	var Win = window.open(url,"openScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
}
//***********默认设置定义.*********************
tPopWait=50;//停留tWait毫秒后显示提示。
tPopShow=5000;//显示tShow毫秒后关闭提示
showPopStep=20;
popOpacity=99;

//***************内部变量定义*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText {  background-color: #ffffff; border: 1px #555555 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");

document.write("</style>");
document.write("<div id='ncpopLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>");


function showPopupText(){
var o=event.srcElement;
	MouseX=event.x;
	MouseY=event.y;
	if(o.alt!=null && o.alt!=""){o.ncpop=o.alt;o.alt=""};
        if(o.title!=null && o.title!=""){o.ncpop=o.title;o.title=""};
	if(o.ncpop!=sPop) {
			sPop=o.ncpop;
			clearTimeout(curShow);
			clearTimeout(tFadeOut);
			clearTimeout(tFadeIn);
			clearTimeout(tFadeWaiting);	
			if(sPop==null || sPop=="") {
				ncpopLayer.innerHTML="";
				ncpopLayer.style.filter="Alpha()";
				ncpopLayer.filters.Alpha.opacity=0;	
				}
			else {
				if(o.dyclass!=null) popStyle=o.dyclass 
					else popStyle="cPopText";
				curShow=setTimeout("showIt()",tPopWait);
			}
			
	}
}

function showIt(){
		ncpopLayer.className=popStyle;
		ncpopLayer.innerHTML=sPop;
		popWidth=ncpopLayer.clientWidth;
		popHeight=ncpopLayer.clientHeight;
		if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
			else popLeftAdjust=0;
		if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
			else popTopAdjust=0;
		ncpopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
		ncpopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
		ncpopLayer.style.filter="Alpha(Opacity=0)";
		fadeOut();
}

function fadeOut(){
	if(ncpopLayer.filters.Alpha.opacity<popOpacity) {
		ncpopLayer.filters.Alpha.opacity+=showPopStep;
		tFadeOut=setTimeout("fadeOut()",1);
		}
		else {
			ncpopLayer.filters.Alpha.opacity=popOpacity;
			tFadeWaiting=setTimeout("fadeIn()",tPopShow);
			}
}

function fadeIn(){
	if(ncpopLayer.filters.Alpha.opacity>0) {
		ncpopLayer.filters.Alpha.opacity-=1;
		tFadeIn=setTimeout("fadeIn()",1);
		}
}
document.onmouseover=showPopupText;
function SetHPage(ab){
    ab.style.behavior='url(#default#homepage)';
	ab.setHomePage('http://www.hualin.cn');
	return false;
}
function bookmark(){
	if ( document.all){
        //检查浏览器是否为IE，如果是，则执行下面的语句
        window.external.AddFavorite('http://www.hualin.cn', "中国调节阀网—专业调节阀技术、产品信息发布平台");
        //调用AddFavorite（）函数，把网站加入到收藏夹里
	}
}
function openurl(tp,id){
     if(tp=="q"){//打开知识问答
            window.open('/news/View_Quess.asp?id='+id,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0');
     }
     if(tp=="x"){//打开学术交流
            window.open('/news/View_Xuesu.asp?id='+id,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0');
     }
     if(tp=="z"){//打开故障维护
            window.open('/news/View_Guzhang.asp?id='+id,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0');
     }
}
function makesmallpic(obj,w,h){//自动缩放图片
 var srcImage = new Image();
 srcImage.src=obj.src;
 var srcW=srcImage.width;  
 var srcH=srcImage.height;
 if(srcW>srcH){
  if(srcW>w){
   obj.width=newW=w;
   obj.height=newH=(w/srcW)*srcH;
  }else{
   obj.width=newW=srcW;
   obj.height=newH=srcH;
  }
 }else{
  if(srcH>h){
   obj.height=newH=h;
   obj.width=newW=(h/srcH)*srcW;
  }else{
   obj.width=newW=srcW;
   obj.height=newH=srcH;
  }
 }
 if(newW>w){
  obj.width=w;
  obj.height=newH*(w/newW);
 }else if(newH>h){
  obj.height=h;
  obj.width=newW*(h/newH);
 }
}