
String.prototype.endWith=function(oString){var reg=new RegExp(oString+"$","ig");return reg.test(this);}
String.prototype.contains=function(oString){return(this.indexOf(oString)>-1);}
function productPing(msg){var img=new Image();img.src='http://ping2.mp3.sogou.com/yama.gif?'+msg+"&"+Math.random();return false;}
function strlen(str)
{var len;var i;len=0;for(i=0;i<str.length;i++){if(str.charCodeAt(i)>255){len+=2;}
else{len++;}}
return len;}
function getShortStr(str,len){if(str==null||str.length<=len)
return str;return str.substr(0,len);}
function getShortUrl(str,len){if(str==null||str.length<=len)
return str;if(str.indexOf("://")<0)
return getShortStr(str,len);var reg=/(http|https|ftp):\/\/(.*?)\//ig;var attr=reg.exec(str);prefix=attr[0];if(prefix>len)
return getShortStr(prefix,len)+"...";return prefix+"..."+str.substr((str.length-len+prefix.length+1)<0?0:(str.length-len+prefix.length),str.length);}
function RemoveOldUrl(array,val)
{var i;var j;for(var i=0,j=0;i<array.length;i++){if(array[i].url==val){for(j=i;j<array.length-1;j++){array[j]=array[j+1];}
array.length=array.length-1;}}
return array;}
function isRm(url){return url.endWith(".rm")||url.endWith(".ram");}
function isMp3(url){return url.endWith(".mp3")||url.contains(".mp3?wxc");}
function setPlayerVolume(){if(isReal){var v=readCookie("sogou_player_volume");var vv=parseInt(v);if(!isNaN(vv)&&sogouRMP&&sogouRMP.player){sogouRMP.setVolume(vv);}}else{var v=readCookie("sogou_player_volume");var vv=parseInt(v);if(!isNaN(vv)&&sogouMP&&sogouMP.player){sogouMP.setVolume(vv);}}}
function changeURLPar(destiny,par,par_value)
{destiny=destiny.replace("#","");var pattern=par+'=([^&]*)';var replaceText=par+'='+par_value;if(destiny.match(pattern))
{var tmp='/'+par+'=[^&]*/';tmp=destiny.replace(eval(tmp),replaceText);return(tmp);}
else
{if(destiny.match('[\?]'))
{return destiny+'&'+replaceText;}
else
{return destiny+'?'+replaceText;}}
return destiny+'\n'+par+'\n'+par_value;}
function playByObj(playerId,musicData){var win=document.getElementById(playerId);win.src="/listen/player.jsp?id="+musicData.id+"&t="+musicData.title+"&s="+musicData.artist+"&url="+musicData.url+"&isExt="+musicData.isExt+"&gid="+musicData.gid+"&cid="+musicData.cid+"&lid="+musicData.lid;}
function playByParam(playerid,id,title,artist,url,isExt,gid,cid,lid){var win=document.getElementById(playerid);win.src="/listen/player.jsp?id="+id+"&t="+title+"&s="+artist+"&url="+url+"&isExt="+isExt+"&gid="+gid+"&cid="+cid+"&lid="+lid;}
function getPlayerUrl(id,title,artist,url,isExt,gid,cid,lid){return"/listen/play.jsp?id="+id+"&t="+title+"&s="+artist+"&url="+url+"&isExt="+isExt+"&gid="+gid+"&cid="+cid+"&lid="+lid;}
function playNext(){}
function getRetryData(){a=new Ajaj("/coo/common/ajaj_getRetryData.jsp",{"parameters":{"query":escape(queryContext)},"onComplete":function(json){retryData=json;retryData=RemoveOldUrl(retryData,initURL);if(retryData==null||retryData.length==0){productPing("retry="+autoTry+"&stat=nodata");}else{productPing("retry="+autoTry+"&stat=hasdata");}
fresh();}});}
function tryNewUrl(){var clickTimer=new Date();if(Date.parse(clickTimer)-Date.parse(timer)<2000){return false;}else{timer=clickTimer;}
if(!retryData){getRetryData();return;}
if(retryData==null||retryData.length<=0){productPing("retry="+autoTry+"&stat=nodata");return;}else{fresh();}}
function fresh(){if(autoTry&&(retryData==null||retryData.length==0)){if(autoTry){parent.nextPlaySong();}else{return false;}}
tryNum=++tryNum%retryData.length;currData=retryData[tryNum];if(currData==null||currData.url==null)
return;currentURL=currData.url;cid=currData.cid;gid=currData.gid;isReal=isRm(currentURL);if(isReal){disableWmPlayerObj();activeRealPlayerObj(currentURL);clearPingbackState();}else{disableRealPlayerObj();activeWmPlayerObj(currentURL);initPingbackState();}
var url_meta=document.getElementById("url_meta");url_meta.innerHTML="来源:<a href="+currentURL+" target=_blank>"+getShortUrl(currentURL,32)+"</a>";showInfoBar(cid,gid);try{parent.updateRetryRes(retryData[tryNum].cid,retryData[tryNum].gid,retryData[tryNum].url);}catch(e){}}
var tryNum=-1;var retryData;function initPlayer(){if(isReal){activeRealPlayerObj(currentURL);}else{activeWmPlayerObj(currentURL);}
lrcInterface('MPH',lid);setPlayerVolume();}
var wmTimer;var realTimer;var sogouMP;var sogouRMP;var timer=new Date();var beginTime=new Date();var playTime=-1;var connectTime=-1;var speedInfoDirty=false;var cached=false;var startPlay=false;var startTime=new Date();function activeRealPlayerObj(url){rplayer=document.getElementById("RealPlayer1");if(!rplayer||!sogouRMP){media=document.getElementById("rmedia");media.innerHTML='<embed name="RealPlayer1" id="RealPlayer1" type="audio/x-pn-realaudio-plugin" src="'+url+'" controls="ControlPanel,StatusBar" width="325" height=64 border=0 autostart=true></embed>';showUpdateTip();sogouRMP=new SogouRealMP("RealPlayer1");rplayer=document.getElementById("RealPlayer1");}else{try{rplayer.setSource(url);rplayer.DoPlay();}catch(e){}}
clearTimeout(realTimer);realTimer=setTimeout(sogouRMP.checkPlayState,200);rm_bufferState=false;rm_connState=false;startPlay=false;document.getElementById("rmplayerdiv").style.display="";setPlayerVolume();}
function disableRealPlayerObj(){var rplayer=document.getElementById("RealPlayer1");if(realTimer&&sogouRMP&&rplayer){clearTimeout(realTimer);rplayer.SetAutoStart(false);rplayer.setSource('');rplayer.DoStop();}
document.getElementById("rmplayerdiv").style.display="none";}
function activeWmPlayerObj(url){var media=document.getElementById("wmedia");var mplayer=document.getElementById("MediaPlayer1");var playcount=(document.all&&navigator.userAgent.indexOf("Opera")<0)?1:99
if(!sogouMP||!mplayer){media.innerHTML='<object id="MediaPlayer1" width="325" height="64" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft? Windows? Media Player components..." type="application/x-oleobject" align="middle"><param name="URL" value="'+url+'">     <param name="ShowStatusBar" value="True"><param name="DefaultFrame" value="sogouwindow"><param name="AutoStart" value="1">      <param name="PlayCount" value="1">      <param name="windowlessVideo" value="1"><param name="invokeURLs" value="false">         <embed id="ffPlayer1" windowlessVideo=true invokeURLs=false type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="'+url+'" align="middle" width="325" height="65" autorewind="0" autostart="1" showcontrols="1" showstatusbar="1" loop="true" playcount="'+playcount+'" defaultframe="sogouwindow"></embed></object>';showUpdateTip();sogouMP=new SogouWmpMP("MediaPlayer1");wmp=sogouMP;bglisten=document.getElementById("bglisten");if(wmp&&wmp.getVersion()>=9&&bglisten){bglisten.location="http://220.181.19.146/bg_listen3.jsp?_random="+Math.random()+"&area="+userArea;}else{}}else{mplayer.url=url;mplayer.controls.play();}
clearTimeout(wmTimer);wmTimer=setTimeout(sogouMP.checkPlayState,200);wm_bufferState=false;wm_connState=false;startPlay=false;document.getElementById("wmplayerdiv").style.display="";setPlayerVolume();}
function disableWmPlayerObj(){var mplayer=document.getElementById("MediaPlayer1");document.getElementById("wmplayerdiv").style.display="none";if(sogouMP&&mplayer){mplayer.url='';mplayer.controls.stop();}
clearTimeout(wmTimer);}
function savePlayerVolume(){if(isReal){if(typeof(sogouRMP)!="undefined"&&typeof(sogouRMP.player)!="undefined"){var v=sogouRMP.getVolume();var vv=parseInt(v);if(!isNaN(vv)){createCookie("sogou_player_volume",vv,60*60*24*365*30);}}}else{if(typeof(sogouMP)!="undefined"&&typeof(sogouMP.player)!="undefined"){var v=sogouMP.getVolume();var vv=parseInt(v);if(!isNaN(vv)){createCookie("sogou_player_volume",vv,60*60*24*365*30);}}}}
function SogouWmpMP(o){if(typeof(o)=="string"){this.player=document.getElementById(o);}else{this.player=o;}
try{this.player.attachEvent("PlayStateChange",function(newState){if(newState==8){sogouMP.playNext();}else if(newState==3){if(playTime==-1&&connectTime!=-1){playTime=new Date();}
if(Date.parse(playTime)-Date.parse(connectTime)<200){cached=true;}}else if(newState==6){if(connectTime==-1){connectTime=new Date();}}else if(newState==1||newState==2||newState==4||newState==5){speedInfoDirty=true;}});}catch(e){}
try{this.player.attachEvent("OpenStateChange",function(newState){if(newState==13){wm_connState=true;}});}catch(e){}
try{this.player.attachEvent("buffering",function(newState){if(newState==true){wm_bufferState=true;}});}catch(e){}
try{this.player.attachEvent("Error",function(){clearTimeout(reportWorker);doErrorReport();});sogouMP.player.attachEvent("PlayStateChange",function(newState){if(newState==6){if(checkWorkerStep==0){checkStatus();}}else if(newState==8){mediaEnd=true;}else if(newState==1||newState==2||newState==4||newState==5){speedInfoDirty=true;getNetSpeed=function(){return-1;};}else if(newState==3){if(!played&&getConnectTime()!=-1){played=true;if(getDuration()<30){doSmallResourceReport();}
clearTimeout(reportWorker);reportWorker=setTimeout(report,period);}}});}catch(e){}}
SogouWmpMP.prototype={getCurrentPosition:function(){if(this.player&&this.player.controls){return this.player.controls.currentPosition;}else{return 0;}},isHigh:function(){try{var v=this.player.versionInfo;var dotIdx=v.indexOf(".");if(dotIdx<0){return false;}
v=v.substring(0,dotIdx);if(!isNaN(v)){return parseInt(v)>=9;}}catch(e){}
return false;},getVersion:function(){version=0;try{var v=this.player.versionInfo;var dotIdx=v.indexOf(".");if(dotIdx<0){return version;}
v=v.substring(0,dotIdx);if(!isNaN(v)){return parseInt(v);}}catch(e){}
return version;},getVolume:function(){try{if(typeof(this.player)!="undefined"&&typeof(this.player.settings)!="undefined"&&this.player&&this.player.settings){return this.player.settings.Volume;}}catch(e){return 50;}},setVolume:function(v){if(this.player&&this.player.settings){this.player.settings.volume=v;}},playNext:function(){if(parent)
parent.nextPlaySong();},getPlayState:function(){return this.player.playState;},isPlaying:function(){var singleSong=1;if(singleSong&&this.getPlayState()==6){return true;}
return this.getPlayState()==3;},isSysStop:function(){return this.getPlayState()==8;},isStoped:function(){return this.getPlayState()==1;},stop:function(){this.player.stop();},getBandwidth:function(){try{return this.player.network.Bandwidth;}catch(e){return-1;}},getBitrate:function(){try{return this.player.currentMedia.getItemInfo("Bitrate");}catch(e){return-1;}},getDuration:function(){try{return this.player.currentMedia.duration;}catch(e){return-1;}},getBufferingCount:function(){try{return this.player.network.bufferingCount;}catch(e){return-1;}},getErrorCode:function(){return this.player.error.item(0).errorCode;},getErrorDesc:function(){return this.player.error.item(0).errorDescription;},getReceivedPackets:function(){try{return this.player.network.receivedPackets;}catch(e){return-1;}},getConnectTime:function(){return connectTime;},getPlayTime:function(){return playTime;},getDownloadProgress:function(){try{return this.player.network.downloadProgress;}catch(e){return-1;}},getBufferingProgress:function(){try{return this.player.network.bufferingProgress;}catch(e){return-1;}},playerType:"wmplayer",checkPlayState:function(){savePlayerVolume();wmTimer=setTimeout(sogouMP.checkPlayState,200);}}
function isInstallReal(){var RealMode=false;if(navigator.userAgent.indexOf("MSIE")<0){numPlugins=navigator.plugins.length;for(i=0;i<numPlugins;i++){plugin=navigator.plugins[i];if(plugin.name.substring(0,10)=="RealPlayer"){RealMode=true;}}}
if(typeof(RealPlayerG2)!="undefined"||typeof(RealPlayer5)!="undefined"||typeof(RealPlayer4)!="undefined"){return true;}else if(RealMode){return true;}else{return false;}}
function SogouRealMP(o){if(typeof(o)=="string"){this.player=document.getElementById(o);}else{this.player=o;}
try{this.player.attachEvent("OnPlayStateChange",function(newState){});}catch(e){}}
SogouRealMP.prototype={getCurrentPosition:function(){if(sogouRMP&&sogouRMP.player&&typeof(sogouRMP.player.GetPosition)!="undefined"){return sogouRMP.player.GetPosition()/1000;}else{return 0;}},getVolume:function(){try{if(instReal){return sogouRMP.player.GetVolume();}else{return 50;}}catch(e){return 50;}},setVolume:function(v){if(instReal&&sogouRMP&&sogouRMP.player){try{sogouRMP.player.SetVolume(v);}catch(e){}}},playNext:function(){if(parent)
parent.nextPlaySong();},playStateChange:function(arg){},getPlayState:function(){try{if(sogouRMP&&sogouRMP.player){return sogouRMP.player.GetPlayState();}}catch(e){return-1;}},isPlaying:function(){return this.getPlayState()==3;},isContacting:function(){return this.getPlayState()==1;},isStoped:function(){return this.getPlayState()==0;},isBuffer:function(){return this.getPlayState()==2;},getErrorCode:function(){return this.player.GetLastErrorUserString();},getErrorDesc:function(){return this.player.GetLastErrorUserCode();},playerType:"rmplayer",checkPlayState:function(){if(instReal&&sogouRMP&&isReal){rm_bufferState=sogouRMP.isBuffer();if(!startPlay){if(sogouRMP.isPlaying()){startPlay=true;rm_connState=true;}}
if(startPlay&&sogouRMP.isStoped()){sogouRMP.playNext();}
savePlayerVolume();setTimeout(sogouRMP.checkPlayState,200);}},test:function(){}}
function showUpdateTip(){if(!isReal&&document.all&&sogouMP&&!sogouMP.isHigh()){document.getElementById('player_tip').innerHTML=' <div style="text-align:right;" id="wmp64">您的播放器版本过低，建议您升级到<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9e5305bf-c415-4c5e-be66-2bd163cce30b&DisplayLang=zh-cn" target=_blank>最新版本</a>。</div>';}else if(isReal&&!isInstallReal()){document.getElementById("rmplayerdiv").innerHTML="如果您无法试听歌曲,请先安装<a href=http://forms.real.com/netzip/intl/intl_getrde601.html?lang=cn&h=software-dl.real.com&f=windows/RealPlayer10-5GOLD_cn.exe&p=RealPlayer&oem=rp10_cn target=_blank><font color=red>RealPlayer</font></a>软件";instReal=false;}}
function showInfoBar(cid,gid){var infobar=document.getElementById("infobar");str='<span>';str+='<a href=\"javascript:void(0)\" onclick=\"dyama(\'ldown\');window.open(\'/down.so?gid='+cid+'&globalId='+gid+'&t='+(isExt?enQueryParam:entitle)+'&w=02030600\',\'down\',\'width=350,height=415,scrollbars=no\');return false;\" >'+'<img src=\"/images/dl.gif\" alt=\"下载\" width=\"16\" height=\"14\">下载</a>';if(isMp3(currentURL)){str+='<a href=\"javascript:void(0)\"  onclick=\"window.open(\'/tools/loading/load.jsp?diyGlobalId='+gid+'&gid='+cid+'\',\'diy\',\'\');return false;\">'+'<img src=\"/images/diy.gif\" alt=\"diy\" width=\"24\" height=\"14\">自制铃声</a>';}
str+='</span>';if(document.all&&currentURL.length>0&&navigator.userAgent.indexOf("Opera")<0){str+='<a href=\"javascript:void(null)\" onclick=\"autoTry=false;tryNewUrl();return false;\">试听慢,点这儿</a>'}
infobar.innerHTML=str;}
var wmp;var period=20000;var detectOver=false;var errorMsg="";var Bandwidth=-1;var Bitrate=-1;var Speed=-1;var reportMsg="";var isCached=false;var mediaEnd=false;var checkWorker=-1;var maxCheckWorkerStep=20;var checkWorkerStep=0;var avgSpeed=-1;var sumBandWidth=0;var downloadCompleteTime=-1;var reportWorker=setTimeout(report,period);var played=false;var reported=false;function clearPingbackState(){wmp=sogouMP;period=20000;detectOver=false;errorMsg="";Bandwidth=-1;Bitrate=-1;Speed=-1;reportMsg="";isCached=false;mediaEnd=false;checkWorker=-1;maxCheckWorkerStep=20;checkWorkerStep=0;avgSpeed=-1;sumBandWidth=0;downloadCompleteTime=-1;clearTimeout(reportWorker);played=false;reported=false;}
function initPingbackState(){wmp=sogouMP;period=20000;detectOver=false;errorMsg="";Bandwidth=-1;Bitrate=-1;Speed=-1;reportMsg="";isCached=false;mediaEnd=false;checkWorker=-1;maxCheckWorkerStep=20;checkWorkerStep=0;avgSpeed=-1;sumBandWidth=0;downloadCompleteTime=-1;clearTimeout(reportWorker);reportWorker=setTimeout(report,period);played=false;reported=false;}
function getNetSpeed(){if(isSpeedInfoDirty()){return-1;}
if(isReal){return-1;}else{now=new Date();if(downloadCompleteTime==-1){cost=now-connectTime;}else{cost=downloadCompleteTime-connectTime;}
cost=cost/1000;if(getPlayTime()!=-1&&getDuration()<(period/1000)){return-1;}else if(getConnectTime()!=-1&&getDuration()<=0){return-1;}else if(getBitrate()==-1||getBitrate()<8*1024){return-1;}
avgSpeed=getDownloadProgress()/100*getDuration()*getBitrate()/8/cost;return avgSpeed;}}
function getDuration(){if(isReal){return-1;}else{return wmp.getDuration();}}
function getCurrentPosition(){if(isReal){return-1;}else{return wmp.getCurrentPosition();}}
function getBandwidth(){if(isReal){return-1;}else{return wmp.getBandwidth();}}
function getBitrate(){if(isReal){return-1;}else{return wmp.getBitrate();}}
function getBufferingCount(){if(isReal){return-1;}else{return wmp.getBufferingCount();}}
function getBufferingProgress(){if(isReal){return-1;}else{return wmp.getBufferingProgress();}}
function getDownloadProgress(){if(isReal){return-1;}else{return wmp.getDownloadProgress();}}
function isSpeedInfoDirty(){if(isReal){return false;}else{return speedInfoDirty||cached;}}
function getConnectTime(){if(isReal){return-1;}else{return connectTime>0?(connectTime-beginTime)/1000:connectTime;}}
function getPlayTime(){if(isReal){return-1;}else{return playTime>0?(playTime-beginTime)/1000:playTime;}}
function getCurrURL(){return currentURL;}
function getErrNums(){return wmp.getErrorCode();}
function getErrCode(){return wmp.getErrorDesc();}
function checkStatus(){checkWorkerStep++;if(getDownloadProgress()==100){downloadCompleteTime=new Date();clearTimeout(reportWorker);report();}else if(checkWorkerStep<maxCheckWorkerStep){checkWorker=setTimeout(checkStatus,1000);}}
function report(){if(reported){return;}
doReport();}
function doReport(){var now=new Date();if(isReal)
return;wmp=sogouMP;if(!isReal&&!wmp.isHigh()){return;}
if(wmp.getVersion<9)
return;var currSongURL=currentURL;var currURL=currentURL.replace("\\?wxc","");var globalid=gid;var cgroupid=cid;var qw=enQueryParam;var isMirror=false;if(currSongURL.indexOf("wxc")>0){isMirror=true;}
if(errorMsg==""){reportMsg="?MediaEnd="+mediaEnd+"&DownloadProgress="+getDownloadProgress()+"&BufferingCount="+getBufferingCount()+"&Duration="+getDuration()+"&CurrentPosition="+getCurrentPosition()+"&SpeedInfoDirty="+isSpeedInfoDirty()+"&ConnectTime="+getConnectTime()+"&PlayTime="+getPlayTime()+"&Speed="+getNetSpeed()+"&Bitrate="+getBitrate()+"&Bandwidth="+getBandwidth()+"&url="+currURL+"&grpid="+cgroupid+"&gid="+globalid;}else{reportMsg="?Error="+errorMsg+"&url="+currURL+"&gid="+globalid+"&grpid="+cgroupid;}
if(reportMsg!=""){win_listenPing=document.getElementById("listenPing");pmsg="http://pa.d.sogou.com/listenPing3.jsp"+reportMsg.replace(" ","_")+"&area="+userArea+"&qw="+qw+"&vendor=orrinDetector";if(win_listenPing.src!=pmsg&&cgroupid!=""){win_listenPing.src=pmsg;reported=true;}}}
function doErrorReport(){var errNum=getErrNums();var errDesc=getErrCode();var msg="Error number: "+errNum+";";msg+="Error description: "+errDesc;errorMsg=msg;doReport();echoError=document.getElementById("headInfo");if(echoError){echoError.innerHTML="服务器忙，请试听其他歌曲！<a href='http://mp3.sogou.com/music.so?query="+entitle+"' target=_blank><font color=red>"+title+"</font></a>";}
errorMsg="";}
function doSmallResourceReport(){var currSongURL=currentURL;var currentURL=currentURL.replace("\\?wxc","");var globalid=gid;var cgroupid=cid;win_listenPing=document.getElementById("listenPing");pmsg="http://pa.d.sogou.com/small.jsp?cid="+cgroupid+"&gid="+globalid+"&duration="+getDuration();if(win_listenPing.src!=pmsg&&cgroupid!=""){win_listenPing.src=pmsg;}}
function setFlash(){if(sogouMP){var pos=sogouMP.getCurrentPosition()*1000;if((typeof(document.lyric)!="undefined")&&(typeof(document.lyric.SetVariable)!="undefined")){document.lyric.SetVariable("playPos",pos);}}
setTimeout(setFlash,200);}
function writeFlash(){flashVars="lyricurl=http://d.sogou.com/gecilrc_flash.so?lyricId="+lid+"&mm";flashVars="lyricurl=http://mp3.sogou.com/gecilrc_flash.so?lyricId="+lid+"&mm";var flashStr='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="325" height="245" id="lyric" align="middle">';flashStr+='<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/listen/lyric_325x245.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />';flashStr+='<param name="Flashvars" value="'+flashVars+'" />';flashStr+='<embed src="/listen/lyric_325x245.swf" quality="high" bgcolor="#ffffff" width="325" height="245" name="lyric" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" Flashvars="'+flashVars+'"/></object>';document.getElementById("lrcSpan").innerHTML=flashStr;setFlash();}
function createCookie(name,value,secs)
{if(secs)
{var date=new Date();date.setTime(date.getTime()+(secs*1000));var expires="; expires="+date.toGMTString();}
else var expires="";document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++)
{var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)return c.substring(nameEQ.length,c.length);}
return null;}
function eraseCookie(name)
{createCookie(name,"",-1);}
function Ajaj(url,args){this.id=Number(new Date()).toString()+parseInt(10*Math.random())+parseInt(10*Math.random())+parseInt(10*Math.random());this.url=url||"";this.params=args.parameters||"";this.onComplete=args.onComplete||this.defaultOnCompleteFunc;this.onLoading=args.onLoading||this.defaultOnLoadingFunc;this.onError=args.onError||this.defaultOnErrorFunc;if(!window._REROADFLOG)window._REROADFLOG=[];this.loadData();}
Ajaj.prototype={getRequest:function(){var id="IFRM"+this.id,ifm=document.getElementById(id);if(!ifm)
{ifm=document.createElement("IFRAME");ifm.id=ifm.name=id;ifm.style.display="none";document.body.appendChild(ifm);}
return ifm||false;},parseParams:function(){if(typeof(this.params)=="string"){return this.params;}else{var s="";if(this.params){for(var k in this.params){s+=k+"="+this.params[k]+"&";}}
return s;}},loadData:function(){var r=this.req=this.getRequest();if(r){this.onLoading();try{var loader=this;r._onreadystatechange=function(jsReturn){r._onreadystatechange=null;loader.onComplete.call(loader,jsReturn);loader.destroy();}
var a=this.parseParams(this.params);var b=this.url;r.contentWindow.document.write('<ht'+'ml><bo'+'dy><scr'+'ipt>try{if(document.all&&!parent._REROADFLOG["'+this.id+'"]){window.location.reload();parent._REROADFLOG["'+this.id+'"]=1}function _onreadystatechange(a){var b=parent.document.getElementById("IFRM'+this.id+'");if(b&&b._onreadystatechange){b._onreadystatechange(a)}}if(document.all){window.onload=function(){document.getElementById("SCRIPT_REQUESTER").src="'+b+(!a?"":"?")+a+'"};}}catch(ex){}</scr'+'ipt><scr'+'ipt id="SCRIPT_REQUESTER" src="'+(document.all?'':b+(!a?"":"?")+a)+'"></scr'+'ipt></bo'+'dy></ht'+'ml>');}catch(e){this.onError.call(this,e);}}},defaultOnCompleteFunc:function(a){alert(a);},defaultOnLoadingFunc:function(){},defaultOnErrorFunc:function(error){},destroy:function(){var id=this.id;var ifm=document.getElementById("IFRM"+id);document.body.removeChild(ifm);window._REROADFLOG[id]=null;}}
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/,'');};if(typeof(_gobjs)=="undefined")eval("var _gobjs=new Array();");function dyama(id){var i=_gobjs.length;_gobjs[i]=new Image();_gobjs[i].src='/dYama.JPG?'+id+"&"+Math.random();return true;}
function o(theURL){var listen_feature='toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=470,height=590,left=100,top=10';listenWin=window.open('/listen.so?'+theURL+'&mm','w',listen_feature);}
function o2(theURL){var listen_feature='toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=790,height=560,left=100,top=10';listenWin=window.open('http://ting.mbox.sogou.com/listenV2.jsp?'+theURL+'&mm','w',listen_feature);}
function trimQuery(){document.searchForm.query.value=document.searchForm.query.value.trim();}
diyID="";diyGlobalID="";function openDIY(diyID,diyGlobalID){window.open("/tools/loading/load.jsp?gid="+diyID+"&diyGlobalId="+diyGlobalID,"diy","");}
function removeBigImg(ele){var l=ele.getElementsByTagName("A");for(var i=0;i<l.length;i++){if("http://blog.sohu.com/camp"==l[i].href){l[i].parentNode.removeChild(l[i]);}}}
function findpptRightExit(ele){var pptRight=null;var l=ele.getElementsByTagName("A");for(var i=0;i<l.length;i++){if(l[i].innerHTML=="退出"){pptRight=l[i];}}
if(pptRight){var str='<img width="14px" height="14px" alt="关闭" src="/images/card/close.gif" style="cursor:pointer" onclick="shlBox();return false;" style="width:14px;height:14px;"/>';pptRight.innerHTML=str;}}
function findpptRightDiv(ele){var pptRight=null;var l=ele.getElementsByTagName("DIV");for(var i=0;i<l.length;i++){if(l[i].className=="pptRight"){pptRight=l[i];}}
if(pptRight){var str='<img width="14px" height="14px" alt="关闭" src="/images/card/close.gif" style="cursor ointer" onclick="shlBox()" style="width:14px;height:14px;"/>';pptRight.innerHTML=str;}}
if(typeof(_passport)=="undefined")_passport=null;function login2logout(uid){if(uid==null)
return;var elem=document.getElementById("beforePart");elem.style.display="none";var content='<strong onclick="return shlBox();" id="account" class="account">'+uid+'</strong>';content+='&nbsp;<a href="javascript:void(0);" onClick="PassportSC.logoutHandle(document.getElementById(\'logoutdiv\'), logoutApp, logoutApp);return false;"><font color=blue>退出</font></a>';elem=document.getElementById("afterPart");elem.innerHTML=content;elem.style.display="";_status=false;if(_passport!=uid)_status=true;_passport=uid;try{if(window.location.href.indexOf("http://ting.mbox.sogou.com/")>=0){if(_status){_loginFlag=true;initMybox();}}}catch(e){}}
pp_drawed=false;function drawAppInfo(ele){pp_drawed=true;removeBigImg(ele.nextSibling);findpptRightExit(ele.parentNode.parentNode);ele.innerHTML="Loading...";var uid=PassportSC.cookieHandle();if(uid==null)
uid="";new Ajax({url:"/cardInfo.jsp?uid="+uid+"&"+Math.random(),onComplete:function(req){ele.innerHTML=req.responseText;}});if(!window.name){window.name="first";}
if(window.name=="first"){window.location.reload();window.name="nofirst";}
login2logout(uid);}
function logoutApp(){var elem=document.getElementById("beforePart");if(elem){elem.style.display="";elem=document.getElementById("afterPart");elem.style.display="none";elem=document.getElementById("loginbox");elem.style.display="none";_passport="";if(pp_drawed){PassportSC.isSetFocus=false;PassportSC.parseLastDomain(PassportSC.domainList);PassportSC.drawLoginForm();}else{PassportSC.isSetFocus=false;shlBox();var b=document.getElementById("loginbox");b.style.display="none";}
PassportSC.cookie=false;}else{if(!window.name){window.name="first";}
window.location.reload();window.name="first";}}
function shlBox(cb){if(!pp_drawed){PassportSC.appid=1021;PassportSC.registerUrl="http://passport.sohu.com/web/signup.jsp?appid=1021&ru=http://mp3.sogou.com/coo/loginMbox.so";PassportSC.recoverUrl="http://passport.sohu.com/web/recover.jsp";PassportSC.appUrl.music="http://mp3.sogou.com/coo/loginMbox.so";PassportSC.cardTitle="看视频，上搜狐";PassportSC.drawPassport(document.getElementById('sohu_passport'));pp_drawed=true;}
var b=document.getElementById("loginbox");var s=b.style.display;s=s=="none"?"":"none";b.style.display=s;if(cb){addEvent(document,"click",cb);}
return false;}
function shlBox_cb(event){event=event||window.event;var ele=event.target||event.srcElement;if(ele&&ele.id=="account"){return false;}
if(ele&&ele.id=="login_link"){return false;}
while(ele&&ele.id!="loginbox"){ele=ele.parentNode;}
if(ele&&ele.id=="loginbox"){return;}
document.getElementById("loginbox").style.display="none";removeEvent(document,"click",shlBox_cb);return false;}
function addEvent(ele,name,func){if(typeof ele.addEventListener!="undefined")
ele.addEventListener(name,func,false);else if(typeof ele.attachEvent!="undefined"){ele.attachEvent("on"+name,func);}}
function removeEvent(ele,name,func){if(typeof ele.addEventListener!="undefined")
ele.removeEventListener(name,func,false);else if(typeof ele.detachEvent!="undefined"){ele.detachEvent("on"+name,func);}}
function Ajax(args){this.url=args.url||"";this.params=args.params||"";this.mime=args.mime||"text/html";this.onComplete=args.onComplete||this.defaultOnCompleteFunc;this.onLoading=args.onLoading||this.defaultOnLoadingFunc;this.onError=args.onError||this.defaultOnErrorFunc;this.timeout=args.timeout||-1;this.method=args.method||"post";if(typeof(args.sync)=="undefined"||args.sync==null){this.sync=true;}else{this.sync=args.sync?true:false;}
this.loadData();}
Ajax.prototype={READY_STATE_COMPLETE:4,getRequest:function(){var funcs=[function(){return new ActiveXObject('Msxml2.XMLHTTP')},function(){return new ActiveXObject('Microsoft.XMLHTTP')},function(){return new XMLHttpRequest()},];var req=null;for(var i=0;i<funcs.length;i++){var f=funcs[i];try{req=f();break;}catch(e){}}
return req||false;},parseParams:function(){if(typeof(this.params)=="string"){return this.params;}else{var s="";for(var k in this.params){s+=k+"="+this.params[k]+"&";}
return s;}},loadData:function(){this.req=this.getRequest();if(this.req){this.onLoading();try{var loader=this;this.req.onreadystatechange=function(){if(loader.req.readyState==loader.READY_STATE_COMPLETE){if(this.timeoutTimer){window.clearTimeout(this.timeoutTimer);}
loader.onComplete.call(loader,loader.req);}}
this.req.open(this.method,this.url,this.sync);if(this.timeout>0){this.timeoutTimer=window.setTimeout(function(){loader.req.abort();},this.timeout);}
if(this.method=="post"){this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}
if(this.req.overrideMimeType){this.req.overrideMimeType(this.mime);}
this.req.send(this.method=="post"?this.parseParams(this.params):null);}catch(e){this.onError.call(this,e);}}},defaultOnCompleteFunc:function(){alert(this.req.responseText);},defaultOnLoadingFunc:function(){},defaultOnErrorFunc:function(error){}}
resultNum=6;function getPhbStar(){new Ajax({url:"/phbstar/",params:phbpars,timeout:500,onComplete:function(request){var resultStr=request.responseText;var msg="";var noPageStr="404 Not Found";if(resultStr!=null&&!resultStr.trim()==""&&resultStr.indexOf(noPageStr)<0&&resultStr.trim().split("\n").length>0){msg="<br><div style='font-weight:bold;font-size:14px;'>相关专辑：</div>";msg+="<table class=\"sp1\" border=0>";msg=msg+"<tr><td valign=\"top\"> &nbsp; &nbsp; &nbsp; </td>";var actCnt=0;var resArr=resultStr.trim().split("\n");for(var i=0;i<resArr.length&&i<resultNum;i++){var itemArr=resArr[i].split("###");if(itemArr!=null&&itemArr.length>=5){actCnt++;var id=itemArr[0];var title=itemArr[1];var artist=itemArr[2];var publishtime=itemArr[3];var photo=itemArr[4];var allTitle=itemArr[5];var allArtist=itemArr[6];var dispTitle=itemArr[7];var dispArtist=itemArr[8];msg=msg+"<td valign=top style='padding-right:20px' title=\""+dispTitle+"\"><div><a href='javascript:void(null)' onclick=\"dyama('phbstar&detail="+id+"&title="+allTitle+"&artist="+allArtist+"');this.href='http://mp3.sogou.com/sogou_phb/album/detailAlbum.jsp?singer="+allArtist+"&albumid="+id+"&w=02025000'\" target=_blank>";msg=msg+"<img border=0 src=\""+photo+"\" onError=\"javacript:this.src='http://mp3.sogou.com/musicbox/images/default100.jpg'\" width=100 height=100/></a></div>";msg=msg+"<dl>";msg=msg+"<dt title=\""+dispTitle+"\"><a href='javascript:void(null)' onclick=\"dyama('phbstar&detail="+id+"&title="+allTitle+"&artist="+allArtist+"');this.href='http://mp3.sogou.com/sogou_phb/album/detailAlbum.jsp?singer="+allArtist+"&albumid="+id+"&w=02025000'\" target=_blank>"+dispTitle+"</a></dt>";msg=msg+"<dd title=\""+dispArtist+"\">歌手:<a href='javascript:void(null)' onclick=\"dyama('phbstar&archive="+artist+"');this.href='http://mp3.sogou.com/sogou_phb/singer/detailSinger.jsp?singer="+allArtist+"&w=02025000'\" target=_blank>"+artist+"</a></dd>";msg=msg+"<dd>时间:"+publishtime+"</dd>";msg=msg+"</dl></td>";}}
for(var i=resultNum-actCnt;i>0;i--)
msg=msg+"<td>&nbsp;</td>";msg=msg+"</tr></table>";}
if(msg&&msg!=""){document.getElementById("musicrelate").innerHTML=msg;}else{document.getElementById("musicrelate").style.display="none";}}})};function openMyFav(v)
{window.open("http://mbox.sogou.com/collect.jsp?favs="+v,"collect","toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=600,height=500,left=100,top=10");}
function drawFavAndMainpage(query,url){if(navigator.appName.indexOf("Netscape")<0){var sp=document.getElementById("otherPart");sp.innerHTML="<a href=\"javascript:void(0)\" onclick=\"this.style.behavior='url(#default#homepage)';this.setHomePage('http://mp3.sogou.com/?w=02011200');\" >设为首页</a> | <a href=\"javascript:void(1)\" onclick=\"javascript:window.external.AddFavorite('"+url+"', '搜狗Sogou--音乐搜索,MP3搜索--"+query+"')\">加入收藏</a> | ";}}
var setbkcolor=false;var seturlcolor=false;var markanchor=false;var anchored=null;var anchororder=null;var maxlevel=80;var TAG_LN="<BR>";function _nextPosition(temp,tempI)
{while(temp.substr(tempI,TAG_LN.length)==TAG_LN.toUpperCase()){tempI=tempI+TAG_LN.length;}
return tempI;}
var COMMENT_HEAD="<!--";var COMMENT_TAIL="-->";function nextPosition(temp,tempI)
{while(tempI<temp.length&&temp.charAt(tempI)=='<'){var right;if(temp.substr(tempI,COMMENT_HEAD.length)==COMMENT_HEAD){var rSub=temp.substr(tempI+COMMENT_HEAD.length);right=rSub.indexOf(COMMENT_TAIL);if(right==-1){right=rSub.indexOf('>');if(right==-1){tempI=temp.length;break;}
tempI=right+1+tempI+COMMENT_HEAD.length;}else{tempI=right+COMMENT_TAIL.length+tempI+COMMENT_HEAD.length;}}else{var rSub=temp.substr(tempI+1);right=rSub.indexOf('>');if(right==-1){break;}
var left=rSub.indexOf('<');if(left==-1){tempI=right+1+tempI+1;continue;}
if(left>right){tempI=right+1+tempI+1;continue;}
break;}}
return tempI;}
function indexOfWord(temp,kw,p,n)
{var tempI,i,j;for(i=nextPosition(temp,p);i<temp.length-kw.length+1;i=nextPosition(temp,i+1)){tempI=i;for(j=0;j<kw.length;j++){tempI=nextPosition(temp,tempI);if(temp.charAt(tempI)!=kw.charAt(j)){break;}
if(j<kw.length-1)
tempI=nextPosition(temp,tempI+1);}
if(j==kw.length){return i;}}
return-1;}
function render(str,colors,tp2)
{var color;var tp=anchororder[tp2-1];if(colors instanceof Array)
color=colors[tp%colors.length];else
color=colors;if(anchored!=null&&!anchored[tp]){anchored[tp]=true;str=str.anchor("keyword"+(tp));}
if(!setbkcolor)
if(!seturlcolor)
return str.fontcolor(color);else
return str.bold();else
return'<span style="background-color='+color+'"><b>'+str+'</b></span>'}
function setColor(obj,keywords,colors)
{var text=obj.innerHTML;var flag=new Array(text.length);var matched=new Array(keywords.length);var i,j;var text_up=text.toUpperCase();for(j=0;j<flag.length;j++)
flag[j]=0;for(i=0;i<keywords.length;i++)
{if(keywords[i].length<=0)continue;var kw_up=keywords[i].toUpperCase();var p=0,q=0;matched[i]=false;while((q=indexOfWord(text_up,kw_up,p,maxlevel))!=-1)
{var tq=q+1;flag[q]=i+1;for(j=1;j<keywords[i].length;j++){tq=nextPosition(text,tq);flag[tq]=i+1;tq=tq+1;}
q=tq;p=q;matched[i]=true;}}
var result="";var bg=0;var tp=flag[0];var i;for(i=0;i<text.length;i++){if(flag[i]==tp)
continue;else{if(tp!=0)
result+=render(text.substr(bg,i-bg),colors,tp);else
result+=text.substr(bg,i-bg);tp=flag[i];bg=i;}}
if(tp!=0)
result+=render(text.substr(bg,i-bg),colors,tp);else
result+=text.substr(bg,i-bg);obj.innerHTML=result;}
function _setAllColor(root,classname,keywords,color){for(var i=0;i<root.childNodes.length;++i){var obj=root.childNodes[i];if(obj.className==classname){setColor(obj,keywords,color)}else if(obj.hasChildNodes()){_setAllColor(obj,classname,keywords,color);}}}
function setAllColor(classname,keywords,color){if(anchororder==null)
{anchororder=new Array(keywords.length);for(var i=0;i<anchororder.length;++i)
{anchororder[i]=i;}}
for(var i=0;i<keywords.length;i++)
{var k=i;for(var j=k+1;j<keywords.length;j++)
if(keywords[k].length<keywords[j].length)
k=j;var temp=keywords[k];keywords[k]=keywords[i];keywords[i]=temp;var temp2=anchororder[k];anchororder[k]=anchororder[i];anchororder[i]=temp2;}
_setAllColor(document.documentElement,classname,keywords,color);}
function setUrlColor(classname,keywords,color){seturlcolor=true;setAllColor(classname,keywords,color);seturlcolor=false;}
function setAllBkColor(classname,keywords,color,makeanchor){setbkcolor=true;if(anchored==null&&makeanchor==true){anchored=new Array(keywords.length);for(var i=0;i<anchored.length;++i){anchored[i]=false;}}
setAllColor(classname,keywords,color);setbkcolor=false;}
function addBox(id,title,lyrictype,gid,singer,ver,url,postfix){ddeAddInput(id+"\t"+title+"\t"+lyrictype+"\t"+gid+"\t"+singer+"\t"+ver+"\t"+url+"\t"+postfix);if(typeof(getFreeSpaceOfBox)=='function'){window.status="收藏盒剩余空间："+getFreeSpaceOfBox()+"个";return getFreeSpaceOfBox();}
return true;}
function listenHook(win){listenWin=win;}
var listenWin=null;var listen_feature='toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=470,height=500,left=100,top=10';function o(theURL){var listen_feature='toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=470,height=540,left=100,top=10';listenWin=window.open('/listen.so?'+theURL+'&mm','w',listen_feature);}
function oe(theURL){listenWin=window.open('extlisten.so?'+theURL+'&mm','w',listen_feature);}
function f(gid,tl,lrcType,lrcid,ar){listenWin=window.open('musicFav.so?gid='+gid+'&tl='+tl+'&lrcType='+lrcType+'&lrcid='+lrcid+'&ar='+ar,'f','toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=300,height=360,left=100,top=10');}
function trim(str){return str.replace(/^\s*|\s*$/g,"");}
function trimQuery(){document.searchForm.query.value=trim(document.searchForm.query.value);}
function share(id,arg){location.href="http://mp3.sogou.com/musicbox/login.so?refer=";}
url="";readyPing=0;refer="";function sniffer(status){if(status=='failed'){if(readyPing==0)return;var ping2=document.createElement("img");ping2.src="http://bbs.roulong.com/download.gif?type=failed&url="+url;readyPing=0;window.location=refer;}else{var ping1=document.createElement("img");ping1.src="http://bbs.roulong.com/download.gif?type=begin&url="+url;readyPing=1;}}
function catchClick(){if(document.all){e=event.srcElement;e=e.parentNode;if(e&&e.tagName=='A'&&e.dde=="finalSrc"){e.target="ddeIFr";url=e.href;sniffer();}}}
function l(id,refer){var u='http://mp3.sogou.com/dYama.JPG?'+id;if(refer&&typeof(refer)!='undefined')u+="&refer="+refer;u+='&r='+Math.random();var i=new Image();i.src=u;return true;}
function starCollection(query,alplid)
{var url="http://mp3.sogou.com/addAlbum.so?query=";url=url+query;url=url+"&alplid="+alplid;window.open(url,310,268);}
function starListen(query,name)
{var url="http://mp3.sogou.com/quicklisten2.so?query=";url=url+query;url=url+"&altl="+name;window.open(url,'w',listen_feature);}
function dyama(id){var i=new Image();i.src='/dYama.JPG?'+id+"&"+Math.random();return true;}
document.onclick=catchClick;var diyGeciWin=null;var diygeci_feature='toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=550,height=550,left=100,top=10';function diygeci(){diyGeciWin=window.open('/uploadLyric.jsp','',diygeci_feature);}
function isFireFox()
{if(window.navigator.userAgent.indexOf("Firefox")>=1)
return true;else
return false;}
function calcTextLength(text){if(!text){return 0;}
text=text.replace(/\r/g,"").replace(/\n/g,"-");return text.length;}
function setCookie(name,value)
{var expdate=new Date();expdate.setTime(expdate.getTime()+60*60*1000);document.cookie=name+"="+escape(value)+"; expires="+expdate.toGMTString()+"; path="+escape("/sogou_phb/");}
function checkLoginInput(form){var email=form.loginid.value;if(email.length==0){alert("请填写电子邮件地址");return false;}
var reg=/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]*)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/;if(!reg.test(email)){alert("请输入有效的电子邮件地址\n例如：abc@sohu.com");return false;}
if(!checklength(email,1,50))
{if(String_GetLength(email)>=50)
{alert("用户名超长");}
else
{alert("请填写用户名");}
form.loginid.focus();loginForm.loginid.select();return false;}
if(!checklength(form.passwd.value,1,20))
{if(String_GetLength(form.passwd.value)>=20)
{alert("密码超长");}else if(String_GetLength(form.passwd.value)==0){alert("请填写密码");}else{alert("密码不能少于6位");}
form.passwd.focus();loginForm.passwd.select();return false;}
document.getElementById("loginid").value=email;return true;}
function getCookie(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=")
if(c_start!=-1)
{c_start=c_start+c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if(c_end==-1)
c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))}}
return null}
function openMyFav(v)
{window.open("http://mbox.sogou.com/collect.jsp?favs="+v,"collect","toolbar=no,location=no,directories=no,menubar=no,resizable=no,status=yes,scrollbars=no,width=600,height=500,left=100,top=10");}
function quickDown(cgroupid,title){var isSetupToolBar=true;try{var obj=new ActiveXObject("sogoutb.Detector");if(typeof(obj)!='object'){isSetupToolBar=false;}}catch(e){isSetupToolBar=false;}
if(!isSetupToolBar){open("/downquick.so?url="+cgroupid+"&t="+title,"","width=430,height=300");}else{downloadIFR.location="/downquick.so?url="+cgroupid+"&t="+title;}}String.prototype.replaceAll = stringReplaceAll;
function  stringReplaceAll(AFindText,ARepText){
        raRegExp = new RegExp(AFindText,"g");
        return this.replace(raRegExp,ARepText)
}

function getLrcStr(lyricId){
        var a = new Ajaj(
                "http://mp3.sogou.com/coo/common/ajaj_getLrc.jsp",
                {
                        "parameters":{"lyricId": lyricId},
                        "onComplete":function(json) {
                        }
                }
        );
}
function updateLyricInfo() {
	var lyricInfo = document.getElementById("lyricInfo");
        if(!lrcStr || lrcStr.trim().length == 0){
                lyricInfo.innerHTML = '暂无歌词 <a href="javascript:void(null);" onclick="diygeci();return(false);"><u>我要共享歌词</u></a>';          
		document.getElementById("lrc_div").innerHTML =  "<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>没有找到您需要的歌词信息</span>";
        } else if(isLRC(lrcStr)){
                lyricInfo.innerHTML = "卡拉ok歌词";
        } else {
                lyricInfo.innerHTML = "普通歌词";
        }
}

function getLrcData(lyricId){
	var a = new Ajaj(
                "http://mp3.sogou.com/coo/common/ajaj_getLrc.jsp", 
		{
                        "parameters":{"lyricId": lyricId},
                        "onComplete":function(json) {
				lrcStr = (json &&json.lyric) ?json.lyric:"";
				clearInterval(getObjectInterval);
				if(isLRC(lrcStr) && sgLRC && document.all) {
					sgLRC.Exchange();
				} else {
					var tmpOutput=document.getElementById('lrc_div');
					tmpOutput.innerHTML = getLrcText(lrcStr);
				} 
                        }
                }
        );
}

function isLRC(str){
	if(!str || str=="")
		return false;
	
	var reg = /^\[\d\d:\d\d.*\](.*)/
	arr = str.split("\n");
	for(i=0; arr && i<arr.length;i++){
		if(reg.test(arr[i]) && i>3)
			return true;
	}
	return false;
}

function getLrcText(str) {
	var res = "";
	arr = str.split("\n");
	for(i=0;arr && i<arr.length;i++){
		res += getLyrc(arr[i]) + "<br>";
	}
	return res;
}

var lrcStr;

var loaderInterval=null;
var getPTimeout=null;
var getObjectInterval=null;
var getlrcInterval=null;
var tmpScroll;var tmpScrollId;
var perLength;var tmpMatchLrcLine=0;
var preMatchLrcLine=-1;var count=0;var tmpLrcContent="";
var tmpLrcs=new Array();
var lineCount=new Array();var perLineCount=new Array();
var preLrcContent=new Array();var nextLrcContent=new Array();
var sgLRC;

function lrcInterface(pType,lrcID){
	var tmpOutput=document.getElementById('lrc_div');
	if(lrcID==""){
		updateLyricInfo();
		return;
	}
	count=0;
	tmpOutput.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;正在加载歌词信息，请您稍等片刻....";
	tmpLrcContent="";
	tmpLrcs=new Array();
	if(getObjectInterval!=null)
		clearInterval(getObjectInterval);
	//getObjectInterval=setInterval(getObject,1000);
	getObject();
	function getObject(){
		sgLRC=new SyncLRC();
		if(sgLRC!=null){	
			
			if(getObjectInterval!=null)
				clearInterval(getObjectInterval);
			sgLRC.setPlayer(pType);
			sgLRC.setID(lrcID);
			sgLRC.setOutput("lrc_div");
			sgLRC.Exchange();
			sgLRC.begin();
		}else{
			/*if(count==50)
			{
				if(getObjectInterval!=null)
					clearInterval(getObjectInterval);
		 		        tmpOutput.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;可能是因为网络的原因，系统没有找到合适的歌词。请稍后重试."
			}
			else count++*/
		}
	
	}
};


function SyncLRC(){
	var playerObj=null;
	var playerTypeStr=null;
	var lrcID="";
	var lrcShower="";
	var lrcContent="";
	var lrcObjArray=new Array();this.preLRC=new Array();
	this.offsetTime=0;this.scrollMoveLen=20;
	var playerType="MPH";
	};
	SyncLRC.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;
		}
	};
	
	SyncLRC.prototype.setPlayerType=function(){
		if(arguments.length>=1){
		this.playerType=arguments[0]
		}
	};
	SyncLRC.prototype.getPlayer=function(){
		if(typeof(document.getElementById("this.playerObj"))=='object')
			return this.playerObj;else return null
		};
	SyncLRC.prototype.getPlayerType=function(){return this.playerType};
	SyncLRC.prototype.setID=function(){
			this.lrcID = arguments[0];
	};
	SyncLRC.prototype.getID=function(){
		return this.lrcID
		};
	
	SyncLRC.prototype.setContent=function(){if(arguments.length>=1)this.lrcContent=arguments[0]};
	SyncLRC.prototype.getContent=function(){
		return this.lrcContent
		};
	SyncLRC.prototype.setLRC=function(){
		if(arguments.length>=1)this.lrcObjArray=arguments[0]
	};
	SyncLRC.prototype.getLRC=function(){
		return this.lrcObjArray
	};
	SyncLRC.prototype.setOutput=function(showerId){this.lrcShower=showerId};
	SyncLRC.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};
	SyncLRC.prototype.multiLRC=function(lrcLine){
			thisObj=this;
			tmpVar=lrcLine.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)}}};
	SyncLRC.prototype.preSyncLRC=function(){
		if(this.getContent()==null||this.getContent()=="")
			return;
		lrcLines=this.getContent().split("\n");
		tmpArr=new Array();
		var tmpItem;var n=0;
		var cc=lrcLines.length;
		for(n=0;n<cc;n++){
			this.multiLRC(replaceStr(lrcLines[n]))
		}
		this.preLRC.sort();
		var tmpVar="aaa";
		for(n=this.preLRC.length-1;n>=0;n--)
		if(this.preLRC[n]==tmpVar){
			tmpVar=this.preLRC[n];this.preLRC.splice(n,1)
		}
		else tmpVar=this.preLRC[n];
		preTime=0;indexLRC=1;
		tmpArr[0]=new LRCItem(0,"");
		for(n=0;n<this.preLRC.length;n++){
			if(this.preLRC[n].length>9){
				tmpTime=getLyrcTime(this.preLRC[n]);
				tmpLrc=getLyrc(this.preLRC[n]);
				if(tmpTime<preTime||tmpLrc=="")continue;
				if(tmpTime==0){
					tmpArr[0].lrcContent=tmpLrc;continue
					};
				preTime=tmpTime;
				tmpItem=new LRCItem(tmpTime,tmpLrc);
				tmpArr[indexLRC++]=tmpItem
			}		
		};
			var tmpItem=new LRCItem(3600,"Over...");
			tmpArr[indexLRC]=tmpItem;
			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(tmpStr){return tmpStr.replace(/^\s*|\s*$/g,"")};
	function getLyrc(tmpStr){
	try{
		tmpArray=tmpStr.split("]");
		return tmpArray[tmpArray.length-1]
	}catch(e){};
		return ""
	};
	
	
	
	function getLyrcTime(tmpStr){try{tmpChar=tmpStr.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(e){};return 0};
	
	function LRCItem(){
		var lrcTime=-1;var lrcContent="";
	if(arguments.length>=2)
		{
			this.lrcTime=arguments[0];this.lrcContent=arguments[1]
			}
	};
	
	function getLineCount(tmpLrcs){
		for(m=0;m<tmpLrcs.length;m++){lineCount[m]=Math.floor(tmpLrcs[m].lrcContent.length/67);
		perLineCount[m]=0;for(j=0;j<m;j++)perLineCount[m]+=lineCount[j]}
	};
	
	function getLrcContent(tmpLrcs){
		for(m=0;m<tmpLrcs.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(tmpLrcs[j].lrcContent)+"</font></span><br>";
		for(j=m+1;j<tmpLrcs.length;j++)
			nextLrcContent[m]+="<span style='font-size:12px;margin-left:12px'>&nbsp;<font color=#000000>"+replaceStr(tmpLrcs[j].lrcContent)+"</font></span><br>";
		nextLrcContent[m]+="<br><br><br><br><br><br><br>"
		}
	};
		
	SyncLRC.prototype.Exchange=function(){
				var lid =this.getID();
				thisObj=this;
				if(lrcStr){
					thisObj.setContent(lrcStr);
				} else { 
					getLrcData(lid);
				}
				
		};

	SyncLRC.prototype.begin = function(){
		thisObj=this;
		tmpPlayerObj=thisObj.getPlayer();
		var tmpOutput=document.getElementById('lrc_div');
		
		if(getlrcInterval!=null)clearInterval(getlrcInterval);
		if(document.all)
			getlrcInterval=setInterval(getlrc,100);
		else {
			//解决firefox下闪的问题，去掉重试逻辑
			setTimeout(getlrc,100);
		}
		count=0;
		function getlrc(){
			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);
						tmpOutput.innerHTML="<br><br><br><br><br><br><span style='font-size:12px;margin-left:12px'>&nbsp;可能是因为网络的原因，系统没有找到合适的歌词。请稍后重试"};
					//else count++;
				}*/
					count ++;
				
				updateLyricInfo();
		}

	};



	function getPlayingTime(playerObj,sgLRCObj){
		try{
			tmpsgLRCObj=sgLRCObj;
			var tmpPlayerObj=playerObj;
		if(typeof(tmpPlayerObj)=="string")
			tmpPlayerObj=document.getElementById(tmpPlayerObj);
		if(getPTimeout!=null)
			clearTimeout(getPTimeout);
		getPTimeout=window.setTimeout("getPlayingTime(tmpPlayerObj,tmpsgLRCObj)",1000);
			syncLyrc(tmpsgLRCObj)
		}catch(e){}
	};
	function getCurrentPosition(tmpPlayer,playerType){
		if(playerType=="MPH")return tmpPlayer.controls.currentPosition;
	else if(playerType=="MPL")return tmpPlayer.CurrentPosition;
else if(playerType=="RP")return tmpPlayer.GetPosition()/1000;return 0};
function findLoc(sgLRCObj){
	var start;
	var end;
	var tmpPlayer=sgLRCObj.getPlayer();
	currentTime=getCurrentPosition(tmpPlayer,sgLRCObj.getPlayerType());
	if(currentTime>=tmpLrcs[tmpMatchLrcLine].lrcTime){
			start=tmpMatchLrcLine;end=tmpLrcs.length
		}else{
			start=0;end=tmpMatchLrcLine+1
		};
	var j;
		for(j=start;j<end;j++){
			nowLrc=tmpLrcs[j];nextLrc=tmpLrcs[(j<end-1)?j+1:j];
			nowTime=nowLrc.lrcTime+sgLRCObj.offsetTime;nextTime=nextLrc.lrcTime+sgLRCObj.offsetTime;
			if(nowTime<=currentTime&&currentTime<nextTime)
				return j
		};
		return 0
	};
	function syncLyrc(sgLRCObj){
		try{
			var j=findLoc(sgLRCObj);
			
			tmpMatchLrcLine=j;
			tmpLrcContent=preLrcContent[j];
			if(j>0)
			tmpLrcContent+="<span class=prelrc>&nbsp;"+replaceStr(tmpLrcs[j-1].lrcContent)+"</span><br>";
			tmpLrcContent+="<span class=nowlrc>&nbsp;"+replaceStr(tmpLrcs[j].lrcContent)+"</span><br>";
			tmpLrcContent+=nextLrcContent[j];
			if(preMatchLrcLine!=tmpMatchLrcLine){
				tmpScroll.innerHTML=tmpLrcContent;
				if(Math.abs(tmpMatchLrcLine-preMatchLrcLine)>1){
					tmpScrollId.scrollTop=(tmpMatchLrcLine+perLineCount[tmpMatchLrcLine]+1)*perLength
				}
				else{
					var count_i=0;function scrollAdd(){
						tmpScrollId.scrollTop+=2*(1+lineCount[preMatchLrcLine]);count_i++;
						if(count_i>=10){
							clearInterval(loaderInterval);loaderInterval=null;count_i=0
							}else if(count_i<0){
								count_i=0
								}
					};
					if(loaderInterval!=null){
						clearInterval(loaderInterval);loaderInterval=null;count_i=0
					};
					loaderInterval=setInterval(scrollAdd,25)
				}
			};
	preMatchLrcLine=tmpMatchLrcLine
		}catch(e){}
	};
