/*

To use, apply any ID you want to toggle your HTML:

<a onclick="toggle('t1')">i get clicked</a>

<div id="t1">then i get open and closed</div>

*/

// TOGGLE

var isToggled = false;
var curWidget = null;
var toggleTimeOut = 0;


function $() {
	var elements = new Array();
	for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string')
			element = document.getElementById(element);
		if (arguments.length == 1)
			return element;
		elements.push(element);
	}
	return elements;
}
// toggling function
function toggle(obj) {
	
	
	var el = document.getElementById(obj);
	
	if(isToggled && (curWidget != null && el != null && el != curWidget)) curWidget.style.display = 'none';
	else isToggled = true;
	
	if (el != null) {
		el.style.display = (el.style.display == 'block') ? "none" : "block"; 
		curWidget = el;
	}
}

function toggleon(obj) {

	var el = document.getElementById(obj);
	
	if(isToggled && (curWidget != null && el != null && el != curWidget)) curWidget.style.display = 'none';
	else 								
	isToggled = true;
	
	if (el != null) {
	el.style.display = 'block' 
	curWidget = el;
	}
	clearTimeout(toggleTimeOut);
	
	
}

function setToggleTimeOut() {
toggleTimeOut = setTimeout("toggleoff()", 3000);
}

function toggleoff() {
	if (curWidget != null) {
		curWidget.style.display = 'none';
	}
}
