	id_flash = 1;
	base_url_swf = "zaglavie.swf";
	base_w = "100%";
	base_h = "100%";
	base_salign = "";
	base_bg_color = "";
	base_transparent = "transparent"
	base_url = "&url_linc=";
	text_replace = "";
	kod = "";
	
	
function SWFobj(div_text, url_swf, w, h, salign, bg_color, transparent, url){
kod = '<object id="pagename'+id_flash+'" width="'+w+'" height="'+h+'" align="middle" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">';
kod = kod + '<param name="FlashVars" value=\'var1='+div_text+url+'\' /><param name="bgcolor" value="'+bg_color+'" />';
kod = kod + '<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+url_swf+'" /><param name="salign" value="'+salign+'" /><param name="wmode" value="'+transparent+'" /><param name="quality" value="high" />';
kod = kod + '<embed FlashVars=\'var1='+div_text+url+'\' name="pagename" src="'+url_swf+'" bgcolor="'+bg_color+'" width="'+w+'" height="'+h+'" wmode="'+transparent+'" salign="'+salign+'" quality="high" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
//document.write(kod);
id_flash++;
}


	div_arr = document.getElementsByTagName("div");
	for(i = 0; i < div_arr.length; i++){
	div = div_arr.item(i);
	if(div.className != "swf") continue;
	
	//определение дива
	//div_text = div.firstChild.nodeValue;
	div_text = div.innerHTML;
	correct_SWFtxt (div_text);
	if (!div.getAttributeNode("swf") || !div.getAttributeNode("swf").value) url_swf=base_url_swf; else url_swf = div.getAttributeNode("swf").value;
	if (!div.getAttributeNode("w") || !div.getAttributeNode("w").value) w=base_w; else w = div.getAttributeNode("w").value;
	if (!div.getAttributeNode("h") || !div.getAttributeNode("h").value) h=base_h; else h = div.getAttributeNode("h").value;
	if (!div.getAttributeNode("salign") || !div.getAttributeNode("salign").value) salign=base_salign; else salign = div.getAttributeNode("salign").value;
	if (!div.getAttributeNode("bg_color") || !div.getAttributeNode("bg_color").value) bg_color=base_bg_color; else bg_color = div.getAttributeNode("bg_color").value;
	if (!div.getAttributeNode("transparent") || !div.getAttributeNode("transparent").value || div.getAttributeNode("transparent").value=="1") transparent=base_transparent; else transparent = div.getAttributeNode("transparent").value;
	if (!div.getAttributeNode("url") || !div.getAttributeNode("url").value) url=base_url; else url = "&url_linc="+div.getAttributeNode("url").value;
	SWFobj(div_text, url_swf, w, h, salign, bg_color, transparent, url);
	idi = id_flash-1;
	flash_obj = document.getElementById('pagename'+idi);
	
	//замена
	//div.replaceChild(flash_obj, div.firstChild);
	div.innerHTML = kod;
		
	}
	
	function correct_SWFtxt (text) {
	text = text.replace(/style="?([\s\:\;\w\d]+)"?\s/g, "style=\"$1\"\ ");
	text = text.replace(/color="?(#?[\w\d]+)"?/g, "color=\"$1\"");
	text = text.replace(/size="?([\w\d]+)"?/g, "size=\"$1\"");
	text = text.replace(/align="?([\w\d]+)"?/g, "align=\"$1\"");
	text = text.replace(/href="?([\/\:\-\_\.\w\d]+)"?/g, "href=\"$1\"");
	text = text.replace(/src="?([\/\:\-\_\.\w\d]+)"?/g, "src=\"$1\"");
	text = text.replace(/target="?([\_\w]+)"?/g, "target=\"$1\"");
	div_text = text;
	return div_text;
}


