var imgstatuenum="";
var HostURL = "http://www.hi-eweb-livechat.com/lcv2/";
//var HostURL = "http://192.168.1.166/livechat/lcv2/";
var folder = "anow/";
var iframewidth = 0;
var iframeheight = 0;
getcss = function(){
var lc_css = document.createElement("link");
lc_css.href = HostURL +"lc_include/css/invite.css";
lc_css.rel = "stylesheet";
lc_css.type = "text/css";
document.body.appendChild(lc_css);
}
createInvitedv = function(){
var invitedv = "";
invitedv += "
";
invitedv += "
";
invitedv += "

";
invitedv += "

";
invitedv += "

";
invitedv += "
";
invitedv += "
";
invitedv += "

";
invitedv += "
";
invitedv += "
";
invitedv += "
";
invitedv += "
";
invitedv += " ";
invitedv += "
";
invitedv += "
";
invitedv += "
";
invitedv += "

";
invitedv += "
";
invitedv += "
";
invitedv += "
";
invitedv += "
";
invitedv += "

";
invitedv += "
";
invitedv += "
";
document.write(invitedv);
}
createimage = function(){
document.write("
");
}
createiframe = function(){
var ifr=document.createElement('IFRAME');
ifr.src = HostURL + folder +'indexweb.aspx';
ifr.scrolling = 'no';
ifr.id = "ifr";
ifr.width = iframewidth;
ifr.height = iframeheight;
ifr.frameborder = 0;
ifr.marginheight = 0;
ifr.marginwidth = 0;
ifr.display = 'none';
document.body.appendChild(ifr);
}
loadiframestate = function(){
var ifr = document.getElementById("ifr");
if(ifr.readyState=="complete")
{
getcnickname();
getserverstatus();
getcontent();
}
else
{
setTimeout("loadiframestate()",100);
}
}
createInvitedv();
createimage();
//*******************************************************************************************************//
_unreplace_character = function(str){
var destStr = str;
destStr = destStr.replace(new RegExp("<", "g"), "<");
destStr = destStr.replace(new RegExp(">", "g"), ">");
destStr = destStr.replace(new RegExp("
", "g"), "\n");
destStr = destStr.replace(new RegExp("
", "g"), "\r\n");
destStr = destStr.replace(new RegExp("
", "g"), "\n"); //适用于firefox
destStr = destStr.replace(new RegExp("
", "g"), "\n"); //适用于firefox
destStr = destStr.replace(new RegExp(" ", "g"), " ");
return destStr;
}
_upload_replace = function(str){
var destStr = str;
destStr = destStr.replace(new RegExp("'", "g"), "''");
destStr = destStr.replace(new RegExp(" ", "g"), " ");
destStr = destStr.replace(new RegExp("\r\n", "g"), "
");
destStr = destStr.replace(new RegExp("\n", "g"), "
");
return destStr;
}
_load_replace = function(str){
var destStr = str;
destStr = destStr.replace(new RegExp(""", "g"), "\"");
destStr = destStr.replace(new RegExp("<", "g"), "<");
destStr = destStr.replace(new RegExp(">", "g"), ">");
destStr = destStr.replace(new RegExp("\n", "g"), "
");
destStr = destStr.replace(new RegExp("\r\n", "g"), "
");
return destStr;
}
var x = 50;
var xin = true;
var step = 1;
var delay = 40;
var invitemove = true;
var _iv_container = document.getElementById("iv_container");
var _iv_closebt = document.getElementById("iv_closebt");
var _iv_newmsg = document.getElementById("iv_newmsg");
var _iv_sendmsg = document.getElementById("iv_sendmsg");
var _iv_sendbt = document.getElementById("iv_sendbt");
var _managerstatusimg = document.getElementById("managerstatusimg");
var manageronline = false;
var getnewmsgflag = true;
var cname = "";
var msgreceiver = "";
_iv_closebt.onclick = function(){
_iv_container.style.display = "none";
setcreadmsgid();
var content = _upload_replace("Sorry, the customer don't want to chat with you now.");
sendContent(content,"1");
changeTalkstatus("refuse");
}
_iv_sendbt.onmousedown = function(){
// _iv_sendbt.style.border = "ridge 1px";
}
_iv_sendbt.onmouseup = function(){
// _iv_sendbt.style.border = "";
}
_iv_sendbt.onclick = function(){
var content = _upload_replace(_iv_sendmsg.value);
sendContent(content,'0');
setcreadmsgid();
setdialogshow();
}
_managerstatusimg.onclick = function(){
var openurl = "";
if(manageronline)
openurl = HostURL + folder +"client/register.aspx?cname="+ cname;
else
openurl = HostURL + folder +"client/leaveword.aspx?cname="+ cname;
var win = window.open(openurl,"c_"+cname,"width=620,height=490,scrollbars=auto,toolbar=no,menubar=no,status=yes");
win.focus();
}
sendContent = function(content,issysteminfo){
if(content != ""){
var s=document.createElement('SCRIPT');
s.src = HostURL + folder +"DataCenter.aspx?command=21&sender="+ cname
+"&receiver="+ msgreceiver +"&content="+ escape(content)
+"&issysteminfo="+ issysteminfo +"&sendfrom=c&s"+Math.random();
document.body.appendChild(s);
if(issysteminfo == 0){
_iv_sendmsg.value = "";
_iv_sendmsg.focus();
_iv_container.style.display = "none";
var openurl = HostURL + folder +"client/c_sendmsg.aspx?cname="+ cname +"&department="+ msgreceiver;
var win = window.open(openurl,"c_"+cname,"width=620,height=490,scrollbars=auto,toolbar=no,menubar=no,status=yes");
win.focus();
}
}else{
alert('Please input your content');
_iv_sendmsg.focus();
}
}
changeTalkstatus = function(applyaction){
var s=document.createElement('SCRIPT');
s.src = HostURL + folder +"DataCenter.aspx?command=110&cname="+ cname +"&applyaction="+ applyaction +"&s"+Math.random();
}
Init_invitedv = function(){
var itl;
if(invitemove)
itl= setInterval("floatInvite()", delay);
_iv_container.style.top = (document.body.scrollTop + 50) + "px";
_iv_container.onmouseover = function(){
invitemove = false;
clearInterval(itl);
}
_iv_container.onmouseout = function(){
invitemove = true;
itl=setInterval("floatInvite()", delay);
}
_iv_container.style.display = "none";
}
floatInvite = function(){
var L=0 ;
var R= document.body.clientWidth - _iv_container.offsetWidth ;
_iv_container.style.left = (document.body.scrollLeft + x) + "px";
_iv_container.style.top = (document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + 50 + 'px';
x = x + step*(xin?1:-1) ;
if (x < L) { xin = true; x = L;}
if (x > R){ xin = false; x = R;}
}
positionInit = function(){
x=50;
_iv_container.style.display = "";
window.focus();
_iv_sendmsg.focus();
}
setcnickname = function(nickname){
cname = nickname;
setTimeout("getcnickname()",3000);
}
getcnickname = function(){
var s=document.createElement('SCRIPT');
s.src = HostURL + folder +"DataCenter.aspx?command=17&fun=setcnickname&s"+Math.random();
document.body.appendChild(s);
}
setcontent = function(sender,content){
if(sender != ""){
msgreceiver = sender;
_iv_newmsg.value = _unreplace_character(_load_replace(unescape(content)));
getnewmsgflag = false;
positionInit();
}
}
getcontent = function(){
if(getnewmsgflag){
var s=document.createElement('SCRIPT');
s.src = HostURL + folder +"DataCenter.aspx?command=18&cname="+ cname +"&fun=setcontent&s"+Math.random();
document.body.appendChild(s);
}
setTimeout("getcontent()",3000);
}
setcreadmsgid = function(){
var s=document.createElement('SCRIPT');
s.src = HostURL + folder +"DataCenter.aspx?command=19&cname="+ cname +"&s"+Math.random();
document.body.appendChild(s);
setTimeout("",2000);
getnewmsgflag = true;
}
setdialogshow = function(){
var s=document.createElement('SCRIPT');
s.src = HostURL + folder +"DataCenter.aspx?command=102&cdialogstatus=1&cname="+ cname +"&s"+Math.random();
document.body.appendChild(s);
}
setserverstatus = function(onlineflag){
if(onlineflag == 1){
_managerstatusimg.src = HostURL + folder +"images/online"+ imgstatuenum +".gif";
manageronline = true;
}else{
_managerstatusimg.src = HostURL + folder +"images/unonline"+ imgstatuenum +".gif";
manageronline = false;
}
}
getserverstatus = function(){
var s=document.createElement('SCRIPT');
s.src = HostURL + folder +"DataCenter.aspx?command=22&fun=setserverstatus&s"+Math.random();
document.body.appendChild(s);
setTimeout("getserverstatus()",3000);
}
window.onload = function(){
createiframe();
Init_invitedv();
getcss();
loadiframestate();
}