// HTML 4+ compliant menu
var g_OnState = "";
function DL_GetElementLeft(eElement) {
   if (!eElement && this) {eElement = this;}
   var DL_bIE = document.all ? true : false;
   var nLeftPos = eElement.offsetLeft;
   var eParElement = eElement.offsetParent;
   while (eParElement != null) {
      if(DL_bIE) {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") ) {
            nLeftPos += eParElement.clientLeft;
         }
      } else {
	  	// is gecko
         if(eParElement.tagName == "TABLE") {
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder)) {
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null) {
                  nLeftPos += 1;
               }
            } else if(nParBorder > 0) {
               nLeftPos += nParBorder;
            }
         }
      }
      nLeftPos += eParElement.offsetLeft;
      eParElement = eParElement.offsetParent;
   }
   return nLeftPos;
}

function DL_GetElementTop(eElement){
   if (!eElement && this) {eElement = this;}
   var DL_bIE = document.all ? true : false; // initialize var to identify IE
   var nTopPos = eElement.offsetTop;         // initialize var to store calculations
   var eParElement = eElement.offsetParent;  // identify first offset parent element
   while (eParElement != null) {
      if(DL_bIE) {
         if( (eParElement.tagName != "TABLE") && (eParElement.tagName != "BODY") ) {
            nTopPos += eParElement.clientTop;
         }
      } else {
         if(eParElement.tagName == "TABLE") {
            var nParBorder = parseInt(eParElement.border);
            if(isNaN(nParBorder)) {
               var nParFrame = eParElement.getAttribute('frame');
               if(nParFrame != null) {
                  nTopPos += 1;
               }
            } else if(nParBorder > 0) {
               nTopPos += nParBorder;
            }
         }
      }
      nTopPos += eParElement.offsetTop;
      eParElement = eParElement.offsetParent;
   }
   return nTopPos; 
}

function drawDrop(thisElement, thisMenu){
	var objM = document.getElementById(thisMenu);
	var objLeft = DL_GetElementLeft(document.getElementById(thisElement));
	var objTop = DL_GetElementTop(document.getElementById(thisElement));
	objLeft += 155;
	objM.style.position = 'absolute';
	objM.style.top = objTop + 'px';
	objM.style.left = objLeft + 'px';
	objM.style.visibility = 'visible';
}
function killDrop(thisMenu){
	if(isBad()){
		if(notHot(thisMenu)) document.getElementById(thisMenu).style.visibility = 'hidden';
	} else {
		document.getElementById(thisMenu).style.visibility = 'hidden';
	}
}
function notHot(thisMenu){
	var obj = document.getElementById(thisMenu);
	var minX = (DL_GetElementLeft(obj)+2); var minY = (DL_GetElementTop(obj)+2);
	var maxX = minX + (obj.offsetWidth-12); var maxY = minY + (obj.offsetHeight-12);
	if(posx > minX && posx < maxX && posy > minY && posy < maxY){return false;}else{return true;} 
}

var posx = 0; var posy = 0;
function getMouse(e) {
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		posx = e.pageX; posy = e.pageY;
	} else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
}

function isBad(){
	// cheap hack workaround: sniff for FF on Mac or Linux
	// if it is, then we use getMouse and notHot so the menus don't flicker
	var blnBad = false;
	if(navigator.product == "Gecko"){
		if(navigator.platform == "Mac" || navigator.platform == "Linux i686"){blnBad = true;}	
	}
	return blnBad;
}
function drawNavs() {
	// About WAO
	var strM = "<div id=\"onemenu\" style=\"visibility: hidden; z-index: 3; position: absolute;\" onMouseOver=\"drawDrop('one', 'onemenu');\" onMouseOut=\"killDrop('onemenu');\" class=\"menu\">";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/contactwao.php\" class=\"menu-link\">Contact</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/board.php\" class=\"menu-link\">Board of Directors</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/bylaws.pdf\" target=\"_blank\" class=\"menu-link\">Bylaws</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/houseofdelegates.php\" class=\"menu-link\">House of Delegates</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/president/\" class=\"menu-link\">President's Messages</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/pastpresidents.php\" class=\"menu-link\">Past Presidents</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/members.php\" class=\"menu-link\">Member Societies</a></div>";
	strM += "<div class=\"m-item\" ><a href=\"http://www.worldallergy.org/wao_societies/committeesandcouncils.php\" class=\"menu-link\">Committees &amp; Councils</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/journal_board.php\" class=\"menu-link\">Journal Editorial Board</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/wao_societies/web_board.php\" class=\"menu-link\">Web Editorial Board</a></div>";
	strM += "<div class=\"m-item\"  style=\"border-bottom: 0px;\"><a href=\"http://www.worldallergy.org/wao_societies/history_project.php\" class=\"menu-link\">WAO History Project</a></div>";

	strM += "</div>";
	//Ed Programs
	strM += "<div id=\"twomenu\" style=\"visibility: hidden; z-index: 3; position: absolute;\" onMouseOver=\"drawDrop('two', 'twomenu');\" onMouseOut=\"killDrop('twomenu');\" class=\"menu\">";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/adrc/\" class=\"menu-link\">Allergic Diseases Resource Center</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/educational_programs/online_lectures.php\" class=\"menu-link\">Asthma & Allergic Rhinitis: WAO Online Lecture Series</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/educational_programs/online_learning.php\" class=\"menu-link\" >Online CME</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/educational_programs/gloria/\" class=\"menu-link\">Global Resources in Allergy &ndash; (GLORIA)</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/educational_programs/world_allergy_forum/\" class=\"menu-link\">World Allergy Forum &ndash; (WAF)</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/esp/\" class=\"menu-link\">Emerging Societies Program</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/sc/\" class=\"menu-link\">Seminars and Conferences</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/interactive_case_reviews/\" class=\"menu-link\">Interactive Case Reports</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/conversations/\" class=\"menu-link\">Expert Interviews</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/educational_programs/webinars.php\" class=\"menu-link\">Webinar Archive</a></div>";
		strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/clinical_allergy_tips/\" class=\"menu-link\">WAO Clinical Allergy Tips</a></div>";
		strM += "<div class=\"m-item\"  style=\"border-bottom: 0px;\"><a href=\"http://www.worldallergy.org/quiz/\" class=\"menu-link\">WAO Allergy Quiz</a></div>";
	
	
	strM += "</div>";
	
		//Research Programs
	strM += "<div id=\"threemenu\" style=\"visibility: hidden; z-index: 3; position: absolute;\" onMouseOver=\"drawDrop('three', 'threemenu');\" onMouseOut=\"killDrop('threemenu');\" class=\"menu\">";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/allergic_rhinitis/\" class=\"menu-link\">Allergic Rhinitis Working Group</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/small_airways_group/\" class=\"menu-link\">Small Airways Working Group</a></div>";
	strM += "<div class=\"m-item\" ><a href=\"http://www.worldallergy.org/haealliance/\" class=\"menu-link\">WAO Hereditary Angioedema (HAE) International Alliance</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/research_fellowships/\" class=\"menu-link\">Research Fellowships</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/allergy_training/\" class=\"menu-link\">Allergy Training Resources</a></div>";
	strM += "<div class=\"m-item\" ><a href=\"http://www.worldallergy.org/research_document/\" class=\"menu-link\">Research Documents</a></div>";
	strM += "<div class=\"m-item\"  style=\"border-bottom: 0px;\"><a href=\"http://www.worldallergy.org/publications/\" class=\"menu-link\">WAO Publications</a></div>";
	
	strM += "</div>";
	

	
	//Links
	strM += "<div id=\"fivemenu\" style=\"visibility: hidden; z-index: 3; position: absolute;\" onMouseOver=\"drawDrop('five', 'fivemenu');\" onMouseOut=\"killDrop('fivemenu');\" class=\"menu\">";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/worldallergyweek/\" class=\"menu-link\">World Allergy Week</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/links/professional_links.php\" class=\"menu-link\">Links for Health Professionals</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/links/patient_links.php\"  class=\"menu-link\">Patient Information Links</a></div>";
	strM += "<div class=\"m-item\" style=\"border-bottom: 0px;\"><a href=\"http://www.worldallergy.org/pollen/\"  class=\"menu-link\">WAO World Pollen Network</a></div>";
	strM += "</div>";
	
	//Members 
	strM += "<div id=\"sixmenu\" style=\"visibility: hidden; z-index: 3; position: absolute;\" onMouseOver=\"drawDrop('six', 'sixmenu');\" onMouseOut=\"killDrop('sixmenu');\" class=\"menu\">";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/members/index.php\" class=\"menu-link\">Member News</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/members/only/journal/\" class=\"menu-link\">WAO Journal</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/members/only/photo_gallery/\" class=\"menu-link\">WAO Photo Gallery</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/UserFiles/file/WAO%20Hierarchy%20of%20Papers%20March%202010_FINAL.pdf\" target=\"_blank\" class=\"menu-link\">WAO Document Dev Process</a></div>";
	strM += "<div class=\"m-item\"><a href=\"http://www.worldallergy.org/members/only/directory/\" class=\"menu-link\">Membership Directory</a></div>";
	strM += "<div class=\"m-item\"  style=\"border-bottom: 0px;\"><a href=\"http://www.worldallergy.org/juniormembers/\" class=\"menu-link\">Junior Members Group</a></div>";
	strM += "</div>";
	
	
	
	document.writeln(strM);
	
}
if(isBad()) {document.onmousemove = getMouse;}
drawNavs();
