var KgAck=KgAck||{$:function(){var c=[];for(var b=0,a=arguments.length;b<a;b++){var d=arguments[b];if(typeof d=="string"){d=document.getElementById(d)}if(a==1){return d}c.push(d)}return c},$T:function(b,c){var a=(this.$(c)||document).getElementsByTagName(b||"*");return this.$A(a)},$A:function(c){var a=[];for(var d=0,b=c.length;d<b;d++){a.push(c[d])}return a},$C:function(d,g,f){var b=[],e=0;if(!!document.getElementsByClassName){var a=this.$(g||document).getElementsByClassName(d);a=this.$A(a);if(f&&f!=="*"){for(var c=a.length;e<c;e++){(a[e].tagName.toLowerCase()===f.toLowerCase())&&b.push(a[e])}}else{b=a}}else{for(var a=this.$T(f,g),c=a.length;e<c;e++){new RegExp("\\b"+d+"\\b","g").test(a[e].className)&&b.push(a[e])}}return b},loadScript:function(c,b,h,e){var g=b||"";if(b&&(typeof b==="object")){var f="";for(var d in b){f+=d+"="+b[d]+"&"}g=f.substr(0,f.length-1)}var a=document.createElement("script");a.type="text/javascript";if(g!=null&&g!=""){c=c+"?"+(g||"")}a.src=c;if(e==true){a.async="async"}a.onload=a.onreadystatechange=function(){if(!this.readyState||(this.readyState=="complete"||this.readyState=="loaded")){h&&h();a.onreadystatechange=a.onload=null;a=null}};document.getElementsByTagName("head")[0].appendChild(a)},JSON:function(){function f(n){return n<10?"0"+n:n}Date.prototype.toJSON=function(){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};var m={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function stringify(value,whitelist){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case"string":return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c){return c}c=a.charCodeAt();return"\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16)})+'"':'"'+value+'"';case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}if(typeof value.toJSON==="function"){return stringify(value.toJSON())}a=[];if(typeof value.length==="number"&&!(value.propertyIsEnumerable("length"))){l=value.length;for(i=0;i<l;i+=1){a.push(stringify(value[i],whitelist)||"null")}return"["+a.join(",")+"]"}if(whitelist){l=whitelist.length;for(i=0;i<l;i+=1){k=whitelist[i];if(typeof k==="string"){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+":"+v)}}}}else{for(k in value){if(typeof k==="string"){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+":"+v)}}}}return"{"+a.join(",")+"}"}}return{stringify:stringify,parse:function(text,filter){var j;function walk(k,v){var i,n;if(v&&typeof v==="object"){for(i in v){if(Object.prototype.hasOwnProperty.apply(v,[i])){n=walk(i,v[i]);if(n!==undefined){v[i]=n}else{delete v[i]}}}}return filter(k,v)}if(/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/bfnrtu]/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof filter==="function"?walk("",j):j}throw new SyntaxError("parseJSON")}}},Cookie:{write:function(b,e,h,g,d,f){var a="";if(h){var c=new Date();c.setTime(c.getTime()+(h*1000));a=";expires="+c.toGMTString()}e=encodeURIComponent(e);g=g?"; path="+(g):";path=/";d=d?"; domain="+(d):"";f=f?"; secure":"";document.cookie=[b,"=",e,a,g,d,f].join("")},setDay:function(a,c,f,e,b,d){this.write(a,c,(f*24*60*60),e,b,d)},setHour:function(a,c,f,e,b,d){this.write(a,c,(f*60*60),e,b,d)},setMin:function(a,c,f,e,b,d){this.write(a,c,(f*60),e,b,d)},setSec:function(a,c,f,e,b,d){this.write(a,c,(f),e,b,d)},read:function(d,f){var g="";var e=d+"=";if(document.cookie.length>0){offset=document.cookie.indexOf(e);if(offset!=-1){offset+=e.length;end=document.cookie.indexOf(";",offset);if(end==-1){end=document.cookie.length}g=document.cookie.substring(offset,end);if(typeof f!="undefined"&&f!=null&&f!=""){var b=g.toString().split("&");for(var c=0;c<b.length;c++){var a=b[c];if(a.substring(0,f.length+1)==(f+"=")){g=a.substring(f.length+1).replace(/%/g,"\\");break}else{g=""}}}}}return decodeURIComponent(g)},remove:function(a){this.write(a,"",-90)}},KgUrl:{getAck:"http://serveraddr.serviceweb.kugou.com/"},getConfig:function(e,k,h){var b=KgAck.GetDomain();if("kugou.com"!=b&&"fanxing.com"!=b){KgAck.GetMsg(k,{errorCode:"20007",errorMsg:"forbidden"});return false}if(KgAck.IsEmpty(e.appid)||KgAck.IsEmpty(e.clientver)||KgAck.IsEmpty(e.clienttime)||KgAck.IsEmpty(e.plats)||KgAck.IsEmpty(k)){KgAck.GetMsg(k,{errorCode:"20010",errorMsg:"必填参数不能为空"});return false}var m=parseInt(e.appid);var c=parseInt(e.clientver);var f=parseInt(e.clientver);var l=e.plats;if(m<1||c<1||f<1||!KgAck.IsArray(l)||!KgAck.IsFunction(k)){KgAck.GetMsg(k,{errorCode:"20007",errorMsg:"非法请求,(请检查参数类型)"});return false}if(l.length>10){KgAck.GetMsg(k,{errorCode:"20007",errorMsg:"非法请求,(请求服务超出限制)"});return false}var n=l.length;var a="";for(var j=0;j<n;j++){a=KgAck.Cookie.read("ACK_SERVER_"+l[j]);if(a!=null&&a!=""){KgAck.GetMsg(k,{errorCode:"20024",errorMsg:"存在缓存"});return false}}var g=l.toString();var h=false;if(h!=null&&h==true){h=true}var d={"appid":m,"clientver":c,"plats":g,"callback":k,"clienttime":parseInt(new Date().getTime()/1000)};this.loadScript(KgAck.KgUrl.getAck,d,h)},GetDomain:function(){var a=/\w*\.(com.cn|com|net.cn|net|org.cn|org|gov.cn|gov|cn|mobi|me|info|name|biz|cc|tv|asia|hk|网络|公司|中国).*$/g;return document.domain.toString().match(a)[0]},GetMsg:function(b,a){if(!KgAck.IsEmpty(b)){window[b](a)}},Trim:function(a){if(typeof a==="string"){return a.replace(/^\s+|\s+$/g,"")}else{return a}},IsEmpty:function(a){if(typeof a!="undefined"&&a!=null&&a!=""){return false}else{return true}},GetBytes:function(){var a=0;for(var b=0;b<this.length;b++){if(this.charCodeAt(b)>256){a+=2}else{a+=1}}return a},Intercept:function(d,a){var f=this;f=f.trim();if(f.getBytes()<d){return f}var e=0;var b=0;if(a.length>0){d=d-a.length}for(var c=0;c<f.length;c++){if(this.charCodeAt(c)>256){e+=2}else{e+=1}if(e>d){break}b++}return f.substr(0,b)+a},IsArray:function(a){if(typeof Array.isArray==="function"){return Array.isArray(a)}else{return Object.prototype.toString.call(a)==="[object Array]"}},IsFunction:function(funcName){try{if(typeof(eval(funcName))=="function"){return true}}catch(e){}return false}};