//======
//======
//
// Template- LOGIN_BLOCK_JS.IHT by S.Huang 10-MAR-05 / 18-AUG-05
//
// Purpose-
//
// Javascript functions for handling MEDIANET login only html
// blocks
//
// Notes-
//
// - This script is used togther with pages that have login only
// block wrapped with
, and a
// javascript to invoke login only function should be after
// the block.
// e.g
//
//
// - Be aware of that different div's can have the same name
// attribute, above function call will apply to all div's
// with name "divName" before it.
//
// - Support browsers: IE5+ and NN6+.
//
// Modifications-
//
// 26-APR-05 SH / TH / KB 12=16390
// - Created.
//
// 18-AUG-05 SH / JY / SH 17=
// - Check whether has 'name' attribute first, and then
// determine show/hide this
or not.
//
// 04-Jul-07 BG / BG / BG 12=18420
// - Converted to from .iht to .js.
//
//======
//======
if (prjNum==undefined) {
var prjNum="217";
}
function userLoggedIn() {
if (!W3CDOM) return;
// CLoginCookie
is MEDIANET login cookie name
// - We have a constant variable prjNum set before this package thus
// it can be used here.
// - The name we are matching to locate the login cookie has length
// of 16.
var matchStr="CLoginCookie"+prjNum+"=";
var inx=document.cookie.indexOf(matchStr,0);
if (inx != -1) {
// - Check the cookie name only is not sufficient for
// determining whether Medianet login cookie exists as the
// login cookie name will remain in cookie with value " "
// after logout.
// - We need to check the cookie value to determine if login
// cookie exists.
// - Cookies are separated by ";"
var endStr = document.cookie.indexOf(";",inx);
if (endStr == -1)
endStr = document.cookie.length;
var cookieValue = unescape(document.cookie.substring(inx+16, endStr));
if (!cookieValue.match(/^\s*$/))
return true;
}
return false;
}
function showBlock(divName) {
if (!W3CDOM) return;
var div;
for (var j=0;(div=document.body.getElementsByTagName("div").item(j)); j++) {
if (div.attributes.getNamedItem("name")==undefined) {
} else if (div.attributes.getNamedItem("name").value==divName) {
div.style.display="inline";
}
}
}
function hideBlock(divName) {
if (!W3CDOM) return;
var div;
for (var j=0;(div=document.body.getElementsByTagName("div").item(j)); j++) {
if (div.attributes.getNamedItem("name")==undefined) {
} else if (div.attributes.getNamedItem("name").value==divName) {
div.style.display="none";
}
}
}
function loginOnly(divName) {
if (!W3CDOM) return;
if(userLoggedIn()) showBlock(divName);
else hideBlock(divName);
}