

$( document ) . ready( function() {
    $( '.firstpane p.menu_head' ) . click( function() {
        $(this).next("div.menu_body"). slideDown("slow").siblings("div.menu_body").slideUp("slow");
	} );
    $( '.secondpane p.menu_head' ) . click( function() {
        $(this).next("div.menu_body"). slideDown("slow").siblings("div.menu_body").slideUp("slow");
    } );
    $( '.thirdpane p.menu_head' ) . click( function() {
        $(this).next("div.menu_body"). slideDown("slow").siblings("div.menu_body").slideUp("slow");
    } );
} );

$( document ) . ready( function() {
	$( '.firstpane p.menu_head' ) . click( function() {
        $(this).css({backgroundImage:"url([[--RootDir--]]common/img/bg_snav_headerbar_ac.jpg)","border":"1px solid #07b"});
    } );
	$( '.secondpane p.menu_head' ) . click( function() {
        $(this).css({backgroundImage:"none",backgroundColor:"#07b","margin":"5px 10px","border":"none"});
    } );
    $( '.thirdpane p.menu_head' ) . click( function() {
        $(this).css({backgroundImage:"none",backgroundColor:"#fff","marign":"5px 10px","border":"none"});
    } );
} );


$( document ) . ready( function() {
	$( '.firstpane p.menu_head a' ) . click( function() {
        $(this).css({backgroundImage:"url([[--RootDir--]]common/img/icon_arrow_whiteB.gif)",backgroundPosition:"5px center",backgroundRepeat:"no-repeat","color":"#fff"});
    } );
	$( '.secondpane p.menu_head a' ) . click( function() {
        $(this).css({backgroundImage:"url([[--RootDir--]]common/img/icon_arrow_whiteB.gif)",backgroundPosition:"5px center",backgroundRepeat:"no-repeat",backgroundColor:"#07b","margin":"5px 0","padding":"0 0 0 20px"});
    } );
    $( '.thirdpane p.menu_head a' ) . click( function() {
        $(this).css({backgroundImage:"url([[--RootDir--]]common/img/icon_arrow_grayB.gif)",backgroundPosition:"left center",backgroundRepeat:"no-repeat",backgroundColor:"#fff","margin":"5px 0","padding":"0 0 0 10px"});
    } );
} );


$(document).ready(function(){
	var easingTime = 300;
	var $ulTAR = $('#snav ul ul');
	var $currentTAR = $('#snav .current');
	var $slidemenuTAR = $('#snav li span');
	
	/*snav下の全てのULを閉じる*/
	$ulTAR.each(function(index){
		var $this = $(this);
		$this.hide();
	});
	/*spanタグのある所は全て開閉スライドメニューにする*/
	$slidemenuTAR.each(function(index){
		var $this = $(this);
		$this.click(function(){
			if($this.parent().hasClass('active') == false){
				activeMenuDeleteFunction($this.parent().parent().children('li'));
				$this.parent().toggleClass('active');
				$this.parent().children('ul').slideToggle(easingTime);
			}else{
				$this.parent().children('ul').slideToggle(easingTime,function(){$this.parent().toggleClass('active');});
			}
		})
	});
	/*currentクラスを検索し、上位ULにactiveクラスを付加*/
	if($currentTAR.length != 0){
	while(String($currentTAR[0].id) != "snav"){
		if(String($currentTAR[0].tagName) == "LI"){
			$currentTAR.addClass('active');
			$currentTAR.parent().show();
		}
		$currentTAR = $currentTAR.parent();
	}
	}
	/*同階層のactiveクラスを除去*/
	function activeMenuDeleteFunction(TAR){
		$(TAR).each(function(index){
			var $this = $(this);
			var hasC = $this.hasClass('active');
			if(hasC === true){
				$this.children('ul').slideToggle(easingTime,function(){$this.removeClass('active');});
			}
		});
	}
	$("#snav a.current").parent().addClass("current");
});

