/**
 * @author Filip Michalowski / Fi Stockholm
 */
Namespace.create("ng.modules.audioPlayerModule");

ng.modules.audioPlayerModule.AudioPlayerModule = function () {

	//private variables:
	var moduleContainer;
	var moduleData;
	
	//private methods:
	
	var draw = function() {	
	
		initializeFlash();
		
	};
	
	var initializeFlash = function() {
		var params = {
		  quality: "high",
		  bgcolor: "#f1f1f1",
		  scale: "noscale"
		};
		
		// iterated through all audio player anchor links that point to mp3 files
		$('.audioPlayer a[href*=".mp3"]').each(function(){
			//console.log($(this).attr('href'));
			//console.log($(this).parent().parent().attr('id'));
			
			var flashvars = {
			  audioFileUrl: $(this).attr('href')
			};
			
			var attributes = {
				id: "ngaudioplayer",
				name: "ngaudioplayer"
			};
			
			swfobject.embedSWF(moduleData.audioPlayerUrl, $(this).parent().parent().attr('id'), "360", "20", "9.0.0", "/projects/nationalgeographicevents/assets/swf/expressInstall.swf", flashvars, params, attributes);
		});
		
	};
	
	//the returned object here will become ng.modules.audioPlayerModule.AudioPlayerModule:
	return  {
		
		// public
		
		init: function (container, data) {
			moduleContainer = container;
			moduleData = data;
			
			draw();
		}

	};
}(); // the parens here cause the anonymous function to execute and return


/**
 * Markup templates for the AudioPlayerModule
 */
ng.modules.audioPlayerModule.AudioPlayerModuleTemplates = 
{
		
};
