/*
 * Tag Convert
 * 
 */
 
/**
 * 
 */
function convTag(str) {
	//re = str.match(/{([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),{review}{\/review},([^.]*)}/);

	while (str.match(/\{name\}([^{}]*)\{\/name\}/)) {
		replace_old = '{name}'+RegExp.$1+'{/name}';
		str = str.replace(replace_old, RegExp.$1);
	}
	while (str.match(/\{catchPhrase\}([^{}]*)\{\/catchPhrase\}/)) {
		replace_old = '{catchPhrase}'+RegExp.$1+'{/catchPhrase}';
		str = str.replace(replace_old, RegExp.$1);
	}
	while (str.match(/\{listPrice\}([^{}]*)\{\/listPrice\}/)) {
		replace_old = '{listPrice}'+RegExp.$1+'{/listPrice}';
                replace_new = RegExp.$1.replace(',', '&#044;');
		str = str.replace(replace_old, replace_new);
	}
	while (str.match(/\{priceRange\}([^{}]*)\{\/priceRange\}/)) {
		replace_old = '{priceRange}'+RegExp.$1+'{/priceRange}';
                replace_new = RegExp.$1.replace(',', '&#044;');
		str = str.replace(replace_old, replace_new);
	}

	while (str.match(/{([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^.]*),([^.]*)}/)) {
		
		replace_old  = '{';
		replace_old += RegExp.$1+',';
		replace_old += RegExp.$2+',';
		replace_old += RegExp.$3+',';
		replace_old += RegExp.$4+',';
		replace_old += RegExp.$5+',';
		replace_old += RegExp.$6+',';
		replace_old += RegExp.$7+',';
		replace_old += RegExp.$8+',';
		replace_old += RegExp.$9;
		replace_old += '}';

		html = "<!-- Arekao Affiliate Tag -->";
		html += '<div class="affliate_catalog">';
		html += "<!-- arekao_custom_tag" + RegExp.$1 + " -->";

		html += "<a class='link_category' href='http://"+RegExp.$9+".arekao.jp/catalog-"+RegExp.$2+".html' target='_blank'>";
		html += "                "+RegExp.$3+"       ";
                html += "</a>";

		if (RegExp.$7) {
			html += "<p><strong style='font-size:14px; line-height:150%'>";
			html += "<a class='link_category' href='http://"+RegExp.$9+".arekao.jp/catalog-"+RegExp.$2+".html' target='_blank'>";
			html += "<img class='item' src='"+RegExp.$7+"' border='0' alt ='"+RegExp.$3+"'>";
			html += "</a>";
			html += "</strong></p>";
		}
                if (RegExp.$8) {
			html += "<img src='http://arekao.jp/images/star_"+RegExp.$8+".gif' border='0'  alt='5'>";
		}
		if (RegExp.$4) {
			html += "<div style='padding: 2px 0px 0px 2px;'>";
			html += "<span class='weight_bold'>";
			html += "<span class='catch_copy'>"+RegExp.$4+"</span>";
			html += "</span>";
			html += "</div>";
		}
		if (RegExp.$5) {
			html += "<div style='padding: 2px 0px 0px 2px;'>";
			html += "        定価：<span class='weight_bold'><span class='price'>"+RegExp.$5+"</span></span>(税込み)</div>";
		}
		if (RegExp.$6) {
			html += "<div style='padding: 2px 0px 0px 2px;'>";
			html += "        販売価格：<span class='weight_bold'><span class='price'>"+RegExp.$6+"</span></span>(税込み)</div>";
		}
		html += "</div>";
		html += "<!-- Arekao Affiliate Tag -->";

		str = str.replace(replace_old, html);
	} 
	//alert('テスト中 ' + re);
	return str;
}

