if (document.all) {
	var detect = navigator.userAgent.toLowerCase();
	var browser,thestring;
	var version = 0;

	if (checkIt('msie')) {
		//browser = "IE "
		browser = detect.substr(place + thestring.length,3);
		//document.title = browser + ' - ' + document.title;
	}
}

function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

function addEvents() {

  var oTopNav = document.getElementById('topnav');

  if (oTopNav.firstChild) {

    var oMainItem = oTopNav.firstChild;
    while (oMainItem) {

      if (oMainItem.firstChild) {

        var oSubItem = oMainItem.firstChild;
        while(oSubItem) {

          if (oSubItem.tagName == 'A') {

            oSubItem.onmouseover = function() {showPopup(this);};
            oSubItem.onmouseout = function() {hide();};

          }

          if (oSubItem.className == 'subnav') {

            if (parseFloat(browser) > 5.2) {

              oSubItem.innerHTML = ('<iframe src="about:blank" scrolling="no" frameborder="0"></iframe>' + oSubItem.innerHTML);
              var iFrame = oSubItem.firstChild;
              iFrame.style.width=oSubItem.offsetWidth+"px";
              iFrame.style.height=oSubItem.offsetHeight+"px";
              oSubItem.style.zIndex="99";

            }

            oSubItem.onmouseover=function() {clearTimer();};
            oSubItem.onmouseout=function() {hide();};

          }

          oSubItem = oSubItem.nextSibling
        }

      }

      oMainItem = oMainItem.nextSibling;

    }

  }

}

var timerID = 0;

function clearTimer() {

  if(timerID) {
    clearTimeout(timerID);
    timerID  = 0;
  }

}
function showPopup(popupLink) {

  hideall();
  clearTimer();

  popupLink = popupLink.parentNode;
  popup = popupLink.id;
  var oContainer = popupLink;//document.getElementById(popup);

  if(oContainer.firstChild) { // check for children
    var oChild = oContainer.firstChild;
    while(oChild) { // run over them
      if(oChild.nodeType==1 && oChild.className == 'subnav') {
        oChild.style.display = "block";
      }
      oChild = oChild.nextSibling;
    }
  } else {

    alert("no children");

  }

}

function hide() {

  timerID = setTimeout('hideall()',1000);

}

function hideall() {

  var oList = document.getElementsByTagName('ul');
  var i;

  for(i=0;i < oList.length;i++) {
    if(oList[i].className=='subnav') {
      oList[i].style.display='none';
    }
  }

}

addLoadEvent(addEvents);
addLoadEvent(hideall);

