

/* replacements for hideLayer and showLayer, in which I made a stupid mistake (confusing 'block' with 'inline') which will never be fully corrected */
function sL(myName) {
	var myObj = new getObj(myName);
	myObj.style.visibility="visible";
	myObj.style.display="block";
}
function hL(myName) {
	var myObj = new getObj(myName);
	myObj.style.visibility="hidden";
	myObj.style.display="none";
}


function showSitemap() {
	// reads a url parameter for the sitemap, and shows the appropriate layer.
	var whichmap = getQueryVal("resource");
	if (whichmap == false) {
		// normal sitemap
		hL("pageheader");
		sL("sitemap");
	} else {
		// resource nav layer
		hL("sitemap");
		sL("nav" + whichmap);
		sL("crumb" + whichmap);
	}
}

function fakeLogin(isbn) {
	// sets a cookie which causes the user to be treated as a teacher or student. Bypasses eRights.
	var wantsProf = (document.forms.frmLandingPage.teacherStatus[0].checked) ? 1 : 0;
	var cookieName = "NOLOGIN" + isbn;
	var cookieString = "isProf=" + wantsProf;
	setSessionCookie(cookieName, cookieString);
	isProfVal = getCookieVal(cookieName, 'isProf');
}

function InitThisStyle(isbn) {
	// currently, just reads the fake login cookie and displays the teacher or student badge / nav as needed.
	// could be expanded to Do More Stuff.
	var cookieName = "";
	if (getCookie("OLCGroup")) {cookieName="OLCGroup"};
	if (getCookie("OLC" + isbn)) {cookieName="OLC" + isbn}
	if (getCookie("NOLOGIN" + isbn)) {cookieName="NOLOGIN" + isbn}

	if (getCookieVal(cookieName, 'isProf') == 1) {
		sL('olc_badge_teacher');
		hL('olc_badge_student');
		sL('teacherNav');
	} else {
		hL('olc_badge_teacher');
		sL('olc_badge_student');
		hL('teacherNav');
	}
}

function testLogin(theUrl, theTarget) {
	// Handle protected atoms (show login form if necessary
	if (loggedIn == 1) {
		if (theTarget) {
			window.open(theUrl, theTarget, "toolbar=yes,location=yes,scrollbars=yes");
		} else {
			// window.location.href=theUrl;
			// For some reason the above fails in IE/Win.  This works, though:
			setTimeout("window.location='"+theUrl+"';",10);
		}
	} else {
		// pass the desired URL into the login form:
		document.forms.loginForm.goto_url.value = theUrl;
		// show the login form
		hL('pagecontent');
		sL('loginPane');
	} 
}
