function WebCall_GetCookieValX(offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function WebCall_GetCookieX(name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return WebCall_GetCookieValX (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } function WebCall_SetCookieX(name, value) { var argv = WebCall_SetCookieX.arguments; var argc = WebCall_SetCookieX.arguments.length; var expires = (2 < argc) ? argv[2] : null; var path = (3 < argc) ? argv[3] : null; var domain = (4 < argc) ? argv[4] : null; var secure = (5 < argc) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } //** end of Cookie // get a random string function WebCall_GetRndString(len) { var ret = ""; while(ret.length < len){ var i = Math.random(); var ii = (122 - 97 + 1) * i + 97; ii = parseInt(ii); ret += String.fromCharCode(ii); } return ret; } function GetClientID() { var cid = WebCall_GetCookieX("WebTongClientID"); if(!cid){ cid = WebCall_GetRndString(16); var expdate = new Date(); expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); //expiry one years later WebCall_SetCookieX ("WebTongClientID",cid,expdate,"/"); } return cid; } function GetVisitTimes() { var num = WebCall_GetCookieX("WebTongVisitTimes"); if(num){ num = parseInt(num); if(/^[0-9]+$/.test(num) == false) num = 0; var NoCountVT = WebCall_GetCookieX("NoCountVT"); if(NoCountVT == null){ num++; WebCall_SetCookieX ("NoCountVT","yes",null,"/"); //if user close the browser,the counter restart } }else{ num = 1; } var expdate = new Date(); expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365)); //expiry one years later WebCall_SetCookieX ("WebTongVisitTimes",num,expdate,"/"); return num; } function webcall_getCharset(){ var wc_charset = document.charset.toLowerCase(); if(wc_charset == 'gbk') wc_charset = 'gb2312'; else if(wc_charset == 'gb2312') wc_charset = 'gb2312'; else wc_charset = "UTF-8"; return wc_charset; } var fromr = ""; try{ top.document.referrer; }catch(e){} fromr = (fromr == "") ? document.referrer : fromr; var wc_charset = webcall_getCharset(); var wc_visittimes = GetVisitTimes(); var QueryString = '&domain='+ window.location.host +'&fromr=' + escape(fromr) + '&url=' + escape(document.URL) + '&screen=' + screen.width + 'x' + screen.height; if(location.search.indexOf("isDebug=1") > -1) QueryString += "&isDebug=1"; var WebTongHome = "http://chat.51kehu.com/"; var cid = GetClientID(); var name = WebCall_GetCookieX('CokClientName'); if(name == null) name = ""; //if(wc_charset == "UTF-8") name = escape(name); //prompt('',name); var initUrl = WebTongHome + "Init/Init_2.aspx?cid=" + cid + "&SiteID=662&AutoHide=1&q=633595903376093750&VisitTimes="+ wc_visittimes +"&Charset="+ wc_charset + QueryString + "&name="+ name; initUrl += "&rand=" + Math.random(); //prompt("",initUrl); //alert(window.location.host); document.writeln("");