// Switch Express video player interface module
// All rights reserved

function SMGAddEvent(obj,evType,fn)
{
	if(evType == "ready"){SMGAddReady(SMGOnLoad);}
	else
	{
		if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}
		else if(obj.attachEvent) {var r=obj.attachEvent("on"+evType,fn);return r;}
		else{return false;}
	}
}

var _SMGAjaxQueue = new Array();
function SMGAjax(js)
{
	js = js.replace(/%26/g, "&");
	js = js.replace(/%25/g, "%");
	js = js.replace(/%22/g, '"');
	
	// must use a timeout so that FireBug picks up the errors again.
	_SMGAjaxQueue.push(js);
	
	window.setTimeout("window.eval(_SMGAjaxProcessQueue());",1);
}

function _SMGAjaxProcessQueue()
{
	//alert('queue: '+_SMGAjaxQueue.length );
	while(_SMGAjaxQueue.length > 0)
	{
		var ajax = _SMGAjaxQueue.shift();
		SMGTrace("SMGAjax: shifting ajax from queue ("+ _SMGAjaxQueue.length+") " + ajax.substr(0,32));
		window.eval(ajax);
	}
}

function SMGTrace(msg)
{
	if(!_SMGDebug)
		return;
		
	var ele = document.getElementById("SMGTrace");
	
	if(ele != null)
		ele.innerHTML = ele.innerHTML + '<br />' +msg;
}
var _SMGDebug = false;
function SMGSetDebug(state)
{
	_SMGDebug=state;	
}

/* track a list of functions that are waiting for the proxy object,
when it cann SMGProxyLoaded then each function is run in turn */
var _proxyCallbacks;
var _proxyObjs;
var _proxyCheckInt;
var _proxyLoaded = false;
var _proxyLoading = false;
var _proxy_url = '/plugin/smgproxy.swf'

function SMGProxyURL(url)
{
	_proxy_url = url;
}
function SMGWaitForProxy(func,obj)
{
	if(_proxyLoaded)
		return true;
	
	SMGTrace('PROXY: proxy not loaded yet ');
	if(!_proxyCallbacks || _proxyCallbacks.length == 0)
	{
		_proxyCallbacks = new Array();
		_proxyObjs = new Array();
	}
	
	_proxyCallbacks.push(func);
	_proxyObjs.push(obj);

	SMGWriteProxy(); // Add proxy to DOM if it isn't already in progress
	return false;
}

function _isSMGProxyLoaded()
{
	SMGTrace('PROXY loaded, calling pending call backs');
			
	while(!_proxyCallbacks || _proxyCallbacks.length > 0)
	{
		
		funcs = _proxyCallbacks.pop();
		objs = _proxyObjs.pop();
		
		SMGTrace('PROXY calling function');
		var obj = objs['obj']
		var func = funcs['callback']
	
		obj[func]();
	}	
}

function SMGProxyLoaded()
{
	SMGTrace('PROXY: proxy loaded running, passing on events');
	_proxyLoaded=true;
	window.setTimeout("_isSMGProxyLoaded();",1);
}


function SMGWriteProxy()
{
	
	if(!document.getElementById('smgproxyholder')!=undefined)
	{
		SMGTrace("PROXY: element smgproxyholder does not exist - adding");
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id','smgproxyholder');
		document.body.appendChild(newdiv);
	}
	
	if(!document.getElementById('smgproxy')!=undefined && !_proxyLoading)
	{
		SMGTrace("PROXY: smgproxy object does not exist - adding");
		var smg_so = new SWFObject(_proxy_url, 'smgproxy', 0, 0, "8", "#000000");
		smg_so.addParam("salign", "m");
		smg_so.write('smgproxyholder');
		_proxyLoading=true;
	}
}

var _smgObjs = {};
var __smgpl = [];
var __smgplf = 0;
function __getSMGpl()
{
	if(__smgplf == 0)
	{
		return __smgpl;
	}
	else
	{
		var d = [];
		d[0] = __smgplf;
		return d.concat(__smgpl);
	}
}
function SMGStoreGUID(guid,obj)
{
	_smgObjs[guid]=obj;
}
function SMGGetGUID(guid)
{
	return _smgObjs[guid];
}
function SMGPlayerLoaded(guid)
{
	SMGGetGUID(guid).PlayerLoaded(guid);
}
function SMGPlayer(siteID,profileID)
{
	this.GUID = 'guid'+Math.floor(Math.random()*1000000);
	SMGStoreGUID(this.GUID,this);

	this.metaDataUrl = "http://web1.switchmedia.asia/plugin/synopsis.php";
	this.videoDomain = "http://web1.switchmedia.asia";
	this.httpRequest = undefined;
	this.videoID;
	this.aspect=169;
	this.siteID=siteID;
	this.profileID=profileID;
	
	this.elementID = 'smg-player';
	this.objectID;
	
	this.fields='';
	this.width_43 = 512;
	this.height_43 = 418;
	this.width_169 = 512;
	this.height_169 = 322;
	
	this.channelID = 0;
	this.categoryID = 0;

	this.wmode = "transparent";
		
	this.previewOnNext = false;
	
	this.onLoadCallback;
	this.isLoaded = false;
	
	this.proxy = true;
	this._smgProxyElement=null;
	
	this.limitVersion = new Object();
	this.limitVersion.major = 8;
	this.limitVersion.minor = 0;
	this.limitVersion.rev = 0;
	
}
SMGPlayer.prototype.test = function(arg1, arg2)
{
	alert(arg1+": "+arg2+": "+this.siteID+": "+this.elementID);
}
SMGPlayer.prototype.Embed = function (vid, wdt, hgt, id)
{
	this.__Write('xid',vid, wdt, hgt, id)
}
SMGPlayer.prototype.Write = function (vid, wdt, hgt, id)
{
	this.__Write('pid',vid, wdt, hgt, id)
}
var SMGUnloadSet = false;
var SMGUnloadFn;

SMGPlayer.prototype.SetVersionLimit = function (major,minor,rev)
{
	this.limitVersion.major = major;	
	this.limitVersion.minor = minor;
	this.limitVersion.rev = rev;
}
SMGPlayer.prototype.isFlashVersionOK = function ()
{
	SMGTrace("Version test: "+this.flashVersion.major+"."+this.flashVersion.minor+"."+this.flashVersion.rev+" >= "+this.limitVersion.major+"."+this.limitVersion.minor+"."+this.limitVersion.rev);
	if(this.flashVersion.major > this.limitVersion.major)
		return true;
	
	if(this.flashVersion.major < this.limitVersion.major)
		return false;
	
	if(this.flashVersion.minor > this.limitVersion.minor)
		return true;
		
	if(this.flashVersion.minor < this.limitVersion.minor)
		return false;
		
	if(this.flashVersion.rev > this.limitVersion.rev)
		return true;
		
	if(this.flashVersion.rev < this.limitVersion.rev)
		return false;

}

SMGPlayer.prototype.__Write = function(mode,vid, wdt, hgt, id)
{
	
	var context = '';
	if(this.channelID > 0 || this.categoryID > 0)
		context = 'ch'+this.channelID+'ca'+this.categoryID;	
	
	var forcePreview;
	if(this.previewOnNext)
		forcePreview = 1;
	else
		forcePreview = 0;
		
	this.previewOnNext = false;
	
	this.videoID = vid;
	this.elementID = id;
		
	this.objectID = id.replace(/-/g,"_")+"_tv";
	
	var so = new SWFObject(this.videoDomain + "/"+mode+"/"+vid+'s'+this.siteID+'p'+this.profileID+'f'+forcePreview+context, this.objectID, wdt, hgt, "8", "#000000");
	so.addParam("salign", "m");
	
	so.addParam("allowScriptAccess", "always");
	so.addParam("allowFullScreen", "true");
	so.addParam("wmode", this.wmode);
	so.addVariable("guid",this.GUID);
	so.write(id);
	var version = deconcept.SWFObjectUtil.getPlayerVersion()
	//
	if(!window.opera&&document.all&&version.major>7)
	{
		// for some reason swfobject isn't doing this for IE6, forcing it here
		if (!SMGUnloadSet) {
			deconcept.SWFObjectUtil.prepUnload = function() {
				__flash_unloadHandler = function(){};
				__flash_savedUnloadHandler = function(){};
				window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs);
			}
			window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload);
			SMGUnloadSet = true;
		}
	}
	SMGStoreGUID(this.GUID,this);
}

SMGPlayer.prototype.WriteTopItem = function(channel,category,wdt,hgt,id) 
{
	vid = 'tch'+channel+'ca'+category;
	this.__Write('pid',vid,wdt,hgt,id);
}
	
SMGPlayer.prototype.WriteFullscreen = function (vid, wdt, hgt, id)
{
	if(this.previewOnNext)
		forcePreview = 1;
	else
		forcePreview = 0;
		
	this.previewOnNext = false;
	
	this.videoID = vid;
	this.elementID = id;
	this.objectID = id.replace(/-/g,"_")+"_tv";
	var so = new SWFObject(this.videoDomain + "/pid/"+vid+'s'+this.siteID+'p'+this.profileID+'f'+forcePreview+'fs1', this.objectID, wdt, hgt, "8", "#000000");
	so.addParam("salign", "m");
	so.addParam("wmode", "transparent");
	so.addParam("allowScriptAccess", "always");
	
	so.write(id);
}
	
SMGPlayer.prototype.WriteMini = function (vid, wdt, hgt, id)
{
	this.__Write('mid',vid, wdt, hgt, id);
}
	
SMGPlayer.prototype.WriteFromDetails = function ()
{
	if(this.aspect==43)
	{
		hgt=this.height_43;
		wdt=this.width_43;
	}
	else
	{
		hgt=this.height_169;
		wdt=this.width_169;
	}
	this.__Write('pid',this.videoID,wdt,hgt,this.elementID);
}

SMGPlayer.prototype.SetWmode = function(mode)
{
	this.wmode = mode;
}

SMGPlayer.prototype.SetDimensions43 = function (wdt,hgt)
{
	this.width_43 = wdt;
	this.height_43 = hgt;
}
	
SMGPlayer.prototype.SetDimensions169 = function (wdt,hgt)
{
	this.width_169 = wdt;
	this.height_169 = hgt;
}
	
SMGPlayer.prototype.SetDimensions = function (wdt43,hgt43,wdt169,hgt169)
{
	this.SetDimensions43(wdt43,hgt43);
	this.SetDimensions169(wdt169,hgt169);
}
	
SMGPlayer.prototype.SetContext = function (channel,category)
{
	this.channelID=channel;
	this.categoryID=category;
}
	
SMGPlayer.prototype.GetCurrentHeight = function ()
{
	if(this.aspect==43)
		return this.height_43;
	else
		return this.height_169;
}
SMGPlayer.prototype.GetPosition = function ()
{
	var ele = document.getElementById(this.objectID);
	
	var ret = -1;
	if(typeof ele != "undefined")
		ret = document.getElementById(this.objectID).SMGGetPosition();
	else
		this._trace("Couldn't find player object: "+this.objectID);
		
	return ret;
}
	
SMGPlayer.prototype.SetMetaData = function (meta)
{
	this.aspect = meta.aspect;
	this.videoID = meta.videoID;
}
	
SMGPlayer.prototype.TestMode = 	function ()
{
	this.videoDomain = "http://test.switch-media-group.com";
}

SMGPlayer.prototype.SetMetaDataUrl = function (_url)
{
	this.metaDataUrl = _url;	
}

SMGPlayer.prototype.SetVideoDomain = function (_url)
{
	this.videoDomain = _url;	
}

SMGPlayer.prototype.PreviewOnNext = function (state)
{
	this.previewOnNext = state;
}

SMGPlayer.prototype.GetVideoID = function ()
{
	return this.videoID;
}
	
SMGPlayer.prototype.Pause = function ()
{
	var ele = document.getElementById(this.objectID);
	
	if(typeof ele != "undefined")
		document.getElementById(this.objectID).SMGPause();
	else
		this._trace("Couldn't find player object: "+this.objectID);
}
SMGPlayer.prototype.Play = function ()
{
	var ele = document.getElementById(this.objectID);
	
	if(typeof ele != "undefined")
		document.getElementById(this.objectID).SMGPlay();
	else
		this._trace("Couldn't find player object: "+this.objectID);
}

SMGPlayer.prototype.Stop = function ()
{
	var ele = document.getElementById(this.objectID);
	
	if(typeof ele != "undefined" && typeof ele.SMGStop != "undefined")
		ele.SMGStop();
	else
		this._trace("Couldn't find player object or SMGStop function: "+ this.objectID);
}
SMGPlayer.prototype.NextKeyFrame = function (dir)
{
	var ele = document.getElementById(this.objectID);
	
	var ret = -1;
	if(typeof ele != "undefined")
		ret = document.getElementById(this.objectID).SMGNextKeyFrame(dir);
	else
		this._trace("Couldn't find player object: "+this.objectID);
		
	return ret;
}	
	
SMGPlayer.prototype.SetFields = function (fields)
{
	this.fields = fields;
	
	// check if corresponding nodes exist
	this._trace('fields: '+this.fields,'info');
	if(this.fields.indexOf(",") > -1)
	{
		var tmp = this.fields.split(",");
		
		for(var id=0;id<tmp.length;id++)
		{
			if(!document.getElementById('smg-'+tmp[id]))
				this._trace('DOM element not found - smg-'+tmp[id],'error');
		}
	}
	else
	{
		if(this.fields!='')
			if(!document.getElementById('smg-'+this.fields))
					this._trace('DOM element not found - smg-'+this.fields,'error');
	}
}
	
	// load the data and run callback onLoadDetails

SMGPlayer.prototype.LoadVideoDetails = function (videoID,id)
{
	this.elementID = id;
	this.videoID=videoID;
	this._LoadVideoDetails();
}

SMGPlayer.prototype._LoadVideoDetails = function() 
{
	if(!SMGWaitForProxy({callback: "_LoadVideoDetails"},{obj: this}))
		return;
	
	this._trace('loading details for id '+this.videoID);

	
	url=this.metaDataUrl;
	
	//url='http://www.switch-media-group.com/plugin/synopsis.php';
	var d= new Date();
	
	query='siteID='+this.siteID+'&videoID='+this.videoID+'&fields='+this.fields+'&guid='+this.GUID+'&ms='+d.getTime();
	
	this._trace(url+'?'+query);
	if(!this.proxy)
	{
		this.httpRequest = getHttpRequestObj();
		this.httpRequest.open('GET', url+'?'+query,true);		
		this.httpRequest.onreadystatechange = function() 
		{
			if (this.httpRequest.readyState==4 && this.httpRequest.status==200)
			{
				//alert('ajax1: '+httpRequest.responseText);
				eval(this.httpRequest.responseText);
			}
			else if (this.httpRequest.readyState==4 )
				Error('Error requesting video list');
		}     
		this.httpRequest.send(null);
	}
	else
	{
		this._trace('_sending via proxy');
		this._SMGSend('GET',url,query);
	}
}

SMGPlayer.prototype.onLoadDetails = function (synopsis,metaData,downloads)
{
	this._trace('main: video data updated');
	
	this.SetMetaData(metaData);
	this.WriteFromDetails();

	for(id in synopsis)
	{
		this._trace("inserting content into smg-"+id);
		this._UpdateHTML('smg-'+id,synopsis, id);
	}
	if(typeof metaData.media_type != "undefined" )
	{
		var ele = document.getElementById('smg-current');
		this.addReplaceClass(ele,"smg-media-video",'smg-media-'+metaData.media_type);
		this.addReplaceClass(ele,"smg-media-audio",'smg-media-'+metaData.media_type);
	}
	if(typeof downloads != "undefined" )
	{
		for(id in downloads)
		{
			this._trace("updating download link smg-download-"+id);
			var ele = document.getElementById('smg-download-'+id);
			if(typeof ele != "undefined" && ele != null)
			{
				if(typeof ele.href != "undefined" || ele.tagName != "A")
				{
					ele.href = downloads[id];
				}
				else
					this._trace("element smg-download-"+id+" is not an achor element","error");
			}
			else
				this._trace("element smg-download-"+id+" not found","error");
		}	
	}
	this._SendCallback(synopsis,metaData);
}
	
	
SMGPlayer.prototype.LoadTopItemDetails = function (channel,category,id)
{
	this.elementID = id;
	this.channelID=channel;
	this.categoryID=category;
	this._LoadTopItemDetails();
}

SMGPlayer.prototype._LoadTopItemDetails = function ()
{
	if(!SMGWaitForProxy({callback: "_LoadTopItemDetails"},{obj: this}))
		return;
	
	this.categoryID;
	
	this._trace('loading top item details for channel= '+this.channelID+' category='+this.categoryID);
	
	url=this.metaDataUrl;
	
	var d= new Date();
	
	query='siteID='+this.siteID+'&channelID='+this.channelID+'&categoryID='+this.categoryID+'&fields='+this.fields+'&guid='+this.GUID+'&ms='+d.getTime();
	
	this._trace(url+'?'+query);
	if(!this.proxy)
	{
		this.httpRequest = getHttpRequestObj();
		this.httpRequest.open('GET', url+'?'+query,true);		
		this.httpRequest.onreadystatechange = function() 
		{
			if (this.httpRequest.readyState==4 && this.httpRequest.status==200)
			{
				eval(this.httpRequest.responseText);
			}
			else if (this.httpRequest.readyState==4 )
				Error('Error requesting video list');
		}     
		this.httpRequest.send(null);
	}
	else
	{
		this._trace('_sending via proxy');
		this._SMGSend('GET',url,query);
	}
}

SMGPlayer.prototype.addReplaceClass = function(ele,orig,subst)
{	
	if(!ele)
		return;
		
	if(ele.className.match(subst))
		return; // already there
	
	if(ele.className.match(orig))
		ele.className = ele.className.replace(orig,subst); // replace
	else
		ele.className = ele.className + ' ' + subst;	// add it.
}
	
SMGPlayer.prototype.Clear = function ()
{
	
	if(this.fields.indexOf(",") > -1)
	{
		var tmp = this.fields.split(",");
		for(id in tmp)
		{
			if(document.getElementById('smg-'+tmp[id])!=undefined)
				document.getElementById('smg-'+tmp[id]).innerHTML = '';
		}
	}
	else
	{
		if(document.getElementById('smg-'+this.fields)!=undefined)
				document.getElementById(this.fields).innerHTML = '';
	}
	document.getElementById(this.elementID).innerHTML = '';
}
	
SMGPlayer.prototype.SetOnLoadCallback = function (callback)
{
	this.onLoadCallback = callback;
}
SMGPlayer.prototype.SetOnPlayerLoaded = function (callback)
{
	this.onPlayerLoaded = callback;
}
SMGPlayer.prototype._SendCallback = function(synopsis,metaData)
{
	if(typeof this.onLoadCallback != "undefined")
	{
		// build object
		var obj = new Object();
		obj['id']=this.elementID;
		for(id in synopsis)
		{
			obj[id] = synopsis[id];
		}
		for(id in metaData)
		{
			obj[id] = metaData[id];
		}
		
		this.onLoadCallback(obj);
	}
}

SMGPlayer.prototype.PlayerLoaded = function (guid)
{
	this.isLoaded=true;
	//alert(guid+" video: "+this.videoID);
	if(this.onPlayerLoaded)
		this.onPlayerLoaded(this.elementID,this.videoID,this);
}

SMGPlayer.prototype.UseProxy = function (_proxy)
{
	this.proxy = _proxy;
}
	

SMGPlayer.prototype._SMGProxy = function(movieName)
{
	// cache handle to proxy component - faster and for some reason can be returned as the wrong element.
	if(this._smgProxyElement==null)
	{
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		this._smgProxyElement = (isIE) ? window[movieName] : document[movieName];
	}
	return this._smgProxyElement;
}
    
SMGPlayer.prototype._SMGSend = function(mode,url,query) 
{	
	this._SMGProxy("smgproxy").sendHTTP(mode,url,query);
}
	
SMGPlayer.prototype.Ajax = function (js)
{
	eval(js);
}


// ****************          Functions to control screen elements
	
SMGPlayer.prototype.SetDebug = function (mode)
{
	this.SMGDebug=mode;
}
	
SMGPlayer.prototype._trace = function(msg,state)
{
	if(!_SMGDebug) return;
	
	var ele = document.getElementById("SMGTrace");

	if(ele != null)
	{
		if(state=='error')
			msg = '<p style="font-weight:bold;color:red;">'+msg+'</p>';
		else if(state=='warn')
			msg = '<p style="font-weight:bold;color:orange;">'+msg+'</p>';
		
		ele.innerHTML = ele.innerHTML + '<br />Player: ' +msg;	
	}
}
		
SMGPlayer.prototype._UpdateHTML = function (id,obj,property)
{
	
	if(document.getElementById(id)!=undefined)
	{
		document.getElementById(id).innerHTML = obj[property];	
	}
	else if(_SMGDebug)
		this._SMGElementPopUp(id);
}
		
SMGPlayer.prototype._SMGElementPopUp = function(id)
{
	alert('Element "'+id+'" was not found in document\n(call SetDebug(false) to disable these popups)');
}
	

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * SMG: slightly edited to allow for 0x0 size flash movies
 * SMG: modified to stop IE throwing a javascript error when the player is contained in form tag and the External Inferace is called.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}this.setAttribute("width",w);this.setAttribute("height",h);if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();if(!(navigator.plugins && navigator.mimeTypes.length)) window[this.getAttribute('id')] = document.getElementById(this.getAttribute('id'));return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

var SMGPlayerScriptLoaded = true;
if(typeof smg_callback_expected != "undefined" || typeof smg_waitPlayer != "undefined")
{
	if(typeof smg_onload_callback != "undefined")
		smg_onload_callback('player');
	
	if(typeof smg_readyBound != "undefined" && typeof smg_DomReady != "undefined")
		smg_DomReady();	
	
}
