document.observe('dom:loaded', function() {
	new SitemapDepth2;
});
var SitemapDepth2 = Class.create({
	initialize: function() {
		$$('.depth1 a').invoke('observe','click',this.getDepth2.bind(this));
	},
	getDepth2: function( ev ) {
		var el = ev.element();
		var target = el.up('li');
		var no = el.className;
		ev.stop();
		if ( target.down('ul') ) {
			target.down('ul').toggle();
		} else {
		new Ajax.Request( '/main/sitemap/depth2?no='+no , {
			onSuccess: function(transport) {
				var text = transport.responseText;
				if ( text == '' ) {
					location.assign(el.href);
				}
				target.insert(text);
			}
		});
		}
	}
});


