// This file was generated by ScriptServer.class.php at 2007-10-19 21:29:45
// Source file's mtime was 2007-10-19 21:28:56

function QuickMenu(idMenu, idInput) {
 this.menuRoot = document.getElementById(idMenu);
 this.input = document.getElementById(idInput);
this.visibleDepth = 1;
this.minimalInputLength = 1;
this.activeItemId = 'qmActive';
this.classTable = new Object;
this.classTable.qmDefault = 'qmDefault';
this.classTable.qmMatch = 'qmMatch';
this.classTable.qmHidden = 'qmHidden';
this.imgExpanded = '';
this.imgCollapsed = '';
this.imgNoChildern = '';
QuickMenu.prototype.MODE_INIT = 0;
QuickMenu.prototype.MODE_SEARCH = 1;
QuickMenu.prototype.MODE_EXPAND = 2;
QuickMenu.prototype.MODE_SHOWACTIVE = 3;
QuickMenu.prototype.setCollapseImg = function(node, hasChildern, bCollapsed) {
var img = new ChildElementsEnumerator(node, 'img').next();
img.qmCollapsed = bCollapsed;
if (!hasChildern)
img.src = this.imgNoChildern;
else if (bCollapsed)
img.src = this.imgCollapsed;
else
img.src = this.imgExpanded;
}
QuickMenu.prototype.setItemClass = function(item, className){
var className = this.classTable[className];
item.className = className;
var a = (new ChildElementsEnumerator(item, 'a')).next();
a.className = className;
}
QuickMenu.prototype.crawler = function(currentNode, mode, depth) {
var textNode = (new ChildElementsEnumerator(currentNode, 'a')).next().firstChild;
var bCurrentVisible = false;
var bImpliedVisible = false;
switch (mode) {
case this.MODE_SEARCH:
if (this.searchEngine.isMatch(textNode.data)) {
this.matchCount++;
this.lastMatchLink = (new ChildElementsEnumerator(currentNode, 'a')).next().attributes.getNamedItem('href').value;
bCurrentVisible = textNode.nodeType==3;
} else {
bCurrentVisible = false;
}
}
var nextList = (new ChildElementsEnumerator(currentNode, 'ul')).next();
var hasChildern = nextList!=null;
if (hasChildern) {
var current;
var enumerator = new ChildElementsEnumerator(nextList, 'li');
while (null!= (current = enumerator.next())) {
var bNested = this.crawler(current, mode, depth-1);
bImpliedVisible |= bNested;
}
}
var bActive = (currentNode.id == this.activeItemId);
switch (mode) {
case this.MODE_INIT:
currentNode.qmStateClass = this.classTable['qmDefault'];
var img = new ChildElementsEnumerator(currentNode, 'img').next();
img.onclick = function() {
with (arguments.callee.qm) {
var bCollapsed = !this.qmCollapsed;
var nextList = (new ChildElementsEnumerator(this.parentNode, 'ul')).next();
if (nextList==null)
return;
var current;
var enumerator = new ChildElementsEnumerator(nextList, 'li');
while (null!= (current = enumerator.next())) {
if (bCollapsed) {
current.qmStateClass = current.className;
setItemClass(current, 'qmHidden');
} else {
setItemClass(current, current.qmStateClass);
}
}
setCollapseImg (this.parentNode, true, !this.qmCollapsed);
}
}
img.onclick.qm = this;
break;
case this.MODE_SEARCH:
case this.MODE_SHOWACTIVE:
if (bCurrentVisible)
this.setItemClass(currentNode, 'qmMatch');
else if (bImpliedVisible || depth>0)
this.setItemClass(currentNode, 'qmDefault');
else
this.setItemClass(currentNode, 'qmHidden');
var bVisible = bImpliedVisible ||
(mode == this.MODE_SEARCH && bCurrentVisible) ||
(mode == this.MODE_SHOWACTIVE && bActive);
if (bVisible)
this.crawler(
currentNode, this.MODE_EXPAND,
(bCurrentVisible)?this.visibleDepth:1);
this.setCollapseImg(currentNode, hasChildern, !bVisible && depth<=1);
return bVisible;
case this.MODE_EXPAND:
if (depth>=0 && currentNode.className == this.classTable['qmHidden']) {
this.setItemClass(currentNode, 'qmDefault');
this.setCollapseImg(currentNode, hasChildern, depth==0);
}
}
}
QuickMenu.prototype.enumMenu = function(mode, depth) {
var rootEnum = new ChildElementsEnumerator(this.menuRoot, 'li');
var currentItem;
while (currentItem = rootEnum.next())
this.crawler(currentItem, mode, depth);
}
QuickMenu.prototype.init = function() {
var cbInput = function(searchStr) {
this.matchCount = 0;
var bEnoughInput =
searchStr!=null &&
searchStr.length >= this.minimalInputLength;
var mode = this.MODE_SEARCH;
if (searchStr=='*')
this.enumMenu(this.MODE_SHOWACTIVE, Infinity);
else if (bEnoughInput) {
this.searchEngine = new SearchEngineChain(searchStr);
this.enumMenu(this.MODE_SEARCH, 1);
} else {
this.enumMenu(this.MODE_SHOWACTIVE, this.visibleDepth);
}
if (this.matchCount ==1) {
this.input.onkeypress = function(e) {
if (-1!=navigator.appName.search(/explorer/i))
var e = window.event;
if (e.keyCode==13)
window.location = arguments.callee.goToLocation;
}
this.input.onkeypress.goToLocation = this.lastMatchLink;
} else {
this.input.onkeypress = null;
}
}
new InputWatch(this.input, cbInput, this);
this.enumMenu(this.MODE_INIT, 0);
cbInput.call(this);
}
}
// File generated in 0.025 s
