var      div = document.getElementById( 'WebdoAdvanceTool' );
var bookFlag = document.getElementById( 'WebdoAdvanceToolBookFlag' ).value;

var html;
var urlPath;

html = div.innerHTML;
urlPath = ( bookFlag == 1 ? "books" : "store" );

	for( i=0; i < salableList.length; i++ ){
		// 作業をする
		// 画像が存在するか？
		reg = new RegExp( "%IMG" + ( i + 1 ) + "%", "g" );
		if( salableList[i][4] != "" ){
			html = html.replace( reg, 
				  "<a href = 'http://webdo.co.jp/" + urlPath + "/?com=shopItem&store_id=" +  salableList[i][2] +"&iid=" +  salableList[i][1] + "&ai=" + aff_id + "'>"
				+ "<img src='http://webdo.co.jp/img/store/" + salableList[i][2]+ "/" + salableList[i][1] + "_1_s." + salableList[i][4] + "' border='0'>"
				+ "</a>" );
		} else {
			html = html.replace( reg, 
				  "<a href = 'http://webdo.co.jp/" + urlPath + "/?com=shopItem&store_id=" +  salableList[i][2] +"&iid=" +  salableList[i][1] + "&ai=" + aff_id + "'>"
				+ "<img src='http://webdo.co.jp/img/store/10000001/noimage.jpg' width='50' height='50' border='0'>"
				+ "</a>" );
		}
		
		// 商品名
		reg = new RegExp( "%NAME" + ( i + 1 ) + "%", "g" );
		html = html.replace( reg, "<a href = 'http://webdo.co.jp/" + urlPath + "/?com=shopItem&store_id=" +  salableList[i][2] +"&iid=" +  salableList[i][1] + "&ai=" + aff_id + "'>" + salableList[i][0] + "</a>" );

		// 価格
		reg = new RegExp( "%PRICE" + ( i + 1 ) + "%", "g" );
		html = html.replace( reg, "\\" + salableList[i][6] + "円" );

	}
	
	if( salableList.length < 16 ){
		for( i=salableList.length; i < 16; i++ ){
			reg = new RegExp( "%IMG" + ( i + 1 ) + "%", "g" );
			html = html.replace( reg, "" );
			reg = new RegExp( "%NAME" + ( i + 1 ) + "%", "g" );
			html = html.replace( reg, "" );
			reg = new RegExp( "%PRICE" + ( i + 1 ) + "%", "g" );
			html = html.replace( reg, "" );
		}
	}
	
	div.innerHTML = html;
	div.style.display="";
