// Audio Embed function

function AudioEmbedGenerator(flash_src, media_url) {
	// Member variables
	this.m_media_url = media_url;
	this.m_flash_src = flash_src;
	this.m_width = 25;
	this.m_height = 20;
	this.m_mode = 'simple';
	this.m_theme = '0'; // Default theme
	this.m_bgcolor1 = new Array(8);
	this.m_bgcolor2 = new Array(8);
	this.m_buttoncolor = new Array(8);
	this.m_buttonovercolor = new Array(8);
	this.m_slidercolor1 = new Array(8);
	this.m_slidercolor2 = new Array(8);
	
	if( window.location.hostname.indexOf('blubrry') != -1 )
	{
		// Blubrry
		this.m_bgcolor1[0] = '003366';
		this.m_bgcolor2[0] = 'ECECEC';
		this.m_buttoncolor[0] = 'FFFFFF';
		this.m_buttonovercolor[0] = 'C0D318';
		this.m_slidercolor1[0] = 'ffffff';
		this.m_slidercolor2[0] = 'cccccc';
	}
	else
	{
		// Default:
		this.m_bgcolor1[0] = '';
		this.m_bgcolor2[0] = '';
		this.m_buttoncolor[0] = '';
		this.m_buttonovercolor[0] = '';
	}

	// Gray
	this.m_bgcolor1[1] = '666666';
	this.m_bgcolor2[1] = 'CCCCCC';
	this.m_buttoncolor[1] = 'FFFFFF';
	this.m_buttonovercolor[1] = '';
	this.m_slidercolor1[1] = '';
	this.m_slidercolor2[1] = '';
	
	if( window.location.hostname.indexOf('blubrry') != -1 )
	{
		// Default:
		this.m_bgcolor1[2] = '';
		this.m_bgcolor2[2] = '';
		this.m_buttoncolor[2] = '';
		this.m_buttonovercolor[2] = '';
		this.m_slidercolor1[2] = '';
		this.m_slidercolor2[2] = '';
	}
	else
	{
		// Blubrry
		this.m_bgcolor1[2] = '003366';
		this.m_bgcolor2[2] = 'ECECEC';
		this.m_buttoncolor[2] = 'FFFFFF';
		this.m_buttonovercolor[2] = 'C0D318';
		this.m_slidercolor1[2] = 'ffffff';
		this.m_slidercolor2[2] = 'cccccc';
	}
	
	// Blue
	this.m_bgcolor1[3] = '2B405B';
	this.m_bgcolor2[3] = '6B8AB6';
	this.m_buttoncolor[3] = 'FFFFFF';
	this.m_buttonovercolor[3] = 'BBBBBB';
	this.m_slidercolor1[3] = 'ECECEC';
	this.m_slidercolor2[3] = 'BBBBBB';
	// Green
	this.m_bgcolor1[4] = '234900';
	this.m_bgcolor2[4] = '4E9E00';
	this.m_buttoncolor[4] = 'FFFFFF';
	this.m_buttonovercolor[4] = 'BBBBBB';
	this.m_slidercolor1[4] = 'ECECEC';
	this.m_slidercolor2[4] = 'BBBBBB';
	// Fire Red
	this.m_bgcolor1[5] = 'E1600F';
	this.m_bgcolor2[5] = 'FEBD01';
	this.m_buttoncolor[5] = 'FFFFFF';
	this.m_buttonovercolor[5] = 'CCCCCC';
	this.m_slidercolor1[5] = 'ffffff';
	this.m_slidercolor2[5] = 'cccccc';
	// Pink
	this.m_bgcolor1[6] = 'CC2550';
	this.m_bgcolor2[6] = 'E87A9F';
	this.m_buttoncolor[6] = 'FFFFFF';
	this.m_buttonovercolor[6] = 'BBBBBB';
	this.m_slidercolor1[6] = 'ffffff';
	this.m_slidercolor2[6] = 'cccccc';
	// Brown
	this.m_bgcolor1[7] = '5D1719';
	this.m_bgcolor2[7] = 'CD311B';
	this.m_buttoncolor[7] = 'FFFFFF';
	this.m_buttonovercolor[7] = 'BBBBBB';
	this.m_slidercolor1[7] = 'ffffff';
	this.m_slidercolor2[7] = 'cccccc';
	
	this.FlashSrc=function(Src) {
		this.m_flash_src = Src;
	}
	
	this.MediaURL=function(Url) {
		this.m_media_url = Url;
	}
	
	
	this.GenerateEmbed=function() {
		
		var Str = '<object type="application/x-shockwave-flash" data="'+ this.m_flash_src +'" width="'+ this.m_width +'" height="20" wmode="transparent">';
    Str += '<param name="movie" value="'+ this.m_flash_src +'" />';
    Str += '<param name="wmode" value="transparent" />';
    Str += '<param name="FlashVars" value="mp3='+ escape(this.m_media_url) +'&amp;'+ this.GetFlashVars() +'" />';
		Str += '</object>';
		return Str;
	}
	
	this.InsertPlayer=function(id) {
		
		var obj = document.getElementById(id);
		if( obj )
			obj.innerHTML = this.GenerateEmbed();
	}
	
	this.InsertPlayerSrc=function(id) {
		
		var obj = document.getElementById(id);
		if( obj )
			obj.value = this.GenerateEmbed();
	}
	
	this.UpdateSetting=function(key,value) {
		
		switch( key )
		{
			case 'theme': {
				this.m_theme = value;
			}; break;
			case 'mode': {
				this.m_mode = value;
				if( this.m_mode == 'advanced' )
					this.m_width = 200;
				else
					this.m_width = 25;
			}; break;
		}
		
	}
	
	this.GetFlashVars=function() {
		
		var Str = '';
			Str += '';
		if( this.m_mode == 'advanced' )
			Str += '&amp;showvolume=1';
		else
			Str += '&amp;showslider=0';
		
		if( this.m_bgcolor1[ this.m_theme ] != '' )
		{
			Str += '&amp;bgcolor1=' + this.m_bgcolor1[ this.m_theme ];
			Str += '&amp;bgcolor2=' + this.m_bgcolor2[ this.m_theme ];
			Str += '&amp;buttoncolor=' + this.m_buttoncolor[ this.m_theme ];
			if( this.m_buttonovercolor[ this.m_theme ] != '' )
				Str += '&amp;buttonovercolor=' + this.m_buttonovercolor[ this.m_theme ] + '&amp;sliderovercolor=' + this.m_buttonovercolor[ this.m_theme ];
			if( this.m_slidercolor1[ this.m_theme ] != '' )
				Str += '&amp;slidercolor1=' + this.m_slidercolor1[ this.m_theme ];
			if( this.m_slidercolor2[ this.m_theme ] != '' )
				Str += '&amp;slidercolor2=' + this.m_slidercolor2[ this.m_theme ];
		}
		
		Str += '&amp;width=' + this.m_width;
		
		return Str;
	}
}

