function $_(n) {
	if(!n) return false;
	if(!document.getElementById(n)) return false;
	return document.getElementById(n)
}

function bubbling_no(e) {
	e = bubbling_ie(e); /* for ie */
	if (!e.cancelBubble) e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
	return false;
}
function bubbling_ie(e) {
	if (!e) var e = window.event;
	return e;
}

var prethis, preid, preeff;

function toggle_hide(_this, id, eff) {
	switch (eff) {
		case "fade":
			$("#"+id).fadeOut("fast");
			break; 

		case "none":
			$("#"+id).css({ display:"none"});
			break; 

		default:
			$("#"+id).slideUp("fast");
	}
	
	$(_this).removeClass("click-active");
}

function toggle(e, _this, id, eff) {
	if (prethis && $_(preid) && prethis != _this) toggle_hide(prethis, preid, preeff);
	prethis = _this;
	preid = id;
	preeff = eff;
	bubbling_no(e);
	if ($_(id)) {
		if (_this.className.indexOf("click-active") == -1) {
			$(_this).addClass("click-active");
			
			switch (eff) {
				case "fade":
					$("#"+id).fadeIn("fast");
					break;    

				default:
					$("#"+id).slideDown("fast");
			}
			
			$("#"+id).click(function(e) {
				bubbling_no(e);
			});

		} else {
			toggle_hide(_this, id, eff);
		}
		
		$(document).click(function() {
			toggle_hide(_this, id, eff);
		});
	}
}

function toggle_only(_this, id, eff) {
	if ($_(id)) {
		if (_this.className.indexOf("click-active") == -1) {
			$(_this).addClass("click-active");
			
			switch (eff) {
				case "fade":
					$("#"+id).fadeIn("fast");
					break;
				
				case "block":
					$("#"+id).css({ display:"block"});
					break;

				default:
					$("#"+id).slideDown("fast");
			}
		} else {
			toggle_hide(_this, id, eff);
		}
	}
}
