var HOST="127.0.0.1",PORT=35555,MY_PUBKEY_STR,MY_HASH_KEY,MY_PUBKEY;if(!isSupportFlash()||isMobile()){var my_domain="";if(my_domain==undefined||my_domain=="")my_domain=getShortDomain();document.domain=my_domain;var swfElement=document.getElementById("topcmm_flashchat");swfElement&&swfElement.parentNode.removeChild(swfElement)}
function isIP(a){var b=false;if(a.length>0)try{var e=a.split(".");if(e.length!=4)b=false;else{for(a=0;a<e.length;a++)if(!isIntegerInRange(e[a],0,255)){b=false;break}b=true}}catch(g){b=false}else b=false;return b}function isIntegerInRange(a,b,e){if(isEmpty(a))return isIntegerInRange.arguments.length==1?false:isIntegerInRange.arguments[1]==true;if(!isInteger(a,false))return false;a=parseInt(a);return a>=b&&a<=e}
function isInteger(a){var b;if(isEmpty(a))return isInteger.arguments.length==1?0:isInteger.arguments[1]==true;for(b=0;b<a.length;b++){var e=a.charAt(b);if(!isDigit(e))return false}return true}function isEmpty(a){return a==null||a.length==0}function isDigit(a){return a>="0"&&a<="9"}function getDomain(){var a="";try{hostStr=window.location.host;a=hostStr.indexOf(":")==-1?hostStr:hostStr.substring(0,hostStr.indexOf(":"))}catch(b){a=""}return a}
function getShortDomain(){var a="";try{hostStr=window.location.host;a=hostStr.indexOf(":")==-1?hostStr:hostStr.substring(0,hostStr.indexOf(":"));if(!isIP(a)){var b=a.split(".");if(b.length>2)a=b[b.length-2]+"."+b[b.length-1]}}catch(e){a=""}return a}function getMovie(a){try{return isIE()?window[a]:document[a]}catch(b){}}function isIE(){return getUserAgent().indexOf("msie")!=-1}function getLanguage(){return isIE()?navigator.browserLanguage:navigator.language}
function isiPad(){return navigator.platform.toLowerCase()=="ipad"}function isMobile(){var a=getUserAgent();return a.indexOf("iphone")!=-1||a.indexOf("android")!=-1||a.indexOf("msiemobile")!=-1}function getUserAgent(){return navigator.userAgent.toLowerCase()}
function isSupportFlash(){var a=false;if(!isiPad())try{if(navigator.plugins&&navigator.plugins.length>0){var b=navigator.plugins["Shockwave Flash"];if(b)a=true}if(!a)if(b=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"))a=true}catch(e){a=false}return a}function flashConnect(a,b){var e=getMovie("topcmm_flashchat");if(e==undefined||e.connect==undefined)return false;return e.connect(a,b)}function flashSendMessage(a){getMovie("topcmm_flashchat").sendMessage(a)}
function httpConnect(a,b){HOST=a;PORT=b;onConnected();return true}function httpSendMessage(a){message=a+"0";message=encodeURIComponent(encodeURIComponent(message));a=Math.floor(Math.random()*999999999999);var b="http://"+HOST+":"+PORT+"/123flashchat_"+a,e="protocol="+message;message.indexOf("%253CInit")==0?J(b,e,"l"):J(b,e,"s"+a)}
function c(a){var b=null,e=a+"_div";if(document.getElementById(a))return document.getElementById(a);try{var g=document.createElement("iframe");g.setAttribute("id",a);g.setAttribute("name",a);g.setAttribute("style","border-width:0;height:0;width:0;visibility:hidden;");var f=document.createElement("div");f.setAttribute("id",e);f.setAttribute("style","position:absolute;top:0;left:0;width:0;height:0;overflow:hidden;");f.appendChild(g);document.body.appendChild(f);if(typeof document.frames!="undefined")b=
document.frames[a];if(!b||typeof b.nodeType=="undefined")b=document.getElementById(a)}catch(h){g='<iframe id="'+a+'" name="'+a+'" style="border-width:0;height:0;width:0;visibility:hidden;"></iframe>';if(document.getElementById(e))document.getElementById(e).innerHTML=g;else{f=document.createElement("div");f.setAttribute("id",e);f.setAttribute("style","position:absolute;top:0;left:0;width:0;height:0;overflow:hidden;");f.innerHTML=g;document.getElementsByTagName("DIV")[0].appendChild(f)}b=document.getElementById(a)}b.onreadystatechange=
function(){if(b.readyState=="complete"){d(b);b.parentNode.removeChild(b)}};return b}function J(a,b,e){try{a=a+"?"+b;var g=c(e),f=d(g)}catch(h){}try{if(f.location)f.location.replace(a);else f.location=a}catch(i){g.src=a}}function d(a){if(a.contentDocument)return a.contentDocument;else if(a.contentWindow)return a.contentWindow.document;else if(a.document)return a.document}function I(a){receiveMessage(a)}
function setPublicKey(a,b,e){MY_PUBKEY_STR=a;MY_HASH_KEY=genFCKey();MY_PUBKEY=new RSAKeyPair("11",MY_PUBKEY_STR);a='<Suhk k="'+encryptedString(MY_PUBKEY,MY_HASH_KEY)+'"';if(b!=null&&b!=undefined&&b!="")a+=' msqid="'+b+'"';a+=' sid="'+e+'"';a+="></Suhk>";isMobile()?httpSendMessage(a):flashSendMessage(a)}function encryptPassword(a){return encryptedString(MY_PUBKEY,a)}function encryptPasswordByPublicKey(a,b){var e=new RSAKeyPair("11",b);return encryptedString(e,a)}
function encodeMessage(a,b){return b==""||b==undefined?fcEncode(MY_HASH_KEY,a):fcEncode(b,a)}function decodeMessage(a,b){var e="";e=b==""||b==undefined?fcDecode(MY_HASH_KEY,a):fcDecode(b,a);return e.split("\\").join("\\\\")}function encryptWithRsaKeyPair(a,b,e){return getEncryptedMsgWithRsaKeyPair(a,b,e)}function getEncryptedMsgWithRsaKeyPair(a,b,e){a=new RSAKeyPair(a,b);return encryptedString(a,e)};
