//*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+
// Generator   : PPWIZARD version 04.051
//             : FREE tool for Windows, OS/2, DOS and UNIX by Dennis Bareis (dbareis@labyrinth.net.au)
//             : http://www.labyrinth.net.au/~dbareis/ppwizard.htm
// Time        : Tuesday, 6 Apr 2004 8:26:10pm
// Input File  : d:\www_newdesign\samarth\source\samarth\scripts\tree.js.it
// Output File : d:\www_newdesign\samarth\target\samarth\scripts\tree.js
//*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+*+

var trees = [];
// --- tree class ---
function tree (elem_data, pos, styles) {
// browser check
this.elem_data = elem_data;
this.pos = pos;
this.styles = styles;
this.id = trees.length;
this.elems = [];
this.children = [];
this.add_elem = tree_add_elem;
this.hide = tree_hide;
this.onclick = tree_onclick;
this.onmouseout = tree_onmouseout;
this.onmouseover = tree_onmouseover;
this.onmousedown = tree_onmousedown;
var i;
for (i = 0; i < this.elem_data.length; i++)
new tree_elem(i, this, this);
for (i = 0; i < this.children.length; i++)
this.children[i].visibility(true);
trees[this.id] = this;
}
function tree_add_elem (elem) {
var id = this.elems.length;
this.elems[id] = elem;
return (id);
}
function tree_hide () {
for (var i = 0; i < this.elems.length; i++) {
this.elems[i].visibility(false);
this.elems[i].switch_style('onmouseout');
}
}
function tree_onclick (id) {
var elem = this.elems[id];
return (elem.fields[1] ? true : false);
}
function tree_onmouseout (id) {
this.hide_timer = setTimeout('trees['+ this.id +'].hide();',
this.pos['hide_delay'][this.active_elem.depth]);
if (this.active_elem.id == id)
this.active_elem = null;
}
function tree_onmouseover (id) {
this.active_elem = this.elems[id];
clearTimeout(this.hide_timer);
var curr_elem, visib;
for (var i = 0; i < this.elems.length; i++) {
curr_elem = this.elems[i];
visib = (curr_elem.arrpath.slice(0, curr_elem.depth).join('_') ==
this.active_elem.arrpath.slice(0, curr_elem.depth).join('_'));
if (visib)
curr_elem.switch_style (
curr_elem == this.active_elem ? 'onmouseover' : 'onmouseout');
curr_elem.visibility(visib);
}
}
function tree_onmousedown (id) {
this.elems[id].switch_style('onmousedown');
}
// --- tree elem Class ---
function tree_elem (path, parent, container) {
this.path = new String (path);
this.parent = parent;
this.container = container;
this.arrpath = this.path.split('_');
this.depth = this.arrpath.length - 1;
// get pointer to elem's data in the structure
var struct_path = '', i;
for (i = 0; i <= this.depth; i++)
struct_path += '[' + (Number(this.arrpath[i]) + (i ? 3 : 0)) + ']';
eval('this.fields = this.container.elem_data' + struct_path);
if (!this.fields) return;
this.height=0;
this.extraTop=0;
this.nextTop=0;
if (this.fields[2]){
this.height= parseInt(this.fields[2]);
}
if (parent.children.length > 0){
this.extraTop = parent.children[parent.children.length - 1].nextTop;
this.nextTop = this.height + this.extraTop;
//alert("nextTop:" + this.nextTop + ", parent.children.length:" + parent.children.length + ", parent.children[parent.children.length - 1].nextTop:" + parent.children[parent.children.length - 1].nextTop);
}
// assign methods
this.get_x = telem_get_x;
this.get_y = telem_get_y;
// these methods may be different for different browsers (i.e. non DOM compatible)
this.init = telem_init;
this.visibility = telem_visibility;
this.switch_style = telem_switch_style;
// register in the collections
this.id = this.container.add_elem(this);
parent.children[parent.children.length] = this;
// init recursively
this.init();
this.children = [];
var child_count = this.fields.length - 2;
for (i = 0; i < child_count; i++)
new tree_elem (this.path + '_' + i, this, this.container);
this.switch_style('onmouseout');
}
function telem_init() {
document.write (
'<a id="mi_' + this.container.id + '_'
+ this.id +'" class="e' + this.container.id + 'l' + this.depth
+'o" href="' + this.fields[1] + '" style="position: absolute; top: '
+ this.get_y() + 'px; left: '   + this.get_x() + 'px; width: '
+ this.container.pos['width'][this.depth] + 'px; height: '
+ this.container.pos['height'][this.depth] + 'px; visibility: hidden;'
+' background: black; color: white; z-index: ' + this.depth + ';" '
+ 'onclick="return trees[' + this.container.id + '].onclick('
+ this.id + ');" onmouseout="trees[' + this.container.id + '].onmouseout('
+ this.id + ');" onmouseover="trees[' + this.container.id + '].onmouseover('
+ this.id + ');" onmousedown="trees[' + this.container.id + '].onmousedown('
+ this.id + ');"><div style="height:"' + this.height + '" class="e'  + this.container.id + 'l' + this.depth + 'i">'
+ this.fields[0] + "</div></a>\n"
);
this.element = document.getElementById('mi_' + this.container.id + '_' + this.id);
}
function telem_visibility(make_visible) {
if (make_visible != null) {
if (this.visible == make_visible) return;
this.visible = make_visible;
if (make_visible)
this.element.style.visibility = 'visible';
else if (this.depth)
this.element.style.visibility = 'hidden';
}
return (this.visible);
}
function telem_get_x() {
var value = 0;
for (var i = 0; i <= this.depth; i++)
value += this.container.pos['block_left'][i]
+ this.arrpath[i] * this.container.pos['left'][i];
return (value);
}
function telem_get_y() {
var value = 0;
var p = this;
for (var i = 0; i <= this.depth; i++) {
value += p.extraTop + this.container.pos['block_top'][i]
+ this.arrpath[i] * (this.container.pos['top'][i]);
p = this.parent;
}
return (value);
}
function telem_switch_style(state) {
if (this.state == state) return;
this.state = state;
var style = this.container.styles[state];
for (var i = 0; i < style.length; i += 2)
if (style[i] && style[i+1])
eval('this.element.style.' + style[i] + "='"
+ style[i+1][this.depth] + "';");
}
// that's all folks

