// JavaScript Document

var itsf = {
	init: function() {
	},
	dominit: function() {
		winScroller = new Fx.Scroll(window, { duration: 500, transition: Fx.Transitions.Quart.easeOut });
		this.funcScroll();
		//this.funcTooltip();
	},
	funcScroll: function() {
		//「ページトップに戻る」アクション
		$('pagetop').addEvent('click', function() {
			winScroller.toTop();
		});
		$('pagetop').addEvent('mouseover', function() {
			this.setStyle('background-position', 'left -20px');
		});
		$('pagetop').addEvent('mouseout', function() {
			this.setStyle('background-position', 'left top');
		});
	},
	funcTooltip: function() {
		var speakerPath;
		var speakerTips = new Tips($$('.speaker-photo'), {
			timeOut: 700,
			maxTitleChars: 50,
			offsets: {'x': 15, 'y': 15}
		});
		$$('.speaker-photo').addEvent('mouseenter', function(tip){
			speakerPath = this.get('rel');
		});		
		speakerTips.addEvent('show', function(tip) {
			tip.fade('in');
			imgTag = '<img src="' + speakerPath + '" alt="" />'
			$$('.tip').set('html', imgTag);
		});
		speakerTips.addEvent('hide', function(tip){
		    tip.fade('out');
		});
	},
	indexFunc: function() {
		imgs = $$("#content .imgblock");
		imgs.set('opacity', 0);
		fadeShow = new Fx.Elements(imgs, { duration: 3000, wait: true });
		imgLength = $('indexMain').getChildren();
		imgLength = imgLength.length;
		this.fadeFunc(imgLength);
	},
	fadeFunc: function(state) {
		var o = {};

		if(state >= imgLength) state = 0;
		else state++;

		imgs.each(function(img, i) {
			if(state == i) {
				o[i] = { opacity: [1] };
			} else {
				o[i] = { opacity: [0] };
			}
		});

		(function(){
			fadeShow.start(o).chain(function(){
				itsf.fadeFunc(state);
			});
		}).delay(3000);
	}
}

window.addEvent('domready', function(){ itsf.dominit() });
window.addEvent('load', function(){ itsf.init() });
window.onresize = function() {
	//itsf.changeSize();
};