// text to Flash
String.prototype.startsWith = function(str)
{return (this.match("^"+str)==str)}

$(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();
			$(this).css("visibility","visible");
			$(this).css("display","block");
			//alert($(this).html());
			var _link = $(this).find("a").html();
			var _color = ""
			try
			{
				_color = $(this).css("color");
				//			alert(_color)		
				if(_color.indexOf("#")!=-1)
				{
					_color = _color.substring(1);
					//alert(_color)
				}
				else
				{
					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
				});
			}

		}
	});
});
