
var root_uri = 'http://www.youcontent.nl/';

var videostyle = function()
{
	var images = document.getElementsByTagName('IMG');
	for(var i = 0; i < images.length; i++)
	{
		var vfile = images[i].getAttribute('video_file');
		if(!vfile)
			continue;
		var dims = {w: images[i].offsetWidth, h: images[i].offsetHeight};
		var replacement = document.createElement('DIV');

		var styleObj = images[i].getAttribute('style');
		if(styleObj == null)
			replacement.setAttribute('style', '');
		else if(typeof(styleObj) == 'string')
			replacement.setAttribute('style', styleObj);
		else
			replacement.style.setAttribute('cssText', styleObj.cssText);

		replacement.style.width  = dims.w + 'px';
		replacement.style.height = dims.h + 'px';
		replacement.style.overflow = 'hidden';

		var htmlStr = '<object width="'+dims.w+'" height="'+dims.h+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">';
		htmlStr += '<param name="movie" value="'+root_uri+'f4player/player.swf" />';
		htmlStr += '<param name="quality" value="high" />';
		htmlStr += '<param name="menu" value="false" />';
		htmlStr += '<param name="allowFullScreen" value="true" />';
		htmlStr += '<param name="scale" value="noscale" />';
		htmlStr += '<param name="allowScriptAccess" value="always" />';
		htmlStr += '<param name="swLiveConnect" value="true" />';
		htmlStr += '<param name="flashVars" value="';
		htmlStr += 'skin='+escape(root_uri)+'f4player%2Fskins%2Fclassic.swf'
		htmlStr += '&thumbnail='+escape(root_uri)+'fetch.php?f='+escape(escape(vfile))+'%26snapshot';
		htmlStr += '&video='+escape(root_uri)+'fetch.php?f='+escape(escape(vfile))+'%26stream';
		htmlStr += '&autoplay=0';
		htmlStr += '"/>';
		htmlStr += '<!--[if !IE]><!-->';
		htmlStr += '<object width="'+dims.w+'" height="'+dims.h+'" data="'+root_uri+'f4player/player.swf" type="application/x-shockwave-flash">';
		htmlStr += '<param name="quality" value="high" />';
		htmlStr += '<param name="menu" value="false" />';
		htmlStr += '<param name="allowFullScreen" value="true" />';
		htmlStr += '<param name="scale" value="noscale" />';
		htmlStr += '<param name="allowScriptAccess" value="always" />';
		htmlStr += '<param name="swLiveConnect" value="true" />';
		htmlStr += '<param name="flashVars" value="';
		htmlStr += 'skin='+escape(root_uri)+'f4player%2Fskins%2Fclassic.swf';
		htmlStr += '&thumbnail='+escape(root_uri)+'fetch.php?f='+escape(escape(vfile))+'%26snapshot';
		htmlStr += '&video='+escape(root_uri)+'fetch.php?f='+escape(escape(vfile))+'%26stream';
		htmlStr += '&autoplay=0';
		htmlStr += '"/>';
		htmlStr += '</object>';
		htmlStr += '<!--<![endif]-->';
		htmlStr += '</object>';

		images[i].parentNode.replaceChild(replacement, images[i]);
		replacement.innerHTML = htmlStr;
		i--;
	}
}

listen(window, 'load', function(){videostyle();});
