	var sina = new Object();
	sina.VERSION = "1.0";
	sina.AUTHOR  = "[SinaUI]Amour GUO";
	sina.COPY_RIGHT = "SINA";
	
	sina.$ = function(objId){
		if(document.getElementById){
			return eval('document.getElementById("' + objId + '")');
		}else if(document.layers){
			return eval("document.layers['" + objId +"']");
		}else{
			return eval('document.all.' + objId);
		}
	}
	
	sina.GetOLeft = function(myObj){
		curObj = myObj;
		var objLT = curObj.offsetLeft;
		while(curObj!=curObj.offsetParent && curObj.offsetParent){
			curObj=curObj.offsetParent;
			if(curObj.tagName=="DIV" || curObj.tagName=="TABLE" || curObj.tagName=="TR" || curObj.tagName=="TD"){
				objLT += curObj.offsetLeft;
			}
		}
		return objLT;
	}
	
	//is IE or is NS ?
	sina.isIE = navigator.appName == "Microsoft Internet Explorer";
	sina.isNS = navigator.appName == "Netscape";
	sina.isOP = navigator.appName == "Opera";
	
	var curFileNumTmp;//当前播放的文件序列值；

	sina.Player = function(watchZoneId,controlZoneId,pZoneId,pBoxId,vZoneId,vBoxId,playBtnId,stopBtnId,screenFBtnId,muteBtnId,broadList,narrowList,broadBtn,narrowBtn,bornBtn,autoStart,defaultBand){
		//this.player = null;
		this.watchZone = sina.$(watchZoneId);//可视区域
		this.controlZone = sina.$(controlZoneId);//控制区域 获得此对象目的在NS下隐藏它
		this.width = this.watchZone.clientWidth;//视频宽度
		this.height = this.watchZone.clientHeight;//视频高度
		this.broadList = broadList;//宽频url 可能有n段
		this.narrowList = narrowList;//窄频url
		this.autoStart = autoStart;//是否自动播放
		this.playBtn = sina.$(playBtnId);//播放按钮
		this.playBtnUrl = this.playBtn.getAttribute("src").split("|")[0];//播放按钮的url
		this.pauseBtnUrl = this.playBtn.getAttribute("src").split("|")[1];//暂停按钮的url
		this.stopBtn = sina.$(stopBtnId);//停止按钮
		this.stopBtnUrl = this.stopBtn.getAttribute("src").split("|")[0];//停止按钮的url（可操作状态）
		this.stop2BtnUrl = this.stopBtn.getAttribute("src").split("|")[1];//停止按钮的url（不可操作状态）
		this.screenFBtn = sina.$(screenFBtnId);//全屏按钮
		this.muteBtn = sina.$(muteBtnId);//静音按钮
		this.muteBtnUrl = this.muteBtn.getAttribute("src").split("|")[0];//静音按钮的url（非静音状态）
		this.muteBtnAlt = this.muteBtn.getAttribute("alt").split("|")[1];//静音按钮（非静音状态）的alt属性值
		this.mute2BtnAlt = this.muteBtn.getAttribute("alt").split("|")[0];//静音按钮（静音状态）的alt属性值
		this.mute2BtnUrl = this.muteBtn.getAttribute("src").split("|")[1];//静音按钮的url（静音状态）
		
		//this.curFileNum = curFileNum;
		//this.broadBtn = sina.$(broadBtn);//宽频按钮
		//this.narrowBtn = sina.$(narrowBtn);//窄频按钮
		
		this.bornBtn = sina.$(bornBtn);//宽窄频单一button
		this.broadBtnUrl = this.bornBtn.getAttribute("src").split("|")[0];//宽频按钮的url
		this.narrowBtnUrl = this.bornBtn.getAttribute("src").split("|")[1];//窄频按钮的url		
		
		this.defaultBand = parseInt(defaultBand);

		//播放状态
		this.isPlay = this.autoStart?true:false;//播放中
		this.isPause = this.autoStart?false:true;//暂停中
		this.isStop = this.autoStart?false:true;//停止中

		this.pBox = sina.$("pBox");//进度条控制钮
		this.pBoxWidth = this.pBox.clientWidth;
		this.pZone = sina.$("pZone");//进度条区域
		this.pZoneWidth = this.pZone.clientWidth - this.pBoxWidth;//进度条区域的宽度 不包括margin, border, or scroll bar

		//this.pBoxPos = 0;//进度条控制钮的style.left值
		this.vBox = sina.$("vBox");//音量控制钮
		this.vBoxWidth = this.vBox.clientWidth;
		this.vZone = sina.$("vZone");//音量条区域
		this.vZoneWidth = this.vZone.clientWidth - this.vBoxWidth;//音量条区域的宽度
		//this.vBoxPos = 0;//音量控制钮的style.left值 默认值
		
		this.pFlag = false;
		this.vFlag = false;
		
		this.isPorV = 0;//判断是否对进度条还是音量操作
		
		this.mplayerAd = sina.$("mplayerAd");
		this.tipForNaI = sina.$("tipForNaI");
		
		//this.pState = this.mpObj.PlayState;//视频的当前状态；

	}
	//var tempPlay = new sina.Player();//解决js1.1 之prototype问题；
	sina.Player.prototype = {	
		mpObj:document.createElement("OBJECT"),
		//duration:this.mpObj.Duration,//视频持续时间
		//pCurPos:this.mpObj.CurrentPosition,//视频当前播放位置
		Draw:function(){
		//alert("开始Draw()");
				this.mpObj.classid = "CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
				this.mpObj.width = this.width;
				this.mpObj.height = this.height;
				this.mpObj.Filename = this.defaultBand == 1?this.broadList[0]:this.narrowList[0];			
				this.mpObj.AutoStart = this.autoStart;
				this.mpObj.ShowStatusBar = true;
				this.mpObj.EnableContextMenu = false;
				this.mpObj.ShowTracker = false;
				this.mpObj.ShowAudioControls = false;
				this.mpObj.ShowControls = false;
				//this.mpObj.Volume = -600;
				this.watchZone.appendChild(this.mpObj);
		},
		DrawToNS:function(){
			this.controlZone.style.display = "none";
			this.tipForNaI.style.display = "";
			var tempEmbed = document.createElement("EMBED");
			tempEmbed.type = "application/x-mplayer2";
			tempEmbed.flename = this.defaultBand == 1?this.broadList[0]:this.narrowList[0];
			tempEmbed.src = this.defaultBand == 1?this.broadList[0]:this.narrowList[0];
			tempEmbed.width = this.width;
			tempEmbed.height = this.height;
			tempEmbed.autoplay = this.autoStart;
			tempEmbed.autostart = this.autoStart;
			tempEmbed.showstatusbar = true;
			tempEmbed.statusbar = true;
			this.watchZone.appendChild(tempEmbed);
		},
		
		Play:function(){
			this.mplayerAd.style.display = "none";
			this.mpObj.style.display = "";
			if(this.mpObj.PlayState == 1){ //pause
				this.mpObj.play();
			}else{
				this.mpObj.Filename = this.broadList[curFileNum-1];
				curFileNumTmp = curFileNum-1;
			}
			this.mpObj.autoStart = true;
			
		},
		
		Pause:function(){
			this.mpObj.pause();
		},

		Stop:function(){
			this.mpObj.style.display = "none";
			this.mplayerAd.style.display = "";
			this.mpObj.stop();
			
		},
		
		// 静音 ///////////////////////////////////////////
		Mute:function(){
			if(this.mpObj.Mute.toString().toLowerCase() == "false"){
				this.mpObj.Mute = true;
				this.muteBtn.setAttribute("src",this.mute2BtnUrl);	
				this.muteBtn.setAttribute("alt",this.mute2BtnAlt); 			
			}else{
				this.mpObj.Mute = false;
				this.muteBtn.setAttribute("src",this.muteBtnUrl);
				this.muteBtn.setAttribute("alt",this.muteBtnAlt);				
			}
		},
		//设定音量值 vol: 0 - 9
		VolumeUp:function(vol){			
			var tmpVol = (10 - vol) * (-100);
			this.mpObj.Volume = tmpVol;
			this.vBox.style.left = Math.round(this.vZoneWidth / 10 * vol) + "px";
		},
		//改变频宽////////////////////////////////////////
		ChgBN:function(){
			if(this.mplayerAd.style.display == "none"){
				var tmpObj = this;
				if(this.defaultBand == 1){
					this.mpObj.FileName = this.narrowList[curFileNumTmp];
					this.bornBtn.setAttribute("src",this.broadBtnUrl);
					this.defaultBand = 0;
				}else{
					this.mpObj.FileName = this.broadList[curFileNumTmp];
					this.bornBtn.setAttribute("src",this.narrowBtnUrl);
					this.defaultBand = 1;
				}
				this.mpObj.autoStart = true;
				
				this.mplayerAd.style.display = "none";
				this.mpObj.style.display = "";
				this.mpObj.play();
			}
		},
		//点播
		SelectFile:function(file_url){
			if(file_url){
				if(sina.isIE) {
					this.mpObj.Filename = file_url;
					this.mpObj.autoStart = true;
					this.Play();
				}else{
					this.tempEmbed.flename = file_url;
					this.tempEmbed.src = file_url;
					alert("提示：\n\n请使用IE浏览器观看");
				}
			}
		},		
		// 全屏播放
		ChgScreen:function(){
			if(this.mpObj.Duration > 0){//If the FileName property is not set, the Duration property returns zero.
				this.mpObj.DisplaySize = 3;						
			}
		},
	
		// 给进度条按钮定位 for setInterval("",1000) 
		FixPos:function(){
			if(this.mpObj.Duration > 0){			
				 this.pBox.style.left = Math.round(this.pZoneWidth/this.mpObj.Duration*this.mpObj.CurrentPosition);
				 if((this.mpObj.Duration - this.mpObj.CurrentPosition) < 1) this.Stop();
			}
			if(this.mpObj.PlayState == 8){ //如果 Stream is not open 进度条滑块左归零
				this.pBox.style.left = "0px";	
			}
		},
		MouseDown:function (objSign){
			this.isPorV = objSign;
			if(this.isPorV == 0){
				if(this.mpObj.Duration > 0){
					this.pFlag = true;
					if(window.event.srcElement.id != this.pZone.id) this.pBox.style.left = this.pBox.offsetLeft;
					else this.pBox.style.left = window.event.x - this.pBoxWidth/2;
				}
			}else if(this.isPorV == 1){
				this.vFlag = true;
				if(window.event.srcElement.id != this.vZone.id) this.vBox.style.left = this.vBox.offsetLeft;
				else this.vBox.style.left = window.event.x - this.vBoxWidth/2;
			}
		},
		
		MouseMove:function(){
			if(this.isPorV == 0){
				if(this.mpObj.Duration > 0){
					if(this.pFlag) this.pBox.style.left = window.event.clientX - sina.GetOLeft(this.pZone) - 10 + "px"; //window.event.x-9;
					if (parseInt(this.pBox.style.left.replace("px","")) > this.pZoneWidth) this.pBox.style.left = this.pZoneWidth +"px";
					if (parseInt(this.pBox.style.left.replace("px","")) < -5) this.pBox.style.left= -5 + "px";
				}
			}else if(this.isPorV == 1){
			//alert(this.vZoneWidth)
				if(this.vFlag) this.vBox.style.left = window.event.clientX - sina.GetOLeft(this.vZone) - 4 + "px"; //window.event.x-9;
					if (parseInt(this.vBox.style.left.replace("px","")) > this.vZoneWidth) this.vBox.style.left = this.vZoneWidth + "px";
					if (parseInt(this.vBox.style.left.replace("px","")) < 0) this.vBox.style.left = 0 + "px";
			}
		},
		
		MouseUp:function(){
			if(this.isPorV == 0){			
				if(this.mpObj.Duration>0){
					if (this.pFlag){
						this.mpObj.CurrentPosition = this.mpObj.Duration * (parseInt(this.pBox.style.left.replace("px",""))/this.pZoneWidth);
					}
					this.pFlag = false;
				}
			}else if(this.isPorV == 1){
				if (this.vFlag){
					var tmpVol = (1 - parseInt(this.vBox.style.left)/this.vZoneWidth)*(-1000);
					if(tmpVol <= -1000){
						if(this.mpObj.Mute.toString().toLowerCase() == 'false'){
							this.mpObj.Mute = true;
							this.muteBtn.setAttribute("src",this.mute2BtnUrl);	
							this.muteBtn.setAttribute("alt",this.mute2BtnAlt); 
						}
					}else{
						if(this.mpObj.Mute.toString().toLowerCase()== 'true'){
							this.mpObj.Mute = false;
							this.muteBtn.setAttribute("src",this.muteBtnUrl);
							this.muteBtn.setAttribute("alt",this.muteBtnAlt);
						}
					}
					this.mpObj.Volume = Math.round(tmpVol);
				}
				this.vFlag = false;
			}
		},
		MouseEnd:function(){
			if(this.mpObj.Duration > 0){
				window.event.returnValue = false;
			}
		},
		//初始化 播放 暂停和停止按钮 ...
		Init:function(){
			var tmpObj = this;//定义临时对象引用类的事例 解决邦定事件处理程序的this问题
			//初始化按钮 是否自动播放决定需要分2种情况考虑
			if(this.autoStart == true){
				this.mplayerAd.style.display = "none";
				this.mpObj.style.display = "";
				this.playBtn.setAttribute("src",this.pauseBtnUrl);//显示暂停按钮
				this.playBtn.onclick = function(){ tmpObj.Pause.call(tmpObj);	} //绑定事件处理程序:this.Pause();
				
				this.stopBtn.setAttribute("src",this.stopBtnUrl);//显示停止按钮（可操作）
				this.stopBtn.onclick = function(){ tmpObj.Stop.call(tmpObj); }
			}
			if(this.autoStart == false){
				this.mplayerAd.style.display = "";
				this.mpObj.style.display = "none";
				
				this.playBtn.setAttribute("src",this.playBtnUrl);//显示播放按钮
				this.playBtn.onclick = function(){ tmpObj.Play.call(tmpObj); }
				
				this.stopBtn.setAttribute("src",this.stop2BtnUrl);//显示停止按钮（可操作）
				this.stopBtn.onclick = function(){ return false; }
			}
			//初始化全屏按钮
			this.screenFBtn.onclick = function(){	tmpObj.ChgScreen.call(tmpObj);}
			//初始化静音按钮
			this.muteBtn.setAttribute("src",this.muteBtnUrl);
			this.muteBtn.setAttribute("alt",this.muteBtnAlt);
			this.muteBtn.onclick = function(){ tmpObj.Mute.call(tmpObj); };
			//初始化 音量调节钮位置
			//this.VolumeUp(5);
			this.vBox.style.left = Math.round(this.vZoneWidth / 10 * 5) + "px";
			//初始化 频宽选择
			//this.broadBtn.checked = false;
			//this.narrowBtn.checked = false;
			if(this.defaultBand == 1){
				this.bornBtn.setAttribute("src",this.narrowBtnUrl);				
				//this.broadBtn.checked = true;
			}else{
				this.bornBtn.setAttribute("src",this.broadBtnUrl);
				//this.narrowBtn.checked = true;
			}
			this.bornBtn.onclick = function(){
					tmpObj.ChgBN.call(tmpObj);
			}
			/*
			this.broadBtn.onclick = function(){
				tmpObj.ChgBN.call(tmpObj);
			}
			this.narrowBtn.onclick = function(){
				tmpObj.ChgBN.call(tmpObj);
			}*/
			//
			//绑定 进度条和调整声音的onmousedown
			this.pZone.onmousedown = function(){
				tmpObj.MouseDown.call(tmpObj,0);				
			}
			this.vZone.onmousedown = function(){
				myPlayer.MouseDown.call(tmpObj,1);
				//alert(myPlayer.MouseDownV)
			}
			//绑定document事件			
			//if(this.mpObj.Duration || (!isNaN(this.mpObj.Duration))){
				document.onmousemove = function(){	 tmpObj.MouseMove.call(tmpObj); }
				document.ondragstart = function(){	 tmpObj.MouseEnd.call(tmpObj); }
				document.onmouseup = function(){ tmpObj.MouseUp.call(tmpObj); }
			//}
			this.Draw();//Draw视频			
		},
		//监测播放 暂停和停止按钮 根据时时监测播放状态来时时设置按钮状态
		CheckBtn:function(){
			var tmpObj = this;
			switch(this.mpObj.PlayState){
				case 0://Playback is stopped.
					this.playBtn.setAttribute("src",this.playBtnUrl);
					this.playBtn.onclick = function(){ tmpObj.Play.call(tmpObj); }
					
					this.stopBtn.setAttribute("src",this.stop2BtnUrl);
					this.stopBtn.onclick = function(){ return false; }
					
					//this.mplayerAd.style.display = "";
					break;
				case 1://Playback is paused
					this.playBtn.setAttribute("src",this.playBtnUrl);
					this.playBtn.onclick = function(){ tmpObj.Play.call(tmpObj); }
					this.stopBtn.setAttribute("src",this.stopBtnUrl);
					this.stopBtn.onclick = function(){ tmpObj.Stop.call(tmpObj); }
					break;
				case 2://Stream is playing
					this.playBtn.setAttribute("src",this.pauseBtnUrl);
					this.playBtn.onclick = function(){ tmpObj.Pause.call(tmpObj); };
					
					this.stopBtn.setAttribute("src",this.stopBtnUrl);
					this.stopBtn.onclick = function(){ tmpObj.Stop.call(tmpObj); };	
					
					//this.mplayerAd.style.display = "";
					break;
				case 3://Waiting for stream to begin
					this.playBtn.setAttribute("src",this.pauseBtnUrl);
					this.playBtn.onclick = function(){ tmpObj.Pause.call(tmpObj); };
					
					this.stopBtn.setAttribute("src",this.stopBtnUrl);
					this.stopBtn.onclick = function(){ tmpObj.Stop.call(tmpObj); };
					break;
				case 8://Stream is not open
					this.playBtn.setAttribute("src",this.pauseBtnUrl);
					this.playBtn.onclick = function(){ tmpObj.Pause.call(tmpObj); };
					
					this.stopBtn.setAttribute("src",this.stopBtnUrl);
					this.stopBtn.onclick = function(){ tmpObj.Stop.call(tmpObj); };
					break;
				//default: alert("this.mpObj.PlayState: " + this.mpObj.PlayState);
			}
		}
	}