/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
	This script contains the code to generate the menu.
	Modify the menuArray array below to make changes to the menu.
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
						 		TITLE					URL						IS SUBMENU	(true/false)
*/
	var menuArray = new Array(
							  	"MAIN",						"main-overview.html",			false,		// 00
							  	"INTRODUCTION",				"main-overview.html",			true,		// 01
							  	"MAIN ANIMATION",			"index.html",					true,		// 02

								'ABOUT US',					'about_us-who_we_are.html',		false,		// 03
								'WHO WE ARE',				'about_us-who_we_are.html',		true,		// 04
								'OUR MISSION', 				'about_us-our_mission.html',	true,		// 05
								'OUR PEOPLE',				'about_us-our_people.html',		true,		// 06
								'OUR HISTORY',				'about_us-our_history.html', 	true,		// 07
								'OUR ACTIVITIES',			'about_us-our_activities.html',	true,		// 08
								'ANNUAL REPORTS',			'about_us-annual_reports.html',	true,		// 09
								
								'SPECIALISED SERVICES',		'services-medical.html',		false,		// 10
								'MEDICAL SERVICES',			'services-medical.html',		true,		// 11
								'» Services Offered',		'services-medical-services.html',					true,		// 12
								'» General Clinics',		'services-medical-generalclinics.html',				true,		// 13
								'» MOHS Surgery',			'services-medical-mohs.html',						true,		// 14
								'» Training for MOHS',		'services-medical-mohstraining.html',				true,		// 15
								'» Phototherapy',			'services-medical-phototherapy.html',				true,		// 16
								'» Laser Therapy',			'services-medical-lasertherapy.html',				true,		// 17
								'» Contact & Occupational __________Dermatitis Clinic',	'services-medical-dermclinic.html',				true,		// 18
								'» General Anaesthetic',	'services-medical-generalanaesthetic.html',			true,		// 19
								'» Microtattooing Clinic',	'services-medical-microclinic.html',				true,		// 21
								'» Photodynamic Therapy',	'services-medical-photodytherapy.html',				true,		// 22
								'» Vitiligo Clinic',		'services-medical-vitiligoclinic.html',				true,		// 23
								'» Oral Medicine',			'services-medical-oralmedicine.html',				true,		// 24
								'» Psychodermatology',		'services-medical-psychodermatology.html',			true,		// 25
								'» Clinical Photography',	'services-medical-clinicalphotography.html',		true,		// 26
								
								'PATHOLOGY SERVICES',		'services-pathology.html',					false,		// 27
								'PATHOLOGY SERVICES',		'services-pathology.html',					true,		// 28
								'» Our Team',				'services-pathology-ourteam.html',			true,		// 29
								'» What We Do',				'services-pathology-whatwedo.html',			true,		// 30
								'» Our Service',			'services-pathology-ourservice.html',		true,		// 31
								'» Our Laboratory',			'services-pathology-ourlab.html',			true,		// 32
								'» Other Areas of Expertise',	'services-pathology-otherareas.html',	true,		// 33
								'» Our Commitment',			'services-pathology-ourcommitment.html',	true,		// 34

								'RESEARCH & PROJECTS',		'research_projects.html',					false,		// 35
								'OVERVIEW',					'research_projects.html',					true,		// 36
								'» Scabies Eradication',	'research_projects-scabieserad.html',		true,		// 37
								'» Clinical Trials',		'research_projects-clinicaltrials.html',	true,		// 38
								'» Dermatological Unit',	'research_projects-dermunit.html',			true,		// 39
								'» Dermapathology Unit',	'research_projects-pathunit.html',			true,		// 40
								'» HIV Clinic',				'research_projects-hivunit.html',			true,		// 41
								'» Phototherapy Unit',		'research_projects-photounit.html',			true,		// 42
								'» Millennium Institute',	'research_projects-millinst.html',			true,		// 43
								
								'TRAINING & TEACHING',		'training.html', 				false,		// 44
								'OVERVIEW',					'training.html', 				true,		// 45
								
								'PRODUCT ENDORSEMENT',		'prodtest-endorsements.html',	false,		// 46
								'PRODUCT ENDORSEMENT',		'prodtest-endorsements.html',	true, 		// 47

								'PATIENT INFORMATION',		'patient-westmead.html',		false,		// 48
								'WESTMEAD DAY SURGERY',		'patient-westmead.html',		true,		// 49
								'PATIENT RIGHTS',			'patient-rights.html',			true,		// 50
								'FEE AND BILLING POLICY',	'patient-billing.html',			true,		// 51

								'LINKS',					'links.html',					false,		// 52
								'LINKS',					'links.html',					true,		// 53

								'JOBS @ SCFA',				'jobs.html', 					false,		// 54
								'JOBS @ SCFA',				'jobs.html', 					true,		// 55
								
								'DONATIONS',				'donations.html', 				false,		// 56
								'DONATIONS',				'donations.html', 				true,		// 57
								
								'CONTACT US',				'contact.html', 				false,		// 58
								'DETAILS',					'contact.html',					true,		// 59
								'» Darlinghurst',			'contact-darlinghurst.html',	true,		// 60
								'» Westmead',				'contact-westmead.html',		true		// 61
				);

	function writeMenuItem(text, url, isopen, isselected, isfirst) {
		var menu	= document.getElementById("menu");
		var newtr	= document.createElement("tr");
		var newtd	= document.createElement("td");
		var newa 	= document.createElement("a");
		
		var bgimg;
		var ovimg;
		
		if (isopen) {
			if (isfirst) {
				bgimg = "images/main/menu_back-open-first.png";
				ovimg = "images/main/menu_back-open-over-first.png";
			} else {
				bgimg = "images/main/menu_back-open-first.png";
				ovimg = "images/main/menu_back-open-over-first.png";
			}
		} else {
			if (isfirst) {
				bgimg = "images/main/menu_back-first.png";
				ovimg = "images/main/menu_back-over-first.png";
			} else {
				bgimg = "images/main/menu_back-first.png";
				ovimg = "images/main/menu_back-over-first.png";
			}
		}
		
		newtd.setAttribute("background", bgimg);

		newtd.setAttribute("width", "208");
		newtd.setAttribute("height", "29");
		newtd.onclick = function () { window.location = url; }
		newtd.onmouseover = function () { this.setAttribute("background", ovimg); };
		newtd.onmouseout = function () { this.setAttribute("background", bgimg); };
		
		newa.setAttribute("href", url);
		newa.appendChild(document.createTextNode(text));
		if (isselected) newa.className = "selected";
		
		newtd.appendChild(newa);
		newtr.appendChild(newtd);
		menu.appendChild(newtr);
		
		return;
	}

	function writeSubMenuItem(text, url, isselected, islast) {
		var menu	= document.getElementById("menu");
		var newtr	= document.createElement("tr");
		var newtd	= document.createElement("td");
		var newa 	= document.createElement("a");
		
		var bgimg;
		var ovimg;
		
		if (islast==true) {
			bgimg = "images/main/submenu_back-last.png";
			ovimg = "images/main/submenu_back-over-last.png";
		} else {
			bgimg = "images/main/submenu_back.png";
			ovimg = "images/main/submenu_back-over.png";
		}
		
		newtd.setAttribute("background", bgimg);

		newtd.setAttribute("width", "208");
		newtd.setAttribute("height", "25");
		newtd.onclick = function () { window.location = url; }
		newtd.onmouseover = function () { this.setAttribute("background", ovimg); };
		newtd.onmouseout = function () { this.setAttribute("background", bgimg); };
		
		newa.setAttribute("href", url);
		newa.appendChild(document.createTextNode(text));
		if (isselected) newa.className = "submenu-s";
		else newa.className = "submenu";

		
		newtd.appendChild(newa);
		newtr.appendChild(newtd);
		menu.appendChild(newtr);
		
		var temp = "";
		for(i=0;i<newa.innerHTML.length;i++){
			if(newa.innerHTML.charAt(i) == "_") {
				temp = temp + "&nbsp;";
			} else {
				temp = temp + newa.innerHTML.charAt(i);	
			}
		}
		newa.innerHTML = temp;
		
		return;
	}

	function loadMenu(index) {
		var i = 0;
		var miTitle, miURL, miSubMenu;
		var parentIndex;
		var lastParent;
		MM_preloadImages(
			'../images/main/menu_back-first.png',
			'../images/main/menu_back-open-first.png',
			'../images/main/menu_back-open-over-first.png',
			'../images/main/menu_back-open-over.png',
			'../images/main/menu_back-open.png',
			'../images/main/menu_back-over-first.png',
			'../images/main/menu_back-over.png',
			'../images/main/menu_back.png',
			'../images/main/menu_btm.png',
			'../images/main/menu_top.png'
		);

		// if no index has been returned then index is -1 (none selected and no submenus shown);
		if (index == null) var index = -1;
		
 		// if index item is a submenu, find its parent
 		if(menuArray[(index*3+2)] == true) {
			i=index;
			while(menuArray[(i*3+2)] == true) {
				i--;
			}
			parentIndex = i;
		}
		i=0;
		while (i<menuArray.length) {
			
			miTitle 	= menuArray[i];
			miURL		= menuArray[i+1];
			miSubMenu	= menuArray[i+2];
			// TEMP: REMOVE PRODUCT TESTING!!
			//if (miTitle != 'PRODUCT TESTING' && miTitle != 'ENDORSEMENTS & TESTING')
			// END TEMP
			if (!miSubMenu) {
				writeMenuItem(miTitle, miURL, ((i/3).valueOf() == parentIndex), (index.valueOf() == (i/3).valueOf()), (index==0));
				lastParent = i/3;
			} else {
				//if  alert('');
				if (lastParent==parentIndex) writeSubMenuItem(miTitle, miURL, (index.valueOf() == (i/3).valueOf()),(i == menuArray.length -3));
			}

			i += 3;
		}
	}

	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}