/**
 * teclan Drop Down Menu functionality.
 * Any changes to this file will not be supported by teclan.
 *
 * @copyright teclan 2009
 */

var timeout	= 500;
var closeTimer = 0;
var menuParent = 0;
var menuItem = 0;
 
var $m = function(id) {
  return document.getElementById(id);
};

// open hidden layer
function tcOpen(id) {	
  // cancel close timer
  tcCancelCloseTime();

  // close old layer
  tcClose();

  // get new layer and show it
  menuParent = $m('main-link' + id);
  menuItem = $m('tc' + id);
  menuItem.style.display = 'block';
}

// close showed layer
function tcClose() {
  if (menuItem) menuItem.style.display = 'none';
  if (menuParent) {
    menuParent.className = '';
  }
}

// go close timer
function tcCloseTime() {
  closeTimer = window.setTimeout(tcClose, timeout);
}

// cancel close timer
function tcCancelCloseTime() {
  if (closeTimer) {
    window.clearTimeout(closeTimer);
	closeTimer = null;
  }
  if (menuParent) {
    menuParent.className = 'sel';
  }
}

// close layer when click-out
document.onclick = tcClose; 
