
(function(){

if(!window.winkball) window.winkball = {};
if(!winkball.flash) winkball.flash = {};
if(!winkball.flash.util) winkball.flash.util = {};
if(!winkball.flash.util.HTMLContainer) winkball.flash.util.HTMLContainer = {};
if(!winkball.flash.util.HTMLContainer.getBackgroundColour) {

	winkball.flash.util.HTMLContainer.getBackgroundColour = function(id) {
		
		var el;
		
		if(Object.prototype.toString.call(id) == '[object String]') {

			el = document.getElementById(id);

		} else {
			
			el = id;
		}
	
		if(!el) {

			//winkball.log.error('Element not found, cannot return background colour');
			return null;
		}

		var backgroundColour = el.style['backgroundColor'];
		
		// For IE
		if(!backgroundColour && el.currentStyle) {

				backgroundColour = el.currentStyle['backgroundColor'];
			
			if(backgroundColour == 'auto') {
				backgroundColour = null;
			}

		// For everyone else
		} else if (!backgroundColour || backgroundColour == 'auto') {

			var css = document.defaultView.getComputedStyle(el, null);
			backgroundColour = css ? css['backgroundColor'] : null;
		}
	
		// Webkit returns rgba(0, 0, 0, 0), everyone else returns null if no background colour set
		if(backgroundColour != null && backgroundColour != 'rgba(0, 0, 0, 0)' && backgroundColour != 'transparent') {

			//winkball.log.info('Found background colour: ' + backgroundColour);
			return backgroundColour;
			
		} else {

			if(el != document.body) {

				//winkball.log.info('Element has no background colour, checking parent');
				return winkball.flash.util.HTMLContainer.getBackgroundColour(el.parentNode);
			}
		}

		return null;
	};
}

var id = 'wb-766';
var w = '390';
var h = '350';

document.write('<div id="'+id+'" class="wb-embed wb-video" style="width:'+ w +'px; height:'+ h +'px;"></div>');

var bg = winkball.flash.util.HTMLContainer.getBackgroundColour(id);
var url = 'http://www.winkball.com/video-embed-web/?guid=64bec669-ff6d-4255-bcb0-61b755a23fc9&bg=' + escape(bg);

document.getElementById(id).innerHTML = '<iframe src="'+ url +'" frameborder="0" width="100%" height="100%" scrolling="no" style="background-color:'+bg+'" ></iframe>';
})();
