// text to Flash

$(document).ready(function(){
	
	$('*[class^="flash"]').each(function () {
		var swf = $(this).attr('class').split('flash-')[1] 
		
		if(swf){
			var alt = $(this).height();
			var larg = $(this).width();
							
			var texto = $(this).html();
			$(this).css("visibility","visible");
			$(this).css("display","block");
			//alert($(this).html());
			var _link = $(this).find("a").html();
			var _color = ""
			try
			{
				_color = $(this).css("color");
				var parts = _color
       				 .match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
					// parts now should be ["rgb(0, 70, 255", "0", "70", "255"]
					delete (parts[0]);
				for (var i = 1; i <= 3; ++i) {
					parts[i] = parseInt(parts[i]).toString(16);
				if (parts[i].length == 1) parts[i] = '0' + parts[i];
				}
			
			_color = parts.join('');			
			}
			catch(err)
			{}
			if(!_link){
				$(this).html("");
				$(this).flash({ 							  
					src: 'images/swf/'+swf+'.swf',
					width: larg,
					height: alt,
					flashvars: { titulo: texto, hexa:_color }	
					},
					{
						version: 8
				});
			}
			else{
			var _link =	$(this).find("a").attr("href");
			$(this).html("");
				$(this).flash({ 							  
					src: 'images/swf/'+swf+'.swf',
					width: larg,
					height: alt,
					flashvars: { titulo: texto, link:  _link, hexa:_color }	
					
					},
					{
						version: 8
				});
			}

		}
	});
});
