	var oOnTop = null;
  var hideTimer = null;
	var bGetInside = false;
  var hideDelay = 1000;
	var bDOM = document.getElementById ? true : false;

	function showPopup( menunum , evt )
	{
		var oPmenu = document.getElementById( "submenu" + menunum );
		if ( oOnTop != oPmenu )
		{
				if ( oOnTop != null )
				{
					hidePopup()
				}

    		startTracking();
    		bGetInside = false;

				oPmenu.style.visibility = "visible";
				oOnTop = oPmenu;
        oOnTop.onmouseover = popupMouseIn;
        oOnTop.onmouseout = popupMouseOut;
		}
    else
    {
        clearHideDelay();
    }
		return false;
	}
  function popupMouseIn()
  {
    bGetInside = true;
    if( hideTimer != null)
    {
      clearTimeout( hideTimer );
      hideTimer = null;
    }
  }
  function popupMouseOut()
  {
    bGetInside = false;
    hideTimer = setTimeout("hideByDelay()", hideDelay );
  }
  function hideByDelay()
  {
    if( bGetInside )
    {
      hideTimer = null;
      return;
    }
    hidePopup();
  }
	function startTracking()
	{
		document.onclick = hidePopup;
	}
	function stopTracking()
	{
		document.onclick = null;
	}
	function switchPopup( menu, evt )
	{
			if ( oOnTop != null)
			{
				hidePopup();
			}
			else
			{
				showPopup(menu, evt);
			}
//			if ( !evt.cancelBubble ) evt.stopPropagation();
			evt.cancelBubble = true;
      return false;
	}
	function hidePopup()
	{
			if ( oOnTop != null)
			{
				oOnTop.style.visibility = "hidden";
				oOnTop = null;
        clearHideDelay();
			}
			stopTracking();
	}
  function clearHideDelay()
  {
        if( hideTimer != null )
        {
          clearTimeout(hideTimer);
          hideTimer = null;
        }
  }
  function clearHideByDelay()
  {
        if( hideTimer != null )
        {
          clearTimeout(hideTimer);
          hideTimer = null;
        }
  }
  function setHideByDelay(t)
  {
      clearHideByDelay();
      hideTimer = setTimeout("hideByDelay()",t);
  }
//
// this will hide popup if mouse is out from menu item
//
  function menuOut()
  {
    setHideByDelay(hideDelay);
  }

  function openWin(url,w,h)
  {
    window.open(url,"_blank","width="+w+",height="+h);
  }

  objFreeInputRow = null;

  function hideFreeText()
  {
  	if (objFreeInputRow != null)
	{
		objFreeInputRow.style.display = "none";
		objFreeInputRow = null;
	}
  }

  function showFreeText(input,text_id)
  {
  	obj = document.getElementById(text_id);
	  if (obj == null) {return;}

//	alert(input.checked);
	  obj.style.display = (input.checked)? "" : "none";

	if (input.checked) objFreeInputRow = obj;
  }

  function showBB (sid)
  {
  	o = document.getElementById(sid);
    if (o == null) return;
    o.style.display = "block";
  }
  function checkAnswers(frm)
  {
    n = frm.length;
    nonempty = /\S+/;
    var check_count = 0;
    var last_checked = false;
    for (i = 0; i < n; i++)
    {
      elem = frm.elements.item(i);
      if (elem.type == "checkbox" || elem.type == "radio")
      {
        last_checked = elem.checked;
        if (elem.checked) check_count++;
      }
      else if (elem.type == "text")
      {
        str = elem.value;
        if (last_checked)
        {
            if (!nonempty.test(str))
            {
              alert(error_poll_invalid_answer);
              return false;
            }
        }
      }
    }
    if (check_count == 0) {
        alert(error_poll_select_answer);
        return false;
    }
    return true;
  }
  function openGalleryPhotoWindow(url,w,h)
  {
	  win_height = h + 40;
	  win_width = w + 40;
	  openWin(url,win_width,win_height);
  }


  function showFullBanner() {
  	for(var i = 0;i< arguments.length;i++) {
  		var obj = document.getElementById(arguments[i]);
  		if(obj != null) {
  			obj.style.display = "block";
  		}
  	}
  }
  function hideFullBanner() {
  	for(var i = 0;i< arguments.length;i++) {
  		var obj = document.getElementById(arguments[i]);
  		if(obj != null) {
  			obj.style.display = "none";
  		}
  	}
  }
