// text to Flash

$(document).ready(function(){
			
	jQuery.each($("div"), function(index, value) {
		var swf = $(this).attr("flash");
		if(swf){
			var alt = $(this).height();
			var larg = $(this).width();
							
			var texto = $(this).html();
			var _link = $(this).find("a").html();
			//alert(texto)
			var _color = ""
			try
			{
				_color = $(this).css("color");
				if(_color.match("rgb")!=null){
					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('');		
				}
				if(_color.match("#")!=null){
					_color = _color.substr(1)					
				}
			}
			catch(err)
			{}
			if(!_link){
				$(this).html("");
				$(this).flash({ 							  
					src: 'titulos/cabecalhos/'+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: 'titulos/cabecalhos/'+swf+'.swf',
					width: larg,
					height: alt,
					flashvars: { titulo: _link, link:  _link, hexa:_color }	
					
					},
					{
						version: 8
				});
			}

		}
	});
});