// menus.js - Created by Bradley J. Gibby q:)
// Version 1.0 - 20030728

var urlPrefix = "http://www.flexiblelearning.net.au/knowledgetree/edition03/";
//var urlPrefix = "http://dv01.elearn.internal/KT/";

var menuState = 0;
var menus = [
	"pra", 
	"cri", 
	"pol", 
	"int", 
	"pro"
];

var pras = [];
var cris = [];
var pols = [];
var ints = [];
var pros = [];

function item(title, link) {
	this.title = title;
	this.link = link;
}

function praMenu() {
	for (var i = 0; i < pras.length; i++) {
		document.write(getMenuItem(pras[i].title, pras[i].link));
	}
}

function criMenu() {
	for (var i = 0; i < cris.length; i++) {
		document.write(getMenuItem(cris[i].title, cris[i].link));
	}
}

function polMenu() {
	for (var i = 0; i < pols.length; i++) {
		document.write(getMenuItem(pols[i].title, pols[i].link));
	}
}

function intMenu() {
	for (var i = 0; i < ints.length; i++) {
		document.write(getMenuItem(ints[i].title, ints[i].link));
	}
}

function proMenu() {
	for (var i = 0; i < pros.length; i++) {
		document.write(getMenuItem(pros[i].title, pros[i].link));
	}
}

function getMenuItem(title, link) {
	return "<tr><td class=\"menuItem_up\" onMouseOver=\"this.className='menuItem_over';\" onMouseOut=\"this.className='menuItem_up';\"><span class=\"menuSpacer\"></span><a href=\"" + link + "\" class=\"flyOutLink\">" + title + "</a></td></tr>";
}

// Pra Menu
pras.push(new item("Submit an Article", urlPrefix + "html/submit.html"));
pras.push(new item("Jo Balatti and Martha Goldman", urlPrefix + "html/pra_balatti-goldman.html"));
pras.push(new item("Margaret Barron", urlPrefix + "html/pra_barron.html"));
pras.push(new item("Karen Ho", urlPrefix + "html/pra_ho.html"));
pras.push(new item("Chris Horton and Katie Scholten", urlPrefix + "html/pra_horton-scholten.html"));
pras.push(new item("Jo Murray", urlPrefix + "html/pra_murray.html"));
pras.push(new item("Ian Robertson", urlPrefix + "html/pra_robertson.html"));
pras.push(new item("Julie Woodlock", urlPrefix + "html/pra_woodlock.html"));

// Cri Menu
cris.push(new item("2002 RTO Case Studies", urlPrefix + "html/cri_rto.html"));
cris.push(new item("Learning Object Hotspot", urlPrefix + "html/cri_savoie.html"));

// Pol Menu
pols.push(new item("Frank Bate and Linda Smart", urlPrefix + "html/res_frankBate_lindaSmart.html"));
pols.push(new item("Chris Howell and Sophie Cholewka", urlPrefix + "html/res_chrisHowell.html"));
pols.push(new item("Reece Lamshed", urlPrefix + "html/res_reeceLamshed.html"));
pols.push(new item("Prue Masden", urlPrefix + "html/res_prueMasden.html"));
pols.push(new item("John Mitchell: Innovation", urlPrefix + "html/res_innovation.html"));
pols.push(new item("Ellie Thompson", urlPrefix + "html/res_ellieThompson.html"));

// Bra Menu
//bras.push(new item("Queensland", urlPrefix + "html/bra_qld.html"));
//bras.push(new item("New South Wales", urlPrefix + "html/bra_nsw.html"));
//bras.push(new item("Victoria", urlPrefix + "html/bra_vic.html"));

// Int Menu
ints.push(new item("Vivienne Blanksby and Graeme Brownfield", urlPrefix + "html/int_vivienneBlanksby_graemeBrownfield.html"));
ints.push(new item("Peter Coyne", urlPrefix + "html/int_peterCoyne.html"));
ints.push(new item("Kathi Eland", urlPrefix + "html/int_kathiEland.html"));
ints.push(new item("Barbara McPherson", urlPrefix + "html/int_barbaraMcPherson.html"));
ints.push(new item("Leone Wheeler", urlPrefix + "html/int_leoneWheeler.html"));
ints.push(new item("Martyn Wild", urlPrefix + "html/int_martynWild.html"));

// Con Menu
/*
cons.push(new item("Editorial Team", urlPrefix + "html/contactDetails.html#edTeam"));
cons.push(new item("Editor", urlPrefix + "html/contactDetails.html#editor"));
cons.push(new item("Project Manager", urlPrefix + "html/contactDetails.html#proMan"));
cons.push(new item("Knowledge Tree Support", urlPrefix + "html/contactDetails.html#support"));
*/

// Pros Menu
pros.push(new item("Full Summary of Leaders' Goals", "javascript:showDocument('FLL2003s.pdf');"));
pros.push(new item("Highlights", urlPrefix + "html/lea_featuredLeaders.html"));

function getPageOffsetLeft(el) {
	var x;
	
	// Return the x coordinate of an element relative to the page.
	
	x = el.offsetLeft;
	if (el.offsetParent != null)
	x += getPageOffsetLeft(el.offsetParent);
	
	return x;
}

function getPageOffsetTop(el) {
	var y;
	
	// Return the x coordinate of an element relative to the page.
	
	y = el.offsetTop;
	if (el.offsetParent != null)
	y += getPageOffsetTop(el.offsetParent);
	
	return y;
}

function hideMenus() {
	if (menuState == 0) {
		for (var i = 0; i < menus.length; i++) {
			document.getElementById(menus[i]).style.display = "none";
		}
	}
}

function showMenu(id) {
	menuState = 0;
	hideMenus();
	menuState = 1;

	var y = getPageOffsetTop(document.getElementById(id + "Parent"));
	var x = getPageOffsetLeft(document.getElementById(id + "Parent"));
	
	document.getElementById(id).style.top = y + 30;
	document.getElementById(id).style.left = x;
	document.getElementById(id).style.display = "block";
}

function init() {
	setInterval('hideMenus();', 1250);
	
	document.getElementById("pra").style.width = "200px";
	document.getElementById("cri").style.width = "215px";
	document.getElementById("pol").style.width = "200px";
//	document.getElementById("bra").style.width = "115px";
	document.getElementById("int").style.width = "235px";
//	document.getElementById("con").style.width = "150px";
	document.getElementById("pro").style.width = "185px";
}

function drawNav() {
	document.write("<a href=\"" + urlPrefix + "html/editor.html\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('home','','" + urlPrefix + "images/homeb.gif',1); menuState = 0;\"><img src=\"" + urlPrefix + "images/homea.gif\" name=\"home\" border=\"0\" alt=\"Home\"></a><a href=\"javascript:void(0);\" id=\"praParent\" onMouseOut=\"MM_swapImgRestore(); menuState = 0;\" onMouseOver=\"MM_swapImage('peer','','" + urlPrefix + "images/peerArticlesb.gif',1); showMenu('pra');\"><img src=\"" + urlPrefix + "images/peerArticlesa.gif\" name=\"peer\" border=\"0\" alt=\"Peer Review Articles\"></a><a href=\"javascript:void(0);\" id=\"criParent\" onMouseOut=\"MM_swapImgRestore(); menuState = 0;\" onMouseOver=\"MM_swapImage('critiques','','" + urlPrefix + "images/critiquesb.gif',1); showMenu('cri');\"><img src=\"" + urlPrefix + "images/critiquesa.gif\" name=\"critiques\" border=\"0\" alt=\"Critiques\"></a><a href=\"" + urlPrefix + "html/branches.html\" onMouseOut=\"MM_swapImgRestore();\" onMouseOver=\"MM_swapImage('branches','','" + urlPrefix + "images/theBranchesb.gif',1); menuState = 0;\"><img src=\"" + urlPrefix + "images/theBranchesa.gif\" name=\"branches\" border=\"0\" alt=\"From the Branches\"></a><a href=\"javascript:void(0);\" id=\"intParent\" onMouseOut=\"MM_swapImgRestore(); menuState = 0;\" onMouseOver=\"MM_swapImage('interviews','','" + urlPrefix + "images/interviewsb.gif',1); showMenu('int');\"><img src=\"" + urlPrefix + "images/interviewsa.gif\" name=\"interviews\" border=\"0\" alt=\"Interviews\"></a><a href=\"javascript:void(0);\" id=\"polParent\" onMouseOut=\"MM_swapImgRestore(); menuState = 0;\" onMouseOver=\"MM_swapImage('currentResearch','','" + urlPrefix + "images/currentResearchb.gif',1); showMenu('pol');\"><img src=\"" + urlPrefix + "images/currentResearcha.gif\" name=\"currentResearch\" border=\"0\" alt=\"Current Research\"></a><a href=\"javascript:void(0);\" id=\"proParent\" onMouseOut=\"MM_swapImgRestore(); menuState = 0;\" onMouseOver=\"MM_swapImage('leaders','','" + urlPrefix + "images/leaderProjectsb.gif',1); showMenu('pro');\"><img src=\"" + urlPrefix + "images/leaderProjectsa.gif\" name=\"leaders\" border=\"0\" alt=\"2003 Leaders Projects\"></a><img src=\"" + urlPrefix + "images/contactDetailsa.gif\" name=\"contactDetails\" border=\"0\" alt=\"Spacer\"></a><img src=\"" + urlPrefix + "images/menuEnd.gif\" alt=\"Edition 3, August 2003\">");
}

function drawMenus() {
	for (var i = 0; i < menus.length; i++) {
		document.write("<div id=\"" + menus[i] + "\" class=\"flyOut\" onMouseOver=\"menuState = 1;\" onMouseOut=\"menuState = 0;\"><table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><script language=\"JavaScript\">" + menus[i] + "Menu();</script></table></div>");
	}
}

function showMovie(id) {
	window.open("../video/" + id, "", "width=455,height=400,resizable=no,statusbar=no,toolbars=no,addressbar=no");
}

function showDocument(id) {
	window.open("downloads/" + id + "", "", "width=550,height=400,scrollbars=yes,resizable=yes,toolbars=yes,statusbar=no");
}

function showMP3(id) {
	window.open("../mp3/" + id + "", "", "width=500,height=400,scrollbars=yes,resizable=yes,toolbars=yes,statusbar=no");
}

function search() {
	document.location.href = "http://www.flexiblelearning.net.au/knowledgetree/edition05/perl/search.pl?keywords=" + document.getElementById("textfield").value + "&ed=3";
}


