$(document).ready(function(){

	flash_replace(".content h1.small", base_url + "/flash/h1_small.swf", 360, 26);
	flash_replace(".content h1:not(.small)", base_url + "/flash/h1.swf", 960, 26);
	flash_replace(".content h2:not(.geenflash)", base_url + "/flash/h2.swf", 360, 26);

});

var flash_replace		=	function(target, flashfile, width, height){
	
	$(target).each(function(){
		
		var randomID	=	"flash" + Math.floor(Math.random()*100);
		
		while($("#" + randomID).attr("id")){
		
			randomID	=	"flash" + Math.floor(Math.random()*100);
		
		}
		
		$(this).attr({"id": randomID});
		
		var content	=	$(this).text();
		
		content		=	content.replace(/&/g, "and");
		
		var targetID	=	$(this).attr("id");
		
		flash_replace_helper(targetID, content, flashfile, width, height);
		
	});
	
}

var flash_replace_helper	=	function(targetID, content, flashfile, width, height){
	
	var so = new SWFObject(flashfile, targetID, width, height, "8", "#fff");
	
	so.addVariable("tekst", content);

	so.addParam("wmode", "transparent");

	so.addParam("menu", "false");
	
	so.write(targetID);

}

