<?php
header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
header('content-type:text/javascript; charset=utf-8');
/**
 * 参数支持说明
 * 1、自定义图标：针对行业平台用户。只支持固定模式。参数: on_img,off_img
 * 2、自定义在线进入页面。参数: onurl
 * 2、自定义离线留言页面。参数: lyurl,lytype
 * lytype=1：对话窗口直接跳转到留言页面；lytype＝0：在信息框中提示 留言链接
 * 3、自定义用户信息。参数: username,userinfo
 * userinfo将以title形式展示
 * 4、自定义单位简介内容。参数: introurl
 * 5、合作伙伴标识：还未实际应用。参数: copartner
 * 6、u_cust_id，u_cust_name 是为APP用户开发的参数，直接将用户的信息存入cus_user表
 * 7、u_stat_id，给第三方用的数据统计ID
 * 阿里旺旺代码：
 * 国际版：http://amos.alicdn.com/msg.aw?v=2&uid=帐号&site=enaliint&s=21&charset=UTF-8
 * 国内版：http://amos.alicdn.com/msg.aw?v=2&uid=帐号&site=cnalichn&s=10&charset=UTF-8
 **/
$arg = get_value('arg');
if ($arg == '') exit();
//区分HTTP请求和HTTPS请求
$http = 'http';
if ( (isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == "on") || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' )) {
    $http = 'https';
}


if (stripos($_SERVER["HTTP_USER_AGENT"], 'msie 6') !== false && !isset($_GET['mycharset'])) {
	$all = $_GET['old_query'];
	$sss = $_SERVER['QUERY_STRING'];
	echo <<< html
	(function(){
		var scripts = document.getElementsByTagName('script'), s_arr = [];
		for (var i = 0, L = scripts.length; i < L; i++) {
			s_arr[i] = scripts[i]; // 先复制scripts,阻断getElementsByTagName动态更新 
		}
		for (var i = 0, L = s_arr.length; i < L; i++) {
			var script = s_arr[i], script_src = script.src.toLowerCase();
			if (/kf.php/.test(script_src) && new RegExp('$all','i').test(script_src) && !/mycharset=utf8/.test(script_src)) {
				var s = document.createElement('script');
				s.charset = 'utf-8';
				s.src = "$http://{$_SERVER['HTTP_HOST']}/kf.php?{$_SERVER['QUERY_STRING']}&mycharset=utf8";
				script.parentNode.insertBefore(s, script);
				script.parentNode.removeChild(script);
			}
		}
	})();
html;
exit();
}
define("IN_OK", true);
require_once ("include/global_kf.php");
require_once ($www_path . "/include/memcache_function_kf.php");


//检测是否是推广链接
$tglink = 1;
$tglink_parma = parse_url($_SERVER['HTTP_REFERER']);
parse_str($tglink_parma['query'],$refer_parm_arr);
if(!empty($refer_parm_arr['tgse']) && !empty($refer_parm_arr['tgkwd'])) {
    $search_arr = array(
        'baidu'=>'wd=',
        'haosou'=>'q=',
        'sogou'=>'query=',
        'google'=>'q=',
        'youdao'=>'q=',
        'sm'=>'q=',
    );
    $tglink = 'http://www.' . $refer_parm_arr['tgse'] . '.com/s?' .  $search_arr[$refer_parm_arr['tgse']] . urldecode($refer_parm_arr['tgkwd']);
}

$powered_by_53kf_url = 'http://www.53kf.com';
$powered_by_53kf_txt = 'Powered by 53KF';
$power_by_53kf_style = ';font-family: Microsoft YaHei;font-size:10px;-webkit-text-size-adjust:none';
$question = get_value("question");
if ($question != "") $question = "&question=" . urlencode($question);
$record_url = get_value("record_url");
$domain_name = $cfg["prefix"] . $arg;
$style_id = get_value("style", 1);
$mem_re = mem_get($domain_name, array("style" => $style_id));
$company_name = $mem_re['company']['name'];
if ($mem_re === false) return;
$style_type = $mem_re["style_type"];

$visitorurl = "webCompany.php";

$visit_uuid = php_uuid();
$in_timestamp = time();
$in_time = date('Y-m-d H:i:s',$in_timestamp);

//主站URL
$base_host = $cfg["base_host"];
$master_host = $cfg["master_host"] . "." . $cfg["base_host"];
$companyid = $mem_re["company"]["id"];
$talk_host = $_SERVER['HTTP_HOST'];
$server_path = "$http://" . $talk_host;
$styles = $mem_re["company_style"];
if ($style_id > count($styles))
	$style_id = 1;
$style_real_id = $styles[$style_id - 1]["id"];
$referer = "&referer={hz6d_referer}"; // 用于在window.open中替换成当前访问页面
$keyword = "{hz6d_keyword}";
$user_agent = "";
if (strpos($_SERVER["HTTP_USER_AGENT"], "TheWorld") !== false)
{
	$user_agent = "TheWorld";
}

$land_page = $_SERVER['HTTP_REFERER']?$_SERVER['HTTP_REFERER']:'';//着陆页面
if(!$_COOKIE["land_page_$companyid"]) {
    setcookie("land_page_$companyid", $land_page, 0, "/", '.' . $cfg['base_host']);
}

$share_hidden = 0; //not hidden 1:hidden
$share_close = 1; //display 2:none
$sharebtn_pos_model = 1; //动态 2: fixed
$sharebtn_l_position = 1; //左侧 2:right
$sharebtn_v_position = 1; //顶部 2:bottom
$sharebtn_v_distance = 150;
$left_share_btn = 'skyblue';
$right_share_btn = 'skyblue';
$share_config_id_arr = array('share_hidden','share_close','sharebtn_pos_model','sharebtn_l_position','sharebtn_v_position','sharebtn_v_distance','left_share_btn','right_share_btn');

$re_config_no_style = get_style_result($mem_re["company_config"], 0);
$language = "cn";
$m_language = "cn";
$ivt_tpl = "";
$company_tpl = "crystal_blue";
if ($re_config_no_style !== false)
{
	foreach ($re_config_no_style as $vv)
	{
		if (get_config_value($vv["config_id"], $vv["config_value"], "company_tpl", $company_tpl))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "default_lang", $language))
			continue;
    for ($i = 0; $i < count($share_config_id_arr); $i++)
    {
      if(get_config_value($vv["config_id"],$vv["config_value"],"$share_config_id_arr[$i]",$$share_config_id_arr[$i]))
        break;
    }
	}
}
// 获取真正风格的所有设置
$re_config = get_style_result($mem_re["company_config"], $style_real_id);
//////////////设置中心->界面样式设置->客服图标////////////////////////
$tb_close = 0; //图标上关闭按钮
$powered_by_53kf = 1; //显示版权信息
$hidden = "0"; //1：隐藏客服图标
$zdytb = "no"; //yes：使用自定义图标
$zdyssan = "no"; //yes：使用自定义伸缩按钮图标
//$iframe_flag=""; //1：图标显示在flash上
$img_on = ""; //在线图标URL
$img_off = ""; //离线图标URL
$right_hidden_img = $left_hidden_img = $left_list_ssan = $right_list_ssan = 'green';//伸缩按钮图标默认为 绿色
$height = 0; //图片高度
$width = 0; //图片宽度
$posmodel = ""; //1：浮动 2：固定 3：浮动固定 4：浮动伸缩
$showmodel = "2"; //1：左侧 2：右侧
$v_showmodel = "1"; //1：顶部 2：底部
$offset_height = ""; //top
$offset_width = ""; //right margin
$offset_left_width = ""; //left margin
//$logo_id = 1087; //默认客服图标
$logo_id = '';

$close_icon = "img/kflogo/close.gif"; //默认关闭图标
$close_icon_right = "0";
$close_icon_top = "0";
//////////////////////////////////////////////////////////////////////
$charset = "GBK";
//////////设置中心->指定客服设置//////////////////////////////////////
$kf = ""; //指定客服 存放具体人员或部门ID或分组ID
$kflist = "off"; //是否显示客服列表 on：显示
$zdkf_type = "1"; //部门或人员或分组 1：人员 2：部门 3:分组
$zdyurl = "";
$kf_type = 2; //1:列表模式 2:图标模式
$kf_other = "off"; //如指定客服不在线，是否到其他客服 off：直接留言
$kf_professor = ""; //无用
$list_type = "blue"; //默认列表样式
$list_width = 130; //默认列表宽度
$list_title = "在线客服"; //默认列表标题
$list_phone = ""; //默认列表电话
$qyfl = "no"; //区域分流 yes：启用
$local_first = "no"; //无用
$kf_city = ""; //图标范围限制
$kf_show = 1; //列表模式：隐藏离线客服
$dept_man_show = 1; //列表模式：指定客服，按部门显示时，显示部门客服
$kf_expand = 1; //列表模式默认展开
$tb_on_str = $tb_off_str = ''; //用于保存图标字符串
$zdytb_53kf_on = $zdytb_53kf_off = ''; // 用于保存自定义图标字符串
//////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////
// 400电话相关
//////////////////////////////////////////////////////////////////////
$etel = "off";
$etel_auto_code = "0";
$now_temp = '';
if ($re_config !== false)
{
	foreach ($re_config as $vv)
	{
		if (get_config_value($vv["config_id"], $vv["config_value"], "hidden", $hidden))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "tb_close", $tb_close))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "powered_by_53kf", $powered_by_53kf))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "zdytb", $zdytb))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "zdyssan", $zdyssan))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "on_img", $img_on))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "off_img", $img_off))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "right_hidden_img", $right_hidden_img))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "left_hidden_img", $left_hidden_img))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "right_list_ssan", $right_list_ssan))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "left_list_ssan", $left_list_ssan))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "height", $height))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "width", $width))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "pos_model", $posmodel))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "show_model", $showmodel))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "offset_height", $offset_height))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "offset_width", $offset_width))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "offset_left_width", $offset_left_width))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "logo_id", $logo_id))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "charset", $charset))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "language", $language))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "m_language", $m_language))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "kf", $kf))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "zdkf", $kflist))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "zdkf_type", $zdkf_type))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "kf_type", $kf_type))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "zdyurl", $zdyurl))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "ivt_off_title", $ivt_off_title))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "ivt_off_content", $ivt_off_content))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "kf_city", $kf_city))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "kf_show", $kf_show))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "dept_man_show", $dept_man_show))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "qyfl", $qyfl))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "local_first", $local_first))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "kf_professor", $kf_professor))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "company_tpl", $company_tpl))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "list_type", $list_type))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "kf_expand", $kf_expand))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "list_width", $list_width))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "list_title", $list_title))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "list_phone", $list_phone))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "icon_l_position", $icon_l_position))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "icon_v_position", $icon_v_position))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "icon_l_distance", $icon_l_distance))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "icon_v_distance", $icon_v_distance))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "etel", $etel))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "etel_auto_code", $etel_auto_code))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "zdytb_53kf_on", $zdytb_53kf_on))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "zdytb_53kf_off", $zdytb_53kf_off))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "mobile_config", $mobile_config))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "mobile_icon", $mobile_icon))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "mobile_invite", $mobile_invite))
			continue;
        if (get_config_value($vv["config_id"], $vv["config_value"], "mobile_chat", $mobile_chat))
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "companysite", $companysite))//公司站点
			continue;
		if (get_config_value($vv["config_id"], $vv["config_value"], "now_temp", $now_temp))//当前在用模版
			continue;
		if($now_temp !='')
		{
			$nums = str_replace('temp_','',$now_temp);
			if (get_config_value($vv["config_id"], $vv["config_value"], "on_zdytb_$nums", $onval_arr))//当前在用模版
				continue;
			if (get_config_value($vv["config_id"], $vv["config_value"], "off_zdytb_$nums", $offval_arr))//当前在用模版
				continue;
			if (get_config_value($vv["config_id"], $vv["config_value"], "on_zdytblist_$nums", $listval_arr))//当前在用模版
				continue;
			if (get_config_value($vv["config_id"], $vv["config_value"], "temp_$nums", $now_pzhi))//当前在用模版
				continue;
		}
			continue;
	}
}
if($onval_arr=='' && $offval_arr=='' && $logo_id==''){
	$now_temp = 'temp_111';
	$onval_arr = '<div id="KFLOGO" class="Lelem" maxwidth="400" maxheight="400" minwidth="100" minheight="100" style="width: 130px; height: 140px; position: relative; z-index: 10000;"><div class="Lelem" type="img" operating="KF" style="display: block; cursor: pointer; position: absolute; top: 0px; left: 0px; z-index: 10001; width: 108px; height: 122px;"><img style="width: 108px; height: 122px;" src="../style/setting/ver06/img/icon/logo-skin/click_btn/clickbtn_4.png"></div></div>';
	$offval_arr = '<div id="KFLOGO" class="Lelem" maxwidth="400" maxheight="400" minwidth="100" minheight="100" style="width: 130px; height: 140px; position: relative; z-index: 10000;"><div class="Lelem" type="img" operating="KF" style="display: block; cursor: pointer; position: absolute; top: 0px; left: 0px; z-index: 10001; width: 108px; height: 122px;"><img style="width: 108px; height: 122px;" src="../style/setting/ver06/img/icon/logo-skin/offline_img/clickbtn_4.png"></div></div>';
}
//获取自定义图标信息 new
if($onval_arr || $offval_arr || $listval_arr)
{
	//在线客服
	if($onval_arr)
	{
		$onval_arr = htmlspecialchars_decode($onval_arr, ENT_QUOTES);
		$onval_arr = str_replace('../',"$http://".$talk_host.'/',$onval_arr);
		$is_onzdytb = 1;
	}
	if($offval_arr)
	{
		$offval_arr = htmlspecialchars_decode($offval_arr, ENT_QUOTES);
		$offval_arr = str_replace('../',"$http://".$talk_host.'/',$offval_arr);
		$is_offzdytb = 1;
	}
	if($listval_arr)
	{
		$listval_arr = htmlspecialchars_decode($listval_arr,ENT_QUOTES);
		$listval_arr = str_replace('../',"$http://".$talk_host.'/',$listval_arr);
		$tblist_arr = str_replace('"', '\"', $listval_arr);
		$is_zdylist = 1;
	}
	if($now_pzhi)
	{
		$tmpl_con = json_decode($now_pzhi,true);
		$langss = explode('_',$tmpl_con['tmpl_id']);
		$languages = $langss[0];
	}
}

//获取自定义图标信息 end
//检测访客网站域名
$is_setDomain = is_setDomain($companysite);
if($is_setDomain === false) return;

//增加代码容错性
if ($company_tpl == "")
	$company_tpl = "crystal_blue";
//水晶蓝最大化
$resize = "no";
if ($company_tpl == "crystal_blue")
	$resize = "yes";
else
	$resize = "no";
if (isset($agent_config))
{
	//此处进行风格继承
	if (get_style_lock("logo"))
	{
		get_agent_config_value("logo_id", $logo_id);
		get_agent_config_value("zdytb", $zdytb);
		get_agent_config_value("on_img", $img_on);
		get_agent_config_value("off_img", $img_off);
		get_agent_config_value("width", $width);
		get_agent_config_value("height", $height);
		get_agent_config_value("pos_model", $posmodel);
		get_agent_config_value("show_model", $showmodel);
		get_agent_config_value("offset_height", $offset_height);
		get_agent_config_value("offset_width", $offset_width);
	}
	if (get_style_lock("zdfq"))
	{
		get_agent_config_value("charset", $charset);
	}
	if (get_style_lock("zdyurl"))
	{
		get_agent_config_value("zdyurl", $zdyurl);
	}
}

require_once ($proj_path . "/templates/company_tpl/$company_tpl/tpl.config.php");
$company_tpl_height = $CompanyTplCfg["height"];
$company_tpl_width = $CompanyTplCfg["width"];
$charset = get_value("charset", $charset);
$ocharset = $charset;
$charset = "&charset=" . $charset;
// 图标位置旧数据兼容处理
if (is_numeric($icon_l_position))
	$showmodel = $icon_l_position; //左侧，右侧
if (is_numeric($icon_v_position))
	$v_showmodel = $icon_v_position; //顶部，底部
if ($showmodel == '1')
	$offset_width = $offset_left_width;
if (is_numeric($icon_l_distance))
	$offset_width = $icon_l_distance; //水平位置
if (is_numeric($icon_v_distance))
	$offset_height = $icon_v_distance; //垂直位置
// 数据库中没有设置值
if ($posmodel != '1' && $posmodel != '2' && $posmodel != '3' && $posmodel != '4')
	$posmodel = '1';
if ($showmodel != '1' && $showmodel != '2')
	$showmodel = '1';
if (!is_numeric($offset_height))
	$offset_height = 200;
if (!is_numeric($offset_width))
	$offset_width = 1;
if ($posmodel == '4')
	$offset_width = 1;
$hangye = 0;
if (isset($_GET["on_img"]) && isset($_GET["off_img"]))
{
	if (get_config($mem_re, "hangye"))
	{
		$hangye = 1;
		$img_on = filterSQL($_GET["on_img"]);
		$img_off = filterSQL($_GET["off_img"]);
		$posmodel = '2';
	}
}
if ($img_on == "" || $img_off == "")
{
	$img_on = "";
	$img_off = "";
}
if ($img_on != "")
{
	if ($zdytb == "no" && $hangye == 0)
	{ //没有自定义
		get_logo_info();
	}
	elseif ($height == 0 || $width == 0)
  {
    $posmodel = '2';
  }
}
else
{ //没有自定义
	get_logo_info();
}

// 检查是否为IE6
if (isBrowserIE6() && $posmodel == '3')
{
	$posmodel = '1';
}
$list_log_flag = true;
$kf_version_type = $cfg["version_type"];
//客服图标的处理
if (strpos($img_on, "http://") === false && strpos($img_on, "https://") === false)
{
	$img_on = "$http://" . $talk_host . "/" . $img_on;
}
if (strpos($img_off, "http://") === false && strpos($img_off, "https://") === false)
{
	$img_off = "$http://" . $talk_host . "/" . $img_off;
}
if (isset($_GET["default"])) default_config();
if (get_value("kf") != "")
{
	$kf = get_value("kf", $kf);
	$kflist = get_value("kflist", $kflist);
	$zdkf_type = get_value("zdkf_type", $zdkf_type);
	$kf_other = get_value("kf_other", $kf_other);
}
set_zdkf_params($style_type);
if ($kflist == "yes") $kflist = "on";
elseif ($kflist == "no") $kflist = "off";
$lang = $language;
$language = "&language=" . $language;
$m_language = "&language=" . $m_language;
$style_id = "&style=" . $style_id;

$test_do = "&test_do=".$_GET["test_do"];

/*通用接口*/

$onurl = "";
if (isset($_GET["onurl"])) $onurl = "&onurl=" . urlencode(filterSQL($_GET["onurl"]));

$lytype = 0;
if (isset($_GET["lytype"]) && $_GET["lytype"] != "") $lytype = filterSQL($_GET["lytype"]) + 0;
$lytype = "&lytype=" . $lytype;

$lyurl = "";
if (isset($_GET["lyurl"])) $lyurl = "&lyurl=" . urlencode(filterSQL($_GET["lyurl"]));

$copartner = ""; // the value is just like shopex
if (isset($_GET["copartner"])) $copartner = "&copartner=" . filterSQL($_GET["copartner"]);

$username = "";
if (isset($_GET["username"])) $username = "&username=" . urlencode(filterSQL($_GET["username"]));

$userinfo = "";
if (isset($_GET["userinfo"])) $userinfo = "&userinfo=" . urlencode(filterSQL(htmlspecialchars($_GET["userinfo"], ENT_QUOTES)));

$introurl = "";
if (isset($_GET["introurl"])) $introurl = "&introurl=" . urlencode(filterSQL($_GET["introurl"]));

$u_stat_id = get_value('u_stat_id');
$u_stat_id = $u_stat_id == '' ? '' : '&u_stat_id='.$u_stat_id;

//OK网接口

$brief = "";
if (isset($_GET["brief"])) $brief = "&brief=" . urlencode(filterSQL($_GET["brief"]));

$logo = "";
if (isset($_GET["logo"])) $logo = "&logo=" . urlencode(filterSQL($_GET["logo"]));

$isonline = 0;
$worker = $mem_re["worker"];
$worker_online = $mem_re["worker_online"];

/* 客服在线信息从redis获取 开始 */
$slave_count = count($cfg['redis_slave']);
if($slave_count < 2) {
    $slave_tag = 0;
}else{
    $slave_tag = mt_rand(0,$slave_count-1);
}
$redis = new Redis();
$redis->connect($cfg['redis_slave'][$slave_tag]['redis_host'],$cfg['redis_slave'][$slave_tag]['redis_port'],1);

/*
try{
    $redis->auth($cfg['redis_key']);
    $redis_re_tmp = $redis->sMembers("status.com.$companyid");//获取在线的ID6D
}catch(Exception $e){}

if($redis_re_tmp) {
    foreach($redis_re_tmp as $v) {
        $redis_re[$v] = $redis->hmGet("status.kf.$companyid.$v",array('im_conn_server','pc.isfln','id6d'));//根据在线ID6D获取相关信息
    }        
}

if($redis_re || $redis_re_tmp !== null) {
    foreach($worker_online as $k => $v) {
        if(isset($redis_re[$k]) && ($redis_re[$k]['pc.isfln'] == 0 || $redis_re[$k]['im_conn_server'])) {
            $worker_online[$k]['online'] = 1;
            $worker_online[$k]['state'] = 1;                   
        } else {
            $worker_online[$k]['online'] = 0;
        }        
    }    
}
*/

$lua_script = <<<LUA
	local re_table = {}
	local id6ds = redis.call('smembers', 'status.com.$companyid')
	for key, id6d in pairs(id6ds) do
        table.insert(re_table,redis.call('hmget', 'status.kf.$companyid.'..id6d ,'im_conn_server','pc.isfln','id6d'))
	end
	return re_table
LUA;
try{
    $redis->auth($cfg['redis_key']);
    $redis_re_lua=$redis->eval($lua_script);
}catch(Exception $e){}

foreach($redis_re_lua as $k => $v) {
    $redis_re[$v[2]] = $v;//id6d作为KEY
}

if($redis_re || $redis_re_lua !== null) {
    foreach($worker_online as $k => $v) {
        if(isset($redis_re[$k]) && ($redis_re[$k][1] == 0 || $redis_re[$k][0])) {
            $worker_online[$k]['online'] = 1;
            $worker_online[$k]['state'] = 1;                   
        } else {
            $worker_online[$k]['online'] = 0;
        }        
    }    
}

/* redis操作 结束 */

$zdkf = true;
//区域分流模块
$qyfl_group = "";
if ($style_type == 0 && $qyfl == 'yes')
{
	$qyfl_group = qyfl_kf_set();
}
$kfonline = 0; //客服在线，不管是否指定客服
$order_groups = get_order_groups();

if ($kf == "")
{
	if ($worker_online !== false)
	{
        if($zdkf_type == 3){
            foreach($order_groups as $k => $v){
                foreach($v['workers'] as $n){
                    if ($worker_online[$n['id6d']]["online"] == 1 && $worker_online[$n['id6d']]["state"] == 1 && is_work_time($n['id6d'])){
                        $isonline = 1;
                        $kfonline = 1;
                        break 2;
                    }
                }
            }
        }else{
            foreach ($worker_online as $online)
			{
				if ($online["online"] == 1 && $online["state"] == 1 && is_work_time($online['id6d']))
				{
					$isonline = 1;
					$kfonline = 1;
					break;
				}
			}
        }
	}
}
else
{
	foreach ($worker as $k => $v)
	{
		if (isset($worker_online[$k]))
		{
			$worker[$k]["online"] = $worker_online[$k]["online"];
			$worker[$k]["state"] = $worker_online[$k]["state"];
		}
	}
        $kfs = explode(",", $kf);
        
        if ($zdkf_type == "1"){
            $temp_q = "worker_id";
        }else{
            $temp_q = "group_id";
        }
        if($zdkf_type == '3'){
            foreach($order_groups as $k => $v){
                foreach($v['workers'] as $n){
                    if ($kfonline == 0 && $worker[$n['id6d']]['online'] == 1 && $worker[$n['id6d']]['state'] == 1 && is_work_time($n['id6d'])){
                        $kfonline = 1;
                    }
                    if ($kf_other == 'on'){
                        if($worker[$n['id6d']]['online'] == '1' && $worker[$n['id6d']]['state'] == 1 && is_work_time($n['id6d'])){
                            $isonline = 1;
                            break 2; 
                        }
                    }else{
                        if ($worker[$n['id6d']]['online'] == '1' && $worker[$n['id6d']]['state'] == 1 && array_search($v['group_id'], $kfs, true) !== false && is_work_time($n['id6d'])){
                                $isonline = 1;
                                break;
                        }
                    }
                }
            }
        }else{
            foreach ($worker as $v)
            {

                    if ($kfonline == 0 && $v["online"] == 1 && $v["state"] == 1 && is_work_time($v['id6d']))
                            $kfonline = 1;
                    if ($kf_other == 'on')
                    {
                            if ($v["online"] == 1 && $v["state"] == 1 && is_work_time($v['id6d']))
                            {
                                    $isonline = 1;
                                    break; 
                            }
                    }
                    else
                    {
                            if ($v["online"] == 1 && $v["state"] == 1 && array_search($v[$temp_q], $kfs, true) !== false && is_work_time($v['id6d']))
                            {
                                    $isonline = 1;
                                    break;
                            }
                    }
            }
        }
}
$kf_zd = $kf;
$kf = "&kflist=" . $kflist . "&kf=" . $kf . "&zdkf_type=" . $zdkf_type;

if ($kf_other == "on")
{
	$kf_other_style = get_value("kf_other_style", "0");
	$kf .= "&kf_other=on&kf_other_style=" . $kf_other_style;
}

if($zdkf_type == 1){
    $group_arr = get_group_worker();
    $group_arr = change_order($group_arr);
}else if($zdkf_type == 2){    //兼容部门
    if ($kf_type == 1)
    {
            $worker_group_sort = $mem_re["worker_group_sort"];
            $group_arr = array();
            foreach ($worker_group_sort as $key => $value)
            {
                    $v = $worker[$value["id6d"]];
                    $kfarr = array();
                    $kfarr = explode(",", $kf_zd);
                    if ($zdkf_type == "1")
                    {
                            if ($kf_zd != "" && array_search($v["worker_id"], $kfarr, true) === false)
                                    continue;
                    }
                    else
                    {
                            if ($kf_zd != "" && array_search($v["group_id"], $kfarr, true) === false)
                                    continue;
                    }
                    if ($v["group_id"] === '0' || $v["group_id"] == null)
                    {
                            $group_name = "未分组";
                            if (strpos($language, "en") !== false)
                            {
                                    $group_name = "Default group";
                            }
                            $v["group_id"] = '0';
                    }
                    else
                    {
                            $group_name = $v["group_name"];
                    }
                    if (!isset($group_arr[$v["group_id"]]))
                    {
                            $group_arr[$v["group_id"]] = array();
                            $group_arr[$v["group_id"]]["worker_name"] = array();
                            $group_arr[$v["group_id"]]["online"] = array();
                            $group_arr[$v["group_id"]]["state"] = array();
                            $group_arr[$v["group_id"]]["worker_id"] = array();
                            $group_arr[$v["group_id"]]["online_num"] = 0;
                    }
                    $is_work = ($worker_online[$value["id6d"]]["online"] && is_work_time($value['id6d']))?1:0;
                    $group_arr[$v["group_id"]]["name"] = $group_name;
                    $group_arr[$v["group_id"]]["online"][] = $is_work;
                    $group_arr[$v["group_id"]]["state"][] = $worker_online[$value["id6d"]]["state"];
                    if ($is_work == 1 && $worker_online[$value["id6d"]]["state"] == 1)
                    {
                        $group_arr[$v["group_id"]]["online_num"]++;
                    }
                    $group_arr[$v["group_id"]]["worker_name"][] = $v["bname"];
                    $group_arr[$v["group_id"]]["worker_id"][] = $v["worker_id"];
            }
    }
    $group_arr = change_order($group_arr);
}
$myip = get_ip();
$ipinfo = "";
$ipinfo=get_ip_info($myip);
if("" != $ipinfo['isp'])
{
	$ipstr = $ipinfo['area']."[".$ipinfo['isp']."]";
}
else
{
	$ipstr = $ipinfo['area'];
}
$ipstr = urlencode($ipstr);

$is_visible = true;
if ($kf_city != '')//只在选择的区域显示
{
	$is_visible = false;
	$arr_c = explode(',', $kf_city);
	foreach ($arr_c as $k => $v)
	{
		if (strpos($ipinfo['area'], $v) !== false)
		{
			$is_visible = true;
			break;
		}
	}
	unset($arr_c);
}
if (!$is_visible)
{
	$hidden = '1';
}
//关闭图片的选择
if ($kf_type == 1 && $list_type != "blue")
{
	$close_icon = "img/kflist/" . $list_type . "_close.gif";
}
$tpl_name = "&tpl_name=" . $company_tpl;
$tpl_width = "&tpl_width=" . $company_tpl_width;
$tpl_height = "&tpl_height=" . $company_tpl_height;
//自定义URL
if (trim($zdyurl) != "" && strpos($zdyurl, "http://") === false)
{
	$zdyurl = "$http://" . $zdyurl;
}
$is_zdyurl = 0;
if (trim($zdyurl) != "")
	$is_zdyurl = 1;
if (strpos($zdyurl, "?") === false)
{
	$zdyurl .= "?arg=$arg$style_id$kf$language$username$userinfo$charset$introurl$onurl$lytype$lyurl$copartner$referer$keyword&tpl=$company_tpl$logo$brief$question";
}
else
{
	$zdyurl .= "arg=$arg$style_id$kf$language$username$userinfo$charset$introurl$onurl$lytype$lyurl$copartner$referer$keyword&tpl=$company_tpl$logo$brief$question";
}
//自定义URL结束

//客户识别代码
//guest_id
$time = strtotime('2030-01-01');
if (isset($_COOKIE["guest_id"]) && !empty($_COOKIE["guest_id"])) {
	$guest_id = $_COOKIE["guest_id"];
} else {
	$guest_id =  new_talk_id();
	setcookie("guest_id", $guest_id, $time, "/", '.' . $cfg['base_host']);
}

// 为APP客户开放的接口 直接将用户信息存入cus_user 
if(!empty($_GET['u_cust_id']) && !empty($_GET['u_cust_name'])) {
    $data = array('u_cust_id'=>$_GET['u_cust_id'],'company_id'=>$companyid,'u_cust_name'=>$_GET['u_cust_name'],'guest_id'=>$guest_id);
    $res_guest_id = curl_post($_SERVER['HTTP_HOST'] . '/reg_m.php',$data);
    if($res_guest_id) {
        $guest_id = $res_guest_id;
        setcookie("guest_id", $guest_id, $time, "/", '.' . $cfg['base_host']);    
    }      
}

// 不想识别为手机访客的网站
$disable_mobile_company = array('72009369');
$debug = !!stripos($_SERVER["HTTP_REFERER"],'53debug');
$mobile_icon = json_decode($mobile_icon,true);
$is_mobile_os = (is_mobile_os() && (!in_array($companyid,$disable_mobile_company) || $debug) ) ? 1 : 0;

echo <<< HTML
(function(window, undefined) {
	var w = window,
		d = document,
		dd = d.documentElement,
		db = d.body,// db kf.php在head中时获取不到 
		head = d.head || d.getElementsByTagName("head")[0] || dd,
		isStrict = d.compatMode == "CSS1Compat",
		m = Math.max,
		ua = navigator.userAgent,
		np = navigator.platform,
		EN = w.encodeURIComponent,
		DE = w.decodeURIComponent;

	var $53 = function(id) {return d.getElementById(id) ? d.getElementById(id) : null};
	$53.version = '1.0.0';
	$53.global = {};
	$53.getKFscript = function(){
		if (typeof $53.global['{$kf_arg_style}'] == 'undefined' || $53.global['{$kf_arg_style}'] == null) {
			var scripts = document.getElementsByTagName('script'), len = scripts.length, i = 0;
			for(;i<len;i++){
				if (/kf\.php/img.test(scripts[i].src)) {
					$53.global['{$kf_arg_style}'] = scripts[i];
					break;
				}
			}
		}
		return $53.global['{$kf_arg_style}'];
	};
	$53.ready = (function(){
		var ie = !!(window.attachEvent && !window.opera),
			wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525),
			fn = [],
			run = function () {isReady = true; for (var i = 0; i < fn.length; i++) fn[i](); },
			d = document,
			isReady = false;
		return function (f) {
			if (d.body) {f();return;}
			if (isReady) {f();return;}
			if (!ie && !wk && d.addEventListener) return d.addEventListener('DOMContentLoaded', f, false);
			if (fn.push(f) > 1) return;
			if (ie) {
				(function () {
					if (!isReady) {
						try { d.documentElement.doScroll('left'); run(); }
						catch (err) { setTimeout(arguments.callee, 0); }
					}
				})();
			} else if (wk) {
				var t = setInterval(function () {
					if (/^(loaded|complete)$/.test(d.readyState))
						clearInterval(t), run();
				}, 0);
			}
		};
	})();
	$53.forEach = function(enumerable, iterator, context) {
		var i, n, t;
		if (typeof iterator == "function" && enumerable) {
			// Array or ArrayLike or NodeList or String or ArrayBuffer
			n = typeof enumerable.length == "number" ? enumerable.length: enumerable.byteLength;
			if (typeof n == "number") {
				if (Object.prototype.toString.call(enumerable) === "[object Function]") {
					return enumerable;
				}
				for (i = 0; i < n; i++) {
					t = enumerable[i];
					t === undefined && (t = enumerable.charAt && enumerable.charAt(i));
					iterator.call(context || null, t, i, enumerable);
				}
				// enumerable is number
			} else if (typeof enumerable == "number") {
				for (i = 0; i < enumerable; i++) {
					iterator.call(context || null, i, i, i);
				}
				// enumerable is json
			} else if (typeof enumerable == "object") {
				for (i in enumerable) {
					if (enumerable.hasOwnProperty(i)) {
						iterator.call(context || null, enumerable[i], i, enumerable);
					}
				}
			}
		}
		return enumerable;
	};
	$53.type = (function() {
		var objectType = {},
			nodeType = [, "HTMLElement", "Attribute", "Text", , , , , "Comment", "Document", , "DocumentFragment", ],
			str = "Array Boolean Date Error Function Number RegExp String",
			retryType = {
				'object': 1,
				'function': '1'
			},
			toString = objectType.toString;
		$53.forEach(str.split(" "), function(name) {
			objectType["[object " + name + "]"] = name.toLowerCase();
			$53["is" + name] = function(unknow) {
				return $53.type(unknow) == name.toLowerCase();
			}
		});
		return function(unknow) {
			var s = typeof unknow;
			return ! retryType[s] ? s: unknow == null ? "null": unknow._type_ || objectType[toString.call(unknow)] || nodeType[unknow.nodeType] || (unknow == unknow.window ? "Window": "") || "object";
		};
	})();
	$53.isObject = function(unknow) {
		return typeof unknow === "function" || (typeof unknow === "object" && unknow != null)
	};
	$53.isPlainObject = function(unknow) {
		var key, hasOwnProperty = Object.prototype.hasOwnProperty;

		if ($53.type(unknow) != "object") {
			return false;
		}
		if (unknow.constructor && !hasOwnProperty.call(unknow, "constructor") && !hasOwnProperty.call(unknow.constructor.prototype, "isPrototypeOf")) {
			return false;
		}
		for (key in unknow) {}
		return key === undefined || hasOwnProperty.call(unknow, key);
	};
	$53.extend = function(depthClone, object) {
		var second, options, key, src, copy, i = 1,
		n = arguments.length,
		result = depthClone || {},
		copyIsArray, clone;
		$53.isBoolean(depthClone) && (i = 2) && (result = object || {}); ! $53.isObject(result) && (result = {});
		for (; i < n; i++) {
			options = arguments[i];
			if ($53.isObject(options)) {
				for (key in options) {
					src = result[key];
					copy = options[key];
					if (src === copy) {
						continue;
					}
					if ($53.isBoolean(depthClone) && depthClone && copy && ($53.isPlainObject(copy) || (copyIsArray = $53.isArray(copy)))) {
						if (copyIsArray) {
							copyIsArray = false;
							clone = src && $53.isArray(src) ? src: [];
						} else {
							clone = src && $53.isPlainObject(src) ? src: {};
						}
						result[key] = $53.extend(depthClone, clone, copy);
					} else if (copy !== undefined) {
						result[key] = copy;
					}
				}
			}
		}
		return result;
	}
	$53.extend($53, {
		$: function(id) {
			return d.getElementById(id) ? d.getElementById(id) : null;
		},
		EN: EN,
		DE: DE,
		isStrict: isStrict,
		data: function(key, value) {
			if(typeof value == 'undefined') {
				return $53.global[key] === undefined ? null : $53.global[key];
			} else {
				$53.global[key] = value;
			}
		},
		trim: function(text) {
			return text == null ? "": (text + "").replace(new RegExp('(^[\\\\s\\\\t\\\\xa0\\\\u3000\\\\uFEFF]+)|([\\\\u3000\\\\xa0\\\\s\\\\t\\\\uFEFF]+\\x24)', 'g'), '');
		},
		getOs: function() {
			var allOs = ['iphone', 'android', 'macos', 'linux', 'win2008', 'win8', 'win7', 'winvista', 'win98', 'win2000', 'win2003', 'winxp', 'os_other'];
			var isWin = (np == "Win32") || (np == "Windows");
			if (isWin) {
				var winos = {
					'win98': '(Win98)|(Windows 98)',
					'win2000': '(Windows NT 5.0)|(Windows 2000)',
					'winxp': '(Windows NT 5.1)|(Windows XP)',
					'win2003': '(Windows NT 5.2)|(Windows 2003)',
					'win7': '(Windows NT 6.1)|(Windows 7)',
					'winvista': '(Windows NT 6.0)|(Windows Vista)',
					'win8': '(Windows NT 6.2)|(Windows 8)',
					'win2008': '(Windows NT 6.1)|(Windows 2008)'
				};
				for (var i in winos) {
					if (winos.hasOwnProperty(i) && (new RegExp(winos[i], 'i')).test(ua)) return i;
				}
			}
			var isMac = (np == "Mac68K") || (np == "MacPPC") || (np == "Macintosh") || (np == "MacIntel");
			if (isMac) return "macos";
			if ((np == "X11") && !isWin && !isMac) return "unix";
			if ((np.toLowerCase() + ua.toLowerCase()).indexOf('iphone') > -1) return 'iphone';
			if (np.toLowerCase().indexOf("linux") > -1 && ua.toLowerCase().indexOf('android') > -1) return 'android';
			if (np.indexOf("Linux") > -1) return "linux";
			return "os_other";
		},
		getBrowser: function() {
			var browsers = {
				'sogou': 'sogou',
				'maxthon': 'maxthon',
				'opera': 'opera',
				'qq': 'tencent',
				'uc': 'uc',
				'360': '360',
				'firefox': 'firefox',
				'chrome': 'chrome',
				'safari': 'safari',
				'ie10': 'msie 10',
				'ie9': 'msie 9',
				'ie8': 'msie 8',
				'ie7': 'msie 7',
				'ie6': 'msie 6',
				'ie5': 'msie 5'
			};
			for (var i in browsers) {
				if (browsers.hasOwnProperty(i) && (new RegExp(browsers[i], 'i')).test(ua)) return i;
			}
			return 'ua_other';
		},
		getScreen: function() {
			return screen.width + "_" + screen.height;
		},
		setCookie: function(key,value,options) {
			if (!$53.isCookieKey(key)) {return;}
			options = options || {};
			var expires = options.expires;
			if ('number' == typeof options.expires) {
				expires = new Date();
				expires.setTime(expires.getTime() + options.expires*1000);
			}
			document.cookie = key + "=" + EN(value)
			+ (options.path ? "; path=" + options.path : "")
			+ (expires ? "; expires=" + expires.toUTCString() : "")
			+ ("; domain=" + (options.domain ? options.domain : location.hostname))
			+ (options.secure ? "; secure" : "");
		},
		getCookie: function(key) {
			if ($53.isCookieKey(key)) {
				var reg = new RegExp('(^| )' + key + '=([^;]*)(;|\\x24)'), result = reg.exec(document.cookie);
				if (result) {
					var value = (result[2] === undefined || result[2] === null) ? '' : result[2];
				}
			}
			if ('string' == typeof value) {
				return DE(value);
			}
			return '';
		},
		isCookieKey:function(key) {
			return (new RegExp('^[^\\\\x00-\\\\x20\\\\x7f\\\\(\\\\)<>@,;:\\\\\\\\\\\\"\\\\[\\\\]\\\\?=\\\\{\\\\}\\\\/\\\\u0080-\\\\uffff]+\\x24')).test(key);
		},
		getWH: function() { // 获取窗口可用大小 
			return {
				W: (isStrict ? dd: d.body).clientWidth,
				H: (isStrict ? dd: d.body).clientHeight
			};
		},
		getSWH: function() { // 获取屏幕分辨率的大小
			return {
				W: screen.width,
				H: screen.height
			};
		},
		getS: function() {// 获取滚动距离 
			return {
				L: m(dd.scrollLeft, d.body.scrollLeft),
				T: m(dd.scrollTop, d.body.scrollTop)
			};
		},
		htmlDecode: function(text) {
			return text.replace(/&amp;/g, '&').replace(/&quot;/g, '\"').replace(/&#039;/g, '\'').replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&douhao/g, ",").replace(/&jinghao/g, '#');
		},
		creElm: function(o, t, a, loc) {
			loc = loc || 0;
			var b = d.createElement(t || 'div'), c = (a || d.body || dd);
			for (var p in o) {
				if (!o.hasOwnProperty(p)) continue;
				p == 'style' ? b[p].cssText = o[p] : b[p] = o[p];
				if(p == 'id' && $53(o[p])) $53(o[p]).parentNode.removeChild($53(o[p]));
			}
			if (!loc) return c.insertBefore(b, c.firstChild);
			else return $53.insertAfter(b, c.lastChild);
		},
		insertAfter: function(newEl, targetEl)
		{
			var parentEl = targetEl.parentNode;
			if(parentEl.lastChild == targetEl)
			{
				return parentEl.appendChild(newEl);
			}else
			{
				return parentEl.insertBefore(newEl,targetEl.nextSibling);
			}
		},
		createScript: function(id,url){
			$53.creElm({
				'id':id == '' ? 'hz6d_script_' + Math.random() : id,
				'src':url,
				'charset':'utf-8'
			},'script',head);
		},
		before: function(html, elem){
			var frag = d.createDocumentFragment(), div=d.createElement('div');
			div.innerHTML = html;
			frag.appendChild(div);
			return (elem.parentNode || d.body || dd).insertBefore(div.firstChild.cloneNode(true), elem);
			frag = null;
		},
		after: function(html, elem){
			var frag = d.createDocumentFragment(), div=d.createElement('div');
			div.innerHTML = html;
			frag.appendChild(div);
			return $53.insertAfter(div.firstChild.cloneNode(true), elem);
			frag = null;
		},
		insertFixed: function(html){ // 图标嵌入固定模式用 //
			$53.ready(function(){
				var script = $53.getKFscript(), elem = null;
				if (script.parentNode == head) elem = $53.before(html, d.body.firstChild);
				else elem = $53.after(html, script);
			});
		},
		getTimeTo24: function(){
			//get senconds time from now to tomorrow 00:00
			var d1 = new Date(),
				d2 = new Date();
			d1.setDate(d1.getDate() + 1);
			d1.setHours(0);
			d1.setMinutes(0);
			d1.setSeconds(0);
			return (d1.getTime() - d2.getTime())/1000;
		},
		json2str : function(json,code){
			var arr = [];
			var encode =  code == 'urlencode' ? $53.EN : function(data){return data};
			for(var i in json) {
				if (json.hasOwnProperty(i)) {
					arr.push(i + '=' + encode(json[i]));
				}
			}
			return arr.join('&');
		},
		addEvent : function( obj, type, fn ) {
			if ( obj.attachEvent ) {
				obj['e'+type+fn] = fn;
				obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
				obj.attachEvent( 'on'+type, obj[type+fn] );
			} else {
				obj.addEventListener( type, fn, false );
			}
		},
		removeEvent : function( obj, type, fn ) {
			if ( obj.detachEvent ) {
				obj.detachEvent( 'on'+type, obj[type+fn] );
				obj[type+fn] = null;
			} else {
				obj.removeEventListener( type, fn, false );
			}
		}
	});
	// window.open 方法重写 
	// 支持ie/ff/chrome/safari/opera 
	var _open = window.open;
	window.open = function(sURL, sName, sFeatures, bReplace) {
		if (sURL == undefined) {
			sURL = ''
		}
		if (sName == undefined) {
			sName = ""
		}
		if (sFeatures == undefined) {
			sFeatures = ""
		}
		if (bReplace == undefined) {
			bReplace = false
		}
		if (/webCompany.php|webClientMin.php/.test(sURL)) {
			sURL += '&timeStamp=' + new Date().getTime() + '&ucust_id=' + $53.EN($53.getCookie('ucust_id'));
		} else if ('$zdyurl' != '') {
			var _zdyurl = '$zdyurl';
			if (sURL.indexOf(_zdyurl) > -1) {
				sURL += '&timeStamp=' + new Date().getTime() + '&ucust_id=' + $53.EN($53.getCookie('ucust_id'));
			}
		}
		sURL = sURL.replace('&referer={hz6d_referer}',hz6d_referer);
		var win = _open(sURL, sName, sFeatures, bReplace);
		return win;
	}
	window.$53 = $53;
})(window);
	// set my site uid -> crm
	// set 53kf guest_id 设置UV 
	if (!$53.getCookie('53gid0')){
		$53.setCookie('53gid0','$guest_id',{
			expires:$53.getTimeTo24()
		});
		$53.data('is_uv',1);
	} else if($53.getCookie('53gid2')){
		$53.data('is_uv',0);
	}
	// 设置RV 
	if (!$53.getCookie('53gid1')){
		$53.setCookie('53gid1','$guest_id',{
			expires:86400
		});
		$53.data('is_rv',0);
	} else if($53.getCookie('53gid2')){
		$53.data('is_rv',1);
	}
	// 设置 新老访客 
	if(!$53.getCookie('53gid2')) {
		$53.setCookie('53gid2','$guest_id',{
			expires:10*365*24*3600
		});
		// new visitor
		$53.setCookie('visitor_type','new');
	} else if($53.getCookie('53gid2')) {
		// old visitor
		$53.setCookie('visitor_type','old');
	}
	// record once visit uuid
	if($53.getCookie('53uvid') != 1) {
		$53.setCookie('53uvid',1);
		$53.data('page_type',1);
	} else {
		$53.data('page_type',2);
	}
	$53.data('visit_uuid','$visit_uuid');
	$53.data('in_time','$in_time');
	$53.data('company_id','$companyid');
	$53.data('visit_num',$53.getCookie('53uvid'));

	var hz6d_referer = '&referer=' + $53.EN(window.location.href); //当前访问页面 
	var kf_success=1, kftype=2,
			powered_by_53kf_url = 'http://www.53kf.com',
			powered_by_53kf_txt = 'Powered by 53KF';
	// 获取访问的入口来源页面:搜索引擎/外部链接/直接输入 
	var hz6d_from_page = $53.getCookie("53kf_{$companyid}_keyword"),
	kf_{$companyid}_keyword_ok = $53.getCookie("kf_{$companyid}_keyword_ok");
	if (kf_{$companyid}_keyword_ok != 1)
	{   
	    if('$tglink' !== '1'){//是否是推广页面
            hz6d_from_page = '$tglink';        
        }else{
            hz6d_from_page = document.referrer;    
        }
		
	}
	$53.data('page_referer',hz6d_from_page);
	$53.setCookie("53kf_{$companyid}_keyword",hz6d_from_page,{'path':'/'});
	$53.setCookie("kf_{$companyid}_keyword_ok",1,{'path':'/'});
	hz6d_from_page_new = "&keyword=" + $53.EN(hz6d_from_page);
	
	function hz6d_html_replace(html)
	{   
	    if(html.indexOf('{hz6d_keyword}') == -1) {
           return html.replace(/%7Bhz6d_keyword%7D/gim, encodeURIComponent(hz6d_from_page_new) + "&tfrom=1"); 	       
	    }else{
	       return html.replace(/{hz6d_keyword}/gim, hz6d_from_page_new + "&tfrom=1");
	    }		
	}

	function hz6d_is_exist(html){
		if (typeof(hz6d_showContent)  == "function" && hz6d_showContent && typeof(hz6d_ID('hz6d_chatting_iframes')) != undefined){
			hz6d_showContent();
		}else{
			var new_clic = html.replace(/#liyc#/g,"\'");
			eval(decodeURIComponent(new_clic));
		}
	}
	function hz6d_is_exists(html,kf){
		if (typeof(hz6d_showContent)  == "function" && hz6d_showContent && typeof(hz6d_ID('hz6d_chatting_iframes')) != undefined){
			hz6d_showContent(kf);
		}else{
			eval(decodeURIComponent(html));
		}
	}
	// has defined <!DOCTYPE... > 

	function hasdoctype()
  {
		if (document.compatMode == "BackCompat")
		{
			ret = false;
		}
		else
		{
			ret = true;
		}
		return ret;
	}

	function detectBrowser()
	{
		var ret = "ie6"; // default
		var user_agent = navigator.userAgent;
		if (user_agent.indexOf("compatible") > -1)
		{
			if (user_agent.indexOf("MSIE 6.0") > -1)
			{
				ret = "ie6";
			}
			else if (user_agent.indexOf("MSIE 7.0") > -1)
			{
				ret = "ie7";
			}
			else if (user_agent.indexOf("MSIE 8.0") > -1)
			{
				ret = "ie8";
			}
			if (user_agent.indexOf("360") > -1)
			{
				ret = "360";
			}
		}
		else if (user_agent.indexOf("Gecko") > -1)
		{
			ret = "firefox";
		}
		if ("$user_agent" == "TheWorld")
		{
			ret = "TheWorld";
		}
		return ret;
	}
	
	// 间距小于步进，则移动间距的距离 
	function smoothMove(start, end)
	{
		var step = Math.abs(end - start);
		var forword = end - start;
		if (step > 2)
		{
			step = Math.ceil(step * 0.2) * (forword / Math.abs(forword));
		}
		else
		{
			step = step * (forword / Math.abs(forword));
		}
		posi = start + step;
		if (step > 0)
		{
			if (posi > end) posi = end;
		}
		else
		{
			if (posi < end) posi = end;
		}
		return posi;
	}
	
	var hasdoctype = hasdoctype();
	var browser = detectBrowser();
	// 点击图标设置变量 

	function setIsinvited()
	{
		try
		{
			onliner_zdfq = 2;
			if (acc_autotype == 3)
			{
				document.cookie = "onliner_zdfq{$companyid}=" + onliner_zdfq;
			}
		}
		catch (e)
		{}
	}
	var onliner_zdfq = $53.getCookie("onliner_zdfq{$companyid}"); // onliner_zdfq: 0.初始值 2.点击接受 3.点击拒绝 
	if (onliner_zdfq == "")
	{
		onliner_zdfq = 0;
		document.cookie = "onliner_zdfq{$companyid}=" + onliner_zdfq;
	}
	var hz6d_kf_type = $kf_type;
	var hz6d_pos_model = $posmodel;
	var hz6d_hidden = $hidden;
	var hz6d_close_icon = 0;
	
	function AccCallBack(){}
	// 加载ivt.php，即中间的接受邀请层 
	if (!$53("ivt_script") && !$is_mobile_os){
		//document.write("<scr"+"ipt src='$server_path/kf_ivt.php?arg=$arg$test_do$style_id&isonline=$isonline&kfonline=$kfonline&lang=$lang&resize=$resize$charset$kf"+ hz6d_referer + hz6d_from_page_new + "$lytype$lyurl$copartner$username$userinfo$introurl$brief$logo$question$tpl_name$tpl_width$tpl_height' type='text/javascript' id='ivt_script' charset='utf-8'></scr"+"ipt>");
		$53.createScript('ivt_script', '$server_path/kf_ivt.php?arg=$arg$test_do$style_id&isonline=$isonline&kfonline=$kfonline&lang=$lang&resize=$resize$charset$kf'+ hz6d_referer + hz6d_from_page_new + '$lytype$lyurl$copartner$username$userinfo$introurl$brief$logo$question$tpl_name$tpl_width$tpl_height$u_stat_id&' + Math.random());
	}
HTML;

if ($is_mobile_os)
{//移动客户开始
	$openurl = "$server_path/m.php?cid=$companyid$style_id$m_language$username$userinfo$charset$introurl$onurl$lytype$lyurl$copartner$referer$keyword&tpl=$company_tpl$logo$brief$question$u_stat_id";
	if ($is_zdyurl == 1) $openurl = $zdyurl;
	$mobile_config = json_decode($mobile_config,true);
	if(strpos($mobile_invite,"\&#039;")!==false) $mobile_invite = str_replace('\&#039;','&#039;',$mobile_invite);
	$mobile_invite = json_decode($mobile_invite,true);
	if(strpos($mobile_chat,"\&#039;")!==false) $mobile_chat = str_replace('\&#039;','&#039;',$mobile_chat);
    $mobile_chat   = json_decode($mobile_chat,true);
    if(strpos($mobile_chat['intr'],"&quot;")!==false) $mobile_chat['intr'] = str_replace('&quot;','\&quot;',$mobile_chat['intr']);
    $mobile_chat['intr']=html_entity_decode($mobile_chat['intr'],ENT_QUOTES);
    if(!isset($mobile_invite['is_open'])) $mobile_invite['is_open'] = 'yes';
	if(!isset($mobile_invite['timeout'])) $mobile_invite['timeout'] = '5';
    //手机版强制对话开启 邀请框和图标都不显示
    if(isset($mobile_chat['is_open']) && $mobile_chat['is_open'] != 0) {
        $mobile_invite['is_open'] = 'no';
        $mobile_icon['position'] = 'hidden';  
        $company_logo = empty($mobile_config['img']) ? 'style/setting/ver06/img/mobile/default_toux.png': $mobile_config['img'];
        $company_short = empty($mobile_config['company_short']) ? '': $mobile_config['company_short'];
        if($isonline) {
            $chat_face_img = 'on_face.png';
            $chat_word = '在线咨询';    
        } else {
            $chat_face_img = 'off_face.png';  
            $chat_word = '离线留言'; 
        }
        
        switch ($mobile_chat['colors']) {
            case 0:
              $chat_color1 = '#eb6c61';
              $chat_color2 = '#eb6558';
              $chat_color3 = '#EA5D50';
              $chat_color4 = '#E95546';
              break;
            case 1:
              $chat_color1 = '#EA944B';
              $chat_color2 = '#ea8f42';
              $chat_color3 = '#e98a38';
              $chat_color4 = '#e8842e';
              break;
            case 2:
              $chat_color1 = '#F3D046';
              $chat_color2 = '#F2CC34';
              $chat_color3 = '#F3CA27';
              $chat_color4 = '#F1C71B';
              break;
            case 3:
              $chat_color1 = '#52C685';
              $chat_color2 = '#49BD7C';
              $chat_color3 = '#3DB772';
              $chat_color4 = '#32B269';
              break;
            case 4:
              $chat_color1 = '#37B5EF';
              $chat_color2 = '#26B0EE';
              $chat_color3 = '#12ABF0';
              $chat_color4 = '#0DA4EA';
              break;
            case 5:
              $chat_color1 = '#A266BB';
              $chat_color2 = '#9E5EB8';
              $chat_color3 = '#9956B4';
              $chat_color4 = '#944DB1';
              break;
            case 6:
              $chat_color1 = '#606265';
              $chat_color2 = '#585A5D';
              $chat_color3 = '#505255';
              $chat_color4 = '#47494C';
              break;
        }          
    }
	
	$mobile_icon_position = $mobile_icon['position'] == '' ? 'right' : $mobile_icon['position'];
    
	$mobile_icon_lang = $mobile_icon['icon_lang'] == '' ? 'si' : $mobile_icon['icon_lang'];
	if($mobile_icon_lang == 'en' || $mobile_icon_lang == 'fr' || $mobile_icon_lang == 'ge' || $mobile_icon_lang == 'ru'){
		$mobile_icon_width = '110px';
	}else{
		$mobile_icon_width = '32px';
	}
	if($mobile_icon['color'] == null) $mobile_icon['color'] = 4;
	$mobile_icon_color = ($mobile_icon['color'] + 1) < 1 ? '1' : $mobile_icon['color'] + 1;
	if (!$isonline) $mobile_icon_color = 's';
	if (!isset($mobile_invite['invite_title'])) $mobile_invite['invite_title'] = $company_name . '欢迎您！';
	if (!isset($mobile_invite['invite_content'])) $mobile_invite['invite_content'] = '欢迎访问，请问有什么可以帮您？';
	//手机版邀请框
	if (empty($mobile_invite['icon_url']))
		$icon_url = '';
	else
		$icon_url = 'setting/'.$mobile_invite['icon_url'];
	//手机邀请框语言
	if(empty($mobile_invite['ivt_lang']))
		$ivt_lang = 'si';
	else
		$ivt_lang = $mobile_invite['ivt_lang'];
	$mobile_invite_title = json_encode($mobile_invite['invite_title']);
	$mobile_invite_content = json_encode($mobile_invite['invite_content']);
	if($mobile_icon['type'] == 'cus') {
		if ($isonline)
			$mobile_icon_pic = "$server_path/setting/".$mobile_icon['icon_on_url'];
		else
			$mobile_icon_pic = "$server_path/setting/".$mobile_icon['icon_off_url'];
	} else {
		if ($mobile_icon_position == 'right') {
			$mobile_icon_pic = "$server_path/style/setting/ver06/img/mobile/lang/$mobile_icon_lang/zxkf_rt/serv_rt$mobile_icon_color.png";
		} else {
			$mobile_icon_pic = "$server_path/style/setting/ver06/img/mobile/lang/$mobile_icon_lang/zxkf_lt/serv_lt$mobile_icon_color.png";
		}
	}
	
	$mobile_ivt_accept = json_encode('交谈');
	$mobile_ivt_refuse = json_encode('取消');
	$mobile_invite = json_encode($mobile_invite);
    $mobile_chat = json_encode($mobile_chat);
	// 不需要将viewport 设为width=device-width, initial-scale=1,user-scalable=1 的手机站
	$show_viewport_meta = isset($mobile_config['compatibility']) && $mobile_config['compatibility'] == 0 ? 0 : 1;
    
    $icon_show='block';
    if($mobile_icon['position']=='hidden')
    {
        $icon_show='none';
    }
	echo <<< HTML
var force_kf = "";
var is_uc = 0;
var is_ios = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
var first_href = (location.href).replace('#hz6d_new_msg','');
if (is_ios && navigator.userAgent.indexOf("UCBrowser") != -1) {
     is_uc = 1;
} 

(function(window, undefined) {
    var mobile_invite = $mobile_invite;
    var mobile_chat   = $mobile_chat;
	if($show_viewport_meta){
		$53.creElm({
			'name': 'viewport',
			'content': 'width=device-width, initial-scale=1,user-scalable=1'
		},'meta',document.getElementsByTagName("head")[0]);
	}
   
	var openurl = '$openurl'.replace('&referer={hz6d_referer}',hz6d_referer).replace(/{hz6d_keyword}/gim,hz6d_from_page_new);
	
    if(mobile_chat && mobile_chat['is_open'] == 1) {//开启手机强制对话
        var audio = document.createElement("audio");
        if (audio != null && audio.canPlayType && audio.canPlayType("audio/mpeg")) {
            audio.src = "$server_path/mobile/sound/msg_tip_2.mp3";       
        }
        
        window.click_icon_min = function() {
            var toolbar = document.getElementById('toolbar');
    		var news = document.getElementById('news');
    		if(toolbar.style.display =='block'){
    			toolbar.style.display = 'none';
    			news.style.display = 'block';
    		}
        }
        window.click_icon_max = function() {
            var toolbar = document.getElementById('toolbar');
    		var news = document.getElementById('news');
    		if(news.style.display =='block'){
    			toolbar.style.display = 'block';
    			news.style.display = 'none';
    		}
        }
           
        window.show_bd_map = function() {
            var bd_src = document.getElementById('bd_map_ifr');
            if((bd_src.src).indexOf('bdmap') == -1) {
                bd_src.src = '$server_path/bdmap.php?img=$server_path/$company_logo&name='+encodeURIComponent("$company_short")+'&intr=' + encodeURIComponent(mobile_chat['intr']) + '&address=' + encodeURIComponent(mobile_chat['position_info']);  
            }
            document.getElementById('bd_map').style.display='block';
        }
        
        window.show_mobile_chat = function() {
            (document.getElementsByTagName('body')[0]).style.overflow = 'hidden';
            (document.getElementsByTagName('body')[0]).style.position = 'fixed';
            document.getElementById('face_twinkle1').className = '';
            document.getElementById('face_twinkle2').className = '';
           
            document.getElementById('mini_chat').style.display='block';
            document.getElementById('msg_tip').style.display='none';
            document.getElementById('msg_tip').innerHTML = 'x';
            document.getElementById('msg_tip_min').style.display='none';
            document.getElementById('msg_tip_min').innerHTML = 'x';
        }
        
        window.close_mobile_chat = function() {
            (document.getElementsByTagName('body')[0]).style.overflow = '';
            (document.getElementsByTagName('body')[0]).style.position = '';
            document.getElementById('mini_chat').style.display='none';
            document.getElementById('msg_tip').innerHTML = 0;   
            document.getElementById('msg_tip_min').innerHTML = 0;
        }
        
        var add_notice_num = function() {
            var msg_tip_dom = document.getElementById('msg_tip');
            var msg_tip_min_dom = document.getElementById('msg_tip_min');
            if((location.hash).indexOf('#hz6d_new_msg') != -1) {
                location.replace(first_href + '#');
                if(msg_tip_dom.innerHTML != 'x') {
                    msg_tip_dom.style.display='block';
                    msg_tip_dom.innerHTML = 1 + parseInt(msg_tip_dom.innerHTML);
                    msg_tip_min_dom.style.display='block';
                    msg_tip_min_dom.innerHTML = 1 + parseInt(msg_tip_min_dom.innerHTML);
                    document.getElementById('face_twinkle1').className = 'face_twinkle';
                    document.getElementById('face_twinkle2').className = 'face_twinkle';
                    try{
                        audio.play();     
                    }catch(e){}
                }
            }    
        }
        var chat_bottom = function(){
        	var screenH=$53.getSWH().H-40;
        	if(mobile_chat['chat_bottom']){
	        	if(mobile_chat['chat_bottom'] > screenH) return screenH;
	        	else return mobile_chat['chat_bottom'];
	        }else{
	        	return 0;
	        }
        } 
            
        setInterval(add_notice_num,1000);
        document.write('<style>body{margin:0;}#scroll-wrapper{-webkit-overflow-scrolling: touch; overflow-y: scroll;}@-webkit-keyframes twinkling{0% {opacity:0;} 100%{ opacity:1;}}.face_twinkle{-webkit-animation: twinkling 0.5s infinite ease-in-out;}#toolbar img{display:inline;}#toolbar a{color:white;font-size:16px;}</style>');
        if(is_ios && is_uc){//IOS浏览器src为空会导致重复请求
            document.write('<div id="mini_chat" style="display:none;z-index:1001;"><br /><div onclick="close_mobile_chat()" style="width:25px; height:25px; position:fixed; top:19px; right:8px; z-index:9102; color:#fff;"><img src="$server_path/style/setting/ver06/img/mobile/mobile_chat/off.png?20150709" width="21" /></div><div style="background:#000; opacity:0.5; width:100%; height:100%; position:fixed; top:0; left:0; z-index:9100"></div><iframe id="iframe_mobile_chat" style="height:56%; width:100%;  position:fixed; top:2%; left:0%; z-index:9101" frameborder="0" vspace="0" scrolling="yes" src="' + openurl + '&minchat=1#' + location.href +'"></iframe></div>');
            document.write('<div id="bd_map" style="position:fixed;height: 500px;display:none;z-index:1001"><br /><div onclick="document.getElementById(\'bd_map\').style.display=\'none\'" style="width:25px; height:25px; position:fixed; top:5%; right:6%; z-index:9102; color:#fff;"><img src="$server_path/style/setting/ver06/img/mobile/mobile_chat/off.png?20150709" width="25" /></div><div style="background:#000; opacity:0.5; width:100%; height:100%; position:fixed; top:0; left:0; z-index:9100"></div><iframe frameborder="0" vspace="0" id="bd_map_ifr" style="height:94%; width:94%;  position:fixed; top:3%; left:3%; z-index:9101" src="http://log.hm.baidu.com/hm.gif"></iframe></div>');
        }else if(is_ios){
            document.write('<div id="mini_chat" style="display:none;z-index:1001;"><br /><div onclick="close_mobile_chat()" style="width:25px; height:25px; position:fixed; top:19px; right:8px; z-index:9102; color:#fff;"><img src="$server_path/style/setting/ver06/img/mobile/mobile_chat/off.png?20150709" width="21" /></div><div style="background:#000; opacity:0.5; width:100%; height:100%; position:fixed; top:0; left:0; z-index:9100"></div><iframe id="iframe_mobile_chat" style="height:96%; width:100%;  position:fixed; top:2%; left:0%; z-index:9101" frameborder="0" vspace="0" scrolling="yes" src="' + openurl + '&minchat=1#' + location.href +'"></iframe></div>');
            document.write('<div id="bd_map" style="position:fixed;height: 500px;display:none;z-index:1001"><br /><div onclick="document.getElementById(\'bd_map\').style.display=\'none\'" style="width:25px; height:25px; position:fixed; top:5%; right:6%; z-index:9102; color:#fff;"><img src="$server_path/style/setting/ver06/img/mobile/mobile_chat/off.png?20150709" width="25" /></div><div style="background:#000; opacity:0.5; width:100%; height:100%; position:fixed; top:0; left:0; z-index:9100"></div><iframe frameborder="0" vspace="0" id="bd_map_ifr" style="height:94%; width:94%;  position:fixed; top:3%; left:3%; z-index:9101" src="http://log.hm.baidu.com/hm.gif"></iframe></div>');           
        }else{
            document.write('<div id="mini_chat" style="display:none;z-index:1001;"><br /><div onclick="close_mobile_chat()" style="width:25px; height:25px; position:fixed; top:12px; right:5px; z-index:9102; color:#fff;"><img src="$server_path/style/setting/ver06/img/mobile/mobile_chat/off.png?20150709" width="21" /></div><div style="background:#000; opacity:0.5; width:100%; height:100%; position:fixed; top:0; left:0; z-index:9100"></div><iframe id="iframe_mobile_chat" style="height:100%; width:100%;  position:fixed; top:0%; left:0%; z-index:9101" frameborder="0" vspace="0" scrolling="yes" src="' + openurl + '&minchat=1#' + location.href +'"></iframe></div>');
            document.write('<div id="bd_map" style="position:fixed;height: 500px;display:none;z-index:1001"><br /><div onclick="document.getElementById(\'bd_map\').style.display=\'none\'" style="width:25px; height:25px; position:fixed; top:5%; right:6%; z-index:9102; color:#fff;"><img src="$server_path/style/setting/ver06/img/mobile/mobile_chat/off.png?20150709" width="25" /></div><div style="background:#000; opacity:0.5; width:100%; height:100%; position:fixed; top:0; left:0; z-index:9100"></div><iframe frameborder="0" vspace="0" id="bd_map_ifr" style="height:100%; width:100%;  position:fixed; top:0%; left:0%; z-index:9101" src=""></iframe></div>');
        }
        document.write('<div style="height:40px; line-height:40px; position:fixed; bottom:'+chat_bottom()+'px; width:100%;z-index:1000;"><ul id="toolbar" style=" list-style:none; margin:0; padding:0; display:block"><li style="width:30%; background:$chat_color1; float:left; display:block; height:40px; line-height:40px; color:#fff;"><a onclick="show_bd_map()" style="padding-left:5px; display:block"><img style="vertical-align:middle; margin-right:2px;" src="$server_path/style/setting/ver06/img/mobile/mobile_chat/location-white.png" height="20" />查看地址</a></li><li style="width:30%; background:$chat_color2; float:left; display:block; height:40px; line-height:40px; color:#fff;"><a href="tel:'+mobile_chat['phone_num']+'"  style="padding-left:3px; display:block; text-decoration:none; color:#fff;"><img style="vertical-align:middle; margin-right:2px;" src="$server_path/style/setting/ver06/img/mobile/mobile_chat/tel-white.png" height="20" />电话咨询</a></li><li onclick="show_mobile_chat()" style="width:30%; background:$chat_color3; float:left; display:block; height:40px; line-height:40px; color:#fff;"><a style="padding-left:3px; display:block; position:relative"><img id="face_twinkle1" style="vertical-align:middle; margin-right:2px;" src="$server_path/style/setting/ver06/img/mobile/mobile_chat/$chat_face_img" height="20" />$chat_word<span id="msg_tip" style="position:absolute;display:none;left:12px; top:2px; width:18px; height:18px; border-radius:15px; background:#F00; color:#fff; font-size:12px; line-height:19px; text-align:center; font-weight:bold;">0</span></a></li><li onclick="click_icon_min()" style="width:10%; background:$chat_color4; float:right; display:block; height:40px; line-height:40px; color:#fff;"><a style=" text-align:center; display:block" ><img style="vertical-align:middle;" src="$server_path/style/setting/ver06/img/mobile/mobile_chat/putaway-white.png" height="40" /></a></li></ul><div id="news" onclick="click_icon_max()" style="background:$chat_color1;height:40px; position:fixed; bottom:'+chat_bottom()+'px; right:0; width:40px; display:none;"><a style="text-align:center; display:block; position:relative;"><img id="face_twinkle2" style=" margin-top:8px;" src="$server_path/style/setting/ver06/img/mobile/mobile_chat/$chat_face_img" width="30" /><span id="msg_tip_min" style="position:absolute; right:2px; top:2px; display:none; width:20px; height:20px; border-radius:15px; background:#F00; color:#fff; font-size:12px; line-height:21px; text-align:center; font-weight:bold;">0</span></a></div></div>');
	}  
   
	$53.creElm({
		'id': 'mobile_icon_div',
		'href': openurl + "&tfrom=50",
		'style': 'position:fixed;display:$icon_show;hide-focus: expression(this.hideFocus=true);outline: none 0;height:110px;width:$mobile_icon_width;$mobile_icon_position:1px;background:url($mobile_icon_pic) no-repeat center center;z-index:10000',
		'onclick': function(){this.href += '&ucust_id=' + $53.EN($53.getCookie('ucust_id'));}
	},'a');
	rePositionIcon();
	$53.addEvent(window, 'resize', function(){
		rePositionIvt();
		rePositionIcon();
	});
	function rePositionIvt()
	{
		try{
			var mobile_ivt_div = document.getElementById('mobile_ivt_div');
			mobile_ivt_div.style.top = '50%';
			mobile_ivt_div.style.left = '50%';
		} catch(e){}
	}
	function rePositionIcon() {
		try{
			document.getElementById('mobile_icon_div').style.top = (window.innerHeight - 110)/2+'px';
		} catch(e){}
	}
	window.hide_mobile_ivt = function(d){
		document.getElementById('mobile_ivt_div').style.display='none';
        if(mobile_invite['is_open'] == 'yes' && mobile_invite['fanfu_time']>0) {
            setTimeout("document.getElementById('mobile_ivt_div').style.display='block'",mobile_invite['fanfu_time'] * 1000);        
        }
		if(d == 3) onliner_zdfq = 3;
	};
	var mobile_invite_content=$mobile_invite_content;
	mobile_invite_content=mobile_invite_content.replace(/\\\\\\\\n/g,"<br/>");
	window.hz6d_showIvt = function() {
	    if('$icon_url' == '') {
	       var htm = "<div style='width:213px; height:108px;background:url() center center no-repeat; padding:10px 14px 0 14px;'>";   
	    }else{
	       var htm = "<div style='width:213px; height:108px;background:url($server_path/$icon_url) center center no-repeat; padding:10px 14px 0 14px;'>";
	    }
		htm += "<span style='display:block;color:#000000;font-weight:500;text-align: center;font-size:22px;height:28px;overflow:hidden;line-height:28px;text-overflow: ellipsis;white-space: nowrap;'>" + $mobile_invite_title + "</span><span style='display:block;color:#7F7F7F; font-weight:500;font-size:15px;line-height:17px;margin-top:3px;width:216px;word-wrap:break-word;'>" + mobile_invite_content + "</span>";
		htm += "</div>";
		htm += "<div style='position:absolute;left:0;bottom:0;'>";
		htm += '<a href="javascript:hide_mobile_ivt(3);" style="outline: none;display:block;float:left;width:120px;height:45px;color:#000000;text-align:center;line-height:45px; text-decoration:none;font-weight:600;font-size:16px;cursor:pointer;"></a>';
		htm += "<a href='" + openurl + "&tfrom=51" + "&=" + force_kf + "' style='outline: none;display:block;float:left;width:120px;height:45px;color:#000000;text-align:center;line-height:45px; text-decoration:none;font-weight:600;font-size:16px;cursor:pointer;margin-left:2px;' id='mobile_ivt_talk_btn'></a>";
		htm += "</div>";
		$53.creElm({
			'style':'position:fixed;width:242px;height:163px;margin-top:-81.5px;margin-left:-121px;background:url($server_path/style/setting/ver06/img/mobile/lang/$ivt_lang/mobile_ivt.png) center center no-repeat;border-radius:5px; font-family:Microsoft YaHei,Arial;overflow:hidden;z-index:100000',
			'id':'mobile_ivt_div',
			'innerHTML':htm
		},'div');
		setTimeout(rePositionIvt,100);
		$53.addEvent($53('mobile_ivt_talk_btn'),'click',function(){
			setIsinvited();
			hide_mobile_ivt();
		});
	};
	window.hz6d_sendACC= function()
	{
	    var talk_page_tmp = window.location.href;
        if(talk_page_tmp.indexOf('hz6d{') != -1) {
            talk_page_tmp = talk_page_tmp.substring(0,talk_page_tmp.indexOf('hz6d{'));
        }
	 	var talk_page = $53.EN(talk_page_tmp);
	 	var time = new Date().getTime();
	 	var kh_status = 0;
	 	if(onliner_zdfq==3) { kh_status = 3; }
	 	var url = "$http://$acc_host/sendacc.jsp?cmd=ACC&did=0&sid=12&company_id=$companyid&guest_id="+$53.getCookie('53gid2')+"&status="+kh_status+"&guest_name=&guest_ip="+$53.EN('$myip')+"&guest_ip_info=$ipstr&from_page=" + $53.EN($53.getCookie("53kf_{$companyid}_keyword")) +"&talk_page="+talk_page+"&kf_time=$in_timestamp&bto_id6d=-99&time="+time + '&ucust_id=' + $53.EN($53.getCookie('ucust_id')) + '$style_id'+'&is_mobile=y&visitor_type='+$53.getCookie('visitor_type')+'&is_uv='+$53.data('is_uv');
	 	$53.createScript('hz6d_send_acc',url);
	 	setTimeout("hz6d_sendACC()",20000);
	};
	if('$isonline' == 1) hz6d_sendACC();
	if (mobile_invite['is_open'] == 'yes'&&'$isonline' == 1) setTimeout('hz6d_showIvt()',mobile_invite['timeout'] * 1000);
})(window);
HTML;
/////手机版结束///////
}
else 
{//桌面客户开始
	if ($kf_type == 1){
		$zdytb_53kf_on = json_encode($zdytb_53kf_on);
		$zdytb_53kf_off = json_encode($zdytb_53kf_off);
	}
	if ($kf_type == 2)
	{
	  $tb_data = get_tb_data();
	  $tb_on_str = $tb_data['on']['str'];
	  $tb_off_str = $tb_data['off']['str'];
		$zdytb_53kf_on = json_encode($zdytb_53kf_on);
		$zdytb_53kf_off = json_encode($zdytb_53kf_off);
	  if ($isonline == 1)
	  {
	    $width = $tb_data['on']['width'];
	    $height = $tb_data['on']['height'];
	  }
	  elseif ($isonline == 0)
	  {
	    $width = $tb_data['off']['width'];
	    $height = $tb_data['off']['height'];
	  }
	  echo <<< HTML
	  \r\n
	  var kf_script_num = 0;
	  var script_total = document.getElementsByTagName('script');
	  for (var i = 0; i < script_total.length; i++)
	  {
	    if (script_total[i].src.toLowerCase().indexOf('kf.php') != -1)
	    {
	      kf_script_num += 1;
	      break;
	    }
	  }
		if (kf_script_num <= 1)
		{
	    function init_zdytb_arr(zdytb_str)
	    {
	      // 生成 图标 数组 
	      var zdytb_arrs = [];
	      var tmp_arrs = zdytb_str.split('#');
	      for (var i = 0; i < tmp_arrs.length; i++)
	      {
	        zdytb_arrs[i] = [];
	        zdytb_arrs[i] = tmp_arrs[i].split(',');
	      }
	      return zdytb_arrs;
	    }
	
	    function get_input_name_pos(_input_name_arr,_input_name)
	    {
	      // 获取自定义图标 输入值位置 
	      var _pos = 0;
	      for (var i = 0; i < _input_name_arr.length; i++)
	      {
	        if (_input_name_arr[i] == _input_name)
	        {
	          _pos = i;
	          break;
	        }
	      }
	      return _pos;
	    }
	
	    // 组装自定义图标div 
	    function get_zdytb_divs(on_off,zdytb_on_arrs,zdytb_off_arrs,kficon_click_str)
	    {
	      var element_arrs = (String(on_off) == '1') ? zdytb_on_arrs : zdytb_off_arrs;
	      
	      var divs_str = '';
	      for (var i = 0; i < element_arrs.length; i++)
	      {
	        var element_arr = element_arrs[i];
	        var css_arr_1 = css_name_arr_1;
	        var css_arr_3 = css_name_arr_3;
	        var css_str = '';
	        var link_str = '';
	        var target_str = '';
	        var text_str = '';
	        var click_str = '';
	
	        // 处理css 
	        for (var j = 0;j < css_arr_3.length; j++)
	        {
	          var css_pos = css_arr_3[j];
	          if (element_arr[css_pos] == '' || element_arr[css_pos] == '-')
	            continue;
	          if (css_pos == 8 && element_arr[css_pos].indexOf('http://') == -1)
	            element_arr[css_pos] = "$http://" + "$talk_host" + "/" + element_arr[css_pos];
	          css_str += css_arr_1[j].replace("c_c",element_arr[css_pos]) + ';';
	        }
	        
	        // 处理文本内容 
	        var text_type_pos = get_input_name_pos(input_name_arr,'text_type');
	        var text_content_pos = get_input_name_pos(input_name_arr,'text_content');
	        var tmp_type = $53.trim(element_arr[text_type_pos]);
	        var tmp_text = $53.htmlDecode($53.trim(element_arr[text_content_pos]).replace(/&amp;/g, '&'));
	        if (tmp_type != '' && tmp_type != '-' && tmp_text != '' && tmp_text != '-')
	        {
	          text_str = tmp_text; 
	        }
	        
	        // 处理连接 
	        var element_type_pos = get_input_name_pos(input_name_arr,'element_type');
	        var link_href_pos = get_input_name_pos(input_name_arr,'link_href');
	        var tmp_e_type = $53.trim(element_arr[element_type_pos]);
	        var tmp_herf = $53.htmlDecode($53.trim(element_arr[link_href_pos]).replace(/&amp;/g, '&'));
	        var im_account_pos = get_input_name_pos(input_name_arr,'im_account');
	        var tmp_im_account = $53.trim(element_arr[im_account_pos]);
	        if ((tmp_e_type == '' || tmp_e_type == '-') && $53.trim(tmp_herf).replace('http://','') != '' && $53.trim(tmp_herf) != '-')
	        {
	          link_str = $53.trim(tmp_herf);
	        }
	        else
	        {
						switch (tmp_e_type)
	          {
	            case 'chat': click_str = kficon_click_str; break;
	            case 'close': click_str = 'this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode)'; break; 
	            case 'etel': click_str = 'window.open(\'http://$master_host/eht.php?company_id=$companyid&style_id=$style_real_id\',\'_blank\',\'height=400,width=300,top=100,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no\')'; break;
	            case 'qq':
								if (tmp_im_account != '' && tmp_im_account != '-'){
									if (tmp_im_account.toLowerCase().indexOf('biz') > -1){ //biz qq
										tmp_im_account = tmp_im_account.replace('biz','');
										link_str = '$http://$talk_host/bizqq.php?qq=' + tmp_im_account + '&from=' + window.encodeURIComponent(window.location.href);
									} else{
										link_str = 'tencent://message/?uin=' + tmp_im_account;
									}
									if(tmp_im_account == '97559766')
										link_str="http://www.53kf.com/?www.53rj.com";
								}
								break;
	            case 'wang': if (tmp_im_account != '' && tmp_im_account != '-') link_str = 'aliim://sendmsg?touid=cntaobao' + tmp_im_account; if(tmp_im_account == 'fonlue') link_str='http://www.53kf.com/?www.53rj.com'; break;
	            case 'msn': if (tmp_im_account != '' && tmp_im_account != '-') link_str = 'msnim:chat?contact=' + tmp_im_account; if(tmp_im_account.indexOf('fonlue') > -1) link_str='http://www.53kf.com/?www.53rj.com'; break;
	            default: link_str = '';click_str = '';
	          }
	        }
	        // 处理是否新窗口 
	        var link_target_pos = get_input_name_pos(input_name_arr,'link_target');
	        var tmp_target = $53.trim(element_arr[link_target_pos]);
	        if (tmp_target == '' || tmp_target == '-' || tmp_target == '_blank') target_str = '_blank';
	        else target_str = '_self';
	        var onclick_str = '';
	        if (link_str == '' && click_str != '') onclick_str = 'onclick="' + click_str + ';"';
	        else if (link_str != ''&& click_str != '') onclick_str = ' onclick="' + click_str + ';window.open(\'' + link_str +'\',\'' + target_str + '\');" ';
	        else if (link_str != ''&& click_str == '') onclick_str = ' onclick="window.open(\'' + link_str +'\',\'' + target_str + '\');" ';
	        
	        if (link_str != '' || click_str != '') css_str += "cursor: pointer;";
	        var height_str = element_arr[get_input_name_pos(input_name_arr,'div_height')];
	        if (text_str != '') css_str += "line-height: " + height_str + "px;";
	        // 组装成div 
	        
	        var title_str = '';
	        if (text_str != ''&& onclick_str != '')
	        {
	          title_str = 'title=\"' + text_str + '\"';
	        }
				if(tmp_e_type != 'qq' && tmp_e_type != 'msn' && tmp_e_type != 'wang' )	link_str = link_str.replace('http://www.53kf.com',powered_by_53kf_url);
				if(tmp_e_type != 'qq' && tmp_e_type != 'msn' && tmp_e_type != 'wang' )	onclick_str =  onclick_str.replace('http://www.53kf.com',powered_by_53kf_url);
	        if(i == 0)
	        {
	          onclick_str = '';
	          divs_str += "<div style=\"position: relative;overflow: hidden;z-index:10086;" + css_str + "\" " + onclick_str + ">";
	        }
	        else if(tmp_im_account != '' && tmp_im_account != '-' && link_str != '')
	        {
	          divs_str += "<a href=\"" + link_str+ "\" target=\"_blank\"><div style=\"position: absolute;overflow: hidden;text-decoration:none;" + css_str + "\" " + title_str + ">" + text_str + "</div></a>";
	        }
	        else
	        {
	          divs_str += "<div style=\"position: absolute;overflow: hidden;" + css_str + "\" " + onclick_str + title_str + ">" + text_str + "</div>";
	        }
	      }
	      divs_str += '</div>';
	      return divs_str;
	    }
	
	    // 定义全局解码数组 
	    var css_name_arr_1 = ["width: c_cpx","height: c_cpx","left: c_cpx","top: c_cpx","z-index: c_c","background-image: url(c_c)","background-repeat: c_c","background-color: #c_c","font-size: c_cpx","color: #c_c","text-align:c_c","font-weight: c_c","font-style: c_c","text-decoration: c_c","font-family:c_c","border-style: c_c","border-width: c_cpx","border-color:#c_c;word-break:break-all;"];
	    var css_name_arr_2 = ["div_width","div_height","div_left","div_top","div_zindex","bg_img_url","bg_img_repeat","bg_color","font_size","text_color","text_align","font_bold","font_italic","text_underline","font_family","border_style","border_width","border_color"];
	    var css_name_arr_3 = [3,4,5,6,7,8,9,10,14,15,16,17,18,19,20,21,22,23];
	    var input_name_str = 'element_id#element_name#element_type#div_width#div_height#div_left#div_top#div_zindex#bg_img_url#bg_img_repeat#bg_color#im_account#text_type#text_content#font_size#text_color#text_align#font_bold#font_italic#text_underline#font_family#border_style#border_width#border_color#link_href#link_target';
	    var input_name_arr = input_name_str.split('#'); // 初始化解码数组 
		// start 客服图标转义url 
	    function hz6d_clicurl(on_off,zdytb_on_arrs,zdytb_off_arrs,kficon_click_str)
	    {
	      var element_arrs = (String(on_off) == '1') ? zdytb_on_arrs : zdytb_off_arrs;
	      var divs_str = '';
				divs_str = element_arrs.replace(/operating="([^"]*)"/g,function(str){
					var vals = str.split('"');
					if(vals[1])
					{
						var click_str = '';
						var link_str ='';
						var target_str = '_blank';
						var hrs = '';
						var valst = vals[1].split("|");
						switch(valst[0])
						{
							case 'KF': 
								var ckick_new_str = kf_click_new = hz6d_html_replace(kficon_click_str);
								ckick_new_str = encodeURIComponent(ckick_new_str);
								ckick_new_str = ckick_new_str.replace(/'/g,"#liyc#");
								click_str = 'hz6d_is_exist(\''+ckick_new_str+'\')';break;
							case 'CLOSE': click_str = 'this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode)'; break;
							case 'ETEL': click_str = 'window.open(\'http://$master_host/eht.php?company_id=$companyid&style_id=$style_real_id\',\'_blank\',\'height=400,width=300,top=100,left=200,status=yes,toolbar=no,menubar=no,resizable=no,scrollbars=no,location=no,titlebar=no\')'; break;
							case 'QQ': 
								if(valst[1])
								{
									if(valst[1].toLowerCase().indexOf('biz') > -1)
									{
										var qq = valst[1].replace('biz','');
										link_str = '$http://$talk_host/bizqq.php?qq=' + qq + '&from=' + window.encodeURIComponent(window.location.href);
									}
									else
									{
										link_str = 'tencent://message/?uin=' + valst[1];
									}
									if(valst[1] == '97559766')
										link_str="http://www.53kf.com/?www.53rj.com";
								};
								break;
							case 'MSN': if (valst[1]) {link_str = 'msnim:chat?contact=' + valst[1]; if(valst[1].indexOf('fonlue') > -1) link_str='http://www.53kf.com/?www.53rj.com';} break;
							case 'WW': 
								if (valst[1]) 
								{
									if(valst[1].toLowerCase().indexOf('###') > -1)
									{
										var wang = valst[1].replace('###','');
										link_str = 'http://amos.alicdn.com/msg.aw?v=2&uid=' + wang +'&site=enaliint&s=21&charset=UTF-8';
									}
									else
									{
										link_str = 'aliim://sendmsg?touid=cntaobao' + valst[1];
									}
									if(valst[1] == 'fonlue') link_str='http://www.53kf.com/?www.53rj.com'; 
								}
								break;
							case 'HYLINK': if (valst[1]) link_str = valst[1]; if(valst[2]) target_str = valst[2]; hrs = 1;break;
							default: click_str = '';link_str = '';
						}
						var onclick_str = '';
						if (link_str == '' && click_str != '') onclick_str = 'onclick="' + click_str + ';"';
						else if (link_str != ''&& click_str != '') onclick_str = ' onclick="' + click_str + ';window.open(\'' + link_str +'\',\'' + target_str + '\');" ';
						else if (link_str != ''&& click_str == '' && !hrs) onclick_str = ' onclick="window.open(\'' + link_str +'\');" ';
						else if (link_str != ''&& click_str == '' && hrs) onclick_str = 'href="'+ link_str+'" target="'+ target_str +'"';
						return onclick_str;
					}
				});
				return divs_str;
	    }
			//end 
		}
	  \r\n
HTML;
	}
	
	///////////////
	if ($posmodel == '4')
	{
		if ($zdyssan == 'yes')
		{
			$left_hidden_img = $left_hidden_img != '' ? str_ireplace('../', '', $left_hidden_img) : 'img/kflogo/ssan/left/green.gif';
			$right_hidden_img = $right_hidden_img != '' ? str_ireplace('../', '', $right_hidden_img) : 'img/kflogo/ssan/right/green.gif';
		}
		elseif ($zdyssan == 'no')
		{
			$left_hidden_img = $left_list_ssan != '' ? "img/kflogo/ssan/left/{$left_list_ssan}.gif" : 'img/kflogo/ssan/left/green.gif';
			$right_hidden_img = $right_list_ssan != '' ? "img/kflogo/ssan/right/{$right_list_ssan}.gif" : 'img/kflogo/ssan/right/green.gif';
		}
		$auto_hidden_img = ($showmodel == '1') ? $left_hidden_img : $right_hidden_img;
		$auto_hidden_img_size = getimagesize("$auto_hidden_img");
		if (auto_hidden_img_size == false)
			$auto_hidden_img_size = array(0,0);
		$hidden_img_width = $auto_hidden_img_size[0];
		$hidden_img_height = $auto_hidden_img_size[1];
	}
	
	
	if (($powered_by_53kf == '0' && $kf_type == '2') || ($zdytb == 'no' && preg_match('/2011/',$img_on)))
	{//版权信息显示
		$power_by_53kf_style = ';display:none;';
	}
	if ($hidden == '0')
	{//不隐藏图标
		$icon = "";
		if ($posmodel == '1' || $posmodel == '4')
		{//浮动图标/浮动伸缩 模式开始      
			if ($kf_type == 1)
			{
				$openurl = "$server_path/$visitorurl?arg=$arg$style_id$language$username$userinfo$charset$introurl$onurl$lytype$lyurl$copartner$referer$keyword&tpl=$company_tpl$logo$brief$question$u_stat_id";
                                if ($is_zdyurl == 1)
					$openurl = $zdyurl;
				$list = kf_list_make($openurl, $posmodel, $dept_man_show);
				$kf_list_show = $list[0];
				$width = $list[2];
				echo "kftype=1;";
				if($tblist_arr)
				{
					$kf_list_shows = $tblist_arr;
					$kf_list_shows = kf_list_czu($openurl,$tblist_arr,$dept_man_show);
				}
				if ($posmodel == '1')
				{
					echo <<< HTML
					function _createIconDivMain()
					{
						if ($53(this.config["iconDiv"]) == null)
						{
							var id = this.config["id"];
							setTimeout('kf_icons[' + id + '].createIconDivMain()', 500);
							return;
						}
						if ($53(this.config["iconDiv"]).innerHTML.indexOf('.gif') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.jpg') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.swf') != -1) return;
						var html = "";
						html += "<iframe style='position:absolute;z-index:7998;width:0px;height:0px;top:0px;left:0px;' frameborder='0' ></iframe>";
						if("$kf_list_shows")
						{
							var kflist = "$kf_list_shows";
							kflist = hz6d_html_replace(kflist);
							var kf_width = kflist.match(/(width|WIDTH):[\d]*/);
							if(kf_width)
							{
								var wid_num = kf_width[0].split(":");
								kf_width = wid_num[1];
							}
							else
							{
								kf_width = this.config["width"];
							}
							html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:7999;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + kf_width + "px;height:auto; POSITION: absolute;'>"  + kflist + "</div>";
						}
						else
						{
							var kflist = "$kf_list_show";
							kflist = hz6d_html_replace(kflist);
							html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:7999;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["width"] + "px;height:auto; overflow:hidden;POSITION: absolute;'>" + this.closeIcon() + kflist + "</div>";
						}
						this.iconDivMain = html;
						$53(this.config["iconDiv"]).innerHTML = this.iconDivMain;
						this.iconDivMain = $53(this.config["iconDivMain"]);
						if(!"$kf_list_shows")
						{
							set_hz6d_bottom_logo();
						}
						
					}
HTML;
				}
				elseif ($posmodel == '4')
				{
					echo <<< HTML
					function _createIconDivMain()
					{
						if ($53(this.config["iconDiv"]) == null)
						{
							var id = this.config["id"];
							setTimeout('kf_icons[' + id + '].createIconDivMain()', 500);
							return;
						}
						if ($53(this.config["iconDiv"]).innerHTML.indexOf('.gif') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.jpg') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.swf') != -1) return;
						var id = this.config["id"];
						var html = "";
						html += "<iframe style='position:absolute;z-index:7998;width:0px;height:0px;top:0px;left:0px;' frameborder='0' ></iframe>";
						if("$kf_list_shows")
						{
							var kflist = "<div>$kf_list_shows</div>";
							kflist = hz6d_html_replace(kflist);
						}
						else
						{
							var kflist = "$kf_list_show";
							kflist = hz6d_html_replace(kflist);
						}
						kflist = hz6d_html_replace(kflist);
						html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:7999;display:block;left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["width"] + "px;height:auto;position: absolute;'>";
						var auto_hidden = "<div id='auto_hidden" + id + "' style='z-index:9001;display:block;right:1px;top:0px;width:" + this.config["hidden_img_width"] + "px;height:" + this.config["hidden_img_height"] + "px;overflow:hidden;position:absolute;background:url(\"$http://$talk_host/$auto_hidden_img\") no-repeat;' onmouseover='show_kf_icon(" + id + ");'></div>";
						html += "<div id='kf_hidden" + id + "' onclick='set_auto_hidden(" + id + ")' onmouseover='show_kf_icon(" + id + ");' onmouseout='hidden_kf_icon(" + id + ");' style='position:absolute; top:0; right:0;z-index:9000;display:none;'>" + this.closeIcon() + kflist + "</div>" + auto_hidden + "</div>";
						$53(this.config["iconDiv"]).innerHTML = html;
						this.iconDivMain = $53(this.config["iconDivMain"]);
						if(!"$kf_list_shows")
						set_hz6d_bottom_logo();
						this.iconDivMain.style.height = Math.max($53("kf_hidden" + id).offsetHeight, parseInt($53("auto_hidden" + id).style.height.replace("px", ""))) + "px";
						
						this.iconDivMain.style.width = this.config['hidden_img_width'] + 'px';
	
						if (this.config["showmodel"] == 2) // 右侧显示 
						{
							$53("auto_hidden" + id).style.right = "0px";
							$53("kf_hidden" + id).style.right = "0px";
						}
						else
						{
							$53("auto_hidden" + id).style.left = "0px";
							$53("kf_hidden" + id).style.left = "0px";
						}
					}
HTML;
				}
			}
			else
			{
				if ($posmodel == '1')
				{
					if("$is_offzdytb" || "$is_onzdytb")
					{
						echo <<< HTML
						function _createIconDivMain()
						{
							if ($53(this.config["iconDiv"]) == null)
							{
								var id = this.config["id"];
								setTimeout('kf_icons[' + id + '].createIconDivMain()', 500);
								return;
							}
							if ($53(this.config["iconDiv"]).innerHTML.indexOf('.gif') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.jpg') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.swf') != -1)
							{
								 return;
							}
							var imgsrc = '';
							if (this.config["isonline"] == 1)
							{
								imgsrc = this.config["img_on"];
							}
							else
							{
								imgsrc = this.config["img_off"];
							}
							var html = "";
							html += "<iframe style='position:absolute;z-index:7998;width:0px;height:0px;top:0px;left:0px;' frameborder='0' ></iframe>";
							var kf = "<div onclick=\"setIsinvited();kf_icons[" + this.config["id"] + "].wopen('" + this.setParameter() + "')\" style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div>";
							if (this.config["isonline"] == 1)
							{
								if('$is_onzdytb')
								{
									var onval_str = '$onval_arr';
									var kf_width = onval_str.match(/(width|WIDTH):[ \d]*/);
									var kf_height = onval_str.match(/(height|HEIGHT):[ \d]*/);
									if(kf_width)
									{
										var wid_num = kf_width[0].split(":");
										kf_width = wid_num[1];
									}
									else
									{
										kf_width = this.config["width"];
									}
									if(kf_height)
									{
										var hei_num = kf_height[0].split(":");
										kf_height = hei_num[1];
									}
									else
									{
										kf_height = this.config["height"];
									}
									html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + kf_width + "px;height:" + kf_height + "px; overflow:hidden;POSITION: absolute;'>";
									html += hz6d_clicurl(this.config["isonline"],'$onval_arr','$offval_arr',kf_icons[this.config["id"]].getClickUrl());
									html += "</div>";
								}
								else
								{
									kf += '<div style="text-align:right"><a style="color:#999;stylefont-size:11px;margin-right:3px;display:inline-block;width:$width;text-decoration:none;line-height:20px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a></div>';
									html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["width"] + "px;height:" + (parseInt(this.config["height"],10) + 20) +  "px; overflow:hidden;POSITION: absolute;'>" + this.closeIcon() + kf + "</div>";
								}
							}
							else
							{
								if(this.config["record_url"])
								{
									kf = "<a href=\"" + this.config["record_url"] + "\" target='_blank'><div style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div></a>";
								}
								if ('$is_offzdytb')
								{
									var offval_str = '$offval_arr';
									var kf_width = offval_str.match(/(width|WIDTH):[ \d]*/);
									var kf_height = offval_str.match(/(height|HEIGHT):[ \d]*/);
									if(kf_width)
									{
										var wid_num = kf_width[0].split(":");
										kf_width = wid_num[1];
									}
									else
									{
										kf_width = this.config["width"];
									}
									if(kf_height)
									{
										var hei_num = kf_height[0].split(":");
										kf_height = hei_num[1];
									}
									else
									{
										kf_height = this.config["height"];
									}
									html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + kf_width + "px;height:" + kf_height + "px; overflow:hidden;POSITION: absolute;'>";
									html += hz6d_clicurl(this.config["isonline"],'$onval_arr','$offval_arr',kf_icons[this.config["id"]].getClickUrl());
									html += "</div>";
								}
								else
								{
									kf += '<div style="text-align:right"><a style="color:#999;stylefont-size:11px;margin-right:3px;display:inline-block;width:$width;text-decoration:none;line-height:20px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a></div>';
									html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["width"] + "px;height:" + (parseInt(this.config["height"],10) + 20) +  "px; overflow:hidden;POSITION: absolute;'>" + this.closeIcon() + kf + "</div>";
								}
							}
							
							$53(this.config["iconDiv"]).innerHTML = html;
							this.iconDivMain = $53(this.config["iconDivMain"]);
						}
HTML;
					}
					else
					{
						echo <<< HTML
						function _createIconDivMain()
						{
							if ($53(this.config["iconDiv"]) == null)
							{
								var id = this.config["id"];
								setTimeout('kf_icons[' + id + '].createIconDivMain()', 500);
								return;
							}
							if ($53(this.config["iconDiv"]).innerHTML.indexOf('.gif') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.jpg') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.swf') != -1)
							{
								 return;
							}
							var imgsrc = '';
							if (this.config["isonline"] == 1)
							{
								imgsrc = this.config["img_on"];
							}
							else
							{
								imgsrc = this.config["img_off"];
							}
							var html = "";
							html += "<iframe style='position:absolute;z-index:7998;width:0px;height:0px;top:0px;left:0px;' frameborder='0' ></iframe>";
							var kf = "<div onclick=\"setIsinvited();kf_icons[" + this.config["id"] + "].wopen('" + this.setParameter() + "')\" style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div>";
							if (this.config["record_url"] != "" && this.config["isonline"] == 0)
							{
								kf = "<a href=\"" + this.config["record_url"] + "\" target='_blank'><div style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div></a>";
							}
							if ($zdytb_53kf_on == '' || $zdytb_53kf_off == ''  || "$zdytb" == 'no')
							{
								kf += '<div style="text-align:right"><a style="color:#999;stylefont-size:11px;margin-right:3px;display:inline-block;width:$width;text-decoration:none;line-height:20px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a></div>';
								html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["width"] + "px;height:" + (parseInt(this.config["height"],10) + 20) +  "px; overflow:hidden;POSITION: absolute;'>" + this.closeIcon() + kf + "</div>";
							}
							else
							{
								html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["width"] + "px;height:" + this.config["height"] + "px; overflow:hidden;POSITION: absolute;'>" + get_zdytb_divs(this.config["isonline"],this.config["zdytb_on_arrs"],this.config["zdytb_off_arrs"],kf_icons[this.config["id"]].getClickUrl()) + "</div>";
							}
							$53(this.config["iconDiv"]).innerHTML = html;
							this.iconDivMain = $53(this.config["iconDivMain"]);
						}
HTML;
					}
				}
				elseif ($posmodel == '4')
				{
					if("$is_offzdytb" || "$is_onzdytb")
					{
						echo <<< HTML
						function _createIconDivMain()
						{
							if ($53(this.config["iconDiv"]) == null)
							{
								var id = this.config["id"];
								setTimeout('kf_icons[' + id + '].createIconDivMain()', 500);
								return;
							}
							if ($53(this.config["iconDiv"]).innerHTML.indexOf('.gif') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.jpg') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.swf') != -1)
							{
								return;
							}
							var id = this.config["id"];
							var imgsrc = '';
							if (this.config["isonline"] == 1)
							{
								imgsrc = this.config["img_on"];
							}
							else
							{
								imgsrc = this.config["img_off"];
							}
							var showmodel = this.config["showmodel"];
							var html = "";
							html += "<iframe style='position:absolute;z-index:7998;width:0px;height:0px;top:0px;left:0px;' frameborder='0' ></iframe>";
							var kf = "<div onclick=\"setIsinvited();kf_icons[" + this.config["id"] + "].wopen('" + this.setParameter() + "')\" style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div>";
							if (this.config["record_url"] != "" && this.config["isonline"] == 0)
							{
								kf = "<a href=\"" + this.config["record_url"] + "\" target='_blank'><div style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div></a>";
							}
							html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["hidden_img_width"] + "px;height:auto;position: absolute;'>";
							var auto_hidden = "<div id='auto_hidden" + id + "' style='z-index:9001;display:block;right:1px;top:0px;width:" + this.config["hidden_img_width"] + "px;height:" + this.config["hidden_img_height"] + "px;overflow:hidden;position:absolute;background:url(\"$http://$talk_host/$auto_hidden_img\") no-repeat;' onmouseover='show_kf_icon(" + id + ");'></div>";
							if (this.config["isonline"] == 1)
							{
								if('$is_onzdytb')
								{
									auto_hidden = "<div id='auto_hidden" + id + "' style='z-index:9001;display:block;right:1px;top:0px;width:" + this.config["hidden_img_width"] + "px;height:" + this.config["hidden_img_height"] + "px;overflow:hidden;position:absolute;background:url(\"$http://$talk_host/$auto_hidden_img\") no-repeat;' onmouseover='show_kf_icons(" + id + ");'></div>";
									html += "<div id='kf_hidden" + id + "' onclick='set_auto_hidden(" + id + ")' onmouseover='show_kf_icons(" + id + ");' onmouseout='hidden_kf_icon(" + id + ");' style='position:absolute; top:0; right:0;z-index:9000;display:none;'>"
									html += hz6d_clicurl(this.config["isonline"],'$onval_arr','$offval_arr',kf_icons[this.config["id"]].getClickUrl());
									html += "</div><div>" + auto_hidden + "</div></div>";
								}
								else
								{
									kf += '<div style="text-align:right;"><a style="color:#999;font-size:11px;margin-right:3px;display:inline-block;width:$width;text-decoration:none;line-height:20px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a></div>';
									html += "<div id='kf_hidden" + id + "' onclick='set_auto_hidden(" + id + ")' onmouseover='show_kf_icon(" + id + ");' onmouseout='hidden_kf_icon(" + id + ");' style='position:absolute; top:0; right:0;z-index:9000;height:" + (parseInt(this.config["height"],10) + 20) + "px;display:none;'>" + this.closeIcon() + kf + "</div>" + auto_hidden + "</div>";
								}
							}
							else
							{
								if (this.config["record_url"] != "")
								{
									kf = "<a href=\"" + this.config["record_url"] + "\" target='_blank'><div style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div></a>";
								}
								if('$is_offzdytb')
								{
									auto_hidden = "<div id='auto_hidden" + id + "' style='z-index:9001;display:block;right:1px;top:0px;width:" + this.config["hidden_img_width"] + "px;height:" + this.config["hidden_img_height"] + "px;overflow:hidden;position:absolute;background:url(\"$http://$talk_host/$auto_hidden_img\") no-repeat;' onmouseover='show_kf_icons(" + id + ");'></div>";
									html += "<div id='kf_hidden" + id + "' onclick='set_auto_hidden(" + id + ")' onmouseover='show_kf_icons(" + id + ");' onmouseout='hidden_kf_icon(" + id + ");' style='position:absolute; top:0; right:0;z-index:9000;display:none;'>"
									html += hz6d_clicurl(this.config["isonline"],'$onval_arr','$offval_arr',kf_icons[this.config["id"]].getClickUrl());
									html += "</div><div>" + auto_hidden + "</div></div>";
								}
								else
								{
									kf += '<div style="text-align:right;"><a style="color:#999;font-size:11px;margin-right:3px;display:inline-block;width:$width;text-decoration:none;line-height:20px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a></div>';
									html += "<div id='kf_hidden" + id + "' onclick='set_auto_hidden(" + id + ")' onmouseover='show_kf_icon(" + id + ");' onmouseout='hidden_kf_icon(" + id + ");' style='position:absolute; top:0; right:0;z-index:9000;height:" + (parseInt(this.config["height"],10) + 20) + "px;display:none;'>" + this.closeIcon() + kf + "</div>" + auto_hidden + "</div>";
								}
							}
							$53(this.config["iconDiv"]).innerHTML = html;
							this.iconDivMain = $53(this.config["iconDivMain"]);
							this.iconDivMain.style.height = Math.max(this.config["height"], parseInt($53("auto_hidden" + id).style.height.replace("px", ""))) + "px";
							this.iconDivMain.style.width = this.config['hidden_img_width'] + 'px';
							if (this.config["showmodel"] == 2) // 右侧显示 
							{
								$53("auto_hidden" + id).style.right = "0px";
								$53("kf_hidden" + id).style.right = "0px";
							}
							else
							{
								$53("auto_hidden" + id).style.left = "0px";
								$53("kf_hidden" + id).style.left = "0px";
							}
						}
HTML;
					}
					else
					{
						echo <<< HTML
						function _createIconDivMain()
						{
							if ($53(this.config["iconDiv"]) == null)
							{
								var id = this.config["id"];
								setTimeout('kf_icons[' + id + '].createIconDivMain()', 500);
								return;
							}
							if ($53(this.config["iconDiv"]).innerHTML.indexOf('.gif') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.jpg') != -1 || $53(this.config["iconDiv"]).innerHTML.indexOf('.swf') != -1)
							{
								return;
							}
							var id = this.config["id"];
							var imgsrc = '';
							if (this.config["isonline"] == 1)
							{
								imgsrc = this.config["img_on"];
							}
							else
							{
								imgsrc = this.config["img_off"];
							}
							var showmodel = this.config["showmodel"];
							var html = "";
							html += "<iframe style='position:absolute;z-index:7998;width:0px;height:0px;top:0px;left:0px;' frameborder='0' ></iframe>";
							var kf = "<div onclick=\"setIsinvited();kf_icons[" + this.config["id"] + "].wopen('" + this.setParameter() + "')\" style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div>";
							if (this.config["record_url"] != "" && this.config["isonline"] == 0)
							{
								kf = "<a href=\"" + this.config["record_url"] + "\" target='_blank'><div style='width:" + this.config["width"] + "px;height:" + this.config["height"] + "px;background:url(\"" + imgsrc + "\") no-repeat;cursor:pointer;'></div></a>";
							}
							html += "<div id='" + this.config["iconDivMain"] + "' style='z-index:10085;display:" + this.display + ";left: " + this.left + "px; top: " + this.top + "px;width:" + this.config["hidden_img_width"] + "px;height:auto;position: absolute;'>";
							var auto_hidden = "<div id='auto_hidden" + id + "' style='z-index:9001;display:block;right:1px;top:0px;width:" + this.config["hidden_img_width"] + "px;height:" + this.config["hidden_img_height"] + "px;overflow:hidden;position:absolute;background:url(\"$http://$talk_host/$auto_hidden_img\") no-repeat;' onmouseover='show_kf_icon(" + id + ");'></div>";
							
							if ($zdytb_53kf_on == '' || $zdytb_53kf_off == '' || "$zdytb" == 'no')
							{
								kf += '<div style="text-align:right;"><a style="color:#999;font-size:11px;margin-right:3px;display:inline-block;width:$width;text-decoration:none;line-height:20px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a></div>';
								html += "<div id='kf_hidden" + id + "' onclick='set_auto_hidden(" + id + ")' onmouseover='show_kf_icon(" + id + ");' onmouseout='hidden_kf_icon(" + id + ");' style='position:absolute; top:0; right:0;z-index:9000;height:" + (parseInt(this.config["height"],10) + 20) + "px;display:none;'>" + this.closeIcon() + kf + "</div>" + auto_hidden + "</div>";
							}
							else
							{
								html += "<div id='kf_hidden" + id + "' onclick='set_auto_hidden(" + id + ")' onmouseover='show_kf_icon(" + id + ");' onmouseout='hidden_kf_icon(" + id + ");' style='position:absolute; top:0; right:0;z-index:9000;height:" + this.config["height"]  + "px;display:none;'>" + get_zdytb_divs(this.config["isonline"],this.config["zdytb_on_arrs"],this.config["zdytb_off_arrs"],kf_icons[this.config["id"]].getClickUrl()) + "</div>" + auto_hidden + "</div>";
							}
							$53(this.config["iconDiv"]).innerHTML = html;
							this.iconDivMain = $53(this.config["iconDivMain"]);
							this.iconDivMain.style.height = Math.max(this.config["height"], parseInt($53("auto_hidden" + id).style.height.replace("px", ""))) + "px";
							this.iconDivMain.style.width = this.config['hidden_img_width'] + 'px';
							if (this.config["showmodel"] == 2) // 右侧显示 
							{
								$53("auto_hidden" + id).style.right = "0px";
								$53("kf_hidden" + id).style.right = "0px";
							}
							else
							{
								$53("auto_hidden" + id).style.left = "0px";
								$53("kf_hidden" + id).style.left = "0px";
							}
						}
HTML;
					}
				}
			}
			if ($posmodel == '4')
			{
				$icon = <<< HTML
				function show_kf_icon(ids)
				{
					$53("kf_hidden" + ids).style.display = "";
					$53("auto_hidden" + ids).style.visibility = "hidden";
				}
				//new
				function show_kf_icons(ids)
				{
					$53("KFLOGO").style.position = "";
					$53("kf_hidden" + ids).style.display = "";
					$53("auto_hidden" + ids).style.visibility = "hidden";
				}
				//end
				
				function hidden_kf_icon(ids)
				{
					$53("kf_hidden" + ids).style.display = "none";
					$53("auto_hidden" + ids).style.visibility = "visible";
				}
	
				function set_auto_hidden(ids)
				{
					$53("auto_hidden" + ids).style.visibility = "hidden";
				}
HTML;
			}
			$icon .= <<< HTML
			if (typeof(kf_icons) == "undefined")
			{
				var kf_icons = new Array();
	
				function hishow(id, img_url)
				{
					var divname = "hsdiv" + id;
					if ($53(divname).style.display == "none")
					{
						$53(divname).style.display = "block";
						$53("arrow" + id).src = "$http://{$talk_host}/" + img_url + "arrow1.gif";
					}
					else
					{
						$53(divname).style.display = "none";
						$53("arrow" + id).src = "$http://{$talk_host}/" + img_url + "arrow2.gif";
					}
				}
				//start
				function hishows(id, obj)
				{
					var divname = "hsdiv" + id,
						mark = obj.getAttribute('mark'),
						a = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_down_01.png',
						b = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_down.gif',
						c = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_left_01.png',
						d = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_left.gif';
						e = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_left_03.png';
						f = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_down_03.png';
					if ($53(divname).style.display == "none")
					{
						$53(divname).style.display = "block";
						if(mark == "changeIcon1")
						{
							$53("arrow" + id).src = b;
						}
						if(mark == "changeIcon2")
						{
							$53("arrow" + id).src = a;
						}
						if(mark == "changeIcon3")
						{
							$53("arrow" + id).src = f;
						}
					}
					else
					{
						$53(divname).style.display = "none";
						if(mark == "changeIcon1")
						{
							$53("arrow" + id).src = d;
						}
						if(mark == "changeIcon2")
						{
							$53("arrow" + id).src = c;
						}
						if(mark == "changeIcon3")
						{
							$53("arrow" + id).src = e;
						}
					}
				}
				//end
				function kfIcon()
				{
					this.config = {};
					this.left = -200; // 图标需要到达的 left 
					this.top = 0;
					this.width = 0; // 图标宽度 
					this.height = 0; // 图标宽度 
					this.offsetLeft = 0; // 距离左侧宽度，包括滚动过的距离 
					this.offsetTop = 0; //距离顶部宽度，包括滚动过的距离 
					this.scrolledX = 0; //图标水平滚动条滚动过的距离 
					this.scrolledY = 0;
					this.issmooth = false; //是否平滑移动 
					this.loopmillisecond = 100; //图标循环定位的毫秒，数值越大越慢，对CPU影响越小 
					this.Xstep = 4; //水平步进基数,数字越大越平滑，也越慢 
					this.Ystep = 4;
					this.pageW = 0; //页面总宽度 
					this.pageH = 0;
					this.display = ""; //是否显示图标,值 "none"|"" 
					this.iconDiv = null;
					this.iconDivMain = null;
					this.autoScrollTimer = null;
					this.init = _init;
					this.autoScroll = kfscroll;
					this.createIconDivMain = _createIconDivMain; // 
					this.setParameter = _setParameter; //在 createIconDivMain 中调用 
					this.wopen = _wopen; //同上 
					this.closeIcon = _closeIcon; //同上 
					this.hidden = _hidden; //同上 
					this.getClickUrl = _getClickUrl; // 获取点击的url 
				};
	
				function kfscroll()
				{
					try
					{
						this.offsetLeft = this.iconDivMain.offsetLeft;
						this.width = parseInt(this.iconDivMain.style.width.replace("px", ""));
						this.height = parseInt(this.iconDivMain.style.height.replace("px", ""));
					}
					catch (e)
					{
						//this.iconDivMain=$53(this.config["iconDivMain"]);
						return;
					}
	
					this.scrolledY = $53.getS().T;
					this.scrolledX = $53.getS().L;
					this.pageH = $53.getWH().H;
					this.pageW = $53.getWH().W;
	
					if (this.config["v_showmodel"] == 1)
					{
						if (this.top != (this.scrolledY + this.pageH))
						{
							var iconDivHeight = this.scrolledY + this.config["offsetH"] - this.offsetTop;
							iconDivHeight = (iconDivHeight > 0 ? 1 : -1) * Math.ceil(Math.abs(iconDivHeight));
							this.top = this.offsetTop + iconDivHeight;
						}
					}
					else
					{	
                        if(isNaN(this.height)){
                            this.height = document.getElementById(this.config["iconDivMain"]).offsetHeight;    
                        }
                        if (this.top != (this.scrolledY + this.pageH - this.height - this.config["offsetH"]))
                        {
                            				
                        	var iconDivHeight = this.scrolledY + this.pageH - this.height - this.config["offsetH"] - this.offsetTop;
                        	iconDivHeight = (iconDivHeight > 0 ? 1 : -1) * Math.ceil(Math.abs(iconDivHeight));
                        	this.top = this.offsetTop + iconDivHeight;
                        }
								
					}
	
					if (this.config["showmodel"] == 1)
					{
						if (this.left != (this.scrolledX + this.pageW))
						{
							var iconDivWidth = this.scrolledX + this.config["offsetW"] - this.offsetLeft;
							iconDivWidth = (iconDivWidth > 0 ? 1 : -1) * Math.ceil(Math.abs(iconDivWidth));
							this.left = this.offsetLeft + iconDivWidth;
						}
					}
					else
					{
						if (this.left != (this.scrolledX + this.pageW - this.width - this.config["offsetW"]))
						{
							var iconDivWidth = this.scrolledX + this.pageW - this.width - this.config["offsetW"] - this.offsetLeft;
							iconDivWidth = (iconDivWidth > 0 ? 1 : -1) * Math.ceil(Math.abs(iconDivWidth));
							this.left = this.offsetLeft + iconDivWidth;
						}
					}
	
					//set kf_icon postiotn
					//超出窗口边界，直接移动到窗口边界再平滑移动 
					var left = parseInt(this.iconDivMain.style.left.replace("px", ""));
					var top = parseInt(this.iconDivMain.style.top.replace("px", ""));
	
					if (this.issmooth == true)
					{
						if (left != this.left)
						{
							if (left < (this.scrolledX - this.width)) left = this.scrolledX - this.width;
							if (left > this.scrolledX + this.pageW) left = this.scrolledX + this.pageW;
							left = smoothMove(left, this.left);
						}
						if (top != this.top)
						{
							if (top < (this.scrolledY - this.height)) top = this.scrolledY - this.height;
							if (top > this.scrolledY + this.pageH) top = this.scrolledY + this.pageH;
							top = smoothMove(top, this.top);
						}
					}
					else if (this.issmooth == false)
					{
						left = this.left;
						top = this.top;
						this.issmooth = true;
					}
	
					this.iconDivMain.style.left = left + "px";
					this.iconDivMain.style.top = top + "px";
				};
	
				function _wopen(com)
				{
					if (this.config["is_zdyurl"] == 1) window.open(this.config["zdyurl"], "_blank", "height=" + $company_tpl_height + ",width=" + $company_tpl_width + ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no");
					else window.open(this.config["server_path"] + "/$visitorurl?arg=" + this.config["arg"] + com, "_blank", "height=" + $company_tpl_height + ",width=" + $company_tpl_width + ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no");
				};
	
				function _setParameter()
				{
					var params = "";
					params += this.config["style_id"];
					params += this.config["language"];
					params += this.config["onurl"];
					params += this.config["lytype"];
					params += this.config["lyurl"];
					params += this.config["copartner"];
					params += this.config["username"];
					params += this.config["userinfo"];
					params += this.config["charset"];
					params += this.config["introurl"];
					params += this.config["kf"];
					params += this.config["referer"];
					params += this.config["keyword"];
					params += this.config["tfrom"];
					params += this.config["company_tpl"];
					params += this.config["brief"];
					params += this.config["logo"];
					params += this.config["question"];
                                        params += this.config["u_stat_id"];
					return params;
				};
				
				function _getClickUrl()
				{
					var _click_str = '';
					if (this.config["record_url"] != "" && this.config["isonline"] == 0)
					{
						 _click_str += 'window.open(\'' + this.config["record_url"] + '\',\'_blank\')';
					}
					else
					{
						_click_str += 'setIsinvited();';
						if (this.config["is_zdyurl"] == 1)
						{
							_click_str += 'window.open(\'' + this.config["zdyurl"] + '\', \'_blank\', \'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
						}
						else
						{
							_click_str += 'window.open(\'' + this.config["server_path"] + '/$visitorurl?arg=' + this.config["arg"] + this.setParameter() + '\', \'_blank\', \'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
						}
					}
					return _click_str;
				}
	
				function _hidden()
				{
					hz6d_close_icon = 1;
					this.display = "none";
					$53(this.config["iconDivMain"]).style.display = "none";
					try
					{
						clearInterval(kf_icons[this.config["kf_icon_id"]].autoScrollTimer);
					}
					catch (e)
					{}
				};
	
				function _closeIcon()
				{
					var str_onmove = "";
					if ($kf_type == 1 && ('$list_type' == "new_blue" || '$list_type' == "new_red" || '$list_type' == "new_yellow" || '$list_type' == "new_green"))
					{
						str_onmove = "onmousemove='this.style.backgroundImage=\"url($http://$talk_host/img/kflist/list_close_move.gif)\"' onmouseout='this.style.backgroundImage=\"url(http://$talk_host/$close_icon)\"'";
					}
					if ($tb_close == 1 || $companyid == 600603 || $companyid == 61393572 || $companyid == 1413303 || $companyid == 61389920 || $companyid == 61420906 || $companyid == 61578368)
					{
						if ($kf_type == 1)
						{
							if ('$list_type' == "new_blue" || '$list_type' == "new_red" || '$list_type' == "new_yellow" || '$list_type' == "new_green")
							{
								var str_wh = "width:27px;height:16px;";
							}
							else if ('$list_type' == "blue")
							{
								var str_wh = "width:11px;height:11px;";
							}
							else if ('$list_type' == "blue2")
							{
								var str_wh = "width:14px;height:14px;";
							}
							else if ('$list_type' == "yellow")
							{
								var str_wh = "width:14px;height:14px;";
							}
							else if ('$list_type' == "yellow2")
							{
								var str_wh = "width:14px;height:13px;";
							}
							else if ('$list_type' == "black")
							{
								var str_wh = "width:14px;height:14px;";
							}
							else if ('$list_type' == "pink")
							{
								var str_wh = "width:18px;height:18px;";
							}
							else
							{
								var str_wh = "width:11px;height:11px;";
							}
							return "<div onclick='kf_icons[" + this.config["id"] + "].hidden()' style='" + str_wh + "background:url(\"$http://$talk_host/$close_icon\") no-repeat;position:absolute;right:{$close_icon_right}px;top:{$close_icon_top}px;cursor:pointer;' " + str_onmove + " ></div>";
						}
						return "<div onclick='kf_icons[" + this.config["id"] + "].hidden()' style='width:11px;height:11px;background:url(\"$http://$talk_host/$close_icon\") no-repeat;position:absolute;right:{$close_icon_right}px;top:{$close_icon_top}px;cursor:pointer;' ></div>";
					}
					return "";
				};
	
				function _init()
				{
					$53.creElm({id: this.config["iconDiv"],style:'height:auto;width:auto;'},'div');
					this.iconDiv = $53(this.config["iconDiv"]);
					this.createIconDivMain();
				};
			}
	
			if (typeof(kf_icon_id) == "undefined") kf_icon_id = 1;
			else kf_icon_id++;
			kf_icons[kf_icon_id] = new kfIcon();
			kf_icons[kf_icon_id].config["id"] = kf_icon_id;
			kf_icons[kf_icon_id].config["arg"] = "$arg";
			kf_icons[kf_icon_id].config["style_id"] = "$style_id";
			kf_icons[kf_icon_id].config["isonline"] = "$isonline";
	    kf_icons[kf_icon_id].config["zdytb_on_arrs"] = [];
	    kf_icons[kf_icon_id].config["zdytb_off_arrs"] = [];
	    if ($kf_type == 2)kf_icons[kf_icon_id].config["zdytb_on_arrs"] = init_zdytb_arr($tb_on_str);
	    if ($kf_type == 2)kf_icons[kf_icon_id].config["zdytb_off_arrs"] = init_zdytb_arr($tb_off_str);
			kf_icons[kf_icon_id].config["img_on"] = "$img_on";
			kf_icons[kf_icon_id].config["img_off"] = "$img_off";
			kf_icons[kf_icon_id].config["height"] = "$height";
			kf_icons[kf_icon_id].config["width"] = "$width";
			kf_icons[kf_icon_id].config["auto_hidden_img"] = "$auto_hidden_img";
			kf_icons[kf_icon_id].config["hidden_img_height"] = "$hidden_img_height";
			kf_icons[kf_icon_id].config["hidden_img_width"] = "$hidden_img_width";
			kf_icons[kf_icon_id].config["showmodel"] = parseInt("$showmodel");
			kf_icons[kf_icon_id].config["offsetW"] = parseInt("$offset_width");
			kf_icons[kf_icon_id].config["v_showmodel"] = parseInt("$v_showmodel");
			kf_icons[kf_icon_id].config["offsetH"] = parseInt("$offset_height");
			kf_icons[kf_icon_id].config["language"] = "$language";
			kf_icons[kf_icon_id].config["username"] = "$username";
			kf_icons[kf_icon_id].config["userinfo"] = "$userinfo";
			kf_icons[kf_icon_id].config["charset"] = "$charset";
			kf_icons[kf_icon_id].config["introurl"] = "$introurl";
			kf_icons[kf_icon_id].config["onurl"] = "$onurl";
			kf_icons[kf_icon_id].config["lytype"] = "$lytype";
			kf_icons[kf_icon_id].config["lyurl"] = "$lyurl";
			kf_icons[kf_icon_id].config["copartner"] = "$copartner";
			kf_icons[kf_icon_id].config["kf"] = "$kf";
			kf_icons[kf_icon_id].config["referer"] = hz6d_referer;
			kf_icons[kf_icon_id].config["keyword"] = hz6d_from_page_new;
			kf_icons[kf_icon_id].config["tfrom"] = "&tfrom=1";
			kf_icons[kf_icon_id].config["record_url"] = "$record_url";
                        kf_icons[kf_icon_id].config["u_stat_id"] = "$u_stat_id";                                
			var hz6d_zdyurl = "$zdyurl";
			hz6d_zdyurl = hz6d_html_replace(hz6d_zdyurl);
			kf_icons[kf_icon_id].config["zdyurl"] = hz6d_zdyurl;
			kf_icons[kf_icon_id].config["is_zdyurl"] = "$is_zdyurl";
			kf_icons[kf_icon_id].config["path"] = "http://$master_host";
			kf_icons[kf_icon_id].config["server_path"] = "$server_path";
			kf_icons[kf_icon_id].config["company_tpl"] = "&tpl=$company_tpl";
			kf_icons[kf_icon_id].config["brief"] = "$brief";
			kf_icons[kf_icon_id].config["logo"] = "$logo";
			kf_icons[kf_icon_id].config["iconDivMain"] = "iconDivMain" + kf_icon_id;
			kf_icons[kf_icon_id].config["iconDiv"] = "iconDiv" + kf_icon_id;
			kf_icons[kf_icon_id].config["question"] = "$question";
			$53.ready(function(){kf_icons[kf_icon_id].init()});
			kf_icons[kf_icon_id].autoScrollTimer = window.setInterval("kf_icons[" + kf_icon_id + "].autoScroll()", kf_icons[kf_icon_id].loopmillisecond);
HTML;
			//浮动图标/浮动伸缩 模式结束
		}
		elseif ($posmodel == '2')
		{//嵌入固定模式开始
			$icon .= <<< HTML
			if (typeof(kf_icon_id) == "undefined")
			{
				kf_icon_id = 1;
			}
			else
			{
				kf_icon_id++;
			}
HTML;
			$openurl = "$server_path/$visitorurl?arg=$arg$style_id$kf$language$username$userinfo$charset$introurl$onurl$lytype$lyurl$copartner$referer$keyword&tpl=$company_tpl$logo$brief$question$u_stat_id";
                        if ($is_zdyurl == 1)
				$openurl = $zdyurl;
			if ($kf_type == 1)
			{
				if($tblist_arr)
				{
					$kf_list_shows = $tblist_arr;
					$kf_list_shows = kf_list_czu($openurl,$tblist_arr,$dept_man_show);
					$icon .= <<< HTML
					function hishows(id, obj)
					{
						var divname = "hsdiv" + id,
							mark = obj.getAttribute('mark'),
							a = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_down_01.png',
							b = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_down.gif',
							c = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_left_01.png',
							d = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_left.gif';
							e = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_left_03.png';
							f = '$http://{$talk_host}/style/setting/ver06/img/icon/logo-skin/list_img/arrow_down_03.png';
						if ($53(divname).style.display == "none")
						{
							$53(divname).style.display = "block";
							if(mark == "changeIcon1")
							{
								$53("arrow" + id).src = b;
							}
							if(mark == "changeIcon2")
							{
								$53("arrow" + id).src = a;
							}
							if(mark == "changeIcon3")
							{
								$53("arrow" + id).src = f;
							}
						}
						else
						{
							$53(divname).style.display = "none";
							if(mark == "changeIcon1")
							{
								$53("arrow" + id).src = d;
							}
							if(mark == "changeIcon2")
							{
								$53("arrow" + id).src = c;
							}
							if(mark == "changeIcon3")
							{
								$53("arrow" + id).src = e;
							}
						}
					}
HTML;
					$icon .= "hz6d_kf_list_show=hz6d_html_replace(\"$kf_list_shows\");$53.insertFixed(hz6d_kf_list_show);";
				}
				else
				{
					$icon .= <<< HTML
					function hishow(id, img_url)
					{
						var divname = "hsdiv" + id;
						if ($53(divname).style.display == "none")
						{
							$53(divname).style.display = "block";
							$53("arrow" + id).src = "$http://{$talk_host}/" + img_url + "arrow1.gif";
						}
						else
						{
							$53(divname).style.display = "none";
							$53("arrow" + id).src = "$http://{$talk_host}/" + img_url + "arrow2.gif";
						}
					}
HTML;
					$list = kf_list_make($openurl, $posmodel, $dept_man_show);
					$kf_list_show = $list[0];
					$icon .= "hz6d_kf_list_show=hz6d_html_replace(\"$kf_list_show\");$53.insertFixed(hz6d_kf_list_show);set_hz6d_bottom_logo();";
				}
			}
			else
			{
				//new 自定义图标 start
				if("$is_offzdytb" || "$is_onzdytb")
				{
					if($isonline == "1")
					{
						if("$is_onzdytb")
						{
							$icon .= <<< HTML
							function getClickUrl_4()
								{
									var _click_str = '';
									if ("$record_url" != "" && "$isonline" == "0")
									{
										_click_str += 'window.open(\'$record_url\',\'_blank\')';
									}
									else
									{
										_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
									}
									return _click_str;
								}
							hz6d_con_img = hz6d_clicurl($isonline,'$onval_arr','$offval_arr',getClickUrl_4());;
							$53.insertFixed("<div style='overflow:hidden;'>"+ hz6d_con_img + "</div>");
HTML;
						}
						else
						{
							if ($zdytb_53kf_on != '""' && $zdytb_53kf_off != '""' && "$zdytb" == 'yes')
							{
								$icon .= <<< HTML
								function getClickUrl_4()
								{
									var _click_str = '';
									if ("$record_url" != "" && "$isonline" == "0")
									{
										_click_str += 'window.open(\'$record_url\',\'_blank\')';
									}
									else
									{
										_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
									}
									return _click_str;
								}
								var zdytb_on_arrs = init_zdytb_arr($zdytb_53kf_on);
								var zdytb_off_arrs = init_zdytb_arr($zdytb_53kf_off);
								var div_str = get_zdytb_divs($isonline,zdytb_on_arrs,zdytb_off_arrs,getClickUrl_4());
								hz6d_con_img = hz6d_html_replace(div_str);
								$53.insertFixed("<div>"+ hz6d_con_img + "</div>");
HTML;
							}
							else
							{
								$con_img = "<img src='{$img_on}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
								$con_img = '<div style=\"width:' . $width . 'px\">' . $con_img . '<div style=\"text-align:right\"><a style=\"color:#999;line-height:20px;margin-right:3px;font-size:11px;text-decoration:none;' . $power_by_53kf_style . '\" onmouseout=\"this.style.textDecoration=\'none\'\" onmouseover=\"this.style.textDecoration=\'underline\'\" target=\"_blank\" href=\"' . $powered_by_53kf_url . '\">' . $powered_by_53kf_txt . '</a></div></div>';
								$icon .= "hz6d_con_img = hz6d_html_replace(\"$con_img\");$53.insertFixed(hz6d_con_img);";//document.write(hz6d_con_img);
							}
						}
					}
					else
					{
						if("$is_offzdytb")
						{
							$icon .= <<< HTML
							function getClickUrl_4()
								{
									var _click_str = '';
									if ("$record_url" != "" && "$isonline" == "0")
									{
										_click_str += 'window.open(\'$record_url\',\'_blank\')';
									}
									else
									{
										_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
									}
									return _click_str;
								}
							hz6d_con_img = hz6d_clicurl($isonline,'$onval_arr','$offval_arr',getClickUrl_4());
							$53.insertFixed("<div style='overflow:hidden;'>"+ hz6d_con_img + "</div>");
HTML;
						}
						else
						{
							if ($zdytb_53kf_on != '""' && $zdytb_53kf_off != '""' && "$zdytb" == 'yes')
							{
								$icon .= <<< HTML
								function getClickUrl_4()
								{
									var _click_str = '';
									if ("$record_url" != "" && "$isonline" == "0")
									{
										_click_str += 'window.open(\'$record_url\',\'_blank\')';
									}
									else
									{
										_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
									}
									return _click_str;
								}
								var zdytb_on_arrs = init_zdytb_arr($zdytb_53kf_on);
								var zdytb_off_arrs = init_zdytb_arr($zdytb_53kf_off);
								var div_str = get_zdytb_divs($isonline,zdytb_on_arrs,zdytb_off_arrs,getClickUrl_4());
								hz6d_con_img = hz6d_html_replace(div_str);
								$53.insertFixed("<div>"+ hz6d_con_img + "</div>");
HTML;
							}
							else
							{
								if ($record_url != "")
								{
									$con_img = "<a href='$record_url' target='_blank'><img src='{$img_off}' border='0' style='cursor:pointer'/></a>";
								}
								else
								{
									$con_img = "<img src='{$img_off}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
								}
								$con_img = '<div style=\"width:' . $width . 'px\">' . $con_img . '<div style=\"text-align:right\"><a style=\"color:#999;line-height:20px;margin-right:3px;font-size:11px;text-decoration:none;' . $power_by_53kf_style . '\" onmouseout=\"this.style.textDecoration=\'none\'\" onmouseover=\"this.style.textDecoration=\'underline\'\" target=\"_blank\" href=\"' . $powered_by_53kf_url . '\">' . $powered_by_53kf_txt . '</a></div></div>';
								$icon .= "hz6d_con_img = hz6d_html_replace(\"$con_img\");$53.insertFixed(hz6d_con_img);";//document.write(hz6d_con_img);
							}
						}
					}
				}
				else
				{
					if ($zdytb_53kf_on != '""' && $zdytb_53kf_off != '""' && "$zdytb" == 'yes')
					{
						$icon .= <<< HTML
						function getClickUrl_4()
						{
							var _click_str = '';
							if ("$record_url" != "" && "$isonline" == "0")
							{
								_click_str += 'window.open(\'$record_url\',\'_blank\')';
							}
							else
							{
								_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
							}
							return _click_str;
						}
						var zdytb_on_arrs = init_zdytb_arr($zdytb_53kf_on);
						var zdytb_off_arrs = init_zdytb_arr($zdytb_53kf_off);
						var div_str = get_zdytb_divs($isonline,zdytb_on_arrs,zdytb_off_arrs,getClickUrl_4());
						hz6d_con_img = hz6d_html_replace(div_str);
						$53.insertFixed("<div>"+ hz6d_con_img + "</div>");
HTML;
					}
					else
					{
						if ($isonline == "1")
						{
							$con_img = "<img src='{$img_on}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
						}
						else
						{
							if ($record_url != "")
							{
								$con_img = "<a href='$record_url' target='_blank'><img src='{$img_off}' border='0' style='cursor:pointer'/></a>";
							}
							else
							{
								$con_img = "<img src='{$img_off}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
							}
							
						}
						$con_img = '<div style=\"width:' . $width . 'px\">' . $con_img . '<div style=\"text-align:right\"><a style=\"color:#999;line-height:20px;margin-right:3px;font-size:11px;text-decoration:none;' . $power_by_53kf_style . '\" onmouseout=\"this.style.textDecoration=\'none\'\" onmouseover=\"this.style.textDecoration=\'underline\'\" target=\"_blank\" href=\"' . $powered_by_53kf_url . '\">' . $powered_by_53kf_txt . '</a></div></div>';
						$icon .= "hz6d_con_img = hz6d_html_replace(\"$con_img\");$53.insertFixed(hz6d_con_img);";//document.write(hz6d_con_img);
					}
				}
			}
			//嵌入固定模式结束
		}
		elseif ($posmodel == '3')
		{//浮动固定模式开始
			$openurl = "$server_path/$visitorurl?arg=$arg$style_id$kf$language$username$userinfo$charset$introurl$onurl$lytype$lyurl$copartner$referer$keyword&tpl=$company_tpl$logo$brief$question$u_stat_id";
                        if ($is_zdyurl == 1)
				$openurl = $zdyurl;
			$icon .= <<< HTML
			if (typeof(kf_icon_id) == "undefined")
			{
				kf_icon_id = 1;
			}
			else
			{
				kf_icon_id++;
			}
	
			function hz6d_createFixedDiv(html)
			{
				var div = document.createElement("div");
				div.style.position = "fixed";
				div.style.zIndex = "10085";
				div.style.margin = 0;
				if (!hasdoctype) div.style.position = "absolute";
				div.id = "hz6d_kf_icon_" + kf_icon_id;
				if ($v_showmodel == 1)
				{
					div.style.top = "$offset_height" + "px";
				}
				else
				{
					div.style.bottom = "$offset_height" + "px";
				}
				if ($showmodel == 1)
				{
					div.style.left = "$offset_width" + "px";
				}
				else
				{
					div.style.right = "$offset_width" + "px";
				}
				if ($zdytb_53kf_on != '' && $zdytb_53kf_off != '' && "$zdytb" == 'yes' && $kf_type == 2)
				{
					div.innerHTML = html;
				}
				else
				{
					if ("$zdytb" == 'no' && $kf_type == 2) {
						html += '<div style="text-align:right"><a style="color:#999;line-height:20px;margin-right:3px;font-size:11px;text-decoration:none;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a></div>';
					}
					div.innerHTML = html + hz6d_closeIcon(kf_icon_id);
				}
				var doc = (document.body||document.documentElement);
				doc.insertBefore(div,doc.firstChild);
			
			}
			//new start
			function hz6d_createFixedDivss(html)
			{
				var div = document.createElement("div");
				div.style.position = "fixed";
				div.style.zIndex = "10085";
				div.style.overflow = "hidden";
				div.style.margin = 0;
				if (!hasdoctype) div.style.position = "absolute";
				div.id = "hz6d_kf_icon_" + kf_icon_id;
				html = html.replace(/position: absolute/,function(){
					return 'position:relative';
				});
				if ($v_showmodel == 1)
				{
					div.style.top = "$offset_height" + "px";
				}
				else
				{
					div.style.bottom = "$offset_height" + "px";
				}
				if ($showmodel == 1)
				{
					div.style.left = "$offset_width" + "px";
				}
				else
				{
					div.style.right = "$offset_width" + "px";
				}
				if ($zdytb_53kf_on != '' && $zdytb_53kf_off != '' && "$zdytb" == 'yes' && $kf_type == 2)
				{
					div.innerHTML = html;
				}
				else
				{
					
					div.innerHTML = html;
				}
				var doc = (document.body||document.documentElement);
				doc.insertBefore(div,doc.firstChild);
			}
			//new end
			function hz6d_closeIcon(kf_icon_id)
			{
				var str_onmove = "";
				if ($kf_type == 1 && ('$list_type' == "new_blue" || '$list_type' == "new_red" || '$list_type' == "new_yellow" || '$list_type' == "new_green"))
				{
					str_onmove = "onmousemove='this.src=\"$http://$talk_host/img/kflist/list_close_move.gif\"' onmouseout='this.src=\"$http://$talk_host/$close_icon\"'";
				}
				if ($tb_close == 1 || $companyid == 600603 || $companyid == 61393572 || $companyid == 1413303 || $companyid == 61389920 || $companyid == 61420906 || $companyid == 61578368)
				{
					if ($kf_type == 1)
					{
						return "<img onclick='$53(\"hz6d_kf_icon_" + kf_icon_id + "\").style.display=\"none\"' style='position:absolute; right:{$close_icon_right}px;top:{$close_icon_top}px; cursor:pointer;' src='$http://$talk_host/$close_icon' " + str_onmove + " />";
					}
					return "<img onclick='$53(\"hz6d_kf_icon_" + kf_icon_id + "\").style.display=\"none\"' style='position:absolute; right:{$close_icon_right}px;top:{$close_icon_top}px; cursor:pointer;' src='$http://$talk_host/$close_icon' />";
				}
				return "";
			}
HTML;
			if ($kf_type == 1)
			{
				if($tblist_arr)
				{
					$kf_list_shows = $tblist_arr;
					$kf_list_shows = kf_list_czu($openurl,$tblist_arr,$dept_man_show);
					$icon .= <<< HTML
					function hishows(id)
					{
						var divname = "hsdiv" + id;
						if ($53(divname).style.display == "none")
						{
							$53(divname).style.display = "block";
							$53("arrow" + id).src = "$http://static.53rj.com.cn/img/logo-skin/list_img/arrow_down.gif";
						}
						else
						{
							$53(divname).style.display = "none";
							$53("arrow" + id).src = "$http://static.53rj.com.cn/img/logo-skin/list_img/arrow_left.gif";
						}
					}
HTML;
					$icon .= "hz6d_kf_list_show=hz6d_html_replace(\"$kf_list_shows\");hz6d_createFixedDivss(hz6d_kf_list_show);";
				}
				else
				{
					$icon .= <<< HTML
					function hishow(id, img_url)
					{
						var divname = "hsdiv" + id;
						if ($53(divname).style.display == "none")
						{
							$53(divname).style.display = "block";
							$53("arrow" + id).src = "$http://{$talk_host}/" + img_url + "arrow1.gif";
						}
						else
						{
							$53(divname).style.display = "none";
							$53("arrow" + id).src = "$http://{$talk_host}/" + img_url + "arrow2.gif";
						}
					}
HTML;
					$list = kf_list_make($openurl, $posmodel, $dept_man_show);
					$kf_list_show = $list[0];
					$icon .= "hz6d_kf_list_show=hz6d_html_replace(\"$kf_list_show\");hz6d_createFixedDiv(hz6d_kf_list_show);set_hz6d_bottom_logo();";
				}
				
			}
			else
			{
				if("$is_offzdytb" || "$is_onzdytb")
				{
					if($isonline == "1")
					{
						if("$is_onzdytb")
						{
							$icon .= <<< HTML
							function getClickUrl_3()
							{
								var _click_str = '';
								if ("$record_url" != "" && "$isonline" == "0")
								{
									_click_str += 'window.open(\'$record_url\',\'_blank\')';
								}
								else
								{
									_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
								}
								return _click_str;
							}
							hz6d_con_img = hz6d_clicurl($isonline,'$onval_arr','$offval_arr',getClickUrl_3());
							hz6d_createFixedDivss(hz6d_con_img);
HTML;
						}
						else
						{
							$con_img = "<img src='{$img_on}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
							$icon .= "hz6d_con_img=hz6d_html_replace(\"$con_img\");hz6d_createFixedDiv(hz6d_con_img);";
						}
					}
					else
					{
						if("$is_offzdytb")
						{
							$icon .= <<< HTML
							function getClickUrl_3()
							{
								var _click_str = '';
								if ("$record_url" != "" && "$isonline" == "0")
								{
									_click_str += 'window.open(\'$record_url\',\'_blank\')';
								}
								else
								{
									_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
								}
								return _click_str;
							}
							var div_str = hz6d_clicurl($isonline,'$onval_arr','$offval_arr',getClickUrl_3());
							hz6d_con_img = hz6d_html_replace(div_str);
							hz6d_createFixedDivss(hz6d_con_img);
HTML;
						}
						else
						{
							if ($record_url != "")
							{
								$con_img = "<a href='$record_url' target='_blank'><img src='{$img_off}' border='0' style='cursor:pointer'/></a>";
							}
							else
							{
								$con_img = "<img src='{$img_off}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
							}
							$icon .= "hz6d_con_img=hz6d_html_replace(\"$con_img\");hz6d_createFixedDiv(hz6d_con_img);";
						}
					}
				}
				else
				{
					if ($zdytb_53kf_on != '""' && $zdytb_53kf_off != '""' && "$zdytb" == 'yes')
					{
						$icon .= <<< HTML
						function getClickUrl_3()
						{
							var _click_str = '';
							if ("$record_url" != "" && "$isonline" == "0")
							{
								_click_str += 'window.open(\'$record_url\',\'_blank\')';
							}
							else
							{
								_click_str += 'setIsinvited();window.open(\'$openurl\',\'_blank\',\'height=$company_tpl_height,width=$company_tpl_width,top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=$resize,scrollbars=no,location=no,titlebar=no\')';
							}
							return _click_str;
						}
						var zdytb_on_arrs = init_zdytb_arr($zdytb_53kf_on);
						var zdytb_off_arrs = init_zdytb_arr($zdytb_53kf_off);
						var div_str = get_zdytb_divs($isonline,zdytb_on_arrs,zdytb_off_arrs,getClickUrl_3());
						hz6d_con_img = hz6d_html_replace(div_str);
						hz6d_createFixedDiv(hz6d_con_img);
HTML;
					}
					else
					{
						if ($isonline == "1")
						{
							$con_img = "<img src='{$img_on}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
							$icon .= "hz6d_con_img=hz6d_html_replace(\"$con_img\");hz6d_createFixedDiv(hz6d_con_img);";
						}
						else
						{
							if ($record_url != "")
							{
								$con_img = "<a href='$record_url' target='_blank'><img src='{$img_off}' border='0' style='cursor:pointer'/></a>";
							}
							else
							{
								$con_img = "<img src='{$img_off}' border='0' onclick='setIsinvited();window.open(\\\"$openurl\\\",\\\"_blank\\\",\\\"height=" . $company_tpl_height . ",width=" . $company_tpl_width . ",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=" . $resize . ",scrollbars=no,location=no,titlebar=no\\\")' style='cursor:pointer'/>";
							}
							$icon .= "hz6d_con_img=hz6d_html_replace(\"$con_img\");hz6d_createFixedDiv(hz6d_con_img);";
						}
					}
				}
			}
			//浮动固定模式结束
		}
		{// 设置列表模式下的logo显示
		echo <<< HTML
		function set_hz6d_bottom_logo() {
			try {
				if ('$kf_version_type' != "oem")
				{
					clearTimeout(set_hz6d_bottom_logo.timer);
					$53("hz6d_bottom_logo").style.textAlign = 'right';
					$53("hz6d_bottom_logo").style.textIndent = '0px';
					if("$list_type" == 'pink' || "$list_type" == 'yellow2'  || "$list_type" == 'blue2')
					{
						$53("hz6d_bottom_logo").style.lineHeight = $53("hz6d_bottom_logo").parentNode.offsetHeight + 'px';
						$53("hz6d_bottom_logo").style.position = 'relative';
						$53("hz6d_bottom_logo").style.top = '6px';
					}
					$53("hz6d_bottom_logo").style.backgroundImage = '';
					if ("$list_log_flag" == true) {
						$53("hz6d_bottom_logo").innerHTML  = '<a style="text-decoration:none;color:#999;display:inline-block;margin-right:8px;font-size:11px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + powered_by_53kf_txt + '</a>';
					}
					else {
						$53("hz6d_bottom_logo").innerHTML  = '<a style="text-decoration:none;color:#999;display:inline-block;margin-right:8px;font-size:11px;$power_by_53kf_style" onmouseout="this.style.textDecoration=\'none\'" onmouseover="this.style.textDecoration=\'underline\'" target="_blank" href="' + powered_by_53kf_url + '">' + $53("hz6d_bottom_logo").innerHTML + '</a>';
					}
					$53("hz6d_bottom_logo").style.display = '';
				}
			} catch(e) {
				set_hz6d_bottom_logo.timer = setTimeout(set_hz6d_bottom_logo,100);
			}
		}
HTML;
		}
		//模式选择结束，输出图标
		echo $icon;
	}
}

echo <<< HTML
	if (!$53("stat_script")){
		//document.write("<scr"+"ipt src='http://$talk_host/stat.php?com_id=$companyid" + hz6d_referer + hz6d_from_page_new + "' type='text/javascript' id='stat_script'></scr"+"ipt>");
		$53.createScript('stat_script','$http://$talk_host/stat.php?com_id=$companyid' + hz6d_referer + hz6d_from_page_new + "&talktitle=" + encodeURIComponent(document.title));
	}
HTML;
echo <<< HTML
(function() {
	var datas = {
		visit_uuid : '$visit_uuid',
		company_id : '$companyid',
		guest_id : '$guest_id',
		site_uid : '11111111',
		in_time : '$in_time',
		page_url : location.href,
		browser : $53.getBrowser(),
		ip : '$myip',
		system : $53.getOs(),
		screen : $53.getScreen(),
		is_uv : $53.data('is_uv'),
		is_rv : $53.data('is_rv'),
		page_referer : $53.data('page_referer'),
		page_type : $53.data('page_type'),
		visitor_type : $53.getCookie('visitor_type') == 'new' ? 1 : 0 ,
		visit_num : $53.data('visit_num')
	};
	if (!$53("stat_new_script")) {
		//document.write("<scr"+"ipt src='http://$talk_host/stat_new.php?" + $53.json2str(datas,'urlencode') + "' type='text/javascript' id='stat_new_script'></scr"+"ipt>");
	}
})();
HTML;
if($is_mobile_os) exit();


if ("$etel" == "on" && "$etel_auto_code" == "1")
{
	echo <<< HTML
	//document.write("<scr"+"ipt src='http://$talk_host/kf_etel.php?arg=$arg$style_id"+hz6d_from_page_new+"' type='text/javascript'></scr"+"ipt>");
	$53.createScript('','$http://$talk_host/kf_etel.php?arg=$arg$style_id' + hz6d_from_page_new);
HTML;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
function get_value($get_name, $re = "")
{
	if (isset($_GET[$get_name]) && trim($_GET[$get_name]) != "")
	{
		if($get_name == 'style')
		{
			$re = addslashes(intval($_GET[$get_name]));
		}
		else
		{
			$re = addslashes($_GET[$get_name]);
		}
	}
	return $re;
}
function get_style_result($re, $style_id)
{
	$re2 = array();
	foreach ($re as $v)
	{
		if ($v["style_id"] == $style_id){
			$v["config_value"]=str_replace('&#039;','\&#039;',$v["config_value"]);
			$re2[] = $v;}
	}
	return $re2;
}
function get_style_lock($stylename)
{
	global $agent_style_lock;
	foreach ($agent_style_lock as $vv)
	{
		if ($vv["stylename"] == $stylename)
			return true;
	}
	return false;
}
function get_agent_config_value($config_id, &$config_value)
{
	global $agent_config;
	foreach ($agent_config as $vv)
	{
		if ($vv["config_id"] == $config_id)
		{
			$config_value = trim($vv["config_value"]);
			return;
		}
	}
}
function get_config_value($v_id, $v_value, $config_id, &$config_value)
{
	if ($v_id == $config_id)
	{
		$config_value = trim($v_value);
		return true;
	}
	return false;
}
function get_config($re, $config_id)
{
	foreach ($re as $v)
	{
		if ($v["config_id"] == $config_id)
			return true;
	}
	return false;
}
function get_logo_info()
{
	global $mem_re, $master_host, $logo_id, $img_on, $img_off, $height, $width, $close_icon, $close_icon_right, $close_icon_top,
		$talk_host, $list_type, $kf_type ,$http;
	$logos = mem_get('kf_logo');

	foreach ($logos as $logo)
	{
		if ($logo["id"] == $logo_id)
		{
			$img_on = "$http://" . $talk_host . $logo["url"];
			$img_name = substr($img_on, strrpos($img_on, "/"), strrpos($img_on, ".") - strrpos($img_on, "/"));
			$img_off = substr($img_on, 0, strrpos($img_on, "/")) . $img_name . "_off" . substr($img_on, strrpos($img_on, "."));
			$height = $logo["height"];
			$width = $logo["width"];
			$close_icon = $logo["close_url"];
			if ($close_icon == false)
			{
				$close_icon = 'img/kflogo/close.gif';
				$close_icon_right = '0';
				$close_icon_top = '0';
				if ($kf_type == "1" && ($list_type == "new_blue" || $list_type == "new_red" || $list_type == "new_yellow" || $list_type == "new_green"))
				{
					$close_icon_right = '5';
					$close_icon_top = '0';
				}
			}
			else
			{
				$close_icon_right = $logo["right_margin"];
				$close_icon_top = $logo["top_margin"];
			}
			return;
		}
	}
}
function get_module_value($module_id)
{

	return true;
}
function get_module_special_value($module_id)
{

	return true;
}
function kf_list_make($openurl, $posmodel, $dept_man_show)
{
	global $group_arr, $language, $ocharset, $company_tpl_height, $company_tpl_width, $zdkf_type, $arg, $kf_show, $companyid, $talk_host, $list_type, $kf_expand;
	$list_arr = array("new_blue", "new_red", "new_yellow", "new_green", "blue", "blue2", "yellow", "black", "pink", "yellow2");
	if (array_search($list_type, $list_arr, true) === false) {
		$list_type = "blue";
	}
	$type_color = explode("_", $list_type);
	include ("kf_list/kf_list_" . $type_color[0] . ".php");
	$strarr = kf_list($openurl, $posmodel, $dept_man_show);
	$str = $strarr[0];
	$str = mb_convert_encoding($str, "HTML-ENTITIES", "UTF-8");
	$list = array();
	$list[0] = $str;
	$list[2] = $strarr[2];
	return $list;
}
//new kf_list start
function kf_list_czu($openurl,$kflists,$dept_man_show)
{
	global $group_arr,$language,$languages,$ocharset,$company_tpl_height, $company_tpl_width,$zdkf_type,$arg,$kf_show,$companyid,$talk_host,$list_title,$list_phone,$list_type,$resize,$cfg,$kf_expand,$order_groups;
	$oldopenurl=$openurl;
	switch($languages)
	{
		case 'simplified':
			$state_wd_on="咨询";
			$state_wd_off="留言";
			break;
		case 'complex':
			$state_wd_on="咨詢";
			$state_wd_off="留言";
			break;
		case 'english':
			$state_wd_on="on";
			$state_wd_off="off";
			break;
		case 'japanese':
			$state_wd_on="諮問";
			$state_wd_off="メモ";
			break;
		case 'korean':
			$state_wd_on="자문";
			$state_wd_off="글";
			break;
		default:
			$state_wd_on="咨询";
			$state_wd_off="留言";
			break;
	}
	
	if($kflists)
	{
		$list_kfarr = explode("#@",$kflists);
		$list_str = $list_kfarr[0];
		$list_strtit = explode("#%@title",$list_str);
		if($list_strtit[2])
		{
			$list_str = $list_strtit[0];
			$list_str .= $list_title;
			$list_str .= $list_strtit[2];
		}
		$list_strs = explode("#!%",$list_kfarr[1]);
		$list_strss = explode("@#!",$list_kfarr[2]);
		$zx_str = "";
		$zx_strs = "";
		$bumens = "";
		$l = 0;
                if($zdkf_type == 1){
                    $tmp_worker = array();
                    foreach($group_arr as $k=>$v){
                        $dpt_dis="";
                        if($dept_man_show==2 && $zdkf_type==1)
                                $dpt_dis="display:none";
                        if($kf_expand==2)
                        {
                                $kf_expand_display = "display:none";
                        }
                        if($dpt_dis)
                        {
                                $zx_str = str_replace("display:block",$dpt_dis,$list_strs[0]);
                                $kf_ylist = str_replace("display:none","display:block",$list_strss[0]);
                                $kf_user = '<div>';
                        }
                        else
                        {
                                $add_show = str_replace('operating=\"show\"','onclick=\"hishows('.($l+1).', this)\"',$list_strs[0]);
                                $zx_str = $add_show;
                                $zx_str = str_replace('id=\"arrow1\"','id=\"arrow'.($l+1).'\"',$zx_str);
                                $kf_ylist = $list_strss[0];
                                $kf_ylist = str_replace('id=\"hsdiv1\"',' ',$kf_ylist);
                                $kf_ylist = str_replace('display:none;',' ',$kf_ylist);
                                $kf_user = '<div id= \"hsdiv'.($l+1).'\" style=\"'.$kf_expand_display.'\">';
                        }
                        $l++;
                        $zx_str .= $v["name"].'['.$v["online_num"].']';
                        $zx_str .= $list_strs[2];
                        $zx_strs = "";
                        foreach($v["worker_name"] as $kk=>$vv)
                        {
                                if(($v["online"][$kk]==0 || $v["state"][$kk]==0) && $kf_show==2)
                                continue;
                                if(in_array($v["worker_id"][$kk],$tmp_worker) && $dept_man_show==2){
                                    continue;
                                }
                                if($v["online"][$kk]==1 && $v["state"][$kk]==1)
                                        $state="<span style=\\\"color:#FF6000;\\\">".$state_wd_on."</span>";
                                else
                                        $state="<span style=\\\"color:#999999;\\\">".$state_wd_off."</span>";
                                $openurl=$oldopenurl."&kf=".$v["worker_id"][$kk]."&zdkf_type=1&kflist=off";
                                $new_clic_url = "window.open(\"".$openurl."\",\"_blank\",\"height=".$company_tpl_height.",width=".$company_tpl_width.",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=".$resize.",scrollbars=no,location=no,titlebar=no\")";
                                $new_clic_url = urlencode($new_clic_url);
                                $cli_zixun = 'onclick=\"setIsinvited();hz6d_is_exists(\''.$new_clic_url.'\',\''.$v["worker_id"][$kk].'\');return false;\" style=\"cursor:pointer\"';
                                $cli_zixuns = str_replace('operating=\"zixun\"',$cli_zixun,$kf_ylist);
                                $zx_strs .= $cli_zixuns;
                                $zx_strs .= '<div style=\"float:left;width:100px;height:28px;overflow:hidden;margin-left:2px;cursor:pointer;\">';
                                $zx_strs .= $vv;
                                $zx_strs .= '</div>';
                                $zx_strs .= '<div style=\"position:absolute;height:28px;overflow:hidden;right:5px;cursor:pointer;\">';
                                $zx_strs .= 
                                "[<a style='cursor:pointer;font-size:12px;padding-left:0;margin-left:0;'>".$state."</a>]";
                                $zx_strs .= '</div>';
                                $zx_strs .= $list_strss[2];
                                if($dept_man_show==2){
                                    array_push($tmp_worker, $v["worker_id"][$kk]);
                                }
                        }
                        $kf_user = $kf_user.$zx_strs.'</div>';
                        $bumens .= '<div>';
                        $bumens .=$zx_str;
                        $bumens .=$kf_user;
                        $bumens .= '</div>';
                    }
                }else if ($zdkf_type == 2){
                    foreach($group_arr as $k=>$v){
                        $dpurl=$oldopenurl."&kf=".$k."&zdkf_type=2";
                        $bum_clic = "onclick='setIsinvited();window.open(\\\"$dpurl\\\",\\\"_blank\\\",\\\"height=".$company_tpl_height.",width=".$company_tpl_width.",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=".$resize.",scrollbars=no,location=no,titlebar=no\\\");return false;'";
                        $add_show = str_replace('operating=\"show\"',$bum_clic,$list_strs[0]);
                        $zx_str = str_replace('id=\"arrow1\"','id=\"arrow'.($l+1).'\"',$add_show);
                        $zx_str .= $v["name"];
                        $zx_str .= $list_strs[2];
                        $bumens .= '<div>';
                        $bumens .=$zx_str;
                        $bumens .= '</div>';
                    }
                }else if($zdkf_type == 3){
                    foreach($order_groups as $k => $v){
                        $dpurl=$oldopenurl."&kf=".$v['group_id']."&zdkf_type=3";
                        $bum_clic = "onclick='setIsinvited();window.open(\\\"$dpurl\\\",\\\"_blank\\\",\\\"height=".$company_tpl_height.",width=".$company_tpl_width.",top=200,left=200,status=yes,toolbar=no,menubar=no,resizable=".$resize.",scrollbars=no,location=no,titlebar=no\\\");return false;'";
                        $add_show = str_replace('operating=\"show\"',$bum_clic,$list_strs[0]);
                        $zx_str = str_replace('id=\"arrow1\"','id=\"arrow'.($l+1).'\"',$add_show);
                        $zx_str .= $v["group_name"];
                        $zx_str .= $list_strs[2];
                        $bumens .= '<div>';
                        $bumens .=$zx_str;
                        $bumens .= '</div>';
                    }
                }
		
		$list_str .= $bumens;
		if($list_phone)
		{
			$last_up = str_replace('#&%end','',$list_kfarr[3]);
			$list_strpho = explode("#%@phone",$last_up);
			if($list_strpho[2])
			{
				$list_str .= $list_strpho[0].$list_phone.$list_strpho[2];
			}
			else
			{
				$list_str .= $list_kfarr[3];
			}
		}
		else
		{
			$list_strphos = explode("#&%end",$list_kfarr[3]);
			if($list_strphos[1])
			{
				$list_str .= $list_strphos[1];
			}
			else
			{
				$list_str .= $list_kfarr[3];
			}
		}
		return $list_str;
	}
}
//按分组显示人员
function get_group_worker(){
    global $mem_re,$kf_zd,$style_real_id,$language;    
    $all_group = $mem_re['all_groups'];
    $order_group = isset($mem_re['order_group'][$style_real_id]) ? $mem_re['order_group'][$style_real_id]['groups'] : array();
    $all_show_group = array();
    //分组排序
    foreach($order_group as $group_id){
        if(isset($all_group[$group_id])){
            $all_show_group[$group_id] = $all_group[$group_id];
            unset($all_group[$group_id]);
        }
    }
    foreach($all_group as $group_id => $group){
        $all_show_group[$group_id] = $group;
    }
    $unset_worker = $mem_re['unset_group'];
    $worker_online = $mem_re["worker_online"];
    $zdkf = explode(',',$kf_zd);
    $group_arr = array();
    foreach($all_show_group as $group){
        $online_num = 0;
        $is_set = 0;    //标识该分组下是否有人
        foreach($group['workers'] as $worker){
            if((in_array($worker['worker_id'],$zdkf) && trim($kf_zd) != '') || trim($kf_zd) == ''){
            	$is_work = ($worker_online[$worker['id6d']]['online'] && is_work_time($worker['id6d']))?$worker_online[$worker['id6d']]['online']:0;
                $group_arr[$group['group_id']]['worker_id'][] = $worker['worker_id'];
                $group_arr[$group['group_id']]['worker_name'][] = $worker['bname'];
                $group_arr[$group['group_id']]['online'][] = $is_work;
                $group_arr[$group['group_id']]['state'][] = $worker_online[$worker['id6d']]['state'];
                if($is_work == '1'){
                    $online_num += 1;
                }
                $is_set = 1;
            }
        }
        if($is_set == 1){
            $group_arr[$group['group_id']]['name'] = $group['group_name'];
            $group_arr[$group['group_id']]['online_num'] = $online_num;
        }
    }
    if(!empty($unset_worker)){
        $online_num = 0;
        $is_set = 0;
        foreach($unset_worker as $worker){
            if((in_array($worker['worker_id'],$zdkf) && trim($kf_zd) != '') || trim($kf_zd) == ''){
                $is_work = ($worker_online[$worker['id6d']]['online'] && is_work_time($worker['id6d']))?$worker_online[$worker['id6d']]['online']:0;
                $group_arr[0]['worker_id'][] = $worker['worker_id'];
                $group_arr[0]['worker_name'][] = $worker['bname'];
                $group_arr[0]['online'][] = $is_work;
                $group_arr[0]['state'][] = $worker_online[$worker['id6d']]['state'];
                if($is_work == '1'){
                    $online_num += 1;
                }
                $is_set = 1;
            }
        }
        if($is_set == 1){
            $group_arr[0]['online_num'] = $online_num;
            if (strpos($language, "en") !== false){
                $group_arr[0]['name'] = 'Default group';
            }else{
                $group_arr[0]['name'] = '未分组';
            } 
        }
    }
    return $group_arr;
}
//获取排序分组
function get_order_groups(){
    global $style_real_id,$mem_re,$kf,$language;
    $all_group = $mem_re['all_groups'];
    if(!empty($mem_re['unset_group'])){
        $all_group[0] = array(
            'group_id' => '0',
            'group_name' => strpos($language, "en") !== false ? 'Default group' : '未分组',
            'workers' => $mem_re['unset_group']
        );
    }
    $order_group = isset($mem_re['order_group'][$style_real_id]) ? $mem_re['order_group'][$style_real_id]['groups'] : array();
    $kf_groups = $kf == '' ? array_keys($all_group) : explode(',',$kf);
    $show_groups = array();
    foreach($order_group as $group_id){
        if(isset($all_group[$group_id]) && in_array($group_id,$kf_groups)){
            $show_groups[$group_id] = $all_group[$group_id];
            unset($all_group[$group_id]);
        }
    }
    foreach($all_group as $group_id => $group){
        if(in_array($group_id,$kf_groups)){
            $show_groups[$group_id] = $group;
        }
    }
    return $show_groups;
}
//new end
function default_config()
{
	global $hidden, $img_on, $img_off, $height, $width, $posmodel, $showmodel, $offset_height, $offset_width, $charset, $pop, $acc_poptime, $acc_autotype, $acc_left, $acc_top, $acc_ip, $acc_img, $acc_title, $acc_content, $kf_type, $acc_pos, $http;
	$hidden = 1;
	$img_on = "$http://" . $master_host . "/img/kflogo/v5_3.gif";
	$img_off = "$http://" . $master_host . "/img/kflogo/v5_3_off.gif";
	$height = 198;
	$width = 112;
	$posmodel = 1;
	$showmodel = 2;
	$offset_height = 200;
	$offset_width = 1;
	$charset = "UTF-8";
	$pop = "man";
	$acc_poptime = 10000;
	$acc_autotype = 1;
	$acc_pos = "1";
	$acc_left = "280";
	$acc_top = "230";
	$acc_ip = "off";
	$acc_img = "";
	$kf_type = 0;
	
}
function change_order($arr)
{
	if (!is_array($arr))
		return $arr;
	$g_arr = array();
	foreach ($arr as $k => $v)
	{
		$online = array();
		$offline = array();
		if (count($v["online"]) < 2)
		{
			$g_arr[$k] = $v;
			$g_arr[$k]["name"] = $v["name"];
			continue;
		}
		foreach ($v["online"] as $key => $val)
		{
			if ($val == 1 && $v["state"][$key] == 1)
			{
				$online["online"][] = $val;
				$online["worker_name"][] = $v["worker_name"][$key];
				$online["worker_id"][] = $v["worker_id"][$key];
				$online["state"][] = $v["state"][$key];
			}
			else
			{
				$offline["online"][] = $val;
				$offline["worker_name"][] = $v["worker_name"][$key];
				$offline["worker_id"][] = $v["worker_id"][$key];
				$offline["state"][] = $v["state"][$key];
			}
		}
		$g_arr[$k] = merge_arr($online, $offline);
		$g_arr[$k]["online_num"] = count($online["online"]);
		$g_arr[$k]["name"] = $v["name"];
	}
	return $g_arr;
}
function merge_arr($online, $offline)
{
	for ($i = 0; $i < count($offline["online"]); $i++)
	{
		$online["online"][] = $offline["online"][$i];
		$online["worker_name"][] = $offline["worker_name"][$i];
		$online["worker_id"][] = $offline["worker_id"][$i];
	}
	return $online;
}
function get_ip_info($ip)
{
	global $dblink;
	if ($dblink === false)
		db_connect();
	$oldip = $ip;
	$ip = parse_ip($ip);
	$c_name = str_replace("", ".", $ip);
	if (isset($_COOKIE[$c_name]) && $_COOKIE[$c_name] != "")
	{
		$c_value = explode(",", $_COOKIE[$c_name]);
		$r_value['area'] = $c_value[0];
		$r_value['isp'] = $c_value[1];
		$r_value['city'] = $c_value[2];
		$r_value['continents'] = $c_value[3];
		return $r_value;
	}
	$res = ipinfo($oldip);
	if ($res === false)
		return '';
	setcookie($c_name, $res["area"] . "," . $res["isp"] . "," . $res["city"] . "," . $res['continents'], time() + 3600 * 24, "/");
	return $res;
}
function qyfl_kf_set()
{
	global $style_real_id, $mem_re;
	$ip_info = get_ip_info(get_ip());
	$area_kf = $mem_re['area_kf'];
	$area_kf_ry = $mem_re['area_kf_ry'];
	$area_kf_zb = $mem_re['area_kf_zb'];
	$kf_group = array();     //分组
        $kf_depart = array();    //部门
	$kf_worker = array();    //人员
        $kf_zb_group = array();  //值班分组
        $kf_zb_depart = array(); //值班部门
	if (!isset($area_kf[$style_real_id]) && !isset($area_kf_ry[$style_real_id]) && !isset($area_kf_zb[$style_real_id]))
	{
		return "";
	}
	$areas = array("安徽", "北京", "重庆", "福建", "甘肃", "广东", "广西", "贵州", "海南", "河北", "黑龙江", "河南", "湖北", "湖南", "江苏", "江西", "吉林",
		"辽宁", "宁夏", "内蒙古", "青海", "上海", "山西", "山东", "四川", "陕西", "天津", "西藏", "新疆", "云南", "浙江", "台湾", "香港", "澳门");
	$ip_addr = "国外";
	$continents_arr = array("亚洲","欧洲","非洲","南美洲","北美洲","大洋洲","南极洲");
	$ip_city = "";

	foreach ($areas as $area)
	{
		if (false !== strpos($ip_info['area'], $area))
		{
			$ip_addr = $ip_info['area'];
			$ip_city = $ip_info['city'];
			break;
		}
	}
	foreach ($continents_arr as $con) {
		if (false !== strpos($ip_info['continents'], $con))
		{
			$ip_cont = $con;
			break;
		}
	}

	$is_fit = 0;
	// 人员
	foreach ($area_kf_ry[$style_real_id] as $worker_id => $area)
	{
		$temp_area = explode(",", $area);
		if (count($temp_area) > 0)
		{
			foreach ($temp_area as $value)
			{
				if (("" != $value) && ((false !== strpos($ip_addr, $value)) || (false !== strpos($ip_cont, $value))) && (false === array_search($worker_id, $kf_worker, true)))// && get_very_city($value, $ip_city) === false
				//修正区域分流问题，get_very_city含义不明，暂时注释  fonlue 2013.11.19
				{
					$kf_worker[] = $worker_id;
					break;
				}
			}
		}
	}
	foreach ($kf_worker as $worker_id)
	{
		if (is_worker_online($worker_id))
		{
			$worker_kf = implode(',', $kf_worker);
			set_group_kf_worker($worker_kf);
			return $worker_kf;
		}
		$is_fit = 1;
	}
    //分组
    foreach ($area_kf[$style_real_id]['group'] as $group_id => $area){
        $temp_area = explode(",", $area);
        if (count($temp_area) > 0){
            foreach ($temp_area as $value){
                if (("" != $value) && ((false !== strpos($ip_addr, $value)) || (false !== strpos($ip_cont, $value)))&& (false === array_search($group_id, $kf_group, true))){
                    $kf_group[] = $group_id;
                    break;
                }
            }
        }
    }
    foreach ($kf_group as $group_id){
        if (is_group_online($group_id)){
                $group_kf = implode(',', $kf_group);
                set_group_kf($group_kf);
                return $group_kf;
        }
        $is_fit = 2;
	}
	// 部门
	foreach ($area_kf[$style_real_id]['depart'] as $group_id => $area)
	{
		$temp_area = explode(",", $area);
		if (count($temp_area) > 0)
		{
			foreach ($temp_area as $value)
			{
				if (("" != $value) && ((false !== strpos($ip_addr, $value)) || (false !== strpos($ip_cont, $value)))&& (false === array_search($group_id, $kf_depart, true))) //&& get_very_city($value, $ip_city) === false 
				//修正区域分流问题，get_very_city含义不明，暂时注释  fonlue 2013.11.19
				{
					$kf_depart[] = $group_id;
					break;
				}
			}
		}
	}
	foreach ($kf_depart as $group_id)
	{
		if (is_dept_online($group_id))
		{
			$group_kf = implode(',', $kf_depart);
			set_depart_kf($group_kf);
			return $group_kf;
		}
		$is_fit = 3;
	}
    //值班分组
    $kf_zb_group = $area_kf_zb[$style_real_id]['group'];
    foreach ($kf_zb_group as $group_id){
        if (is_group_online($group_id)){
                $group_kf = implode(',', $kf_zb_group);
                set_group_kf($group_kf);
                return $group_kf;
        }
        $is_fit = 4;
    }
	// 值班部门
	$kf_zb_depart = $area_kf_zb[$style_real_id]['depart'];
	foreach ($kf_zb_depart as $group_id)
	{
		if (is_dept_online($group_id))
		{
			$group_kf = implode(',', $kf_zb_depart);
			set_depart_kf($group_kf);
			return $group_kf;
		}
		$is_fit = 5;
	}
	if ($is_fit == 1)
	{
		$worker_kf = implode(',', $kf_worker);
		set_group_kf_worker($worker_kf);
		return $worker_kf;
	}
        if ($is_fit == 2){
		$group_kf = implode(',', $kf_group);
		set_group_kf($group_kf);
		return $group_kf;
	}
	if ($is_fit == 3)
	{
		$group_kf = implode(',', $kf_depart);
		set_depart_kf($group_kf);
		return $group_kf;
	}
	if ($is_fit == 4)
	{
		$group_kf = implode(',', $kf_zb_group);
		set_group_kf($group_kf);
		return $group_kf;
	}
        if ($is_fit == 5)
	{
		$group_kf = implode(',', $kf_zb_depart);
		set_depart_kf($group_kf);
		return $group_kf;
	}
	return "";
}
function get_very_city($value, $ip_city)
{
	global $www_path, $mem_re;
	require ($www_path . "/lib/common/place_data2.php");
	$key = array_search($value, $statename);
	if ($key !== false)
	{
		foreach ($mem_re['area_city'] as $city)
		{
			if (strpos($ip_city, $city) !== false)
			{
				return true;
			}
		}
		return false;
	}
	return false;
}
function set_group_kf($kfs){
    global $kf, $zdkf, $kf_type, $kflist, $zdkf_type;
    $zdkf = "no";
    $kf_type = "2";
    $zdkf_type = "3";
    $kf = $kfs;
    $kflist = "off";
}
function set_depart_kf($kfs)
{
	global $kf, $zdkf, $kf_type, $kflist, $zdkf_type;
	$zdkf = "no";
	$kf_type = "2";
	$zdkf_type = "2";
	$kf = $kfs;
	$kflist = "off";
}
function set_group_kf_worker($kfs)
{
	global $kf, $zdkf, $kf_type, $kflist, $zdkf_type;
	$zdkf = "no";
	$kf_type = "2";
	$zdkf_type = "1";
	$kf = $kfs;
	$kflist = "off";
}
function set_zdkf_params($style_type)
{
	global $kf, $kflist, $kf_professor, $zdkf_type;
	if ($style_type == 2)
	{
		$kf = $kf_professor;
		$zdkf_type = 1;
		$kflist = "off";
	}
}
function isBrowserIE6()
{
	if (strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 6.0') !== false)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function is_worker_online($worker_id)
{
	global $mem_re;
	$workers = $mem_re['worker'];
	foreach ($workers as $worker)
	{
		if ($worker["worker_id"] == $worker_id)
		{
			if ($worker["last_time"] < "9999999999" && $worker["state"] == "1")
			{
				return true;
			}
			else
			{
				return false;
			}
		}
	}
}
function is_group_online($group_id){
    global $order_groups,$mem_re;
    $group_worker = $order_groups[$group_id]['workers'];
    $workers = $mem_re['worker'];
    foreach($group_worker as $id6d){
        if($workers[$id6d]["last_time"] < "9999999999" && $workers[$id6d]["state"] == "1"){
            return true;
        }
    }
    return false;
}
function is_dept_online($group_id)
{
	global $mem_re;
	$workers = $mem_re['worker'];
	foreach ($workers as $worker)
	{
		if ($worker["group_id"] == $group_id)
		{
			if ($worker["last_time"] < "9999999999" && $worker["state"] == "1")
			{
				return true;
			}
		}
	}
	return false;
}

function get_tb_data()
{
  global $height,$width,$zdytb,$img_on,$img_off,$zdytb_53kf_on,$zdytb_53kf_off;
  if (strtolower($zdytb == 'yes') && ($zdytb_53kf_on != '' || $zdytb_53kf_off != '') )//&& get_module_value("zdytb")===true
  {
    if ($zdytb_53kf_on == '') $zdytb_53kf_on = $zdytb_53kf_off;
    if ($zdytb_53kf_off == '') $zdytb_53kf_off = $zdytb_53kf_on;
    $zdytb_on_arr = explode('#',$zdytb_53kf_on,2);
    $zdytb_off_arr = explode('#',$zdytb_53kf_off,2);
    $zdytb_on_arr_1 = explode(',',$zdytb_on_arr[0]);
    $zdytb_off_arr_1 = explode(',',$zdytb_off_arr[0]);
    
    $zdytb_on_str = $zdytb_53kf_on;
    $zdytb_on_width = $zdytb_on_arr_1[3];
    $zdytb_on_height = $zdytb_on_arr_1[4];
    
    $zdytb_off_str = $zdytb_53kf_off;
    $zdytb_off_width = $zdytb_off_arr_1[3];
    $zdytb_off_height = $zdytb_off_arr_1[4];
  }
  else
  {
    $zdytb_on_img_str = $img_on;
    $zdytb_off_img_str = $img_off;
    if ($zdytb_on_img_str == '') $zdytb_on_img_str = $zdytb_off_img_str;
    if ($zdytb_off_img_str == '') $zdytb_off_img_str = $zdytb_on_img_str;
    
    $zdytb_on_width = $width;
    $zdytb_on_height = $height;
    
    
    $zdytb_off_width = $width;
    $zdytb_off_height = $height;
    
    $zdytb_on_str = "1,外框,-,$zdytb_on_width,$zdytb_on_height,-,-,1,-,no-repeat,-,-,-,-,12,-,-,-,-,none,宋体,-,-,-,-,_blank#2,在线图标,chat,$zdytb_on_width,$zdytb_on_height,0,0,2,$zdytb_on_img_str,no-repeat,-,-,zdy,-,12,000000,-,-,-,none,宋体,-,-,-,-,_blank";
    $zdytb_off_str = "1,外框,-,$zdytb_off_width,$zdytb_off_height,-,-,1,-,no-repeat,-,-,-,-,12,-,-,-,-,none,宋体,-,-,-,-,_blank#2,离线图标,chat,$zdytb_off_width,$zdytb_off_height,0,0,2,$zdytb_off_img_str,no-repeat,-,-,zdy,-,12,000000,-,-,-,none,宋体,-,-,-,-,_blank";
  }

  
  $zdytb_on_str = json_encode($zdytb_on_str);
  $zdytb_off_str = json_encode($zdytb_off_str);

  $data = array();
  $data['on']['str'] = $zdytb_on_str;
  $data['on']['width'] = $zdytb_on_width;
  $data['on']['height'] = $zdytb_on_height;
  
  $data['off']['str'] = $zdytb_off_str;
  $data['off']['width'] = $zdytb_off_width;
  $data['off']['height'] = $zdytb_off_height;
  
  return $data;
}

// 生成 tmpid guest_id talk_id
function new_talk_id()
{
  db_execute("insert into talk_id values()");
  return db_lastinsertid();
}

//检测访客网站域名
function is_setDomain($companysite){
	if(strpos($_SERVER['HTTP_REFERER'], '53kf.com') !== false){
		return true;
	}
	$svalue = json_decode($companysite, true);
	if($svalue != ''){
		$start = 0;
		foreach($svalue as $val){
			if($val['isstart'] == 'yes'){
				$start++;
				if(strpos($_SERVER['HTTP_REFERER'], $val['sdomain']) !== false)
					return true;
			}
		}
		if($start == 0)
			return true;
		else
			return false;
	}
	return true;
}

//判断客服是否在工作时间
function is_work_time($id6d){
	global $mem_re,$in_timestamp;

	if(empty($mem_re['schedule'])){
		return true;
	}
	$week = date("w");//星期
	if($week=='0'){
		$week = '7';
	}
	foreach ($mem_re['schedule'][$id6d] as $v) {
		if(strpos($v['schedule_days'], $week) !== false){
			if(strtotime($v['start_time'])<$in_timestamp && strtotime($v['end_time'])>$in_timestamp)
				return true;
		}
	}
	return false;
}
?>