

function openLogin(type, ref) {
	loggedOut = false;
	if(type == "lout")
		loggedOut = true;
	
	if(type == "updateRef") {
		var refObj = document.getElementById("ref");
		refObj.value = ref;
	}
	
	var bgOpac = document.getElementById("op");
	var newWin = document.getElementById("LoginBox");
	var newFrame = document.getElementById("hiddenFrame");  //Fixes IE bug
	newFrame.style.width = "900px"; //The size of any content
	newFrame.style.height = "900px"; //The size of any content
	newFrame.style.zindex = "999999";
	window.scrollTo(0,0);
	bgOpac.style.width = "1680px";
	bgOpac.style.height = "1250px";
	if(loggedOut) {
		newWin.style.width = "277px";
		newWin.style.height = "278px";
		newWin.style.top = "125px";
		newWin.style.left = "350px";
		newWin.innerHTML = "<table border=0 width=100%><tr><td width=15>&nbsp;</td><td width=245 align=right><a href=\"javascript:void(0)\" onClick=\"closeLogin('" + ref + "');\" class=\"link4\">Close X</a></td><td width=15>&nbsp;</td></tr><tr><td colspan=2><span align=left class=\"loginTitle\" style=\"color: #EE0000\">&nbsp;You have been logged out</span></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td colspan=2><hr class=\"sideTitle\" /></td></tr><tr><td>&nbsp;</td><td>Thank You,<p>You have been successfully logged out.  Please click \"Close\" to continue</td></tr></table>";
	} else {
		newWin.style.width = "277px";
		newWin.style.height = "278px";
		newWin.style.top = "125px";
		newWin.style.left = "350px";
	}
	bgOpac.style.visibility = "visible";
	newWin.style.visibility = "visible";
	
	if(!loggedOut) {
		theField = document.getElementById('username');
		theField.focus();
	}
}

function replaceDiv(ref) {
	var newWin = document.getElementById("LoginBox");
	newWin.innerHTML = "<table border=0 width=100%><tr><td width=15>&nbsp;</td><td width=245 align=right><a href=\"javascript:void(0)\" onClick=\"closeLogin('');\" class=\"link4\">Close X</a></td><td width=15>&nbsp;</td></tr><tr><td colspan=2><span align=left class=\"loginTitle\">&nbsp;Please Login To Continue</span></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td colspan=2><hr class=\"sideTitle\" /></td></tr><tr><td>&nbsp;</td><td align=center><form name=login action=\"/login.php\" method=post><input type=hidden name=login value=\"1\" /><input type=hidden name=ref id=\"ref\" value=\"" + ref + "\" /><table border=0><tr><td align=right class=\"loginTxt\">Email Address:&nbsp;</td><td><input type=text id=username name=username class=\"field0\" onfocus=\"swapClass(this);\" onblur=\"swapClass(this);\"></td></tr><tr><td align=right class=\"loginTxt\">Password:&nbsp;</td><td><input type=password name=password class=\"field0\" onfocus=\"swapClass(this);\" onblur=\"swapClass(this);\"></td></tr><tr><td colspan=2>&nbsp;</td></tr><tr><td colspan=2 align=center><input type=submit class=btn value=\"Login To My Account\"></td></tr></table></form></td><td>&nbsp;</td></tr><tr><td colspan=3>&nbsp;</td></tr><tr><td colspan=3>&nbsp;</td></tr><tr><td colspan=2><span align=left class=\"loginTitle\">&nbsp;Help Me</span></td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td colspan=2><hr class=\"sideTitle\" /></td></tr><tr><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"login.php?pageID=139\" class=link4>Create a new account</a><br />&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"login.php?pageID=140\" class=link4>I forgot my email address</a><br />&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"login.php?pageID=141\" class=link4>I forgot my password</a><br /></td><td>&nbsp;</td></tr></table>";
}

function closeLogin(ref) {
	var bgOpac = document.getElementById("op");
	var newWin = document.getElementById("LoginBox");
	var newFrame = document.getElementById("hiddenFrame");  //Fixes IE bug
	newFrame.style.width = "0px";
	newFrame.style.height = "0px";
	bgOpac.style.width = "0px";
	bgOpac.style.height = "0px";
	bgOpac.style.visibility = "hidden";
	newWin.style.visibility = "hidden";
	if(ref != "")
		replaceDiv(ref);
}
