d=document;
l=d.layers; //netscape 4 detection trick.
op=navigator.userAgent.indexOf('Opera')!=-1; 
ie=navigator.userAgent.indexOf('MSIE')!=-1;
win=navigator.platform.indexOf('Win')!=-1;
ver55=navigator.userAgent.indexOf('5.5')!=-1;
ver6=navigator.userAgent.indexOf('6')!=-1;

xAdj = 0;
yAdj = -40;
pcYAdj = 1;

var timerID = 0;

if ((ie) && (!win)){macIE = 1;} else {macIE = 0;}
if ((!ver55) && (!ver6) && win && ie){oldIE = 1;} else {oldIE = 0;}
if ((ver6) && (!ie)) {net6 = 1;} else {net6 = 0;}
if (l || macIE || oldIE || net6){menuShow = 0;} else {menuShow = 1;}
if(win){yAdj = yAdj - pcYAdj;}	

function gE(e,f){if(l){f=(f)?f:self;var V=f.document.layers;if(V[e])return V[e];for(var W=0;W<V.length;)t=gE(e,V[W++]);return t;}if(d.all)return d.all[e];return d.getElementById(e);}
function sE(e){e.style.visibility='visible';}
function hE(e){e.style.visibility='hidden';}
function sX(e,x){op?e.style.pixelLeft=x:e.style.left=x;}
function sY(e,y){op?e.style.pixelTop=y:e.style.top=y;}
function gX(e) {if (!e) return 0; return e.offsetLeft + gIX(e.offsetParent);}
function gY(e) {if (!e) return 0; return e.offsetTop + gIY(e.offsetParent);}
function gIX(e) {if (!e) return 0; return gX(e);}
function gIY(e) {if (!e) return 0; return gY(e);}

function hideMenu (menuID) {
	timerID = setTimeout("realHideMenu(\""+menuID+"\")",500);
}

function realHideMenu (menuID) {
	var menuRef = gE(menuID);
	hE(menuRef);
}

function hideAll (menuID) {
	allMenus = ["about","news","crp","train","con","sup","hyper","cont"];
	for (i = 0; i < allMenus.length; i++){
		if(allMenus[i] != menuID) {
			realHideMenu(allMenus[i]);
		}
	}
}

function showMenu (menuID) {
	if(menuShow){
		if(timerID) clearTimeout(timerID);
		var xyID = menuID+"link";
		var xyPosRef = gE(xyID);
		var newX = gX(xyPosRef);
		var newY = gY(xyPosRef);
		var menuRef = gE(menuID);
		sX(menuRef, newX-xAdj);
		sY(menuRef, newY-yAdj);
		sE(menuRef);
		hideAll(menuID);
	}
}

dropDownmHead = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"200\"><tr><td class=\"white\" colspan=\"4\"></td></tr>";
dropDownspace = "<tr><td class=\"white\" width=\"1\"></td><td class=\"dmenu\" width=\"12\"></td><td class=\"dmenu\"></td><td class=\"white\" width=\"1\"></td></tr>";
dropDowntStart = "<tr><td class=\"white\" width=\"1\"></td><td class=\"dmenu\" width=\"12\"></td><td class=\"dmenu\"><table cellpadding=\"2\" cellspacing=\"0\" border=\"0\"><tr>";
dropDowntEnd = "</tr></table></td><td class=\"white\" width=\"1\"></td></tr>";
dropDownlStart = "<tr><td class=\"white\" width=\"1\"></td><td class=\"dmenu\" width=\"12\"></td><td class=\"dmenu\"><table cellpadding=\"2\" cellspacing=\"0\" border=\"0\"><tr><td class=\"dmenu\"><a href=\"";
dropDownlMid = "\" class=\"dmenuLink\">";
dropDownlEnd = "</a></td></tr></table></td><td class=\"white\" width=\"1\"></td></tr>";
dropDownsep = "<tr><td class=\"white\" width=\"1\"></td><td class=\"dmenu\" width=\"12\"></td><td class=\"dmenu\"></td><td class=\"white\" width=\"1\"></td></tr>";
dropDownmFoot = "<tr><td colspan=\"4\"></td></tr></table></div>";
dropDownmNoFoot	= "</table></div>";

//About iCRM					
aboutmDiv = "<div id=\"about\" class=\"hiddenMenu\" onMouseOver=\"showMenu('about');\" onMouseOut=\"hideMenu('about');\">";
aboutmMainLink = "<a href=\"../Main.htm\" class=\"dmenuTitleLink\">About iCRM</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
aboutdropDowntitleName = new Array ("<td class=\"dmenuTitle\">About iCRM</td>");
aboutMenuItems =  [["title","title"],
		   ["Chairman's Word","../AboutiCRM/Chairman's_Words.htm"],
		   ["The Council - Honourable Council Member","../AboutiCRM/Administration_Office.htm"],
		   ["Introduction","../AboutiCRM/Introduction.htm"],
		   ["Our Vision","../AboutiCRM/Vision.htm"],
		   ["Our mission","../AboutiCRM/Mission.htm"],
		   ["Objectives","../AboutiCRM/Objectives.htm"],
		   ["Major Benefits of Joining iCRM - CRP","../AboutiCRM/Major_Benefits.htm"],
		   ["Code of Conduct and Ethics","../AboutiCRM/Code_of_C&E.htm"]];
							
//News				
newsmDiv = "<div id=\"news\" class=\"hiddenMenu\" onMouseOver=\"showMenu('news');\" onMouseOut=\"hideMenu('news');\">";
newsmMainLink = "<a href=\"../Main.htm\" class=\"dmenuTitleLink\">News</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
newsdropDowntitleName = new Array ("<td class=\"dmenuTitle\">Latest Events</td>","<td class=\"dmenuTitle\">Internal Communications</td>","<td class=\"dmenuTitle\">Professional Awards</td>");
newsMenuItems =  [["title","title"],
		  ["Latest Events","../News/Latest_Events.htm"],
		  ["title","title"],
		  ["CRP Innovation Center","../News/CRP_Innovation_Centre.htm"],
		  ["Resources & Experience Sharing","../News/Resources_Experience_Sharing.htm"],
		  ["Speaking Opportunity","../News/Speaking_Opportunity.htm"],
		  ["E-Newsletter","../News/E-Newsletter.htm"],
		  ["title","title"],
		  ["Nomination","../News/Nomination.htm"]];


//CRP
crpmDiv = "<div id=\"crp\" class=\"hiddenMenu\" onMouseOver=\"showMenu('crp');\" onMouseOut=\"hideMenu('crp');\">";
crpmMainLink = "<a href=\"../Main.htm\" class=\"dmenuTitleLink\">CRP</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
crpdropDowntitleName = new Array ("<td class=\"dmenuTitle\">CRP (Certified Risk Planner)</td>","<td class=\"dmenuTitle\">International Recognition</td>","<td class=\"dmenuTitle\">CRT (Certified Risk Trainer)</td>","<td class=\"dmenuTitle\">CCC (Certified Crisis Consultant)</td>","<td class=\"dmenuTitle\">CPD (Continuing Professional Development)</td>");
crpMenuItems = [["title","title"],
		["CRP Introduction","../CRP/CRP_Introduction.htm"],
		["CRP Program","../CRP/CRP_Programs.htm"],
		["CRP Brochure","../CRP/CRP_Brochure.htm"],
		["CRP Enrolment Form","../CRP/CRP_Enrolment_Form.htm"],
		["CRP Assessment","../CRP/Requirements_of_CRP_Assessment_Examination.htm"],
		["Membership Category","../CRP/Membership_Category.htm"],
		["Application for Membership","../CRP/Application_for_Membership.htm"],
		["CRP Members Profiles","../CRP/CRP_Members_Profiles.htm"],
		["CRP Certificate Sample","../CRP/Certified_Risk_Planner_Certificate_Sample.htm"],
		["FAQ","../CRP/FAQ.htm"],
		["title","title"],
		["Professional Recognition","../CRP/Prof_Recognition.htm"],
		["Academic Recognition","../CRP/Academic_Recognition.htm"],
		["title","title"],		
		["CRT Program","../CRP/CRT_Program.htm"],
		["CRT Name List","../CRP/Certified_Risk_Trainer_List.htm"],
		["title","title"],		
		["CCC Program","../CRP/CCC_Program.htm"],
		["title","title"],
		["CPD Policy","../Training/CPD_Policy.htm"],
		["CPD Form","../Pix&Files/Training/CPD_Form.pdf"]];
					
//Training
trainmDiv = "<div id=\"train\" class=\"hiddenMenu\" onMouseOver=\"showMenu('train');\" onMouseOut=\"hideMenu('train');\">";
trainmMainLink = "<a href=\"../Main.htm\" class=\"dmenuTitleLink\">Programmes</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
traindropDowntitleName = new Array ("<td class=\"dmenuTitle\">Coming&nbsp;Programmes</td>");
trainMenuItems = [["title","title"],
		  ["CEF Program","../Training/Coming_Programs.htm"],
		  ["CCP Program","../Training/CCP_Programs.htm"],
		  ["CPM Program","../Training/CPM_Programs.htm"]];


//Consultant Services
conmDiv = "<div id=\"con\" class=\"hiddenMenu\" onMouseOver=\"showMenu('con');\" onMouseOut=\"hideMenu('con');\">";
conmMainLink = "<a href=\"../Main.htm\" class=\"dmenuTitleLink\">Consultant Services</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
condropDowntitleName = new Array ("<td class=\"dmenuTitle\">Consulting&nbsp;Services</td>");
conMenuItems = [["title","title"],
		["Scope of Services","../Consulting_Services/Scope_of_Services.htm"],
		["Management Training","../Consulting_Services/Management_Training.htm"],
		["Our Clients","../Consulting_Services/Our_Clients.htm"],
		["Job Opportunities","../Consulting_Services/Job_Opportunities.htm"]];

//Supporting Partners
supmDiv = "<div id=\"sup\" class=\"hiddenMenu\" onMouseOver=\"showMenu('sup');\" onMouseOut=\"hideMenu('sup');\">";
supmMainLink = "<a href=\"../Supporting_Partners/Our_Partners.htm\" class=\"dmenuTitleLink\">Supporting&nbsp;Partners</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
supdropDowntitleName = new Array ("<td class=\"dmenuTitle\">Supporting&nbsp;Partners</td>");
supMenuItems = [["title","title"],
		["Pty Ltd (Australia)","http://www.sabenet.com"],
		["Hong Kong Society for Quality","http://www.hksq.org"],
		["Security Consultants International","http://www.securityinternational.com.au/worldwidepartners.htm"],
		["Security Consulting","http://www.security-consults.com/aboutus.html"],
		["SIMGSoft, Computer Monitoring","http://www.simgsoft.com"],
		["Environmental Technology and quality management","http://gadome.no-ip.com/etqm"],
		["Professional Informantion Security Association","http://www.pisa.org.hk"],
		["Dynamic Dragon International Consultancy Limited","http://www.ddragon.com.hk"]];

//Hyper Link / Forum
hypermDiv = "<div id=\"hyper\" class=\"hiddenMenu\" onMouseOver=\"showMenu('hyper');\" onMouseOut=\"hideMenu('hyper');\">";
hypermMainLink = "<a href=\"../Hyper_Link&Forum/Useful_Links.html\" class=\"dmenuTitleLink\">MEMBERS</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
hyperdropDowntitleName = new Array ("<td class=\"dmenuTitle\">Hyper&nbsp;Link</td>");
hyperMenuItems = [["title","title"],
		  ["The University of Hong Kong","http://www.hku.hk"],
		  ["Po Kam Kai Institute of Management","http://www.pkki.business.hku.hk"],
		  ["Hon Kong University of Science & Technology (HKUST)","http://www.hkust.hk/en/aa/index.html"],
		  ["City University of Hong Kong","http://www.cityu.edu,hk"],
		  ["The Chinese Univerity of Hong Kong","http://www.cuhk.edu.hk/en"],
		  ["Hong Kong Polytechnic University","http://www.polyu.edu.hk"],
		  ["Open Learning University of Hong Kong","http://www.ouhk.edu.hk"],
		  ["Lingnan University","http://www.ln.edu.hk"],
		  ["Hong Kong Education Web","http://www.education.com.hk/hkindex.asp"],
		  ["Labour Department","http://www.labour.gov.hk/eng/news/content.htm"]];


//Contact us
contmDiv = "<div id=\"cont\" class=\"hiddenMenu\" onMouseOver=\"showMenu('cont');\" onMouseOut=\"hideMenu('cont');\">";
contmMainLink = "<a href=\"../Contact_Us/Index.htm\" class=\"dmenuTitleLink\">MEMBERS</a></td><td class=\"white\" width=\"1\" valign=\"top\" height=\"18\"></td></tr>";
contdropDowntitleName = new Array ("<td class=\"dmenuTitle\">Contact us</td>");
contMenuItems = [["title","title"],
		 ["Tel. no. 21003239","info@icrmasia.com"],
		 ["Email","info@icrmasia.com"]];

function buildMenu(menuName,menuType,noFoot) {
	var titleNum = 0; 
	var titleStart = eval(menuType+"tStart");
	var titleEnd = eval(menuType+"tEnd");
	var lineStart = eval(menuType+"lStart");
	var lineMid = eval(menuType+"lMid");
	var lineEnd = eval(menuType+"lEnd");
	var menuDiv = eval(menuName+"mDiv");
	var menuHead = eval(menuType+"mHead");
	var menuFoot = eval(menuType+"mFoot");
	var menuNoFoot = eval(menuType+"mNoFoot");
	var menuMainLink = eval(menuName+"mMainLink");
	var seperator = eval(menuType+"sep");
	var spacer = eval(menuType+"space");
	var menuItemArray = eval(menuName+"MenuItems");
	var menuTitlesArray = eval(menuName+menuType+"titleName");
	var arrayLength = menuItemArray.length;
	
	if(menuType == "dropDown"){
		document.write(menuDiv+menuHead+"\n"); //+menuMainLink+
	} else {
		document.write(menuHead+"\n");
	}
	
	for(i=0; i < arrayLength; i++) {
    	var name = menuItemArray[i][0];
    	var currentURL = menuItemArray[i][1];
	
		if(name == "sep") {
			document.write(seperator);
		} else if (name == "space") {
			document.write(spacer);
		} else {
			if(name == "title"){
				var title = menuTitlesArray[titleNum];
				document.write(titleStart+title+titleEnd);
				titleNum = titleNum + 1;
			} else {
				if ((menuType == "leftNav") && (currentName == name)) {
					document.write(lineStart+currentURL+lineMid+"<b>"+name+"</b>"+lineEnd);
				} else {
					document.write(lineStart+currentURL+lineMid+name+lineEnd);
				}
			}
		}
	}
	if (noFoot) {
	    document.write(menuNoFoot);
	} else {
	    document.write(menuFoot);
        }
}