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';
	}	
	

	// Audio
	if (this.options.audio.type != 'auslegung') {
		this.item = {
			audio: {
				file: 'http://www.domradio.de/comet/audio/mp3/24418.mp3'
			}
		}
	} else {
		this.item = {
			audio: {
				file: 'http://www.domradio.de/comet/audio/mp3/24417.mp3'
			}
		}
	}

	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);
		}
	}
	
	this.item.image = {
		file: 'http://www.domradio.de/resize/resize_cap/width_'+this.imageSize+'/20652.jpg'
	}
	
	this.write = function(element_id){
		this.theHTML = '<div id="dr-eva-container" style="width:'+this.options.width+'px;">';
		
		// Write 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>';
			}
		}
		
		// write Item
		this.theHTML += '<div id="dr-content"> ';	

		if (this.options.image.show) {
			this.theHTML += '	<img class="'+this.options.image.size+'"';
			this.theHTML += '		 src="'+this.item.image.file+'"';
			this.theHTML += '	/>';
		}

		this.theHTML += '  <div class="dr-content-text"> ';
		this.theHTML += 	'	<p>';
		this.theHTML += 	'		Auslegung zum Anh&ouml;ren von ';
		this.theHTML += 	'		Michael Pahl';
		this.theHTML += 	'	</p>';
		this.theHTML += 	'	<p>';
		this.theHTML += 	'		Evangelium des Tages:<br/>';
		this.theHTML +=  '		<a target="_blank" "href="http://www.domradio.de/evangelium/67131/donnerstag-02-september-2010.html">';
		this.theHTML += 	'		Lk 5,1-11</a>';
		this.theHTML += 	'	</p>';
		this.theHTML += 	'</div>';
		
		this.playerSize		= this.contentSize-10;
		if ( this.options.width >= 300 && this.options.image.size == 'small' ) {
			this.playerSize		= this.playerSize/2;
		}

		if (this.options.audio.show) {		
			AudioPlayer.setup("http://www.domradio.de/javascript/player.swf", {  
				width: this.playerSize,  
				initialvolume: 100,  
				transparentpagebg: "yes",  
				left: "000000",  
				lefticon: "FFFFFF"  
			});  
			
			this.id = Math.floor(Math.random()*100001);
			this.theHTML += 	'<div class="dr-player">';
			this.theHTML += 	'<div id="dr-player-'+this.id+'">Bitte Flash installieren.</div>';
			AudioPlayer.embed("dr-player-"+this.id, {
				soundFile: this.item.audio.file,
				titles: "Evangelium - "+this.item.audio.type
			});  
		}		
		this.theHTML += 	'  </div>';

		// Footer Begin
		this.theHTML += 		'<p class="dr-footer">';
		this.theHTML += 			'<a target="_blank" href="http://www.domradio.de">';
		switch (this.options.footer.style) {
			case 'logo':
				this.theHTML += '<img src="http://www.domradio.de/bilder/layout/domradio84_reduce.jpeg" />';
				break;
			default:
				this.theHTML += 'domradio.de';
		}
		this.theHTML += 			'</a>';
		this.theHTML += 		'</p>';		
		// Footer End
		
		this.theHTML += 	'</div>';	
		document.getElementById(element_id).innerHTML = this.theHTML;
	};
	
}
 