var asahi = asahi || new Object();
/**************************************************************************
 * Scroll
 **************************************************************************/
asahi.Scroll = function()
{
	this.initialize.apply(this, arguments);
}

asahi.Scroll.prototype =
{
	initialize: function()
	{
		this.scrollSpeed = 10;
		this.scrollRange;
		this.interval;
		
		this.initScroll();
	},
	
	
	initScroll: function()
	{
		var html = jQuery('#ScrlArea')
			.addClass('js')
			.prepend('<p id="ScrlLeft"><img src="/images08/common/btn_scrl_left.gif" alt="" width="19" height="105" /></p>')
			.append('<p id="ScrlRight"><img src="/images08/common/btn_scrl_right.gif" alt="" width="19" height="105" /></p>')
			.html();
		
		jQuery('#ScrlArea').html(html);
		
		/*
		 * 
		 */
		this.setButton();
		
		
		/*
		 * 
		 */
		this.setScrollRange();
		
		/*
		 * EVENT: resize
		 */
		var self = this;
		jQuery(window).resize(function(){self.setScrollRange()});
	},
	
	
	setButton: function()
	{
		jQuery('#ScrlLeft').find('img').hover
		(
			function(self)
			{
				return function()
				{
					self.scroll(self.scrollSpeed);
					self.interval = setInterval(function(){self.scroll(self.scrollSpeed);}, 10);
				};
			}(this),
			
			function(self)
			{
				return function()
				{
					clearInterval(self.interval);
				};
			}(this)
		);
		
		jQuery('#ScrlRight').find('img').hover
		(
			function(self)
			{
				return function()
					{
						self.scroll(-self.scrollSpeed);
						self.interval = setInterval(function(){self.scroll(-self.scrollSpeed)}, 10);
					};
			}(this),
			
			function(self)
			{
				return function()
					{
						clearInterval(self.interval);
					};
			}(this)
		);
	},
	
	
	setScrollRange: function()
	{
		this.scrollRange = Math.min(0, jQuery('#ScrlTarget').width() - jQuery('#ScrlTarget').find('ul').width());
		this.scroll(0);
	},
	
	
	scroll: function(dx)
	{
		var ox = parseInt(jQuery('#ScrlTarget').find('ul').css('margin-left'));
		var vx = ox + dx;
		if(vx>0)
		{
			vx = 0;
		}
		else if(vx<this.scrollRange)
		{
			vx = this.scrollRange;
		}
		
		jQuery('#ScrlTarget').find('ul').css('margin-left', vx + 'px');
	}
}




if(asahi.agent.getTarget())
{
	jQuery(function()
	{
	});
}



