//Hierarchy:
// -Optimised ( basically a final version of the base to extension including all common class libraries,
//			    it wont have a prerequesite, but may be one elsewhere )
// -Base
// --Primal
// ---Extension
// ----Specialized

//Prerequisites:
//	-class.js

/*
--------------------
Type:Base/Primal
Name: Javascript Extensions, focused on Media Interaction
Source File Name: cls_base_MediaObject.js
Desc:	Adds Basic Base Class, which provides a basic media object. it can detect browser,
			find the container, define its size and color
		Adds Basic Primal Class, which provides an advanced media object pointing to a file,
			and allowing low level customization: title, params, and basic player manipulation (and control mechanisms)

Author:	Joe Mieszczur
--------------------
*/
function MediaObject(nContainer, nWidth, nHeight, nBgColor)				{this.width = nWidth;this.height = nHeight;this.bgColor = nBgColor;this.container = nContainer;this.browser = this.setBrowser();}
MediaObject.method('setSize', 			function(nWidth,nHeight)		{this.width = nWidth;this.height = nHeight;})
MediaObject.method('getWidth', 			function()						{return this.width;})
MediaObject.method('getHeight', 		function()						{return this.height;})
MediaObject.method('setBgColor', 		function(nBgColor)				{this.bgColor = nBgColor;})
MediaObject.method('getBgColor', 		function()						{return this.bgColor;})
MediaObject.method('setContainer', 		function(nContainer)			{this.container = nContainer;})
MediaObject.method('getContainer', 		function()						{return this.container;})
MediaObject.method('setBrowser', 		function()						{if(navigator.userAgent.indexOf('MSIE') != -1 || navigator.userAgent.indexOf('Safari') != -1){this.browser = 1;}else{this.browser = 0;};return this.browser;})
MediaObject.method('getBrowser', 		function()						{return this.browser;})

function MediaFileObject(nContainer, nTitle, nSrc, nWidth, nHeight, nBgColor)	{this.setSize(nWidth,nHeight);this.setBgColor(nBgColor);this.setContainer(nContainer);this.title = nTitle;this.src = nSrc;var tpArry = ['',''];this.params = [tpArry];}
MediaFileObject.inherits(MediaObject);
MediaFileObject.method('setSrc', 		function(nSrc)					{this.src = nSrc;})
MediaFileObject.method('getSrc', 		function()						{return this.src;})
MediaFileObject.method('setTitle', 		function(nTitle)				{this.title = nTitle;})
MediaFileObject.method('getTitle', 		function()						{return this.title;})
MediaFileObject.method('makePlayer',	function()						{})
MediaFileObject.method('killPlayer',	function()						{this.getContainer().innerHTML = '';this.getContainer().style.display = 'none';})
MediaFileObject.method('hidePlayer',	function(nShrink)				{this.getContainer().style.visibility = 'hidden';if(nShrink){this.getContainer().style.display = 'none';};})
MediaFileObject.method('showPlayer',	function()						{this.getContainer().style.visibility = 'visible';if(this.browser==1){this.getContainer().style.display = 'block';}else{this.getContainer().style.display = 'table-cell';};})
MediaFileObject.method('addParam',		function(name,value)			{var tArry = [name,value];this.params[this.params.length] = [tArry];})
MediaFileObject.method('delParam',		function(name)					{for(var x=1;x<this.params.length;x++){if(this.params[x][0][0] == name){this.params.splice(x,1)};}return this.params;})
MediaFileObject.method('modParam',		function(name,value)			{for(var x=1;x<this.params.length;x++){if(this.params[x][0][0] == name){this.params[x][0][1] = value;}}})
MediaFileObject.method('loadParams',	function()						{var tempStr = '';for(var x=1;x<this.params.length;x++){if(this.getBrowser()==1){tempStr += '<param name="' + this.params[x][0][0] + '" value="' + this.params[x][0][1] + '" />';}else{tempStr += ' ' + this.params[x][0][0] + '="' + this.params[x][0][1] + '"';}};return tempStr;})
MediaFileObject.method('clearParams', 	function()						{var tArry = [];tArry = ['',''];this.params = [tArry];})