var dots = "";
var snm = function(data, config) {
this.level = 0;
this.config = config;
this.data = data;
this.strHTML="";
this.isDefined=function(el){return (typeof(el)=="undefined"||el==null)?false:true;};
this.build=function()
{
var strHTML = "";
strHTML += "
";
this.container.innerHTML = strHTML;
};
this.init=function(c, n)
{
this.container = $(this.config.container);
this.setPref(c);
this.build();
if(this.isDefined(n)) this.expandToNode(n);
};
this.setPref = function(pref)
{
var pref = (this.isDefined(pref))?pref:false;
this.config.prefix = (pref && pref.prefix)?pref.prefix:this.config.prefix;
this.config.indent = (pref && pref.indent)?pref.indent:this.config.indent;
this.config.bg = (pref && pref.bg)?pref.bg:this.config.bg;
this.config.iconPosition = (pref && pref.iconPosition)?pref.iconPosition:this.config.iconPosition;
};
this.addItems=function(arr)
{
// this is the generic add item that's used to add an item to the SNM
var child = 3;
var display = (arr[2]!=null)?"display:none;":"";
var str = "";
var img;
do{
str += this.buildRow(arr[child]);
child++;
}while(arr[child]&&arr[child]!=null)
str += "
";
this.menus++;
return str;
};
this.buildRow=function(arr)
{
var str = ""; var bg = ""; var style = "";
if(this.isDefined(arr[3]) && this.level == 0)
{
bg = "background: url(resources/images/arrow.gif) no-repeat 187px 50%;";
}
if(this.config.style!=null) style = this.getStyle();
// href=\""+arr[1]+"\"
if(this.level == 0 && this.isDefined(arr[3]))
str += ""+arr[0]+"";
else
str += ""+arr[0]+"";
if(this.isDefined(arr[3]))
{
this.level++;
str += this.addItems(arr);
this.level--;
}
str += "";
return str;
};
this.getStyle = function()
{
var sli = this.config.style[this.level].li;
var sa = this.config.style[this.level].a;
var li = "";
var a = "";
for(key in sli)
{
li += key+":"+sli[key];
}
for(key in sa)
{
a += key+":"+sa[key];
}
return [li, a];
};
this.showChild=function(e, element, section)
{
// this is called when you are expanding a node so see it's children
var elem=(!(this.isDefined(element)&&this.isDefined(element.tagName)))?null:element;
var ct = (elem!=null)?elem.nextSibling:this.nextSibling;
bi = elem.style.backgroundImage;
if(bi == "" && (ct.style.display != "none"))
elem.style.backgroundImage = "url(resources/images/arrow.gif)";
else
elem.style.backgroundImage = "";
ct.style.display = (ct.style.display=="none")?"":"none";
};
this.collapseAll=function(e)
{
var tbl = findParent(findParent(e, "TD"), "TABLE").firstChild;
var ri = null; var s = null; var b = null;
for(var a=0; a