﻿var lastTop = 0;
function qqFloat(oDiv, nTop) {
	var ttop= document.body.scrollTop>document.documentElement.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;
	if (oDiv.style.top != (nTop + ttop)	+ "px") {
		var py = (nTop + ttop - lastTop) / 4;
		if (py > 10 || py < -10) {
			lastTop = lastTop + py;
			oDiv.style.top = lastTop + "px";
		}
	}
}
function setQQNums(tstr){
	var qqarray = [];
	qqarray=tstr.split("|");
	var htmlStr='<STYLE type=text/css>#ServiceQQ {RIGHT: 70px;TOP: 180px; no-repeat;TOP: 180px; no-repeat;PADDING-TOP: 40px;POSITION: absolute;overflow: hidden;z-index: 10;}</style>';
	htmlStr+='<DIV id="ServiceQQ"><TABLE cellSpacing="0" cellPadding="0" width="109" border="0"><TBODY><TR><TD colSpan="3"><A onclick="CloseQQ()" href="javascript:;" shape="circle" coords="91,16,12"><IMG height="34" src="/images/im/qq_top.gif" width="109" useMap="#Map"border="0"></A></TD></TR><TR><TD width="6" background="/images/im/qq_life.gif"></TD><TD vAlign="top" width="96" style="background-color: #ffffff;"><TABLE cellSpacing="0" cellPadding="0" width="90" align="center" border="0"><TBODY><TR><TD></TD></TR><TR><TD><TABLE id="table47" cellPadding="2" width="100%" border="0"><TBODY>';
	for(i=0;i<qqarray.length;i++){
		htmlStr+='<TR><TD vAlign="bottom"><a target="blank" href="tencent://message/?uin='+qqarray[i]+'&Site=在线客服&Menu=yes"><img border="0" SRC="http://wpa.qq.com/pa?p=1:'+qqarray[i]+':7" alt="在线客服">							</a>							</TD>						</TR>					';	
	}
	htmlStr+='</TBODY></TABLE></TD></TR><TR><TD></TD></TR>	</TBODY></TABLE></TD><TD width="7" align="left" background="/images/im/qq_right.gif"></TD></TR><TR><TD colSpan="3"><IMG height="30" src="/images/im/qq_bottom1.gif" width="109"></TD></TR><TR><TD colSpan="3"><IMG height="33" src="/images/im/qq_logo.png" width="109"></TD></TR></TBODY></TABLE></DIV>';
	document.write(htmlStr);
	setInterval('qqFloat(document.getElementById("ServiceQQ"),180)', 60);
}
function CloseQQ() {
	document.getElementById("ServiceQQ").style.display = "none";
	return true;
}

function getElementsByName(eltname){ 
  var tag='div';
  var elts=document.getElementsByTagName(tag); 
  var count=0; 
  var elements=[]; 
  for(var i=0;i<elts.length;i++){ 
     if(elts[i].getAttribute("name")==eltname){ 
        elements[count++]=elts[i]; 
     } 
  } 
  return elements; 
}
function replaceLeaveMessage(guid, freecall, qq) {
	var h1 = '<a href="/leaveMessage.jsp?companyid='+guid+'" target="_blank"><img alt="点击留言" src="/image/clicktotalk.gif" title="点击留言" width="75" height="18" border="0" /></a>';
	var h2 = '<a target="_blank" href="http://wpa.qq.com/msgrd?V=1&Uin='+qq+'&Site=&Menu=yes"><img border="0" width="75" height="18" src="http://wpa.qq.com/pa?p=2:'+qq+':41&r=0.5529319992018282" alt="点击这里给我发消息" /></a>';
	var h3 = '<a href="javascript:;" onclick="javascript:open(\'http://www.imcaller.com/LeaveMessage/leaveMessage.aspx?logo=&workgroup='+guid+'_wg@workgroup.imcaller.com&target=C\',\'win\',\'width=560,height=450,resizable=0,scrollbars=0,status=no,toolbar=no,location=no,menu=no\')" target="_self"><img alt="免费电话" src="/image/freecall.gif" title="点击按钮，即刻进行免费通话" width="75" height="18" border="0" /></a>';
	
	var h = h1;
	if (qq!='' && qq!='-1') {
		h = h1 + '&nbsp' + h2;
	}	
	if (freecall>0) {
		h = h1 + '&nbsp' + h3;
	}
	/*
	if (qq=='-1') {
		h = '&nbsp';
	}
	*/
	
	var divs = getElementsByName("contact_leavemessage");
	for(i = 0; i < divs.length; i++) {
		divs[i].innerHTML=h;
	}
	
	divs = getElementsByName("contact_product");
	for(i = 0; i < divs.length; i++) {
		if (qq=='-1')
			divs[i].innerHTML='&nbsp';
		else if (freecall>0)
			divs[i].innerHTML=h3;
		else if (qq!='')
			divs[i].innerHTML=h2;
		else
			divs[i].innerHTML=h1;
	}

	if (qq!='-1' && qq!='') {
		setQQNums(qq);
	}
}


function check(theForm){
	var keywords = theForm.keywords.value;
	if(keywords == "输入关键字" || keywords == "" ){
	alert("请输入查询内容！");
	theForm.keywords.focus();
	return false;
	}
	return true;
}
function changeLinkStyle(div, aid){
	var nowdiv = document.getElementById(div);
	var A=nowdiv.getElementsByTagName("A");
	for(var i=0;i<A.length;i++)
	{
		A[i].className="e";
	}
	aid.className="be";
}
