/* /////////////////////////////////////////////////////////////////////////

title:   dropdown.js
author:  Case
url:     -
outline: BB Drop Down Menu JS.
version: 1.1
date:    12/05/2006
update:  10/02/2007

///////////////////////////////////////////////////////////////////////// */


function WriteSourceMain() {

	with(document) {
		write("")
	}

};

function WriteSourceSub() {

	with(document) {
		write("")
	}

};

var DropDownMenu = {

	/* 開くまでの待ち時間 */
	open_sleep: 100,

	/* 閉じるまでの待ち時間 */
	close_sleep: 500,

	timer: null,

	active_oid: null,

	// 開くメイン
	open: function(target_id)
	{
		// 開いているメニューを閉じる
		if (this.timer) {
			if (this.active_oid == target_id)
				clearTimeout(this.timer);
			else
				this._close();
		}
		this.active_oid = target_id;
		this.timer = setTimeout("DropDownMenu._open();", this.open_sleep);
		EventListener.add(document.documentElement, "click", DropDownMenu._close, true);
	},

	// 閉じるメイン
	close: function()
	{
		if (this.timer)
			clearTimeout(this.timer);
		this.timer = setTimeout("DropDownMenu._close();", this.close_sleep);
	},

	_open: function()
	{
		var obj = document.getElementById(this.active_oid);
	},

	_close: function()
	{
		EventListener.remove(document.documentElement, "click", DropDownMenu._close, true);
		clearTimeout(DropDownMenu.timer);
		delete DropDownMenu.timer;
	}

};

var SlideSubMenu = {

	/* 開くまでの待ち時間 */
	open_sleep: 100,

	/* 閉じるまでの待ち時間 */
	close_sleep: 0,

	timer: null,

	active_oid: null,

	// 開くメイン
	open: function(target_id)
	{
		// 開いているメニューを閉じる
		if (this.timer) {
			if (this.active_oid == target_id)
				clearTimeout(this.timer);
			else
				this._close();
		}
		this.active_oid = target_id;
		this.timer = setTimeout("SlideSubMenu._open();", this.open_sleep);
		EventListener.add(document.documentElement, "click", SlideSubMenu._close, true);
	},

	// 閉じるメイン
	close: function()
	{
		if (this.timer)
			clearTimeout(this.timer);
		this.timer = setTimeout("SlideSubMenu._close();", this.close_sleep);
	},

	_open: function()
	{
		var obj = document.getElementById(this.active_oid);
	},

	_close: function()
	{
		EventListener.remove(document.documentElement, "click", SlideSubMenu._close, true);
		clearTimeout(SlideSubMenu.timer);
		delete SlideSubMenu.timer;
	}

};

var EventListener = {
	add: function(obj, event, funcname, capture)
	{
		if (obj.addEventListener)
			obj.addEventListener(event, funcname, capture);
		else if (obj.attachEvent)
			obj.attachEvent("on" + event, funcname);
	},
	remove: function(obj, event, funcname, capture)
	{
		if (obj.removeEventListener)
			obj.removeEventListener(event, funcname, capture);
		else if (obj.detachEvent)
			obj.detachEvent("on" + event, funcname);
	}
};


function SwitchMenuCSS () {

	if ( document.getElementById ) {
		document.write ( '<style type="text/css">¥n' );
		document.write ( '#ad-space-large3{display:none;}¥n' );
		document.write ( '</style>¥n' );
	}

}

function SwitchMenu ( obj ) {

	if ( document.getElementById ) {
		var el = document.getElementById ( obj );
		var ar = document.getElementById ( "ad-space-large3" );
	} else if ( document.all ) {
		var el = document.all ( obj );
		var ar = document.all ( "ad-space-large3" );
	}

	if ( el.style.display != "block" ) {
		el.style.display = "block";
	} else {
		el.style.display = "none";
	}

}

