var loaderInterval=null,getPTimeout=null,getObjectInterval=null,getlrcInterval=null,tmpScroll,tmpScrollId,perLength,tmpMatchLrcLine=0,preMatchLrcLine=-1,count=0,tmpLrcContent="",preStyleObj=null,nowStyleObj=null,tmpLrcs=new Array(),lineCount=new Array(),perLineCount=new Array(),preLrcContent=new Array(),nextLrcContent=new Array(),color=new Array(21);color[0]="#000000";color[1]="#0d0500";color[2]="#1a0a00";color[3]="#270f00";color[4]="#341400";color[5]="#411900";color[6]="#4e1e00";color[7]="#5b2300";color[8]="#682800";color[9]="#752d00";color[10]="#823200";color[11]="#8f3700";color[12]="#9c3c00";color[13]="#a94100";color[14]="#b64600";color[15]="#c34b00";color[16]="#d05000";color[17]="#dd5500";color[18]="#ea5a00";color[19]="#f75f00";color[20]="#ff5a00";var imgsServer="http://imgs.zhangmen.baidu.com/",mlrcID;function lrcInterface(A,B){mlrcID=B;preStyleObj=document.styleSheets[0].rules[0];nowStyleObj=document.styleSheets[0].rules[1];var _=document.getElementById("LrcShower_div");count=0;_.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;\u6b63\u5728\u52a0\u8f7d\u6b4c\u8bcd\u4fe1\u606f\uff0c\u8bf7\u60a8\u7a0d\u7b49\u7247\u523b....";document.getElementById("LrcUrl_div").style.display="";bdSyncLRC.showLRCAPI(null);tmpLrcContent="";tmpLrcs=new Array();if(getObjectInterval!=null)clearInterval(getObjectInterval);getObjectInterval=setInterval($,200);function $(){bdLRC=new bdSyncLRC();if(bdLRC!=null){if(getObjectInterval!=null)clearInterval(getObjectInterval);bdLRC.setPlayer(A);bdLRC.setURL(B);bdLRC.setOutput("LrcShower_div");bdLRC.Exchange();bdLRC.begin()}else if(count==25){if(getObjectInterval!=null)clearInterval(getObjectInterval);_.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;\u53ef\u80fd\u662f\u56e0\u4e3a\u7f51\u7edc\u7684\u539f\u56e0\uff0c\u7cfb\u7edf\u6ca1\u6709\u627e\u5230\u5408\u9002\u7684\u6b4c\u8bcd\u3002\u8bf7\u7a0d\u540e\u91cd\u8bd5<span style='color:#FFF'>S1</span></span>";bdSyncLRC.showLRCAPI(null)}else count++}}function bdSyncLRC(){var F=null,E=null,$="",D="",A="",C=new Array();this.preLRC=new Array();this.offsetTime=0;this.scrollMoveLen=20;var B="MPH",_=document.getElementById("LrcUrlA")}bdSyncLRC.prototype.setPlayer=function(){if(arguments.length>=1){arg=arguments[0];this.playerType=arg;if(arg=="MPH"||arg=="MPL")arg="MediaPlayer1";else if(arg=="RP")arg="RealPlayer1";playerTypeStr=String(arg);if(typeof(arg)=="string")this.playerObj=document.getElementById(arg);else if(typeof(arg)=="object")this.playerObj=arg}};bdSyncLRC.prototype.showLRC=function(){if(arguments[0]){LrcUrlA.style.visibility="visible";LrcUrlA.href=arguments[0];var $=(arguments[0].length<=42)?arguments[0]:(arguments[0].substr(0,42)+"...");LrcUrlA.innerHTML="LRC\u6b4c\u8bcd\u6765\u81ea\uff1a"+$}else LrcUrlA.style.visibility="hidden"};bdSyncLRC.showLRCAPI=bdSyncLRC.prototype.showLRC;bdSyncLRC.prototype.setPlayerType=function(){if(arguments.length>=1)this.playerType=arguments[0]};bdSyncLRC.prototype.getPlayer=function(){if(typeof(document.getElementById("this.playerObj"))=="object")return this.playerObj;else return null};bdSyncLRC.prototype.getPlayerType=function(){return this.playerType};bdSyncLRC.prototype.setURL=function(){if(arguments.length>=1){var $,_;$=String(Math.floor((parseInt(arguments[0])/100)));_=arguments[0]+".lrc";this.lrcURL="http://box.zhangmen.baidu.com"+"/bdlrc/"+$+"/"+_}};bdSyncLRC.prototype.getURL=function(){return this.lrcURL};bdSyncLRC.prototype.setContent=function(){if(arguments.length>=1)this.lrcContent=arguments[0]};bdSyncLRC.prototype.getContent=function(){return this.lrcContent};bdSyncLRC.prototype.setLRC=function(){if(arguments.length>=1)this.lrcObjArray=arguments[0]};bdSyncLRC.prototype.getLRC=function(){return this.lrcObjArray};bdSyncLRC.prototype.setOutput=function($){this.lrcShower=$};bdSyncLRC.prototype.getOutput=function(){if(this.lrcShower!=""){arg=this.lrcShower;if(typeof(arg)=="string")return document.getElementById(arg);else if(typeof(arg)=="object")return arg}return null};bdSyncLRC.prototype.multiLRC=function($){thisObj=this;tmpVar=$.split("]");if(tmpVar.length>=2){lrcText=tmpVar[tmpVar.length-1];for(j=0;j<tmpVar.length-1;j++){lrcTime=tmpVar[j]+"]";thisObj.preLRC.push(lrcTime+""+lrcText)}}};bdSyncLRC.prototype.preSyncLRC=function(){if(this.getContent()==null||this.getContent()=="")return;lrcLines=this.getContent().split("\n");tmpArr=new Array();var _,B=0,A=lrcLines.length,$=lrcLines[A-1];new RegExp("url:([^]]+)").test($);$=RegExp.$1;this.showLRC($);for(B=0;B<A;B++)this.multiLRC(replaceStr(lrcLines[B]));this.preLRC.sort();var C="aaa";for(B=this.preLRC.length-1;B>=0;B--)if(this.preLRC[B]==C){C=this.preLRC[B];this.preLRC.splice(B,1)}else C=this.preLRC[B];preTime=0;indexLRC=1;tmpArr[0]=new LRCItem(0,"");for(B=0;B<this.preLRC.length;B++)if(this.preLRC[B].length>9){tmpTime=getLyrcTime(this.preLRC[B]);tmpLrc=getLyrc(this.preLRC[B]);if(tmpTime<preTime||tmpLrc=="")continue;if(tmpTime==0){tmpArr[0].lrcContent=tmpLrc;continue}preTime=tmpTime;_=new LRCItem(tmpTime,tmpLrc);tmpArr[indexLRC++]=_}_=new LRCItem(3600,"Over...");tmpArr[indexLRC]=_;this.setLRC(tmpArr);getLineCount(tmpArr);getLrcContent(tmpArr);tmpLrcs=this.getLRC();tmpScroll=this.getOutput();tmpScrollId=this.getOutput();perLength=this.scrollMoveLen;if(perLength<=0)perLength=1;tmpScrollId.scrollTop=0;tmpMatchLrcLine=0;preMatchLrcLine=-1};function replaceStr($){return $.replace(/^\s*|\s*$/g,"")}function getLyrc($){try{tmpArray=$.split("]");return tmpArray[tmpArray.length-1]}catch(_){}return""}function getLyrcTime($){try{tmpChar=$.split("]")[0].split("[")[1];tmpVar=tmpChar.split(":");if(tmpVar.length<2)return 0;min=tmpVar[1].split(".")[0];tmpInt=parseInt(tmpVar[0])*60+parseFloat(min);if(!isNaN(tmpInt))return tmpInt}catch(_){}return 0}function LRCItem(){var _=-1,$="";if(arguments.length>=2){this.lrcTime=arguments[0];this.lrcContent=arguments[1]}}function getLineCount($){for(m=0;m<$.length;m++){lineCount[m]=Math.floor($[m].lrcContent.length/67);perLineCount[m]=0;for(j=0;j<m;j++)perLineCount[m]+=lineCount[j]}}function getLrcContent($){for(m=0;m<$.length;m++){preLrcContent[m]="<br>"+"<br>"+"<br>"+"<br>"+"<br>"+"<br>"+"<br>";nextLrcContent[m]="";for(j=0;j<m-1;j++)preLrcContent[m]+="<span style='font-size:12px;margin-left:12px'>&nbsp;<font color=#000000>"+replaceStr($[j].lrcContent)+"</font></span><br>";for(j=m+1;j<$.length;j++)nextLrcContent[m]+="<span style='font-size:12px;margin-left:12px'>&nbsp;<font color=#000000>"+replaceStr($[j].lrcContent)+"</font></span><br>";nextLrcContent[m]+="<br><br><br><br><br><br><br>"}}bdSyncLRC.prototype.Exchange=function(){var $=null;if(window.XMLHttpRequest)$=new XMLHttpRequest();else if(window.ActiveXObject){try{$=new ActiveXObject("Microsoft.XMLHTTP")}catch(_){$=new ActiveXObject("MSXML.XMLHTTP")}}var A=this.getURL();thisObj=this;var B="";try{$.open("GET",A,false);$.onreadystatechange=function(){if(($.readyState==4)&&($.status==200)){B=bdBytes2Str($.responseBody);thisObj.setContent(B)}};$.send(null)}catch(_){}};bdSyncLRC.prototype.begin=function(){thisObj=this;tmpPlayerObj=thisObj.getPlayer();var _=document.getElementById("LrcShower_div");if(getlrcInterval!=null)clearInterval(getlrcInterval);getlrcInterval=setInterval($,100);count=0;function $(){if(typeof(thisObj.getContent())!="undefined"){if(getlrcInterval!=null)clearInterval(getlrcInterval);thisObj.preSyncLRC();if(thisObj.getLRC()[0].lrcContent!="")thisObj.getOutput().innerHTML="<br><br><br><br><br><br>"+"<span style='font-size:12px;margin-left:12px'>&nbsp;<font color=#000000>"+replaceStr(thisObj.getLRC()[0].lrcContent)+"</font></span><br>"+nextLrcContent[0];else thisObj.getOutput().innerHTML="<br><br><br><br><br><br>"+nextLrcContent[0];getPlayingTime(thisObj.getPlayer(),thisObj)}else if(count==50){if(getlrcInterval!=null)clearInterval(getlrcInterval);_.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;\u53ef\u80fd\u662f\u56e0\u4e3a\u7f51\u7edc\u7684\u539f\u56e0\uff0c\u7cfb\u7edf\u6ca1\u6709\u627e\u5230\u5408\u9002\u7684\u6b4c\u8bcd\u3002\u8bf7\u7a0d\u540e\u91cd\u8bd5<span style='color:#FFF'>S2</span></span>";new Image().src=imgsServer+"wd/lrc.gif?status=s2&lrcid="+mlrcID+"&random="+Math.random();bdSyncLRC.showLRCAPI(null)}else count++}};function getPlayingTime(_,A){try{tmpbdLRCObj=A;var $=_;if(typeof($)=="string")$=document.getElementById($);if(getPTimeout!=null)clearTimeout(getPTimeout);getPTimeout=window.setTimeout("getPlayingTime(tmpPlayerObj,tmpbdLRCObj)",1000);bdsyncLyrc(tmpbdLRCObj)}catch(B){}}function getCurrentPosition(_,$){if($=="MPH")return _.controls.currentPosition;else if($=="MPL")return _.CurrentPosition;else if($=="RP")return _.GetPosition()/1000;return 0}function findLoc(C){var $,_,B=C.getPlayer();currentTime=getCurrentPosition(B,C.getPlayerType());if(currentTime>=tmpLrcs[tmpMatchLrcLine].lrcTime){$=tmpMatchLrcLine;_=tmpLrcs.length}else{$=0;_=tmpMatchLrcLine+1}var A;for(A=$;A<_;A++){nowLrc=tmpLrcs[A];nextLrc=tmpLrcs[(A<_-1)?A+1:A];nowTime=nowLrc.lrcTime+C.offsetTime;nextTime=nextLrc.lrcTime+C.offsetTime;if(nowTime<=currentTime&&currentTime<nextTime)return A}return 0}function bdsyncLyrc(B){try{var A=findLoc(B);tmpMatchLrcLine=A;tmpLrcContent=preLrcContent[A];if(A>0)tmpLrcContent+="<span class=prelrc>&nbsp;"+replaceStr(tmpLrcs[A-1].lrcContent)+"</span><br>";tmpLrcContent+="<span class=nowlrc>&nbsp;"+replaceStr(tmpLrcs[A].lrcContent)+"</span><br>";tmpLrcContent+=nextLrcContent[A];if(preMatchLrcLine!=tmpMatchLrcLine){tmpScroll.innerHTML=tmpLrcContent;if(Math.abs(tmpMatchLrcLine-preMatchLrcLine)>1)tmpScrollId.scrollTop=(tmpMatchLrcLine+perLineCount[tmpMatchLrcLine]+1)*perLength;else{var _=0;function $(){tmpScrollId.scrollTop+=2*(1+lineCount[preMatchLrcLine]);_++;if(_>=10){clearInterval(loaderInterval);loaderInterval=null;_=0}else if(_<0)_=0}if(loaderInterval!=null){clearInterval(loaderInterval);loaderInterval=null;_=0}loaderInterval=setInterval($,25)}}preMatchLrcLine=tmpMatchLrcLine}catch(C){}}