window.addEvent('domready', function() {
//ページ読み込み時のスタイル設定
$$('.dn').setStyle('display','none');
$$('.imgreplace','a.prev','a.next').setStyle('text-indent','-9999px');
//Tips初期設定
new Tips($$('.tips'));
//mainMenu初期設定
openingEffect = function(){
new mainMenu('menu', {transition: Fx.Transitions.backOut, duration: 500, onClick: function(ev, item) { ev.stop(); }});
}.delay(500);
//Ticker初期設定
new Ticker($('ticker'));
//DisableOutlineの設定
disable_links_outline();
//Multiboxの設定
new MultiBox('mb', {showControls:false, showNumbers:false, contentColor:'#210', offset:{x:0, y:-50} });
});

//(CLASS)メインメニューの設定
var mainMenu = new Class({
initialize: function(menu, options) {
this.setOptions(this.getOptions(), options);
this.menu = $(menu), this.current = this.menu.getElement('li.current');
this.menu.getElements('li').each(function(item){
item.addEvent('mouseenter', function(){ this.moveBg(item); }.bind(this));
item.addEvent('mouseleave', function(){ this.moveBg(this.current); }.bind(this));
window.addEvent('resize', function(){ this.moveBg(this.current); }.bind(this));
}.bind(this));
this.back = new Element('li').addClass('background').adopt(new Element('div').addClass('left')).injectInside(this.menu);
this.back.fx = this.back.effects(this.options);
if(this.current) this.setCurrent(this.current);
},

setCurrent: function(el, effect){
this.back.setStyles({left: (el.offsetLeft)+'px', width: (el.offsetWidth)+'px'});
(effect) ? this.back.effect('opacity').start(0,1) : this.back.setOpacity(1);
this.current = el;
},

getOptions: function(){
return {
transition: Fx.Transitions.sineInOut,
duration: 500, wait: false,
onClick: Class.empty
};
},

moveBg: function(to) {
if(!this.current) return;
this.back.fx.start({
left: [this.back.offsetLeft, to.offsetLeft],
width: [this.back.offsetWidth, to.offsetWidth]
});
}
});
mainMenu.implement(new Options);

//Ticker
var Ticker = new Class({
	setOptions: function(options) {
		this.options = Object.extend({
			speed: 500,
			delay: 3000,
			onComplete: Class.empty,
			onStart: Class.empty
		}, options || {});
	},
	initialize: function(el,options){
		this.setOptions(options);
		this.el = $(el);
		this.items = this.el.getElements('li');
		this.fx = new Fx.Styles(this.el,{duration:this.options.speed,onComplete:function() {
			this.items[this.current];
			var i = (this.current==0)?this.items.length:this.current;
			this.items[i-1].injectInside(this.el);
			var pos = this.items[this.current];
			this.el.effect('margin-left',{duration:this.options.speed,transition:Fx.Transitions.backOut}).start(0);
			}.bind(this)
		});
		this.current = 0;
		this.next();
	},
	next: function() {
		this.current++;
		if (this.current >= this.items.length) this.current = 0;
		var pos = this.items[this.current];
		this.fx.start({
			'margin-left': -pos.offsetWidth
		});
		this.next.bind(this).delay(this.options.delay+this.options.speed);
	}
});

//リンクの点線(クリックフォーカス)を消す
function disable_links_outline() {
var blur = function () { this.blur() };
for (var i = 0; i < document.links.length; i++)
document.links[i].onfocus = blur;
}

window.addEvent('domready', function() {
$$('img.hover').each(function(img) {
var src = img.getProperty('src');
var extension = src.substring(src.lastIndexOf('.'),src.length)
img.addEvent('mouseenter', function() { img.setProperty('src',src.replace(extension,'-hover' + extension)); });
img.addEvent('mouseleave', function() { img.setProperty('src',src); });
});
});
