/**
 * @author jmcardle
 */

$(document).ready(replaceContent);

function replaceContent()
{
	if($('.swf').length > 0)
	{
		$('.swf').each(injectVideo);
	}
	
	if($('.facebook').length > 0)
	{
		$('.facebook').each(injectFB);
	}
	
}

function injectVideo(i,obj)
{
	var opts	= $(obj).text().split(',');
	var src		= opts[0];
	var h		= opts[1].split('=')[1];
	var w		= opts[2].split('=')[1];
	var f_var	= '';
	
	if(opts.length > 3)
	{
		f_var = opts[3];
	}
	
	$(obj).html('');
	$(obj).flash({swf:src,height:h,width:w,flashvars:f_var});
	$(obj).show();
}

function injectFB(i,obj)
{
	var opts = $(obj).text().split(',');
	var s = opts[0];
	var style = opts[1];
	
	var frame = '<iframe style="' + style + '" src="' + s + '" frameBorder="0" scrolling="no"></iframe>';
	$(obj).html(frame);
	$(obj).show();
} 