var menuSet = new Array(0, false, false);			// if a submenu is open
var menuSetLink = new Array(0, false, false, false);		// if a submenu link is selected
var subMenu = false;
var subMenuDiv = false;

var backContent = false;
var newsMenu = "latestnews";

var currentMenuItem = false;						// which main pathway is active - why? when?...
var currentMain = new Array(0, false, false, false); // which contentdiv is active

var shifted = false;								// to mark before and after first-click
var baractive = false;
var current_illust = false;
var timed_illust, shifting, movingmain;


function do_back() {
	putThirdDiv(backContent);
}
//  FUNCTIONS USED ON PAGE STARTUP
//  time out for menuItems fading in and settings rollovers 
function init() {
	setupSearch('searchinput');
	
	setupFadein('whodiv', 250, 1);
	setupFadein('whatdiv', 1250, 2);
	setupFadein('wherediv', 750, 3);
	setupFadein('whydiv', 1750, 4);
	setupFadein('contactnumbersdiv', 2500, 5);
	setupFadeinIllust('home', 3000, 9);
	setTimeout("firstSetup()", 750);
	setTimeout("hideNavContainer('MainNavContainer')",2590);
}

function hideNavContainer(ctrl){
	document.getElementById(ctrl).style.display = 'none'
}


//  moves and fades in menuItems
function setupFadein(divId, time, idNum) {	
	document.getElementById(divId).style.display = 'block';
	// 300108 changeOpac(0, divId);
	setTimeout("opacity('" +divId+ "', 0, 100, 1000)",time);
	setTimeout("moveContent('" +divId+ "', " +idNum+ ")",time);
}
function setupFadeDivin(divId, time, idNum) {		
	document.getElementById(divId).style.display = 'block';
	// 300108 changeOpac(0, divId);
	setTimeout("opacity('" +divId+ "', 0, 100, 1000)",time);
	setTimeout("moveDivContent('" +divId+ "', " +idNum+ ")",time);
}
function setupFadeinIllust(divId, time, idNum) {
	//width = 185; height = 200;
	width = 325; height = 350;
//	if(divId == 'where') {

//	}
	document.getElementById('illust_holder').innerHTML = 

	"<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=" + width + " height=" + height + " id=\"where\" align=\"middle\">"+
	"<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+

	"<param name=\"allowFullScreen\" value=\"false\" />"+
	"<param name=\"movie\" value=\"images/" + divId + ".swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#ffffff\" />	<embed src=\"images/" + divId + ".swf\" quality=\"high\" bgcolor=\"#ffffff\" width=" + width + " height=" + height + " name=\"where\" align=\"middle\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />"+
	"</object>";



//	"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" width=" + width + " height=" + height + " title=\"Illust\">" +
//    "<param name=\"movie\" value=\"images/" + divId + ".swf\" />" +
//    "<param name=\"quality\" value=\"high\" />" +
//    "<param name=\"wmode\" value=\"transparent\">" +
//    "<embed src=\"images/" + divId + ".swf\" quality=\"high\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=" + width + " height=" + height + " wmode=\"transparent\"></embed>" +
//  	"</object>";

	document.getElementById('illust_holder').style.display = 'block';
	// 300108 changeOpac(0, 'illust_holder');
	current_illust = 'illust_holder';
	timed_illust = setTimeout("opacity('" +'illust_holder'+ "', 0, 100, 1000)",time);
}
//  sets rollovers
function firstSetup() {
	baractive = true;
	setupRollover('who');
	setupRollover('what');
	setupRollover('where');
	setupRollover('why');
	setupRolloverContact('contactnumbers');
}
//  rollover function declarations for main menuItems
function setupRollover(imageId) {
	thisImage = document.images[imageId];
	thisImage.overImage = new Image();
	thisImage.overOnImage = new Image();
	thisImage.outImage = new Image();
	thisImage.overImage.src = "images/" + imageId + "_on.gif";
	thisImage.overOnImage.src = "images/" + imageId + "_over_on.gif";
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseover = rollOver;
	thisImage.onmouseout = rollOut;
	thisImage.onclick = onClick;
}
//  END OF STARTUP FUNCTIONS


function hideIllust() {
	if(current_illust) {
		clearTimeout(timed_illust);
		document.getElementById(current_illust).style.display = 'none';
	}
	current_illust = false;
}
// MAKES H1 PUT GREEN IMAGE
function colourTitle(id) {
	himage = id + '_h1';
	if(document.getElementById(himage)) {
		offimg = document.getElementById(himage).src;
		offimgroot = offimg.split(".gif");
		offimgroot = offimgroot[0].split("-on");
		document.getElementById(himage).src = offimgroot[0] + '-on.gif';	
	}
}
// MAKES H1 PUT GREY IMAGE
function greyTitle(id) {
	himage = id + '_h1';
	if(document.getElementById(himage)) {
		offimg = document.getElementById(himage).src;
		offimgroot = offimg.split(".gif");	
		offimgroot = offimgroot[0].split("-on");
		document.getElementById(himage).src = offimgroot[0] + '.gif';
	}
}
// USED TO INITIALISE THE ITEMS IN THE NAVBAR
function setupSearch(sinput) {
	thisSearch = document.getElementById(sinput);
	thisSearch.onfocus = highlightSearch;
	thisSearch.onblur = lowlightSearch;
	
	thisSearchButton = document.getElementById(sinput + 'button');
	thisSearchButton.overImage = new Image();
	thisSearchButton.outImage = new Image();
	thisSearchButton.overImage.src = "images/go_over.gif";
	thisSearchButton.outImage.src = thisSearchButton.src;
	thisSearchButton.onmouseover = buttonOver;
	thisSearchButton.onmouseout = buttonOut;
}

function highlightSearch() {
	this.style.background = '#fff';
	this.value = '';
}
function lowlightSearch() {
	this.style.background = '#9eb7bb';
	if(this.value == '')
		this.value = 'Search';
}
function buttonOver() { this.src = this.overImage.src; }
function buttonOut() { this.src = this.outImage.src; }
function mOver(thislink) { document.getElementById(thislink.id).className = 'selectedLink'; }
function mOut(thislink) { if((thislink.id != menuSetLink[1])&&(thislink.id != menuSetLink[2])&&(thislink.id != menuSetLink[3])) document.getElementById(thislink.id).className = ''; }
function mOverSub(thislink) { document.getElementById(thislink.id).className = 'submenulinkSelected'; }
function mOutSub(thislink) { if(thislink.id != subMenu) document.getElementById(thislink.id).className = 'submenulink'; }