// JavaScript Document
// (c)TheDesignum

var fgh = {
	init: function() {
	},
	dominit: function() {
		this.returnFunc();
	},
	indexFunc: function() {
		imgs = $$("#content .imgblock");
		imgs.set('opacity', 0);
		fadeShow = new Fx.Elements(imgs, { duration: 3000, wait: true });
		this.fadeFunc(0);
	},
	fadeFunc: function(state) {
		var o = {};
		
		imgs.each(function(img, i) {
			if(state == i) {
				o[i] = { opacity: [1] };
			} else {
				o[i] = { opacity: [0] };
			}
		});

		if(state > 1) state = 0;
		else state++;

		(function(){
			fadeShow.start(o).chain(function(){
				fgh.fadeFunc(state);
			});
		}).delay(3000);
	},
	returnFunc: function() {
		//var winScroller = new Fx.Scroll(window, { duration: 400, transition: Fx.Transitions.Expo.easeOut });
		var winScroller = new Fx.Scroll(window, { duration: 400 });
		$$('.return-pagetop').addEvent('click', function() {
			winScroller.toTop();
		});
		$$('.room-gopagetop').addEvent('click', function() {
			winScroller.toTop();
		});
		$$('.room_single').addEvent('click', function() {
			var target = this.get('rel');
			var targetId = this.get('href');
			this.set('href', 'javascript:void(0)');
			winScroller.toElement(target);
		});
		$$('.room_twin').addEvent('click', function() {
			var target = this.get('rel');
			var targetId = this.get('href');
			this.set('href', 'javascript:void(0)');
			winScroller.toElement(target);
		});
		$$('.room_double').addEvent('click', function() {
			var target = this.get('rel');
			var targetId = this.get('href');
			this.set('href', 'javascript:void(0)');
			winScroller.toElement(target);
		});
		$$('.room_triple').addEvent('click', function() {
			var target = this.get('rel');
			var targetId = this.get('href');
			this.set('href', 'javascript:void(0)');
			winScroller.toElement(target);
		});
		$$('.room_fourth').addEvent('click', function() {
			var target = this.get('rel');
			var targetId = this.get('href');
			this.set('href', 'javascript:void(0)');
			winScroller.toElement(target);
		});
	}
}

window.addEvent('domready', function(){ fgh.dominit() });
//window.addEvent('load', function(){ fgh.init() });　描画にずれ？
window.onresize = function() {
	//fgh.changeSize();
};
window.onload = function() {
	fgh.init();
};