
var bbcjs =
{
version				: 1,
cvs_version			: "$Revision: 1.30 $",
build_date			: '$Date: 2005/04/28 12:40:48 $',
page				: location.href.split("/")[location.href.split("/").length-1],
onLoadArr			: [],
o2lvl				: 0,
o2cnt				: 0,
dhtml				: (document.getElementById) ? true : false,
defaultTraceLevel	: 3,
quietMode			: false,
activex				: (typeof(window.ActiveXObject)!="undefined"),
qs					: location.search.substr(1,location.search.length),
lib					: {},
documentLoaded		: false
};
//Need to remind IE5 mac that it DOESN'T support activex:
if (navigator.userAgent.indexOf("Mac")>-1) bbcjs.activex = false;
bbcjs.trace = function (str,lvl)
{
if (window.self != window.parent) {
if ((typeof(window.parent.frames.tools)!="undefined") && typeof(window.parent.frames.tools.jsh_debug)!="undefined" )
{
if (typeof(lvl)=="undefined") lvl = bbcjs.defaultTraceLevel;
window.parent.frames.tools.jsh_debug(str,lvl);
}
}
//If we have a level 1 alert, are working on preview servers and no harness is loaded, alert the message.
else if ( (!bbcjs.quietMode) && (lvl == 1) && (location.href.match(/wc\.bbc/)))
{
str = str.replace(/\<br ?\/?\>/g,"\n");
str = str.replace(/\<[a-zA-Z0-9\=\"_\-\' \/]+\>/g,"");
alert("JSTools error (this will not appear on live):\n\n"+str);
}
}
bbcjs.clearTraceWindow = function ()
{
if (window.self != window.parent) {
if ((typeof(window.parent.frames.tools)!="undefined") && typeof(window.parent.frames.tools.jsh_debug)!="undefined" )
{
if (typeof(lvl)=="undefined") lvl = bbcjs.defaultTraceLevel;
window.parent.frames.tools.jsh_reset();
}
}
}
bbcjs.clearTraceWindow();
bbcjs.trace("<b>Loaded url: "+bbcjs.page+"</b>",2);
bbcjs.trace('<b><font color="green">jst_core.js</font> was included.</b>',2);
bbcjs.addOnLoadItem = function (str)
{
bbcjs.onLoadArr[bbcjs.onLoadArr.length] = str;
window.onload = bbcjs.loadedHandler;
}
bbcjs.loadedHandler = function ()
{
for (var i in bbcjs.onLoadArr)
{
eval(bbcjs.onLoadArr[i]);
}
}
bbcjs.copyObj = function (o)
{
var t = {};
if (typeof(o.length)!="undefined") t = [];
for (var i in o)
{
if (typeof(o[i])=="object") t[i] = bbcjs.copyObj(o[i]);
else t[i] = o[i];
}
return t;
}
bbcjs.obj2list = function(o,name,hide)
{
var str = "";
var c=0;
var display = "none";
if (typeof(hide)!="undefined"){ if (!(hide)) display = "block";}
else hide = true;
//If we haven't been supplied a name, use a common name
if (typeof(name)=="undefined") name = "_root";
//Only create the outer UL tag for the first instance (root)
if (bbcjs.o2lvl==0) str+="<ul>\n";
bbcjs.o2lvl++;
bbcjs.o2cnt++;
//Begin the object element.
str+='<li><a href="javascript:void(0);" onclick="return bbcjs.o2swap('+bbcjs.o2cnt+')">'+name+'</a></li>\n';
str+='<ul style="display:'+display+';" id="bbcjsnode_'+bbcjs.o2cnt+'">\n';
//Loop through each element of this object, recurse if we find an object...
for (var i in o)
{
if (typeof(o[i])=='function') str+=('<li>'+i.bold()+'()</li>\n');
else if (typeof(o[i])=='object' && o[i] != null)
{
if ((typeof(o[i].src)!="undefined") && (typeof(o[i].alt)!="undefined"))
{
str+=('<li><b>'+i+"</b>: "+o[i].src+' (image)</li>\n');
}
else if (bbcjs.o2lvl<100 && (i!="prototype")) str+=bbcjs.obj2list(o[i],i,hide);
else if (bbcjs.o2lv>=100) str+="<li>Too much recursion...</li>\n";
}
else if (o[i]!=null) str+=('<li>'+i+' ['+bbcjs.HTMLOut(o[i])+'] ('+typeof(o[i])+')</li>\n');
else str += '<li><b>null item</b></li>';
c++;
}
if (c==0) str+=('<li>'+o+'</li>\n');
str+="</ul>\n";
//Get out of this level of nesting...
bbcjs.o2lvl--;
//close the original ul if on main recursion level.
if (bbcjs.o2lvl==0)	str+="</ul>\n";
return str;
}
bbcjs.o2swap = function (nn)
{
var node = document.getElementById("bbcjsnode_"+nn);
if (node.style.display == "block") node.style.display = "none";
else node.style.display = "block";
return false;
}
bbcjs.HTMLOut = function (html)
{
return "<xmp style='display:inline;'>"+html+"</xmp>";
}
bbcjs.Module = function (name, v, cvs, bd)
{
this.name = name;
this.version = v;
this.cvs_version = cvs;
this.build_date = bd;
this.getDocs = function()
{
window.open("http://technet.wc.bbc.co.uk/software/js/findmod.xhtml?"+this.name);
}
}
var CONST = {};
var GLOB = {};
//Set documentLoaded property to true when the whole page has finished loading.
bbcjs.addOnLoadItem("bbcjs.documentLoaded = true;");

