	
	/**
	* VideoConfig for storing values
	*
	* @author Christian Lorenz
	*
	*
	*/
	function _VideoConfig()
	{
		this.data = new Array();
		this.filename = "videoplayer--13.swf";
	}
	
	/**
	* Set alias
	*
	* Calls PHP xmlRPC::getLanguage();
	*
	* @param  int from
	* @param  int to
	* @param  int parent window
	* @access public
	* @return null
	*/
	_VideoConfig.prototype.setAlias = function (name,alias,parentWindow)
	{
		var o = new Object();
		o.alias = alias;
		o.parentWindow = parentWindow;
		
		this.data[name] = o;
	}
	
	_VideoConfig.prototype.getAlias = function (name)
	{
		return this.data[name];
	}
		
	var videoConfig = new _VideoConfig();
	
	function _VideoPlayer(elementId,videoId,autoPlay)
	{
		this.videoId = videoId;
		this.elementId = elementId;
		this.autoPlay = autoPlay;
		this.popupMode = false;
		this.lcid = 0;
		this.referer = "";
		this.host = "";
		this.url = "";
		this.pageRegister = "";
	}

	_VideoPlayer.prototype.init = function()
	{
		var autoPlay = (this.autoPlay) ? 1 : 0;
	
		var so = new SWFObject("http://static.pokerstrategycdn.com/front/flash/" + videoConfig.filename, this.elementId + "_flash", "100%", "100%", "10", "#000000");
		so.useExpressInstall('http://static.pokerstrategycdn.com/front/flash/expressInstall.swf');
		so.addParam("scale", "noscale");
		so.addParam("allowscriptaccess", "always");
		so.addParam("salign", "tl");
		so.addParam("allowFullScreen","true");
		so.addVariable("videoId",this.videoId);
		so.addVariable("elementId",this.elementId);
		so.addVariable("autoPlay",autoPlay);
		so.addVariable("popupMode",(this.popupMode) ? "1" : "0");
		so.addVariable("lcid",this.lcid);
		so.addVariable("referer",this.referer);
		so.addVariable("host",this.host);
		so.addVariable("url",this.url);
		so.write(this.elementId);
		
		
		var flashObject = document.getElementById(this.elementId + "_flash");
		
		videoConfig.setAlias(this.elementId,flashObject,window);
		videoConfig.setAlias("elementId",this.elementId,window);
		videoConfig.setAlias(this.elementId + "_window",flashObject,window);
		videoConfig.setAlias("pageRegister",this.pageRegister,window);
	}

	_VideoPlayer.prototype.replaceTimecodes = function(container)
	{	
		var elements = $(container);
		var i;
		var html;
		var result;
		var exp = /\b((([0-9]{1,2}\:){0,1}([0-5]{1}){0,1}[0-9]{1}\:[0-5]{1}[0-9]{1}))\b/g;
		
		for (i=0; i<elements.length; i++)
		{
			html = $(elements[i]).html().toString();
			result = html.replace(exp,'<a href=javascript:_VideoFactory.seek("$1","' + this.elementId + '");>$1</a>');
			$(elements[i]).html(result);
		}
	}
	
	
	function _VideoFactory()
	{
		
	}
	
	_VideoFactory.seek = function(time,elementId)
	{
		var flashObject = videoConfig.getAlias(elementId);
		
		flashObject.alias.seek(time);
		
		try
		{
			if (top.consoleRef.location.href)
			{
				top.consoleRef.focus();
			}
			else
			{
				$(this).scrollTo($("#" + elementId),600,{offset: -50});
			}
		}
		catch (e)
		{
			$(this).scrollTo($("#" + elementId),600,{offset: -50});
		}
	}
	
	_VideoFactory.resize = function (height,elementId)
	{
		if (!document.all)
		{
			//$("#" + elementId).css("height",height + "px");
		}
	}

	
	_VideoFactory.goToPopup = function (width,height,lcid)
	{
		var windowName = "popup_" + lcid;
		var url = "/page/video/video.popup.php?" + lcid;
		top.consoleRef = window.open(url, windowName, "width=" + width + ", height=" + height + ",resizable=1");
		top.consoleRef.focus();
	}
	
	_VideoFactory.goRegister = function ()
	{
		window.location.href = 	videoConfig.getAlias("pageRegister").alias;
	}
	
	function reportError(videoId, filename, hash, playerVersion, code)
	{
		var url = "/page/video/debuglog/reporterror.ajax.php";
		var browser;
		
		if (jQuery.browser.msie)
		{
			browser = "IE"; 
		}
		else if(jQuery.browser.safari)
		{
			browser = "Safari"; 
		}
		else if(jQuery.browser.opera)
		{
			browser = "Opera"; 
		}
		else if(jQuery.browser.mozilla)
		{
			browser = "Mozilla"; 
		}
		else
		{
			browser = "Unknown"; 
		}
		
		browser += " " + jQuery.browser.version;
			
		
		$.post(url,
		{	
			videoid: videoId, 
			filename: filename,
			hash: hash, 
			playerversion: playerVersion,
			browser: browser,
			code: code
		},
		function(result) 
		{		
		});
	}
