// JavaScript Document

jQuery.fn.extend({
	subMenuDoor : function(opt) {
		if( !opt ) opt = new Opbject();
		var p, c;
		if( opt.parent != null ) p = opt.parent;
		else return false;
		if( opt.child != null ) c = opt.child;
		else return false;
		var a = opt.active != null ? opt.active : false;
		
		var _rt = $(this);
		var cnt=0;
		_rt.each( function() {
			var _p = $(this).find(p);
			var _c = $(this).find(c);
			if( cnt != opt.active ) {
				_p.attr('rel', 'close').parent().addClass("close");
				_c.hide();
			} else {
				_p.addClass("act").attr('rel', 'open').find("img").attr('src', $(this).find("img").attr('src').replace('.jpg', '_act.jpg') );
			}
			_p.filter(":not(.exeption)").click( function() {
				var now = $(this).attr('rel');
				if( now == 'open' ) {
					_c.slideUp();
					$(this).removeClass("act").attr('rel', 'close').parent().addClass("close");
					$(this).find("img").attr('src', $(this).find("img").attr('src').replace('_act.jpg', '.jpg') );
				} else {
					_rt.each( function() {
						var aNow = $(this).find(p).attr('rel');
						if( aNow == 'open' ) {
							$(this).find(c).slideUp();
							$(this).find(p).removeClass("act").attr('rel', 'close').parent().addClass("close");
							$(this).find(p+" img").attr('src', $(this).find("img").attr('src').replace('_act.jpg', '.jpg') );
						}
					} );
					
					_c.slideDown();
					$(this).addClass("act").attr('rel', 'open').parent().removeClass("close");
					$(this).find("img").attr('src', $(this).find("img").attr('src').replace('.jpg', '_act.jpg') );
				}
				return false;
			} );
			cnt++;
		} );
		return this;
	}
});

