function build_extrahtml (t, s, w, h) {
	switch (t) {
		case '_er_youtube':
			v = /v=(\w+)/i.exec(s)[1] || '';
			return '<object width="'+w+'" height="'+h+'"><param name="movie" value="http://www.youtube.com/v/'+v+'"></param><param name="allowFullScreen" value="false"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+v+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'+w+'" height="'+h+'"></embed></object>';
		break;	
		case '_er_flash':
			var sfo = new SWFObject(s, 'flash'+((new Date()).getTime()), w, h, '9');
			sfo.addParam('allowfullscreen', 'false');
			sfo.addParam('allowscriptaccess', 'never');
			sfo.addParam('alt', s);
			return sfo.getSWFHTML();
		break;	
		case '_er_video':
			switch (s.replace(/^.+\./, '')) {
				case 'flv':
				case 'mp4':
					var sfo = new SWFObject('player.swf', 'video'+((new Date()).getTime()), w, h, '9', '#FFFFFF');
					sfo.addParam('allowfullscreen', 'false');
					sfo.addParam('allowscriptaccess', 'never');
					sfo.addParam('alt', s);
					sfo.addParam('flashvars', 'file='+s);
					return sfo.getSWFHTML();
				break;
				case 'avi':
				case 'mpg':
				case 'wmv':
					h = h * 1 + 60;
					return '<object type="application/x-mplayer2" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+w+'" height="'+h+'"><param name="url" value="'+s+'" /><param name="autostart" value="true" /><param name="balance" value="0" /><param name="currentPosition" value="0" /><param name="currentMarker" value="0" /><param name="enableContextMenu" value="false" /><param name="enableErrorDialogs" value="false" /><param name="enabled" value="true" /><param name="fullScreen" value="false" /><param name="invokeURLs" value="false" /><param name="mute" value="false" /><param name="playCount" value="1" /><param name="rate" value="1" /><param name="ShowStatusBar" value="true" /><param name="uimode" value="full" /><param name="volume" value="100" /><embed width="'+w+'" height="'+h+'" type="application/x-mplayer2" src="'+s+'" enableContextMenu="0" autoStart="1" stretchToFit="1" showStatusBar="1" showPositionControls="0" BufferingTime="3" AutoSize="1" windowlessVideo="1" showcontrols="1" playCount="1" volume="0"  pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" /></object>';
				break;
			}
		break;
	}
}

function parse_extrahtml (content) {
	var width, height, src;
	var piece, html;
	
	html 	= content.innerHTML;
	piece 	= /<img[\s]*class=['"]?(_er_youtube|_er_flash|_er_video)['"]?[^>]+>/i.exec(html);
	
	while (null != piece){
		width 	= /width=['"]?(\d+)/i.exec(piece[0])[1] || '';
		height 	= /height=['"]?(\d+)/i.exec(piece[0])[1] || '';
		src 	= /alt=['"]?([^" ]+)/i.exec(piece[0])[1] || '';
		html 	= html.replace(piece[0], build_extrahtml(piece[1], src, width, height));
		piece 	= /<img[\s]*class=['"]?(_er_youtube|_er_flash|_er_video)['"]?[^>]+>/i.exec(html);
	}
	
	content.innerHTML = html;
}

function number_format( number, decimals, dec_point, thousands_sep ) {
    var n = number, prec = decimals;
    var toFixedFix = function (n,prec) {
        var k = Math.pow(10,prec);
        return (Math.round(n*k)/k).toString();
    };
 
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
    var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;
 
    var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;
 
    var abs = toFixedFix(Math.abs(n), prec);
    var _, i;
 
    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;
 
        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');
        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }
    if (s.indexOf(dec) === -1 && prec > 1) {
        s += dec+new Array(prec).join(0)+'0';
    }
    return s;
}