var $=function(strId){if(!strId){return null}
if(document.getElementById){return eval('document.getElementById("'+strId+'")')}else if(document.layers){return eval("document.layers['"+strId+"']")}else{return eval('document.all.'+strId)}},GetOffsetPos=function(i){var l=0,I=0;do{l+=i.offsetTop||0;I+=i.offsetLeft||0;i=i.offsetParent} while(i);return{x:I,y:l}},UCLivePlayer={};UCLivePlayer.Create=function(i){this.args=i};UCLivePlayer.Create.prototype={Init:function(args){args=this.args;var me=this;this.skinsPath=args.skinsPath.substr((args.skinsPath.length-1),1)=="/"?args.skinsPath:args.skinsPath+"/";this.statusBar={height:20};if(args.defaultVolume){args.defaultVolume=parseInt(args.defaultVolume,10)}else{args.defaultVolume=5}
this.host={node:$(args.hostId)};this.resizeFrame={node:$(args.resizeFrameId)};this.activeXHost={node:$(args.activeXHostId)};this.video={width:parseInt(args.videoWidth,10),height:parseInt(args.videoHeight,10)+this.statusBar.height,minWidth:parseInt(args.minVideoWidth,10),minHeight:parseInt(args.minVideoHeight,10)+this.statusBar.height,maxWidth:parseInt(args.maxVideoWidth,10),maxHeight:parseInt(args.maxVideoHeight,10)+this.statusBar.height,limitScale:eval(args.limitScale),curPlayURL:"",curPlayTitle:""};this.video.scale=this.video.width/this.video.height;this.video.curWidth=this.video.width;this.video.curHeight=this.video.height;this.installTip={node:$(args.installTipId),src:args.installTipPath};this.extend={node:$(args.extendId),src:args.extendPath};this.controlBar={node:$(args.controlBarId)};this.controlBar.height=this.controlBar.node.offsetHeight;this.controlBar.backgoundImage=this.skinsPath+"control_bg.gif";this.playBtn={node:$(args.playBtnId),src:{disable:this.skinsPath+"play_disable.gif",down:this.skinsPath+"play_down.gif",over:this.skinsPath+"play_over.gif",out:this.skinsPath+"play_out.gif"},title:{disable:"",able:"播放"},cursor:{disable:"default",able:"pointer"}};this.pauseBtn={src:{disable:this.skinsPath+"pause_disable.gif",down:this.skinsPath+"pause_down.gif",over:this.skinsPath+"pause_over.gif",out:this.skinsPath+"pause_out.gif"},title:{disable:"",able:"暂停"},cursor:{disable:"default",able:"pointer"}};this.stopBtn={node:$(args.stopBtnId),src:{disable:this.skinsPath+"stop_disable.gif",down:this.skinsPath+"stop_down.gif",over:this.skinsPath+"stop_over.gif",out:this.skinsPath+"stop_out.gif"},title:{disable:"",able:"停止"},cursor:{disable:"default",able:"pointer"}};this.muteBtn={node:$(args.muteBtnId),src:{disable:this.skinsPath+"mute_disable.gif",down:this.skinsPath+"mute_down.gif",over:this.skinsPath+"mute_over.gif",out:this.skinsPath+"mute_out.gif"},title:{disable:"",able:"声音"},cursor:{disable:"default",able:"pointer"}};this.mutenoBtn={src:{disable:this.skinsPath+"muteno_disable.gif",down:this.skinsPath+"muteno_down.gif",over:this.skinsPath+"muteno_over.gif",out:this.skinsPath+"muteno_out.gif"},title:{disable:"",able:"静音"},cursor:{disable:"default",able:"pointer"}};this.vBox={node:$(args.vBoxId),src:{disable:this.skinsPath+"vbox_disable.gif",down:this.skinsPath+"vbox_down.gif",over:this.skinsPath+"vbox_over.gif",out:this.skinsPath+"vbox_out.gif"},title:{disable:"",able:"音量"},cursor:{disable:"default",able:"pointer"},defaultVolume:args.defaultVolume*10};this.vBox.width=this.vBox.node.offsetWidth;this.vBox.height=this.vBox.node.offsetHeight;this.vZone={node:$(args.vZoneId),backgroundImage:this.skinsPath+"control_bg.gif",title:{able:"音量",disable:""}};this.vZone.width=this.vZone.node.offsetWidth;this.vZone.height=this.vZone.node.offsetHeight;this.vZone.slipWidth=this.vZone.width-this.vBox.width;this.vBoxTip={node:document.createElement("div"),height:12};this.vBoxTip.node.style.height=this.vBoxTip.height+"px";this.vBoxTip.node.style.padding="0px 2px";this.vBoxTip.node.style.backgroundColor="#ffffe1";this.vBoxTip.node.style.color="#000000";this.vBoxTip.node.style.border="1px solid #000000";this.vBoxTip.node.style.position="absolute";this.vBoxTip.node.style.pixelTop=this.vBox.node.style.pixelTop;this.UpdateVBoxTip(this.vBox.defaultVolume.toString(10),this.vBox.node.style.pixelTop+this.vBox.width,"none");this.vZone.node.appendChild(this.vBoxTip.node);this.standardScreenBtn={node:$(args.standardScreenBtnId),src:{disable:this.skinsPath+"standardscreen_disable.gif",down:this.skinsPath+"standardscreen_down.gif",over:this.skinsPath+"standardscreen_over.gif",out:this.skinsPath+"standardscreen_out.gif"},title:{disable:"",able:"标准大小"},cursor:{disable:"default",able:"pointer"}}
this.fullScreenBtn={node:$(args.fullScreenBtnId),src:{disable:this.skinsPath+"fullscreen_disable.gif",down:this.skinsPath+"fullscreen_down.gif",over:this.skinsPath+"fullscreen_over.gif",out:this.skinsPath+"fullscreen_out.gif"},title:{disable:"",able:"全屏"},cursor:{disable:"default",able:"pointer"}};this.tipBar={node:$(args.tipBarId)};this.tipBar.height=this.tipBar.node.offsetHeight;this.resizeBtn={node:$(args.resizeBtnId),src:{disable:this.skinsPath+"resize_disable.gif",down:this.skinsPath+"resize_down.gif",over:this.skinsPath+"resize_over.gif",out:this.skinsPath+"resize_out.gif"},title:{disable:"",able:"更改大小"},cursor:{disable:"default",able:"nw-resize"}};this.InitPlayerSize(this.video.width,this.video.height);this.ulObject=document.createElement("object");this.ulObject.id="ulObject";this.ulObject.classid="clsid:070CA17A-4BD2-4612-83B4-32B1B9159B47";this.ulObject.width=args.videoWidth?args.videoWidth:"400";this.ulObject.height=((args.videoHeight?parseInt(args.videoHeight,10):300)+this.statusBar.height).toString(10);this.ulObject.codebase="http://uc.sina.com.cn/download/live/weblive2.4.0.0.cab#version=2,8,6,6";this.ulObject.standby="Loading UC Live Player components...";this.activeXHost.node.appendChild(this.ulObject);if(!this.DetectActiveX()){this.HandlerPlayStateChange(-1);return false}else{this.HandlerPlayStateChange(1)}
this.SetVolume(this.vBox.defaultVolume);this.playBtn.node.onmouseover=function(){this.src=this.src.replace(/_out\./,"_over.")};this.playBtn.node.onmouseout=function(){this.src=this.src.replace(/_over\./,"_out.")};this.playBtn.node.onmousedown=function(){};this.stopBtn.node.onmouseover=function(){this.src=this.src.replace(/_out\./,"_over.")};this.stopBtn.node.onmouseout=function(){this.src=this.src.replace(/_over\./,"_out.")};this.stopBtn.node.onmousedown=function(){};this.muteBtn.node.src=this.mutenoBtn.src.out;this.muteBtn.node.title=this.mutenoBtn.title.able;this.muteBtn.node.style.cursor=this.mutenoBtn.cursor.able;this.muteBtn.node.onmouseover=function(){this.src=this.src.replace(/_out\./,"_over.")};this.muteBtn.node.onmouseout=function(){this.src=this.src.replace(/_over\./,"_out.")};this.muteBtn.node.onclick=function(){var nowMute=me.GetMute.call(me);if(nowMute===0){me.SetMute.call(me,true)}else if(nowMute===-1){me.SetMute.call(me,false)}};this.standardScreenBtn.node.onmouseover=function(){this.src=this.src.replace(/_out\./,"_over.")};this.standardScreenBtn.node.onmouseout=function(){this.src=this.src.replace(/_over\./,"_out.")};this.fullScreenBtn.node.onmouseover=function(){this.src=this.src.replace(/_out\./,"_over.")};this.fullScreenBtn.node.onmouseout=function(){this.src=this.src.replace(/_over\./,"_out.")};this.vZone.node.title=this.vZone.title.able;this.vZone.node.onmousedown=function(){if(event.srcElement!==this){return false}
if(event.offsetX<(me.vBox.width/2)){me.vBox.node.style.left="0px"}else if(event.offsetX>(me.vZone.width-me.vBox.width)){me.vBox.node.style.left=me.vZone.width-me.vBox.width+"px"}else{me.vBox.node.style.left=event.offsetX-(me.vBox.width/2)+"px"}
var nValue=Math.floor(me.vBox.node.style.pixelLeft*100/(me.vZone.width-me.vBox.width));me.SetVolume.call(me,nValue);me.UpdateVBoxTip.call(me,nValue.toString(10),me.vBox.node.style.pixelLeft+me.vBox.width,"")};this.vBox.node.style.backgroundImage="url("+this.vBox.src.out+")";this.vBox.node.title=this.vBox.title.able;this.vBox.node.style.cursor=this.vBox.cursor.able;this.vBox.node.onmouseover=function(){this.style.backgroundImage=this.style.backgroundImage.replace(/_out\./,"_over.")};this.vBox.node.onmouseout=function(){this.style.backgroundImage=this.style.backgroundImage.replace(/_over\./,"_out.");this.title=me.vBox.title.able};this.vBox.node.onmousedown=function(){if(event.srcElement!==this){return false}
var nValue=0;me.vBox.node.setCapture();var startLeft=me.vBox.node.style.pixelLeft,startClientX=event.clientX,clientOffsetX=0;me.UpdateVBoxTip.call(me,me.vBox.defaultVolume.toString(10),me.vBox.node.style.pixelLeft+me.vBox.width,"");document.onmousemove=function(){clientOffsetX=event.clientX-startClientX;var newLeft=startLeft+clientOffsetX;if(newLeft<=0){newLeft=0}else if(newLeft>me.vZone.slipWidth){newLeft=me.vZone.slipWidth}
me.vBox.node.style.pixelLeft=newLeft;var curVolumeValue=me.vBox.node.style.pixelLeft*100/me.vZone.slipWidth;curVolumeValue=Math.floor(curVolumeValue);me.SetVolume.call(me,curVolumeValue);me.UpdateVBoxTip.call(me,curVolumeValue.toString(10),newLeft+me.vBox.width)};document.onmouseup=function(){me.vBox.node.releaseCapture();if(me.vBoxTip.node.style.display!="none"){me.vBoxTip.node.style.display="none"}
document.onmousemove=null;document.onmouseup=null}};this.resizeBtn.node.style.backgroundImage="url("+this.resizeBtn.src.out+")";this.resizeBtn.node.title=this.resizeBtn.title.able;this.resizeBtn.node.style.cursor=this.resizeBtn.cursor.able;this.resizeBtn.node.onmousedown=function(){me.resizeBtn.node.setCapture();me.resizeFrame.node.style.width=me.video.curWidth+1+"px";me.resizeFrame.node.style.height=me.video.curHeight+me.controlBar.height+me.tipBar.height+1+"px";me.resizeFrame.node.style.display="";var nowClientX=event.clientX,nowClientY=event.clientY,offsetClientX=0,offsetClientY=0,curWidth=0,curHeight=0;document.onmousemove=function(){offsetClientX=event.clientX-nowClientX;offsetClientY=event.clientY-nowClientY;curWidth=me.video.curWidth+offsetClientX;curHeight=me.video.curHeight+offsetClientY;if(curWidth<me.video.minWidth){curWidth=me.video.minWidth}
if(curHeight<me.video.minHeight){curHeight=me.video.minHeight}
if(curWidth>me.video.maxWidth){curWidth=me.video.maxWidth}
if(curHeight>me.video.maxHeight){curHeight=me.video.maxHeight}
if(me.video.limitScale===true){if(curWidth/curHeight>me.video.scale){curWidth=Math.floor(me.video.scale*curHeight)}
if(curWidth/curHeight<me.video.scale){curHeight=Math.floor(curWidth/me.video.scale)}}
me.resizeFrame.node.style.width=curWidth+1+"px";me.resizeFrame.node.style.height=curHeight+me.controlBar.height+me.tipBar.height+1+"px"};document.onmouseup=function(){me.resizeFrame.node.style.display="none";me.resizeBtn.node.releaseCapture();me.video.curWidth=curWidth;me.video.curHeight=curHeight;me.UpdatePlayerSize.call(me,me.video.curWidth,me.video.curHeight);document.onmousemove=null;document.onkeydown=null;document.onmouseup=null}}},DetectActiveX:function(i){if(typeof i==="undefined"){i="ULIVECTRL.ULiveCtrlCtrl.1"}
try{var I=new ActiveXObject(i)}catch(e){return false}
return true},IsInstallUClive:function(){try{var i=new ActiveXObject("ULIVECTRL.ULiveCtrlCtrl.1");var I=i.Play;if(I===true){return true}else{return false}}catch(e){return false}
return false},ShowTheBlock:function(i){var I=this;I.installTip.node.style.display="none";I.activeXHost.node.style.display="none";I.extend.node.style.display="none";i.style.display=""},UpdateVBoxTip:function(I,i,l){var o=this;o.vBoxTip.node.innerHTML=I+"%";o.vBoxTip.node.style.pixelLeft=i+10;if(typeof l!="undefined"){o.vBoxTip.node.style.display=l}},InitPlayerSize:function(i,I){var l=this;l.host.node.style.width=i+"px";l.activeXHost.node.style.width=i+"px";l.installTip.node.style.width=i+"px";l.installTip.node.style.height=I+"px";l.installTip.node.src=l.installTip.src+"?w="+i+"&h="+I;l.extend.node.style.width=i+"px";l.extend.node.style.height=I+"px";l.extend.node.src=l.extend.src+"?w="+i+"&h="+I},UpdatePlayerSize:function(i,I){var o=this,l=o;o.host.node.style.width=i+"px";o.activeXHost.node.style.width=i+"px";o.ulObject.width=i+"px";o.ulObject.height=I+"px";o.installTip.node.style.width=i+"px";o.installTip.node.style.height=I+"px";o.installTip.node.src=o.installTip.src+"?w="+i+"&h="+I;o.extend.node.style.width=i+"px";o.extend.node.style.height=I+"px";o.extend.node.src=o.extend.src+"?w="+i+"&h="+I;o.video.curWidth=i;o.video.curHeight=I;if(o.video.width!=o.video.curWidth||o.video.height!=o.video.curHeight){o.standardScreenBtn.node.title=o.standardScreenBtn.title.able;o.standardScreenBtn.node.src=o.standardScreenBtn.src.out;o.standardScreenBtn.node.style.cursor=o.standardScreenBtn.cursor.able;o.standardScreenBtn.node.onclick=function(){l.RevertPlayerSize.call(l)};if(o.ResizeHook){o.ResizeHook()}}else{o.standardScreenBtn.node.title=o.standardScreenBtn.title.disable;o.standardScreenBtn.node.src=o.standardScreenBtn.src.disable;o.standardScreenBtn.node.style.cursor=o.standardScreenBtn.cursor.disable;o.standardScreenBtn.node.onclick=null;if(o.RevertSizeHook){o.RevertSizeHook()}}},RevertPlayerSize:function(){var i=this;i.standardScreenBtn.node.title=i.standardScreenBtn.title.disable;i.standardScreenBtn.node.src=i.standardScreenBtn.src.disable;i.standardScreenBtn.node.style.cursor=i.standardScreenBtn.cursor.disable;i.standardScreenBtn.node.onclick=null;i.UpdatePlayerSize(i.video.width,i.video.height);if(i.RevertSizeHook){i.RevertSizeHook()}},InitPlayer:function(){},Destroy:function(){this.ulObject.Destroy()},SetPlayURL:function(I,i){var l=this;if(l.DetectActiveX()){l.video.curPlayURL=I;if(typeof i!="undefined"){l.video.curPlayTitle=i}}},Play:function(){var i=this;if(i.DetectActiveX()){if(i.video.curPlayURL==""){throw new Error("play fun error")}
i.HandlerPlayStateChange(3);return i.ulObject.SetPlayURL(i.video.curPlayURL,i.video.curPlayTitle)}},Stop:function(){var i=this;i.HandlerPlayStateChange(1);return i.ulObject.Stop()},Pause:function(){var i=this;i.HandlerPlayStateChange(2);return i.ulObject.Pause()},GetVolume:function(){return this.ulObject.GetVolume()},SetVolume:function(i){var I=this;if(i<0){i=0}
if(i>100){i=100}
I.ulObject.SetVolume(i);if(i<=0){I.SetMute(true)}else{I.SetMute(false)}
I.vBox.node.style.left=(I.vZone.width-I.vBox.width)*i/100+"px"},SetMute:function(i){var I=this;I.ulObject.SetMute(i);if(I.GetMute()===0){I.muteBtn.node.src=I.mutenoBtn.src.out;I.muteBtn.node.title=I.mutenoBtn.title.able;I.muteBtn.node.style.cursor=I.mutenoBtn.cursor.able}else if(I.GetMute()===-1){I.muteBtn.node.src=I.muteBtn.src.out;I.muteBtn.node.title=I.muteBtn.title.able;I.muteBtn.node.style.cursor=I.muteBtn.cursor.able}},GetMute:function(){return this.ulObject.GetMute()},GetFullScreen:function(){return this.ulObject.GetFullScreen()},SetFullScreen:function(i){this.ulObject.SetFullScreen(i)},GetDuration:function(){return this.ulObject.GetDuration()},GetCurrentPostion:function(){return this.ulObject.GetCurrentPostion()},SetCurrentPostion:function(i){this.ulObject.SetCurrentPostion(i)},GetPlayState:function(){return this.ulObject.GetPlayState()},ResetUI:function(){this.ulObject.ResetUI()},GetBufferingProgress:function(){return this.ulObject.GetBufferingProgress()},HandlerPlayStateChange:function(i){var l=this,I=l;switch(i){case(-1):l.ShowTheBlock(l.installTip.node);break;case 1:case 8:case 12:l.ShowTheBlock(l.extend.node);l.playBtn.node.src=l.playBtn.src.out;l.playBtn.node.title=l.playBtn.title.able;l.playBtn.node.style.cursor=l.playBtn.cursor.able;l.playBtn.node.onclick=function(){I.Play.call(I)};l.stopBtn.node.src=l.stopBtn.src.disable;l.stopBtn.node.title=l.stopBtn.title.disable;l.stopBtn.node.style.cursor=l.stopBtn.cursor.disable;l.stopBtn.node.onclick=function(){};l.fullScreenBtn.node.src=l.fullScreenBtn.src.disable;l.fullScreenBtn.node.title=l.fullScreenBtn.title.disable;l.fullScreenBtn.node.style.cursor=l.fullScreenBtn.cursor.disable;l.fullScreenBtn.node.onclick=function(){};break;case 2:l.ShowTheBlock(l.extend.node);l.playBtn.node.src=l.playBtn.src.out;l.playBtn.node.title=l.playBtn.title.able;l.playBtn.node.style.cursor=l.playBtn.cursor.able;l.playBtn.node.onclick=function(){I.Play.call(I)};l.stopBtn.node.src=l.stopBtn.src.out;l.stopBtn.node.title=l.stopBtn.title.able;l.stopBtn.node.style.cursor=l.stopBtn.cursor.able;l.stopBtn.node.onclick=function(){I.Stop.call(I)};l.fullScreenBtn.node.src=l.fullScreenBtn.src.disable;l.fullScreenBtn.node.title=l.fullScreenBtn.title.disable;l.fullScreenBtn.node.style.cursor=l.fullScreenBtn.cursor.disable;l.fullScreenBtn.node.onclick=function(){};break;case 3:case 4:case 5:case 6:case 7:case 9:case 10:case 11:l.ShowTheBlock(l.activeXHost.node);l.playBtn.node.src=l.pauseBtn.src.out;l.playBtn.node.title=l.pauseBtn.title.able;l.playBtn.node.style.cursor=l.pauseBtn.cursor.able;l.playBtn.node.onclick=function(){I.Pause.call(I)};l.stopBtn.node.src=l.stopBtn.src.out;l.stopBtn.node.title=l.stopBtn.title.able;l.stopBtn.node.style.cursor=l.stopBtn.cursor.able;l.stopBtn.node.onclick=function(){I.Stop.call(I)};l.fullScreenBtn.node.src=l.fullScreenBtn.src.out;l.fullScreenBtn.node.title=l.fullScreenBtn.title.able;l.fullScreenBtn.node.style.cursor=l.fullScreenBtn.cursor.able;l.fullScreenBtn.node.onclick=function(){I.SetFullScreen.call(I,1)};break;default:}},HandlerPlayError:function(){}}