var isPlayer = "";
var isList = "";
var isSetup = false;
var isTimeOut = 5000;
var codeUrl = "http://download.pplive.com/webinstall/install.CAB#version=";
var thisVersion = "1.2.33.1108";
var codeVer = "1,2,33,0";
var isReload = 0;
function $(){
	return document.getElementById(arguments[0]);
}
function ocxstatus(){
	var SynaObj;
	try{
		SynaObj = new ActiveXObject("Synacast.EWA");
		var thisVers = SynaObj.version;
		if (typeof SynaObj != "undefined"){
			if(thisVers == thisVersion){
				getPPLive();
			}else if(!isSetup && loadMethod){
				isSetup = true;
				getPPLive();
				setTimeout(ocxstatus,isTimeOut);
			}else{
				setTimeout(ocxstatus,isTimeOut);	
			}
		}
	}catch(e){
		if(!isSetup && loadMethod){
			isSetup = true;
			getPPLive();
		}
		setTimeout(ocxstatus,isTimeOut);
	}
}
function getPPLive(){
	try{
		$("player").Destroy();
		$("list").Destroy();
	}catch(e){}
	var pplive = '<object id="player" style="width:'+parentSize(pplPlayer,"wid")
				+'px; height:'+parentSize(pplPlayer,"high")
				+'px;" classid="CLSID:18226BF8-DC0B-4D81-80E9-A41AE37BB73A" '
				+'codebase="'+codeUrl+codeVer+'">'
				+ isPlayer + '</object>';
	$(pplPlayer).innerHTML = pplive;
	if(pplList && $("player").PlayerHWnd){
		var listArea = '<object id="list" style="width:'+parentSize(pplList,"wid")
						+'px; height:'+parentSize(pplList,"high")
						+'px;" classid="CLSID:70CACCCA-8B83-4BCB-B2D1-188E9A495527">'
						+ isList +'</object>';
		$(pplList).innerHTML = listArea;
		$("list").PlayerHWnd = $("player").PlayerHWnd;
	}
	if(ppliveurl){
		try{$("player").URL = ppliveurl;}catch(e){}
	}
}
function addMode(ModeName,ModeValue,ModeObj){
	var modestyle = '<param name="'+ ModeName +'" value="'+ ModeValue +'" />';
	if (ModeObj == 1){
		isPlayer += modestyle;
	}else if(ModeObj == 2){
		isList += modestyle;
	}
}
function parentSize(obj,method){
	if(method == "wid"){
		return $(obj).offsetWidth;
	}else if(method == "high"){
		return $(obj).offsetHeight;
	}	
}
window.onunload=function(){
	$("player").Destroy();
	$("list").Destroy();
}
