/*#############################################################
Name: BeautifulJapanese[flashkit]
Version: 0.50
Author: Yasuhiro Monta [ideaman's]
URL: http://www.ideamans.com/
#############################################################*/
//初期設定->beautifulJapanese.swfをアップロードした場所に応じて、下記のパスを書き換えてください。

//例）baseSwfFile = '/common/swf/beautifulJapanese.swf';
function replaceFonts( targetId, targetTag, targetSwf, flaWidth, fontSize, fontLineHeight, charLimit, fontColorNormal, fontColorLink, fontColorHover ){
		var targetObj = targetTags="#"+targetId;
//		var targetObj2= "."+targetId +"_0";
		var textValue = $(targetObj).text();
		var textHref = 'none';
		var textTarget = '_top';
		var flaHeight ='50';
		var flaWidth ='100';
		var targetObj2 = targetObj + "> a";
		baseSwfFile= '/images/beautifulJapanese.swf';
		textHref = $(targetObj2).attr("href");
	//	alert(textHref);
	//utf-8でURLエンコード（firefox対応）
		chCode = "";
	encodeTextValue = "";
	num = "";
	encodeTextValueUnit = "";

	for (var ii = 0; ii < textValue.length; ii++) {
		chCode = textValue.charCodeAt(ii);
		if (chCode <= 0x7f) {
			encodeTextValue += textValue.charAt(ii);
		} else if (chCode >= 0x80 && chCode <= 0x7ff) {
			encodeTextValue += String.fromCharCode(((chCode >> 6) & 0x1f) | 0xc0);
			encodeTextValue += String.fromCharCode((chCode & 0x3f) | 0x80);
		} else {
			encodeTextValue += String.fromCharCode((chCode >> 12) | 0xe0);
			encodeTextValue += String.fromCharCode(((chCode >> 6) & 0x3f) | 0x80);
			encodeTextValue += String.fromCharCode((chCode & 0x3f) | 0x80);
		}
	}
	for (var jj = 0; jj < encodeTextValue.length; jj++) {
		chCode = encodeTextValue.charCodeAt(jj);
		if ((chCode >= 0x30 && chCode <= 0x39) || (chCode >= 0x40 && chCode <= 0x5A) ||
			(chCode >= 0x61 && chCode <= 0x7A) || (chCode == 0x2A) ||
			(chCode == 0x2D) || (chCode == 0x2E) || (chCode == 0x5F)) {
			encodeTextValueUnit += encodeTextValue.charAt(jj);
		} else {
			num = chCode.toString(16).toUpperCase();
			encodeTextValueUnit += "%" + (num.length == 1 ? "0" + num : num);
		}
	}
	
	sendParam = "?textValue=" + encodeTextValueUnit;
	sendParam += "&textHref=" + textHref;
	sendParam += "&textTarget=" + textTarget;
	sendParam += "&fontSize=" + fontSize;
	sendParam += "&fontLineHeight=" + fontLineHeight;
	sendParam += "&fontColorNormal=" + fontColorNormal;
	sendParam += "&fontColorLink=" + fontColorLink;
	sendParam += "&fontColorHover=" + fontColorHover;
	sendParam += "&targetSwf=" + targetSwf;
	sendParam += "&flaHeight=" + flaHeight;
	sendParam += "&flaWidth=" + flaWidth;
	swfCode = "<EMBED src="+ baseSwfFile + sendParam;
	swfCode += " quality=high wmode=transparent bgcolor=#FFFFFF";
	swfCode += " WIDTH=" + flaWidth;
	swfCode += " HEIGHT=" + flaHeight;
	swfCode += " NAME=" + targetId;
	swfCode += " ALIGN=top scale=noscale salign=lt wmode=transparent";
	swfCode += " TYPE=application/x-shockwave-flash";
	swfCode += " PLUGINSPAGE=http://www.macromedia.com/go/getflashplayer></EMBED>";
	$(targetObj).html(swfCode);

}
