if(typeof(HTMLElement)!="undefined")    // 给firefox定义contains()方法，ie下不起作用
{   
      HTMLElement.prototype.contains=function(obj)   
      {   
          while(obj!=null&&typeof(obj.tagName)!="undefind"){ // 通过循环对比来判断是不是obj的父元素
   　　　　if(obj==this) return true;   
   　　　　obj=obj.parentNode;
   　　}   
          return false;   
      };   
} 

/**
 * 
 * @param qq1:
 *            第一QQ号码
 * @param qq2：第二个QQ号码
 * @param email
 *            电子邮件
 * @param contact_us
 *            联系我们url
 * @param img_path
 *            图片路径
 */
function initQQBody(qq1,qq2,email,contact_us,img_path){
	// var qq= "2226312086";
	// var qq2 = "1379498929"
	// var email = "support#ezhoutour.gov.cn";
	document.write("<div class='QQbox' id='divQQbox' >");
	document.write("<div class='Qlist' id='divOnline' onmouseout='hideMsgBox(event);' style='display : none;'>");
	// qq body
	document.write("<div id='qq_wrapper'>");
	document.write("<div id='qq_box'>");
	document.write("	<div id='online_server'>");
	document.write("	</div>");
	document.write("	<div id='online1>");
	document.write("	  <a href='#'><img width='70px' height='70px' alt='在线QQ咨询' src='" + img_path +"/spacer.gif' onclick='javascript:window.open(\"http://wpa.qq.com/msgrd?v=3&uin="+qq1+"&site=qq&menu=yes\", \"_top\");'></a>");
	document.write("	</div>");
	document.write("	<div id='qq_online'>");
	document.write("	  <img alt='在线QQ咨询' width='83px' height='24px' src='" + img_path + "/spacer.gif' onclick='javascript:window.open(\"http://wpa.qq.com/msgrd?v=3&uin="+qq1+"&site=qq&menu=yes\", \"_top\");'>");
	document.write("	</div>");
	document.write("	<div id='msn_online'>");
	document.write("	  <img alt='在线MSN咨询' width='83px' height='24px' src='" + img_path + "/spacer.gif' onclick='javascript:window.open(\"http://wpa.qq.com/msgrd?v=3&uin="+qq2+"&site=qq&menu=yes\", \"_blank\");'>");
	document.write("	</div>");
	document.write("	<div id='contact_us1'>");
	document.write(" <a href='" + contact_us + "' target='_blank' ><img width='103px' height='30px' alt='联系我们' src='" + img_path + "/spacer.gif'></a>");
	document.write("</div>");
	document.write("<div id='contact_us2'>");
	document.write(" <img width='98px' height='16px' alt='联系我们' src='" + img_path +"/spacer.gif'>");
	document.write("</div>");
	document.write("<div id='servicesboxnav'><br>");
	document.write("<a target='_top' href='http://wpa.qq.com/msgrd?v=3&uin="+qq1+"&site=qq&menu=yes'>在线客服</a><br>");
	document.write("</div>");
	document.write("</div>");
	document.write("</div>");
	// end qq body

	document.write("</div>");
	document.write("<div id='divMenu' onmouseover='OnlineOver();'><img src='" + img_path + "/onlineicon.gif' class='press' alt='在线咨询'></div>");
	document.write("</div>");
	initFloatTips();
}
var tips; 
var theTop = 200 /* 这是默认高度,越大越往下 */; 
var old = theTop;
function initFloatTips() {
   tips = document.getElementById('divQQbox');
   moveTips();
};
function moveTips() {
  var tt=50;
  if (window.innerHeight) {
    pos = window.pageYOffset
  }
     else if (document.documentElement && document.documentElement.scrollTop) {
     pos = document.documentElement.scrollTop
    }
     else if (document.body) {
     pos = document.body.scrollTop;
     }
     pos=pos-tips.offsetTop+theTop;
     pos=tips.offsetTop+pos/10;
     if (pos < theTop) pos = theTop;
    if (pos != old) {
     tips.style.top = pos+"px";
     tt=10;
   }
    old = pos;
     setTimeout(moveTips,tt);
}

// initFloatTips();
function OnlineOver(){
   document.getElementById("divMenu").style.display = "none";
   document.getElementById("divOnline").style.display = "block";
   document.getElementById("divQQbox").style.width = "170px";
}

function OnlineOut(){
   document.getElementById("divMenu").style.display = "block";
   document.getElementById("divOnline").style.display = "none";
}

function hideMsgBox(theEvent){ // theEvent用来传入事件，Firefox的方式
　  if (theEvent){
　  var browser=navigator.userAgent; // 取得浏览器属性
　  if (browser.indexOf("Firefox")>0){ // 如果是Firefox
　　 if (document.getElementById('divOnline').contains(theEvent.relatedTarget)) { // 如果是子元素
　　 return; // 结束函式
   } 
   } 
   if (browser.indexOf("MSIE")>0){ // 如果是IE
   if (document.getElementById('divOnline').contains(event.toElement)) { // 如果是子元素
   return; // 结束函式
   }
   }
  }
   /* 要执行的操作 */
   document.getElementById("divMenu").style.display = "block";
   document.getElementById("divOnline").style.display = "none";
}

