// JavaScript Document

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_off."))
			{
				images[i].onmouseover = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
				}
				images[i].onmouseout = function() {
					this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
				}
			}
		}
	}
}
if(window.addEventListener) {
	window.addEventListener("load", smartRollover, false);
}
else if(window.attachEvent) {
	window.attachEvent("onload", smartRollover);
}

jQuery(function(){
	 
	// サブカテゴリをすべて隠す
	var categories = jQuery('#categories-list');
	jQuery('ul.children', categories).hide();
	 
	// カテゴリリストにアイコンを付加
	var categories_list = jQuery('li', categories);
	 
	// クリックイベントを設定する
	categories_list.each(function(){
		// サブカテゴリが有るときの処理
		if(jQuery(this).children('ul.children').length > 0) {
			// カテゴリリンクにクリックイベントを付加
				jQuery(this).children('a').click(function(){

					var parentClass = jQuery(this).parent().attr("class");
					if(parentClass.match(/arrow_open/)){
						jQuery(this).parent().removeClass('arrow_open');
					}else{
						jQuery(this).parent().addClass('arrow_open');
					}

					jQuery(this).siblings('ul.children').toggle('fast');
				return false;
			});
		}
	});
});
