jQuery(function()
{
	var whatsNewSwitch = function(targetID)
	{
		for(var i = 1; i <= 4; i++)
		{
			document.getElementById('whatsNew' + i).style.display = 'none';
			document.getElementById('whatsNewMenu' + i).src = document.getElementById('whatsNewMenu' + i).src.replace('_on.' , '_off.');
		}
		document.getElementById(targetID).style.display = 'block';
	}
	for(var i = 1; i <= 4; i++)
	{
		document.getElementById('whatsNewMenu' + i).onclick = (function(i)
			{
				return function()
				{
					whatsNewSwitch('whatsNew' + i);
					this.src = this.src.replace('_off.' , '_on.');
				}
			}
		)(i);
		
		document.getElementById('whatsNewMenu' + i).onmouseover = function()
		{
			this.src = this.src.replace('_off.' , '_on.');
		}
		document.getElementById('whatsNewMenu' + i).onmouseout = (function(i)
			{
				return function()
				{
					if(document.getElementById('whatsNew' + i).style.display == 'none')
					{
						this.src = this.src.replace('_on.' , '_off.');
					}
				}
			}
		)(i);
		document.getElementById('whatsNewMenu' + i).style.cursor = 'pointer';
	}
	var slideBunner =
	{
		btn1  : jQuery('#slideBnrArrowL') ,
		btn2  : jQuery('#slideBnrArrowR') ,
		bnrs  : jQuery('#slideBnr a') ,
		box   : jQuery('#slideBnr div') ,
		markbox : jQuery('#slideBnrMark') ,
		
		current : 0 ,
		
		slide : function(type)
		{
			if(type == 'l') this.current++;
			if(type == 'r') this.current--;
			
			if(this.current < 0) this.current = this.bnrs.size() - 1;
			if(this.current >= this.bnrs.size()) this.current = 0;
			
			this.box.animate(
				{
					marginLeft : this.current * -450
				},
				500
			);
			for(var i = 0; i < this.bnrs.size(); i++)
			{
				jQuery('#sidemark_' + i).attr('src' , './img/top/slide_mark_off.gif');
			}
				jQuery('#sidemark_' + this.current).attr('src' , './img/top/slide_mark_on.gif');
		},
		init : function()
		{
			this.btn1.click(function()
			{
				slideBunner.slide('l');
			});
			this.btn2.click(function()
			{
				slideBunner.slide('r');
			});
			this.box.css({width : this.bnrs.size() * 450});
			
			for(var i = 0; i < this.bnrs.size(); i++)
			{
				if(i == 0)
				{
					this.markbox.append('<img src="./img/top/slide_mark_on.gif" id="sidemark_' + i + '" />');
				}
				else
				{
					this.markbox.append('<img src="./img/top/slide_mark_off.gif" id="sidemark_' + i + '" />');
				}
			}
		}
	}
	slideBunner.init();
});
