if('undefined' == typeof Emv.Videode) {
	
	Emv.Videode = {};
}

if('undefined' == typeof Emv.Videode.Coverflow) {
	
	Emv.Videode.Coverflow = {};
}

/**
 * Handle image subtitle and credits in video.de coverflow views.
 */
Emv.Videode.Coverflow.Legend = function(subtitleId, creditsId) {
	
	this.id            = subtitleId + '_' + creditsId;
	this.subtitleId    = subtitleId;
	this.creditsId     = creditsId;
	this.creditsFormat = '%c';
	
	this.getId = function() {
    	
		return this.id;
    };
    
    this.handleEvent = function(event) {
    	
    	if(event.name == Emv.Coverflow.Event._IMAGE_LOADED) {

    		var txt  = unescape(event.params.text);
    		var link = '';
    		
    		if( event.params.link != '' && event.params.customData != '' ) {
    			
    			link = '<a href="' + unescape(event.params.link) + '">' + unescape(event.params.customData) + '</a>';
    		} else if( event.params.customData != '' ) {
    			
    			link = unescape(event.params.customData);
    		}
    		
    		if( link != '' && txt != '' ) {
    			
    			txt = '<strong>' + link + '</strong>: ' + txt;
    		} else if( link != '' && txt == '' ) {
    			
    			txt = '<strong>' + link + '</strong>';
    		}
    			
    		document.getElementById(this.subtitleId).innerHTML = txt;
    		
    		var copy = this.creditsFormat;
    		if(event.params.copyright != '') {
    			
    			copy = copy.replace(new RegExp("\%c",  "gi"), unescape(event.params.copyright));
    		} else {
    			
    			copy = '';
    		}	
    		document.getElementById(this.creditsId).innerHTML  = copy;
    	}
    };
    
    this.setCreditsFormat = function(format) {
    	
    	this.creditsFormat = format;
    };
};
