// クラスの宣言
var BrandControl = Class.create();

// クラスの定義
BrandControl.prototype = {

	// 初期化処理
	initialize: function(shoparea, scrollarea, scrollbar) {
	
		this.brandList = scrollarea;

		// スクロールバー描画処理
		this.scrollbar = new FLScroll(scrollbar, this.brandList);

		// 全店舗に対するイベントの追加
		var node = $(shoparea).getElementsByTagName('img');
		var shops = $A(node);
		shops.each(
			function(shop) {
				this.addEvent(shop);
			}.bindAsEventListener(this)
		);
	},

	// イベント追加処理
	addEvent: function(shop) {
		Event.observe(
			shop,
			'mouseover',
			function () {
				this.getBrand(shop.getAttribute('rel'));
			}.bindAsEventListener(this),
			false
		);
	},
		
	// ブランド情報の取得
	getBrand: function(shopno) {

		while ( true ) {

			// 読み込み不能時
			if ( !shopno ) {
				$(this.brandList).innerHTML = '';
				break;
			}

			// 商品情報を読む
			var ajax = new Ajax.Updater(
				{
					"success":this.brandList
				},
				'index.php',
				{
					asynchronous:false,
					method:'get',
					parameters:'act=ajax_brand&sn=' + shopno,
					onFailure: function() {
						$(this.brandList).innerHTML = '';
					}
				}
			);

			break;
		}
	
		// スクロールバーの再描画
		this.scrollbar.redraw();

	}

}
