﻿//update 3 Mar 2010
var style
if(!style){
	style="0"
}
var imgSrc="http://dl.tvunetworks.com/webplayer/";
/*var imgSrc="";*/
var AffiliateID
if(!AffiliateID){
   	AffiliateID="1002"
}
var AdDir
if(!AdDir){
    AdDir="RightBottom"	
}
var loadOutTime=60*5
var loadingTime=0;
var StreamPort;

var macPluginSrc="http://dl.tvunetworks.com/TVUPlayerInstaller.v1.1.4.pkg";
var macPluginSrcFF="http://dl.tvunetworks.com/TVUPlugin_mac.v1.1.4.xpi";

var TVU_ShowInstallMsg="";
var TVU_ShowInstallUpdateMsg="";
var TVULang;

var w
var h
var c
var autoplay
var auto_play
var TVUControlBar;
if(!TVUControlBar||TVUControlBar==0){
    TVUControlBar='Hide';
}else if(TVUControlBar==1){
    TVUControlBar='Auto';
}else{
	TVUControlBar='Show'
}
var TVU_WMP_TestVersion=0;
var TVU_isFirstPlay=true;
/*-------------------------------------css.js-----------------------------------------------------------------*/
document.writeln("<style>");
document.writeln(".TVU_txtTitle,.TVU_txt12w{");
document.writeln("	width:90%; margin:5px; auto;text-align:center;");
document.writeln("	font-family:Verdana, Geneva, sans-serif;");
document.writeln("	line-height:14px;");
document.writeln("}");
document.writeln(".TVU_txtTitle{");
document.writeln("	color:#5ee614; font-size:14px;  font-weight:bold;");
document.writeln("}");
document.writeln(".TVU_txt12w{");
document.writeln("	color:#fff; font-size:12px;font-weight:500;margin-bottom:15px;margin-top:15px;");
document.writeln("}");
document.writeln("#loading a{");
document.writeln("	color:#5ee614;");
document.writeln("	text-decoration:underline;");
document.writeln("}");
document.writeln("#loading a:hover{");
document.writeln("	text-decoration:none;");
document.writeln("}");
document.writeln(".floatR{float:right;}");
document.writeln(".TVU_txt12w img{");
document.writeln("	margin:5px;");
document.writeln("	border:none;");
document.writeln("}");
document.writeln("#TVU_BtnDiv td,#TVU_BtnDiv div,#TVU_BtnDiv, #TVU_BtnDiv img{");
document.writeln("	margin:0;");
document.writeln("	padding:0;");
document.writeln("}");
document.writeln("#InstallBtn{");
document.writeln("	margin-top:30px;");
document.writeln("	padding:0;text-align:center");
document.writeln("}");
document.writeln("#TVU_ControlBar{");
document.writeln("	margin:0;");
document.writeln("	padding:2px 0; background:url(http://pages.tvunetworks.com/webplayer/images/metal_bg.png) repeat-x;height:32px;text-align:right;");
document.writeln("}");
document.writeln("#TVU_ControlBar img{");
document.writeln("	margin:0 5px;");
document.writeln("	padding:0;");
document.writeln("}");
document.writeln("#play_content embed{");
document.writeln("	margin:0;");
document.writeln("	padding:0;");
document.writeln("}");
document.writeln("<\/style>")

function GetCookie(name){  
      var  arg = name + "=";  
      var  alen = arg.length;  
      var  clen = document.cookie.length;  
      var  i = 0;  
      while(i< clen){  
          var  j = i + alen;  
          if(document.cookie.substring(i,j) == arg)  
              return  getCookieVal(j);  
          i = document.cookie.indexOf(" ",i)+ 1;  
          if(i == 0)break;    
      }  
      return null;  
  }  
   
function getCookieVal(offset){  
	var  endstr  =  document.cookie.indexOf(";",  offset);  
	if(endstr == -1)  
		endstr = document.cookie.length;  
	return  unescape(document.cookie.substring(offset, endstr));  
}  
function   SetCookie(name,  value){  
	var expire_days = 30;
	var expire_date =new Date("December   31,   3666"); 
	var ms_from_now =  expire_days*24*60*60*1000;  
	expire_date.setTime(expire_date.getTime()+ ms_from_now);  
	var expire_string = expire_date.toGMTString();  
	document.cookie = name + "=" +escape(value)+";expires="+expire_string;  
} 
/*-----------------------------------------------------------------check wmp version -----------------------------------------------------------*/
/* PluginDetect v0.6.3 [ isMinVersion getVersion WMP ] by Eric Gerds www.pinlady.net/PluginDetect */ if(!PluginDetect){var PluginDetect={getNum:function(b,c){if(!this.num(b)){return null}var a;if(typeof c=="undefined"){a=/[\d][\d\.\_,-]*/.exec(b)}else{a=(new RegExp(c)).exec(b)}return a?a[0].replace(/[\.\_-]/g,","):null},hasMimeType:function(c){if(PluginDetect.isIE){return null}var b,a,d,e=c.constructor==String?[c]:c;for(d=0;d<e.length;d++){b=navigator.mimeTypes[e[d]];if(b&&b.enabledPlugin){a=b.enabledPlugin;if(a.name||a.description){return b}}}return null},findNavPlugin:function(g,d){var a=g.constructor==String?g:g.join(".*"),e=d===false?"":"\\d",b,c=new RegExp(a+".*"+e+"|"+e+".*"+a,"i"),f=navigator.plugins;for(b=0;b<f.length;b++){if(c.test(f[b].description)||c.test(f[b].name)){return f[b]}}return null},AXO:window.ActiveXObject,getAXO:function(b,a){var f=null,d,c=false;try{f=new this.AXO(b);c=true}catch(d){}if(typeof a!="undefined"){delete f;return c}return f},num:function(a){return(typeof a!="string"?false:(/\d/).test(a))},compareNums:function(g,e){var d=this,c,b,a,f=window.parseInt;if(!d.num(g)||!d.num(e)){return 0}if(d.plugin&&d.plugin.compareNums){return d.plugin.compareNums(g,e)}c=g.split(",");b=e.split(",");for(a=0;a<Math.min(c.length,b.length);a++){if(f(c[a],10)>f(b[a],10)){return 1}if(f(c[a],10)<f(b[a],10)){return -1}}return 0},formatNum:function(b){if(!this.num(b)){return null}var a,c=b.replace(/\s/g,"").replace(/[\.\_]/g,",").split(",").concat(["0","0","0","0"]);for(a=0;a<4;a++){if(/^(0+)(.+)$/.test(c[a])){c[a]=RegExp.$2}}if(!(/\d/).test(c[0])){c[0]="0"}return c[0]+","+c[1]+","+c[2]+","+c[3]},initScript:function(){var $=this,userAgent=navigator.userAgent;$.isIE=/*@cc_on!@*/false;$.IEver=$.isIE&&((/MSIE\s*(\d\.?\d*)/i).exec(userAgent))?parseFloat(RegExp.$1,10):-1;$.ActiveXEnabled=false;if($.isIE){var x,progid=["Msxml2.XMLHTTP","Msxml2.DOMDocument","Microsoft.XMLDOM","ShockwaveFlash.ShockwaveFlash","TDCCtl.TDCCtl","Shell.UIHelper","Scripting.Dictionary","wmplayer.ocx"];for(x=0;x<progid.length;x++){if($.getAXO(progid[x],1)){$.ActiveXEnabled=true;break}}$.head=typeof document.getElementsByTagName!="undefined"?document.getElementsByTagName("head")[0]:null}$.isGecko=!$.isIE&&typeof navigator.product=="string"&&(/Gecko/i).test(navigator.product)&&(/Gecko\s*\/\s*\d/i).test(userAgent)?true:false;$.GeckoRV=$.isGecko?$.formatNum((/rv\s*\:\s*([\.\,\d]+)/i).test(userAgent)?RegExp.$1:"0.9"):null;$.isSafari=!$.isIE&&(/Safari\s*\/\s*\d/i).test(userAgent)?true:false;$.isChrome=(/Chrome\s*\/\s*\d/i).test(userAgent)?true:false;$.onWindowLoaded(0)},init:function(c,a){if(typeof c!="string"){return -3}c=c.toLowerCase().replace(/\s/g,"");var b=this,d;if(typeof b[c]=="undefined"){return -3}d=b[c];b.plugin=d;if(typeof d.installed=="undefined"||a==true){d.installed=null;d.version=null;d.version0=null;d.getVersionDone=null;d.$=b}b.garbage=false;if(b.isIE&&!b.ActiveXEnabled){if(b.plugin!=b.java){return -2}}return 1},isMinVersion:function(g,e,c,b){var f=PluginDetect,d=f.init(g);if(d<0){return d}if(typeof e=="number"){e=e.toString()}if(typeof e!="string"){e="0"}if(!f.num(e)){return -3}e=f.formatNum(e);var a=-1,h=f.plugin;if(h.getVersionDone!=1){h.getVersion(c,b);if(h.getVersionDone===null){h.getVersionDone=1}}if(h.version!==null||h.installed!==null){if(h.installed<=0.5){a=h.installed}else{a=(h.version===null?0:(f.compareNums(h.version,e)>=0?1:-1))}}f.cleanup();return a;return -3},getVersion:function(e,b,a){var d=PluginDetect,c=d.init(e),f;if(c<0){return null}f=d.plugin;if(f.getVersionDone!=1){f.getVersion(b,a);if(f.getVersionDone===null){f.getVersionDone=1}}d.cleanup();return(f.version||f.version0);return null},getInfo:function(f,c,b){var a={};return a},cleanup:function(){},isActiveXObject:function(b){},codebaseSearch:function(c){var e=this;if(!e.ActiveXEnabled){return null}if(typeof c!="undefined"){return e.isActiveXObject(c)}},dummy1:0}}PluginDetect.onDetectionDone=function(g,e,d,a){return -1};PluginDetect.onWindowLoaded=function(c){};PluginDetect.div=null;PluginDetect.pluginSize=1;PluginDetect.DOMbody=null;PluginDetect.uninstantiate=function(a){var c,b=this;if(!a){return}try{if(a[0]&&a[0].firstChild){a[0].removeChild(a[0].firstChild)}if(a[0]&&b.div){b.div.removeChild(a[0])}if(b.div&&b.div.childNodes.length==0){b.div.parentNode.removeChild(b.div);b.div=null;if(b.DOMbody&&b.DOMbody.parentNode){b.DOMbody.parentNode.removeChild(b.DOMbody)}b.DOMbody=null}a[0]=null}catch(c){}};PluginDetect.getObject=function(b,a){var f,c=this,d=null;try{if(b&&b[0]&&b[0].firstChild){d=b[0].firstChild}}catch(f){}try{if(a&&d&&typeof d.focus!="undefined"&&typeof document.hasFocus!="undefined"&&!document.hasFocus()){d.focus()}}catch(f){}return d};PluginDetect.getContainer=function(a){var c,b=null;if(a&&a[0]){b=a[0]}return b};PluginDetect.hideObject=function(a){var b=this.getObject(a);if(b&&b.style){b.style.height="0"}};PluginDetect.instantiate=function(h,b,c,a){var j=function(d){var e=d.style;if(!e){return}e.border="0px";e.padding="0px";e.margin="0px";e.fontSize=(g.pluginSize+3)+"px";e.height=(g.pluginSize+3)+"px";e.visibility="visible";if(d.tagName&&d.tagName.toLowerCase()=="div"){e.width="100%";e.display="block"}else{if(d.tagName&&d.tagName.toLowerCase()=="span"){e.width=g.pluginSize+"px";e.display="inline"}}};var k,l=document,g=this,p,i=(l.getElementsByTagName("body")[0]||l.body),o=l.createElement("span"),n,f,m="/";if(typeof a=="undefined"){a=""}p="<"+h+' width="'+g.pluginSize+'" height="'+g.pluginSize+'" ';for(n=0;n<b.length;n=n+2){p+=b[n]+'="'+b[n+1]+'" '}p+=">";for(n=0;n<c.length;n=n+2){p+='<param name="'+c[n]+'" value="'+c[n+1]+'" />'}p+=a+"<"+m+h+">";if(!g.div){g.div=l.createElement("div");f=l.getElementById("plugindetect");if(f){j(f);f.appendChild(g.div)}else{if(i){try{if(i.firstChild&&typeof i.insertBefore!="undefined"){i.insertBefore(g.div,i.firstChild)}else{i.appendChild(g.div)}}catch(k){}}else{try{l.write('<div id="pd33993399">o<'+m+"div>");i=(l.getElementsByTagName("body")[0]||l.body);i.appendChild(g.div);i.removeChild(l.getElementById("pd33993399"))}catch(k){try{g.DOMbody=l.createElement("body");l.getElementsByTagName("html")[0].appendChild(g.DOMbody);g.DOMbody.appendChild(g.div)}catch(k){}}}}j(g.div)}if(g.div&&g.div.parentNode&&g.div.parentNode.parentNode){g.div.appendChild(o);try{o.innerHTML=p}catch(k){}j(o);return[o]}return[null]};PluginDetect.windowsmediaplayer={mimeType:["application/x-mplayer2","application/asx"],progID:"wmplayer.ocx",classID:"clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6",getVersion:function(){var a=null,e=this.$,b=null;this.installed=-1;if(!e.isIE){if(e.hasMimeType(this.mimeType)){if(e.findNavPlugin(["Windows","Media","(Plug-in|Plugin)"],false)||e.findNavPlugin(["Flip4Mac","Windows","Media"],false)){this.installed=0}var d=e.isGecko&&e.compareNums(e.GeckoRV,e.formatNum("1.8"))<0;if(!d&&e.findNavPlugin(["Windows","Media","Firefox Plugin"],false)){var c=e.instantiate("object",["type",this.mimeType[0]],[]),f=e.getObject(c);if(f){a=f.versionInfo}e.uninstantiate(c)}}}else{b=e.getAXO(this.progID);if(b){a=b.versionInfo}}if(a){this.installed=1}this.version=e.formatNum(a)}};PluginDetect.initScript();
if(PluginDetect.getVersion('WindowsMediaPlayer')){
    TVU_WMP_TestVersion=PluginDetect.getVersion('WindowsMediaPlayer').split(",")[0];
}
//alert(TVU_WMP_TestVersion)
/*-------------------------------------webplayer.js-----------------------------------------------------------*/
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};


function tvu(){
	var tvu = document.getElementById("tvuplayer");
	return tvu;
}
var TVU_delayFlag=true;
function play(channel)
{   
   if(!channel) return;
   channel=channel.toString();
   c=channel;
   if(c.indexOf("tvu:")<0){
	   if(c.indexOf("'")>=0){
		  c=c.split("'")[1];			
		}
   }
   SetCookie("TVU_playCh",c)
   var showurl="";
   if(TVU_isFirstPlay){
	   try{
		  loadA();
		  TVU_isFirstPlay=false;
		}catch(err){}
   }
  try{	
        if(c.indexOf("tvu:")<0){
           showurl="tvup://ps3.tvunetworks.com:3940/"+c+".0.0.0";
        }else{//play key
		   showurl=c;
		}
    	if(TVU_delayFlag){
			setTimeout(function(){
				tvu().Stop();
				if(BrowserDetect.OS=="Mac"){
					tvu().Play(showurl);
				}else{
					tvu().Play2(showurl,true,10);
				}
		        TVU_delayFlag=false;},4000);
		}else{
			tvu().Stop();
			if(BrowserDetect.OS=="Mac"){
				tvu().Play(showurl);
			}else{
				tvu().Play2(showurl,true,10);
			}
		}
		if(style=="1"){
		document.getElementById("playbtn").innerHTML=
		'<img src="http://dl.tvunetworks.com/webplayer/images/play_on.png" width="29" height="27" border="0" id="Image_play" alt="Play" />';
		}
	}catch(e){}	
}

function stop(channel)
{
  if(!channel) return;	
  if(channel.indexOf("'")<0&&channel.indexOf('"')<0){
	  channel="'"+channel+"'";
  }
  tvu().Stop();
  if(style=="1"){
  document.getElementById("playbtn").innerHTML=
  '<img src="http://dl.tvunetworks.com/webplayer/images/play_off.png" name="Image_play" width="29" height="27" border="0" id="Image_play" alt="Play" onclick="play('+channel+');" onmouseout="mout();"  onmouseover="mover();" />';
  }
}

function mout()
{
	if(style=="1"){
    document.getElementById("Image_play").src="http://dl.tvunetworks.com/webplayer/images/play_off.png";
	}
}

function mover()
{
	if(style=="1"){
    document.getElementById("Image_play").src="http://dl.tvunetworks.com/webplayer/images/play_on.png";
	}
}

function refresh()
{
  tvu().Refresh();
}

function get_Volume(){
	if(BrowserDetect!=undefined){
		if(BrowserDetect.browser == "Firefox"&&BrowserDetect.OS!="Mac"){
			return tvu().get_Volume();
		}
	}
	return tvu().Volume;
}
function put_Volume(v){
	if(BrowserDetect!=undefined){
		if(BrowserDetect.browser == "Firefox"&&BrowserDetect.OS!="Mac"){
			tvu().put_Volume(v);
			return;
		}
	}
	
	tvu().Volume = v;
	return;
}
function get_Mute(){
	if(BrowserDetect!=undefined){
		if(BrowserDetect.browser == "Firefox"&&BrowserDetect.OS!="Mac"){
			return tvu().get_Mute();
		}
	}
	
	return tvu().Mute;
}
function put_Mute(m){
	if(BrowserDetect!=undefined){
		if(BrowserDetect.browser == "Firefox"&&BrowserDetect.OS!="Mac"){
			tvu().put_Mute(m);
			return;
		}
	}
	
	tvu().Mute = m;
	return;
}

function mute()
{
  	if(!get_Mute()){
		put_Mute(true);
		document.getElementById("Image_mute").src="http://dl.tvunetworks.com/webplayer/images/mute.png";
	}
	else
	{
		put_Mute(false);
		document.getElementById("Image_mute").src="http://dl.tvunetworks.com/webplayer/images/unmute_off.png";
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

MM_preloadImages('http://dl.tvunetworks.com/webplayer/images/play_on.png','http://dl.tvunetworks.com/webplayer/images/stop_on.png','http://dl.tvunetworks.com/webplayer/images/refresh_on.png','http://dl.tvunetworks.com/webplayer/images/full_on.png','http://dl.tvunetworks.com/webplayer/images/mute.png','http://dl.tvunetworks.com/webplayer/images/volume_ball_blue.png');


function vol(){
	var sliderEl = document.getElementById("sliderbar");
	var inputEl = document.getElementById("sliderinput");
	var xInit = false;
	var s = new Slider(sliderEl, inputEl);
	s.onchange = function () {
	document.getElementById("vol_value").innerHTML=s.getValue();
	if(!xInit)
	{
		s.setValue(50);
		xInit = true;
	}
	else
	{
	try{
		put_Volume(s.getValue());
		if(get_Volume()>0)
			document.getElementById("Image_mute").src="http://dl.tvunetworks.com/webplayer/images/unmute_off.png";
		else
			document.getElementById("Image_mute").src="http://dl.tvunetworks.com/webplayer/images/mute.png";
	}catch(e){}
	}
};
s.setValue(50);
}

var TVU_installCue="";
var TVU_updateCue="";
var TVU_WMPDetecMsg="";
function TVU_MsgInit(){
if(TVULang=="pt"){
	TVU_ShowInstallMsg="<div class='TVU_txtTitle'>Para assistir você precisa do TVUPlayer gratuito:</div><div class='TVU_txt12w'><a href='javascript:void(0);' target='_self' onclick='TVU_download();'><img src='http://pages.tvunetworks.com/webplayer/images/install_btn.gif' alt='install now' title='install now' class='floatR'></a> Clique <a href='javascript:void(0);' onclick='TVU_download();' target='_self'><b>aqui</b></a> para realizar a instalação manualmente.</div>";
	TVU_ShowInstallUpdateMsg="<div class='TVU_txtTitle'>Para assistir você precisa do TVUPlayer gratuito:</div><div class='TVU_txt12w'><a href='javascript:void(0);' target='_self' onclick='TVU_download();'><img src='http://pages.tvunetworks.com/webplayer/images/install_btn.gif' alt='install now' title='install now' class='floatR'></a> Clique <a href='javascript:void(0);' onclick='TVU_download();' target='_self'><b>aqui</b></a> para realizar a instalação manualmente.</div>";
	TVU_WMPDetecMsg="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center;' id='loading'>ONosso sistema notou que você não possui a versão correta do Windows Media Player instalada. É necessário ter o Windows Media Player versão 9.x ou mais recente para executar o TVUPlayer. Podemos realizar a <a href='http://www.microsoft.com/downloads/results.aspx?pocId=4&freetext=windows%20media%20player%2011' target='blank'>instalação</a> agora?</span>"
}else{
	TVU_WMPDetecMsg="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center;' id='loading'>Our system sees that you do not have the right <br>version of Windows Media Player (WMP) installed. You need WMP v9.x and higher in order to run TVUPlayer. <br>Shall we <a href='http://www.microsoft.com/downloads/results.aspx?pocId=4&freetext=windows%20media%20player%2011&DisplayLang=en' target='blank'>install</a> it now?</span>"
	if(BrowserDetect.OS=="Windows"){
		TVU_ShowInstallMsg="<div class='TVU_txtTitle'>You need the free TVUPlayer to watch.</div><br><div class='TVU_txt12w'><input type='checkbox' id='TVU_checkBox' value='checkbox' checked onClick='TVU_installCheckit()'> I agree with the TVU <a href=javascript:open_new_window('http://pages.tvunetworks.com/doc/terms_of_service.html') >Terms of Service</a></div><div  id='InstallBtn'><a href='javascript:void(0);'  target='_self' onclick='TVU_download();TVU_installLoading()'><img src='http://pages.tvunetworks.com/webplayer/images/install_btn.gif' alt='install now' title='install now' border=0></a></div>";
		TVU_ShowInstallUpdateMsg="<div class='TVU_txtTitle'>You need the free TVUPlayer to watch.<br>A new version is available and required to install.</div><br><div class='TVU_txt12w'><input type='checkbox' id='TVU_checkBox' value='checkbox' checked onClick='TVU_installCheckit()'> I agree with the TVU <a href=javascript:open_new_window('http://pages.tvunetworks.com/doc/terms_of_service.html') >Terms of Service</a></div><div  id='InstallBtn'><a href='javascript:void(0);'  target='_self' onclick='TVU_download();TVU_installLoading()'><img src='http://pages.tvunetworks.com/webplayer/images/install_btn.gif' alt='install now' title='install now' border=0></a></div>";
		
		if(BrowserDetect.browser=="Explorer"){
			TVU_installCue="<div class='TVU_txt12w' id='TVU_installCueBox'>In the next window, select 'Run' to download and install.</div>";
			TVU_updateCue="<div class='TVU_txt12w' id='TVU_installCueBox'>In the next window, select 'Run' to download and install. You need to close and reopen IE browser.</div>";
		}else if(BrowserDetect.browser=="Firefox"){
			TVU_installCue="<div class='TVU_txt12w' id='TVU_installCueBox'>In the next window, select 'Save File'. Then double click on the downloaded file.<br>When finished, please close and reopen Firefox.</div>";
			TVU_updateCue="<div class='TVU_txt12w' id='TVU_installCueBox'>In the next window, select 'Save File'. Then double click on the downloaded file.<br>When finished, please close and reopen Firefox.</div>";
		}
		TVU_ShowInstallMsg=TVU_ShowInstallMsg+TVU_installCue;
		TVU_ShowInstallUpdateMsg=TVU_ShowInstallUpdateMsg+TVU_updateCue;
	}else if(BrowserDetect.OS=="Mac"){
		TVU_ShowInstallMsg="";
		TVU_ShowInstallUpdateMsg="";
	}
}
}

var screen_height
function initPlayer(){
	w=(w<340)?340:w
    h=(h<44)?44:h
	document.write("<div id=allPlay style='width:"+w+"px;height:"+h+"px;'></div>")
    var allPlay=document.getElementById("allPlay")
	
	var play_control="<table id='TVU_BtnDiv' width="+w+" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" height=\"44\"><tr style=\"height:31px;\"><td background=http://dl.tvunetworks.com/webplayer/images/left_bg.png width=\"35\" align=\"right\" valign=\"middle\"><div id=\"playbtn\"><img src=http://dl.tvunetworks.com/webplayer/images/play_off.png name=\"Image_play\" width=\"29\" height=\"27\" border=\"0\" id=\"Image_play\" alt=\"Play\" onclick=\"play(c);\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image_play','','http://dl.tvunetworks.com/webplayer/images/play_on.png',0)\" /></div></td><td background=http://dl.tvunetworks.com/webplayer/images/gray_bg.png width=\"44\" align=\"right\" valign=\"middle\"><div id=\"stopbtn\"><img src=http://dl.tvunetworks.com/webplayer/images/stop_off.png name=\"Image_stop\" width=\"28\" height=\"27\" border=\"0\" id=\"Image_stop\" alt=\"Stop\" onclick=\"stop(c);\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image_stop','','http://dl.tvunetworks.com/webplayer/images/stop_on.png',0)\" /></div></td><td background=http://dl.tvunetworks.com/webplayer/images/gray_bg.png width=\"44\" align=\"right\" valign=\"middle\"><div><img src=http://dl.tvunetworks.com/webplayer/images/refresh_off.png name=\"Image_refresh\" width=\"29\" height=\"27\" border=\"0\" id=\"Image_refresh\" alt=\"Refresh\" onclick=\"refresh() \" onmouseout=\"MM_swapImgRestore()\"   onmouseover=\"MM_swapImage('Image_refresh','','http://dl.tvunetworks.com/webplayer/images/refresh_on.png',0)\" /></div></td><td background=http://dl.tvunetworks.com/webplayer/images/gray_bg.png valign=\"middle\" width=\"125\" align=\"right\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" height=\"31\"><tr><td height=\"7\" colspan=\"2\"></td></tr><tr><td  height=\"9\" valign=\"middle\" align=\"center\" colspan=\"2\"><div id=\"sliderbar\" style=\"width: 110px; margin: 0px;position:relative;\"><input  id=\"sliderinput\"/></div></td></tr><tr><td class=\"text10\" align=\"right\" width=\"72\" valign=\"top\" height=\"15\"><strong>Volume: </strong></td><td class=\"text10\" width=\"48\" align=\"left\" valign=\"top\"><strong><span id=\"vol_value\"></span></strong></td></tr></table></td><td background=http://dl.tvunetworks.com/webplayer/images/gray_bg.png width=\"44\" valign=\"middle\"><div><img src=http://dl.tvunetworks.com/webplayer/images/unmute_off.png name=\"Image_mute\" width=\"28\" height=\"27\" border=\"0\" id=\"Image_mute\" alt=\"Mute/Unmute\" onclick=\"mute();\" /></div></td><td background=http://dl.tvunetworks.com/webplayer/images/gray_bg.png width="+(w-340)+"></td><td style=\"background:url(http://dl.tvunetworks.com/webplayer/images/right_bg.png) no-repeat;\" width=\"50\" align=\"center\" valign=\"middle\"><img border=\"0\"  src=\""+imgSrc+"images/logo.png\" width=\"32\" height=\"32\"></td></tr></table>"
    screen_height=(style=="1")?(h-44):h;
	var play_body="<table width="+w+" height="+screen_height+" align='center' border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor='#000'><tr><td align='center' id='play_content'></td></tr></table>";
	TVU_MsgInit();
	if(style=="1"){
	   allPlay.innerHTML=play_body+play_control;
	   vol();
	}else{
	   allPlay.innerHTML=play_body; 
	}
	var play_content=document.getElementById("play_content")		
		  
if(BrowserDetect.OS=="Mac"){//Mac
	if(BrowserDetect.browser=="Safari"){
		play_content.innerHTML="<embed id='tvuplayer' height="+screen_height+" width='100%' srcURL=\"/sample_videos/bao.wmv\" pluginspage="+macPluginSrc+" type=\"application/x-tvuplayer-plugin\"></embed>"
		var plugin = navigator.plugins["TVU Web Player for Safari"];
		
		if(plugin){
		    var desc = plugin.description;
			
			if(desc.indexOf("1.1.4")<0){
				location.href=macPluginSrc;
			}else{
				TVU_autoplay()
			}
		}
		
	}else if(BrowserDetect.browser=="Firefox"){
		 var plugin = navigator.plugins["TVU Web Player for Firefox"];
		 if(plugin){
			    var desc = plugin.description;
			    if(desc.indexOf("1.1.4")<0) { 
			         InstallTrigger.install({'TVU Web Player for Firefox':macPluginSrcFF});
			         if(!checkIsInstallTVU()){
				        //document.getElementById("play_content").innerHTML="<span id='loading'>"+TVU_ShowInstallMsg+"</span>";
						isLoadingF()
				     }        
			     }else {
				     play_content.innerHTML="<embed id='tvuplayer' type='application/x-tvuplayer-plugin' width='100%' height="+screen_height+" pluginspage='http://wwww.tvunetworks.com/downloads/player.html' AffiliateID="+AffiliateID+" />"		
					 TVU_autoplay()
			     }
		   }else{
			    InstallTrigger.install({'TVU Web Player for Firefox':macPluginSrcFF});
			    if(!checkIsInstallTVU()){
				   // document.getElementById("play_content").innerHTML="<span id='loading'>"+TVU_ShowInstallMsg+"</span>";
				    isLoadingF()
				}
		   }
		 
	}else{
		play_content.innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center'>TVU plug-in supports Safari and FireFox on Intel Mac 10.5.x only.</span>";
	}
}else if(BrowserDetect.OS=="Windows"){//windows
   if(BrowserDetect.browser=="Firefox"||BrowserDetect.browser=="Explorer"){// ie and firefox
	   if(BrowserDetect.browser=="Firefox"){
	       var plugin = navigator.plugins["TVU Web Player for FireFox"];
		   if(plugin){
			    var desc = plugin.description;
			    if(!isNew(desc,'2,5,2,2')) {
			         //InstallTrigger.install({'TVU Web Player For Firefox':'https://subscribe.tvunetworks.com/firefox/ffplugin.xpi'});
			        document.getElementById("play_content").innerHTML="<span id='loading'>"+TVU_ShowInstallUpdateMsg+"</span>";
					//isLoadingF()    
			     }else {
				     play_content.innerHTML="<embed id='tvuplayer' type='application/x-tvuplayer-plugin' width='100%' height="+screen_height+" pluginspage='http://wwww.tvunetworks.com/downloads/player.html' AffiliateID="+AffiliateID+" ControlBar="+TVUControlBar+" PlayCallback='onPlayCallback'  PopADDirection='"+AdDir+"' />"	
					 TVU_autoplay()
			     }
		   }else{
			    //InstallTrigger.install({'TVU Web Player For Firefox':'https://subscribe.tvunetworks.com/firefox/ffplugin.xpi'});
			    if(!checkIsInstallTVU()){
				    document.getElementById("play_content").innerHTML="<span id='loading'>"+TVU_ShowInstallMsg+"</span>";
					//isLoadingF()
				}
		   }
        }else if(BrowserDetect.browser=="Explorer"){
			if(TVU_WMP_TestVersion<9){
				play_content.innerHTML=TVU_WMPDetecMsg;
				return;
			}
			play_content.innerHTML="<object id='tvuplayer' width='100%' height="+screen_height+" align='center' classid='CLSID:3EA4FA88-E0BE-419A-A732-9B79B87A6ED0'><PARAM NAME='AffiliateID' VALUE="+AffiliateID+" ><PARAM NAME='PlayCallback' VALUE='onPlayCallback'><PARAM NAME='ControlBar' VALUE="+TVUControlBar+"><PARAM NAME='PopADDirection' VALUE='"+AdDir+"'></object><span id='loading'  style='display:none'>"+TVU_ShowInstallMsg+"</span>";
			if(!checkIsInstallTVU()){
				TVU_firstInstall();
			}else if(TVU_get_BuildVerNum()<1960){
				TVU_update();
			}else{
				TVU_autoplay()
			}
        }
	
     }else{//not ie and firefox
			 play_content.innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center'>We only support IE and FireFox in Windows, and Safari in Mac.</span>";			
			 return;
	 }
}else {   //other OS
  play_content.innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center'>We only support IE and FireFox in Windows, and Safari in Mac.</span>"
  return;
}
}
function TVU_init_activX(){
	play_content.innerHTML="<object id='tvuplayer' width='100%' height="+screen_height+" align='center' classid='CLSID:3EA4FA88-E0BE-419A-A732-9B79B87A6ED0'><PARAM NAME='AffiliateID' VALUE="+AffiliateID+" ><PARAM NAME='PlayCallback' VALUE='onPlayCallback'><PARAM NAME='ControlBar' VALUE="+TVUControlBar+"><PARAM NAME='PopADDirection' VALUE='"+AdDir+"'></object><span id='loading'  style='display:none'>"+TVU_ShowInstallMsg+"</span>";
}
function TVU_autoplay(){
	window.onload=function(){
	   if(auto_play){
	     return play(c)
	   }
	}
}

/*----------------------------------------------------------------------------\
|                                Slider 1.02                                  |
|-----------------------------------------------------------------------------|
| A  slider  control that  degrades  to an  input control  for non  supported |
| browsers.                                                                   |
|-----------------------------------------------------------------------------|
|                Copyright (c) Erik Arvidsson                                 |
|-----------------------------------------------------------------------------|
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License.  You may obtain a copy |
| of the License at http://www.apache.org/licenses/LICENSE-2.0                |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| Unless  required  by  applicable law or  agreed  to  in  writing,  software |
| distributed under the License is distributed on an  "AS IS" BASIS,  WITHOUT |
| WARRANTIES OR  CONDITIONS OF ANY KIND,  either express or implied.  See the |
| License  for the  specific language  governing permissions  and limitations |
| under the License.                                                          |
\----------------------------------------------------------------------------*/
Slider.isSupported = typeof document.createElement != "undefined" &&
	typeof document.documentElement != "undefined" &&
	typeof document.documentElement.offsetWidth == "number";


function Slider(oElement, oInput, sOrientation) {
	if (!oElement) return;
	this._orientation = sOrientation || "horizontal";
	this._range = new Range();
	this._range.setExtent(0);
	this._blockIncrement = 10;
	this._unitIncrement = 1;
	this._timer = new Timer(100);


	if (Slider.isSupported && oElement) {

		this.document = oElement.ownerDocument || oElement.document;

		this.element = oElement;
		this.element.slider = this;
		this.element.unselectable = "on";

		// add class name tag to class name
		this.element.className = this._orientation + " " + this.classNameTag + " " + this.element.className;

		// create line
		this.line = this.document.createElement("DIV");
		this.line.className = "line";
		this.line.unselectable = "on";
		this.line.appendChild(this.document.createElement("DIV"));
		this.element.appendChild(this.line);

		// create handle
		this.handle = this.document.createElement("DIV");
		this.handle.className = "handle";
		this.handle.unselectable = "on";
		this.handle.appendChild(this.document.createElement("DIV"));
		this.handle.firstChild.appendChild(
			this.document.createTextNode(String.fromCharCode(160)));
		this.element.appendChild(this.handle);
	}

	this.input = oInput;

	// events
	var oThis = this;
	this._range.onchange = function () {
		oThis.recalculate();
		if (typeof oThis.onchange == "function")
			oThis.onchange();
	};

	if (Slider.isSupported && oElement) {
		this.element.onfocus		= Slider.eventHandlers.onfocus;
		this.element.onblur			= Slider.eventHandlers.onblur;
		this.element.onmousedown	= Slider.eventHandlers.onmousedown;
		this.element.onmouseover	= Slider.eventHandlers.onmouseover;
		this.element.onmouseout		= Slider.eventHandlers.onmouseout;
		this.element.onkeydown		= Slider.eventHandlers.onkeydown;
		this.element.onkeypress		= Slider.eventHandlers.onkeypress;
		this.element.onmousewheel	= Slider.eventHandlers.onmousewheel;
		this.handle.onselectstart	=
		this.element.onselectstart	= function () { return false; };

		this._timer.ontimer = function () {
			oThis.ontimer();
		};

		// extra recalculate for ie
		window.setTimeout(function() {
			oThis.recalculate();
		}, 1);
	}
	else {
		this.input.onchange = function (e) {
			oThis.setValue(oThis.input.value);
		};
	}
}

Slider.eventHandlers = {

	// helpers to make events a bit easier
	getEvent:	function (e, el) {
		if (!e) {
			if (el)
				e = el.document.parentWindow.event;
			else
				e = window.event;
		}
		if (!e.srcElement) {
			var el = e.target;
			while (el != null && el.nodeType != 1)
				el = el.parentNode;
			e.srcElement = el;
		}
		if (typeof e.offsetX == "undefined") {
			e.offsetX = e.layerX;
			e.offsetY = e.layerY;
		}

		return e;
	},

	getDocument:	function (e) {
		if (e.target)
			return e.target.ownerDocument;
		return e.srcElement.document;
	},

	getSlider:	function (e) {
		var el = e.target || e.srcElement;
		while (el != null && el.slider == null)	{
			el = el.parentNode;
		}
		if (el)
			return el.slider;
		return null;
	},

	getLine:	function (e) {
		var el = e.target || e.srcElement;
		while (el != null && el.className != "line")	{
			el = el.parentNode;
		}
		return el;
	},

	getHandle:	function (e) {
		var el = e.target || e.srcElement;
		var re = /handle/;
		while (el != null && !re.test(el.className))	{
			el = el.parentNode;
		}
		return el;
	},
	// end helpers

	onfocus:	function (e) {
		var s = this.slider;
		s._focused = true;
		s.handle.className = "handle hover";
	},

	onblur:	function (e) {
		var s = this.slider
		s._focused = false;
		s.handle.className = "handle";
	},

	onmouseover:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);
		var s = this.slider;
		if (e.srcElement == s.handle)
			s.handle.className = "handle hover";
	},

	onmouseout:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);
		var s = this.slider;
		if (e.srcElement == s.handle && !s._focused)
			s.handle.className = "handle";
	},

	onmousedown:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);
		var s = this.slider;
		if (s.element.focus)
			s.element.focus();

		Slider._currentInstance = s;
		var doc = s.document;

		if (doc.addEventListener) {
			doc.addEventListener("mousemove", Slider.eventHandlers.onmousemove, true);
			doc.addEventListener("mouseup", Slider.eventHandlers.onmouseup, true);
		}
		else if (doc.attachEvent) {
			doc.attachEvent("onmousemove", Slider.eventHandlers.onmousemove);
			doc.attachEvent("onmouseup", Slider.eventHandlers.onmouseup);
			doc.attachEvent("onlosecapture", Slider.eventHandlers.onmouseup);
			s.element.setCapture();
		}

		if (Slider.eventHandlers.getHandle(e)) {	// start drag
			Slider._sliderDragData = {
				screenX:	e.screenX,
				screenY:	e.screenY,
				dx:			e.screenX - s.handle.offsetLeft,
				dy:			e.screenY - s.handle.offsetTop,
				startValue:	s.getValue(),
				slider:		s
			};
		}
		else {
			var lineEl = Slider.eventHandlers.getLine(e);
			s._mouseX = e.offsetX + (lineEl ? s.line.offsetLeft : 0);
			s._mouseY = e.offsetY + (lineEl ? s.line.offsetTop : 0);
			s._increasing = null;
			s.ontimer();
		}
	},

	onmousemove:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);

		if (Slider._sliderDragData) {	// drag
			var s = Slider._sliderDragData.slider;

			var boundSize = s.getMaximum() - s.getMinimum();
			var size, pos, reset;

			if (s._orientation == "horizontal") {
				size = s.element.offsetWidth - s.handle.offsetWidth;
				pos = e.screenX - Slider._sliderDragData.dx;
				reset = Math.abs(e.screenY - Slider._sliderDragData.screenY) > 100;
			}
			else {
				size = s.element.offsetHeight - s.handle.offsetHeight;
				pos = s.element.offsetHeight - s.handle.offsetHeight -
					(e.screenY - Slider._sliderDragData.dy);
				reset = Math.abs(e.screenX - Slider._sliderDragData.screenX) > 100;
			}
			s.setValue(reset ? Slider._sliderDragData.startValue :
						s.getMinimum() + boundSize * pos / size);
			return false;
		}
		else {
			var s = Slider._currentInstance;
			if (s != null) {
				var lineEl = Slider.eventHandlers.getLine(e);
				s._mouseX = e.offsetX + (lineEl ? s.line.offsetLeft : 0);
				s._mouseY = e.offsetY + (lineEl ? s.line.offsetTop : 0);
			}
		}

	},

	onmouseup:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);
		var s = Slider._currentInstance;
		var doc = s.document;
		if (doc.removeEventListener) {
			doc.removeEventListener("mousemove", Slider.eventHandlers.onmousemove, true);
			doc.removeEventListener("mouseup", Slider.eventHandlers.onmouseup, true);
		}
		else if (doc.detachEvent) {
			doc.detachEvent("onmousemove", Slider.eventHandlers.onmousemove);
			doc.detachEvent("onmouseup", Slider.eventHandlers.onmouseup);
			doc.detachEvent("onlosecapture", Slider.eventHandlers.onmouseup);
			s.element.releaseCapture();
		}

		if (Slider._sliderDragData) {	// end drag
			Slider._sliderDragData = null;
		}
		else {
			s._timer.stop();
			s._increasing = null;
		}
		Slider._currentInstance = null;
	},

	onkeydown:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);
		//var s = Slider.eventHandlers.getSlider(e);
		var s = this.slider;
		var kc = e.keyCode;
		switch (kc) {
			case 33:	// page up
				s.setValue(s.getValue() + s.getBlockIncrement());
				break;
			case 34:	// page down
				s.setValue(s.getValue() - s.getBlockIncrement());
				break;
			case 35:	// end
				s.setValue(s.getOrientation() == "horizontal" ?
					s.getMaximum() :
					s.getMinimum());
				break;
			case 36:	// home
				s.setValue(s.getOrientation() == "horizontal" ?
					s.getMinimum() :
					s.getMaximum());
				break;
			case 38:	// up
			case 39:	// right
				s.setValue(s.getValue() + s.getUnitIncrement());
				break;

			case 37:	// left
			case 40:	// down
				s.setValue(s.getValue() - s.getUnitIncrement());
				break;
		}

		if (kc >= 33 && kc <= 40) {
			return false;
		}
	},

	onkeypress:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);
		var kc = e.keyCode;
		if (kc >= 33 && kc <= 40) {
			return false;
		}
	},

	onmousewheel:	function (e) {
		e = Slider.eventHandlers.getEvent(e, this);
		var s = this.slider;
		if (s._focused) {
			s.setValue(s.getValue() + e.wheelDelta / 120 * s.getUnitIncrement());
			// windows inverts this on horizontal sliders. That does not
			// make sense to me
			return false;
		}
	}
};



Slider.prototype.classNameTag = "dynamic-slider-control",

Slider.prototype.setValue = function (v) {
	this._range.setValue(v);
	this.input.value = this.getValue();
};

Slider.prototype.getValue = function () {
	return this._range.getValue();
};

Slider.prototype.setMinimum = function (v) {
	this._range.setMinimum(v);
	this.input.value = this.getValue();
};

Slider.prototype.getMinimum = function () {
	return this._range.getMinimum();
};

Slider.prototype.setMaximum = function (v) {
	this._range.setMaximum(v);
	this.input.value = this.getValue();
};

Slider.prototype.getMaximum = function () {
	return this._range.getMaximum();
};

Slider.prototype.setUnitIncrement = function (v) {
	this._unitIncrement = v;
};

Slider.prototype.getUnitIncrement = function () {
	return this._unitIncrement;
};

Slider.prototype.setBlockIncrement = function (v) {
	this._blockIncrement = v;
};

Slider.prototype.getBlockIncrement = function () {
	return this._blockIncrement;
};

Slider.prototype.getOrientation = function () {
	return this._orientation;
};

Slider.prototype.setOrientation = function (sOrientation) {
	if (sOrientation != this._orientation) {
		if (Slider.isSupported && this.element) {
			// add class name tag to class name
			this.element.className = this.element.className.replace(this._orientation,
									sOrientation);
		}
		this._orientation = sOrientation;
		this.recalculate();

	}
};

Slider.prototype.recalculate = function() {
	if (!Slider.isSupported || !this.element) return;

	var w = this.element.offsetWidth;
	var h = this.element.offsetHeight;
	var hw = this.handle.offsetWidth;
	var hh = this.handle.offsetHeight;
	var lw = this.line.offsetWidth;
	var lh = this.line.offsetHeight;

	// this assumes a border-box layout

	if (this._orientation == "horizontal") {
		this.handle.style.left = (w - hw) * (this.getValue() - this.getMinimum()) /
			(this.getMaximum() - this.getMinimum()) + "px";
		this.handle.style.top = (h - hh) / 2 + "px";

		this.line.style.top = (h - lh) / 2 + "px";
		this.line.style.left = hw / 2 + "px";
		this.line.style.width = Math.max(0, w - hw - 2)+ "px";
		this.line.firstChild.style.width = Math.max(0, w - hw - 4)+ "px";
	}
	else {
		this.handle.style.left = (w - hw) / 2 + "px";
		this.handle.style.top = h - hh - (h - hh) * (this.getValue() - this.getMinimum()) /
			(this.getMaximum() - this.getMinimum()) + "px";

		this.line.style.left = (w - lw) / 2 + "px";
		this.line.style.top = hh / 2 + "px";
		this.line.style.height = Math.max(0, h - hh - 2) + "px";	//hard coded border width
		this.line.firstChild.style.height = Math.max(0, h - hh - 4) + "px";	//hard coded border width
	}
};

Slider.prototype.ontimer = function () {
	var hw = this.handle.offsetWidth;
	var hh = this.handle.offsetHeight;
	var hl = this.handle.offsetLeft;
	var ht = this.handle.offsetTop;

	if (this._orientation == "horizontal") {
		if (this._mouseX > hl + hw &&
			(this._increasing == null || this._increasing)) {
			this.setValue(this.getValue() + this.getBlockIncrement());
			this._increasing = true;
		}
		else if (this._mouseX < hl &&
			(this._increasing == null || !this._increasing)) {
			this.setValue(this.getValue() - this.getBlockIncrement());
			this._increasing = false;
		}
	}
	else {
		if (this._mouseY > ht + hh &&
			(this._increasing == null || !this._increasing)) {
			this.setValue(this.getValue() - this.getBlockIncrement());
			this._increasing = false;
		}
		else if (this._mouseY < ht &&
			(this._increasing == null || this._increasing)) {
			this.setValue(this.getValue() + this.getBlockIncrement());
			this._increasing = true;
		}
	}

	this._timer.start();
};

/*----------------------------------------------------------------------------\
|                                 Timer Class                                 |
|-----------------------------------------------------------------------------|
| Object Oriented Encapsulation  of setTimeout  fires ontimer when the  timer |
| is triggered. Does not work in IE 5.00                                      |
\----------------------------------------------------------------------------*/

function Timer(nPauseTime) {
	this._pauseTime = typeof nPauseTime == "undefined" ? 1000 : nPauseTime;
	this._timer = null;
	this._isStarted = false;
}

Timer.prototype.start = function () {
	if (this.isStarted())
		this.stop();
	var oThis = this;
	this._timer = window.setTimeout(function () {
		if (typeof oThis.ontimer == "function")
			oThis.ontimer();
	}, this._pauseTime);
	this._isStarted = false;
};

Timer.prototype.stop = function () {
	if (this._timer != null)
		window.clearTimeout(this._timer);
	this._isStarted = false;
};

Timer.prototype.isStarted = function () {
	return this._isStarted;
};

Timer.prototype.getPauseTime = function () {
	return this._pauseTime;
};

Timer.prototype.setPauseTime = function (nPauseTime) {
	this._pauseTime = nPauseTime;
};

/*----------------------------------------------------------------------------\
|                                Range Class                                  |
|-----------------------------------------------------------------------------|
| Used to  model the data  used  when working  with  sliders,  scrollbars and |
| progress bars.  Based  on  the  ideas of  the javax.swing.BoundedRangeModel |
| interface  defined  by  Sun  for  Java;   http://java.sun.com/products/jfc/ |
| swingdoc-api-1.0.3/com/sun/java/swing/BoundedRangeModel.html                |
\----------------------------------------------------------------------------*/


function Range() {
	this._value = 0;
	this._minimum = 0;
	this._maximum = 100;
	this._extent = 0;

	this._isChanging = false;
}

Range.prototype.setValue = function (value) {
	value = Math.round(parseFloat(value));
	if (isNaN(value)) return;
	if (this._value != value) {
		if (value + this._extent > this._maximum)
			this._value = this._maximum - this._extent;
		else if (value < this._minimum)
			this._value = this._minimum;
		else
			this._value = value;
		if (!this._isChanging && typeof this.onchange == "function")
			 this.onchange();
	}
};

Range.prototype.getValue = function () {
	return this._value;
};

Range.prototype.setExtent = function (extent) {
	if (this._extent != extent) {
		if (extent < 0)
			this._extent = 0;
		else if (this._value + extent > this._maximum)
			this._extent = this._maximum - this._value;
		else
			this._extent = extent;
		if (!this._isChanging && typeof this.onchange == "function")
			this.onchange();
	}
};

Range.prototype.getExtent = function () {
	return this._extent;
};

Range.prototype.setMinimum = function (minimum) {
	if (this._minimum != minimum) {
		var oldIsChanging = this._isChanging;
		this._isChanging = true;

		this._minimum = minimum;

		if (minimum > this._value)
			this.setValue(minimum);
		if (minimum > this._maximum) {
			this._extent = 0;
			this.setMaximum(minimum);
			this.setValue(minimum)
		}
		if (minimum + this._extent > this._maximum)
			this._extent = this._maximum - this._minimum;

		this._isChanging = oldIsChanging;
		if (!this._isChanging && typeof this.onchange == "function")
			this.onchange();
	}
};

Range.prototype.getMinimum = function () {
	return this._minimum;
};

Range.prototype.setMaximum = function (maximum) {
	if (this._maximum != maximum) {
		var oldIsChanging = this._isChanging;
		this._isChanging = true;

		this._maximum = maximum;

		if (maximum < this._value)
			this.setValue(maximum - this._extent);
		if (maximum < this._minimum) {
			this._extent = 0;
			this.setMinimum(maximum);
			this.setValue(this._maximum);
		}
		if (maximum < this._minimum + this._extent)
			this._extent = this._maximum - this._minimum;
		if (maximum < this._value + this._extent)
			this._extent = this._maximum - this._value;

		this._isChanging = oldIsChanging;
		if (!this._isChanging && typeof this.onchange == "function")
			this.onchange();
	}
};

Range.prototype.getMaximum = function () {
	return this._maximum;
};

/*----------------------------------------check.js--------------------------------------------*/

function checkIsInstallTVU() {
	return checkPlugins("TVU Web Player for FireFox","TVUAx.TVUAxCtrl.1");
}
function checkPlugins(pluginsName, activexObjectName) { 
    //ActiveXObject name 
    if (activexObjectName == '') activexObjectName = pluginsName + "." + pluginsName; 
    
    var np = navigator.plugins; 
    // firefox 
    if (np && np.length) { 
        for(var i = 0; i < np.length; i ++) { 
		    if(np[i].name.indexOf(pluginsName) != -1) return true; 
        } 
        return false; 
    } 
    // IE 
    else if (window.ActiveXObject) { 
        try { 
            var axobj =eval("new ActiveXObject(activexObjectName);"); 
            return axobj ? true : false; 
        } catch (e) { 
            return false; 
        } 
    } else { 
        return false; 
    } 
}


function closeObj(id)
{ 
   var obj=document.getElementById(id)
   if(obj!=null&&obj!="undefinded"&&obj.style.display!="none"){obj.style.display="none";}
}
function showObj(id)
{ 
	var obj=document.getElementById(id)
   if(obj!=null&&obj!="undefinded"&&obj.style.display=="none"){
	   obj.style.display="inline";
	   }
}
function TVU_get_BuildVerNum(){
	try{
		if(tvu()){
	      //alert(tvu().get_BuildVerNum()+","+typeof(tvu().get_BuildVerNum()));
		  return tvu().get_BuildVerNum()
	    }
		return 0
	}catch(e){return 0}
}
function TVU_firstInstall(){
	var t;
	if(!checkIsInstallTVU()){//not install tvu
		 showObj("loading")
		 closeObj("tvuplayer")
		 t=setTimeout("TVU_firstInstall()",5000)
	 }else{
		 clearTimeout(t)
		 showObj("tvuplayer")
		 closeObj("loading")
		 play_content.innerHTML="<object id='tvuplayer' width='100%' height="+screen_height+" align='center' classid='CLSID:3EA4FA88-E0BE-419A-A732-9B79B87A6ED0'><PARAM NAME='AffiliateID' VALUE="+AffiliateID+" ><PARAM NAME='PlayCallback' VALUE='onPlayCallback'><PARAM NAME='ControlBar' VALUE="+TVUControlBar+"><PARAM NAME='PopADDirection' VALUE='"+AdDir+"'></object><span id='loading'  style='display:none'>"+TVU_ShowInstallMsg+"</span>";
		if(auto_play){
	     return play(c)
	   }                         
	 }
}
function TVU_update(){
	 document.getElementById("play_content").innerHTML="<span id='loading'>"+TVU_ShowInstallUpdateMsg+"</span>";
}
 function isLoading(){//ie
             var t;
			 //alert(TVU_get_BuildVerNum())
			 if(!checkIsInstallTVU()){//not install tvu		
			    //if(loadingTime<loadOutTime){
					 showObj("loading")
					 closeObj("tvuplayer")
				//	 loadingTime++;
			         t=setTimeout("isLoading()",1000)
					// document.getElementById("play_content").innerHTML=TVU_ShowInstallMsg
			    // }else{
					//play_content.innerHTML="<object id='tvuplayer' width='100%' height="+screen_height+" align='center' classid='CLSID:3EA4FA88-E0BE-419A-A732-9B79B87A6ED0'><PARAM NAME='AffiliateID' VALUE="+AffiliateID+" ><PARAM NAME='PlayCallback' VALUE='onPlayCallback'><PARAM NAME='ControlBar' VALUE="+TVUControlBar+"><PARAM NAME='PopADDirection' VALUE='"+AdDir+"'></object><span id='loading'  style='display:none'>"+TVU_ShowInstallMsg+"</span>";
					  //document.getElementById("play_content").innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center;' id='loading'>A problem may be encountered during the installation. click <a href='http://pages.tvunetworks.com/downloads/player.html' target='blank'>HERE</a> to download TVUPlayer.</span>"
				//	 clearTimeout(t)
			    // }
			 }else{
				 clearTimeout(t)
				 //showObj("tvuplayer")
				 //closeObj("loading")
				 play_content.innerHTML="<object id='tvuplayer' width='100%' height="+screen_height+" align='center' classid='CLSID:3EA4FA88-E0BE-419A-A732-9B79B87A6ED0'><PARAM NAME='AffiliateID' VALUE="+AffiliateID+" ><PARAM NAME='PlayCallback' VALUE='onPlayCallback'><PARAM NAME='ControlBar' VALUE="+TVUControlBar+"><PARAM NAME='PopADDirection' VALUE='"+AdDir+"'></object><span id='loading'  style='display:none'>"+TVU_ShowInstallMsg+"</span>";
				if(auto_play){
				   return play(c)
				 }
				// window.location.replace(location.href)	                         
			 }
			 
		 }
		 
 function isLoadingF(){//firefox
		var t
		if(!checkIsInstallTVU()){//not install tvu
			//if(loadingTime<loadOutTime){
			   //document.getElementById("play_content").innerHTML="<span id='loading'>"+TVU_ShowInstallMsg+"</span>";
			//   loadingTime++;
			   t=setTimeout("isLoadingF()",1000)
			//}else{
			   /*document.getElementById("play_content").innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center;' id='loading'>A problem may be encountered during the installation. click <a href='http://pages.tvunetworks.com/downloads/player.html' target='blank'>HERE</a> to download TVUPlayer.</span>"*/
			 //  clearTimeout(t)
			//}
		}else{
			play_content.innerHTML="<embed id='tvuplayer' type='application/x-tvuplayer-plugin' width='100%' height="+screen_height+" pluginspage='http://wwww.tvunetworks.com/downloads/player.html' AffiliateID="+AffiliateID+" ControlBar="+TVUControlBar+" PlayCallback='onPlayCallback'  PopADDirection='"+AdDir+"' />"
			if(auto_play){
			   return play(c)
			 }
			clearTimeout(t)				 
		}
}		 

/*--------------------------------------action.js----------------------------------------------*/
BrowserDetect.init();
if(style!=undefined){
	if(style=="0"){
		if(c) tvuplayerX(c,w,h);
	}else{
		initPlayer()
	} 
    if(style!="2"&BrowserDetect.OS=="Mac"){
	  tvu().ShowStatus=false
    }
	try{
	  if(StreamPort){
		 tvu().StreamPort=StreamPort;
	  }
	}catch(e){
		
	}
	/*window.onload =function(){
	  if(auto_play){
        return play(c)
	  }
    }*/
}

/*------------------------------------------old--------------------------------------------------*/

function tvuplayerX(channel,width,height){
	if(!channel)return;
	if(width<200)
		width=200;
	if(height<150)
		height=150;
	c=channel
	w=width
	h=height-24
	document.write('<div  style="width:'+width+'px;height:'+height+'px;margin:0;">');
	document.write('<table border="0" cellpadding="0" cellspacing="0" align="center" width='+width+'>');
	document.write('<tr  height='+h+'><td width='+width+'height='+h+ ' align="center" id="play_content"><div id="Dtvu" style="display:none" ></div><table width="'+width+'" height="'+h+ '" align="center" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor="#000000" id="TMsg"><tr><td align="center" id="loading"  bgcolor="#000000" width=100% height=100%></td></tr></table></td></tr>');
	document.write('<tr><td height="24" align="center" bgcolor="#000000">');
	document.write('<img border="0" style="cursor: hand" src="http://dl.tvunetworks.com/webplayer/images/play.gif" alt="Play" onclick="play('+c+')" width="32" height="20">');
    document.write('<img border="0" style="cursor: hand" src="http://dl.tvunetworks.com/webplayer/images/stop.gif" alt="Stop" onclick="stopO()" width="32" height="20">');
    document.write('<img border="0" style="cursor: hand" src="http://dl.tvunetworks.com/webplayer/images/refresh.gif" alt="Refresh" onclick="refresh()" width="32" height="20">');
    document.write('<img border="0" style="cursor: hand" src="http://dl.tvunetworks.com/webplayer/images/mute.gif" alt="Mute" onclick="muteO()" width="32" height="20">');
    document.write('<img border="0" style="cursor: hand" src="http://dl.tvunetworks.com/webplayer/images/volumeup.gif" alt="Volume Up" onclick="vup()" width="32" height="20">');
    document.write('<img border="0" style="cursor: hand" src="http://dl.tvunetworks.com/webplayer/images/volumedown.gif" alt="Volume Down" onclick="vdown()" width="32" height="20">');
 	document.write('</td></tr></table></div>');	
	var loading=document.getElementById("loading")
	var Dtvu=document.getElementById("Dtvu")
	TVU_MsgInit();
if(BrowserDetect.OS=="Mac"){//Mac
	if(BrowserDetect.browser=="Safari"){
		showObj("Dtvu")
		closeObj("TMsg")
		Dtvu.innerHTML="<embed id='tvuplayer'  width="+width+" height="+h+"  srcURL=\"/sample_videos/bao.wmv\" pluginspage="+macPluginSrc+" type=\"application/x-tvuplayer-plugin\"></embed>";
		var plugin = navigator.plugins["TVU Web Player for Safari"];
		
		if(plugin){
		    var desc = plugin.description;
			if(desc.indexOf("1.1.4")<0){
				location.href=macPluginSrc;
			}else{
				TVU_autoplay()
			}
		}				
	}else if(BrowserDetect.browser=="Firefox"){
		 var plugin = navigator.plugins["TVU Web Player for Firefox"];
		 if(plugin){
			    var desc = plugin.description;
			    if(desc.indexOf("1.1.4")<0) { 
			         InstallTrigger.install({'TVU Web Player for Firefox':macPluginSrcFF});
			         if(!checkIsInstallTVU()){
				        isLoadingFO()
				     }        
			     }else {
					 showObj("Dtvu")
				     closeObj("TMsg")
				     Dtvu.innerHTML="<embed id='tvuplayer' type='application/x-tvuplayer-plugin' width="+ width +"  height="+h+" pluginspage='http://wwww.tvunetworks.com/downloads/player.html' AffiliateID="+AffiliateID+" />"	
					 TVU_autoplay()
			     }
		   }else{
			    InstallTrigger.install({'TVU Web Player for Firefox':macPluginSrcFF});
			    if(!checkIsInstallTVU()){
				    isLoadingFO()
				}
		   } 
	}else{
		showObj("TMsg")
		closeObj("Dtvu")
		loading.innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center'>TVU plug-in supports Safari and FireFox on Intel Mac 10.5.x only.</span>";
	}
}else if(BrowserDetect.OS=="Windows"){//windows
  if(BrowserDetect.browser=="Firefox"||BrowserDetect.browser=="Explorer"){// ie and firefox
	
	if(BrowserDetect.browser=="Firefox"){
		
		var plugin = navigator.plugins["TVU Web Player for FireFox"];
		if(plugin){
			var desc = plugin.description;
			if(!isNew(desc,'2,5,2,2'))
			{
				 document.getElementById("loading").innerHTML=TVU_ShowInstallUpdateMsg;
				 //isLoadingFO()
			}
			else{
				 showObj("Dtvu")
				 closeObj("TMsg")
				 Dtvu.innerHTML='<embed id="tvuplayer" type="application/x-tvuplayer-plugin" width="' + width + '" height="' + h + '" pluginspage="http://wwww.tvunetworks.com/downloads/player.html" AffiliateID='+AffiliateID+'  PopADDirection="'+AdDir+'"  />';
				 if(auto_play){
				   return play(c)
				 }
			}
		}else{
			 document.getElementById("loading").innerHTML=TVU_ShowInstallMsg;
			 //isLoadingFO()
		}
	}else if(BrowserDetect.browser=="Explorer"){
		if(TVU_WMP_TestVersion<9){
				Dtvu.innerHTML=TVU_WMPDetecMsg;
				return;
		 }
		showObj("Dtvu")
	    closeObj("TMsg")
		Dtvu.innerHTML="<object classid='clsid:3EA4FA88-E0BE-419A-A732-9B79B87A6ED0' id='tvuplayer'  align='center' width='" + width + "' height='" + h +"' ><PARAM NAME='AffiliateID' VALUE="+AffiliateID+"><PARAM NAME='PopADDirection' VALUE='"+AdDir+"'></object>";
		if(!checkIsInstallTVU()){
			showObj("TMsg")
			closeObj("Dtvu")
			document.getElementById("loading").innerHTML=TVU_ShowInstallMsg;
		    isLoadingO()
		}else if(TVU_get_BuildVerNum()<1960){
			showObj("TMsg")
			closeObj("Dtvu")
			document.getElementById("loading").innerHTML=TVU_ShowInstallUpdateMsg;
		}else{
			TVU_autoplay()
		}
	}
  }else{//not ie and firefox
        showObj("TMsg")
		closeObj("Dtvu")
		loading.innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center'>We only support IE and FireFox in Windows, and Safari in Mac.</span>";			
  }
}else {//other OS
  loading.innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center'>We only support IE and FireFox in Windows, and Safari in Mac.</span>"
  return;
}

}

function isLoadingO(){//ie for old version
			 if(!checkIsInstallTVU()){//not install tvu
					 loadingTime++;
					 showObj("TMsg")
					 closeObj("Dtvu")
					 var t=setTimeout("isLoadingO()",1000)
			 }
			 else{
				 clearTimeout(t)
				 showObj("Dtvu")
				 closeObj("TMsg")
				 Dtvu.innerHTML="<object classid='clsid:3EA4FA88-E0BE-419A-A732-9B79B87A6ED0' id='tvuplayer'  align='center' width='" + w + "' height='" + h +"' ><PARAM NAME='AffiliateID' VALUE="+AffiliateID+"><PARAM NAME='PopADDirection' VALUE='"+AdDir+"'></object>";
				 if(auto_play){
				   return play(c)
				 }           
			 }
		 }
		 
 function isLoadingFO(){//firefox for old version
			 if(!checkIsInstallTVU()){//not install tvu
			    if(loadingTime<loadOutTime){
					 
					 loadingTime++;
					 var t=setTimeout("isLoadingFO()",1000)
				}else{
					 /*document.getElementById("loading").innerHTML="<span style='color:#0099CC; font-size:14px; font-weight:bold;text-align:center;' id='loading'>A problem may be encountered during the installation. click <a href='http://pages.tvunetworks.com/downloads/player.html' target='blank'>HERE</a> to download TVUPlayer.</span>"*/
					 clearTimeout(t)
				}
			 }
			 else{
				 clearTimeout(t)				 
			 }
		 }		 
function stopO(channel)
{
  tvu().Stop();
}		
function playO(channel,waitforchannel,timeout)
{
	try{
		var showurl="tvup://ps3.tvunetworks.com:3940/"+channel+".0.0.0";
    	tvu().Stop();
     	tvu().Play(showurl);
	}catch(e){
	}	
}

function muteO()
{
  	if(!get_Mute()){
		put_Mute(true);
	}
	else
	{
		put_Mute(false);
	}
}

function vup()
{
  	var nVol = get_Volume() + 15;

	if(nVol >= 100)
		put_Volume(100);
	else
		put_Volume(nVol);
}

function vdown()
{
  	var nVol = get_Volume() - 15;
	if(nVol <= 0)
		put_Volume(0);
	else
		put_Volume(nVol);
}

function isNew(userVersion,newVersion)
{
   var v1=userVersion.split(',').join("");
   var v2=newVersion.split(',').join("");

   if(parseInt(v1)>=parseInt(v2)){
	  return true;   
   }
   return false;  
}
function open_new_window(url){
	window.open(url,"theNewWindow","width=650,height=600,location=no,menubar=no,resizable=yes,scrollbars=yes,screenX=175,screenY=175,status=no,toolbar=no")
}
function TVU_installCheckit(){
	if(document.getElementById("TVU_checkBox").checked){
		document.getElementById("InstallBtn").innerHTML="<a href='javascript:void(0);' target='_self' onclick='TVU_download();TVU_installLoading()'><img src='http://pages.tvunetworks.com/webplayer/images/install_btn.gif' alt='install now' title='install now' border=0></a>";
	}else{
       document.getElementById("InstallBtn").innerHTML="<a href='javascript:void(0);' onclick='TVU_Msg()'><img src='http://pages.tvunetworks.com/webplayer/images/install_btn.gif' alt='install now' title='install now' border=0></a>";	
	}
}
function TVU_installLoading(){
	document.getElementById("TVU_checkBox").disabled="disabled";
	document.getElementById("InstallBtn").innerHTML='<div style="background:#000; margin:0 auto; height:25px; width:250px; padding-bottom:10px;"><img src="'+imgSrc+'images/ad_loading.gif"></div>'
}
function TVU_download(){
    window.location.href="http://dl.tvunetworks.com/PluginInstaller.exe";	
}
function TVU_Msg(){
	alert("You need to agree to TVU terms of service to install.")
}