﻿var langType;
if(!langType){
	langType="en"
}
function loadA(){
	var tp = tvu();
	if(!tp) return;
	try{
	tp.SetTVGuideUrl(getA());
	}catch(err){		
	}
}

function onPlayCallback(s,ec){
	if(ec == 3){
		showObj("PlayCallback");
		if(langType=="en"){
	          document.getElementById("PlayCallback").innerHTML="<div style='margin:13px auto; width:410px;'>To watch this channel, you must sign in and subscribe it. Do you want to sign in now?</div><div style='margin:20px auto; width:200px;'><div style='float:left;background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; line-height:27px; height:27px;'><a href='javascript:openLogin()' class='auplay_btn'>OK</a></div><div style='background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; height:27px;float:right; line-height:27px;'><a href='javascript:closeObj(\"PlayCallback\")' class='auplay_btn'>Cancel</a></div></div>"
		   }else if(langType=="zh") {
			  document.getElementById("PlayCallback").innerHTML="<div style='margin:13px auto; width:410px; '>您必须登录并且订阅才能观看这个频道。<br> 您现在需要登录吗?</div><div style='margin:20px auto; width:200px;'><div style='float:left;background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; line-height:25px; height:25px;'><a href='javascript:openLogin()' class='auplay_btn'>确定</a></div><div style='background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; height:27px;float:right; line-height:27px;'><a href='javascript:closeObj(\"PlayCallback\")' class='auplay_btn'>取消</a></div></div>"
		   }
		
	} else if(ec == 4) {
		showObj("PlayCallback");
		if(langType=="en"){
		   document.getElementById("PlayCallback").innerHTML="<div style='margin:13px auto; width:410px;'>This channel is only available to subscribers. Are you interested in becoming a subscriber?</div><div style='margin:20px auto; width:200px;'><div style='float:left;background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; line-height:27px; height:27px;text-align:center;'><a target='_blank' href='http://pages.tvunetworks.com/viewers/tvutos.jsp?c=" +s+"' onclick='closeObj(\"PlayCallback\")' class='auplay_btn'>OK</a></div><div style='background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; height:27px;float:right; line-height:27px;'><a href='javascript:closeObj(\"PlayCallback\")' class='auplay_btn'>Cancel</a></div><div>"
		 }else if(langType=="zh") {
			 document.getElementById("PlayCallback").innerHTML="<div style='margin:13px auto; width:410px;'>您需要订阅才能观看这个频道。<br> 您有兴趣订阅吗?</div><div style='margin:20px auto; width:200px;'><div style='float:left;background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; line-height:25px; height:25px;text-align:center;'><a target='_blank' href='http://pages.tvunetworks.com/viewers/tvutos.jsp?c=" +s+"' onclick='closeObj(\"PlayCallback\")' class='auplay_btn'>确定</a></div><div style='background:url(http://pages.tvunetworks.com/images/broadcast/button_bg.png); width:80px; height:27px;float:right; line-height:27px;'><a href='javascript:closeObj(\"PlayCallback\")' class='auplay_btn'>取消</a></div><div>"
		 }
	}	
}
function openLogin(){
	document.getElementById("loginFrame").src="http://pages.tvunetworks.com/accounts/viewLoginl.do?referer=s.html";
	document.getElementById("login_w").style.display = "block";
	document.getElementById("login_w_b").style.display = "block";
	closeObj("PlayCallback")
}
function logout(){
	document.getElementById("loginFrame").src="http://pages.tvunetworks.com/accounts/logoutP.do?referer=s.html";
}

function closeLoginW(){
	document.getElementById("login_w").style.display = "none";
	document.getElementById("login_w_b").style.display = "none";
	document.getElementById("loginFrame").src="about:blank";
}


function refreshAccountStatus(){
	reloadSc("assc","http://pages.tvunetworks.com/accounts/accountStatusSmallAx.jsp");
}

function resetAStatus(){
	var tp = tvu();
	tp.SetTVGuideUrl(getA());	
	var at = accountStatusTableBuild();
	document.getElementById("accountStatus").innerHTML =at ;
}

function reloadSc(emId,url){
	var el = document.getElementById(emId);
	var p=el.parentNode;
	//delete
	if(el != null && el != 'undefine'){
		var p=el.parentNode;
		p.removeChild(el);
	}
	var newSc=document.createElement('script');
	newSc.setAttribute('src',url);   
	newSc.id=emId; 
	newSc.DEFER="defer";
	var done = false;
	newSc.onload= newSc.onreadystatechange = function(){
		if ( !done && (!this.readyState || 
				this.readyState == "loaded" || this.readyState == "complete")){
			done=true;
			resetAStatus();
		}
	};
	p.appendChild(newSc);

}
