document.write('<link href="http://www.domradio.de/comet/cms/widgets/eva/css/dr.eva.css" type="text/css" rel="stylesheet">');

function dr_eva_widget(opts) {
	this.options = opts;


	if ( this.options.width > 300 ) {
		this.options.image.size = 'small';
	}
	
	if ( this.options.width <= 100 ) {
		this.options.image.size = 'big';
	}	
	
	this.contentSize 	= this.options.width-10;	

	/*-- BILD --*/
	if (this.options.image.size == 'big') {
		this.imageSize 	= this.contentSize;
	} else {
		this.imageSize 	= parseInt(this.contentSize/2);
		if (this.options.width > 300) {
			this.imageSize 	= parseInt(this.imageSize/2);
		}
	}

	/*-- set Item Values --*/
	this.item = {
		"lesung" : {
			"flashid"	: Math.floor(Math.random()*100001),
			"file" 		: "http://www.domradio.de/comet/audio/mp3/29069.mp3"
		},
		"auslegung" : {
			"flashid"	: Math.floor(Math.random()*100001),
			"file" 		: "http://www.domradio.de/comet/audio/mp3/29079.mp3"
		},
		"title"	: "Mk 6,30-34"
	};

		this.imagePath	= 'http://www.domradio.de/resize/resize_cap/width_'+this.imageSize+'/27874.jpg ';
		
	this.write = function(element_id){
		this.theHTML = '<div id="dr-eva-container" style="width:'+this.options.width+'px;">';
		
		/**********
		 * Header *
		 **********/
		if (this.options.header.show) {
			if (this.options.header.text != '') {
				this.theHTML += '<p class="dr-header">'+this.options.header.text+'</p>';
			} else
			{
				this.theHTML += '<p class="dr-header">Evangelium</p>';
			}
		}
		
		/********
		 * Item *
		 ********/
		this.theHTML += '<div id="dr-content"> ';	

		if ( this.options.image.show && this.imagePath != '' ) {
			this.theHTML += '	<a target="_blank" href="http://www.domradio.de/evangelium/"><img class="'+this.options.image.size+'"';
			this.theHTML += '		 src="'+this.imagePath+'"';
			this.theHTML += '	/></a>';
		}

		/*************
		 * Item.Text *
		 *************/		
		this.theHTML += '	<div class="dr-content-text"> ';
		// this.theHTML += '		<p>';
		// this.theHTML += '			Mk 6,30-34';
		// this.theHTML += '		</p>';		
		this.theHTML += '		<p>';
		this.theHTML += '			Samstag, 4. Februar 2011';
		this.theHTML += '		</p>';

		this.playerSize		= this.contentSize-10;
		if ( this.options.width >= 300 && this.options.image.size == 'small' ) {
			this.playerSize		= this.playerSize/2;
		}	
		if (this.options.audio.lesung || this.options.audio.auslegung) {		
			AudioPlayer.setup("http://www.domradio.de/javascript/player.swf", {  
				width: this.playerSize,  
				initialvolume: 100,  
				transparentpagebg: "yes",  
				left: "000000",  
				lefticon: "FFFFFF"  
			});  		
		}			
		
		/*-- Lesung  BEGIN --*/
		this.theHTML += '		<p class="dr-content-subtitle">';
		this.theHTML += '			Evangelium: Mk 6,30-34';
		this.theHTML += '		</p>';	
		if (this.options.audio.lesung) {		
			this.theHTML += '	<div class="dr-player">';
			this.theHTML += '		<div id="dr-player-'+this.item.lesung.flashid+'">';
			this.theHTML += '			<a title="Flash Player herunterladen" href="/go/getflashplayer_de"><img src="http://wwwimages.adobe.com/www.adobe.com/images/shared/download_buttons/get_adobe_flash_player.png" alt="Get Adobe Flash Player"></a>';
			this.theHTML += '		</div>';
			this.theHTML += '	</div>';
		}
		/*-- Lesung END --*/
		
			
		/*-- Auslegung BEGIN --*/
		if ( this.item.auslegung.file != '' )
		{
			this.theHTML += '		<p class="dr-content-subtitle">';
			this.theHTML += '			Auslegung von: ';
	//		this.theHTML += '			<a href="Hans-Bernd Serries">';
			this.theHTML += '				Hans-Bernd Serries';
	//		this.theHTML += '			</a>';
			this.theHTML += '		</p>';
			if (this.options.audio.auslegung) {		
				this.theHTML += '<div class="dr-player">';
				this.theHTML += '	<div id="dr-player-'+this.item.auslegung.flashid+'">';
				this.theHTML += '		<a title="Flash Player herunterladen" href="/go/getflashplayer_de"><img src="http://wwwimages.adobe.com/www.adobe.com/images/shared/download_buttons/get_adobe_flash_player.png" alt="Get Adobe Flash Player"></a>';
				this.theHTML += '	</div>';
				this.theHTML += '</div>';			
			}		
		}
		/*-- Auslegung END --*/
		
		this.theHTML += 	'</div>';
		/*-- Content.Text END--*/
	
		this.theHTML += '</div>';		
		/*-- Content END --*/
		
		/*-- Footer BEGIN --*/
		this.theHTML += '		<p class="dr-footer">';
		this.theHTML += 			'<a target="_blank" href="http://www.domradio.de/evangelium/">';
		switch (this.options.footer.style) {
			case 'logo':
				this.theHTML += '		<img src="http://www.domradio.de/website/image/24287.jpg?width=84" />';
				break;
			default:
				this.theHTML += 'domradio.de';
		}
		this.theHTML += 			'</a>';
		this.theHTML += 		'</p>';		
		/*-- Footer END --*/
		
		this.theHTML += 	'</div>';
		/*-- Container END --*/
		
		document.getElementById(element_id).innerHTML = this.theHTML;

		if (this.options.audio.lesung) {		
			AudioPlayer.embed("dr-player-"+this.item.lesung.flashid , {
				soundFile	: this.item.lesung.file,
				titles		: "Lesung Evangelium"
			}); 		
		}
		if (this.options.audio.auslegung) {			
			AudioPlayer.embed("dr-player-"+this.item.auslegung.flashid, {
				soundFile: this.item.auslegung.file,
				titles: "Auslegung Evangelium"
			});  		
		}
	};
	
}
 
