function kfObj(_type,id,name,key)
{
	this.id = id;
	this.type = _type.toLowerCase();
	this.key = key;
	name = name==undefined? '' : name;
	this.getHref=function()
	{
		if(this.type == "qq")
		{
			return 'http://sighttp.qq.com/cgi-bin/check?sigkey='+key+'" onclick="return _clickQQ(\''+key+'\')';
		}
		else if(this.type == "bqq")
		{
			return 'http://b3.qq.com/webc.htm?new=0&sid='+id+'&o=&q=7" onclick="return_cbQQ(\''+id+'\',this)';
		}
		return _jsDir +'/kf/rtc.html#'+_type+'='+id;
	}
	this.getLink= function()
	{
		switch(this.type)
		{
			case "bqq" : return '<a href="http://b3.qq.com/webc.htm?new=0&sid='+id+'&o=&q=7" onclick="return_cbQQ(\''+id+'\',this)" target="_blank"><img src="http://wpa.qq.com/pa?p=1:'+id+':4" />'+(name==''?'QQ客服':name)+'</a>';
				break;
			case "qq" : return '<a href="http://sighttp.qq.com/cgi-bin/check?sigkey='+key+'" onclick="return _clickQQ(\''+key+'\')" target="_blank"><img src="http://wpa.qq.com/pa?p=1:'+id+':4" />'+(name==''?'QQ客服':name)+'</a>';
				break;
			case "msn" : return '<a href="'+_jsDir+'/kf/rtc.html#'+_type+'='+id+'" target="_blank"><img src="'+_jsDir+'/kf/msn.gif" />'+(name==''?'MSN客服':name)+'</a>';
				break;
			case "ww" : return '<a href="'+_jsDir+'/kf/rtc.html#'+_type+'='+id+'" target="_blank"><img src="http://amos1.taobao.com/online.ww?v=2&uid='+id+'&s=2" />'+(name==''?'旺旺客服':name)+'</a>';
				break;
		}
	}
}

var _kf;
function kf(pkf,delay,popTime,locationStr,popText,kfs,kfText)
{
	_kf = this;
	var _self = this;
	
	kflist='<li style="margin:0 5px;border-bottom:1px dashed #CCC;line-height:30px;height:30px;padding:7px 0 0 0">'+pkf.getLink()+'</li>';
	if(kfs != undefined)
	{
		for(var i=0,j=kfs.length;i<j;i++)
		{
			kflist+='<li style="margin:0 5px;border-bottom:1px dashed #CCC;line-height:30px;height:30px;padding:7px 0 0 0">'+kfs[i].getLink()+'</li>';
		}
	}
	if(pkf.type.toLowerCase() == "qq")
	{
		document.write('<div id="kfBox" style="display:none;position:absolute;top:200px;height:214px;z-index:999999;width:98%;left:0;"><div style="background:url('+_jsDir+'/kf/kf.png) no-repeat;position:relative;width:436px;height:214px;margin:0 auto;"><div style="position:absolute;top:110px;left:235px;padding-right:10px;">'+popText+'</div><div style="fontSize:12px;padding:75px 5px 0 130px;" id="kfText"></div><a style="position:absolute;display:block;width:80px;height:25px;text-align:center;color:#FFF;line-height:25px;font-size:16px;top:165px;left:240px;" target="_blank" href="http://sighttp.qq.com/cgi-bin/check?sigkey='+pkf.key+'" onclick="this.close();return _clickQQ(\''+pkf.key+'\')" id="kfClickObj">开始交谈</a><span id="kfCloseObj" style="position:absolute;cursor:pointer;display:block;width:80px;height:25px;text-align:center;color:#FFF;line-height:25px;font-size:16px;top:165px;left:335px;" onclick="this.close()">待会再说</span></div></div>');
	}
	else if(pkf.type.toLowerCase() == "bqq")
	{
		document.write('<div id="kfBox" style="display:none;position:absolute;top:200px;height:214px;z-index:999999;width:98%;left:0;"><div style="background:url('+_jsDir+'/kf/kf.png) no-repeat;position:relative;width:436px;height:214px;margin:0 auto;"><div style="position:absolute;top:110px;left:235px;padding-right:10px;">'+popText+'</div><div style="fontSize:12px;padding:75px 5px 0 130px;" id="kfText"></div><a style="position:absolute;display:block;width:80px;height:25px;text-align:center;color:#FFF;line-height:25px;font-size:16px;top:165px;left:240px;" target="_blank" href="http://b3.qq.com/webc.htm?new=0&sid='+pkf.id+'&o=&q=7" onclick="this.close();return_cbQQ(\''+pkf.id+'\',this)" id="kfClickObj">开始交谈</a><span id="kfCloseObj" style="position:absolute;cursor:pointer;display:block;width:80px;height:25px;text-align:center;color:#FFF;line-height:25px;font-size:16px;top:165px;left:335px;" onclick="this.close()">待会再说</span></div></div>');
	}
	else
	{
		document.write('<div id="kfBox" style="display:none;position:absolute;top:200px;height:214px;z-index:999999;width:98%;left:0;"><div style="background:url('+_jsDir+'/kf/kf.png) no-repeat;position:relative;width:436px;height:214px;margin:0 auto;"><div style="position:absolute;top:110px;left:235px;padding-right:10px;">'+popText+'</div><div style="fontSize:12px;padding:75px 5px 0 130px;" id="kfText"></div><a style="position:absolute;display:block;width:80px;height:25px;text-align:center;color:#FFF;line-height:25px;font-size:16px;top:165px;left:240px;" target="_blank" href="'+_jsDir+'/kf/rtc.html#'+pkf.type+'='+pkf.key+'" onclick="this.close();" id="kfClickObj">开始交谈</a><span id="kfCloseObj" style="position:absolute;cursor:pointer;display:block;width:80px;height:25px;text-align:center;color:#FFF;line-height:25px;font-size:16px;top:165px;left:335px;" onclick="this.close()">待会再说</span></div></div>');
	}
	document.write('<div id="kfLBox" style="display:none;background:url('+_jsDir+'/kf/kflbox.png) no-repeat;width:100px;height:22px;position:absolute;top:200px;right:20px;padding-top:22px;"><ul style="background:#FFF;padding:5px 0;text-align:center;border-left:1px solid #81d3bd;border-right:1px solid #81d3bd;">'+kflist+'</ul><p style="padding:5px;margin:0;border:1px solid #81d3bd;border-top:none;text-align:center;background:#FFF;">'+kfText+'</p></div>');
	this.kfBox = document.getElementById("kfBox");
	this.kfLbox = document.getElementById("kfLBox");
	this.tarBox = this.kfBox;
	document.getElementById("kfCloseObj").close = function()
	{
		_self.close();
	}
	document.getElementById("kfClickObj").close = function()
	{
		_self.close();
	}
	this.close = function()
	{
		_self.tarBox = _self.kfLBox;
		_self.kfBox.style.display = "none";
		_self.kfLBox.style.display = "block";
		_self.tarBox.style.top = (parseInt(document.documentElement.scrollTop) + 200) + "px";
	}
	this.show = function()
	{
		_self.tarBox = _self.kfBox;
		_self.kfBox.style.display = "block";
		_self.kfLBox.style.display = "none";
		_self.tarBox.style.top = (parseInt(document.documentElement.scrollTop) + 200) + "px";
	}
	delay = delay == undefined ? 0 : delay;
	setTimeout(function()
	{
		_self.show();
		if(popTime != undefined)
		{
			setInterval(_self.show,popTime*1000);
		}
	},delay*1000);
	if(_isIE)
	{
		window.attachEvent("onscroll",function()
		{
			_self.tarBox.style.top = (parseInt(document.documentElement.scrollTop) + 200) + "px";
		});
	}
	else
	{
		document.addEventListener("scroll",function()
		{
			_self.tarBox.style.top = (parseInt(document.documentElement.scrollTop) + 200) + "px";
		},false);
	}	
	this.ipArea = function(str)
	{
		document.getElementById("kfText").innerHTML = locationStr.replace("$location$",str.replace(/ADSL|电信|网通/gi,"").replace(/CZ88\.NET/gi,"未知地区"));
	}
	document.write("<script charset='utf-8' src='http://ip.7lk.cn/iplocation.js.aspx?t="+new Date().getTime()+"'></script>")
}

function ipArea(str)
{
	_kf.ipArea(str.replace(/ $/,""));
}
function _clickQQ(skey)
{
	var tempSrc='http://sighttp.qq.com/wpa.js?rantime='+Math.random()+'&sigkey='+skey;
	var oldscript=document.getElementById('testJs');
	var newscript=document.createElement('script');
	newscript.setAttribute('type','text/javascript');
	newscript.setAttribute('id', 'testJs');
	newscript.setAttribute('src',tempSrc);
	if(oldscript == null)
	{
		document.body.appendChild(newscript);
	}
	else
	{
		oldscript.parentNode.replaceChild(newscript, oldscript);
	}
	return false;
}
var IsInstallQQ = false;
try
{
	var xmlhttp=new ActiveXObject("TimwpDll.TimwpCheck");    
	IsInstallQQ = true;            
}catch(e){}
function return_cbQQ(id,obj)
{
	if(IsInstallQQ)
	{
		obj.target="_self";
		obj.href = 'tencent://message/?uin='+ id + '&Site=&Menu=yes&crm=1';
		return false;
	}
	window.open('http://b3.qq.com/webc.htm?new=0&sid='+id+'&o=&q=7', '_blank', 'height=544, width=644,toolbar=no,scrollbars=no,menubar=no,status=no','_blank');
	return false;
}
function WarningBox(tit,arg,closeFun)
{
	var _self = this;
	this.isRun = false;
	this.box;
	document.write('<div id="warningBox" style="position:absolute;bottom:-1000px;width:150px;height:200px;right:0;height:200px;z-index:999999;"><h3><span id="closeWarningObj" onclick="this.close()" style="float:right;cursor:pointer;">关闭<\/span>'+tit+'<\/h3><div>'+arg+'<\/div><\/div>');
	window.setTimeout(function()
	{
		_self.box = _$("warningBox");
		_self.init();
		_$("closeWarningObj").close = function()
		{
			_self.isRun = false;
			_self.box.style.display="none";
			if(closeFun != undefined)
			{
				(closeFun)();
			}
		}
	},1000);
	this.init = function()
	{
		this.goI = this.box.offsetHeight;
		this.box.style.bottom = "-" + this.goI + "px";
		this.box.style.display = "block";
		this.set = window.setInterval(function()
		{
			if(_self.goI > 1)
			{
				_self.box.style.bottom = "-" + (--_self.goI) + "px";
			}
			else
			{
				window.clearInterval(_self.set);
				_self.isRun = true;
			}
		},20);
		this.tmpHeight = document.documentElement.clientHeight - this.box.offsetHeight;
		if(_isIE)
		{
			window.attachEvent("onscroll",function()
			{
				if(_self.isRun)
				{
					_self.box.style.top = (parseInt(document.documentElement.scrollTop) + _self.tmpHeight) + "px";
				}
			});
		}
		else
		{
			document.addEventListener("scroll",function()
			{
				if(_self.isRun)
				{
					_self.box.style.top = (parseInt(document.documentElement.scrollTop) + _self.tmpHeight) + "px";
				}
			},false);
		}
	}
	this.reload = function(t)
	{
		setInterval(function()
		{
			_self.isRun = false;
			_self.init();
		},t*1000);
	}
}