// JavaScript Document
//
// default size of popup window for associates
// (not implemented yet)
//
//
// This is the menu system for Future Climate. It's pretty simple.
//
// menuItems is the names that appear to the user.
// htmlItems are the links for those names. For no link, use "".
//
// Each time you want a new menu section, just push in a new Array.
//
//
menuItems = new Array();
htmlItems = new Array();
// HOME
menuItems.push(new Array("Home"));
htmlItems.push(new Array("index"));
//NEWS
//menuItems.push(new Array("Latest news", "In the media", "In the media archive"));
//htmlItems.push(new Array("news", "news_media", "news_media_archive"));
// ABOUT
menuItems.push(new Array("About Future Climate"));
htmlItems.push(new Array("about"));
// INDIVID
menuItems.push(new Array("For Individuals", "Greenhouse tips"));
htmlItems.push(new Array("individuals", "individuals", "ind_comment"));
// ORGS
menuItems.push(new Array("For Organisations", "Develop a strategy", "Events & workshops"));
htmlItems.push(new Array("organisations", "associates_dev", "events"));
// ASSOCIATES
menuItems.push(new Array("Future Climate Associates"));
htmlItems.push(new Array("associates"));
// TREE PLANTING
//menuItems.push(new Array("Tree planting"));
//htmlItems.push(new Array("tree_planting"));
// SUSTAINABLE MOBILITY
menuItems.push(new Array("Sustainable mobility"));
htmlItems.push(new Array("sustainable_mobility"));
// CONTACT
menuItems.push(new Array("Contact us"));
htmlItems.push(new Array("contact"));
//
// SPAM EMAIL PREVENTION
noSpamLink= function (e){
	// build the addresses based on a single char passed.
	if(e=="h" || e=="H"){
		e="hen"+"ry"
	}else if(e=="r" || e=="R"){
		e="r"+"eg"
	}else if(e=="c" || e=="C"){
		e="cat"+"hie"
	}else{
		// default to this
		e="in"+"fo"
	}
	e+="@futur"
	e+="eclima"
	e+="te.com.au"
	e="mai" + "lto:" +e+ "?subjec" + "t=Future%20Climate%20enquiry"
	//alert(e)
	location.href =e
}
	
//
// function called by each html page that needs the menu written
//
//alert("hi minty");
writeMenu = function () {
	//alert("WRITING");
	// sort out where we are now
	var loc = document.location;
	loc=loc.toString();
	//alert('loc:'+loc);
	// split to array based on slashes
	var loc = loc.split("/");
	// and grab the last item
	var loc = loc[loc.length-1];
	//alert('loc:'+loc);
	var dot = loc.lastIndexOf(".");
	loc = loc.substr(0, dot);
	loc=loc.toString();
	// all mailing list pages only have one location
	if(loc.substr(0, 7)=="mailing"){
		loc="mailing"
	}
	//alert('loc:'+loc);
	var t = "";
	var menuItemsNum = menuItems.length;
	//alert('menuItemsNum'+menuItemsNum);
	for (var i = 0; i<menuItemsNum; i++) {
		var m = menuItems[i];
		var h = htmlItems[i];
		var mNum = m.length;
		
		t += "<UL>";
		for (var j = 0; j<mNum; j++) {
			
			var m1 = m[j];
			var h1 = h[j];
			//alert('m1'+m1);
			if (j == 1) {
				t += "<UL>";
			}
			//alert(h1+" : "+loc);
			// the second test is for all the mailing list pages (success/remove etc)
			//if (h1==loc || h1.substr(0, 7)==loc) {
			if (h1==loc || h1.substr(0, 99)==loc) {
				//alert("match:"+h1);
				t += '<li class="youarehere">';
				h1="";
			} else {
				t += "<li>";
			}
			if (h1 != "") {
				t += '<a href="'+h1+'.html">'+m1+"</a>";
			} else {
				t += m1;
			}
			t += "</li>";
		}
		if (j>1) {
			t += "</UL>";
		}
		t += "</UL>";
	}
	document.write(t);
};

writeBottomMenu = function (isIndexPage) {
	//alert('writeBottomMenu');
	var loc="not worry about it yet";
	var t = "";
	var theSep=" ~ "
	var menuItemsNum = menuItems.length;
	//alert('menuItemsNum'+menuItemsNum);
	for (var i = 0; i<menuItemsNum; i++) {
		if(isIndexPage==true){
			// skip the stuff in big buttons on the index page!
			if(i==0)i=5; 
		}
		var m = menuItems[i];
		var h = htmlItems[i];
		var mNum = m.length;
		// for now (with restricted space), let's only use the first item!!
		var mNum =1;
		
		for (var j = 0; j<mNum; j++) {
			//alert('result:'+j);
			var m1 = m[j];
			var h1 = h[j];

			if (h1==loc || h1.substr(0, 7)==loc) {
				// this is the current page!
			} else {
				// not the current page
				//t += "<li>";
			}
			if (h1 != "") {
				// we've got a valid link, so stick it in
				t += '<a href="'+h1+'.html">'+m1+"</a>";
				t += theSep;
			} else {
				// no link, don't add anything!
				//t += m1;
			}
			
		}
		//alert('thats it for i:'+i);
		
	}
	t += '<a href="#top">Top of page</a>';
	//alert('result:'+t);
	document.write(t);
};

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}