﻿window.addEvent('domready', function() {
	//	accordion
	var showNum;
	if ($$('.entry_99999999').length > 0) {
		showNum = 1;
	}
	else {
		showNum =0;
	}
	/*
	new Accordion('.hEntryTitle', 'div.entrybody', {
		alwaysHide:true,
		show:showNum,
		onActive: function(toggler, element) {
			toggler.removeClass('hEntryTitle_bg');
		}, 
		onBackground: function(toggler, element) {
			toggler.addClass('hEntryTitle_bg');
		}
	});
	*/
	//	slide
	$$('.hEntryTitle').addEvent('click', entryToggle);
	$$('.hAreaTitle').addEvent('click', areaToggle);
	
	new SmoothScroll();
	
	//	auto lightbox
	$$('.entrybody').forEach(function(ent) {
		ent.getChildren('a').forEach(function(lnk) {
			if (!lnk.get('rel') && lnk.getChildren('img').length == 1) {
				lnk.set('rel', 'LightBox');
				//lnk.set('title', lnk.getChildren('img')[0].alt);
			}
		});
	});
	
	//	lightbox
	new SexyLightBox({'find':'LightBox', 'color':'white'});
	new SexyLightBox({'find':'LBWhite', 'color':'white'});
	new SexyLightBox({'find':'LBBlack', 'color':'black'});
});

//	entry toggle
function entryToggle(e) {
	var sl = this.mySlide;
	
	if (!sl) {
		var bdy = this.getNext('div.entrybody');
		if (bdy) {
			sl = new Fx.Slide(bdy, {'duration':'short'});
			this.mySlide = sl;
		}
	}
	
	if (sl) {
		sl.toggle();
		if (this.hasClass('hEntryTitle_bg')) {
			this.removeClass('hEntryTitle_bg');
		}
		else {
			this.addClass('hEntryTitle_bg');
		}
	}
}

//	area toggle
function areaToggle(e) {
	var sl = this.mySlide;
	
	if (!sl) {
		var bdy = this.getNext('.dvAreaBody');
		if (bdy) {
			sl = new Fx.Slide(bdy, {'duration':'short'});
			this.mySlide = sl;
		}
	}
	
	if (sl) {
		sl.toggle();
	}
}
