$j(function() {
	var current = new Object();
	var easing = 'swing';

	$j('ul.ryokinNav>li>div').each( function() {
		if ( $j(this).css('display') == 'block' ) {
			current.elm = $j(this);
			current.size = $j(this).find('li').size();
		}
	});

	$j('ul.ryokinNav>li>img').each( function() {
		$j(this).click(slide);
	});

	function slide() {
		var navList = $j(this).next();
		if ( navList.get(0).tagName == 'DIV' ) {
			var navSize = navList.find('li').size();
			var time = getDelay(navSize);
			var btnSrc = this.getAttribute('src');
			if ( navList.css('display') == 'none' ) {
				navList.animate( {height:'show'}, time, easing );
				this.setAttribute( 'src', btnSrc.replace('.gif', '_cr.gif') );
				if (current.elm) {
					var pSrc = current.elm.prev().attr('src');
					current.elm.prev().attr( 'src', pSrc.replace('_cr.gif', '.gif') );
					current.elm.animate( {height:'hide'}, getDelay(current.size), easing );
				}
				current.elm = navList;
				current.size = navSize;
			} else {
				navList.slideUp( time );
				navList.animate( {height:'hide'}, time, easing );
				this.setAttribute( 'src', btnSrc.replace( '_cr.gif', '.gif') );
				current.elm = null;
			}
		}
	}

	function getDelay(num) {
		return (num * 19) + 190;
	}
});

