// <![CDATA

	/**		
	 * Dynamix Portfolio, version 0.3 beta (Dynamix-0.3.0 b)
	 * (c) 2008 Amorphik / Marc Hottinger
	 *
	 * http://www.amorphik.com/
	 *
	 * This script may not be used, modified, copied, etc. without the
	 * autorisation of amorphik.
	 *
	 *
	 * This script is meant to be further used with a Content Management System (CMS) in the next release.
	 *
	 */

	// --------------------------------------------
	// load quicktime objects
	// --------------------------------------------
	function injectObject(obj,div) {
		
		// arrays containing the param and embed properties to inject
		var injectParam = new Array();
		var injectEmbed = new Array();
		
		// option(s) for movie object
		var hasPoster   = false;
		var hasRefMovie = false;
		
		// extract data from the file name
		var extension = new Array();
		extension = obj.split('.');
		var property = new Array();
		property = extension[0].split('-');
		var size = new Array();
		if(property[2] == 'poster') {
			hasPoster = true;
		} else {
			hasPoster = false;
		}
		
		// extract size data in the right place, depending on the options of the object
		size = (hasPoster) ? property[3].split('_') : property[2].split('_') ;
		
		// width & height 
		var width  = parseInt(size[0]);
		var height = (hasPoster) ? parseInt(size[1])-16 : parseInt(size[1]) ;
		var controllerHeight = (hasPoster) ? parseInt(size[1]) : parseInt(size[1])+16 ;
		
		// object properties
		var controller  = false;
		var volume      = 80;
		var target      = 'myself';
		
		// arrays containing the param and embed properties to inject
		var injectParam = new Array();
		var injectEmbed = new Array();
		
		
		// check the data extracted
		//debug(property[0]+'-'+property[1]+'-'+property[2]+'-'+property[3]+'.mov, size = '+width+'x'+height);
		
		if(hasPoster) {
			
			// check the filename structure
			debug(property[1]+'/'+property[0]+'/'+property[0]+'-'+property[1]+'-'+property[2]+'-'+property[3]+'.mov');
			
			// open the object tag
			var injectObjOpening = '<object classid="clsid: 02BF25D5..." ...>';
			
			// define the content of the object
			injectParam[0]   = '<param name="src" value="media/video/portfolio/content/'+property[1]+'/'+property[0]+'/'+property[0]+'-'+property[1]+'-'+property[2]+'-'+property[3]+'.mov" />';
			injectParam[1]   = '<param name="width" value="'+width+'" />';
			injectParam[2]   = '<param name="height" value="'+controllerHeight+'" />';
			injectParam[3]   = '<param name="volume" value="'+volume+'" />';
			injectParam[4]   = '<param name="controller" value="'+controller+'" />';
			injectParam[5]   = '<param name="target" value="'+target+'" />';
			injectParam[6]   = '<param name="href" value="'+property[0]+'-'+property[1]+'-'+width+'_'+height+'.mov" />';
			injectEmbed[0]   = '<embed width="'+width+'" height="'+controllerHeight+'" controller="'+controller+'" target="'+target+'" bgcolor="000000" border="0" src="media/video/portfolio/content/'+property[1]+'/'+property[0]+'/'+property[0]+'-'+property[1]+'-'+property[2]+'-'+property[3]+'.mov" href="'+property[0]+'-'+property[1]+'-'+width+'_'+height+'.mov" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
			
			// close the object tag
			var injectObjClosing = '</object>\n';
			
			// gather all the content into a string
			var injectedContent  = injectObjOpening+injectParam[0]+injectParam[1]+injectParam[2]+injectParam[3]+injectParam[4]+injectParam[5]+injectEmbed[0]+injectObjClosing;
			
		} else {
		
			// check the filename structure
			debug(property[1]+'/'+property[0]+'/'+property[0]+'-'+property[1]+'-'+property[2]+'.mov');
			
			// add the controller
			controller = true;
			
			// open the object tag
			var injectObjOpening = '<object classid="clsid: 02BF25D5..." ...>';
			
			// define the content of the object
			injectParam[0]   = '<param name="src" value="media/video/portfolio/content/'+property[1]+'/'+property[0]+'/'+property[0]+'-'+property[1]+'-'+property[2]+'.mov" />';
			injectParam[1]   = '<param name="width" value="'+width+'" />';
			injectParam[2]   = '<param name="height" value="'+controllerHeight+'" />';
			injectParam[3]   = '<param name="volume" value="'+volume+'" />';
			injectParam[4]   = '<param name="controller" value="'+controller+'" />';
			injectEmbed[0]   = '<embed width="'+width+'" height="'+controllerHeight+'" controller="'+controller+'" bgcolor="000000" border="0" src="media/video/portfolio/content/'+property[1]+'/'+property[0]+'/'+property[0]+'-'+property[1]+'-'+property[2]+'.mov" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
			
			// close the object tag
			var injectObjClosing = '</object>\n';
			
			// gather all the content into a string
			var injectedContent  = injectObjOpening+injectParam[0]+injectParam[1]+injectParam[2]+injectParam[3]+injectParam[4]+injectEmbed[0]+injectObjClosing;
		
		}

		$(div).update(injectedContent);
		
	}

// ]]>
