js.module('shop.auction');

shop.auction = {

	window_id: 'auction_frame',
	product_id: 0,
	window_width: 400,
	window_height: 200,

	splashWindow : function()
	{
		var divTag = document.getElementById(this.window_id);
		visual.show(divTag);
	},
	showWindow : function(id)
	{
		visual.showFade();
		this.product_id		= id;
		var divTag			= document.createElement("div");
		divTag.id			= this.window_id;

		new AJAX(js.getAjaxPath('shop.auction'), 'id=' + id, true, this.window_id);

		divTag.className		= this.window_id;
		divTag.style.width		= this.window_width + 'px';
		divTag.style.height		= this.window_height + 'px';
		divTag.style.display	= 'none';
		divTag.style.left		= ((visual.windowWidth()-parseInt(this.window_width))/2)  + 'px';
		divTag.style.top		= ((visual.windowHeight()-this.window_height)/2)+document.body.scrollTop  + 'px';
		document.body.appendChild(divTag);
	},
	checkMe : function()
	{
		var divTag = document.getElementById(this.window_id);
		new AJAX(js.getAjaxPath('shop.auction'), 'step=checkme&product_id=' + this.product_id + '&password=' + $$('auction_pwd'), true, this.window_id);
	},
	goBuy : function()
	{
		window.location.href = '/index.php?page=shop&view=buy&product_id=' + this.product_id;
	},
	returnPrice : function(value)
	{
		var divOldPrice		= document.getElementById('price_' + this.product_id);
		var divButton		= document.getElementById('auction_btn_' + this.product_id);
		var divPrice		= document.getElementById('auction_price_' + this.product_id);
		divPrice.innerHTML	= value;
		divButton.parentNode.removeChild(divButton);
		visual.show(divPrice);
		divOldPrice.className = 'priced';
	},
	closeWindow : function()
	{
		var divTag = document.getElementById(this.window_id);
		divTag.parentNode.removeChild(divTag);
		visual.hideFade();
	}
}
