// Photobattle Badge 
var Pb = window.Pb || {}
Pb.Badge = {
	
	css : '.pb_badge_content {font-family: Lucida Grande, Arial, Verdana, Sans-Serif;  color: #FFF;background:#000;  font-size: 14px;  line-height:1.6em;margin:0;padding:1px;overflow:hidden;position:relative;width:450px;}.pb_badge_content .pb_image{ margin:0; padding:0; }.pb_badge_content a{ color:#FFF; text-decoration:none; }.pb_badge_content a:hover{ color:#CCC; text-decoration:underline; }.pb_badge_content a img{ border:none !important; }.pb_badge_content img { border:none !important; padding:0 !important; margin:0 !important; }.pb_badge_content img.pb_logo{ position:absolute; top:25px; left:1px; }.pb_badge_content p.pb_legend{ margin:5px 15px; padding:0; float:left; }.pb_badge_content p.pb_legend small{ display:block; }.pb_badge_content .pb_rank{ float:right; display:inline; background:#a90832; padding:1px 9px; margin:16px 15px 0 0; }',
	badgeContent : '<div class="pb_badge_content"><a href="http://www.photobattle.net" title="Photobattle - online Fotowettbewerb"><img src="http://www.photobattle.net/images/logo_transparent.gif" alt="Photobattle" class="pb_logo" /></a><a href="http://photobattle.net/photos/1176"><img src="http://www.photobattle.net/sources/1176/medium/783833680e6da5cf6cd7481a44d8fa4c.jpg" alt="Foto von elsa zum Thema Stimmungen beim online Fotowettbewerb Photobattle" title="Foto von elsa zum Thema Stimmungen beim online Fotowettbewerb Photobattle" class="pb_image" id ="pb_image-1176" /></a><p class="pb_legend"><a href="http://photobattle.net/photos/1176">Stimmungen von elsa</a><small>beim online Fotowettbewerb <a href="http://www.photobattle.net">Photobattle</a></small></p><p class="pb_rank">Platz 3</p></div>',
	
	getCss : function() {
		var head = document.getElementsByTagName('head')[0];
		var style = document.createElement('style');
		style.setAttribute('type', 'text/css');
		
		if (style.styleSheet) {
			style.styleSheet.cssText = this.css;
		} else {
			style.appendChild(document.createTextNode(this.css));
		}
		head.appendChild(style);
	},
	
	getHtml : function() {
		var badge = document.getElementById('pb_badge-1176');
		
		badge.innerHTML = this.badgeContent;
	},
		
	init : function() {
		if (document.getElementById && document.createTextNode) {
			this.getCss();
			this.getHtml();
			
			var img = document.getElementById('pb_image-1176');


			img.onload = function(){ 
				width = img.width; 
				var badgeContainer = document.getElementById('pb_badge-1176').firstChild;
				badgeContainer.setAttribute('style', 'width:'+width+'px');
			}
		}
	}
	
}

Pb.Badge.init();