	var winW = 1024; 
	var winH = 600; 

		if (parseInt(navigator.appVersion)>3) 
		{
			if (navigator.appName=="Netscape") 
			{
				winW = window.innerWidth-16;
				winH = window.innerHeight;
			}
	
			if (navigator.appName.indexOf("Microsoft")!=-1) 
			{
				winW = document.body.offsetWidth-20;
				winH = document.body.offsetHeight-3;
			}
		}		

	String.prototype.getQueryString = function(name)
	{
	  var reg = new RegExp("(^|&|\\?)"+ name +"=([^&]*)(&|$)"), r;
	  if (r=this.match(reg)) return unescape(r[2]); return null;
	}



		var oScript = document.getElementsByTagName("script");
		var b ="";
		
		for (var i=0;i<oScript.length;i++ )
		{
			
			if (oScript[i].src.toLowerCase().indexOf('wintv_display.js')>=0)
			{			 

			   b = oScript[i].src;
			}
		}

	   var userName = b.getQueryString("user");
	   var begin = b.getQueryString("begin");
	   var w = 	b.getQueryString("w");
	   var h =  parseInt(b.getQueryString("h"));
	   var h2 = h+10;
   	   var pos = b.getQueryString("pos");
   	   var localip = b.getQueryString("ip");
   	   var id = b.getQueryString("id");
   	   var tmpURI = b.getQueryString("uri");
   	   var liveParam = b.getQueryString("live");
   	   var winLiveURI="";
   	   if(tmpURI!=null&&tmpURI.length>0){
   	   		winLiveURI = "&uri="+tmpURI;
   	   }
   	   if(liveParam!=null&&liveParam.length>0){
  	 	   begin+="&live="+liveParam;
		}
	   var posStr = '';
	   
		switch (pos)
		{
		case '1':
			posStr='left:0;top:0;';
			break;
		case '2':
			posStr='right:0;top:0;';
			break;
		case '3':
			posStr='left:0;bottom:0;';
			break;
		case '4':
			posStr='right:0;bottom:0;';
			break;	
		case '5':
			posStr='left:'+(winW-w)/2+';top:'+(winH-h)/2+';';
			break;						
		}

		
//		var code = '<div id=wintv_content><iframe width=100% height=100% frameborder=1 scrolling=no src="http://localhost/wintv//player/player.swf?user=test&id=1&ip=http://localhost/wintv/" >';
//		code +='</iframe></div>';

		var code = '<div id=wintv_content_'+pos+'>';
//		code += '<a id=closeButton href=#></a><a id=switchButton href=#></a><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+w+'" height="'+h+'"><param name="movie" value="'+localip+'player/player.swf?user='+userName+'&id='+id+'&ip='+localip+'" ><param name="quality" value="high"><embed src="'+localip+'player/player.swf?user='+userName+'&id='+id+'&ip='+localip+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>';
		code += '</div>';

		document.write(code);			
		initMain(pos);		
		//dao hang			
		initDaohang(pos);
		mymove('wintv_content_'+pos);
		function mymove(divname){
			var content = document.getElementById(divname);
			switch (pos)
			{
				case '1':
					content.style.top=document.body.scrollTop;
					break;
				case '2':
					content.style.top=document.body.scrollTop;
					break;
				case '3':
					content.style.top=document.body.scrollTop+winH-h2;
					break;
				case '4':
					content.style.top=document.body.scrollTop+winH-h2;
		//			content.style.bottom=0-document.body.scrollTop;
					break;	
				case '5':
					content.style.top=document.body.scrollTop+(winH-h)/2;
		//			posStr='left:'+(winW-w)/2+';top:'+(winH-h)/2+';';
					break;						
			}

			setTimeout("mymove('"+divname+"');",200)
		}
		
	
		function initMain(posname){		//????????			
			var divname = 'wintv_content_'+posname;
			var content = document.getElementById(divname);
			content.style.cssText="position:absolute;"+posStr+"z-index:1000;overflow:hidden;height:"+h2+";width:"+w+";filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8;border:0px solid #EEEEEE;line-height:0px;";		
			content.innerHTML = '<div id=topmenu_'+posname+' ><a id=closeButton_'+posname+' onclick=closewindow("'+divname+'");></a><a id=switch2Button_'+posname+' ></a><a id=switchButton_'+posname+' onclick=resize("'+divname+'",'+posname+'); ></a></div><div id=flash_sec_'+posname+'><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+w+'" height="'+h+'"><param name="movie" value="'+localip+'player/player.swf?user='+userName+'&id='+id+'&begin='+begin+'&ip='+localip+winLiveURI+'" ><param name="quality" value="high"><param name="allowFullScreen" value="true" /><embed src="'+localip+'player/player.swf?user='+userName+'&id='+id+'&begin='+begin+'&ip='+localip+winLiveURI+'" width="'+w+'" height="'+h+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object></div>';
		//	alert(content.innerHTML);		
			
			
		}
		function initDaohang(posname){		//??????
			
			var tmenu = document.getElementById('topmenu_'+posname);
			tmenu.style.cssText='width:100%;height:10px;float:right;';
	//		tmenu.style.background = 'url('+localip+'images/top_bg.gif)';
			
			var cbt = document.getElementById('closeButton_'+posname);
			cbt.style.cssText='position:absolute;\
								z-index:2;\
								top:1px;right:1px;\
								width:8px;\
								height:8px;cursor:hand;';
			cbt.style.background = 'url('+localip+'images/close.gif)';		
			
			var sbt2 = document.getElementById('switch2Button_'+posname);		
			sbt2.style.cssText='position:absolute;\
								z-index:2;\
								top:1px;right:11px;\
								width:8px;\
								height:8px;cursor:default';
			sbt2.style.backgroundImage = 'url('+localip+'images/switch2.gif)';
			
			var sbt = document.getElementById('switchButton_'+posname);		
			sbt.style.cssText='position:absolute;\
								z-index:2;\
								top:1px;right:21px;\
								width:8px;\
								height:8px;cursor:hand;';
			sbt.style.backgroundImage = 'url('+localip+'images/switch.gif)';
		}		
		
		
		function closewindow(divname){	//close the window			
			var content1 = document.getElementById(divname);
			content1.innerHTML = '';
			content1.style.border='0px';			
		}
		var switchFlag = true;
		function resize(divname,posname){	//min window switch
	//		var flash_sec = document.getElementById("flash_sec");
	//		flash_sec.innerHTML = '';
			
			var content = document.getElementById(divname);	
			if(switchFlag){					
				content.style.height=10;
				content.style.width=80;
				content.innerHTML = '<div id=topmenu_'+posname+' ><a id=closeButton_'+posname+' onclick=closewindow("'+divname+'") ></a><a id=switch2Button_'+posname+'></a><a id=switchButton_'+posname+' onclick=resize("'+divname+'",'+posname+') ></a></div>';
				
				initDaohang(posname);
				switchFlag=false;
				
			}else{
		//		alert(posname);
				initMain(posname);	initDaohang(posname);mymove(divname);
				switchFlag=true;
			}
		}