// initialises the menu location as they are absolute positioned
function set_menu_pos() {
	//get a reference position from the form
	var pos = document.getElementById("login").offsetLeft;
	
	

	//set init positon of menu and set spacer
	var menuXPos = pos - 12;
	var top = 280;
	var adj= "";
	if (navigator.appName == "Microsoft Internet Explorer") {
		//var newpos = document.body.clientWidth;
		var elpos = document.getElementById("wrapper").offsetLeft;
		//menuXPos = newpos * 0.50 + (newpos*0.1);
		menuXPos = menuXPos + 0 + elpos;
		top = top + 5;
		adj = 10;
		
	}
	/**/document.getElementById("menuEnter").style.left = menuXPos+"px";
	document.getElementById("menuEnter").style.top = top + "px";
	document.getElementById("menuMembers").style.left = menuXPos+"px";
	document.getElementById("menuMembers").style.top = top + 12 +"px";
	document.getElementById("menuAbout").style.left = menuXPos+"px";
	document.getElementById("menuAbout").style.top = top + 24 +"px";
	//set the description boxes next to menu and hide them all
	var desLeft = menuXPos + 65;
	document.getElementById("aboutText").style.left = desLeft+"px";
	document.getElementById("membersText").style.left = desLeft+"px";
	document.getElementById("enterText").style.left = desLeft+"px";
	document.getElementById("aboutText").style.top = top +"px";
	document.getElementById("membersText").style.top = top +"px";
	document.getElementById("enterText").style.top = top +"px";
	document.getElementById("aboutText").style.visibility = "hidden";
	document.getElementById("membersText").style.visibility = "hidden";
	document.getElementById("enterText").style.visibility = "hidden";
	//set the element position of the error message
	document.getElementById("errorBox").style.left = menuXPos+63+adj+"px";
	document.getElementById("errorBox").style.top = 184 + "px";
		
}

//glow enter
function EnterBlackCol () {
	document.getElementById('menuEnter').style.color = "#000000";
}
function glow () {
	red = setInterval("turnred()", 12);
	//turnred();
}
way = "up"
function turnred() {
	ebut = document.getElementById('menuEnter');
	var r = ebut.style.color;
	r = r.split("rgb(");
	x = r[1];
	x = x.split(",");
	y = x[0];
	y=parseInt(y);
	if (y <= "255") {
		if (way == "up"){
			y = y+5;
		} 
		if (way == "down") {
			y = y-5;
		}
	}
	if (y >= "255") {
		way = "down";
		y = 255;
	}
	if (y <= 0) {
		way = "up";
		y = 0;
	}
	ebut.style.color = "rgb("+y+",0,0)";
	//alert(y + "   "+ebut.style.color);
}
function gloIII(n) {
	ebut = document.getElementById('menuEnter');
	ebut.style.color = "";
	
}
// 2. series of functions to show the descriptions -------------------
var  autoHideText = "";
function showAbout(){
	window.clearInterval(autoHideText);
	document.getElementById("menuAbout").style.color = "red";
	document.getElementById("menuAbout").style.cursor = "default";
	document.getElementById("aboutText").style.visibility = "visible";
	document.getElementById("aboutText").style.zIndex = 1;
	//set the other menus to invisble
	document.getElementById("membersText").style.visibility = "hidden";
	document.getElementById("enterText").style.visibility = "hidden";
	autoHideText = setTimeout("document.getElementById('aboutText').style.visibility = 'hidden'",10000);
	
}

function showMembers () {
	window.clearInterval(autoHideText);
	document.getElementById("menuMembers").style.color = "red";
	document.getElementById("menuMembers").style.cursor = "default";
	document.getElementById("membersText").style.visibility = "visible";
	document.getElementById("membersText").style.zIndex = 1;
	//set the other menus to invisble
	document.getElementById("aboutText").style.visibility = "hidden";
	document.getElementById("enterText").style.visibility = "hidden";
	autoHideText = setTimeout("document.getElementById('membersText').style.visibility = 'hidden'",10000);
}

function showEnter () {
	window.clearInterval(autoHideText);
	document.getElementById("menuEnter").style.color = "red";
	document.getElementById("menuEnter").style.cursor = "pointer";
	document.getElementById("enterText").style.visibility = "visible";
	document.getElementById("enterText").style.zIndex = 1;
	//set the other menus to invisble
	document.getElementById("membersText").style.visibility = "hidden";
	document.getElementById("aboutText").style.visibility = "hidden";
	autoHideText = setTimeout("document.getElementById('enterText').style.visibility = 'hidden'",10000);
}
//--------------------------------------------------------------------

// 3. reset the colors of the menu bar
function resetColor() {
	document.getElementById("menuAbout").style.color = "black";
	document.getElementById("menuMembers").style.color = "black";
	document.getElementById("menuEnter").style.color = "black";
	
}

// 4. hide all the descriptions
function hideMenuDescriptions() {
	document.getElementById("aboutText").style.visibility = "hidden";
	document.getElementById("membersText").style.visibility = "hidden";
	document.getElementById("enterText").style.visibility = "hidden";
}
//-----------------------------------------------------------------------

// form codeing
function resetInputBg(){
	passwordBlur();
	emailBlur();
}

function emailFocus(){
	document.getElementById("email").style.backgroundColor = "#a0c5d0";
}
function passwordFocus() {
	document.getElementById("password").style.backgroundColor = "#a0c5d0";
}

function passwordBlur() {
	document.getElementById("password").style.backgroundColor = "#ffffff";
}
function emailBlur() {
	document.getElementById("email").style.backgroundColor = "#ffffff";
}

//-----------enter main site
function enter() {
	//bang in a switch to php file for session modification + security
	window.location.href = "gateway.php";
}

//----want to sumit for on the enter key pres on the password field
function keyEnter(e) {
	if (e.keyCode == "13") {
		document.getElementById("login").submit();	
	}
	/*alert(e.keyCode);*/
}

function checkver() {
	var x = navigator.appName;
	var version=navigator.appVersion;
	
	var version=parseFloat(navigator.appVersion.split("MSIE")[1])
	
	if ((x == "Microsoft Internet Explorer") && (version < 7)) {
		window.location.href="noaccess.php";
	}
	
}