var jpf = {
VERSION:'2.0.',
CDN            : "",
READY          : false,
NODE_HIDDEN    : 101,
NODE_VISIBLE   : 102,
NODE_MEDIAFLOW : 103,
NODE_ELEMENT                : 1,
NODE_ATTRIBUTE              : 2,
NODE_TEXT                   : 3,
NODE_CDATA_SECTION          : 4,
NODE_ENTITY_REFERENCE       : 5,
NODE_ENTITY                 : 6,
NODE_PROCESSING_INSTRUCTION : 7,
NODE_COMMENT                : 8,
NODE_DOCUMENT               : 9,
NODE_DOCUMENT_TYPE          : 10,
NODE_DOCUMENT_FRAGMENT      : 11,
NODE_NOTATION               : 12,
KEYBOARD       : 2,
KEYBOARD_MOUSE : true,
SUCCESS : 1,
TIMEOUT : 2,
ERROR   : 3,
OFFLINE : 4,
debug         : false,
includeStack  : [],
initialized   : false,
autoLoadSkin  : false,
crypto        : {}, 
_GET          : {},
basePath      : "./",
ns : {
jpf    : "http://www.javeline.com/2005/jml",
jml    : "http://www.javeline.com/2005/jml",
xsd    : "http://www.w3.org/2001/XMLSchema",
xhtml  : "http://www.w3.org/1999/xhtml",
xslt   : "http://www.w3.org/1999/XSL/Transform",
xforms : "http://www.w3.org/2002/xforms",
ev     : "http://www.w3.org/2001/xml-events"
},
browserDetect : function(){
if (this.$bdetect)
return;
this.$bdetect = true;
var sAgent = navigator.userAgent.toLowerCase();
this.isOpera = sAgent.indexOf("opera") != -1;
this.isKonqueror = sAgent.indexOf("konqueror") != -1;
this.isSafari    = !this.isOpera && ((navigator.vendor
&& navigator.vendor.match(/Apple/) ? true : false)
|| sAgent.indexOf("safari") != -1 || this.isKonqueror);
this.isSafariOld = false;
if (this.isSafari) {
var matches  = sAgent.match(/applewebkit\/(\d+)/);
if (matches)
this.isSafariOld = parseInt(matches[1]) < 420;
}
this.isChrome    = sAgent.indexOf("chrome/") != -1;
this.isGecko     = !this.isOpera && !this.isSafari && sAgent.indexOf("gecko") != -1;
this.isGecko3    = this.isGecko && sAgent.indexOf("firefox/3") != -1;
this.isIE        = document.all && !this.isOpera && !this.isSafari ? true : false;
this.isIE50      = this.isIE && sAgent.indexOf("msie 5.0") != -1;
this.isIE55      = this.isIE && sAgent.indexOf("msie 5.5") != -1;
this.isIE6       = this.isIE && sAgent.indexOf("msie 6.") != -1;
this.isIE7       = this.isIE && sAgent.indexOf("msie 7.") != -1;
this.isIE8       = this.isIE && sAgent.indexOf("msie 8.") != -1;
this.isWin       = sAgent.indexOf("win") != -1 || sAgent.indexOf("16bit") != -1;
this.isMac       = sAgent.indexOf("mac") != -1;
this.isAIR       = sAgent.indexOf("adobeair") != -1;
},
setCompatFlags : function(){
this.TAGNAME                   = jpf.isIE ? "baseName" : "localName";
this.supportVML                = jpf.isIE;
this.supportCanvas             = !jpf.isIE;
this.supportSVG                = !jpf.isIE;
this.styleSheetRules           = jpf.isIE ? "rules" : "cssRules";
this.brokenHttpAbort           = jpf.isIE6;
this.canUseHtmlAsXml           = jpf.isIE;
this.supportNamespaces         = !jpf.isIE;
this.cannotSizeIframe          = jpf.isIE;
this.supportOverflowComponent  = jpf.isIE;
this.hasEventSrcElement        = jpf.isIE;
this.canHaveHtmlOverSelects    = !jpf.isIE6 && !jpf.isIE5;
this.hasInnerText              = jpf.isIE;
this.hasMsRangeObject          = jpf.isIE;
this.hasContentEditable        = jpf.isIE || jpf.isOpera;
this.descPropJs                = jpf.isIE;
this.hasClickFastBug           = jpf.isIE;
this.hasExecScript             = window.execScript ? true : false;
this.canDisableKeyCodes        = jpf.isIE;
this.hasTextNodeWhiteSpaceBug  = jpf.isIE;
this.hasCssUpdateScrollbarBug  = jpf.isIE;
this.canUseInnerHtmlWithTables = !jpf.isIE;
this.hasSingleResizeEvent      = !jpf.isIE;
this.hasStyleFilters           = jpf.isIE;
this.supportOpacity            = !jpf.isIE;
this.supportPng24              = !jpf.isIE6 && !jpf.isIE5;
this.cantParseXmlDefinition    = jpf.isIE50;
this.hasDynamicItemList        = !jpf.isIE || jpf.isIE7;
this.canImportNode             = jpf.isIE;
this.hasSingleRszEvent         = !jpf.isIE;
this.hasXPathHtmlSupport       = !jpf.isIE;
this.hasFocusBug               = jpf.isIE;
this.hasReadyStateBug          = jpf.isIE50;
this.dateSeparator             = jpf.isIE ? "-" : "/";
this.canCreateStyleNode        = !jpf.isIE;
this.supportFixedPosition      = !jpf.isIE || jpf.isIE7;
this.hasHtmlIdsInJs            = jpf.isIE || jpf.isSafari;
this.needsCssPx                = !jpf.isIE;
this.hasAutocompleteXulBug     = jpf.isGecko;
this.mouseEventBuffer          = jpf.isIE ? 20 : 6;
this.hasComputedStyle          = typeof document.defaultView != "undefined"
&& typeof document.defaultView.getComputedStyle != "undefined";
this.locale                    = (this.isIE
? navigator.userLanguage
: navigator.language).toLowerCase();
this.maxHttpRetries = this.isOpera ? 0 : 3;
this.dynPropMatch = new RegExp();
this.dynPropMatch.compile("^[{\\[].*[}\\]]$");
this.percentageMatch = new RegExp();
this.percentageMatch.compile("([\\-\\d\\.]+)\\%", "g");
},
extend : function(dest, src){
var prop, i, x = !dest.notNull;
if (arguments.length == 2) {
for (prop in src) {
if (x || src[prop])
dest[prop] = src[prop];
}
return dest;
}
for (i = 1; i < arguments.length; i++) {
src = arguments[i];
for (prop in src) {
if (x || src[prop])
dest[prop] = src[prop];
}
}
return dest;
},
start : function(){
this.started = true;
var sHref = location.href.split("?")[0];
this.host     = location.hostname && sHref.replace(/(\/\/[^\/]*)\/.*$/, "$1");
this.hostPath = sHref.replace(/\/[^\/]*$/, "") + "/";
this.CWD      = sHref.replace(/^(.*\/)[^\/]*$/, "$1") + "/";
this.browserDetect();
this.setCompatFlags();
if (this.isIE) jpf.runIE();
if (this.isSafari) jpf.runSafari();
if (this.isOpera) jpf.runOpera();
if (this.isGecko || !this.isIE && !this.isSafari && !this.isOpera)
jpf.runGecko();
for (var i, a, m, n, o, v, p = location.href.split(/[?&]/), l = p.length, k = 1; k < l; k++)
if (m = p[k].match(/(.*?)(\..*?|\[.*?\])?=([^#]*)/)) {
n = decodeURI(m[1]).toLowerCase(), o = this._GET;
if (m[2])
for (a = decodeURI(m[2]).replace(/\[\s*\]/g, "[-1]").split(/[\.\[\]]/), i = 0; i < a.length; i++)
v = a[i], o = o[n]
? o[n]
: o[n] = (parseInt(v) == v)
? []
: {}, n = v.replace(/^["\'](.*)["\']$/,"$1");
n != '-1'
? o[n] = decodeURI(m[3])
: o[o.length] = decodeURI(m[3]);
}
this.oHttp = new this.http();
this.Init.addConditional(this.loadIncludes, jpf, ['body', 'xmldb']);
try {
if (jpf.isIE)
document.execCommand("BackgroundImageCache", false, true);
}
catch(e) {};
this.root = true;
},
startDependencies : function(){
if (location.protocol != "file:") {
jpf.console.warn("You are serving multiple files from a (local)\
webserver - please consider using the file:// protocol to \
load your files, because that will make your application \
load several times faster.\
On a webserver, we recommend using a release or debug build \
of Javeline Platform.");
}
jpf.console.info("Loading Dependencies...");
var i;
for (i = 0; i < this.KernelModules.length; i++)
jpf.include("core/" + this.KernelModules[i], true);
for (i = 0; i < this.TelePortModules.length; i++)
jpf.include("elements/teleport/" + this.TelePortModules[i], true);
for (i = 0; i < this.Elements.length; i++) {
var c = this.Elements[i];
jpf.include("elements/" + c + ".js", true);
}
jpf.Init.interval = setInterval(
"if (jpf.checkLoadedDeps()) {\
clearInterval(jpf.Init.interval);\
jpf.start();\
}", 100);
},
nsqueue   : {},
namespace : function(name, oNamespace){
try{
eval("jpf." + name + " = oNamespace");
delete this.nsqueue[name];
for (var ns in this.nsqueue) {
if (ns.indexOf(name) > -1) {
this.namespace(ns, this.nsqueue[ns]);
}
}
return true;
}catch(e){
this.nsqueue[name] = oNamespace;
return false;
}
},
findPrefix : function(xmlNode, xmlns){
var docEl;
if (xmlNode.nodeType == 9) {
if (!xmlNode.documentElement) return false;
if (xmlNode.documentElement.namespaceURI == xmlns)
return xmlNode.prefix || xmlNode.scopeName;
docEl = xmlNode.documentElement;
}
else {
if (xmlNode.namespaceURI == xmlns)
return xmlNode.prefix || xmlNode.scopeName;
docEl = xmlNode.ownerDocument.documentElement;
if (docEl && docEl.namespaceURI == xmlns)
return xmlNode.prefix || xmlNode.scopeName;
while (xmlNode.parentNode) {
xmlNode = xmlNode.parentNode;
if (xmlNode.namespaceURI == xmlns)
return xmlNode.prefix || xmlNode.scopeName;
}
}
if (docEl) {
for (var i=0; i<docEl.attributes.length; i++) {
if (docEl.attributes[i].nodeValue == xmlns)
return docEl.attributes[i][jpf.TAGNAME]
}
}
return false;
},
importClass : function(ref, strip, win){
if (!ref)
throw new Error(jpf.formatErrorString(1018, null,
"importing class",
"Could not load reference. Reference is null"));
if (!strip)
return jpf.exec(ref.toString(), win);
var q = ref.toString().replace(/^\s*function\s*\w*\s*\([^\)]*\)\s*\{/, "");
q = q.replace(/\}\s*$/, "");
return jpf.exec(q, win);
},
toString : function(){
return "[Javeline (jpf)]";
},
all : [],
inherit : function(classRef){
for (var i=0; i<arguments.length; i++) {
arguments[i].call(this);
}
return this;
},
makeClass : function(oBlank){
if (oBlank.inherit) return;
oBlank.inherit = this.inherit;
oBlank.inherit(jpf.Class);
oBlank.uniqueId = this.all.push(oBlank) - 1;
},
uniqueHtmlIds : 0,
setUniqueHtmlId : function(oHtml){
oHtml.setAttribute("id", "q" + this.uniqueHtmlIds++);
},
getUniqueId : function(oHtml){
return this.uniqueHtmlIds++;
},
register : function(o, tagName, nodeFunc){
o.tagName  = tagName;
o.nodeFunc = nodeFunc || jpf.NODE_HIDDEN;
o.$domHandlers  = {"remove" : [], "insert" : [], "reparent" : [], "removechild" : []};
o.$propHandlers = {}; 
if (nodeFunc != jpf.NODE_HIDDEN) {
o.$booleanProperties = {
"visible"          : true,
"focussable"       : true,
"disabled"         : true,
"disable-keyboard" : true
}
o.$supportedProperties = [
"draggable", "resizable",
"focussable", "zindex", "disabled", "tabindex",
"disable-keyboard", "contextmenu", "visible", "autosize",
"loadjml", "actiontracker", "alias"];
}
else {
o.$booleanProperties = {}; 
o.$supportedProperties = []; 
}
if (!o.inherit) {
o.inherit = this.inherit;
o.inherit(jpf.Class);
o.uniqueId = this.all.push(o) - 1;
}
},
lookup : function(uniqueId){
return this.all[uniqueId];
},
findHost : function(o){
while (o && !o.host && o.parentNode)
o = o.parentNode;
return (o && o.host && typeof o.host != "string") ? o.host : false;
},
setReference : function(name, o){
return self[name] && self[name].hasFeature
? 0
: (self[name] = o);
},
console : {
debug : function(msg, subtype, data){
},
time : function(msg, subtype, data){
},
log : function(msg, subtype, data){
},
info : function(msg, subtype, data){
},
warn : function(msg, subtype, data){
},
error : function(msg, subtype, data){
},
dir : function(obj){
this.info(jpf.vardump(obj, null, false).replace(/ /g, "&nbsp;").replace(/</g, "&lt;"));
}
},
formatErrorString : function(number, control, process, message, jmlContext, outputname, output){
jpf.lastErrorMessage = message;
return message;
},
include : function(sourceFile, doBase){
jpf.console.info("including js file: " + sourceFile);
var sSrc = doBase ? (jpf.basePath || "") + sourceFile : sourceFile;
if (jpf.isSafariOld || !jpf.started) {
document.write('<script type="text/javascript" src="' + sSrc + '"><\/script>');
}
else {
var head     = document.getElementsByTagName("head")[0];
var elScript = document.createElement("script");
elScript.defer = true;
elScript.src   = sSrc;
head.appendChild(elScript);
}
},
Init : {
queue : [],
cond  : {
combined : []
},
done  : {},
add   : function(func, o){
if (this.inited)
func.call(o);
else if (func)
this.queue.push([func, o]);
},
addConditional : function(func, o, strObj){
if (typeof strObj != "string") {
if (this.checkCombined(strObj))
return func.call(o);
this.cond.combined.push([func, o, strObj]);
}
else if (self[strObj]) {
func.call(o);
}
else {
if (!this.cond[strObj])
this.cond[strObj] = [];
this.cond[strObj].push([func, o]);
this.checkAllCombined();
}
},
checkAllCombined : function(){
for (var i=0; i<this.cond.combined.length; i++) {
if (!this.cond.combined[i]) continue;
if (this.checkCombined(this.cond.combined[i][2])) {
this.cond.combined[i][0].call(this.cond.combined[i][1])
this.cond.combined[i] = null;
}
}
},
checkCombined : function(arr){
for (var i=0; i<arr.length; i++) {
if (!this.done[arr[i]])
return false;
}
return true;
},
run : function(strObj){
this.inited = this.done[strObj] = true;
this.checkAllCombined();
var data = strObj ? this.cond[strObj] : this.queue;
if (!data) return;
for (var i = 0; i < data.length; i++)
data[i][0].call(data[i][1]);
}
},
getJmlDocFromString : function(xmlString){
var str = xmlString.replace(/\<\!DOCTYPE[^>]*>/, "").replace(/&nbsp;/g, " ")
.replace(/^[\r\n\s]*/, "").replace(/<\s*\/?\s*(?:\w+:\s*)?[\w-]*[\s>\/]/g,
function(m){ return m.toLowerCase(); });
if (!this.supportNamespaces)
str = str.replace(/xmlns\=\"[^"]*\"/g, "");
var xmlNode = jpf.getXmlDom(str, null, jpf.debug);
var nodes = xmlNode.selectNodes("//@*[not(contains(local-name(), '.')) and not(translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = local-name())]");
for (var i=0; i<nodes.length; i++) {
(nodes[i].ownerElement || nodes[i].selectSingleNode(".."))
.setAttribute(nodes[i].nodeName.toLowerCase(), nodes[i].nodeValue);
}
return xmlNode;
},
parseStrategy : 0,
loadIncludes : function(docElement){
var isEmptyDocument = false;
if (this.parseStrategy == 21 || !this.parseStrategy && !docElement) {
return jpf.oHttp.get((document.body.getAttribute("xmlurl") || location.href).split(/#/)[0],
function(xmlString, state, extra){
if (state != jpf.SUCCESS) {
var oError;
if (extra.tpModule.retryTimeout(extra, state, null, oError) === true)
return true;
throw oError;
}
var xmlNode = jpf.getJmlDocFromString(xmlString);
if (jpf.isIE)
document.body.innerHTML ="";
else {
var nodes = document.body.childNodes;
for (var i=nodes.length-1; i>=0; i--)
nodes[i].parentNode.removeChild(nodes[i]);
}
return jpf.loadIncludes(xmlNode);
}, {ignoreOffline: true});
}
var prefix = jpf.findPrefix(docElement, jpf.ns.jml);
if (prefix)
prefix += ":";
if (jpf.isSafariOld || true)
prefix = "j";
jpf.AppData = jpf.supportNamespaces
? docElement.createElementNS(jpf.ns.jml, prefix + ":application")
: docElement.createElement(prefix + ":application");
var i, nodes;
var head = $xmlns(docElement, "head", jpf.ns.xhtml)[0];
if (head) {
nodes = head.childNodes;
for (i = nodes.length-1; i >= 0; i--)
if (nodes[i].namespaceURI && nodes[i].namespaceURI != jpf.ns.xhtml)
jpf.AppData.insertBefore(nodes[i], jpf.AppData.firstChild);
}
var body = (docElement.body
? docElement.body
: $xmlns(docElement, "body", jpf.ns.xhtml)[0]);
for (i = 0; i < body.attributes.length; i++)
jpf.AppData.setAttribute(body.attributes[i].nodeName,
body.attributes[i].nodeValue);
nodes = body.childNodes;
for (i = nodes.length - 1; i >= 0; i--)
jpf.AppData.insertBefore(nodes[i], jpf.AppData.firstChild);
docElement.documentElement.appendChild(jpf.AppData); 
jpf.loadJmlIncludes(jpf.AppData);
if ($xmlns(jpf.AppData, "loader", jpf.ns.jml).length) {
jpf.loadScreen = {
show : function(){
this.oExt.style.display = "block";
},
hide : function(){
this.oExt.style.display = "none";
}
}
if (jpf.isGecko || jpf.isSafari)
document.body.innerHTML = "";
if (jpf.isSafariOld) {
var q = jpf.getFirstElement(
$xmlns(jpf.AppData, "loader", jpf.ns.jml)[0]).serialize();
document.body.insertAdjacentHTML("beforeend", q);
jpf.loadScreen.oExt = document.body.lastChild;
}
else
{
var htmlNode = jpf.getFirstElement(
$xmlns(jpf.AppData, "loader", jpf.ns.jml)[0]);
if (htmlNode.ownerDocument == document)
jpf.loadScreen.oExt = document.body.appendChild(
htmlNode.cloneNode(true));
else {
document.body.insertAdjacentHTML("beforeend", htmlNode.xml
|| htmlNode.serialize());
jpf.loadScreen.oExt = document.body.lastChild;
}
}
}
document.body.style.display = "block"; 
if (!self.ERROR_HAS_OCCURRED) {
jpf.Init.interval = setInterval(function(){
if (jpf.checkLoaded())
jpf.initialize()
}, 20);
}
},
checkForJmlNamespace : function(xmlNode){
if (!xmlNode.ownerDocument.documentElement)
return false;
var nodes = xmlNode.ownerDocument.documentElement.attributes;
for (var found = false, i=0; i<nodes.length; i++) {
if (nodes[i].nodeValue == jpf.ns.jml) {
found = true;
break;
}
}
return found;
},
loadJmlIncludes : function(xmlNode, doSync){
var i, nodes, path;
var basePath = jpf.getDirname(xmlNode.getAttribute("filename")) || jpf.hostPath;
nodes = $xmlns(xmlNode, "include", jpf.ns.jml);
if (nodes.length) {
xmlNode.setAttribute("loading", "loading");
for (i = nodes.length - 1; i >= 0; i--) {
path = jpf.getAbsolutePath(basePath, nodes[i].getAttribute("src"));
jpf.loadJmlInclude(nodes[i], doSync, path);
}
}
else
xmlNode.setAttribute("loading", "done");
nodes = $xmlns(xmlNode, "skin", jpf.ns.jml);
for (i = 0; i < nodes.length; i++) {
if (!nodes[i].getAttribute("src") && !nodes[i].getAttribute("name")
|| nodes[i].childNodes.length)
continue;
path = nodes[i].getAttribute("src")
? jpf.getAbsolutePath(basePath, nodes[i].getAttribute("src"))
: jpf.getAbsolutePath(basePath, nodes[i].getAttribute("name")) + "/index.xml";
jpf.loadJmlInclude(nodes[i], doSync, path, true);
nodes[i].setAttribute("j_preparsed", "9999")
}
if (!nodes.length && !jpf.skins.skins["default"] && jpf.autoLoadSkin) {
jpf.console.warn("No skin file found, attempting to autoload the \
default skin file: skins.xml");
jpf.loadJmlInclude(null, doSync, "skins.xml", true);
}
return true;
},
loadJmlInclude : function(node, doSync, path, isSkin){
this.oHttp.get(path || jpf.getAbsolutePath(jpf.hostPath, node.getAttribute("src")),
function(xmlString, state, extra){
if (state != jpf.SUCCESS) {
var oError;
if (extra.tpModule.retryTimeout(extra, state, null, oError) === true)
return true;
if (!node) {
jpf.console.warn("Could not autload skin.");
jpf.includeStack[extra.userdata[1]] = true;
return;
}
throw oError;
}
var xmlNode, isTeleport;
if (!isSkin) {
xmlNode = jpf.getJmlDocFromString(xmlString).documentElement;
var tagName = xmlNode[jpf.TAGNAME];
if (tagName == "skin")
isSkin = true;
else if (tagName == "teleport")
isTeleport = true;
else if(tagName != "application") {
throw new Error(jpf.formatErrorString(0, null,
"Loading Includes",
"Could not find handler to parse include file for '"
+ xmlNode[jpf.TAGNAME]
+ "' expected 'skin' or 'application'", node));
}
}
if (isSkin) {
if (xmlString.indexOf('xmlns="http://www.w3.org/1999/xhtml"') > -1){
xmlString = xmlString.replace('xmlns="http://www.w3.org/1999/xhtml"', '');
}
xmlNode = jpf.getJmlDocFromString(xmlString).documentElement;
jpf.skins.Init(xmlNode, node, path);
jpf.includeStack[extra.userdata[1]] = true;
if (jpf.isOpera && extra.userdata[0] && extra.userdata[0].parentNode) 
extra.userdata[0].parentNode.removeChild(extra.userdata[0]);
}
else if (isTeleport) {
jpf.teleport.loadJml(xmlNode);
jpf.includeStack[extra.userdata[1]] = true;
}
else {
jpf.includeStack[extra.userdata[1]] = xmlNode;
extra.userdata[0].setAttribute("iid", extra.userdata[1]);
}
xmlNode.setAttribute("filename", extra.url);
jpf.loadJmlIncludes(xmlNode); 
}, {
async         : !doSync,
userdata      : [node, jpf.includeStack.push(false) - 1],
ignoreOffline : true
});
},
checkLoaded : function(){
for (var i = 0; i < jpf.includeStack.length; i++) {
if (!jpf.includeStack[i]) {
jpf.console.info("Waiting for: [" + i + "] " + jpf.includeStack[i]);
return false;
}
}
if (!document.body) return false;
jpf.console.info("Dependencies loaded");
return true;
},
initialize : function(){
jpf.console.info("Initializing...");
clearInterval(jpf.Init.interval);
jpf.Init.run(); 
{
if (jpf.JmlParser && jpf.AppData)
jpf.JmlParser.parse(jpf.AppData);
if (jpf.loadScreen && jpf.appsettings.autoHideLoading)
jpf.loadScreen.hide();
}
},
addDomLoadEvent: function(func) {
if (!this.$bdetect)
this.browserDetect();
var load_events = [],
load_timer,
done   = arguments.callee.done,
exec,
init   = function () {
if (done) return;
clearInterval(load_timer);
load_timer = null;
done       = true;
var len = load_events.length;
while (len--) {
(load_events.shift())();
}
};
if (func && !load_events[0]) {
if (document.addEventListener && !jpf.isOpera) {
window.addEventListener("DOMContentLoaded", init, false);
}
else if (jpf.isIE && window == top) {
load_timer = setInterval(function() {
try {
document.documentElement.doScroll("left");
}
catch(error) {
setTimeout(arguments.callee, 0);
return;
}
init();
}, 10);
}
else if (jpf.isOpera) {
document.addEventListener( "DOMContentLoaded", function () {
load_timer  = setInterval(function() {
for (var i = 0; i < document.styleSheets.length; i++) {
if (document.styleSheets[i].disabled)
return;
}
init();
}, 10);
}, false);
}
else if (jpf.isSafari) {
var aSheets = documents.getElementsByTagName("link");
for (var i = aSheets.length; i >= 0; i++) {
if (!aSheets[i] || aSheets[i].getAttribute("rel") != "stylesheet")
aSheets.splice(i, 0);
}
var iSheets = aSheets.length;
load_timer  = setInterval(function() {
if (/loaded|complete/.test(document.readyState)
&& document.styleSheets.length == iSheets)
init(); 
}, 10);
}
else {
var old_onload = window.onload;
window.onload  = function () {
init();
if (old_onload)
old_onload();
};
}
}
load_events.push(func);
},
destroy : function(exclude){
this.isDestroying = true;
this.popup.destroy();
for (i = 0; i < this.all.length; i++) {
if (this.all[i] && this.all[i] != exclude && this.all[i].destroy)
this.all[i].destroy(false);
}
for (i = this.$jmlDestroyers.length - 1; i >= 0; i--)
this.$jmlDestroyers[i].call(this);
this.$jmlDestroyers = undefined;
jpf.teleport.destroy();
if (jpf.xmldb)
jpf.xmldb.unbind(jpf.window);
this.isDestroying = false;
}
};
var $xmlns = function(xmlNode, tag, xmlns, prefix){
if (!jpf.supportNamespaces) {
if (!prefix)
prefix = jpf.findPrefix(xmlNode, xmlns);
if (xmlNode.style || xmlNode == document)
return xmlNode.getElementsByTagName(tag)
else {
if (prefix)
(xmlNode.nodeType == 9 ? xmlNode : xmlNode.ownerDocument)
.setProperty("SelectionNamespaces",
"xmlns:" + prefix + "='" + xmlns + "'");
return xmlNode.selectNodes(".//" + (prefix ? prefix + ":" : "") + tag);
}
}
else
return xmlNode.getElementsByTagNameNS(xmlns, tag);
}
jpf.Init.run('jpf');
jpf.XmlDatabase = function(){
this.xmlDocTag    = "j_doc";
this.xmlIdTag     = "j_id";
this.xmlListenTag = "j_listen";
this.htmlIdTag    = "id";
var xmlDocLut     = [];
this.getElementById = function(id, doc){
if (!doc)
doc = xmlDocLut[id.split("\|")[0]];
if (!doc)
return false;
return doc.selectSingleNode("descendant-or-self::node()[@"
+ this.xmlIdTag + "='" + id + "']");
};
this.getNode = function(htmlNode){
if (!htmlNode || !htmlNode.getAttribute(this.htmlIdTag))
return false;
return this.getElementById(htmlNode.getAttribute(this.htmlIdTag)
.split("\|", 2).join("|"));
};
this.getNodeById = function(id, doc){
var q = id.split("\|");
q.pop();
return this.getElementById(q.join("|"), doc);
};
this.getDocumentById = function(id){
return xmlDocLut[id];
};
this.getDocument = function(node){
return xmlDocLut[node.getAttribute(this.xmlIdTag).split("\|")[0]];
};
this.getID = function(xmlNode, o){
return xmlNode.getAttribute(this.xmlIdTag) + "|" + o.uniqueId;
};
this.getChildNumber = function(node){
var p = node.parentNode;
for (var i = 0; i < p.childNodes.length; i++)
if (p.childNodes[i] == node)
return i;
};
this.isChildOf = function(pNode, childnode, orItself){
if (!pNode || !childnode)
return false;
if (childnode.nodeType == 2)
childnode = childnode.selectSingleNode("..");
if (orItself && pNode == childnode)
return true;
var loopnode = childnode.parentNode;
while(loopnode){
if(loopnode == pNode)
return true;
loopnode = loopnode.parentNode;
}
return false;
};
this.isOnlyChild = function(node, nodeType){
if (!node || !node.parentNode || nodeType && nodeType.indexOf(node.nodeType) == -1)
return false;
var i, l, cnode, nodes = node.parentNode.childNodes;
for (i = 0, l = nodes.length; i < l; i++) {
cnode = nodes[i];
if (cnode.nodeType == 1 && cnode != node)
return false;
if (cnode.nodeType == 3 && !cnode.nodeValue.trim())
return false;
}
return true;
};
this.findHTMLNode = function(xmlNode, oComp){
do {
if (xmlNode.nodeType == 1 && xmlNode.getAttribute(this.xmlIdTag)) {
return oComp.getNodeFromCache(xmlNode.getAttribute(this.xmlIdTag)
+ "|" + oComp.uniqueId);
}
if (xmlNode == oComp.xmlRoot)
return null;
xmlNode = xmlNode.parentNode;
}
while (xmlNode && xmlNode.nodeType != 9)
return null;
};
this.findXMLNode = function(htmlNode){
if (!htmlNode)
return false;
while (htmlNode && htmlNode.nodeType == 1
&& htmlNode.tagName.toLowerCase() != "body"
&& !htmlNode.getAttribute("id")
|| htmlNode && htmlNode.nodeType == 1
&& htmlNode.getAttribute(this.htmlIdTag)
&& htmlNode.getAttribute(this.htmlIdTag).match(/^q/)) {
if (htmlNode.host && htmlNode.host.oExt == htmlNode)
return htmlNode.host.xmlRoot;
htmlNode = htmlNode.parentNode;
}
if (!htmlNode || htmlNode.nodeType != 1)
return false;
if (htmlNode.tagName.toLowerCase() == "body")
return false;
return this.getNode(htmlNode);
};
this.getElement = function(parent, nr){
var nodes = parent.childNodes;
for (var j = 0, i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1)
continue;
if (j++ == nr)
return nodes[i];
}
};
this.getModel = function(name){
return jpf.nameserver.get("model", name);
};
this.setModel = function(model){
jpf.nameserver.register("model", model.data.ownerDocument
.documentElement.getAttribute(this.xmlDocTag), model);
};
this.findModel = function(xmlNode){
return this.getModel(xmlNode.ownerDocument
.documentElement.getAttribute(this.xmlDocTag));
};
this.getXml = function(strXml, noError, preserveWhiteSpace){
return jpf.getXmlDom(strXml, noError, preserveWhiteSpace).documentElement;
};
this.getXmlId = function(xmlNode){
return xmlNode.getAttribute(this.xmlIdTag) ||
this.nodeConnect(jpf.xmldb.getXmlDocId(xmlNode), xmlNode);
}
this.nodeCount = {};
this.nodeConnect = function(documentId, xmlNode, htmlNode, o){
if (!this.nodeCount[documentId])
this.nodeCount[documentId] = 0;
var xmlId;
xmlId = xmlNode.getAttribute(this.xmlIdTag)
|| xmlNode.setAttribute(this.xmlIdTag, (xmlId = documentId
+ "|" + ++this.nodeCount[documentId])) || xmlId;
if (!o)
return xmlId;
var htmlId = xmlId + "|" + o.uniqueId;
if (htmlNode)
htmlNode.setAttribute(this.htmlIdTag, htmlId);
return htmlId;
};
this.addNodeListener = function(xmlNode, o){
var listen = xmlNode.getAttribute(this.xmlListenTag);
var nodes  = (listen ? listen.split(";") : []);
var id = String(o.uniqueId);
if (!nodes.contains(id)) {
nodes.push(id);
xmlNode.setAttribute(this.xmlListenTag, nodes.join(";"));
}
return xmlNode;
};
this.removeNodeListener = function(xmlNode, o){
var listen = xmlNode.getAttribute(this.xmlListenTag);
var nodes = (listen ? listen.split(";") : []);
for (var newnodes = [], i = 0; i < nodes.length; i++) {
if (nodes[i] != o.uniqueId)
newnodes.push(nodes[i]);
}
xmlNode.setAttribute(this.xmlListenTag, newnodes.join(";"));
return xmlNode;
};
this.integrate = function(XMLRoot, parentNode, options){
if (typeof parentNode != "object")
parentNode = getElementById(parentNode);
if (options && options.clearContents) {
var nodes = parentNode.childNodes;
for (var i = nodes.length - 1; i >= 0; i--)
parentNode.removeChild(nodes[i]);
}
{
beforeNode = jpf.getNode(parentNode, [0]);
nodes      = XMLRoot.childNodes;
if (parentNode.ownerDocument.importNode) {
doc = parentNode.ownerDocument;
for (i = 0, l = nodes.length; i < l; i++)
parentNode.insertBefore(doc.importNode(nodes[i], true), beforeNode);
}
else
for (i = nodes.length - 1; i >= 0; i--)
parentNode.insertBefore(nodes[0], beforeNode);
}
if (options && options.copyAttributes) {
var attr = XMLRoot.attributes;
for (i = 0; i < attr.length; i++)
if (attr[i].nodeName != this.xmlIdTag)
parentNode.setAttribute(attr[i].nodeName, attr[i].nodeValue);
}
return parentNode;
};
this.synchronize = function(){
this.forkRoot.parentNode.replaceChild(this.root, this.forkRoot);
this.parent.applyChanges("synchronize", this.root);
};
this.copyNode = function(xmlNode){
return this.clearConnections(xmlNode.cloneNode(true));
};
this.setNodeValue = function(xmlNode, nodeValue, applyChanges, options){
var undoObj, xpath, newNodes;
if (options) {
undoObj  = options.undoObj;
xpath    = options.xpath;
newNodes = options.newNodes;
undoObj.extra.oldValue = options.forceNew
? ""
: jpf.getXmlValue(xmlNode, xpath);
undoObj.xmlNode        = xmlNode;
if (xpath)
xmlNode = jpf.xmldb.createNodeFromXpath(xmlNode, xpath, newNodes, options.forceNew);
undoObj.extra.appliedNode = xmlNode;
}
if (xmlNode.nodeType == 1) {
if (!xmlNode.firstChild)
xmlNode.appendChild(xmlNode.ownerDocument.createTextNode("-"));
xmlNode.firstChild.nodeValue = jpf.isNot(nodeValue) ? "" : nodeValue;
if (applyChanges)
jpf.xmldb.applyChanges("synchronize", xmlNode, undoObj);
}
else {
xmlNode.nodeValue = jpf.isNot(nodeValue) ? "" : nodeValue;
if (applyChanges)
jpf.xmldb.applyChanges("synchronize", xmlNode.parentNode
|| xmlNode.ownerElement || xmlNode.selectSingleNode(".."),
undoObj);
}
};
this.getNodeValue = function(xmlNode){
if (!xmlNode)
return "";
return xmlNode.nodeType == 1
? (!xmlNode.firstChild ? "" : xmlNode.firstChild.nodeValue)
: xmlNode.nodeValue;
};
this.getInheritedAttribute = function(xml, attr, func){
var result;
while (xml && xml.nodeType != 11 && xml.nodeType != 9
&& !(result = attr && xml.getAttribute(attr) || func && func(xml))) {
xml = xml.parentNode;
}
return !result && attr && jpf.appsettings
? jpf.appsettings.tags[attr]
: result;
};
this.setTextNode = function(pNode, value, xpath, undoObj){
var tNode;
if (xpath) {
tNode = pNode.selectSingleNode(xpath);
if (!tNode)
return;
pNode = tNode.nodeType == 1 ? tNode : null;
}
if (pNode || !tNode) {
tNode = pNode.selectSingleNode("text()");
if (!tNode)
tNode = pNode.appendChild(pNode.ownerDocument.createTextNode(""));
}
if (undoObj)
undoObj.extra.oldValue = tNode.nodeValue;
tNode.nodeValue = value;
this.applyChanges("text", tNode.parentNode, undoObj);
};
this.setAttribute = function(xmlNode, name, value, xpath, undoObj){
(xpath ? xmlNode.selectSingleNode(xpath) : xmlNode).setAttribute(name, value);
this.applyChanges("attribute", xmlNode, undoObj);
};
this.removeAttribute = function(xmlNode, name, xpath, undoObj){
if (undoObj) undoObj.name = name;
(xpath ? xmlNode.selectSingleNode(xpath) : xmlNode).removeAttribute(name);
this.applyChanges("attribute", xmlNode, undoObj);
};
this.replaceNode = function(oldNode, newNode, xpath, undoObj){
if (xpath)
oldNode = oldNode.selectSingleNode(xpath);
if (undoObj)
undoObj.oldNode = oldNode;
oldNode.parentNode.replaceChild(newNode, oldNode);
this.copyConnections(oldNode, newNode);
this.applyChanges("replacechild", newNode, undoObj);
};
this.addChildNode = function(pNode, tagName, attr, beforeNode, undoObj){
var xmlNode = pNode.insertBefore(pNode.ownerDocument
.createElement(tagName), beforeNode);
for (var i = 0; i < attr.length; i++)
xmlNode.setAttribute(attr[i][0], attr[i][1]);
if (undoObj)
undoObj.extra.addedNode = xmlNode;
this.applyChanges("add", xmlNode, undoObj);
return xmlNode;
};
this.appendChild = function(pNode, xmlNode, beforeNode, unique, xpath, undoObj){
if (unique && pNode.selectSingleNode(xmlNode.tagName))
return false;
if (undoObj)
this.clearConnections(xmlNode);
if (jpf.isSafari && pNode.ownerDocument != xmlNode.ownerDocument)
xmlNode = pNode.ownerDocument.importNode(xmlNode, true); 
if (xpath) {
var addedNodes = [];
var pNode = this.createNodeFromXpath(pNode, xpath, addedNodes);
if (addedNodes.length) {
pNode.appendChild(xmlNode);
while(addedNodes.length) {
if (pNode == addedNodes.pop() && addedNodes.length)
pNode = pNode.parentNode;
}
}
}
pNode.insertBefore(xmlNode, beforeNode);
this.applyChanges("add", xmlNode, undoObj);
return xmlNode;
};
this.moveNode = function(pNode, xmlNode, beforeNode, xpath, undoObj){
if (!undoObj)
undoObj = {extra:{}};
undoObj.extra.pNode      = xmlNode.parentNode;
undoObj.extra.beforeNode = xmlNode.nextSibling;
undoObj.extra.toPnode    = (xpath ? pNode.selectSingleNode(xpath) : pNode);
this.applyChanges("move-away", xmlNode, undoObj);
if (!jpf.isSafari
&& jpf.xmldb.getXmlDocId(xmlNode) != jpf.xmldb.getXmlDocId(pNode)) {
xmlNode.removeAttributeNode(xmlNode.getAttributeNode(this.xmlIdTag));
this.nodeConnect(jpf.xmldb.getXmlDocId(pNode), xmlNode);
}
if (jpf.isSafari && pNode.ownerDocument != xmlNode.ownerDocument)
xmlNode = pNode.ownerDocument.importNode(xmlNode, true); 
undoObj.extra.toPnode.insertBefore(xmlNode, beforeNode);
this.applyChanges("move", xmlNode, undoObj);
};
this.removeNode = function(xmlNode, xpath, undoObj){
if (xpath)
xmlNode = xmlNode.selectSingleNode(xpath);
if (undoObj) {
undoObj.extra.pNode       = xmlNode.parentNode;
undoObj.extra.removedNode = xmlNode;
undoObj.extra.beforeNode  = xmlNode.nextSibling;
}
this.applyChanges("remove", xmlNode, undoObj);
var p = xmlNode.parentNode;
p.removeChild(xmlNode);
this.applyChanges("redo-remove", xmlNode, null, p);
};
this.removeNodeList = function(xmlNodeList, undoObj){
for (var rData = [], i = 0; i < xmlNodeList.length; i++) { 
if (undoObj) {
rData.push({
pNode      : xmlNodeList[i].parentNode,
removedNode: xmlNodeList[i],
beforeNode : xmlNodeList[i].nextSibling
});
}
this.applyChanges("remove", xmlNodeList[i], undoObj);
var p = xmlNodeList[i].parentNode;
p.removeChild(xmlNodeList[i]);
this.applyChanges("redo-remove", xmlNodeList[i], null, p);
}
if (undoObj)
undoObj.extra.removeList = rData;
};
var notifyQueue = {}, notifyTimer;
this.applyChanges = function(action, xmlNode, undoObj, nextloop){
var oParent  = nextloop;
var loopNode = (xmlNode.nodeType == 1 ? xmlNode : xmlNode.parentNode);
var xmlId = xmlNode.getAttribute(this.xmlIdTag);
if (!this.delayUpdate && "|remove|move-away|".indexOf("|" + action + "|") > -1)
this.notifyQueued(); 
var listen, uIds, i, j, hash, info, jmlNode, runTimer, found;
while (loopNode && loopNode.nodeType != 9) {
listen = loopNode.getAttribute(this.xmlListenTag);
if (listen) {
uIds = listen.split(";");
for (i = 0; i < uIds.length; i++) {
hash = notifyQueue[uIds[i]];
if (!hash)
notifyQueue[uIds[i]] = hash = [];
if ("|update|attribute|text|".indexOf("|"
+ action + "|") > -1) {
found = false;
for (j = 0; j < hash.length; j++) {
if (hash[j] && xmlNode == hash[j][1]
&& "|update|attribute|text|"
.indexOf("|" + hash[j][0] + "|") > -1) {
hash[j] = null;
found = true;
continue;
}
}
hash.push(["update", xmlNode, loopNode, undoObj, oParent]);
runTimer = true;
continue;
}
if (!this.delayUpdate && "|remove|move-away|add|".indexOf("|" + action + "|") > -1) {
jmlNode = jpf.lookup(uIds[i]);
if (jmlNode)
jmlNode.$xmlUpdate(action, xmlNode,
loopNode, undoObj, oParent);
}
else {
hash.push([action, xmlNode, loopNode, undoObj, oParent]);
runTimer = true;
}
}
}
loopNode = loopNode.parentNode || nextloop;
if (loopNode == nextloop)
nextloop = null;
}
if (undoObj && !this.delayUpdate) {
if (!undoObj.xmlNode) 
undoObj.xmlNode = xmlNode;
jpf.xmldb.notifyQueued();
}
else if (runTimer) {
clearTimeout(notifyTimer);
notifyTimer = setTimeout(function(){
jpf.xmldb.notifyQueued();
});
}
};
this.notifyQueued = function(){
clearTimeout(notifyTimer);
for (var uId in notifyQueue) {
var q = notifyQueue[uId];
jmlNode = jpf.lookup(uId);
if (!jmlNode || !q)
continue;
if (jmlNode.$listenRoot) {
var model = jmlNode.getModel();
var xpath   = model.getXpathByJmlNode(jmlNode);
var xmlRoot = xpath
? model.data.selectSingleNode(xpath)
: model.data;
if (xmlRoot) {
jpf.xmldb.removeNodeListener(jmlNode.$listenRoot, jmlNode);
jmlNode.$listenRoot = null;
jmlNode.load(xmlRoot);
}
continue;
}
for (var i = 0; i < q.length; i++) {
if (!q[i])
continue;
jmlNode.$xmlUpdate.apply(jmlNode, q[i]);
}
}
notifyQueue = {}; 
}
this.notifyListeners = function(xmlNode){
var listen = xmlNode.getAttribute(jpf.xmldb.xmlListenTag);
if (listen) {
listen = listen.split(";");
for (var j = 0; j < listen.length; j++) {
jpf.lookup(listen[j]).$xmlUpdate("synchronize", xmlNode, xmlNode);
}
}
};
this.copyConnections = function(fromNode, toNode){
try {
toNode.setAttribute(this.xmlListenTag, fromNode.getAttribute(this.xmlListenTag));
toNode.setAttribute(this.xmlIdTag, fromNode.getAttribute(this.xmlIdTag));
}
catch (e) {}
};
this.clearConnections = function(xmlNode){
try {
var i, nodes = xmlNode.selectNodes("descendant-or-self::node()[@" + this.xmlListenTag + "]");
for (i = nodes.length - 1; i >= 0; i--)
nodes[i].removeAttributeNode(nodes[i].getAttributeNode(this.xmlListenTag));
nodes = xmlNode.selectNodes("descendant-or-self::node()[@" + this.xmlIdTag + "]");
for (i = nodes.length - 1; i >= 0; i--)
nodes[i].removeAttributeNode(nodes[i].getAttributeNode(this.xmlIdTag));
nodes = xmlNode.selectNodes("descendant-or-self::node()[@" + this.xmlDocTag + "]");
for (i = nodes.length - 1; i >= 0; i--)
nodes[i].removeAttributeNode(nodes[i].getAttributeNode(this.xmlDocTag));
nodes = xmlNode.selectNodes("descendant-or-self::node()[@j_loaded]");
for (i = nodes.length - 1; i >= 0; i--)
nodes[i].removeAttributeNode(nodes[i].getAttributeNode("j_loaded"));
}
catch (e) {}
return xmlNode;
};
this.serializeNode = function(xmlNode){
var xml = this.clearConnections(xmlNode.cloneNode(true));
return xml.xml || xml.serialize();
};
this.unbind = function(frm){
for (var lookup = {}, i = 0; i < frm.jpf.all.length; i++)
if (frm.jpf.all[i] && frm.jpf.all[i].unloadBindings)
lookup[frm.jpf.all[i].unloadBindings()] = true;
for (var k = 0; k < xmlDocLut.length; k++) {
if (!xmlDocLut[k]) continue;
var Nodes = xmlDocLut[k].selectNodes("//self::node()[@"
+ this.xmlListenTag + "]");
for (var i = 0; i < Nodes.length; i++) {
var listen = Nodes[i].getAttribute(this.xmlListenTag).split(";");
for (var nListen = [], j = 0; j < listen.length; j++)
if (!lookup[listen[j]])
nListen.push(listen[j]);
if (nListen.length != listen.length)
Nodes[i].setAttribute(this.xmlListenTag, nListen.join(";"));
}
}
};
this.selectNodes = function(sExpr, contextNode){
if (contextNode && (jpf.hasXPathHtmlSupport && contextNode.selectSingleNode || !contextNode.style))
return contextNode.selectNodes(sExpr); 
return jpf.XPath.selectNodes(sExpr, contextNode)
};
this.selectSingleNode = function(sExpr, contextNode){
if (contextNode && (jpf.hasXPathHtmlSupport && contextNode.selectSingleNode || !contextNode.style))
return contextNode.selectSingleNode(sExpr); 
var nodeList = this.selectNodes(sExpr + (jpf.isIE ? "" : "[1]"),
contextNode ? contextNode : null);
return nodeList.length > 0 ? nodeList[0] : null;
};
this.createNodeFromXpath = function(contextNode, xPath, addedNodes, forceNew){
var xmlNode, foundpath = "", paths = xPath.split("\|")[0].split("/");
if (!forceNew && (xmlNode = contextNode.selectSingleNode(xPath)))
return xmlNode;
var len = paths.length -1;
if (forceNew) {
if (paths[len].trim().match(/^\@(.*)$|^text\(\)$/))
len--;
}
for (var addedNode, isAdding = false, i = 0; i < len; i++) {
if (!isAdding && contextNode.selectSingleNode(foundpath
+ (i != 0 ? "/" : "") + paths[i])) {
foundpath += (i != 0 ? "/" : "") + paths[i];
continue;
}
var isAddId = paths[i].match(/(\w+)\[@([\w-]+)=(\w+)\]/);
if (isAddId)
paths[i] = isAddId[1];
isAdding = true;
addedNode = contextNode.selectSingleNode(foundpath || ".")
.appendChild(contextNode.ownerDocument.createElement(paths[i]));
if (isAddId) {
addedNode.setAttribute(isAddId[2], isAddId[3]);
foundpath += (foundpath ? "/" : "") + isAddId[0];
}
else
foundpath += (foundpath ? "/" : "") + paths[i];
if (addedNodes)
addedNodes.push(addedNode);
}
if (!foundpath)
foundpath = ".";
var newNode, lastpath = paths[len];
do {
if (lastpath.match(/^\@(.*)$/)) {
(newNode || contextNode.selectSingleNode(foundpath))
.setAttributeNode(newNode = contextNode.ownerDocument.createAttribute(RegExp.$1));
}
else if (lastpath.trim() == "text()") {
newNode = (newNode || contextNode.selectSingleNode(foundpath))
.appendChild(contextNode.ownerDocument.createTextNode(""));
}
else {
var hasId = lastpath.match(/(\w+)\[@([\w-]+)=(\w+)\]/);
if (hasId) lastpath = hasId[1];
newNode = (newNode || contextNode.selectSingleNode(foundpath))
.appendChild(contextNode.ownerDocument.createElement(lastpath));
if (hasId)
newNode.setAttribute(hasId[2], hasId[3]);
if (addedNodes)
addedNodes.push(newNode);
}
foundpath += (foundpath ? "/" : "") + paths[len];
} while((lastpath = paths[++len]));
return newNode;
};
this.getXmlDocId = function(xmlNode, model){
var docEl = xmlNode.ownerDocument.documentElement;
if (!this.isChildOf(docEl, xmlNode))
docEl = xmlNode;
var docId = (docEl || xmlNode).getAttribute(this.xmlDocTag)
|| xmlDocLut.indexOf(docEl || xmlNode.ownerDocument || xmlNode);
if (docId && docId > -1)
return docId;
docId = xmlDocLut.push(docEl || xmlNode.ownerDocument || xmlNode) - 1;
if (docEl)
docEl.setAttribute(this.xmlDocTag, docId);
if (model)
jpf.nameserver.register("model", docId, model);
return xmlDocLut.length - 1;
};
this.getBindXmlNode = function(xmlRootNode){
if (typeof xmlRootNode != "object")
xmlRootNode = jpf.getXmlDom(xmlRootNode);
if (xmlRootNode.nodeType == 9)
xmlRootNode = xmlRootNode.documentElement;
if (xmlRootNode.nodeType == 3 || xmlRootNode.nodeType == 4)
xmlRootNode = xmlRootNode.parentNode;
if (xmlRootNode.nodeType == 2)
xmlRootNode = xmlRootNode.selectSingleNode("..");
return xmlRootNode;
};
this.convertMethods = {
"json": function(xml){
var result = {}, filled = false, nodes = xml.childNodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1)
continue;
var name = nodes[i].tagName;
filled = true;
var sameNodes = xml.selectNodes(x);
if (sameNodes.length > 1) {
var z = [];
for (var j = 0; j < sameNodes.length; j++) {
z.push(this.json(sameNodes[j], result));
}
result[name] = z;
}
else 
result[name] = this.json(sameNodes[j], result);
}
return filled ? result : jpf.getXmlValue(xml, "text()");
},
"cgivars": function(xml, basename){
if (!basename) 
basename = "";
var str = [], value, nodes = xml.childNodes, done = {};
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1)
continue;
var name = nodes[i].tagName;
if (done[name])
continue;
var sameNodes = xml.selectNodes(name);
if (sameNodes.length > 1) {
done[name] = true;
for (var j = 0; j < sameNodes.length; j++) {
value = this.cgivars(sameNodes[j],
basename + name + "[" + j + "]");
if (value)
str.push(value);
}
}
else { 
value = this.cgivars(nodes[i], basename + name);
if (value)
str.push(value);
}
}
var attr = xml.attributes;
for (i = 0; i < attr.length; i++) {
if (attr[i].nodeValue) {
if (basename) 
str.push(basename + "[" + attr[i].nodeName + "]="
+ encodeURIComponent(attr[i].nodeValue));
else
str.push(attr[i].nodeName + "="
+ encodeURIComponent(attr[i].nodeValue));
}
}
if (str.length)
return str.join("&");
value = jpf.getXmlValue(xml, "text()");
if (basename && value)
return basename + "=" + encodeURIComponent(value);
},
"cgiobjects": function(xml, basename, isSub){
if (!basename)
basename = "";
var str = [], value, nodes = xml.childNodes, done = {};
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.nodeType != 1)
continue;
var name        = node.tagName;
if (name == "revision")
continue;
var isOnlyChild = jpf.xmldb.isOnlyChild(node.firstChild, [3,4]);
var count       = 0;
if (!node.attributes.length && !isOnlyChild) {
var lnodes = node.childNodes;
for (var nm, j = 0, l = lnodes.length; j < l; j++) {
if (lnodes[j].nodeType != 1)
continue;
nm = basename + (isSub ? "[" : "") + name + (isSub ? "]" : "") + "[" + count++ + "]";
value = this.cgiobjects(lnodes[j], nm, true);
if (value)
str.push(value);
var a, attr = lnodes[j].attributes;
for (k = 0; k < attr.length; k++) {
if (!(a = attr[k]).nodeValue)
continue;
str.push(nm + "[" + a.nodeName + "]=" 
+ encodeURIComponent(a.nodeValue));
}
}
}
else {
if (isOnlyChild)
str.push(basename + (isSub ? "[" : "") + name + (isSub ? "]" : "") + "=" 
+ encodeURIComponent(node.firstChild.nodeValue));
var a, attr = node.attributes;
for (j = 0; j < attr.length; j++) {
if (!(a = attr[j]).nodeValue)
continue;
str.push(basename + (isSub ? "[" : "") + name + "_" + a.nodeName + (isSub ? "]" : "") + "=" 
+ encodeURIComponent(a.nodeValue));
}
}
}
if (!isSub && xml.getAttribute("id"))
str.push("id=" + encodeURIComponent(xml.getAttribute("id")));
if (str.length)
return str.join("&");
}
};
this.convertXml = function(xml, to){
return this.convertMethods[to](xml);
};
this.getTextNode = function(x){
for (var i = 0; i < x.childNodes.length; i++) {
if (x.childNodes[i].nodeType == 3 || x.childNodes[i].nodeType == 4)
return x.childNodes[i];
}
return false;
};
this.getBoundValue = function(jmlNode, xmlRoot, applyChanges){
if (!xmlRoot && !jmlNode.xmlRoot)
return "";
var xmlNode = !jmlNode.nodeFunc
? xmlRoot.selectSingleNode(jmlNode.getAttribute("ref"))
: jmlNode.getNodeFromRule("value", jmlNode.xmlRoot);
return xmlNode ? this.getNodeValue(xmlNode) : "";
};
this.getArrayFromNodelist = function(nodelist){
for (var nodes = [], j = 0; j < nodelist.length; j++)
nodes.push(nodelist[j]);
return nodes;
};
};
jpf.getXml = function(){
return jpf.xmldb.getXml.apply(jpf.xmldb, arguments);
};
jpf.Init.run('XmlDatabase');
jpf.namespace("datainstr", {
"call" : function(xmlContext, options, callback){
var parsed = options.parsed || this.parseInstructionPart(
options.instrData.join(":"), xmlContext, options.args, options);
if (options.preparse) {
options.parsed = parsed;
options.preparse = -1;
return;
}
var retvalue = self[parsed.name].apply(null, parsed.arguments);
if (callback)
callback(retvalue, jpf.SUCCESS, options);
},
"eval" : function(xmlContext, options, callback){
var parsed = options.parsed
|| this.parseInstructionPart(
"(" + options.instrData.join(":") + ")", xmlContext,
options.args, options);
if (options.preparse) {
options.parsed = parsed;
options.preparse = -1;
return;
}
try {
var retvalue = eval(parsed.arguments[0]);
}
catch(e) {
}
if (callback)
callback(retvalue, jpf.SUCCESS, options);
}
});
jpf.saveData = function(instruction, xmlContext, options, callback){
if (!instruction) return false;
if (!options) options = {};
options.instrData = instruction.split(":");
options.instrType = options.instrData.shift();
var instrType = options.instrType.indexOf("url.") == 0
? "url"
: options.instrType;
options.instruction = instruction;
this.datainstr[instrType].call(this, xmlContext, options, callback);
};
jpf.getData = function(instruction, xmlContext, options, callback){
var instrParts = instruction.match(/^(.*?)(?:\!(.*)$|$)/);
var operators  = instrParts[2] ? instrParts[2].splitSafe("\{|\}\s*,|,") : "";
var gCallback  = function(data, state, extra){
if (state != jpf.SUCCESS)
return callback(data, state, extra);
operators[2] = data;
if (operators[0] && data) {
if (typeof data == "string")
data = jpf.xmldb.getXml(data);
extra.data = data;
data = data.selectSingleNode(operators[0]);
if (!data) {
throw new Error(jpf.formatErrorString(0, null,
"Loading new data", "Could not load data by doing \
selection on it using xPath: '" + operators[0] + "'."));
}
}
extra.userdata = operators;
return callback(data, state, extra);
}
if (!options) options = {};
options.isGetRequest = true;
options.userdata     = operators;
if (this.saveData(instrParts[1], xmlContext, options, gCallback) !== false)
return;
var data      = instruction.split(":");
var instrType = data.shift();
if (instrType.substr(0, 1) == "#") {
instrType = instrType.substr(1);
var retvalue, oJmlNode = self[instrType];
if (!oJmlNode.value)
retvalue = null;
else
retvalue = data[2]
? oJmlNode.value.selectSingleNode(data[2])
: oJmlNode.value;
}
else {
var model = jpf.nameserver.get("model", instrType);
if (!model.data)
retvalue = null;
else
retvalue = data[1]
? model.data.selectSingleNode(data[1])
: model.data;
}
if (callback)
gCallback(retvalue, jpf.SUCCESS, {userdata:operators});
else {
jpf.console.warn("Returning data directly in jpf.getData(). \
This means that all callback communication ends in void!");
return retvalue;
}
};
jpf.setModel = function(instruction, jmlNode, isSelection){
if (!instruction) return;
var data      = instruction.split(":");
var instrType = data[0];
var model = isSelection
? jmlNode.$getMultiBind().getModel()
: jmlNode.getModel && jmlNode.getModel();
if(model)
model.unregister(jmlNode);
if (jpf.datainstr[instrType]) {
jmlNode.setModel(new jpf.model().loadFrom(instruction));
}
else if (instrType.substr(0,1) == "#") {
instrType = instrType.substr(1);
if (isSelection) {
var sb2 = jpf.isParsing
? jpf.JmlParser.getFromSbStack(jmlNode.uniqueId, 1)
: jmlNode.$getMultiBind().smartBinding;
if (sb2)
sb2.$model = new jpf.model().loadFrom(instruction);
}
else if (!self[instrType] || !jpf.JmlParser.inited) {
jpf.JmlParser.addToModelStack(jmlNode, data)
}
else {
var oConnect = eval(instrType);
if (oConnect.connect)
oConnect.connect(jmlNode, null, data[2], data[1] || "select");
else
jmlNode.setModel(new jpf.model().loadFrom(instruction));
}
jmlNode.connectId = instrType;
}
else {
var instrType = data.shift();
model = instrType == "@default"
? jpf.globalModel
: jpf.nameserver.get("model", instrType);
if (isSelection) {
var sb2 = jpf.isParsing
? jpf.JmlParser.getFromSbStack(jmlNode.uniqueId, 1)
: jmlNode.$getMultiBind().smartBinding;
if (sb2) {
sb2.$model = model;
sb2.$modelXpath[jmlNode.uniqueId] = data.join(":");
}
}
else
jmlNode.setModel(model, data.join(":"));
}
};
jpf.parseInstructionPart = function(instrPart, xmlNode, arg, options){
var parsed  = {}, s = instrPart.split("(");
parsed.name = s.shift();
if (!arg) {
arg = s.join("(");
function getXmlValue(xpath){
var o = xmlNode ? xmlNode.selectSingleNode(xpath) : null;
if (!o)
return null;
else if (o.nodeType >= 2 && o.nodeType <= 4)
return o.nodeValue;
else if (jpf.xmldb.isOnlyChild(o.firstChild, [3, 4]))
return o.firstChild.nodeValue;
else
return o.xml || o.serialize();
}
arg = arg.slice(0, -1);
var depth, lastpos = 0, result = ["["];
arg.replace(/\\[\{\}\'\"]|(["'])|([\{\}])/g,
function(m, chr, cb, pos){
chr && (!depth && (depth = chr)
|| depth == chr && (depth = null));
if (!depth && cb) {
if (cb == "{") {
result.push(arg.substr(lastpos, pos - lastpos));
lastpos = pos + 1;
}
else {
result.push("getXmlValue('", arg
.substr(lastpos, pos - lastpos)
.replace(/([\\'])/g, "\\$1"), "')");
lastpos = pos + 1;
}
}
});
result.push(arg.substr(lastpos), "]");
(function(){
try{
with (options) {
arg = eval(result.join(""));
}
}
catch(e) {
arg = [];
}
})();
}
parsed.arguments = arg;
return parsed;
};
jpf.Class = function(){
this.$jmlLoaders   = [];
this.$addJmlLoader = function(func){
if (!this.$jmlLoaders)
func.call(this, this.$jml);
else
this.$jmlLoaders.push(func);
};
this.$jmlDestroyers   = [];
this.$regbase         = 0;
this.hasFeature       = function(test){
return this.$regbase&test;
};
var boundObjects       = {};
var myBoundPlaces      = {};
if (!this.$handlePropSet) {
this.$handlePropSet    = function(prop, value){
this[prop] = value;
};
}
this.bindProperty = function(myProp, bObject, bProp, strDynamicProp){
if (!boundObjects[myProp])
boundObjects[myProp] = {};
if (!boundObjects[myProp][bObject.uniqueId])
boundObjects[myProp][bObject.uniqueId] = [];
if (boundObjects[myProp][bObject.uniqueId].contains(bProp)) {
return;
}
if (strDynamicProp)
boundObjects[myProp][bObject.uniqueId].push([bProp, strDynamicProp]);
else
boundObjects[myProp][bObject.uniqueId].pushUnique([bProp]); 
bObject.$handlePropSet(bProp, strDynamicProp ? eval(strDynamicProp) : this[myProp]);
};
this.unbindProperty = function(myProp, bObject, bProp){
boundObjects[myProp][bObject.uniqueId].remove(bProp);
};
this.unbindAllProperties = function(){
var prop;
for (prop in myBoundPlaces) {
if (myBoundPlaces[prop] && typeof myBoundPlaces[prop] != "function") {
for (var i = 0; i < myBoundPlaces[prop].length; i++) {
if (!self[myBoundPlaces[prop][i][0]]) continue;
self[myBoundPlaces[prop][i][0]]
.unbindProperty(myBoundPlaces[prop][i][1], this, prop);
}
}
}
};
this.getAvailableProperties = function(){
return this.$supportedProperties.slice();
};
this.setDynamicProperty = function(prop, pValue){
var pStart = pValue.substr(0,1);
if (myBoundPlaces[prop]) {
for (var i = 0; i < myBoundPlaces[prop].length; i++) {
self[myBoundPlaces[prop][i][0]].unbindProperty(myBoundPlaces[prop][i][1], this, prop);
}
}
if (pStart == "[") {
var p = pValue.substr(1,pValue.length-2).split(".");
if (!self[p[0]]) return;
if (!p[1])
p[1] = self[p[0]].$supportedProperties[0]; 
self[p[0]].bindProperty(p[1], this, prop);
myBoundPlaces[prop] = [p];
this.bindProperty(prop, self[p[0]], p[1]);
}
else if (pStart == "{") { 
var o, node, bProp, p, matches = {};
pValue = pValue.substr(1, pValue.length - 2);
pValue.replace(/["'](?:\\.|[^"']+)*["']|\\(?:\\.|[^\\]+)*\/|(?:\W|^)([a-z]\w*\.\w+(?:\.\w+)*)(?!\()(?:\W|$)/gi,
function(m, m1){
if(m1) matches[m1] = true;
});
pValue = pValue.replace(/\Wand\W/g, "&&").replace(/\Wor\W/g, "||");  
myBoundPlaces[prop] = [];
var found = false;
for (p in matches) {
if (typeof matches[p] == "function")
continue;
o = p.split(".");
if (o.length > 2) { 
bProp = o.pop();
node  = eval(o.join("."));
if (typeof node != "object" || !node.$regbase) {
bProp = o[1];
node  = self[o[0]];
}
else
o.push(bProp);
}
else {
bProp = o[1];
node  = self[o[0]];
}
if (!node || !node.bindProperty)
continue;  
node.bindProperty(bProp, this, prop, pValue);
myBoundPlaces[prop].push(o);
found = true;
}
if (!found)
this.$handlePropSet(prop, eval(pValue));
}
else
this.$handlePropSet(prop, pValue);
}
this.setProperty = function(prop, value, reqValue, forceOnMe){
if (reqValue && !value || !jpf || this.$ignoreSignals)
return;
if (String(this[prop]) !== String(value) || typeof value == "object") {
var oldvalue = this[prop];
if (this.$handlePropSet(prop, value, forceOnMe) === false) {
this[prop] = oldvalue;
return false;
}
}
if (this["onpropertychange"] || events_stack["propertychange"]) {
this.dispatchEvent("propertychange", {
name          : prop,
value         : value,
originalvalue : oldvalue
});
}
var nodes = boundObjects[prop];
if (!nodes) return;
var id, ovalue = this[prop];
for (id in nodes) {
if (jpf.isSafari && (typeof nodes[id] != "object" || !nodes[id]))
continue;
for (var o = jpf.lookup(id), i = nodes[id].length - 1; i >= 0; --i) {
try {
value = nodes[id][i][1] ? eval(nodes[id][i][1]) : ovalue;
}
catch(e) {
throw new Error(jpf.formatErrorString(0, this,
"Property-binding",
"Could not execute binding test: " + nodes[id][i][1]));
}
if (typeof o != "undefined" && o[nodes[id][i][0]] != value)
o.setProperty(nodes[id][i][0], value);
}
}
return value;
};
this.getProperty = function(prop){
return this[prop];
};
var capture_stack = {}, events_stack = {};
this.dispatchEvent = function(eventName, options, e){
var arr, result, rValue;
if (options && options.name)
e = options;
else if (!e)
e = new jpf.Event(eventName, options);
if (!e.originalElement) {
e.originalElement = this;
if (arr = capture_stack[eventName]) {
for (var i = 0; i < arr.length; i++) {
rValue = arr[i].call(this, e);
if (rValue != undefined)
result = rValue;
}
}
}
if (this.disabled)
result = false;
else {
if (this["on" + eventName])
result = this["on" + eventName].call(this, e); 
if (arr = events_stack[eventName]) {
for (var i = 0; i < arr.length; i++) {
rValue = arr[i].call(this, e);
if (rValue != undefined)
result = rValue;
}
}
}
if (e.bubbles && !e.cancelBubble && this != jpf) {
rValue = (this.parentNode || jpf).dispatchEvent(eventName, null, e);
if (rValue != undefined)
result = rValue;
}
return e.returnValue !== undefined ? e.returnValue : result;
};
this.addEventListener = function(eventName, callback, useCapture){
if (eventName.indexOf("on") == 0)
eventName = eventName.substr(2);
var stack = useCapture ? capture_stack : events_stack;
if (!stack[eventName])
stack[eventName] = [];
stack[eventName].pushUnique(callback);
}
this.removeEventListener = function(eventName, callback, useCapture){
var stack = useCapture ? capture_stack : events_stack;
if (stack[eventName])
stack[eventName].remove(callback);
};
this.hasEventListener = function(eventName){
return (events_stack[eventName] && events_stack[eventName].length > 0);
};
this.destroy = this.destroy || function(deep){
if (!this.$jmlDestroyers) 
return;
if (this.$destroy)
this.$destroy();
for (var i = this.$jmlDestroyers.length - 1; i >= 0; i--)
this.$jmlDestroyers[i].call(this);
this.$jmlDestroyers = undefined;
if (typeof this.uniqueId == "undefined")
return;
jpf.all[this.uniqueId] = undefined;
if (!this.nodeFunc) { 
if (this.name)
self[this.name] = null;
return;
}
if (this.oExt && !this.oExt.isNative && this.oExt.nodeType == 1) {
this.oExt.oncontextmenu = this.oExt.host = null;
}
if (this.oInt && !this.oExt.isNative && this.oInt.nodeType == 1)
this.oInt.host = null;
this.$jml = null;
if (this.parentNode)
this.removeNode();
if (this.$focussable && this.focussable)
jpf.window.$removeFocus(this);
this.unbindAllProperties();
if (deep && this.childNodes) {
var i, l, nodes = this.childNodes;
for (i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].destroy)
nodes[i].destroy(true);
}
this.childNodes = null;
}
if (this.name)
self[this.name] = null;
};
};
jpf.Event = function(name, data){
this.name = name;
this.bubbles = false;
this.cancelBubble = false;
this.preventDefault = function(){
this.returnValue = false;
}
this.stopPropagation = function(){
this.cancelBubble = true;
}
this.isCharacter = function(){
return (this.keyCode < 112 || this.keyCode > 122) 
&& (this.keyCode < 33  && this.keyCode > 31 || this.keyCode > 42 || this.keyCode == 8);
}
jpf.extend(this, data);
};
jpf.inherit(jpf.Class);
jpf.Init.run('class');
jpf.component = function(nodeFunc, oBase) {
var fC = function() {
this.$init.apply(this, arguments);
};
if (oBase) {
if (typeof oBase == "function")
fC.prototype.base = oBase;
else
fC.prototype = oBase;
}
fC.prototype.nodeFunc = nodeFunc || jpf.NODE_HIDDEN;
fC.prototype.inherit = jpf.inherit;
if (typeof fC.prototype['$init'] != "function") {
var aImpl = [];
fC.implement = function() {
aImpl = aImpl.concat(Array.prototype.slice.call(arguments));
return fC;
}
fC.prototype.$init = function(pHtmlNode, sName){
if (typeof sName != "string") 
throw new Error(jpf.formatErrorString(0, this, 
"Error creating component",
"Dependencies not met, please provide a component name when \
instantiating it (ex.: new jpf.tree(oParent, 'tree') )"));
this.tagName       = sName;
this.pHtmlNode     = pHtmlNode || document.body;
this.pHtmlDoc      = this.pHtmlNode.ownerDocument;
this.uniqueId      = jpf.all.push(this) - 1;
this.$propHandlers = {}; 
this.$domHandlers  = {
"remove"      : [],
"insert"      : [],
"reparent"    : [],
"removechild" : []
};
if (nodeFunc != jpf.NODE_HIDDEN) {
if (typeof this.$focussable == "undefined")
this.$focussable = jpf.KEYBOARD_MOUSE; 
this.$booleanProperties = {
"disable-keyboard" : true,
"visible"          : true,
"focussable"       : true,
"disabled"         : true
};
this.$supportedProperties = [
"draggable", "resizable",
"focussable", "zindex", "disabled", "tabindex",
"disable-keyboard", "contextmenu", "visible", "autosize", 
"loadjml", "actiontracker", "alias"];
} 
else {
this.$booleanProperties   = {}; 
this.$supportedProperties = []; 
}
this.inherit(jpf.Class);
this.inherit.apply(this, aImpl);
this.inherit(jpf.JmlElement, this.base || jpf.K);
if (typeof this['init'] == "function")
this.init();
}
}
return fC;
};
jpf.subnode = function(nodeFunc, oBase) {
var fC = function() {
this.$init.apply(this, arguments);
};
if (oBase) {
if (typeof oBase == "function")
fC.prototype.base = oBase;
else
fC.prototype = oBase;
}
fC.prototype.nodeFunc = nodeFunc || jpf.NODE_HIDDEN;
fC.prototype.inherit  = jpf.inherit;
if (typeof fC.prototype['$init'] != "function") {
var aImpl = [];
fC.implement = function() {
aImpl = aImpl.concat(Array.prototype.slice.call(arguments));
return fC;
}
fC.prototype.$init = function(pHtmlNode, sName, parentNode){
if (typeof sName != "string") 
throw new Error(jpf.formatErrorString(0, this, 
"Error creating component",
"Dependencies not met, please provide a component name when \
instantiating it (ex.: new jpf.tree(oParent, 'tree') )"));
this.tagName      = sName;
this.pHtmlNode    = pHtmlNode || document.body;
this.pHtmlDoc     = this.pHtmlNode.ownerDocument;
this.parentNode   = parentNode;
this.$domHandlers = {
"remove"      : [],
"insert"      : [],
"reparent"    : [],
"removechild" : []
};
this.uniqueId     = jpf.all.push(this) - 1;
this.inherit(jpf.Class);
this.inherit.apply(this, aImpl);
this.inherit(jpf.JmlDom, this.base || jpf.K);
if (typeof this['init'] == "function")
this.init();
}
}
return fC;
};
jpf.windowManager = {
destroy: function(frm){
},
userdata: [],
forms   : new Array(),
addForm: function(xmlFormNode){
var x = {
jml: xmlFormNode,
show: function(){
alert("not implemented");
}
};
this.forms.push(jpf.setReference(x.name, x, true));
return x;
},
getForm: function(value){
for (var i = 0; i < this.forms.length; i++)
if (this.forms[i].name == value)
return this.forms[i];
return this.forms.length ? this.forms[0] : false;
},
closeAll: function(){
for (var i = 0; i < this.forms.length; i++)
if (this.forms[i].name != "main" && this.forms[i].type != "modal")
this.forms[i].hide();
}
};
jpf.WindowImplementation = function(){
jpf.register(this, "window", jpf.NODE_HIDDEN);
this.jpf = jpf;
this.toString = function(){
return "[Javeline Component : " + (this.name || "") + " (jpf.window)]";
};
this.getActionTracker = function(){
return this.$at
};
this.loadCodeFile = function(url){
if (self[url])
jpf.importClass(self[url], true, this.win);
else
jpf.include(url);
};
this.show = function(){
if (jpf.isDeskrun)
jdwin.Show();
};
this.hide = function(){
if (jpf.isDeskrun)
jdwin.Hide();
else {
this.loaded = false;
if (this.win)
this.win.close();
}
};
this.focus = function(){
if (jpf.isDeskrun)
jdwin.SetFocus();
else
window.focus();
};
this.setIcon = function(url){
if (jpf.isDeskrun)
jdwin.icon = parseInt(url) == url ? parseInt(url) : url;
};
this.setTitle = function(value){
this.title = value || "";
if (jpf.isDeskrun)
jdwin.caption = value;
else
document.title = (value || "");
};
this.loadJml = function(x){
if (x[jpf.TAGNAME] == "deskrun")
this.loadDeskRun(x);
else {
}
};
this.$tabList = [];
this.$addFocus = function(jmlNode, tabindex, isAdmin){
if (!isAdmin) {
if (jmlNode.$domHandlers) {
jmlNode.$domHandlers.reparent.push(moveFocus);
jmlNode.$domHandlers.remove.push(removeFocus);
}
if (jmlNode.isWindowContainer > -1) {
jmlNode.addEventListener("focus", trackChildFocus);
if (!jmlNode.$tabList) {
jmlNode.$tabList = [jmlNode];
}
jmlNode.$focusParent = jmlNode;
this.$tabList.push(jmlNode);
return;
}
}
var fParent = findFocusParent(jmlNode);
var list    = fParent.$tabList;
jmlNode.$focusParent = fParent;
if (list[tabindex])
list.insertIndex(jmlNode, tabindex);
else
list.push(jmlNode);
};
this.$removeFocus = function(jmlNode){
if (!jmlNode.$focusParent)
return;
jmlNode.$focusParent.$tabList.remove(jmlNode);
if (!jmlNode.isWindowContainer && jmlNode.$domHandlers) {
jmlNode.$domHandlers.reparent.remove(moveFocus);
jmlNode.$domHandlers.remove.remove(removeFocus);
}
if (jmlNode.isWindowContainer > -1)
jmlNode.removeEventListener("focus", trackChildFocus);
};
this.$focus = function(jmlNode, e, force){
if (this.focussed == jmlNode && !force)
return; 
this.$settingFocus = jmlNode;
if (this.focussed && this.focussed != jmlNode) {
this.focussed.blur(true, e);
}
(this.focussed = jmlNode).focus(true, e);
this.$settingFocus = null;
jpf.dispatchEvent("movefocus", {
toElement : this.focussed
});
};
this.$blur = function(jmlNode){
if (this.focussed != jmlNode)
return false;
jpf.window.focussed.$focusParent.$lastFocussed = null;
this.focussed = null;
jpf.dispatchEvent("movefocus", {
fromElement : jmlNode
});
};
var lastFocusParent;
this.$focusDefault = function(jmlNode, e){
var fParent = findFocusParent(jmlNode);
this.$focusLast(fParent, e);
}
this.$focusRoot = function(e){
var docEl = jpf.document.documentElement;
if (this.$focusLast(docEl, e) === false) {
}
};
this.$focusLast = function(jmlNode, e, ignoreVisible){
var lf = jmlNode.$lastFocussed;
if (lf && lf.parentNode && lf.$focussable === true
&& (ignoreVisible || lf.oExt.offsetHeight)) {
this.$focus(lf, e, true);
}
else { 
var str, x, node = jmlNode;
while (node) {
if (node.focussable !== false && node.$focussable === true
&& (ignoreVisible || node.oExt.offsetHeight)) {
this.$focus(node, e, true);
break;
}
if (node.firstChild || node.nextSibling) {
node = node.firstChild || node.nextSibling;
}
else {
do {
node = node.parentNode;
} while (node && !node.nextSibling && node != jmlNode)
if (node == jmlNode)
return; 
if (node)
node = node.nextSibling;
}
}
if (!node)
this.$focus(jpf.document.documentElement);
}
};
function trackChildFocus(e){
if (e.srcElement == this || e.trackedChild) {
e.trackedChild = true;
return;
}
this.$lastFocussed = e.srcElement;
if (this.tagName.indexOf("window") > -1)
e.trackedChild = true;
}
function findFocusParent(jmlNode){
var node = jmlNode;
do {
node = node.parentNode;
} while(node && !node.isWindowContainer);
return node || jpf.document.documentElement;
}
function moveFocus(){
if (this.isWindowContainer)
jpf.window.$tabIndex.push(this);
else
jpf.window.$addFocus(this, this.tabindex, true)
}
function removeFocus(doOnlyAdmin){
if (this.isWindowContainer) {
jpf.window.$tabList.remove(this);
return;
}
if (!this.$focusParent)
return;
this.$focusParent.$tabList.remove(this);
}
this.hasFocus = function(jmlNode){
return this.focussed == jmlNode;
};
this.moveNext = function(shiftKey, relObject, switchWindows, e){
var dir, start, next;
if (switchWindows && jpf.window.focussed) {
var p = jpf.window.focussed.$focusParent;
if (p.visible && p.modal)
return false;
}
var jmlNode = relObject || jpf.window.focussed;
var fParent = jmlNode
? (switchWindows && jmlNode.isWindowContainer
? jpf.window
: jmlNode.$focusParent)
: jpf.document.documentElement;
var list    = fParent.$tabList;
if (jmlNode && (switchWindows || jmlNode != jpf.document.documentElement)) {
start   = (list || []).indexOf(jmlNode);
if (start == -1) {
return;
}
}
else
start = -1;
if (this.focussed && this.focussed == jmlNode
&& list.length == 1 || list.length == 0)
return false;
dir  = (shiftKey ? -1 : 1);
next = start;
if (start < 0)
start = 0;
do {
next += dir;
if (next >= list.length)
next = 0;
else if (next < 0)
next = list.length - 1;
if (start == next)
return false; 
jmlNode = list[next];
}
while (!jmlNode
|| jmlNode.disabled
|| jmlNode == jpf.window.focussed
|| (switchWindows ? !jmlNode.visible : jmlNode.oExt && !jmlNode.oExt.offsetHeight)
|| jmlNode.focussable === false
|| switchWindows && !jmlNode.$tabList.length);
if (fParent == jpf.window)
this.$focusLast(jmlNode, {mouse:true}, switchWindows);
else
this.$focus(jmlNode, e);
};
this.focusDefault = function(){
if (this.moveNext() === false) {
this.moveNext(null, jpf.document.documentElement, true)
}
};
window.onbeforeunload = function(){
return jpf.dispatchEvent("exit");
};
window.onunload = function(){
jpf.window.isExiting = true;
jpf.window.destroy();
};
document.oncontextmenu = function(e){
if (!e)
e = event;
if (jpf.appsettings.disableRightClick)
return false;
};
var ta = {"INPUT":1, "TEXTAREA":1};
document.onmousedown = function(e){
if (!e) e = event;
var jmlNode = jpf.findHost(e.srcElement || e.target);
if (jpf.popup.last && jpf.popup.last != jmlNode.uniqueId)
jpf.popup.forceHide();
var p;
if ((!jmlNode || !jmlNode.$focussable || jmlNode.focussable === false)
&& jpf.appsettings.allowBlur) {
lastFocusParent = null;
if (jpf.window.focussed)
jpf.window.focussed.blur();
}
else if ((p = jpf.window.focussed && jpf.window.focussed.$focusParent || lastFocusParent)
&& p.visible && p.modal && jmlNode.$focusParent != p) {
jpf.window.$focusLast(p, {mouse: true});
}
else if (!jmlNode && jpf.window.focussed) {
jpf.window.$focusRoot();
}
else if (!jmlNode.disabled && jmlNode.focussable !== false) {
if (jmlNode.$focussable === jpf.KEYBOARD_MOUSE)
jpf.window.$focus(jmlNode, {mouse: true});
else if (jmlNode.canHaveChildren == 2) {
if (!jpf.appsettings.allowBlur)
jpf.window.$focusLast(jmlNode, {mouse: true});
}
else
jpf.window.$focusDefault(jmlNode, {mouse: true});
}
else
jpf.window.$focusDefault(jmlNode, {mouse: true});
jpf.dispatchEvent("mousedown", {
htmlEvent : e,
jmlNode   : jmlNode
});
if (!jpf.isIE && (jpf.JmlParser && !jpf.appsettings.allowSelect
&& (!jpf.isParsingPartial || jmlNode)
) && !ta[e.target.tagName])
return false;
};
document.onselectstart = function(e){
if (!e) e = event;
if (jpf.JmlParser && !jpf.appsettings.allowSelect
)
return false;
};
document.onkeyup = function(e){
if (!e) e = event;
if (jpf.window.focussed
&& !jpf.window.focussed.disableKeyboard
&& jpf.window.focussed.dispatchEvent("keyup", {
keyCode  : e.keyCode,
ctrlKey  : e.ctrlKey,
shiftKey : e.shiftKey,
altKey   : e.altkey,
htmlEvent: e
}) === false) {
return false;
}
jpf.dispatchEvent("keyup", null, e);
};
var keyNames = {
"32" : "Spacebar",
"13" : "Enter",
"9"  : "Tab",
"27" : "Esc",
"46" : "Del",
"36" : "Home",
"35" : "End",
"107": "+",
"37" : "Left Arrow",
"38" : "Up Arrow",
"39" : "Right Arrow",
"40" : "Down Arrow",
"33" : "Page Up",
"34" : "Page Down",
"112": "F1",
"113": "F2",
"114": "F3",
"115": "F4",
"116": "F5",
"117": "F6",
"118": "F7",
"119": "F8",
"120": "F9",
"121": "F10",
"122": "F11",
"123": "F12"
};
document.onkeydown = function(e){
if (!e)
e = event;
var eInfo = {
ctrlKey   : e.ctrlKey,
shiftKey  : e.shiftKey,
altKey    : e.altKey,
keyCode   : e.keyCode,
htmlEvent : e,
bubbles   : true
};
var keys = []; 
if (e.altKey)
keys.push("Alt");
if (e.ctrlKey)
keys.push("Ctrl");
if (e.shiftKey)
keys.push("Shift");
if (e.metaKey)
keys.push("Meta");
if (keyNames[e.keyCode])
keys.push(keyNames[e.keyCode]);
if (keys.length) {
if (e.keyCode > 46)
keys.push(String.fromCharCode(e.keyCode));
jpf.setProperty("hotkey", keys.join("-"));
}
if (jpf.window.focussed && !jpf.window.focussed.disableKeyboard
&& jpf.window.focussed.dispatchEvent("keydown", eInfo) === false) {
e.returnValue  = false;
e.cancelBubble = true;
if (jpf.canDisableKeyCodes) {
try {
e.keyCode = 0;
}
catch(e) {}
}
return false;
}
else if ((!jpf.appsettings.disableTabbing || jpf.window.focussed) && e.keyCode == 9) {
if (e.ctrlKey) {
if (jpf.window.focussed) {
jpf.window.moveNext(e.shiftKey,
jpf.window.focussed.$focusParent, true);
var w = jpf.window.focussed.$focusParent;
if (w && w.bringToFront)
w.bringToFront();
}
}
else if(!jpf.window.focussed || jpf.window.focussed.tagName != "menu")
jpf.window.moveNext(e.shiftKey);
e.returnValue = false;
return false;
}
if (jpf.appsettings.disableBackspace
&& (e.keyCode == 8 || e.altKey && (e.keyCode == 37 || e.keyCode == 39))
&& !ta[(e.srcElement || e.target).tagName]) {
if (jpf.canDisableKeyCodes) {
try {
e.keyCode = 0;
}
catch(e) {}
}
e.returnValue = false;
}
if (jpf.appsettings.disableF5 && (e.keyCode == 116 || e.keyCode == 117)) {
if (jpf.canDisableKeyCodes) {
try {
e.keyCode = 0;
}
catch(e) {}
}
else {
e.preventDefault();
e.stopPropagation();
}
}
if (e.keyCode == 27) { 
e.returnValue = false;
}
if (!jpf.appsettings.allowSelect
&& e.shiftKey && (e.keyCode > 32 && e.keyCode < 41)
&& !ta[(e.explicitOriginalTarget || e.srcElement || e.target).tagName]
&& (!e.srcElement || e.srcElement.contentEditable != "true")) {
e.returnValue = false;
}
return e.returnValue;
};
this.destroy = function(){
this.$at = null;
jpf.destroy(this);
jpf.windowManager.destroy(this);
jpf           =
this.win      =
this.window   =
this.document = null;
window.onfocus        =
window.onerror        =
window.onunload       =
window.onbeforeunload =
window.onbeforeprint  =
window.onafterprint   =
window.onmousewheel   =
window.onblur         = null;
document.oncontextmenu =
document.onmousedown   =
document.onmousemove   =
document.onmouseup     =
document.onselectstart =
document.onmousewheel  =
document.onkeyup       =
document.onkeydown     = null
document.body.onmousedown =
document.body.onmousemove =
document.body.onmouseup   = null;
document.body.innerHTML = "";
};
};
jpf.DocumentImplementation = function(){
jpf.makeClass(this);
this.inherit(jpf.JmlDom); 
this.nodeType   = jpf.NODE_DOCUMENT;
this.nodeFunc   = jpf.NODE_HIDDEN;
this.$jmlLoaded = true;
this.documentElement = {
uniqueId      : jpf.all.push(this) - 1,
nodeType      :  1,
nodeFunc      : jpf.NODE_HIDDEN,
tagName       : "application",
parentNode    : this,
ownerDocument : this,
pHtmlNode     : document.body,
$jml          : jpf.JmlParser.$jml,
$tabList      : [], 
$jmlLoaded    : true,
$focussable   : jpf.KEYBOARD,
focussable    : true,
isWindowContainer : true,
canHaveChildren   : true,
focus : function(){
this.dispatchEvent("focus");
},
blur  : function(){
this.dispatchEvent("blur");
}
};
this.appendChild  =
this.insertBefore = function(){
this.documentElement.insertBefore.apply(this.documentElement, arguments);
};
jpf.inherit.call(this.documentElement, jpf.Class);
jpf.window.$addFocus(this.documentElement);
jpf.inherit.call(this.documentElement, jpf.JmlDom);
this.getElementById = function(id){
return self[id];
};
this.createElement = function(tagName){
var x, o;
if (tagName.nodeType) {
x = tagName;
}
else if (tagName.indexOf("<") > -1) {
x = jpf.getXml(tagName)
}
else {
var prefix = jpf.findPrefix(jpf.JmlParser.$jml, jpf.ns.jml);
var doc = jpf.JmlParser.$jml.ownerDocument;
if(jpf.JmlParser.$jml && doc.createElementNS) {
x = doc.createElementNS(jpf.ns.jml, prefix + ":" + tagName);
}
else {
x = jpf.getXml("<" + prefix + ":" + tagName + " xmlns:"
+ prefix + "='" + jpf.ns.jml + "' />", true);
}
}
if (jpf.isIE) {
if (!prefix)
prefix = x.prefix;
x.ownerDocument.setProperty("SelectionNamespaces",
"xmlns:" + prefix + "='" + jpf.ns.jml + "'");
}
tagName = x[jpf.TAGNAME];
var initId;
if (typeof jpf[tagName] != "function") { 
o = new jpf.JmlDom(tagName, null, jpf.NODE_HIDDEN, x);
if (jpf.JmlParser.handler[tagName]) {
initId = o.$domHandlers["reparent"].push(function(b, pNode){
this.$domHandlers.reparent[initId] = null;
if (!pNode.$jmlLoaded)
return; 
o = jpf.JmlParser.handler[tagName](this.$jml,
pNode, pNode.oInt);
if (o) jpf.extend(this, o); 
if (o && this.name)
jpf.nameserver.register(tagName, this.name, o);
if (this.name)
jpf.setReference(name, o);
o.$jmlLoaded = true;
}) - 1;
}
}
else {
o = new jpf[tagName](null, tagName, x);
if (o.loadJml) {
initId = o.$domHandlers["reparent"].push(function(b, pNode){
this.$domHandlers.reparent[initId] = null;
if (!pNode.$jmlLoaded) 
return;
function loadJml(o, pHtmlNode){
if (!o.$jmlLoaded) {
var length = o.childNodes.length;
o.pHtmlNode = pHtmlNode || document.body;
o.loadJml(o.$jml);
o.$jmlLoaded = false; 
if (length) {
for (var i = 0, l = o.childNodes.length; i < l; i++) {
if (o.childNodes[i].loadJml) {
loadJml(o.childNodes[i], o.canHaveChildren
? o.oInt
: document.body);
}
else
o.childNodes[i].$jmlLoaded = true;
}
}
}
if (o.$reappendToParent) {
o.$reappendToParent();
}
o.$jmlLoaded = true;
o.$reappendToParent = null;
}
var parsing = jpf.isParsing;
jpf.isParsing = true;
jpf.JmlParser.parseFirstPass([x]);
loadJml(o, pNode && pNode.oInt || document.body);
if (pNode.pData)
jpf.layout.activateRules(pNode.oInt || document.body);
jpf.JmlParser.parseLastPass();
jpf.isParsing = parsing;
}) - 1;
}
}
if (o.name)
jpf.setReference(o.name, o);
o.$jml = x;
return o;
};
this.createDocumentFragment = function(){
return new jpf.JmlDom(jpf.NODE_DOCUMENT_FRAGMENT)
}
this.evaluate = function(sExpr, contextNode, nsResolver, type, x){
var result = jpf.XPath.selectNodes(sExpr,
contextNode || this.documentElement);
return {
snapshotLength : result.length,
snapshotItem   : function(i){
return result[i];
}
}
};
this.createNSResolver = function(contextNode){
return {};
};
};
var __INTERACTIVE__ = 1 << 21;
jpf.Interactive = function(){
var nX, nY, rX, rY, startPos, lastCursor = null, l, t, lMax, tMax, 
w, h, we, no, ea, so, rszborder, rszcorner, marginBox,
verdiff, hordiff, _self = this, posAbs, oX, oY, overThreshold,
dragOutline, resizeOutline;
this.$regbase = this.$regbase | __INTERACTIVE__;
this.$propHandlers["draggable"] = function(value){
if (jpf.isFalse(value))
this.draggable = value = false;
else if (jpf.isTrue(value))
this.draggable = value = true;
var o = this.oDrag || this.oExt;
if (o.interactive & 1) 
return;
var mdown = o.onmousedown;
o.onmousedown = function(){
if (mdown && mdown.apply(this, arguments) === false)
return;
dragStart.apply(this, arguments);
}
o.interactive = (o.interactive||0)+1;
};
this.$propHandlers["resizable"] = function(value){
if (jpf.isFalse(value))
this.resizable = value = false;
else if (jpf.isTrue(value))
this.resizable = value = true;
var o = this.oResize || this.oExt;
if (o.interactive & 2) 
return;
var mdown = o.onmousedown;
var mmove = o.onmousemove;
o.onmousedown = function(){
if (mdown && mdown.apply(this, arguments) === false)
return;
resizeStart.apply(this, arguments);
};
o.onmousemove = function(){
if (mmove && mmove.apply(this, arguments) === false)
return;
resizeIndicate.apply(this, arguments);
};
o.interactive = (o.interactive||0)+2;
rszborder = this.$getOption && parseInt(this.$getOption("Main", "resize-border")) || 3;
rszcorner = this.$getOption && parseInt(this.$getOption("Main", "resize-corner")) || 12;
marginBox = jpf.getBox(jpf.getStyle(this.oExt, "borderWidth"));
};
function dragStart(e){
if (!e) e = event;
if (!_self.draggable || jpf.dragmode.isDragging)
return;
dragOutline = !(_self.dragOutline == false || !jpf.appsettings.dragOutline);
jpf.dragmode.isDragging = true;
overThreshold           = false;
jpf.popup.forceHide();
posAbs = "absolute|fixed".indexOf(jpf.getStyle(_self.oExt, "position")) > -1;
if (!posAbs)
_self.oExt.style.position = "relative";
if (posAbs && !_self.aData) {
jpf.plane.show(dragOutline
? oOutline
: _self.oExt);
}
var pos = posAbs 
? jpf.getAbsolutePosition(_self.oExt, _self.oExt.offsetParent) 
: [parseInt(_self.oExt.style.left) || _self.oExt.offsetLeft || 0, 
parseInt(_self.oExt.style.top) || _self.oExt.offsetTop || 0];
nX = pos[0] - (oX = e.clientX);
nY = pos[1] - (oY = e.clientY);
if (_self.hasFeature && _self.hasFeature(__ANCHORING__))
_self.disableAnchoring();
if (posAbs && dragOutline) {
oOutline.className     = "drag";
var diffOutline = jpf.getDiff(oOutline);
_self.oExt.parentNode.appendChild(oOutline);
oOutline.style.left    = pos[0] + "px";
oOutline.style.top     = pos[1] + "px";
oOutline.style.width   = (_self.oExt.offsetWidth - diffOutline[0]) + "px";
oOutline.style.height  = (_self.oExt.offsetHeight - diffOutline[1]) + "px";
}
document.onmousemove = dragMove;
document.onmouseup   = function(){
document.onmousemove = document.onmouseup = null;
if (posAbs && !_self.aData)
jpf.plane.hide();
if (overThreshold) {
if (_self.setProperty) {
if(l) _self.setProperty("left", l);
if(t) _self.setProperty("top", t);
}
else if (dragOutline) {
_self.oExt.style.left = l + "px";
_self.oExt.style.top  = t + "px";
}
}
if (!posAbs)
_self.oExt.style.position = "relative";
if (_self.showdragging)
jpf.setStyleClass(_self.oExt, "", ["dragging"]);
if (posAbs && dragOutline)
oOutline.style.display = "none";
jpf.dragmode.isDragging = false;
if (_self.dispatchEvent)
_self.dispatchEvent("drag");
};
if (jpf.isIE)
document.onmousedown();
return false;
};
function dragMove(e){
if(!e) e = event;
if (!overThreshold && _self.showdragging)
jpf.setStyleClass(_self.oExt, "dragging");
var dx = e.clientX - oX,
dy = e.clientY - oY,
distance; 
if (!overThreshold 
&& (distance = dx*dx > dy*dy ? dx : dy) * distance < 2)
return;
else if (!overThreshold && dragOutline 
&& oOutline.style.display != "block")
oOutline.style.display = "block";
var oHtml = dragOutline
? oOutline
: _self.oExt;
oHtml.style.left = (l = e.clientX + nX) + "px";
oHtml.style.top  = (t = e.clientY + nY) + "px";
overThreshold = true;
};
function resizeStart(e){
if (!e) e = event;
if (!_self.resizable)
return;
resizeOutline = !(_self.resizeOutline == false || !jpf.appsettings.resizeOutline);
if (!resizeOutline) {
var diff = jpf.getDiff(_self.oExt);
hordiff  = diff[0];
verdiff  = diff[1];
}
startPos = jpf.getAbsolutePosition(_self.oExt);
startPos.push(_self.oExt.offsetWidth);
startPos.push(_self.oExt.offsetHeight);
var sLeft = document.documentElement.scrollLeft;
var sTop = document.documentElement.scrollTop;
var x = (oX = e.clientX) - startPos[0] + sLeft;
var y = (oY = e.clientY) - startPos[1] + sTop;
var resizeType = getResizeType.call(_self.oExt, x, y);
rX = x;
rY = y;
if (!resizeType)
return;
if (_self.dispatchEvent && _self.dispatchEvent("resizestart", {
type : resizeType
}) === false)
return;
jpf.popup.forceHide();
if (_self.hasFeature && _self.hasFeature(__ANCHORING__))
_self.disableAnchoring();
jpf.dragmode.isDragging = true;
overThreshold           = false;
var r = "|" + resizeType + "|"
we = "|w|nw|sw|".indexOf(r) > -1;
no = "|n|ne|nw|".indexOf(r) > -1;
ea = "|e|se|ne|".indexOf(r) > -1;
so = "|s|se|sw|".indexOf(r) > -1;
if (!_self.minwidth)  _self.minwidth  = 0;
if (!_self.minheight) _self.minheight = 0;
if (!_self.maxwidth)  _self.maxwidth  = 10000;
if (!_self.maxheight) _self.maxheight = 10000;
if (posAbs) {
lMax = startPos[0] + startPos[2] - _self.minwidth;
tMax = startPos[1] + startPos[3] - _self.minheight;
lMin = startPos[0] + startPos[2] - _self.maxwidth;
tMin = startPos[1] + startPos[3] - _self.maxheight;
}
if (posAbs) {
jpf.plane.show(resizeOutline
? oOutline
: _self.oExt);
}
if (resizeOutline) {
oOutline.className     = "resize";
var diffOutline = jpf.getDiff(oOutline);
hordiff = diffOutline[0];
verdiff = diffOutline[1];
oOutline.style.left    = startPos[0] + "px";
oOutline.style.top     = startPos[1] + "px";
oOutline.style.width   = (_self.oExt.offsetWidth - hordiff) + "px";
oOutline.style.height  = (_self.oExt.offsetHeight - verdiff) + "px";
oOutline.style.display = "block";
}
if (lastCursor === null)
lastCursor = document.body.style.cursor;
document.body.style.cursor = resizeType + "-resize";
document.onmousemove = resizeMove;
document.onmouseup   = function(e){
document.onmousemove = document.onmouseup = null;
if (posAbs)
jpf.plane.hide();
if (resizeOutline) {
var diff = jpf.getDiff(_self.oExt);
hordiff  = diff[0];
verdiff  = diff[1];
}
doResize(e || event, true);
if (_self.setProperty) {
if (posAbs) {
if (l) _self.setProperty("left", l);
if (t) _self.setProperty("top", t);
}
if (w) _self.setProperty("width", w + hordiff) 
if (h) _self.setProperty("height", h + verdiff); 
}
l = t = w = h = null;
document.body.style.cursor = lastCursor;
lastCursor = null;
if (resizeOutline)
oOutline.style.display = "none";
jpf.dragmode.isDragging = false;
if (_self.dispatchEvent)
_self.dispatchEvent("resize");
};
if (jpf.isIE)
document.onmousedown();
return false;
};
var min = Math.min, max = Math.max, lastTime;
function resizeMove(e){
if(!e) e = event;
if (lastTime && new Date().getTime() 
- lastTime < (resizeOutline ? 6 : jpf.mouseEventBuffer))
return;
lastTime = new Date().getTime();
doResize(e);
};
function doResize(e, force){
var oHtml = resizeOutline && !force
? oOutline
: _self.oExt;
var sLeft = document.documentElement.scrollLeft;
var sTop = document.documentElement.scrollTop;
if (we) {
oHtml.style.left = (l = max(lMin, min(lMax, e.clientX - rX + sLeft))) + "px";
oHtml.style.width = (w = min(_self.maxwidth - hordiff, 
max(hordiff, _self.minwidth, 
startPos[2] - (e.clientX - startPos[0]) + rX + sLeft
) - hordiff) + sLeft) + "px"; 
}
if (no) {
oHtml.style.top = (t = max(tMin, min(tMax, e.clientY - rY + sTop))) + "px";
oHtml.style.height = (h = min(_self.maxheight - verdiff, 
max(verdiff, _self.minheight, 
startPos[3] - (e.clientY - startPos[1]) + rY + sTop
) - verdiff)) + "px"; 
}
if (ea)
oHtml.style.width  = (w = min(_self.maxwidth - hordiff, 
max(hordiff, _self.minwidth, 
e.clientX - startPos[0] + (startPos[2] - rX) + sLeft)
- hordiff)) + "px";
if (so)
oHtml.style.height = (h = min(_self.maxheight - verdiff, 
max(verdiff, _self.minheight, 
e.clientY - startPos[1] + (startPos[3] - rY) + sTop)
- verdiff)) + "px";
if (jpf.hasSingleRszEvent)
jpf.layout.forceResize(_self.oInt);
}
function getResizeType(x, y){
var cursor  = "", 
tcursor = "";
posAbs = "absolute|fixed".indexOf(jpf.getStyle(_self.oExt, "position")) > -1;
if (_self.resizable == true || _self.resizable == "vertical") {
if (y < rszborder + marginBox[0])
cursor = posAbs ? "n" : "";
else if (y > this.offsetHeight - rszborder) 
cursor = "s";
else if (y > this.offsetHeight - rszcorner) 
tcursor = "s";
}
if (_self.resizable == true || _self.resizable == "horizontal") {
if (x < (cursor ? rszcorner : rszborder))  
cursor += tcursor + (posAbs ? "w" : "");
else if (x > this.offsetWidth - (cursor || tcursor ? rszcorner : rszborder)) 
cursor += tcursor + "e";
}
return cursor;
}
var originalCursor;
function resizeIndicate(e){
if(!e) e = event;
if (!_self.resizable || document.onmousemove)
return;
var pos = jpf.getAbsolutePosition(_self.oExt);
var sLeft = document.documentElement.scrollLeft;
var sTop = document.documentElement.scrollTop;
var x = e.clientX - pos[0] + sLeft;
var y = e.clientY - pos[1] + sTop;
if (!originalCursor)
originalCursor = jpf.getStyle(this, "cursor");
var cursor = getResizeType.call(_self.oExt, x, y);
this.style.cursor = cursor 
? cursor + "-resize" 
: originalCursor || "default";
};
if (!this.pHtmlDoc)
this.pHtmlDoc = window.document;
var oOutline = this.pHtmlDoc.getElementById("jpf_outline");
if (!oOutline) {
oOutline = this.pHtmlDoc.body.appendChild(this.pHtmlDoc.createElement("div"));
oOutline.refCount = 0;
oOutline.setAttribute("id", "jpf_outline");
oOutline.style.position = "absolute";
oOutline.style.display  = "none";
oOutline.style.zIndex   = 100000000;
}
oOutline.refCount++;
};
var __MEDIA__ = 1 << 20;
jpf.Media = function(){
this.$regbase = this.$regbase | __MEDIA__;
this.muted = false;
this.$booleanProperties["paused"]     = true;
this.$booleanProperties["muted"]      = true;
this.$booleanProperties["seeking"]    = true;
this.$booleanProperties["autoplay"]   = true;
this.$booleanProperties["controls"]   = true;
this.$booleanProperties["ready"]      = true;
this.$supportedProperties.push("position", "networkState", "readyState",
"progress", "buffered", "bufferedBytes", "totalBytes", "currentTime",
"paused", "seeking", "volume", "type", "src", "autoplay", "controls");
this.mainBind = "src";
this.$propHandlers["readyState"] = function(value){ 
if (this.readyState !== value)
this.readyState = value;
if (value == jpf.Media.HAVE_NOTHING) {
var oError = this.MediaError("Unable to open medium with URL '" + this.src
+ "'. Please check if the URL you entered as src is pointing to \
a valid resource.");
if (this.dispatchEvent("havenothing", {
error   : oError,
bubbles : true
}) === false)
throw oError;
}
else if (value == jpf.Media.HAVE_CURRENT_DATA)
this.dispatchEvent("havecurrentdata");
else if (value == jpf.Media.HAVE_FUTURE_DATA)
this.dispatchEvent("havefuturedata");
else if (value == jpf.Media.HAVE_ENOUGH_DATA) {
this.dispatchEvent("haveenoughdata");
this.setProperty('ready', true);
}
};
this.$propHandlers["bufferedBytes"] = function(value) {
this.setProperty("progress", this.totalBytes
? value.end / this.totalBytes
: 0);
};
this.$propHandlers["position"] = function(value){
if (this.duration > 0 && this.seek) {
if (value >= this.progress)
value = this.progress - 0.05;
var isPlaying = !this.paused;
if (isPlaying)
this.pause();
if (value < 0)
value = 0;
else if (value > 1)
value = 1;
this.seek(Math.round(value * this.duration));
this.setProperty('paused', !isPlaying);
}
};
this.$propHandlers["currentTime"] = function(value){ 
if (value >= 0 && this.seek)
this.seek(value);
};
this.$propHandlers["volume"] = function(value){
if (!this.player) return;
if (value < 1 && value > 0)
value = value * 100;
if (this.setVolume)
this.setVolume(value);
if (value > 0 && this.muted)
this.setProperty("muted", false);
};
var oldVolume = null;
this.$propHandlers["muted"] = function(value){
if (!this.player || !this.setVolume) return;
if (value) { 
oldVolume = this.volume;
this.setVolume(0);
}
else
this.setVolume(oldVolume || 20);
};
this.$propHandlers["paused"] = function(value){
if (!this.player) return;
this.paused = jpf.isTrue(value);
if (this.paused)
this.player.pause();
else
this.player.play();
};
var loadTimer = null;
this.$propHandlers["type"] = function(value){
if (loadTimer) return;
var _self = this;
loadTimer = window.setTimeout(function() {
reload.call(_self);
});
};
this.$propHandlers["src"] = function(value){
if (loadTimer || !value) return; 
var oUrl = new jpf.url(value);
this.src = oUrl.uri;
if (this.src != this.currentSrc && this.networkState !== jpf.Media.LOADING) {
var type = this.$guessType(this.src);
if (type == this.type) {
reset.call(this);
this.loadMedia();
}
else {
this.type = type;
var _self = this;
loadTimer = window.setTimeout(function() {
reload.call(_self);
});
}
}
};
this.$propHandlers["ID3"] = function(value){
if (!this.player) return;
if (typeof this.player.setID3 == "function")
this.player.setID3(value);
};
this.$domHandlers["remove"].push(function(doOnlyAdmin){
reset.call(this);
});
this.$domHandlers["reparent"].push(function(beforeNode, pNode, withinParent){
if (!this.$jmlLoaded)
return;
this.$draw();
reload.call(this, true);
});
function reset() {
this.setProperty('networkState',  jpf.Media.NETWORK_EMPTY);
this.setProperty('ready',         false);
this.buffered      = {start: 0, end: 0, length: 0};
this.bufferedBytes = {start: 0, end: 0, length: 0};
this.totalBytes    = 0;
this.setProperty('progress',      0);
this.setProperty('seeking',  false);
this.setProperty('paused',   true);
this.setProperty('position', 0);
this.currentTime = this.duration = 0;
this.played = this.seekable = null;
this.ended  = false;
this.start = this.end = this.loopStart = this.loopEnd =
this.playCount = this.currentLoop = 0;
this.controls = this.muted = false;
}
function reload(bNoReset) {
window.clearTimeout(loadTimer);
loadTimer = null;
if (!bNoReset)
reset.call(this);
this.$destroy(true); 
this.playerType = this.$getPlayerType(this.type);
if (!this.playerType || !this.$isSupported()) {
this.oExt.innerHTML = this.notSupported;
return;
}
this.$initPlayer();
}
this.MediaError = function(sMsg) {
return new Error(jpf.formatErrorString(0, this, "Media", sMsg));
};
this.src = this.currentSrc = null;
this.networkState       = jpf.Media.NETWORK_EMPTY; 
this.bufferingRate      = 0;
this.bufferingThrottled = false;
this.buffered           = {start: 0, end: 0, length: 0}; 
this.bufferedBytes      = {start: 0, end: 0, length: 0}; 
this.totalBytes         = 0;
this.volume             = 100;
this.loadMedia = function() {
};
this.readyState = jpf.Media.HAVE_NOTHING;
this.seeking    = false;
this.currentTime         = this.duration = 0;
this.paused              = true;
this.defaultPlaybackRate = this.playbackRate = 0;
this.played              = null; 
this.seekable            = null; 
this.ended = this.autoplay = false;
this.canPlayType = function(sType) {
if (this.$getPlayerType) {
var sPlayer = this.$getPlayerType(sType);
if (!sPlayer || !this.$isSupported(sPlayer))
return "no";
if (sPlayer.indexOf("Wmp") != -1)
return "maybe";
return "probably"; 
}
return "no";
};
this.play = function() {
this.setProperty('paused', false);
};
this.pause = function() {
this.setProperty('paused', true);
};
this.start = this.end = this.loopStart = this.loopEnd =
this.playCount = this.currentLoop = 0;
this.addCueRange = function(sClassName, sId, iStart, iEnd, bPauseOnExit, fEnterCallback, fExitCallback) {
};
this.removeCueRanges = function(sClassName) {
};
this.getCounter = function(iMillis, sFormat, bReverse) {
if (bReverse)
iMillis = iMillis - this.duration;
var iSeconds = Math.round(Math.abs(iMillis / 1000)),
sHours   = String(Math.round(Math.abs(iSeconds / 60 / 60))).pad(2, "0"),
sMinutes = String(Math.round(Math.abs(iSeconds / 60))).pad(2, "0"),
sSeconds = String(iSeconds).pad(2, "0"),
sMillis  = String(Math.round(Math.abs(iMillis % 1000))).pad(3, "0");
return (bReverse ? "- " : "") + sFormat.replace(/\%T/g, "%H:%M:%S")
.replace(/\%[a-zA-Z\%]/g, function(sMatch) {
switch (sMatch) {
case "%H":
return sHours;
case "%M":
return sMinutes;
case "%S":
return sSeconds;
case "%Q":
return sMillis;
case "%n":
return "\n";
case "%t":
return "\t";
case "%%":
return "%";
}
});
};
this.setSource = function(jml) {
jml = jml || this.$jml;
var aNodes = $xmlns(jml, "nomedia", jpf.ns.jml);
if (!aNodes.length) {
this.notSupported = (jml.firstChild && jml.firstChild.nodeType == 3)
? jml.firstChild.nodeValue
: "Unable to playback, medium not supported.";
}
else
this.notSupported = aNodes[0].innerHTML;
if (!this.src) { 
var src, type, oSources = $xmlns(jml, "source", jpf.ns.jml);
for (var i = 0, j = oSources.length; i < j; i++) {
src  = oSources[i].getAttribute("src");
if (!src) continue;
type = oSources[i].getAttribute("type");
if (!type) 
type = this.$guessType(src);
if (this.canPlayType(type) != "no") {
this.src  = src;
this.type = type;
break; 
}
}
}
else if (!this.type) {
this.type = this.$guessType(this.src);
if (this.canPlayType(this.type) == "no")
return false;
}
return (this.src && this.type);
};
};
jpf.Media.NETWORK_EMPTY   = 0;
jpf.Media.NETWORK_IDLE    = 1;
jpf.Media.NETWORK_LOADING = 2;
jpf.Media.NETWORK_LOADED  = 3;
jpf.Media.HAVE_NOTHING      = 0;
jpf.Media.HAVE_METADATA     = 1;
jpf.Media.HAVE_SOME_DATA    = 2; 
jpf.Media.HAVE_CURRENT_DATA = 3;
jpf.Media.HAVE_FUTURE_DATA  = 4;
jpf.Media.HAVE_ENOUGH_DATA  = 5;
var __DELAYEDRENDER__ = 1 << 11
jpf.DelayedRender = function(){
this.$regbase   = this.$regbase | __DELAYEDRENDER__;
this.isRendered = false;
var withheld    = false;
this.$checkDelay = function(x){
if (x.getAttribute("render") == "runtime") {
x.setAttribute("render-status", "withheld");
if (!jpf.JmlParser.renderWithheld)
jpf.JmlParser.renderWithheld = [];
jpf.JmlParser.renderWithheld.push(this);
withheld = true;
return true;
}
this.isRendered = true;
return false;
};
this.$render = function(usedelay){
if (this.isRendered || this.$jml.getAttribute("render-status") != "withheld")
return;
this.dispatchEvent("beforerender");
if (jpf.isNull(this.usedelay))
this.usedelay = jpf.xmldb.getInheritedAttribute(this.$jml,
"use-render-delay") == "true";
if (this.usedelay || usedelay)
setTimeout("jpf.lookup(" + this.uniqueId + ").$renderparse()", 10);
else
this.$renderparse();
};
this.$renderparse = function(){
if (this.isRendered)
return;
jpf.JmlParser.parseMoreJml(this.$jml, this.oInt, this)
this.$jml.setAttribute("render-status", "done");
this.$jml.removeAttribute("render"); 
this.isRendered = true;
withheld = false;
this.dispatchEvent("afterrender");
};
};
var __DATABINDING__ = 1 << 1;
jpf.DataBinding = function(){
var loadqueue;
var cXmlOnLoad = [];
var cXmlSelect = [];
var cXmlChoice = [];
this.$regbase  = this.$regbase | __DATABINDING__;
this.mainBind  = "value";
var _self      = this;
this.getMainBindXpath = function(){
if (this.hasFeature(__MULTIBINDING__))
return this.$getMultiBind().getMainBindXpath();
var m = this.getModel(true);
return (m && m.connect
? m.connect.select + "/"
: (this.dataParent
? this.dataParent.xpath + "/"
: "")) + this.smartBinding.bindings[this.mainBind][0].getAttribute("select");
};
this.isBoundComplete = function(){
if (!this.smartBinding) return true;
if (!this.xmlRoot) return false;
if (this.hasFeature(__MULTIBINDING__) && !this.$getMultiBind().xmlRoot)
return false;
return true;
};
this.queryValue = function(xpath, type){
return jpf.getXmlValue(this[type || 'xmlRoot'], xpath );
};
	
this.queryValues = function(xpath, type){
return jpf.getXmlValues(this[type || 'xmlRoot'], xpath );
};
	
this.queryNode = function(xpath, type){
var n = this[type||'xmlRoot'];
		return n?n.selectSingleNode(xpath):null;
};
this.queryNodes = function(xpath, type){
var n = this[type||'xmlRoot'];
		return n?n.selectNodes(xpath):null;
};
	
this.loadBindings = function(rules, node){
if (this.bindingRules)
this.unloadBindings();
this.bindingRules = rules;
if (this.$loaddatabinding)
this.$loaddatabinding();
if (this.bindingRules["traverse"])
this.parseTraverse(this.bindingRules["traverse"][0]);
this.$checkLoadQueue();
};
this.$checkLoadQueue = function(){
if (loadqueue) {
if (this.load(loadqueue[0], loadqueue[1]) != loadqueue)
loadqueue = null;
}
};
this.unloadBindings = function(){
if (this.$unloaddatabinding)
this.$unloaddatabinding();
var node = this.xmlBindings;
if (!node || !node.getAttribute("connect"))
return;
try {
var o = eval(node.getAttribute("connect"));
o.disconnect(this, node.getAttribute("type"));
}
catch(e) {}
this.bindingRules = null;
return this.uniqueId;
};
this.loadActions = function(rules, node){
if (this.actionRules)
this.unloadActions();
this.actionRules = rules;
};
this.getActionTracker = function(ignoreMe){
if (!jpf.JmlDom)
return jpf.window.$at;
var pNode = this, tracker = ignoreMe ? null : this.$at;
if (!tracker && this.connectId)
tracker = self[this.connectId].$at;
while (!tracker) {
if (!pNode.parentNode)
return jpf.window.$at;
tracker = (pNode = pNode.parentNode).$at;
}
return tracker;
};
this.unloadActions = function(){
this.xmlActions  = null;
this.actionRules = null;
if (this.$at) {
this.$at = null;
}
};
var actions = {};
this.$startAction = function(name, xmlContext, fRollback){
if (this.disabled)
return false;
var actionRule = this.getNodeFromRule(name, xmlContext, true);
if (jpf.appsettings.autoDisableActions && !this.actionRules 
|| this.actionRules && !actionRule)
return false;
if (this.dispatchEvent(name + "start", {
xmlContext: xmlContext
}) === false)
return false;
actions[name] = xmlContext;
return true;
};
this.$stopAction = function(name, isCancelled, curLock){
delete actions[name];
};
this.executeAction = function(atAction, args, action, xmlNode, noevent, contextNode, multiple){
if (this.disabled) return; 
var rules = this.actionRules
? this.actionRules[action]
: (!action.match(/change|select/) && jpf.appsettings.autoDisableActions
? false
: []);
if (!rules)
return false;
for (var node, i = 0; i < (rules.length || 1); i++) {
if (!rules[i] || !rules[i].getAttribute("select")
|| xmlNode.selectSingleNode(rules[i].getAttribute("select"))) {
var ev = new jpf.Event("before" + action.toLowerCase(), {
action        : atAction,
args          : args,
xmlActionNode : rules[i],
jmlNode       : this,
selNode       : contextNode,
multiple      : multiple || false
});
if (!noevent) {
if (this.dispatchEvent(ev.name, null, ev) === false)
return false;
}
var UndoObj = this.getActionTracker().execute(ev);
ev.xmlNode = UndoObj.xmlNode;
ev.undoObj = UndoObj;
if (!noevent) {
ev.name         = "after" + action.toLowerCase();
ev.cancelBubble = false;
delete ev.returnValue;
this.dispatchEvent(ev.name, null, ev);
}
return UndoObj;
}
}
return false;
};
this.executeActionByRuleSet = function(atName, setName, xmlNode, value){
var xpath, args, selInfo = this.getSelectFromRule(setName, xmlNode);
var shouldLoad = false, atAction, node = selInfo[1];
if (node) {
if (jpf.xmldb.getNodeValue(node) == value) return; 
atAction = (node.nodeType == 1 || node.nodeType == 3
|| node.nodeType == 4) ? "setTextNode" : "setAttribute";
args = (node.nodeType == 1)
? [node, value]
: (node.nodeType == 3 || node.nodeType == 4
? [node.parentNode, value]
: [node.ownerElement || node.selectSingleNode(".."), node.nodeName, value]);
}
else {
if (!this.createModel)
return false;
atAction = "setValueByXpath";
xpath    = selInfo[0];
if (!xmlNode) {
var model   = this.getModel();
if (model) {
if (!model.data)
model.load("<data />");
xpath   = (model.getXpathByJmlNode(this) || ".")
+ (xpath && xpath != "." ? "/" + xpath : "");
xmlNode = model.data;
}
else {
if (!this.dataParent)
return false;
xmlNode = this.dataParent.parent.selected;
xpath = this.dataParent.xpath;
shouldLoad = true;
}
}
args = [xmlNode, value, xpath];
}
this.executeAction(atAction, args, atName, xmlNode);
if (shouldLoad)
this.load(xmlNode.selectSingleNode(xpath));
};
this.connect = function(o, dataOnly, xpath, type, noselect){
if (o.dataParent)
o.dataParent.parent.disconnect(o);
if (!this.signalXmlUpdate)
this.signalXmlUpdate = {};
o.dataParent = {
parent: this,
xpath : xpath
};
if (dataOnly) {
if (cXmlOnLoad)
return cXmlOnLoad.push([o, xpath]);
else
return o.load(xpath ? this.xmlRoot.selectSingleNode(xpath) : this.selected);
}
if (!dataOnly)
(!type || type == "select")
? cXmlSelect.push({o:o,xpath:xpath})
: cXmlChoice.push({o:o,xpath:xpath});
if (type != "choice" && !noselect) {
if (this.selected || !this.traverse && this.xmlRoot) {
var xmlNode = this.selected || this.xmlRoot;
if (xpath) {
xmlNode = xmlNode.selectSingleNode(xpath);
if (!xmlNode) {
this.addEventListener("xmlupdate", function(){
this.connect(o, false, xpath, type);
this.removeEventListener("xmlupdate", arguments.callee);
});
}
}
if (xmlNode)
o.load(xmlNode);
}
else {
if (o.clear && !o.hasFeature(__MULTIBINDING__))
o.clear(); 
if (o.disable && o.createModel)
o.disable();
}
}
};
this.disconnect = function(o, type){
var ar = (!type || type == "select") ? cXmlSelect : cXmlChoice; 
if (this.signalXmlUpdate) {
this.signalXmlUpdate[o.uniqueId] = null;
delete this.signalXmlUpdate[o.uniqueId];
}
o.dataParent = null;
for (var i = 0; i < ar.length; i++){
if (ar[i].o != o) continue;
for (var j = i; j < ar.length; j++)
ar[j] = ar[j + 1];
ar.length--;
i--;
}
};
this.setConnections = function(xmlNode, type){
var a = type == "both"
? cXmlChoice.concat(cXmlSelect)
: (type == "choice" ? cXmlChoice : cXmlSelect);
for (var x, o, i = 0; i < a.length; i++) {
o     = a[i].o;
xpath = a[i].xpath;
o.load((xpath && xmlNode)
? xmlNode.selectSingleNode(xpath)
: xmlNode);
if (xmlNode && o.disabled && o.createModel)
o.enable();
}
if (!cXmlOnLoad) return;
for (var i = 0; i < cXmlOnLoad.length; i++)
cXmlOnLoad[i][0].load(cXmlOnLoad[i][1]
? this.xmlRoot.selectSingleNode(cXmlOnLoad[i][1])
: this.selected);
cXmlOnLoad = null;
};
this.importConnections = function(x){
cXmlSelect = x;
};
this.getConnections = function(){
return cXmlSelect;
};
this.removeConnections = function(){
cXmlSelect = [];
};
this.applyRuleSetOnNode = function(setname, cnode, def){
if (!cnode) return "";
var rules = typeof setname == "string"
? (this.bindingRules || {})[setname]
: setname;
if (!rules) {
if (setname == "value") setname = "valuerule";
return typeof this[setname] == "string" && setname != "value"
&& jpf.getXmlValue(cnode, this[setname])
|| def && cnode.selectSingleNode(def) || false;
}
for (var node = null, i = 0; i < rules.length; i++) {
var sel = jpf.parseExpression(rules[i].getAttribute("select")) || ".";
var o = cnode.selectSingleNode(sel);
if (o) {
this.lastRule = rules[i];
if (rules[i].getAttribute("rpc"))
return rules[i];
else if(rules[i].getAttribute("value")){ 
return rules[i].getAttribute("value");
}
else if(rules[i].childNodes.length) {
var xsltNode;
if (rules[i].getAttribute("cacheId")) {
xsltNode = jpf.nameserver.get("xslt",
rules[i].getAttribute("cacheId"));
}
else {
var prefix = jpf.findPrefix(rules[i], jpf.ns.xslt);
var xsltNode;
if (rules[i].getElementsByTagNameNS) {
xsltNode = rules[i].getElementsByTagNameNS(jpf.ns.xslt, "*")[0];
}
else {
var prefix = jpf.findPrefix(rules[i], jpf.ns.xslt, true);
if (prefix) {
if (!jpf.supportNamespaces)
rules[i].ownerDocument.setProperty("SelectionNamespaces", "xmlns:"
+ prefix + "='" + jpf.ns.xslt + "'");
xsltNode = rules[i].selectSingleNode(prefix + ":*");
}
}
if (xsltNode) {
if (xsltNode[jpf.TAGNAME] != "stylesheet") {
var baseXslt = jpf.nameserver.get("base", "xslt");
if (!baseXslt) {
baseXslt = jpf.getXmlDom(
'<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="node()"></xsl:template></xsl:stylesheet>')
.documentElement;
jpf.nameserver.register("base", "xslt", xsltNode);
}
var xsltNode = baseXslt.cloneNode(true);
for (var j = rules[i].childNodes.length; j >= 0; j++)
xsltNode.firstChild.appendChild(rules[i].childNodes[j]);
rules[i].setAttribute("cacheId",
jpf.nameserver.add("xslt", xsltNode));
}
}
}
if (xsltNode) {
var x = o.transformNode(xsltNode)
.replace(/^<\?xml version="1\.0" encoding="UTF-16"\?>/, "")
.replace(/\&lt\;/g, "<").replace(/\&gt\;/g, ">")
.replace(/\&amp\;/g, "&");
}
else {
var x = jpf.JsltInstance.apply(rules[i], o);
}
return rules[i].getAttribute("method") ? self[rules[i].getAttribute("method")](x, this) : x;
}
else if(rules[i].getAttribute("method")){
if(!self[rules[i].getAttribute("method")]){
return false;
}
return self[rules[i].getAttribute("method")](o, this);
}
else if(rules[i].getAttribute("eval")){
var func = new Function('xmlNode', 'control', "return " + rules[i].getAttribute("eval"));
var value = func.call(this, o, this);
if (!value) continue;
return value;
}
else {
if (o.nodeType == 1) {
if (!o.firstChild || o.firstChild.nodeType == 1 || o.firstChild.nodeType > 4)
return "";
o = o.firstChild;
}
var value;
if (o.nodeType == 2) {
try {
value = decodeURI(o.nodeValue);
}
catch(e) {
value = o.nodeValue;
}
value = unescape(value);
}
else
value = o.nodeValue;
if (rules[i].getAttribute("mask")) {
if (value.match(/^(?:true|false)$/))
value = value=="true"?1:0;
return rules[i].getAttribute("mask").split(";")[value];
}
else
return value;
}
}
}
return false;
};
this.setSmartBinding = function(sb){
this.$propHandlers["smartbinding"].call(this, sb);
};
this.removeSmartBinding = function(){
this.setProperty("smartbinding", null);
};
this.getSmartBinding = function(){
return this.smartBinding;
};
this.getModel = function(doRecur){
if(doRecur && !this.$model)
return this.dataParent ? this.dataParent.parent.getModel(true) : null;
return this.$model;
};
this.setModel = function(model, xpath){
if (this.$model)
this.$model.unregister(this);
if (typeof model == "string")
model = jpf.nameserver.get("model", model);
this.$model = model;
model.register(this, xpath);
};
this.getNodeFromRule = function(setname, cnode, isAction, getRule, createNode){
var rules = ((isAction ? this.actionRules : this.bindingRules) || {})[setname];
if (!rules) {
if (setname == "value") setname = "valuerule";
if (!isAction && !getRule && typeof this[setname] == "string") {
return cnode.selectSingleNode(this[setname]) || (createNode
? jpf.xmldb.createNodeFromXpath(cnode, this[setname])
: false);
}
return false;
}
for(var i = 0; i < rules.length; i++) {
if (!rules[i]) continue;
var sel = jpf.parseExpression(rules[i].getAttribute("select")) || ".";
if (!sel)
return getRule ? rules[i] : false;
if (!cnode) return false;
var o = cnode.selectSingleNode(sel);
if (o)
return getRule ? rules[i] : o;
if (createNode || rules[i].getAttribute("create") == "true") {
var o = jpf.xmldb.createNodeFromXpath(cnode, sel);
return getRule ? rules[i] : o;
}
}
return false;
};
this.getSelectFromRule = function(setname, cnode){
var rules = this.bindingRules && this.bindingRules[setname];
if (!rules || !rules.length) {
if (setname == "value") setname = "valuerule";
return typeof this[setname] == "string" && [this[setname]] || ["."];
}
for (var first, i = 0; i < rules.length; i++) {
var sel = jpf.parseExpression(rules[i].getAttribute("select")) || ".";
if (!cnode) return [sel];
if (i == 0)
first = sel;
var o = cnode.selectSingleNode(sel);
if (o)
return [sel, o];
}
return [first];
};
this.reload = function(){
var sb = this.getSmartBinding();
if (sb && sb.$isMarkedForUpdate(this)) {
sb.$updateMarkedItems();
}
else
this.load(this.xmlRoot, this.cacheID, true);
};
this.load = function(xmlRootNode, cacheID, forceNoCache, noClearMsg){
if (jpf.popup.isShowing(this.uniqueId))
jpf.popup.forceHide(); 
if ((!this.bindingRules && this.$jml
&& (!this.smartBinding || jpf.JmlParser.stackHasBindings(this.uniqueId))
&& !this.traverse) || (this.$canLoadData && !this.$canLoadData())) {
return loadqueue = [xmlRootNode, cacheID];
}
if (xmlRootNode)
xmlRootNode = jpf.xmldb.getBindXmlNode(xmlRootNode);
if (this.dataParent && this.dataParent.xpath)
this.dataParent.parent.signalXmlUpdate[this.uniqueId] = !xmlRootNode;
if (!xmlRootNode && (!cacheID || !this.isCached(cacheID))) {
this.clear(noClearMsg, true);
if (jpf.appsettings.autoDisable && !this.createModel)
this.disable();
this.setConnections();
return;
}
var disabled = this.disabled;
this.disabled = false;
if (this.$listenRoot) {
jpf.xmldb.removeNodeListener(this.$listenRoot, this);
this.$listenRoot = null;
}
if (this.dispatchEvent("beforeload", {xmlNode : xmlRootNode}) === false)
return false;
if (this.caching && !forceNoCache && xmlRootNode && xmlRootNode == this.xmlRoot)
return;
if (!cacheID) {
cacheID = xmlRootNode.getAttribute(jpf.xmldb.xmlIdTag) ||
jpf.xmldb.nodeConnect(jpf.xmldb.getXmlDocId(xmlRootNode), xmlRootNode);
}
if (this.$removeClearMessage)
this.$removeClearMessage();
var fromCache;
if (this.caching && !forceNoCache && (fromCache = this.getCache(cacheID, xmlRootNode))) {
if (fromCache == -1)
return;
if (!this.hasFeature(__MULTISELECT__))
this.setConnections(this.xmlRoot, "select");
else {
var nodes = this.getTraverseNodes();
if (nodes.length && this.autoselect)
this.select(nodes[0], null, null, null, true);
else
this.setConnections();
if (!nodes.length)
this.$setClearMessage(this.emptyMsg, "empty");
}
if (this.hasFeature(__MULTISELECT__) && nodes.length != this.length)
this.setProperty("length", nodes.length);
this.dispatchEvent('afterload', {XMLRoot : xmlRootNode});
return;
}
else
this.clear(true);
this.documentId = jpf.xmldb.getXmlDocId(xmlRootNode);
this.cacheID    = cacheID;
this.xmlRoot    = xmlRootNode;
this.$load(xmlRootNode);
this.$loadSubData(xmlRootNode);
if (!this.createModel) {
this.disabled = true;
this.enable();
}
else
this.disabled = disabled;
if (!this.hasFeature(__MULTISELECT__))
this.setConnections(this.xmlRoot);
this.dispatchEvent('afterload', {XMLRoot : xmlRootNode});
};
this.$loadSubData = function(xmlRootNode){
if (this.hasLoadStatus(xmlRootNode)) return;
var loadNode, rule = this.getNodeFromRule("load", xmlRootNode, false, true);
var sel = (rule && rule.getAttribute("select"))
? rule.getAttribute("select")
: ".";
if (rule && (loadNode = xmlRootNode.selectSingleNode(sel))) {
this.setLoadStatus(xmlRootNode, "loading");
if (this.$setClearMessage)
this.$setClearMessage(this.loadingMsg, "loading");
var mdl = this.getModel(true);
var jmlNode = this;
if (mdl.insertFrom(rule.getAttribute("get"), loadNode, {
insertPoint : xmlRootNode, 
jmlNode     : this
}, function(){
jmlNode.setConnections(xmlRootNode);
}) === false
) {
this.clear(true);
if (jpf.appsettings.autoDisable)
this.disable();
this.setConnections(null, "select"); 
}
}
};
this.setLoadStatus = function(xmlNode, state, remove){
var ostatus = xmlNode.getAttribute("j_loaded");
ostatus = ostatus
? ostatus.replace(new RegExp("\\|\\w+\\:" + this.uniqueId + "\\|", "g"), "")
: "";
if (!remove)
ostatus += "|" + state + ":" + this.uniqueId + "|";
xmlNode.setAttribute("j_loaded", ostatus);
};
this.removeLoadStatus = function(xmlNode){
this.setLoadStatus(xmlNode, null, true);
};
this.hasLoadStatus = function(xmlNode, state){
var ostatus = xmlNode.getAttribute("j_loaded");
if (!ostatus) return false;
return (ostatus.indexOf((state || "") + ":" + this.uniqueId + "|") != -1)
};
this.insert = function(XMLRoot, parentXMLElement, options){
if (typeof XMLRoot != "object")
XMLRoot = jpf.getXmlDom(XMLRoot).documentElement;
if (!parentXMLElement)
parentXMLElement = this.xmlRoot;
if (this.dispatchEvent("beforeinsert", {xmlParentNode : parentXMLElement}) === false)
return false;
var newNode = jpf.xmldb.integrate(XMLRoot, parentXMLElement,
jpf.extend(options, {copyAttributes: true}));
jpf.xmldb.applyChanges("insert", parentXMLElement);
if (this.selectable && this.autoselect) {
if (this.xmlRoot == newNode)
this.$selectDefault(this.xmlRoot);
}
else if (this.xmlRoot == newNode)
this.setConnections(this.xmlRoot, "select");
if (this.hasLoadStatus(parentXMLElement, "loading"))
this.setLoadStatus(parentXMLElement, "loaded");
this.dispatchEvent("afterinsert");
};
this.inherit(this.hasFeature(__MULTISELECT__)
? jpf.MultiselectBinding
: jpf.StandardBinding);
function findModel(x, isSelection) {
return x.getAttribute((isSelection
? "ref"
: "") + "model") || jpf.xmldb.getInheritedAttribute(x, null,
function(xmlNode){
if (isSelection && x == xmlNode)
return false;
if (xmlNode.getAttribute("model")) {
return xmlNode.getAttribute("model");
}
if (xmlNode.getAttribute("smartbinding")) {
var bclass = x.getAttribute("smartbinding").split(" ")[0];
if (jpf.nameserver.get("model", bclass))
return bclass + ":select";
}
return false
});
}
var initModelId = [];
this.$addJmlLoader(function(x){
if (initModelId[0])
jpf.setModel(initModelId[0], this);
if (initModelId[1])
jpf.setModel(initModelId[1], this, true);
var hasModel = initModelId.length;
if ((!this.ref || this.hasFeature(__MULTISELECT__)) && !this.xmlRoot) {
var sb = jpf.JmlParser.sbInit[this.uniqueId]
&& jpf.JmlParser.sbInit[this.uniqueId][0];
if (this.traverse && (sb && !sb.model
|| !sb && this.hasFeature(__MULTISELECT__))
|| !initModelId[0] && sb) {
initModelId = findModel(x);
if (initModelId) {
if (!sb)
this.smartBinding = true; 
jpf.setModel(initModelId, this, 0);
}
}
}
initModelId = null;
if (this.hasFeature(__MULTISELECT__) || this.$hasStateMessages) {
var defProps = ["empty-message", "loading-message", "offline-message"];
for (var i = 0, l = defProps.length; i < l; i++) {
if (!x.getAttribute(defProps[i]))
this.$propHandlers[defProps[i]].call(this);
}
}
if (!x.getAttribute("create-model"))
this.$propHandlers["create-model"].call(this);
var hasInitSb = jpf.JmlParser.sbInit[this.uniqueId] ? true : false;
if ((!hasInitSb || !hasModel) && this.$setClearMessage
&& (!loadqueue && !this.xmlRoot && (this.hasFeature(__MULTISELECT__)
|| this.ref || hasInitSb)))
this.$setClearMessage(this.emptyMsg, "empty");
});
this.$jmlDestroyers.push(function(){
if (this.dataParent)
this.dataParent.parent.disconnect(this);
if (this.hasFeature(__DATABINDING__)) {
this.unloadBindings();
this.unloadActions();
}
});
this.$booleanProperties["render-root"] = true;
this.$supportedProperties.push("empty-message", "loading-message",
"offline-message", "render-root", "smartbinding", "create-model",
"bindings", "actions", "dragdrop");
this.$propHandlers["render-root"] = function(value){
this.renderRoot = value;
}
this.$propHandlers["empty-message"] = function(value){
this.emptyMsg = value
|| jpf.xmldb.getInheritedAttribute(this.$jml, "empty-message")
|| "No items";
if (!jpf.isParsing) 
this.$updateClearMessage(this.emptyMsg, "empty");
};
this.$propHandlers["loading-message"] = function(value){
this.loadingMsg = value
|| jpf.xmldb.getInheritedAttribute(this.$jml, "loading-message")
|| "Loading...";
if (!jpf.isParsing)
this.$updateClearMessage(this.loadingMsg, "loading");
};
this.$propHandlers["offline-message"] = function(value){
this.offlineMsg = value
|| jpf.xmldb.getInheritedAttribute(this.$jml, "offline-message")
|| "You are currently offline...";
if (!jpf.isParsing)
this.$updateClearMessage(this.offlineMsg, "offline");
};
this.$propHandlers["create-model"] = function(value){
this.createModel = !jpf.isFalse(
jpf.xmldb.getInheritedAttribute(this.$jml, "create-model"));
var mb;
if (this.getMultibinding && (mb = this.getMultibinding()))
mb.createModel = this.createModel;
};
this.$propHandlers["smartbinding"] = function(value, forceInit){
var sb;
if (value && typeof value == "string") {
sb = jpf.JmlParser.getSmartBinding(value);
}
else
sb = value;
if (this.smartBinding && this.smartBinding.deinitialize)
this.smartBinding.deinitialize(this)
if (jpf.isParsing) {
if (forceInit === true)
return (this.smartBinding = sb.initialize(this));
return jpf.JmlParser.addToSbStack(this.uniqueId, sb);
}
return (this.smartBinding = sb.markForUpdate(this));
};
this.$propHandlers["bindings"] = function(value){
var sb = this.smartBinding || (jpf.isParsing
? jpf.JmlParser.getFromSbStack(this.uniqueId)
: this.$propHandlers["smartbinding"].call(this, new jpf.smartbinding()));
if (!value) {
throw new Error("Not Implemented"); 
return;
}
sb.addBindings(jpf.nameserver.get("bindings", value));
};
this.$propHandlers["actions"] = function(value){
var sb = this.smartBinding || (jpf.isParsing
? jpf.JmlParser.getFromSbStack(this.uniqueId)
: this.$propHandlers["smartbinding"].call(this, new jpf.smartbinding()));
if (!value) {
throw new Error("Not Implemented"); 
return;
}
sb.addActions(jpf.nameserver.get("actions", value));
};
function refModelPropSet(strBindRef){
var isSelection = this.hasFeature(__MULTISELECT__) ? 1 : 0;
var o = isSelection
? this.$getMultiBind()
: this;
var sb = hasRefBinding && o.smartBinding || (jpf.isParsing
? jpf.JmlParser.getFromSbStack(this.uniqueId, isSelection, true)
: this.$propHandlers["smartbinding"].call(this, new jpf.smartbinding()))
if (!hasRefBinding) {
if (o.bindingRules)
o.unloadBindings();
o.bindingRules = {};
}
var bindRule = (o.bindingRules[o.mainBind] ||
(o.bindingRules[o.mainBind]
= [jpf.getXml("<" + (o.mainBind || "value") + " />")]))[0];
((sb.bindings || (sb.bindings = o.bindingRules))[o.mainBind])
|| (sb.bindings[o.mainBind] = [bindRule]);
var model, modelId;
if (!jpf.isParsing)
model = o.getModel();
if (!model) {
modelId = o.lastModelId =
o.model || findModel(this.$jml, isSelection);
if (!modelId) {
if (jpf.globalModel) {
modelId = "@default";
}
}
}
strBindRef.match(/^(.*?)((?:\@[\w-_\:]+|text\(\))(\[.*?\])?|[\w-_\:]+\[.*?\])?$/);
var valuePath   = RegExp.$1;
var valueSelect = RegExp.$2 || ".";
if (valuePath === null) {
return;
}
if (modelId) {
if (modelId == "@default") {
valueSelect = strBindRef;
}
else if (valuePath) {
var modelIdParts = modelId.split(":", 3);
modelId = modelIdParts.shift();
if (modelId.indexOf("#") == 0) {
modelId += (modelIdParts[0]
? ":" + modelIdParts.shift()
: ":select")
}
modelId += ":" + ((modelIdParts[0] ? modelIdParts[0] + "/" : "")
+ (valuePath || "."))
.replace(/\/$/, "")
.replace(/\/\/+/, "/");
}
if (jpf.isParsing && initModelId)
initModelId[isSelection] = modelId
else
setModelQueue(modelId, isSelection);
}
else {
var m = (o.lastModelId || "").split(":");
var modelIdPart = ((m.shift().indexOf("#") == 0
&&  m.shift() && m.shift() || m.shift()) || "");
model.$register(this, ((modelIdPart ? modelIdPart + "/" : "")
+ (valuePath || "."))
.replace(/\/$/, "")
.replace(/\/\/+/, "/")); 
sb.markForUpdate(this, "model");
}
bindRule.setAttribute("select", valueSelect);
}
var timer = [];
function setModelQueue(modelId, isSelection){
clearTimeout(timer[isSelection ? 1 : 0]);
timer[isSelection ? 1 : 0] = setTimeout(function(){
jpf.setModel(modelId, _self, isSelection);
});
}
this.$propHandlers["model"] = function(value){
if (!value) {
this.clear();
this.$model.unregister(this);
this.$model = null;
this.lastModelId = "";
return;
}
this.lastModelId = value;
if (!this.hasFeature(__MULTISELECT__)) {
if (jpf.isParsing && this.$jml.getAttribute("ref")) 
return; 
if (this.ref) {
refModelPropSet.call(this, this.ref);
return;
}
}
if (jpf.isParsing)
initModelId[0] = value;
else
setModelQueue(value, this.hasFeature(__MULTISELECT__));
};
var hasRefBinding;
this.$propHandlers["ref"] = function(value){
if (!value) {
this.unloadBindings();
hasRefBinding = false;
return;
}
refModelPropSet.call(this, value);
hasRefBinding = value ? true : false;
};
};
jpf.StandardBinding = function(){
if (!this.defaultValue) 
this.defaultValue = "";
this.$load = function(XMLRoot){
jpf.xmldb.addNodeListener(XMLRoot, this);
var lrule, rule;
for (rule in this.bindingRules) {
lrule = rule.toLowerCase();
if (this.$supportedProperties.contains(lrule))
this.setProperty(lrule, this.applyRuleSetOnNode(rule,
this.xmlRoot) || "", null, true);
}
if (this.errBox && this.isValid())
this.clearError();
};
this.$xmlUpdate = function(action, xmlNode, listenNode, UndoObj){
if (action == "redo-remove") {
var testNode = this.xmlRoot;
while (testNode && testNode.nodeType != 9)
testNode = testNode.parentNode;
if (!testNode) {
var model = this.getModel(true);
if (!model)
return;
return model.loadInJmlNode(this, model.getXpathByJmlNode(this));
}
}
if (UndoObj && !UndoObj.xmlNode)
UndoObj.xmlNode = this.xmlRoot;
var lrule, rule;
for (rule in this.bindingRules) {
lrule = rule.toLowerCase();
if (this.$supportedProperties.contains(lrule)) {
var value = this.applyRuleSetOnNode(rule, this.xmlRoot) || "";
if (this[lrule] != value)
this.setProperty(lrule, value, null, true);
}
}
if (this.errBox && this.isValid())
this.clearError();
};
if (!this.clear) {
this.clear = function(nomsg, do_event){
this.documentId = this.xmlRoot = this.cacheID = null;
if (this.$clear)
this.$clear(nomsg, do_event);
};
}
};
jpf.MultiselectBinding = function(){
this.length = 0;
this.parseTraverse = function (xmlNode){
this.traverse = xmlNode.getAttribute("select");
this.$sort = xmlNode.getAttribute("sort") ? new jpf.Sort(xmlNode) : null;
};
this.resort = function(options, clear, noReload){
if (!this.$sort)
this.$sort = new jpf.Sort();
this.$sort.set(options, clear);
this.clearAllCache();
if (noReload)
return;
(function sortNodes(xmlNode, htmlParent) {
var sNodes = _self.$sort.apply(
jpf.xmldb.getArrayFromNodelist(xmlNode.selectNodes(_self.traverse)));
for (var i = 0; i < sNodes.length; i++) {
if (_self.isTreeArch || _self.$withContainer){
var htmlNode = jpf.xmldb.findHTMLNode(sNodes[i], _self);
var container = _self.$findContainer(htmlNode);
htmlParent.appendChild(htmlNode);
if (!jpf.xmldb.isChildOf(htmlNode, container, true))
htmlParent.appendChild(container);
sortNodes(sNodes[i], container);
}
else
htmlParent.appendChild(jpf.xmldb.findHTMLNode(sNodes[i], _self));
}
})(this.xmlRoot, this.oInt);
return options;
};
this.toggleSortOrder = function(){
return this.resort({"ascending" : !this.$sort.get().ascending}).ascending;
};
this.getSortSettings = function(){
return this.$sort.get();
};
this.getTraverseNodes = function(xmlNode){
if (this.$sort) {
var nodes = jpf.xmldb.getArrayFromNodelist((xmlNode || this.xmlRoot)
.selectNodes(this.traverse));
return this.$sort.apply(nodes);
}
return (xmlNode || this.xmlRoot).selectNodes(this.traverse);
};
this.getFirstTraverseNode = function(xmlNode){
if (this.$sort) {
var nodes = jpf.xmldb.getArrayFromNodelist((xmlNode || this.xmlRoot)
.selectNodes(this.traverse));
return this.$sort.apply(nodes)[0];
}
return (xmlNode || this.xmlRoot).selectSingleNode(this.traverse);
};
this.getLastTraverseNode = function(xmlNode){
var nodes = this.getTraverseNodes(xmlNode || this.xmlRoot);
return nodes[nodes.length-1];
};
this.isTraverseNode = function(xmlNode){
var nodes = this.getTraverseNodes(this.isTreeArch
? this.getTraverseParent(xmlNode) || this.xmlRoot
: this.xmlRoot);
for (var i = 0; i < nodes.length; i++)
if (nodes[i] == xmlNode)
return true;
return false;
};
this.getNextTraverseSelected = function(xmlNode, up, count){
if (!xmlNode)
xmlNode = this.selected;
if (!count)
count = 1;
var i = 0;
var nodes = this.getTraverseNodes(this.getTraverseParent(xmlNode) || this.xmlRoot);
while (nodes[i] && nodes[i] != xmlNode)
i++;
var node = (up == null)
? nodes[i + count] || nodes[i - count]
: (up ? nodes[i + count] : nodes[i - count]);
return node || arguments[2] && (i < count || (i + 1) > Math.floor(nodes.length / count) * count)
? node
: (up ? nodes[nodes.length-1] : nodes[0]);
};
this.getNextTraverse = function(xmlNode, up, count){
if (!count)
count = 1;
if (!xmlNode)
xmlNode = this.selected;
var i = 0;
var nodes = this.getTraverseNodes(this.getTraverseParent(xmlNode) || this.xmlRoot);
while (nodes[i] && nodes[i] != xmlNode)
i++;
return nodes[i + (up ? -1 * count : count)];
};
this.getTraverseParent = function(xmlNode){
if (!xmlNode.parentNode || xmlNode == this.xmlRoot) return false;
var x, id = xmlNode.getAttribute(jpf.xmldb.xmlIdTag);
if (!id) {
xmlNode.setAttribute(jpf.xmldb.xmlIdTag, "temp");
id = "temp";
}
if (jpf.isSafari) {
var y = this.traverse.split("\|");
for (var i = 0; i < y.length; i++) {
x = xmlNode.selectSingleNode("ancestor::node()[("
+ y[i] + "/@" + jpf.xmldb.xmlIdTag + "='" + id + "')]");
break;
}
} else {
x = xmlNode.selectSingleNode("ancestor::node()[(("
+ this.traverse + ")/@" + jpf.xmldb.xmlIdTag + ")='"
+ id + "']");
}
if (id == "temp")
xmlNode.removeAttribute(jpf.xmldb.xmlIdTag);
return x;
};
this.$load = function(XMLRoot){
jpf.xmldb.addNodeListener(XMLRoot, this);
var length = this.getTraverseNodes(XMLRoot).length;
if (!this.renderRoot && !length)
return this.clearAllTraverse();
var nodes = this.$addNodes(XMLRoot, null, null, this.renderRoot);
this.$fill(nodes);
if (this.selectable) {
if (this.autoselect) {
if (this.renderRoot)
this.select(XMLRoot);
else if (nodes.length)
this.$selectDefault(XMLRoot);
else
this.setConnections();
}
else {
this.clearSelection(null, true);
var xmlNode = this.renderRoot
? this.xmlRoot
: this.getFirstTraverseNode(); 
if (xmlNode)
this.setIndicator(xmlNode);
this.setConnections(null, "both");
}
}
if (this.focussable)
jpf.window.focussed == this ? this.$focus() : this.$blur();
if (length != this.length)
this.setProperty("length", length);
};
var selectTimer = {}, _self = this;
var actionFeature = {
"insert"      : 127,
"add"         : 123,
"remove"      : 47, 
"redo-remove" : 79, 
"synchronize" : 127,
"move-away"   : 105,
"move"        : 77  
};
this.$xmlUpdate = function(action, xmlNode, listenNode, UndoObj, lastParent){
if (!this.xmlRoot)
return; 
var result, startNode = xmlNode, length;
if (!listenNode)
listenNode = this.xmlRoot;
if (action == "redo-remove") {
lastParent.appendChild(xmlNode); 
var traverseNode = this.isTraverseNode(xmlNode);
lastParent.removeChild(xmlNode);
if (!traverseNode)
xmlNode = lastParent;
}
do {
if (action == "add" && this.isTraverseNode(xmlNode)
&& startNode == xmlNode)
break; 
if (xmlNode.getAttribute(jpf.xmldb.xmlIdTag)) {
var htmlNode = this.getNodeFromCache(
xmlNode.getAttribute(jpf.xmldb.xmlIdTag)
+ "|" + this.uniqueId);
if (htmlNode
&& (startNode != xmlNode || xmlNode == this.xmlRoot)
&& actionFeature[action] & 1)
action = "update";
if (xmlNode == listenNode) {
if (xmlNode == this.xmlRoot && action != "insert")
return;
break;
}
if (htmlNode && actionFeature[action] & 2
&& !this.isTraverseNode(xmlNode))
action = "remove"; 
if (!htmlNode && actionFeature[action] & 4
&& this.isTraverseNode(xmlNode)){
action = "add";
break;
}
if (htmlNode  || action == "move")
break;
}
else if (actionFeature[action] & 8 && this.isTraverseNode(xmlNode)){
action = "add";
break;
}
if (xmlNode == listenNode) break;
xmlNode = xmlNode.parentNode;
}
while(xmlNode && xmlNode.nodeType != 9);
var foundNode = xmlNode;
if (xmlNode && xmlNode.nodeType == 9)
xmlNode = startNode;
if (action == "replacechild"
&& (UndoObj ? UndoObj.args[0] == this.xmlRoot : !this.xmlRoot.parentNode)) {
return this.load(UndoObj ? UndoObj.args[1] : listenNode); 
}
if (UndoObj && xmlNode && !UndoObj.xmlNode)
UndoObj.xmlNode = xmlNode;
if (action == "move" && foundNode == startNode) {
var isInThis  = jpf.xmldb.isChildOf(this.xmlRoot, xmlNode.parentNode, true);
var wasInThis = jpf.xmldb.isChildOf(this.xmlRoot, UndoObj.extra.pNode, true);
if (isInThis && wasInThis)
this.$moveNode(xmlNode, htmlNode);
else if (isInThis) 
action = "add";
else if (wasInThis) 
action = "remove";
}
else if (action == "move-away") {
var goesToThis = jpf.xmldb.isChildOf(this.xmlRoot, UndoObj.extra.toPnode, true);
if (!goesToThis)
action = "remove";
}
if (this.$removeClearMessage && this.$setClearMessage) {
if (this.getFirstTraverseNode())
this.$removeClearMessage();
else
this.$setClearMessage(this.emptyMsg, "empty")
}
if (action == "insert" && (this.isTreeArch || xmlNode == this.xmlRoot)) {
if (this.hasLoadStatus(xmlNode) && this.$removeLoading)
this.$removeLoading(htmlNode);
if (this.oInt.firstChild && !jpf.xmldb.getNode(this.oInt.firstChild)) {
this.oInt.innerHTML = "";
if (!this.renderRoot) {
length = this.getTraverseNodes().length;
if (!length)
this.clearAllTraverse();
}
}
result = this.$addNodes(xmlNode, (this.$getParentNode
? this.$getParentNode(htmlNode)
: htmlNode), true, false);
this.$fill(result);
if (this.selectable && (length === 0 || !this.xmlRoot.selectSingleNode(this.traverse)))
return;
}
else if (action == "add") {
var parentHTMLNode = xmlNode.parentNode == this.xmlRoot
? this.oInt
: this.getNodeFromCache(xmlNode.parentNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId); 
if (!parentHTMLNode)
parentHTMLNode = this.getCacheItem(xmlNode.parentNode.getAttribute(jpf.xmldb.xmlIdTag)
|| (xmlNode.parentNode.getAttribute(jpf.xmldb.xmlDocTag)
? "doc" + xmlNode.parentNode.getAttribute(jpf.xmldb.xmlDocTag)
: false))
|| this.oInt; 
if (parentHTMLNode || jpf.xmldb.isChildOf(this.xmlRoot, xmlNode)) {
parentHTMLNode = (this.$findContainer && parentHTMLNode
? this.$findContainer(parentHTMLNode)
: parentHTMLNode) || this.oInt;
result = this.$addNodes(xmlNode, parentHTMLNode, true, true,
this.getNodeByXml(this.getNextTraverse(xmlNode)));
if (parentHTMLNode)
this.$fill(result);
}
}
else if ((action == "remove") && (!xmlNode || foundNode == xmlNode && xmlNode.parentNode)) { 
if (!xmlNode)
return;
if (htmlNode)
this.$deInitNode(xmlNode, htmlNode);
else if (xmlNode == this.xmlRoot) {
return this.load(null, null, null,
!this.dataParent || !this.dataParent.autoselect);
}
}
else if (htmlNode) {
this.$updateNode(xmlNode, htmlNode);
if (action == "replacechild" && this.hasFeature(__MULTISELECT__)
&& this.selected && xmlNode.getAttribute(jpf.xmldb.xmlIdTag)
== this.selected.getAttribute(jpf.xmldb.xmlIdTag)) {
this.selected = xmlNode;
}
}
else if (action == "redo-remove") { 
var testNode = this.xmlRoot;
while (testNode && testNode.nodeType != 9)
testNode = testNode.parentNode;
if (!testNode) {
var model = this.getModel(true);
return model.loadInJmlNode(this, model.getXpathByJmlNode(this));
}
}
var pNode = xmlNode ? xmlNode.parentNode : lastParent;
if (this.isTreeArch && pNode && pNode.nodeType == 1) {
do {
var htmlNode = this.getNodeFromCache(pNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId);
if (htmlNode)
this.$updateNode(pNode, htmlNode);
}
while ((pNode = this.getTraverseParent(pNode)) && pNode.nodeType == 1);
}
if (actionFeature[action] & 32 && this.selectable
&& startNode == xmlNode
&& (action != "insert" || xmlNode == this.xmlRoot)) {
clearTimeout(selectTimer.timer);
if (action == "remove" && xmlNode == this.selected
|| xmlNode == selectTimer.nextNode)
selectTimer.nextNode = this.getDefaultNext(xmlNode);
selectTimer.timer = setTimeout(function(){
_self.$checkSelection(selectTimer.nextNode);
selectTimer.nextNode = null;
});
}
if (actionFeature[action] & 64) {
if (!length)
length = this.xmlRoot.selectNodes(this.traverse).length;
if (length != this.length)
this.setProperty("length", length);
}
if (this.signalXmlUpdate && actionFeature[action] & 16) {
var uniqueId;
for (uniqueId in this.signalXmlUpdate) {
if (parseInt(uniqueId) != uniqueId) continue; 
var o = jpf.lookup(uniqueId);
if (!this.selected) continue;
var xmlNode = this.selected.selectSingleNode(o.dataParent.xpath);
if (!xmlNode) continue;
o.load(xmlNode);
}
}
this.dispatchEvent("xmlupdate", {
action : action,
xmlNode: xmlNode,
result : result
});
};
this.$addNodes = function(xmlNode, parent, checkChildren, isChild, insertBefore){
var htmlNode, lastNode;
isChild          = (isChild && (this.renderRoot && xmlNode == this.xmlRoot
|| this.isTraverseNode(xmlNode)));
var nodes        = isChild ? [xmlNode] : this.getTraverseNodes(xmlNode);
var loadChildren = nodes.length && (this.bindingRules || {})["insert"]
? this.applyRuleSetOnNode("insert", xmlNode)
: false;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1) continue;
if (checkChildren)
htmlNode = this.getNodeFromCache(nodes[i].getAttribute(jpf.xmldb.xmlIdTag)
+ "|" + this.uniqueId);
if (!htmlNode) {
var Lid = jpf.xmldb.nodeConnect(this.documentId, nodes[i], null, this);
var beforeNode = isChild ? insertBefore : (lastNode ? lastNode.nextSibling : null);
var parentNode = this.$add(nodes[i], Lid, isChild ? xmlNode.parentNode : xmlNode,
beforeNode ? parent || this.oInt : parent, beforeNode,
!beforeNode && i==nodes.length-1);
if (parentNode === false) {
for (var i = i; i < nodes.length; i++)
jpf.xmldb.nodeConnect(this.documentId, nodes[i],
null, this);
break;
}
}
if (checkChildren)
lastNode = htmlNode;
}
return nodes;
};
this.addEventListener("beforeselect", function(e){
var combinedvalue = null;
if (this.indicator == this.selected || e.list && e.list.length > 1
&& this.getConnections().length) {
if (e.list && e.list.length > 1 && this.getConnections().length) {
var oEl  = this.xmlRoot.ownerDocument.createElement(this.selected.tagName);
var attr = {};
var nodes = e.list[0].attributes;
for (var j = 0; j < nodes.length; j++)
attr[nodes[j].nodeName] = nodes[j].nodeValue;
for (var i = 1; i < e.list.length; i++) {
for (prop in attr) {
if (typeof attr[prop] != "string") continue;
if (!e.list[i].getAttributeNode(prop))
attr[prop] = undefined;
else if(e.list[i].getAttribute(prop) != attr[prop])
attr[prop] = "";
}
}
for (prop in attr) {
if (typeof attr[prop] != "string") continue;
oEl.setAttribute(prop, attr[prop]);
}
oEl.setAttribute(jpf.xmldb.xmlIdTag, this.uniqueId);
jpf.MultiSelectServer.register(oEl.getAttribute(jpf.xmldb.xmlIdTag),
oEl, e.list, this);
jpf.xmldb.addNodeListener(oEl, jpf.MultiSelectServer);
combinedvalue = oEl;
}
}
var jNode = this;
setTimeout(function(){
jNode.setConnections(combinedvalue || jNode.selected);
}, 10);
});
this.addEventListener("afterdeselect", function(){
var _self = this;
setTimeout(function(){
_self.setConnections(null);
}, 10);
});
this.$loadInlineData = function(x){
if (!$xmlns(x, "item", jpf.ns.jml).length)
return jpf.JmlParser.parseChildren(x, null, this);
var parent = x;
var prefix = jpf.findPrefix(x, jpf.ns.jml);
x.ownerDocument.setProperty("SelectionNamespaces", "xmlns:"
+ prefix + "='" + jpf.ns.jpf + "'");
this.icon      = "@icon";
this.image     = "@image";
this.caption   = "label/text()|text()|@caption";
this.valuerule = "value/text()|@value|text()";
this.traverse  = prefix + ":item";
this.load(x);
};
var timer;
this.$handleBindingRule = function(value, f, prop){
if (!value)
this[prop] = null;
if (this.xmlRoot && !timer && !jpf.isParsing) {
timer = setTimeout(function(){
_self.reload();
timer = null;
});
}
};
this.$propHandlers["traverse"] =
this.$propHandlers["caption"]  =
this.$propHandlers["valuerule"]  =
this.$propHandlers["icon"]     =
this.$propHandlers["tooltip"]  =
this.$propHandlers["select"]   = this.$handleBindingRule;
};
var __VIRTUALVIEWPORT__ = 1 << 19;
var __PRESENTATION__ = 1 << 9;
jpf.skins = {
skins  : {},
css    : [],
events : ["onmousemove", "onmousedown", "onmouseup", "onmouseout",
"onclick", "ondragmove", "ondragstart"],
Init: function(xmlNode, refNode, path){
var name      = (refNode ? refNode.getAttribute("id") : null)
|| xmlNode.getAttribute("id");
var base      = (refNode ? refNode.getAttribute("src").match(/\//) || path : "")
? (path || refNode.getAttribute("src")).replace(/\/[^\/]*$/, "") + "/"
: "";
var mediaPath = (xmlNode.getAttribute("media-path")
? jpf.getAbsolutePath(base || jpf.hostPath, xmlNode.getAttribute("media-path"))
: (refNode ? refNode.getAttribute("media-path") : null));
var iconPath  = (xmlNode.getAttribute("icon-path")
? jpf.getAbsolutePath(base || jpf.hostPath, xmlNode.getAttribute("icon-path"))
: (refNode ? refNode.getAttribute("icon-path") : null));
if (!name)
name = "default";
if (xmlNode.getAttribute("id"))
document.body.className += " " + xmlNode.getAttribute("id");
if (!this.skins[name] || name == "default") {
this.skins[name] = {
base     : base,
name     : name,
iconPath : (iconPath === null)  ? "icons/" : iconPath,
mediaPath: (mediaPath === null) ? "images/" : mediaPath,
templates: {},
originals: {},
xml      : xmlNode
}
}
if (!this.skins["default"])
this.skins["default"] = this.skins[name];
var nodes = xmlNode.childNodes;
for (var i = nodes.length - 1; i >= 0; i--) {
if (nodes[i].nodeType != 1)
continue;
this.skins[name].templates[nodes[i].getAttribute("name")] = nodes[i];
if (nodes[i].ownerDocument)
this.importSkinDef(nodes[i], base, name);
}
this.purgeCss(mediaPath || base + "images/", iconPath || base + "icons/");
},
loadStylesheet: function(filename, title){
with (o = document.getElementsByTagName("head")[0].appendChild(document.createElement("LINK"))) {
rel   = "stylesheet";
type  = "text/css";
href  = filename;
title = title;
}
return o;
},
importSkinDef: function(xmlNode, basepath, name){
var i, l, nodes = $xmlns(xmlNode, "style", jpf.ns.jml), tnode, node;
for (i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
if (node.getAttribute("src"))
this.loadStylesheet(node.getAttribute("src").replace(/src/, basepath + "/src"));
else {
var test = true;
if (node.getAttribute("condition")) {
try {
test = eval(node.getAttribute("condition"));
}
catch (e) {
test = false;
}
}
if (test) {
tnode = node.firstChild;
while (tnode) {
this.css.push(tnode.nodeValue);
tnode = tnode.nextSibling;
}
}
}
}
nodes = $xmlns(xmlNode, "alias", jpf.ns.jpf);
for (i = 0; i < nodes.length; i++) {
if (!nodes[i].firstChild)
continue;
this.skins[name].templates[nodes[i].firstChild.nodeValue.toLowerCase()] = xmlNode;
}
},
loadedCss : "",
purgeCss: function(imagepath, iconpath){
if (!this.css.length)
return;
var cssString = this.css.join("\n").replace(/images\//g, imagepath).replace(/icons\//g, iconpath);
jpf.importCssString(document, cssString);
this.css = [];
},
loadCssInWindow : function(skinName, win, imagepath, iconpath){
this.css = [];
var name = skinName.split(":");
var skin = this.skins[name[0]];
var template = skin.templates[name[1]];
this.importSkinDef(template, skin.base, skin.name);
var cssString = this.css.join("\n").replace(/images\//g, imagepath).replace(/icons\//g, iconpath);
jpf.importCssString(win.document, cssString);
this.css = [];
},
setSkinPaths: function(skinName, jmlNode){
skinName = skinName.split(":");
var name = skinName[0];
var type = skinName[1];
jmlNode.iconPath  = this.skins[name].iconPath;
jmlNode.mediaPath = this.skins[name].mediaPath;
},
getTemplate: function(skinName, cJml){
skinName = skinName.split(":");
var name = skinName[0];
var type = skinName[1];
if (!this.skins[name].templates[type])
return false;
var skin      = this.skins[name].templates[type];
var originals = this.skins[name].originals[type];
if (!originals) {
originals = this.skins[name].originals[type] = {};
var nodes = $xmlns(skin, "presentation", jpf.ns.jml)[0].childNodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1) continue;
originals[nodes[i].baseName || nodes[i][jpf.TAGNAME]] = nodes[i];
}
}
return originals;
},
getCssString : function(skinName){
return jpf.getXmlValue($xmlns(this.skins[skinName.split(":")[0]].xml,
"style", jpf.ns.jml)[0], "text()");
},
changeSkinset : function(value){
var node = jpf.document.documentElement;
while (node) {
if (node && node.nodeFunc == jpf.NODE_VISIBLE
&& node.hasFeature(__PRESENTATION__) && !node.skinset) {
node.$propHandlers["skinset"].call(node, value);
node.skinset = null;
}
if (node.firstChild || node.nextSibling) {
node = node.firstChild || node.nextSibling;
}
else {
do {
node = node.parentNode;
} while (node && !node.nextSibling)
if (node)
node = node.nextSibling;
}
}
},
iconMaps : {},
addIconMap : function(options){
this.iconMaps[options.name] = options;
if (options.size)
options.width = options.height = options.size;
else {
if (!options.width)
options.width = 1;
if (!options.height)
options.height = 1;
}
},
setIcon : function(oHtml, strQuery, iconPath){
if (!strQuery) {
oHtml.style.backgroundImage = "";
return;
}
if (oHtml.tagName.toLowerCase() == "img") {
oHtml.setAttribute("src", strQuery
? (iconPath || "") + strQuery
: "");
return;
}
var parts = strQuery.split(":");
var map = this.iconMaps[parts[0]];
if (map) {
var left, top, coords = parts[1].split(",");
if (map.type == "vertical") {
left = (coords[1] || 0) * map.width;
top  = (coords[0] || 0) * map.height;
}
else {
left = (coords[0] || 0) * map.width;
top  = (coords[1] || 0) * map.height;
}
oHtml.style.backgroundImage = "url(" + (iconPath || "")
+ map.src + ")";
oHtml.style.backgroundPosition = ((-1 * left) - map.offset[0])
+ "px " + ((-1 * top) - map.offset[1]) + "px";
}
else
{
oHtml.style.backgroundImage = "url(" + (iconPath || "")
+ strQuery + ")";
}
}
};
jpf.Presentation = function(){
var pNodes, originalNodes;
this.$regbase = this.$regbase | __PRESENTATION__;
this.skinName = null;
var _self     = this;
var skinTimer;
this.$supportedProperties.push("skin");
this.$propHandlers["skinset"] =
this.$propHandlers["skin"] = function(value){
if (!this.$jmlLoaded) 
return;
if (!skinTimer) {
clearTimeout(skinTimer);
skinTimer = setTimeout(function(){
changeSkin.call(_self);
skinTimer = null;
});
}
}
this.$propHandlers["style"] = function(value){
if (!jpf.isParsing)
this.oExt.setAttribute("style", value);
}
var oldClass;
this.$propHandlers["class"] = function(value){
this.$setStyleClass(this.oExt, value, [oldClass || ""])
}
this.$forceSkinChange = function(skin, skinset){
changeSkin.call(this, skin, skinset);
}
function changeSkin(skin, skinset){
clearTimeout(skinTimer);
var skinName = (skinset || this.skinset || jpf.appsettings.skinset)
+ ":" + (skin || this.skin || this.tagName);
if (this.selectable)
var valueList = this.getSelection();
var oExt = this.oExt;
var beforeNode = oExt.nextSibling;
var id         = this.oExt.getAttribute("id");
var oldBase    = this.baseCSSname;
if (oExt.parentNode)
oExt.parentNode.removeChild(oExt);
if (this.$destroy)
this.$destroy(true);
this.$loadSkin(skinName);
this.$draw();
if (id)
this.oExt.setAttribute("id", id);
if (beforeNode)
this.oExt.parentNode.insertBefore(this.oExt, beforeNode);
var i, l, newclasses = [],
classes    = (oExt.className || "").splitSafe("\s+");
for (i = 0; i < classes; i++) {
if (classes[i] && classes[i] != oldBase)
newclasses.push(classes[i].replace(oldBase, this.baseCSSname));
}
jpf.setStyleClass(this.oExt, newclasses.join(" "));
var en, ev = jpf.skins.events;
for (i = 0, l = ev.length; i < l; i++) {
en = ev[i];
if (typeof oExt[en] == "function" && !this.oExt[en])
this.oExt[en] = oExt[en];
}
this.oExt.style.left     = oExt.style.left;
this.oExt.style.top      = oExt.style.top;
this.oExt.style.width    = oExt.style.width;
this.oExt.style.height   = oExt.style.height;
this.oExt.style.right    = oExt.style.right;
this.oExt.style.bottom   = oExt.style.bottom;
this.oExt.style.zIndex   = oExt.style.zIndex;
this.oExt.style.position = oExt.style.position;
this.oExt.style.display  = oExt.style.display;
if (this.$loadJml)
this.$loadJml(this.$jml);
if (this.disabled)
this.$disable();
if (this.$focussable && jpf.window.focussed == this)
this.$focus();
if (this.hasFeature(__DATABINDING__) && this.xmlRoot)
this.reload();
else
if (this.value)
this.$propHandlers["value"].call(this, this.value);
if (this.hasFeature(__MULTISELECT__)) {
if (this.selectable)
this.selectList(valueList, true);
}
if (this.draggable)
this.$propHandlers["draggable"].call(this, this.draggable);
if (this.resizable)
this.$propHandlers["resizable"].call(this, this.resizable);
if (this.$skinchange)
this.$skinchange();
};
this.$setStyleClass = jpf.setStyleClass;
this.$loadSkin = function(skinName){
this.baseSkin = skinName || this.skinName || (this.skinset || this.$jml
&& this.$jml.getAttribute("skinset") || jpf.appsettings.skinset)
+ ":" + (this.skin || this.$jml
&& this.$jml.getAttribute("skin") || this.tagName);
if (this.skinName) {
this.$blur();
this.baseCSSname = null;
}
this.skinName = this.baseSkin; 
pNodes = {}; 
originalNodes = jpf.skins.getTemplate(this.skinName, this.$jml);
if (!originalNodes) {
this.baseName = this.skinName = "default:" + this.tagName;
originalNodes = jpf.skins.getTemplate(this.skinName, this.$jml);
if (!originalNodes) {
throw new Error(jpf.formatErrorString(1077, this,
"Presentation",
"Could not load skin: " + this.skinName, this.$jml));
}
}
if (originalNodes)
jpf.skins.setSkinPaths(this.skinName, this);
};
this.$getNewContext = function(type, jmlNode){
pNodes[type] = originalNodes[type].cloneNode(true);
};
this.$hasLayoutNode = function(type){
return originalNodes[type] ? true : false;
};
this.$getLayoutNode = function(type, section, htmlNode){
var node = pNodes[type] || originalNodes[type];
if (!node) {
return false;
}
if (!section)
return jpf.getFirstElement(node);
var textNode = node.selectSingleNode("@" + section);
if (!textNode) {
return null;
}
return (htmlNode
? jpf.xmldb.selectSingleNode(textNode.nodeValue, htmlNode)
: jpf.getFirstElement(node).selectSingleNode(textNode.nodeValue));
};
this.$getOption = function(type, section){
type = type.toLowerCase(); 
var node = pNodes[type] || originalNodes[type];
if (!section)
return node;
var option = node.selectSingleNode("@" + section);
return option ? option.nodeValue : "";
};
this.$getExternal = function(tag, pNode, func, jml){
if (!pNode)
pNode = this.pHtmlNode;
if (!tag)
tag = "main";
if (!jml)
jml = this.$jml;
tag = tag.toLowerCase(); 
this.$getNewContext(tag);
var oExt = this.$getLayoutNode(tag);
if (jml && jml.getAttributeNode("style"))
oExt.setAttribute("style", jml.getAttribute("style"));
if (jml && (jml.getAttributeNode("class") || jml.className)) {
this.$setStyleClass(oExt,
(oldClass = jml.getAttribute("class") || jml.className));
}
if (func)
func.call(this, oExt);
oExt = jpf.xmldb.htmlImport(oExt, pNode);
oExt.host = this;
if (jml && jml.getAttribute("bgimage"))
oExt.style.backgroundImage = "url(" + jpf.getAbsolutePath(
this.mediaPath, jml.getAttribute("bgimage")) + ")";
if (!this.baseCSSname)
this.baseCSSname = oExt.className.trim().split(" ")[0];
return oExt;
};
this.$focus = function(){
if (!this.oExt)
return;
this.$setStyleClass(this.oFocus || this.oExt, this.baseCSSname + "Focus");
};
this.$blur = function(){
if (!this.oExt)
return;
this.$setStyleClass(this.oFocus || this.oExt, "", [this.baseCSSname + "Focus"]);
};
if (jpf.hasCssUpdateScrollbarBug) {
this.$fixScrollBug = function(){
if (this.oInt != this.oExt)
this.oFocus = this.oInt;
else {
this.oFocus =
this.oInt   =
this.oExt.appendChild(document.createElement("div"));
this.oInt.style.height = "100%";
}
};
}
if (this.hasFeature(__MULTISELECT__)) {
this.$select = function(o){
if (!o || !o.style)
return;
return this.$setStyleClass(o, "selected");
};
this.$deselect = function(o){
if (!o)
return;
return this.$setStyleClass(o, "", ["selected", "indicate"]);
};
this.$indicate = function(o){
if (!o)
return;
return this.$setStyleClass(o, "indicate");
};
this.$deindicate = function(o){
if (!o)
return;
return this.$setStyleClass(o, "", ["indicate"]);
};
}
};
var __ALIGNMENT__ = 1 << 12;
var __VALIDATION__ = 1 << 6;
jpf.Validation = function(){
this.isActive = true;
this.$regbase = this.$regbase | __VALIDATION__;
this.isValid = function(checkRequired){
var value = this.getValue();
if (checkRequired && this.required) {
if (!value || value.toString().trim().length == 0) {
return false;
}
}
var isValid = (vRules.length
? eval("!value || (" + vRules.join(") && (") + ")")
: true);
return isValid;
};
this.showMe = function(){
var p = this.parentNode;
while (p) {
if (p.show)
p.show();
p = p.parentNode;
}
};
this.validate = function(ignoreReq, nosetError, force){
if (force || !this.isValid(!ignoreReq) && !nosetError) {
this.setError();
return false;
}
else {
this.clearError();
return true;
}
};
this.setError = function(value){
if (!this.$validgroup)
this.$propHandlers["validgroup"].call(this, "vg" + this.parentNode.uniqueId);
var errBox = this.$validgroup.getErrorBox(this);
if (!this.$validgroup.allowMultipleErrors)
this.$validgroup.hideAllErrors();
errBox.setMessage(this.invalidmsg);
jpf.setStyleClass(this.oExt, this.baseCSSname + "Error");
this.showMe(); 
if (this.$validgroup) {
var refHtml = this.validityState.errorHtml || this.oExt;
document.body.appendChild(errBox.oExt);
var pos = jpf.getAbsolutePosition(refHtml, document.body);
if (document != refHtml.ownerDocument) {
var pos2 = jpf.getAbsolutePosition(refHtml.ownerDocument.parentWindow.frameElement, document.body);
pos[0] += pos2[0];
pos[1] += pos2[1];
}
errBox.oExt.style.left = pos[0] + "px"; 
errBox.oExt.style.top  = pos[1] + "px"; 
errBox.host = this;
}
errBox.show();
if (this.hasFeature(__MULTISELECT__) && this.validityState.errorXml)
this.select(this.validityState.errorXml);
if (jpf.window.focussed && jpf.window.focussed != this)
this.focus(null, {mouse:true}); 
};
this.clearError = function(value){
if (this.$setStyleClass)
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Error"]);
if (this.$validgroup) {
var errBox = this.$validgroup.getErrorBox(null, true);
if (!errBox || errBox.host != this)
return;
errBox.hide();
}
};
this.$jmlDestroyers.push(function(){
if (this.$validgroup)
this.$validgroup.remove(this);
});
var vRules = ["true"];
var vIds   = {};
this.addValidationRule = function(rule){
vRules.push(rule);
};
this.$addJmlLoader(function(x){
if (!this.form) {
var y = this.$jml;
do {
y = y.parentNode;
}
while (y && y.tagName && !y.tagName.match(/submitform|xforms$/)
&& y.parentNode && y.parentNode.nodeType != 9);
if (y && y.tagName && y.tagName.match(/submitform|xforms$/)) {
this.form = eval(y.getAttribute("id"));
this.form.addInput(this);
}
}
if (!this.form && !x.getAttribute("validgroup")) {
var vgroup = jpf.xmldb.getInheritedAttribute(x, "validgroup");
if (vgroup)
this.$propHandlers["validgroup"].call(this, vgroup);
}
});
this.$booleanProperties["required"] = true;
this.$supportedProperties.push("validgroup", "required", "datatype",
"pattern", "min", "max", "maxlength", "minlength", "valid-test",
"notnull", "checkequal", "invalidmsg", "requiredmsg");
this.$fValidate = function(){ this.validate(true); };
this.$propHandlers["validgroup"] = function(value){
this.removeEventListener("blur", this.$fValidate);
if (value) {
this.addEventListener("blur", this.$fValidate);
var vgroup;
if (typeof value != "string") {
this.$validgroup = value.name;
vgroup = value;
}
else {
vgroup = jpf.nameserver.get("validgroup", value);
}
this.$validgroup = vgroup || new jpf.ValidationGroup(value);
this.$validgroup.add(this);
}
else {
this.$validgroup.remove(this);
this.$validgroup = null;
}
};
this.$setRule = function(type, rule){
var vId = vIds[type];
if (!rule) {
if (vId)
vRules[vId] = "";
return;
}
if (!vId)
vIds[type] = vRules.push(rule) - 1;
else
vRules[vId] = rule;
}
this.$propHandlers["pattern"] = function(value){
if (!value)
return this.$setRule("pattern");
if (value.match(/^\/.*\/(?:[gim]+)?$/))
this.reValidation = eval(value);
this.$setRule("pattern", this.reValidation
? "this.getValue().match(this.reValidation)" 
: "(" + validation + ")"); 
};
this.$propHandlers["min"] = function(value){
this.$setRule("min", value
? "parseInt(value) >= " + value
: null);
};
this.$propHandlers["max"] = function(value){
this.$setRule("max", value
? "parseInt(value) <= " + value
: null);
};
this.$propHandlers["maxlength"] = function(value){
this.$setRule("maxlength", value
? "value.toString().length <= " + value
: null);
};
this.$propHandlers["minlength"] = function(value){
this.$setRule("minlength", value
? "value.toString().length >= " + value
: null);
};
this.$propHandlers["notnull"] = function(value){
this.$setRule("notnull", value
? "value.toString().length > 0"
: null);
};
this.$propHandlers["checkequal"] = function(value){
this.$setRule("checkequal", value
? "!" + value + ".isValid() || " + value + ".getValue() == value"
: null);
};
this.$propHandlers["valid-test"] = function(value){
var _self = this, rvCache = {};
this.removeValidationCache = function(){
rvCache = {};
}
this.$checkRemoteValidation = function(){
var value = this.getValue();
if(typeof rvCache[value] == "boolean") return rvCache[value];
if(rvCache[value] == -1) return true;
rvCache[value] = -1;
var instr = this.$jml.getAttribute('valid-test').split("==");
jpf.getData(instr[0], this.xmlRoot, {
value : this.getValue() 
}, function(data, state, extra){
if (state != jpf.SUCCESS) {
if (state == jpf.TIMEOUT && extra.retries < jpf.maxHttpRetries)
return extra.tpModule.retry(extra.id);
else {
var commError = new Error(jpf.formatErrorString(0, _self, 
"Validating entry at remote source", 
"Communication error: \n\n" + extra.message));
if (_self.dispatchEvent("error", jpf.extend({
error : commError, 
state : status
}, extra)) !== false)
throw commError;
return;
}
}
rvCache[value] = instr[1] ? data == instr[1] : jpf.isTrue(data);
if(!rvCache[value]){
if (!_self.hasFocus())
_self.setError();
}
else _self.clearError();
});
return true;
}
this.$setRule("valid-test", value
? "this.$checkRemoteValidation()"
: null);
};
};
jpf.ValidationGroup = function(name){
jpf.makeClass(this);
this.validateVisibleOnly = false;
this.allowMultipleErrors = false;
this.childNodes = [];
this.add        = function(o){ this.childNodes.push(o); };
this.remove     = function(o){ this.childNodes.remove(o); };
if (name)
jpf.setReference(name, this);
this.name = name || "validgroup" + this.uniqueId;
jpf.nameserver.register("validgroup", this.name, this);
this.toString = function(){
return "[Javeline Validation Group]";
};
var errbox; 
this.getErrorBox = function(o, no_create){
if (this.allowMultipleErrors || !errbox && !no_create) {
errbox           = new jpf.errorbox(null, "errorbox");
errbox.pHtmlNode = o.oExt.parentNode;
var cNode        = o.$jml.ownerDocument.createElement("errorbox");
errbox.loadJml(cNode);
}
return errbox;
};
this.hideAllErrors = function(){
if (errbox && errbox.host)
errbox.host.clearError();
};
function checkValidChildren(oParent, ignoreReq, nosetError){
var found;
for (var v, i = 0; i < oParent.childNodes.length; i++) {
var oEl = oParent.childNodes[i];
if (!oEl)
continue;
if (!oEl.disabled
&& (!this.validateVisibleOnly && oEl.visible || !oEl.oExt || oEl.oExt.offsetHeight)
&& (oEl.hasFeature(__VALIDATION__) && oEl.isValid && !oEl.isValid(!ignoreReq))) {
if (!nosetError) {
if (!found) {
oEl.validate(true, null, true);
found = true;
if (!this.allowMultipleErrors)
return true; 
}
else if (oEl.errBox && oEl.errBox.host == oEl)
oEl.errBox.hide();
}
else if (!this.allowMultipleErrors)
return true;
}
if (oEl.canHaveChildren && oEl.childNodes.length) {
found = checkValidChildren.call(this, oEl, ignoreReq, nosetError) || found;
if (found && !this.allowMultipleErrors)
return true; 
}
}
return found;
}
this.validate =
this.isValid = function(ignoreReq, nosetError, page){
var found = checkValidChildren.call(this, page || this, ignoreReq,
nosetError);
if (page) {
if (page.validation && !eval(page.validation)) {
alert(page.invalidmsg);
found = true;
}
}
if (!found)
found = this.dispatchEvent("validation");
return !found;
};
};
var __CACHE__ = 1 << 2;
jpf.Cache = function(){
var cache     = {};
var subTreeCacheContext;
this.caching  = true;
this.$regbase = this.$regbase | __CACHE__;
this.getCache = function(id, xmlNode){
if (id == this.cacheID) return -1;
if (xmlNode && this.hasFeature(__MULTISELECT__)) {
var cacheItem = this.getCacheItemByHtmlId(
xmlNode.getAttribute(jpf.xmldb.xmlIdTag) + "|" + this.uniqueId);
if (cacheItem && !cache[id]) {
this.clear(true);
var oHtml = this.getNodeFromCache(
xmlNode.getAttribute(jpf.xmldb.xmlIdTag) + "|" + this.uniqueId);
subTreeCacheContext = {
oHtml      : oHtml,
parentNode : oHtml.parentNode,
beforeNode : oHtml.nextSibling,
cacheItem  : cacheItem
};
this.documentId = jpf.xmldb.getXmlDocId(xmlNode);
this.cacheID    = id;
this.xmlRoot    = xmlNode;
if (this.renderRoot)
this.oInt.appendChild(oHtml);
else {
while (oHtml.childNodes.length)
this.oInt.appendChild(oHtml.childNodes[0]);
}
return true;
}
}
if (!cache[id]) return false;
if (this.cacheID)
this.clear(true);
var fragment    = cache[id];
this.documentId = fragment.documentId;
this.cacheID    = id;
this.xmlRoot    = fragment.xmlRoot;
this.clearCacheItem(id);
this.$setCurrentFragment(fragment);
return true;
};
this.setCache = function(id, fragment){
if (!this.caching) return;
cache[id] = fragment;
};
this.getNodeFromCache = function(id){
var node = this.$findNode(null, id);
if (node) return node;
for (var prop in cache) {
if (cache[prop] && cache[prop].nodeType) {
node = this.$findNode(cache[prop], id);
if (node) return node;
}
}
return null;
};
this.$findNode = function(cacheNode, id){
if (!cacheNode)
return this.pHtmlDoc.getElementById(id);
return cacheNode.getElementById(id);
};
this.getNodeByXml = function(xmlNode){
return xmlNode
? (this.getNodeFromCache((typeof xmlNode == "object"
? xmlNode.getAttribute(jpf.xmldb.xmlIdTag)
: xmlNode) + "|" + this.uniqueId))
: null;
};
this.getCacheItemByHtmlId = function(id){
var node = this.$findNode(null, id);
if (node) return this.oInt;
for (var prop in cache) {
if (cache[prop] && cache[prop].nodeType) {
node = this.$findNode(cache[prop], id);
if (node) return cache[prop];
}
}
return null;
};
this.clear = function(nomsg, doEvent){
if (this.clearSelection)
this.clearSelection(null, !doEvent);
if (this.caching) {
if (this.hasFeature(__MULTISELECT__)
&& subTreeCacheContext && subTreeCacheContext.oHtml) {
if (this.renderRoot)
subTreeCacheContext.parentNode.insertBefore(subTreeCacheContext.oHtml, subTreeCacheContext.beforeNode);
else {
while (this.oInt.childNodes.length)
subTreeCacheContext.oHtml.appendChild(this.oInt.childNodes[0]);
}
this.documentId = this.xmlRoot = this.cacheID = subTreeCacheContext = null;
}
else{
if (this.loadedWhenOffline) {
this.loadedWhenOffline = false;
}
else {
var fragment = this.$getCurrentFragment();
if (!fragment) return;
fragment.documentId = this.documentId;
fragment.xmlRoot    = this.xmlRoot;
}
}
}
else if (this.$clear)
this.$clear();
else
this.oInt.innerHTML = "";
if (typeof nomsg == "string") {
var msgType = nomsg;
nomsg = false;
}
if (!nomsg)
this.$setClearMessage(msgType ? this[msgType + "Msg"] : this.emptyMsg, msgType || "empty");
else if(this.$removeClearMessage)
this.$removeClearMessage();
if (this.caching && (this.cacheID || this.xmlRoot))
this.setCache(this.cacheID || this.xmlRoot.getAttribute(jpf.xmldb.xmlIdTag) || "doc"
+ this.xmlRoot.getAttribute(jpf.xmldb.xmlDocTag), fragment);
this.documentId = this.xmlRoot = this.cacheID = null;
if (!nomsg && this.hasFeature(__MULTISELECT__)) 
this.setProperty("length", 0);
};
this.clearAllTraverse = function(msg, className){
if (this.clearSelection)
this.clearSelection(null, true);
this.oInt.innerHTML = "";
this.$setClearMessage(msg || this.emptyMsg, className || "empty");
this.setConnections();
this.setProperty("length", 0);
};
this.clearCacheItem = function(id, remove){
cache[id].documentId = cache[id].cacheID = cache[id].xmlRoot = null;
if (remove)
jpf.removeNode(cache[id]);
cache[id] = null;
};
this.clearAllCache = function(){
for (var prop in cache) {
if (cache[prop])
this.clearCacheItem(prop, true);
}
};
this.getCacheItem = function(id){
return cache[id];
};
this.isCached = function(id){
return cache[id] || this.cacheID == id ? true : false;
}
this.$booleanProperties["caching"] = true;
this.$supportedProperties.push("caching");
if (this.hasFeature(__MULTISELECT__))
this.inherit(jpf.MultiselectCache);
this.$jmlDestroyers.push(function(){
this.clearAllCache();
});
};
jpf.MultiselectCache = function(){
this.$getCurrentFragment = function(){
var fragment = this.oInt.ownerDocument.createDocumentFragment();
while (this.oInt.childNodes.length) {
fragment.appendChild(this.oInt.childNodes[0]);
}
return fragment;
};
this.$setCurrentFragment = function(fragment){
this.oInt.appendChild(fragment);
if (!jpf.window.hasFocus(this))
this.blur();
};
this.$findNode = function(cacheNode, id){
if (!cacheNode)
return this.pHtmlDoc.getElementById(id);
return cacheNode.getElementById(id);
};
var oEmpty;
this.$setClearMessage = function(msg, className){
if (!oEmpty) {
this.$getNewContext("empty");
var xmlEmpty = this.$getLayoutNode("empty");
if (!xmlEmpty) return;
oEmpty = jpf.xmldb.htmlImport(xmlEmpty, this.oInt);
}
else {
this.oInt.appendChild(oEmpty);
}
var empty = this.$getLayoutNode("empty", "caption", oEmpty);
if (empty)
jpf.xmldb.setNodeValue(empty, msg || "");
oEmpty.setAttribute("id", "empty" + this.uniqueId);
jpf.setStyleClass(oEmpty, className, ["loading", "empty", "offline"]);
};
this.$updateClearMessage = function(msg, className) {
if (!oEmpty || oEmpty.parentNode != this.oInt
|| oEmpty.className.indexOf(className) == -1)
return;
var empty = this.$getLayoutNode("empty", "caption", oEmpty);
if (empty)
jpf.xmldb.setNodeValue(empty, msg || "");
}
this.$removeClearMessage = function(){
if (!oEmpty)
oEmpty = document.getElementById("empty" + this.uniqueId);
if (oEmpty && oEmpty.parentNode)
oEmpty.parentNode.removeChild(oEmpty);
};
};
var __JMLNODE__    = 1 << 15;
var __VALIDATION__ = 1 << 6;
jpf.JmlElement = function(){
this.$regbase = this.$regbase | __JMLNODE__;
var _self     = this;
if (this.nodeFunc == jpf.NODE_VISIBLE) {
this.setWidth = function(value){
this.setProperty("width", value);
};
this.setHeight = function(value){
this.setProperty("height", value);
};
this.setLeft   = function(value){
this.setProperty("left", value);
};
this.setTop    = function(value){
this.setProperty("top", value);
};
this.$noAlignUpdate = false;
if (!this.show)
this.show = function(s){
this.$noAlignUpdate = s;
this.setProperty("visible", true);
this.$noAlignUpdate = false;
};
if (!this.hide)
this.hide = function(s){
this.$noAlignUpdate = s;
this.setProperty("visible", false);
this.$noAlignUpdate = false;
};
this.getWidth  = function(){
return (this.oExt || {}).offsetWidth;
};
this.getHeight = function(){
return (this.oExt || {}).offsetHeight;
};
this.getLeft   = function(){
return (this.oExt || {}).offsetLeft;
};
this.getTop    = function(){
return (this.oExt || {}).offsetTop;
};
this.enable  = function(){
this.setProperty("disabled", false);
};
this.disable = function(){
this.setProperty("disabled", true);
};
this.sendToBack    =
this.sentToBack    = function(){
this.setProperty("zindex", 0);
};
this.bringToFront  = function(){
this.setProperty("zindex", jpf.all.length + 1);
};
this.sendBackwards =
this.sentBackwards = function(){
this.setProperty("zindex", this.zindex - 1);
};
this.bringForward  = function(){
this.setProperty("zindex", this.zindex + 1);
};
if (this.$focussable) {
this.setTabIndex = function(tabindex){
jpf.window.$removeFocus(this);
jpf.window.$addFocus(this, tabindex);
};
this.focus = function(noset, e, nofix){
if (!noset) {
if (this.isWindowContainer) {
jpf.window.$focusLast(this, e, true);
}
else {
jpf.window.$focus(this, e);
}
return;
}
if (this.$focus)
this.$focus(e);
this.dispatchEvent("focus", {
srcElement : this,
bubbles    : true
});
};
this.blur = function(noset, e){
if (jpf.popup.isShowing(this.uniqueId))
jpf.popup.forceHide(); 
if (this.$blur)
this.$blur(e);
if (!noset)
jpf.window.$blur(this);
this.dispatchEvent("blur", {
srcElement : this,
bubbles    : !e || !e.cancelBubble
});
};
this.hasFocus = function(){
return jpf.window.focussed == this || this.isWindowContainer
&& (jpf.window.focussed || {}).$focusParent == this;
};
}
}
if (!this.hasFeature(__WITH_JMLDOM__))
this.inherit(jpf.JmlDom); 
this.loadJml = function(x, pJmlNode, ignoreBindclass, id){
this.name = x.getAttribute("id");
if (this.name)
jpf.setReference(this.name, this);
if (!x)
x = this.$jml;
if (this.parentNode || pJmlNode)
this.$setParent(this.parentNode || pJmlNode);
this.$jml = x;
if (this.nodeFunc != jpf.NODE_HIDDEN) {
if (this.$loadSkin)
this.$loadSkin();
if (this.$draw)
this.$draw();
if (id)
this.oExt.setAttribute("id", id);
var pTagName = x.parentNode && x.parentNode[jpf.TAGNAME] || "";
if (this.$positioning != "basic") {
this.inherit(jpf.Anchoring); 
this.enableAnchoring();
}
if (this.visible === undefined && !x.getAttribute("visible"))
this.visible = true;
this.$drawn = true;
}
else if (this.$draw)
this.$draw();
if (!ignoreBindclass) { 
if (!this.hasFeature(__DATABINDING__) && x.getAttribute("smartbinding")) {
this.inherit(jpf.DataBinding);
this.$xmlUpdate = this.$load = function(){};
}
}
this.$noAlignUpdate = true;
var value, name, type, l, a, i, attr = x.attributes;
for (i = 0, l = attr.length; i < l; i++) {
a     = attr[i];
value = a.nodeValue;
name  = a.nodeName;
if (value && jpf.dynPropMatch.test(value)) {
jpf.JmlParser.stateStack.push({
node  : this,
name  : name,
value : value
});
} else
{
if (name == "disabled") {
jpf.JmlParser.stateStack.push({
node  : this,
name  : name,
value : value
});
}
if (a.nodeName.indexOf("on") === 0) {
this.addEventListener(name, new Function('event', value));
continue;
}
if (!value)
value = this.defaults && this.defaults[name];
if (this.$booleanProperties[name])
value = jpf.isTrue(value);
this[name] = value;
(this.$propHandlers && this.$propHandlers[name]
|| jpf.JmlElement.propHandlers[name] || jpf.K).call(this, value)
}
}
this.$noAlignUpdate = false;
if (this.$focussable && this.focussable === undefined)
jpf.JmlElement.propHandlers.focussable.call(this);
if (this.$loadJml && !this.$isSelfLoading)
this.$loadJml(x);
for (i = this.$jmlLoaders.length - 1; i >= 0; i--)
this.$jmlLoaders[i].call(this, x);
this.$jmlLoaded = true;
return this;
};
this.$handlePropSet = function(prop, value, force){
if (!force && this.xmlRoot && this.bindingRules
&& this.bindingRules[prop] && !this.ruleTraverse) {
return jpf.xmldb.setNodeValue(this.getNodeFromRule(
prop.toLowerCase(), this.xmlRoot, null, null, true),
value, !this.$onlySetXml);
}
if (this.$booleanProperties[prop])
value = jpf.isTrue(value);
this[prop] = value;
if(this.$onlySetXml)
return;
return (this.$propHandlers && this.$propHandlers[prop]
|| jpf.JmlElement.propHandlers[prop]
|| jpf.K).call(this, value, force, prop);
};
this.replaceJml = function(jmlDefNode, oInt, oIntJML, isHidden){
for (var i = 0; i < this.childNodes.length; i++) {
var oItem = this.childNodes[i];
var nodes = oItem.childNodes;
for (var k = 0; k < nodes.length; k++)
if (nodes[k].destroy)
nodes[k].destroy();
if (oItem.$jml && oItem.$jml.parentNode)
oItem.$jml.parentNode.removeChild(oItem.$jml);
oItem.destroy();
if (oItem.oExt != this.oInt)
jpf.removeNode(oItem.oExt);
}
this.childNodes.length = 0;
this.oExt.innerHTML = "";
this.insertJml(jmlDefNode, oInt, oIntJML, isHidden);
};
this.insertJml = function(jmlDefNode, oInt, oIntJML, isHidden){
var callback = function(data, state, extra){
if (state != jpf.SUCCESS) {
var oError;
if (extra.tpModule.retryTimeout(extra, state, _self, oError) === true)
return true;
throw oError;
}
jpf.console.info("Runtime inserting jml");
var JML = oIntJML || _self.$jml;
if (JML.insertAdjacentHTML)
JML.insertAdjacentHTML(JML.getAttribute("insert")|| "beforeend",
(typeof data != "string" && data.length) ? data[0] : data);
else {
if (typeof data == "string")
data = jpf.xmldb.getXml("<j:jml xmlns:j='"
+ jpf.ns.jml +"'>" + data + "</j:jml>");
for (var i = data.childNodes.length - 1; i >= 0; i--)
JML.insertBefore(data.childNodes[i], JML.firstChild);
}
jpf.JmlParser.parseMoreJml(JML, oInt || _self.oInt, _self,
(isHidden && (oInt || _self.oInt).style.offsetHeight)
? true : false);
}
if (typeof jmlDefNode == "string") {
if (jpf.datainstr[jmlDefNode]){
return jpf.getData(jmlDefNode, null, {
ignoreOffline : true
}, callback);
}
else
jmlDefNode = jpf.xmldb.getXml(jmlDefNode);
}
return callback(jmlDefNode, jpf.SUCCESS);
};
if (
this.hasFeature(__DATABINDING__) &&
!this.hasFeature(__MULTISELECT__) && !this.change) {
this.change = function(value){
if (this.errBox && this.errBox.visible && this.isValid())
this.clearError();
if ((!this.createModel || !this.$jml.getAttribute("ref")) && !this.xmlRoot) {
if (this.dispatchEvent("beforechange", {value : value}) === false)
return;
this.setProperty("value", value);
return this.dispatchEvent("afterchange", {value : value});
}
this.executeActionByRuleSet("change", this.mainBind, this.xmlRoot, value);
};
}
if (this.setValue && !this.clear) {
this.clear = function(nomsg){
if (this.$setClearMessage) {
if (!nomsg)
this.$setClearMessage(this.emptyMsg, "empty");
else if (this.$removeClearMessage)
this.$removeClearMessage();
}
this.value = -99999; 
this.$propHandlers && this.$propHandlers["value"]
? this.$propHandlers["value"].call(this, "")
: this.setValue("");
};
}
};
jpf.JmlElement.propHandlers = {
"id": function(value){
if (this.name == value)
return;
if (self[this.name] == this)
self[this.name] = null;
jpf.setReference(value, this);
this.name = value;
},
"focussable": function(value){
if (typeof value == "undefined")
this.focussable = true;
if (this.focussable) {
jpf.window.$addFocus(this, this.tabindex
|| this.$jml.getAttribute("tabindex"));
}
else {
jpf.window.$removeFocus(this);
}
},
"zindex": function(value){
this.oExt.style.zIndex = value;
},
"visible": function(value){
if (this.tagName == "modalwindow") 
return; 
if (jpf.isFalse(value) || typeof value == "undefined") {
this.oExt.style.display = "none";
if (this.$hide && !this.$noAlignUpdate)
this.$hide();
if (jpf.window.focussed == this
|| this.canHaveChildren
&& jpf.xmldb.isChildOf(this, jpf.window.focussed, false)) {
if (jpf.appsettings.allowBlur)
this.blur();
else
jpf.window.moveNext();
}
}
else if (jpf.isTrue(value)) {
this.oExt.style.display = "block"; 
if (this.$show && !this.$noAlignUpdate)
this.$show();
if (jpf.hasSingleRszEvent)
jpf.layout.forceResize(this.oInt);
}
},
"disabled": function(value){
if (this.canHaveChildren) {
function loopChildren(nodes){
for (var node, i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
if (node.nodeFunc == jpf.NODE_VISIBLE)
node.setProperty("disabled", value);
if (node.childNodes.length)
loopChildren(node.childNodes);
}
}
loopChildren(this.childNodes);
return;
}
if (value) {
this.disabled = false;
if (jpf.window.focussed == this) {
jpf.window.moveNext(true); 
if (jpf.window.focussed == this)
this.$blur();
}
if (this.hasFeature(__PRESENTATION__))
this.$setStyleClass(this.oExt, this.baseCSSname + "Disabled");
if (this.$disable)
this.$disable();
this.disabled = true;
}
else {
if (this.hasFeature(__DATABINDING__) && jpf.appsettings.autoDisable
& !this.isBoundComplete())
return false;
this.disabled = false;
if (jpf.window.focussed == this)
this.$focus();
if (this.hasFeature(__PRESENTATION__))
this.$setStyleClass(this.oExt, null, [this.baseCSSname + "Disabled"]);
if (this.$enable)
this.$enable();
}
},
"enabled" : function(value){
this.setProperty("disabled", !value);
},
"disable-keyboard": function(value){
this.disableKeyboard = jpf.isTrue(value);
},
"left": function(value){
this.oExt.style.position = "absolute";
this.oExt.style.left = value + "px";
},
"top": function(value){
this.oExt.style.position = "absolute";
this.oExt.style.top = value + "px";
},
"right": function(value){
this.oExt.style.position = "absolute";
this.oExt.style.right = value + "px";
},
"bottom": function(value){
this.oExt.style.position = "absolute";
this.oExt.style.bottom = value + "px";
},
"width": function(value){
this.oExt.style.width = Math.max(0, value
- jpf.getWidthDiff(this.oExt)) + "px";
},
"height": function(value){
this.oExt.style.height = Math.max(0,
value - jpf.getHeightDiff(this.oExt)) + "px";
},
"contextmenu": function(value){
this.contextmenus = [value];
},
"resizable": function(value){
this.inherit(jpf.Interactive);
this.$propHandlers["resizable"].apply(this, arguments);
},
"draggable": function(value){
this.inherit(jpf.Interactive);
this.$propHandlers["draggable"].apply(this, arguments);
},
"actiontracker": function(value){
if (!value)
this.$at = null;
else if (value.tagName == "actiontracker")
this.$at = value;
else {
this.$at = typeof value == "string" && self[value]
? jpf.JmlParser.getActionTracker(value)
: jpf.setReference(value,
jpf.nameserver.register("actiontracker",
value, new jpf.actiontracker()));
}
},
"jml": function(value){
this.insertJml(value);
this.$isSelfLoading = true;
},
"alias" : function(value){
if (!value) 
return;
var cg = jpf.nameserver.get("alias", value);
if (!cg) {
cg = jpf.nameserver.register("alias", value, {
name  : value,
props : {},
$handlePropSet : function(prop, value, forceOnMe){
if (prop == "alias") return;
this.props[prop] = value;
this[prop] = value;
if (!forceOnMe)
this.active.setProperty(prop, value);
},
$propchange : function(e){
cg.setProperty(e.name, e.value, null, true);
},
data : [],
connect : function(o, dataOnly, xpath, type, noselect){
this.data.push([o, dataOnly, xpath, type, noselect]);
if (this.active)
this.active.connect(o, dataOnly, xpath, type, noselect);
},
disconnect : function(o, type){
for (var data, i = 0, l = this.data.length; i < l; i++) {
if (this.data[i][0] == o && this.data[i][3] == type)
this.data.removeIndex(i);
}
if (this.active)
this.active.disconnect(o, type);
},
set : function(jmlNode){
if (this.active == jmlNode)
return;
if (this.active) {
for (var name in events) {
var ev = events[name];
for (var i = 0; i < ev.length; i++) {
this.active.removeEventListener(name, ev[i]);
}
}
for (var name in events_capture) {
var ev = events_capture[name];
for (var i = 0; i < ev.length; i++) {
this.active.removeEventListener(name, ev[i], true);
}
}
this.active.removeEventListener("propertychange", this.$propchange);
for (var i = 0, l = this.data.length; i < l; i++)
this.active.disconnect(this.data[i][0], this.data[i][3]);
this.active.setProperty("alias", false);
}
this.active = jmlNode;
for (var name in events) {
var ev = events[name];
for (var i = 0; i < ev.length; i++) {
this.active.addEventListener(name, ev[i]);
}
}
for (var name in events_capture) {
var ev = events_capture[name];
for (var i = 0; i < ev.length; i++) {
this.active.addEventListener(name, ev[i], true);
}
}
for (var prop in this.props)
this.setProperty(prop, this.active[prop]);
this.active.addEventListener("propertychange", this.$propchange);
for (var i = 0, l = this.data.length; i < l; i++)
this.active.connect.apply(this.active, this.data[i]);
jmlNode.$alias = this;
}
});
jpf.makeClass(cg);
jpf.setReference(value, cg);
var events = {}, events_capture = {};
cg.addEventListener = function(eventName, callback, useCapture){
var ev = useCapture ? events_capture : events;
(ev[eventName] || (ev[eventName] = [])).pushUnique(callback);
this.active.addEventListener(eventName, callback, useCapture);
}
cg.removeEventListener = function(eventName, callback, useCapture){
var ev = useCapture ? events_capture : events;
(ev[eventName] || (ev[eventName] = [])).remove(callback);
this.active.addEventListener(eventName, callback, useCapture);
}
cg.dispatchEvent = function(eventName, options){
this.active.dispatchEvent(eventName, options);
}
}
cg.set(this);
}
};
var __WITH_JMLDOM__ = 1 << 14;
jpf.JmlDom = function(tagName, parentNode, nodeFunc, jml, content){
this.nodeType      = jpf.NODE_ELEMENT;
this.$regbase      = this.$regbase | __WITH_JMLDOM__;
this.childNodes    = [];
var _self          = this;
if (!this.$domHandlers)
this.$domHandlers = {"remove" : [], "insert" : [],
"reparent" : [], "removechild" : []};
if (jpf.document)
this.ownerDocument = jpf.document;
if (tagName) {
if (typeof tagName == "number") {
if (tagName == jpf.NODE_DOCUMENT_FRAGMENT) {
this.nodeType = jpf.NODE_DOCUMENT_FRAGMENT;
this.hasFeature = function(){
return false;
}
}
}
else {
this.parentNode = parentNode;
this.$jml        = jml;
this.nodeFunc   = nodeFunc;
this.tagName    = tagName;
this.name       = jml && jml.getAttribute("id");
this.content    = content;
}
}
this.appendChild =
this.insertBefore = function(jmlNode, beforeNode){
if (jmlNode.nodeType == jpf.NODE_DOCUMENT_FRAGMENT) {
var nodes = jmlNode.childNodes.slice(0);
for (var i = 0, l = nodes.length; i < l; i++) {
this.insertBefore(nodes[i], beforeNode);
}
return;
}
var isMoveWithinParent = jmlNode.parentNode == this;
var oldParentHtmlNode  = jmlNode.pHtmlNode;
if (jmlNode.parentNode)
jmlNode.removeNode(isMoveWithinParent);
jmlNode.parentNode = this;
var index;
if (beforeNode) {
index = this.childNodes.indexOf(beforeNode);
if (index < 0) {
return false;
}
jmlNode.nextSibling = beforeNode;
jmlNode.previousSibling = beforeNode.previousSibling;
beforeNode.previousSibling = jmlNode;
if (jmlNode.previousSibling)
jmlNode.previousSibling.nextSibling = jmlNode;
}
if (index)
this.childNodes = this.childNodes.slice(0, index).concat(jmlNode,
this.childNodes.slice(index));
else {
index = this.childNodes.push(jmlNode) - 1;
jmlNode.nextSibling = null;
if (index > 0) {
jmlNode.previousSibling = this.childNodes[index - 1];
jmlNode.previousSibling.nextSibling = jmlNode;
}
else
jmlNode.previousSibling = null;
}
this.firstChild = this.childNodes[0];
this.lastChild  = this.childNodes[this.childNodes.length - 1];
function triggerUpdate(){
jmlNode.pHtmlNode = _self.canHaveChildren
? _self.oInt
: document.body;
var i, callbacks = jmlNode.$domHandlers["reparent"];
for (i = 0, l = callbacks.length; i < l; i++) {
if (callbacks[i])
callbacks[i].call(jmlNode, beforeNode,
_self, isMoveWithinParent, oldParentHtmlNode);
}
callbacks = _self.$domHandlers["insert"];
for (i = 0, l = callbacks.length; i < l; i++) {
if (callbacks[i])
callbacks[i].call(_self, jmlNode,
beforeNode, isMoveWithinParent);
}
if (jmlNode.oExt) {
jmlNode.pHtmlNode.insertBefore(jmlNode.oExt,
beforeNode && beforeNode.oExt || null);
}
}
if (!this.$jmlLoaded) {
jmlNode.$reappendToParent = triggerUpdate;
return;
}
triggerUpdate();
};
this.removeNode = function(doOnlyAdmin){
if (!this.parentNode || !this.parentNode.childNodes)
return;
this.parentNode.childNodes.remove(this);
if (this.$jmlLoaded && !jpf.isDestroying) {
if (this.oExt && this.oExt.parentNode)
this.oExt.parentNode.removeChild(this.oExt);
var i, l, callbacks = this.$domHandlers["remove"];
if (callbacks) {
for (i = 0, l = callbacks.length; i < l; i++) {
callbacks[i].call(this, doOnlyAdmin);
}
}
callbacks = (this.parentNode.$domHandlers || {})["removechild"];
if (callbacks) {
for (i = 0, l = callbacks.length; i < l; i++) {
callbacks[i].call(this.parentNode, this, doOnlyAdmin);
}
}
}
if (this.parentNode.firstChild == this)
this.parentNode.firstChild = this.nextSibling;
if (this.parentNode.lastChild == this)
this.parentNode.lastChild = this.previousSibling;
if (this.nextSibling)
this.nextSibling.previousSibling = this.previousSibling;
if (this.previousSibling)
this.previousSibling.nextSibling = this.nextSibling;
this.pHtmlNode       =
this.parentNode      =
this.previousSibling =
this.nextSibling     = null;
return this;
};
this.removeChild = function(childNode) {
childNode.removeNode();
};
this.getElementsByTagName = function(tagName, norecur){
tagName = tagName.toLowerCase();
for (var result = [], i = 0; i < this.childNodes.length; i++) {
if (this.childNodes[i].tagName == tagName || tagName == "*")
result.push(this.childNodes[i]);
if (!norecur)
result = result.concat(this.childNodes[i].getElementsByTagName(tagName));
}
return result;
};
this.cloneNode = function(deep){
var jml = this.serialize(true, true, !deep);
return jpf.document.createElement(jml);
};
this.serialize = function(returnXml, skipFormat, onlyMe){
var node = this.$jml.cloneNode(false);
for (var name, i = 0; i < (this.$supportedProperties || []).length; i++) {
name = this.$supportedProperties[i];
if (this.getProperty(name) !== undefined)
node.setAttribute(name, String(this.getProperty(name)).toString());
}
if (!onlyMe) {
var l, nodes = this.childNodes;
for (i = 0, l = nodes.length; i < l; i++) {
node.appendChild(nodes[i].serialize(true));
}
}
return returnXml
? node
: (skipFormat
? node.xml || node.serialize()
: jpf.formatXml(node.xml || node.serialize()));
};
this.setAttribute = function(name, value) {
if (this.$jml)
this.$jml.setAttribute(name, (value || "").toString());
if (name.indexOf("on") === 0) { 
this.addEventListener(name, typeof value == "string"
? new Function(value)
: value);
return;
}
if (this.nodeFunc == jpf.NODE_VISIBLE && !this.oExt)
return;
if (jpf.dynPropMatch.test(value))
this.setDynamicProperty(name, value);
else if (this.setProperty)
this.setProperty(name, value);
else
this[name] = value;
};
this.removeAttribute = function(name){
this.setProperty(name, null);
};
this.getAttribute = this.getProperty || function(name){
return this[name];
};
this.getAttributeNode = function(name){
return this.attributes.getNamedItem(name);
}
this.selectNodes = function(sExpr, contextNode){
return jpf.XPath.selectNodes(sExpr,
contextNode || (this.nodeType == 9 ? this.documentElement : this));
};
this.selectSingleNode  = function(sExpr, contextNode){
return jpf.XPath.selectNodes(sExpr,
contextNode || (this.nodeType == 9 ? this.documentElement : this))[0];
};
this.attributes = {
getNamedItem    : function(name){
return {
nodeType  : 2,
nodeName  : name,
nodeValue : _self[name] || ""
}
},
setNamedItem    : function(node){
_self.setAttribute(node.name, node.value);
},
removeNamedItem : function(name){
_self.removeAttribute(name);
},
length          : function(){
return _self.$jml && _self.$jml.attributes.length
|| (_self.$supportedProperties || {length:0}).length; 
},
item            : function(i){
if (_self.$jml && _self.$jml.attributes)
return _self.$jml.attributes[i];
var collection = _self.$supportedProperties;
if (!collection[i])
return false;
return this.getNamedItem(collection[i]);
}
};
this.nodeValue    = "";
this.namespaceURI = jpf.ns.jml;
this.$setParent = function(pNode){
if (pNode && pNode.childNodes.indexOf(this) > -1)
return;
this.parentNode = pNode;
var nodes = this.parentNode.childNodes;
var id = nodes.push(this) - 1;
if (id === 0)
this.parentNode.firstChild = this;
else {
var n = nodes[id - 1];
if (n) {
n.nextSibling = this;
this.previousSibling = n || null;
}
this.parentNode.lastChild = this;
}
};
if (this.parentNode && this.parentNode.hasFeature
&& this.parentNode.hasFeature(__WITH_JMLDOM__))
this.$setParent(this.parentNode);
};
var __MULTISELECT__ = 1 << 8;
jpf.MultiSelect = function(){
var noEvent;
var selSmartbinding;
var valueList    = [];
var selectedList = [];
var _self        = this;
this.$regbase    = this.$regbase|__MULTISELECT__;
this.selected     = null;
this.$selected    = null;
this.indicator    = null;
this.$indicator   = null;
this.useindicator = true;
this.remove = function(nodeList){
if (!nodeList)
nodeList = valueList;
if (nodeList.nodeType)
nodeList = [nodeList];
if (!nodeList || !nodeList.length)
return;
var rValue;
if (nodeList.length > 1 && (!this.actionRules
|| this.actionRules["removegroup"] || !this.actionRules["remove"])) {
rValue = this.executeAction("removeNodeList", nodeList,
"removegroup", nodeList[0]);
}
else {
for (var i = 0; i < nodeList.length; i++) {
rValue = this.executeAction("removeNode",
[nodeList[i]], "remove", nodeList[i], null, null, true);
if (rValue === false)
return false;
}
}
return rValue;
};
this.add = function(xmlNode, pNode, beforeNode){
var node;
if (this.actionRules) {
if (xmlNode && xmlNode.nodeType)
node = this.getNodeFromRule("add", xmlNode, true);
else if (typeof xmlNode == "string") {
if (xmlNode.trim().charAt(0) == "<") {
xmlNode = jpf.getXml(xmlNode);
node = this.getNodeFromRule("add", xmlNode, true);
}
else {
var rules = this.actionRules["add"];
for (var i = 0, l = rules.length; i < l; i++) {
if (rules[i].getAttribute("type") == xmlNode) {
xmlNode = null;
node = rules[i];
break;
}
}
}
}
if (!node && this.actionRules["add"])
node = this.actionRules["add"][0];
}
else
node = null;
var refNode  = this.isTreeArch ? this.selected || this.xmlRoot : this.xmlRoot;
var jmlNode  = this; 
var callback = function(addXmlNode, state, extra){
if (state != jpf.SUCCESS) {
var oError;
if (extra.tpModule.retryTimeout(extra, state, jmlNode, oError) === true)
return true;
throw oError;
}
if (typeof addXmlNode != "object")
addXmlNode = jpf.getXmlDom(addXmlNode).documentElement;
if (addXmlNode.getAttribute(jpf.xmldb.xmlIdTag))
addXmlNode.setAttribute(jpf.xmldb.xmlIdTag, "");
var actionNode = jmlNode.getNodeFromRule("add", jmlNode.isTreeArch
? jmlNode.selected
: jmlNode.xmlRoot, true, true);
if (!pNode) {
if (actionNode && actionNode.getAttribute("parent")) {
pNode = jmlNode.xmlRoot
.selectSingleNode(actionNode.getAttribute("parent"));
}
else {
pNode = jmlNode.isTreeArch
? jmlNode.selected || jmlNode.xmlRoot
: jmlNode.xmlRoot
}
}
if (!pNode)
pNode = jmlNode.xmlRoot;
if (jpf.isSafari && pNode.ownerDocument != addXmlNode.ownerDocument)
addXmlNode = pNode.ownerDocument.importNode(addXmlNode, true); 
if (jmlNode.executeAction("appendChild",
[pNode, addXmlNode, beforeNode], "add", addXmlNode) !== false
&& jmlNode.autoselect)
jmlNode.select(addXmlNode);
return addXmlNode;
}
if (xmlNode)
return callback(xmlNode, jpf.SUCCESS);
else {
if (node.getAttribute("get"))
return jpf.getData(node.getAttribute("get"), refNode, null, callback)
else if (node.firstChild) {
var node = jpf.getNode(node, [0]);
if (jpf.supportNamespaces && node.namespaceURI == jpf.ns.xhtml) {
node = jpf.getXml(node.xml.replace(/xmlns\=\"[^"]*\"/g, ""));
}
else node = node.cloneNode(true);
return callback(node, jpf.SUCCESS);
}
}
return addXmlNode;
};
if (!this.setValue) {
this.setValue = function(value, disable_event){
noEvent = disable_event;
this.setProperty("value", value);
noEvent = false;
};
}
this.findXmlNodeByValue = function(value){
var nodes = this.getTraverseNodes();
var bindSet = this.bindingRules && this.bindingRules[this.mainBind]
? this.mainBind
: (this.valuerule ? "value" : "caption");
for (var i = 0; i < nodes.length; i++) {
if (this.applyRuleSetOnNode(bindSet, nodes[i]) == value)
return nodes[i];
}
};
if (!this.getValue) {
this.getValue = function(xmlNode){
if (!this.bindingRules && !this.caption) 
return false;
return this.applyRuleSetOnNode(this.mainBind, xmlNode || this.selected, null, true)
|| this.applyRuleSetOnNode("caption", xmlNode || this.selected, null, true);
};
}
this.$setMultiBind = function(smartbinding, part){
if (!selSmartbinding)
selSmartbinding = new jpf.MultiLevelBinding(this);
selSmartbinding.setSmartBinding(smartbinding, part);
this.dispatchEvent("initselbind", {smartbinding : selSmartbinding});
};
this.getMultibinding = function(){
return selSmartbinding;
}
this.$getMultiBind = function(){
return (selSmartbinding
|| (selSmartbinding = new jpf.MultiLevelBinding(this)));
};
this.reselect = function(){
if (this.selected) this.select(this.selected, null, this.ctrlselect,
null, true);
};
var buffered = null;
this.select  = function(xmlNode, ctrlKey, shiftKey, fakeselect, force, noEvent){
if (!this.selectable || this.disabled) return;
if (this.ctrlselect && !shiftKey)
ctrlKey = true;
if (!this.xmlRoot) {
buffered        = [arguments, this.autoselect];
this.autoselect = true;
return;
}
if (buffered) {
var x    = buffered;
buffered = null;
if (this.autoselect)
this.autoselect = x[1];
return this.select.apply(this, x[0]);
}
var htmlNode;
if (!xmlNode) {
return false;
}
if (typeof xmlNode != "object") {
var str = xmlNode;
xmlNode = jpf.xmldb.getNodeById(xmlNode);
if (!xmlNode) {
xmlNode = this.findXmlNodeByValue(str);
if (!xmlNode) {
this.clearSelection(null, noEvent);
return;
}
}
}
if (!xmlNode.style)
htmlNode = this.caching
? this.getNodeFromCache(xmlNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId)
: document.getElementById(xmlNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId); 
else {
var id = (htmlNode = xmlNode).getAttribute(jpf.xmldb.htmlIdTag);
while (!id && htmlNode.parentNode)
id = (htmlNode = htmlNode.parentNode).getAttribute(
jpf.xmldb.htmlIdTag);
xmlNode = jpf.xmldb.getNodeById(id, this.xmlRoot);
}
if(!noEvent && this.dispatchEvent('beforeselect', {
xmlNode : xmlNode,
htmlNode: htmlNode,
ctrlKey : ctrlKey,
shiftKey : shiftKey}) === false)
return false;
var lastIndicator = this.indicator;
this.indicator    = xmlNode;
if (shiftKey && this.multiselect) {
var range = this.$calcSelectRange(valueList[0] || lastIndicator,
xmlNode);
if (this.$indicator)
this.$deindicate(this.$indicator);
this.selectList(range);
this.$selected  =
this.$indicator = this.$indicate(htmlNode);
}
else if (ctrlKey && this.multiselect) { 
if (valueList.contains(xmlNode)) {
if (!fakeselect) {
selectedList.remove(htmlNode);
valueList.remove(xmlNode);
}
if (this.selected == xmlNode) {
var ind = this.$indicator;
this.clearSelection(true, true);
this.$deindicate(ind);
if (valueList.length && !fakeselect) {
this.selected = valueList[0];
}
}
else
this.$deselect(htmlNode, xmlNode);
if (htmlNode != this.$indicator)
this.$deindicate(this.$indicator);
this.$selected  =
this.$indicator = this.$indicate(htmlNode);
}
else {
if (this.$indicator)
this.$deindicate(this.$indicator);
this.$indicator = this.$indicate(htmlNode);
this.$selected   = this.$select(htmlNode);
this.selected     = xmlNode;
if (!fakeselect) {
selectedList.push(htmlNode);
valueList.push(xmlNode);
}
}
}
else if (htmlNode && selectedList.contains(htmlNode) && fakeselect) 
return;
else { 
if (!force && htmlNode && this.$selected == htmlNode
&& valueList.length <= 1 && !this.reselectable
&& selectedList.contains(htmlNode))
return;
if (this.$selected)
this.$deselect(this.$selected);
if (this.$indicator)
this.$deindicate(this.$indicator);
if (this.selected)
this.clearSelection(null, true);
this.$indicator = this.$indicate(htmlNode, xmlNode);
this.$selected  = this.$select(htmlNode, xmlNode);
this.selected    = xmlNode;
selectedList.push(htmlNode);
valueList.push(xmlNode);
}
if (!noEvent) {
if (this.delayedselect){
var jNode = this;
setTimeout(function(){
jNode.dispatchEvent("afterselect", {
list    : valueList,
xmlNode : xmlNode}
);
}, 10);
}
else
this.dispatchEvent("afterselect", {
list    : valueList,
xmlNode : xmlNode
});
}
return true;
};
this.choose = function(xmlNode){
if (!this.selectable || this.disabled) return;
if (this.dispatchEvent("beforechoose", {xmlNode : xmlNode}) === false)
return false;
if (xmlNode && !xmlNode.style)
this.select(xmlNode);
if (this.hasFeature(__DATABINDING__)
&& this.dispatchEvent("afterchoose", {xmlNode : this.selected}) !== false)
this.setConnections(this.selected, "choice");
};
this.clearSelection = function(singleNode, noEvent){
if (!this.selectable || this.disabled) return;
var clSel = singleNode ? this.selected : valueList;
if (!noEvent && this.dispatchEvent("beforedeselect", {
xmlNode : clSel
}) === false)
return false;
var htmlNode;
if (this.selected) {
htmlNode = this.caching
? this.getNodeFromCache(this.selected.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId)
: document.getElementById(this.selected.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId); 
this.$deselect(htmlNode);
}
this.$selected = this.selected = null;
if (!singleNode) {
for (var i = valueList.length - 1; i >= 0; i--) {
htmlNode = this.caching
? this.getNodeFromCache(valueList[i].getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId)
: document.getElementById(valueList[i].getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId); 
this.$deselect(htmlNode);
}
selectedList = [];
valueList    = [];
}
if (this.indicator) {
htmlNode = this.caching
? this.getNodeFromCache(this.indicator.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId)
: document.getElementById(this.indicator.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId); 
this.$selected  =
this.$indicator = this.$indicate(htmlNode);
}
if (!noEvent)
this.dispatchEvent("afterdeselect", {xmlNode : clSel});
};
this.selectList = function(xmlNodeList, noEvent, selected){
if (!this.selectable || this.disabled) return;
if (!noEvent && this.dispatchEvent("beforeselect", {
xmlNode : selected
}) === false)
return false;
this.clearSelection(null, true);
for (var sel, i=0;i<xmlNodeList.length;i++) {
if (!xmlNodeList[i] || xmlNodeList[i].nodeType != 1) continue; 
var xmlNode = xmlNodeList[i];
if (typeof xmlNode != "object")
xmlNode = jpf.xmldb.getNodeById(xmlNode);
if (!xmlNode.style)
htmlNode = this.$findNode(null, xmlNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId); 
else {
htmlNode = xmlNode;
xmlNode  = jpf.xmldb.getNodeById(htmlNode.getAttribute(
jpf.xmldb.htmlIdTag));
}
if (!xmlNode) {
continue;
}
if (htmlNode) {
if (!sel && selected == htmlNode)
sel = htmlNode;
this.$select(htmlNode);
selectedList.push(htmlNode);
}
valueList.push(xmlNode);
}
this.$selected = sel || selectedList[0];
this.selected   = selected || valueList[0];
if (!noEvent) {
this.dispatchEvent("afterselect", {
list    : valueList,
xmlNode : this.selected
});
}
};
this.setIndicator = function(xmlNode){
if (!xmlNode) {
if (this.$indicator)
this.$deindicate(this.$indicator);
this.indicator  =
this.$indicator = null;
return;
}
var htmlNode;
if (typeof xmlNode != "object")
xmlNode = jpf.xmldb.getNodeById(xmlNode);
if (!xmlNode.style)
htmlNode = this.caching
? this.getNodeFromCache(xmlNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId)
: document.getElementById(xmlNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId); 
else {
var id = (htmlNode = xmlNode).getAttribute(jpf.xmldb.htmlIdTag);
while (!id && htmlNode.parentNode)
id = (htmlNode = htmlNode.parentNode).getAttribute(
jpf.xmldb.htmlIdTag);
xmlNode = jpf.xmldb.getNodeById(id);
}
if (this.$indicator)
this.$deindicate(this.$indicator);
this.indicator  = xmlNode;
this.$indicator = this.$indicate(htmlNode);
this.dispatchEvent("indicate");
};
this.setTempSelected = function(xmlNode, ctrlKey, shiftKey){
clearTimeout(this.timer);
if (ctrlKey || this.ctrlselect) {
if (this.$tempsel) {
this.select(this.$tempsel);
this.$tempsel = null;
}
this.setIndicator(xmlNode);
}
else if (shiftKey){
if (this.$tempsel) {
this.$deselect(this.$tempsel);
this.$tempsel = null;
}
this.select(xmlNode, null, shiftKey);
}
else if (!this.bufferselect) {
this.select(xmlNode);
}
else {
var id = jpf.xmldb.getID(xmlNode, this);
this.$deselect(this.$tempsel || this.$selected);
this.$deindicate(this.$tempsel || this.$indicator);
this.$tempsel = this.$indicate(document.getElementById(id));
this.$select(this.$tempsel);
this.timer = setTimeout(function(){
_self.selectTemp();
}, 400);
}
};
this.selectTemp = function(){
if (!this.$tempsel)
return;
clearTimeout(this.timer);
this.select(this.$tempsel);
this.$tempsel = null;
this.timer    = null;
};
this.selectAll = function(){
if (!this.multiselect || !this.selectable
|| this.disabled || !this.$selected)
return;
var nodes = this.getTraverseNodes();
this.selectList(nodes);
};
this.getSelection = function(xmldoc){
var i, r;
if (xmldoc) {
r = this.xmlRoot
? this.xmlRoot.ownerDocument.createDocumentFragment()
: jpf.getXmlDom().createDocumentFragment();
for (i = 0; i < valueList.length; i++)
jpf.xmldb.clearConnections(r.appendChild(
valueList[i].cloneNode(true)));
}
else
for (r = [], i = 0; i < valueList.length; i++)
r.push(valueList[i]);
return r;
};
this.defaultSelectNext = function(xmlNode, isTree){
var next = this.getNextTraverseSelected(xmlNode);
if (next || !isTree)
this.select(next ? next : this.getTraverseParent(xmlNode));
else
this.clearSelection(null, true);
};
this.selectNext = function(){
var xmlNode = this.getNextTraverse();
if (xmlNode)
this.select(xmlNode);
};
this.selectPrevious = function(){
var xmlNode = this.getNextTraverse(null, -1);
if (xmlNode)
this.select(xmlNode);
};
this.getDefaultNext = function(xmlNode, isTree){
var next = this.getNextTraverseSelected(xmlNode);
return (next && next != xmlNode)
? next
: (isTree
? this.getTraverseParent(xmlNode)
: null); 
};
this.isSelected = function(xmlNode){
if (!xmlNode) return false;
for (var i = 0; i < valueList.length; i++) {
if (valueList[i] == xmlNode)
return true;
}
return false;
};
this.$checkSelection = function(nextNode){
if (valueList.length > 1) {
for (var lst = [], i = 0, l = valueList.length; i < l; i++) {
if (jpf.xmldb.isChildOf(this.xmlRoot, valueList[i]))
lst.push(valueList[i]);
}
if (lst.length > 1) {
this.selectList(lst);
if(this.indicator
&& !jpf.xmldb.isChildOf(this.xmlRoot, this.indicator)) {
this.setIndicator(nextNode || this.selected);
}
return;
}
else if (lst.length) {
nextNode = lst[0];
}
}
if (!nextNode) {
if (this.selected
&& !jpf.xmldb.isChildOf(this.xmlRoot, this.selected)) {
nextNode = this.getFirstTraverseNode();
}
else if(this.selected && this.indicator
&& !jpf.xmldb.isChildOf(this.xmlRoot, this.indicator)) {
this.setIndicator(this.selected);
}
else if (!this.selected){
nextNode = this.xmlRoot
? this.getFirstTraverseNode()
: null;
}
else {
return; 
}
}
if (nextNode) {
if (this.autoselect) {
this.select(nextNode);
}
else {
if (!this.multiselect)
this.clearSelection();
this.setIndicator(nextNode);
}
}
else
this.clearSelection();
};
this.selectable = true;
if (this.ctrlselect === undefined)
this.ctrlselect = false;
if (this.multiselect === undefined)
this.multiselect = true;
if (this.autoselect === undefined)
this.autoselect = true;
if (this.delayedselect === undefined)
this.delayedselect = true;
if (this.allowdeselect === undefined)
this.allowdeselect = true;
this.reselectable = false;
this.$booleanProperties["selectable"]    = true;
this.$booleanProperties["multiselect"]   = true;
this.$booleanProperties["autoselect"]    = true;
this.$booleanProperties["delayedselect"] = true;
this.$booleanProperties["allowdeselect"] = true;
this.$booleanProperties["reselectable"]  = true;
this.$supportedProperties.push("selectable", "ctrlselect", "multiselect",
"autoselect", "delayedselect", "allowdeselect", "reselectable", "value");
this.$propHandlers["value"] = function(value){
if (!this.bindingRules && !this.caption || !this.xmlRoot)
return;
if (jpf.isNot(value))
return this.clearSelection(null, noEvent);
if (!this.xmlRoot)
return this.select(value);
var xmlNode = this.findXmlNodeByValue(value);
if (xmlNode)
this.select(xmlNode, null, null, null, null, noEvent);
else
return this.clearSelection(null, noEvent);
};
this.$propHandlers["allowdeselect"] = function(value){
if (value) {
var _self = this;
this.oInt.onmousedown = function(e){
if (!e) e = event;
if (e.ctrlKey || e.shiftKey)
return;
var srcElement = e.srcElement || e.target;
if (_self.allowdeselect && (srcElement == this
|| srcElement.getAttribute(jpf.xmldb.htmlIdTag)))
_self.clearSelection(); 
}
}
else {
this.oInt.onmousedown = null;
}
};
this.$propHandlers["ctrlselect"] = function(value){
if (value != "enter")
this.ctrlselect = jpf.isTrue(value);
}
function fAutoselect(){this.selectAll();}
this.$propHandlers["autoselect"] = function(value){
if (value == "all" && this.multiselect) {
this.addEventListener("afterload", fAutoselect);
}
else {
this.removeEventListener("afterload", fAutoselect);
}
};
this.$propHandlers["multiselect"] = function(value){
if (!value && valueList.length > 1) {
this.select(this.selected);
}
if (value)
this.bufferselect = false; 
};
this.addEventListener("beforeselect", function(e){
if (this.applyRuleSetOnNode("select", e.xmlNode, ".") === false)
return false;
});
this.addEventListener("afterselect", function (e){
if (this.bindingRules && (this.bindingRules["value"]
|| this.bindingRules["caption"]) || this.caption) {
this.value = this.applyRuleSetOnNode(this.bindingRules && this.bindingRules["value"] || this.valuerule
? "value"
: "caption", e.xmlNode);
this.setProperty("value", this.value);
}
if (this.sellength != valueList.length)
this.setProperty("sellength", valueList.length);
});
};
jpf.MultiSelectServer = {
objects : {},
register : function(xmlId, xmlNode, selList, jNode){
if (!this.uniqueId)
this.uniqueId = jpf.all.push(this) - 1;
this.objects[xmlId] = {
xml   : xmlNode,
list  : selList,
jNode : jNode
};
},
$xmlUpdate : function(action, xmlNode, listenNode, UndoObj){
if (action != "attribute") return;
var data = this.objects[xmlNode.getAttribute(jpf.xmldb.xmlIdTag)];
if (!data) return;
var nodes = xmlNode.attributes;
for (var j = 0; j < data.list.length; j++) {
jpf.xmldb.setAttribute(data.list[j], UndoObj.name,
xmlNode.getAttribute(UndoObj.name));
}
}
};
var __TRANSACTION__ = 1 << 3;
var __RENAME__ = 1 << 10;
var __XFORMS__ = 1 << 17;
var __EDITMODE__  = 1 << 15;
var __MULTILANG__ = 1 << 16;
var __DOCKING__ = 1 << 18;
var __ANCHORING__ = 1 << 13;
jpf.Anchoring = function(){
this.$regbase = this.$regbase | __ANCHORING__;
this.$anchors = [];
var VERTICAL   = 1;
var HORIZONTAL = 2;
var l = jpf.layout, inited = false, updateQueue = 0,
hordiff, verdiff, rule_v = "", rule_h = "", rule_header,
id, inited, parsed, disabled;
this.disableAnchoring = function(activate){
if (!parsed || !inited || disabled)
return;
l.removeRule(this.pHtmlNode, this.uniqueId + "_anchors");
if (l.queue)
l.queue(this.pHtmlNode);
this.$propHandlers["anchors"] =
this.$propHandlers["left"]   =
this.$propHandlers["width"]  =
this.$propHandlers["right"]  =
this.$propHandlers["top"]    =
this.$propHandlers["height"] =
this.$propHandlers["bottom"] = null;
this.$domHandlers["remove"].remove(remove);
this.$domHandlers["reparent"].remove(reparent);
if (this.right)
this.oExt.style.left = this.oExt.offsetLeft;
if (this.bottom)
this.oExt.style.top = this.oExt.offsetTop;
this.$hide = null;
this.$show = null;
inited   = false;
disabled = true; 
};
this.enableAnchoring = function(){
if (inited) 
return;
this.$supportedProperties.push("right", "bottom", "width",
"left", "top", "height");
this.$propHandlers["anchors"]  = function(value){
this.$anchors = value.splitSafe("(?:, *| )");
if (!updateQueue && jpf.loaded)
l.queue(this.pHtmlNode, this);
updateQueue = updateQueue | HORIZONTAL | VERTICAL;
};
this.$propHandlers["left"]  =
this.$propHandlers["width"] =
this.$propHandlers["right"] = function(value){
if (!updateQueue && (!jpf.isParsing || jpf.parsingFinalPass))
l.queue(this.pHtmlNode, this);
updateQueue = updateQueue | HORIZONTAL;
};
this.$propHandlers["top"]    =
this.$propHandlers["height"] =
this.$propHandlers["bottom"] = function(value){
if (!updateQueue && (!jpf.isParsing || jpf.parsingFinalPass))
l.queue(this.pHtmlNode, this);
updateQueue = updateQueue | VERTICAL;
};
this.$domHandlers["remove"].push(remove);
this.$domHandlers["reparent"].push(reparent);
this.$hide = function(){
if (!(rule_header || rule_v || rule_h))
return;
l.removeRule(this.pHtmlNode, this.uniqueId + "_anchors");
l.queue(this.pHtmlNode)
};
this.$show = function(){
if (!(rule_header || rule_v || rule_h))
return;
if (rule_v || rule_h) {
rules = rule_header + "\n" + rule_v + "\n" + rule_h;
l.setRules(this.pHtmlNode, this.uniqueId + "_anchors", rules);
this.oExt.style.display = "none";
l.queue(this.pHtmlNode, this);
}
l.processQueue();
};
inited   = true;
};
function remove(doOnlyAdmin){
if (doOnlyAdmin)
return;
if (l.queue) {
l.removeRule(this.pHtmlNode, this.uniqueId + "_anchors");
l.queue(this.pHtmlNode)
}
}
function reparent(beforeNode, pNode, withinParent, oldParent){
if (!this.$jmlLoaded)
return;
if (!withinParent && !disabled && parsed) 
this.$moveAnchoringRules(oldParent);
}
this.$moveAnchoringRules = function(oldParent, updateNow){
var rules = l.removeRule(oldParent, this.uniqueId + "_anchors");
if (rules)
l.queue(oldParent);
if (!rule_v && !rule_h)
return;
rule_header = getRuleHeader.call(this);
rules = rule_header + "\n" + rule_v + "\n" + rule_h;
this.oExt.style.display = "none";
l.setRules(this.pHtmlNode, this.uniqueId + "_anchors", rules);
l.queue(this.pHtmlNode, this);
};
this.$hasAnchorRules = function(){
return rule_v || rule_h ? true : false;
};
this.$setAnchoringEnabled = function(){
disabled = false;
};
function getRuleHeader(){
return "try{\
var oHtml = " + (jpf.hasHtmlIdsInJs
? this.oExt.getAttribute("id")
: "document.getElementById('"
+ this.oExt.getAttribute("id") + "')") + ";\
\
var pWidth = " + (this.pHtmlNode == this.pHtmlDoc.body
? (jpf.isIE
? "document.documentElement.offsetWidth"
: "window.innerWidth")
: "oHtml.parentNode.offsetWidth") + ";\
\
var pHeight = " + (this.pHtmlNode == this.pHtmlDoc.body
? (jpf.isIE
? "document.documentElement.offsetHeight"
: "window.innerHeight")
: "oHtml.parentNode.offsetHeight") + ";\
}catch(e){\
}";
}
function setPercentage(expr, value){
return String(expr).replace(jpf.percentageMatch, "((" + value + " * $1)/100)");
}
this.$updateLayout = function(){
if (!parsed) {
if (!this.oExt.getAttribute("id"))
jpf.setUniqueHtmlId(this.oExt);
var diff    = jpf.getDiff(this.oExt);
hordiff     = diff[0];
verdiff     = diff[1];
rule_header = getRuleHeader.call(this);
parsed      = true;
}
if (!updateQueue) {
if (this.visible)
this.oExt.style.display = "block";
return;
}
if (this.left || this.top || this.right || this.bottom || this.$anchors.length)
this.oExt.style.position = "absolute";
var rules;
if (updateQueue & HORIZONTAL) {
rules = [];
var left  = this.left || this.$anchors[3];
var right = this.right || this.$anchors[1];
var width = this.width;
if (right && typeof right == "string")
right = setPercentage(right, "pWidth");
if (left) {
if (parseInt(left) != left) {
left = setPercentage(left,  "pWidth");
rules.push("oHtml.style.left = (" + left + ") + 'px'");
}
else
this.oExt.style.left = left + "px";
}
if (!left && right) {
if (parseInt(right) != right) {
right = setPercentage(right, "pWidth");
rules.push("oHtml.style.right = (" + right + ") + 'px'");
}
else
this.oExt.style.right = right + "px";
}
if (width) {
if (parseInt(width) != width) {
width = setPercentage(width, "pWidth");
rules.push("oHtml.style.width = ("
+ width + " - " + hordiff + ") + 'px'");
}
else
this.oExt.style.width = (width - hordiff) + "px";
}
if (right != null && left != null) {
rules.push("oHtml.style.width = (pWidth - (" + right
+ ") - (" + left + ") - " + hordiff + ") + 'px'");
}
rule_h = (rules.length
? "try{" + rules.join(";}catch(e){};try{") + ";}catch(e){};"
: "");
}
if (updateQueue & VERTICAL) {
rules = [];
var top    = this.top || this.$anchors[0];
var bottom = this.bottom || this.$anchors[2];
var height = this.height;
if (bottom && typeof bottom == "string")
bottom = setPercentage(bottom, "pHeight");
if (top) {
if (parseInt(top) != top) {
top = setPercentage(top, "pHeight");
rules.push("oHtml.style.top = (" + top + ") + 'px'");
}
else
this.oExt.style.top = top + "px";
}
if (!top && bottom) {
if (parseInt(bottom) != bottom) {
rules.push("oHtml.style.bottom = (" + bottom + ") + 'px'");
}
else
this.oExt.style.bottom = bottom + "px";
}
if (height) {
if (parseInt(height) != height) {
height = setPercentage(height, "pHeight");
rules.push("oHtml.style.height = (" + height + " - " + verdiff + ") + 'px'");
}
else
this.oExt.style.height = (height - verdiff) + "px";
}
if (bottom != null && top != null) {
rules.push("oHtml.style.height = (pHeight - (" + bottom +
") - (" + top + ") - " + verdiff + ") + 'px'");
}
rule_v = (rules.length
? "try{" + rules.join(";}catch(e){};try{") + ";}catch(e){};"
: "");
}
if (rule_v || rule_h) {
l.setRules(this.pHtmlNode, this.uniqueId + "_anchors",
rule_header + "\n" + rule_v + "\n" + rule_h, true);
}
else {
l.removeRule(this.pHtmlNode, this.uniqueId + "_anchors");
}
updateQueue = 0;
disabled = false;
};
this.$addJmlLoader(function(){
if (updateQueue)
this.$updateLayout();
});
this.$jmlDestroyers.push(function(){
this.disableAnchoring();
});
};
var __MULTIBINDING__ = 1 << 7;
var __DRAGDROP__ = 1 << 5;
jpf.offline = {
onLine : true
}
jpf.Sort = function(xmlNode){
var settings = {};
this.parseXml = function(xmlNode, clear){ 
if (clear) settings = {};
settings.order       = xmlNode.getAttribute("order");
settings.xpath       = xmlNode.getAttribute("sort");
settings.getNodes    = self[xmlNode.getAttribute("nodes-method")];
settings.getValue    = function(item){
return jpf.getXmlValue(item, settings.xpath);
}
settings.ascending = (settings.order || "").indexOf("desc") == -1;
settings.order = null;
if (xmlNode.getAttribute("data-type")) 
settings.method = sort_methods[xmlNode.getAttribute("data-type")];
else if (xmlNode.getAttribute("sort-method")) {
settings.method = self[xmlNode.getAttribute("sort-method")];
}
else
settings.method = sort_methods["alpha"];
var str = xmlNode.getAttribute("date-format");
if (str) {
settings.sort_dateFmtStr = str;
settings.method = sort_methods["date"];
var result = str.match(/(D+|Y+|M+|h+|m+|s+)/g);
if (result) {
for (var pos = {}, i = 0; i < result.length; i++) 
pos[result[i].substr(0, 1)] = i + 1;
settings.dateFormat = new RegExp(str.replace(/([^\sDYMhms])/g, '\\$1')
.replace(/YYYY/, "(\\d\\d\\d\\d)")
.replace(/(DD|YY|MM|hh|mm|ss)/g, "(\\d\\d)"));
settings.dateReplace = "$" + pos["M"] + "/$" + pos["D"] + "/$" + pos["Y"];
if (pos["h"]) 
settings.dateReplace += " $" + pos["h"] + ":$" + pos["m"] + ":$" + pos["s"];
}
}
};
this.set = function(struct, clear){
if (clear) settings = {};
jpf.extend(settings, struct);
if (struct.order && !settings.ascending)
settings.ascending = struct.order.indexOf("desc") == -1;
settings.order = null;
if (struct["type"]) 
settings.method = sort_methods[struct["type"]];
else if (struct["method"])
settings.method = self[struct["method"]];
else if (!settings.method) 
settings.method = sort_methods["alpha"];
if (!settings.getValue) {
settings.getValue = function(item){
return jpf.getXmlValue(item, settings.xpath);
}
}
};
this.get = function(){
return jpf.extend({}, settings);
};
this.findSortSibling = function(pNode, xmlNode){
var nodes = getNodes ? getNodes(pNode, xmlNode) : this.getTraverseNodes(pNode);
for (var i = 0; i < nodes.length; i++) 
if (!compare(xmlNode, nodes[i], true, sortSettings)) 
return nodes[i];
return null;
};
var sort_intmask = ["", "0", "00", "000", "0000", "00000", "000000",
"0000000", "00000000", "000000000", "0000000000", "00000000000",
"000000000000", "0000000000000", "00000000000000"];
var sort_methods = {
"alpha" : function (n){
return n.toString().toLowerCase()
},
"number" : function (t){
return (t.length < sort_intmask.length
? sort_intmask[sort_intmask.length - t.length]
: "") + t;
},
"date" : function (t, args){
var sort_dateFormat = settings.dateFormat;
var sort_dateReplace = settings.dateReplace;
var sort_dateFmtStr = settings.sort_dateFmtStr;
if (!sort_dateFormat || (args && sort_dateFmtStr != args[0])) 
sort_dateFmt(args ? args[0] : "*");
var d;
if (sort_dateFmtStr == '*') 
d = Date.parse(t);
else 
d = (new Date(t.replace(sort_dateFormat, sort_dateReplace))).getTime();
t = "" + parseInt(d);
if (t == "NaN") 
t = "0";
return (t.length < sort_intmask.length ? sort_intmask[sort_intmask.length
- t.length] : "") + t;
}
};
this.apply = function(n, args, func, start, len){
var sa = [], i = n.length;
while (i--) {
var v = settings.getValue(n[i]);
if (n) 
sa[sa.length] = {
toString: function(){
return this.v;
},
xmlNode : n[i],
v       : (settings.method || sort_methods.alpha)(v || "", args, n[i])
};
}
sa.sort();
var end = len ? Math.min(sa.length, start + len) : sa.length;
if (!start) 
start = 0;
if (func) {
if (settings.ascending) 
for (i = start; i < end; i++) 
f(i, end, sa[i].xmlNode, sa[i].v);
else 
for (i = end - 1; i >= start; i--) 
f(end - i - 1, end, sa[i].xmlNode, sa[i].v);
}
else {
var res = [];
if (settings.ascending) 
for (i = start; i < end; i++) 
res[res.length] = sa[i].xmlNode;
else 
for (i = end - 1; i >= start; i--) 
res[res.length] = sa[i].xmlNode;
return res;
}
};
if (xmlNode) 
this.parseXml(xmlNode);
};
jpf.uirecorder = {
actionStack : [],
playStack   : [],
isPlaying   : false,
isRecording : false,
inited      : false,
init : function() {
if (jpf.uirecorder.inited)
return;
jpf.uirecorder.inited = true;
document.documentElement.onselect = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onselect",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onchange = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onchange",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onsubmit = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onsubmit",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onreset = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onreset",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onfocus = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onfocus",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onblur = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onblur",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onclick = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onclick",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.ondblclick = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "ondblclick",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onmousedown = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onmousedown",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onmouseup = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onmouseup",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onmousemove = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onmousemove",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onmouseover = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onmouseover",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onmouseout = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onmouseout",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onkeyup = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onkeyup",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onkeydown = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onkeydown",
e.srcElement || e.target, jpf.extend({}, e)]);
}
document.documentElement.onkeypress = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([new Date().getTime(), "onkeypress",
e.srcElement || e.target, jpf.extend({}, e)]);
}
var mEvents = ["DOMSubtreeModified", "DOMNodeInserted", "DOMNodeRemoved", "DOMNodeRemovedFromDocument",
"DOMNodeInsertedIntoDocument", "DOMAttrModified", "DOMCharacterDataModified", "DOMActivate"];
if(document.addEventListener) {
document.addEventListener("DOMMouseScroll", function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([
new Date().getTime(),
"DOMMouseScroll",
e.target,
jpf.extend({}, jpf.uirecorder.createMouseWheelEvent(e))
]);
}, false);
}
else {
document.onmousewheel = function(e) {
if (jpf.uirecorder.isPlaying || !jpf.uirecorder.isRecording)
return;
e = e || event;
jpf.uirecorder.actionStack.push([
new Date().getTime(),
"onmousewheel",
e.srcElement,
jpf.extend({}, jpf.uirecorder.createMouseWheelEvent(e))
]);
};
}
},
createMouseWheelEvent : function(e) {
var delta = null;
if (e.wheelDelta) {
delta = e.wheelDelta / 120;
if (jpf.isOpera)
delta *= -1;
}
else if (e.detail)
delta = -e.detail / 3;
return {
type : jpf.isGecko ? "DOMMouseScroll" : (jpf.isIE ? "mousewheel" : "DOMMouseScroll"),
delta : delta
}
},
record : function() {
jpf.uirecorder.isRecording = true;
jpf.uirecorder.init();
},
play : function() {
jpf.uirecorder.isRecording = false;
jpf.uirecorder.isPlaying   = true;
jpf.uirecorder.playStack   = jpf.uirecorder.actionStack.slice(0);
if (jpf.uirecorder.playStack.length)
playFrame();
},
stop : function() {
jpf.uirecorder.isRecording = false;
jpf.uirecorder.isPlaying   = false;
},
reset : function() {
jpf.uirecorder.isRecording = false;
jpf.uirecorder.isPlaying   = false;
jpf.uirecorder.playStack   = [];
jpf.uirecorder.actionStack = [];
}
};
var timeout;
function playFrame() {
var frame = jpf.uirecorder.playStack.shift();
if(!frame || !jpf.uirecorder.isPlaying)
return;
var lastTime = frame[0];
var simulate = false;
var src = frame[3], e;
if (jpf.isIE) {
e = document.createEventObject();
for (prop in frame[3]) {
if (frame[3][prop]) {
e[prop] = frame[3][prop];
}
}
e.target = frame[2];
switch (src.type) {
case "mousewheel":
fireScroll(frame);
break;
default:
frame[2].fireEvent(frame[1], e);
break;
}
}
else {
switch(src.type) {
case "mousemove":
case "mouseup":
case "mousedown":
case "click":
case "dblclick":
case "mouseover":
case "mouseout":
e = document.createEvent("MouseEvents");
e.initMouseEvent(src.type, src.bubbles, src.cancelable, src.view, src.detail, src.screenX,
src.screenY, src.clientX, src.clientY, src.ctrlKey, src.altKey,
src.shiftKey, src.metaKey, src.button, src.relatedTarget
);
jpf.event.layerX = src.layerX
jpf.event.layerY = src.layerY
break;
case "keyup":
case "keydown":
case "keypress":
e = document.createEvent("KeyboardEvent");
e.initKeyEvent(src.type, src.bubbles, true, window, 
src.ctrlKey, src.altKey, src.shiftKey, src.metaKey, 
src.keyCode, src.charCode); 
break;
case "select":
case "change":
case "submit":
case "reset":
e = document.createEvent("HTMLEvents");
e.initEvent(src.type, src.bubbles, src.cancelable);
break;
case "DOMActivate":
case "resize":
case "focus":
case "blur":
e = document.createEvent("UIEvents");
e.initUIEvent(src.type, src.bubbles, src.cancelable, e.view, e.detail);
break;
case "DOMMouseScroll": 
fireScroll(frame);
simulate = true;
break;
default:
jpf.console.info("default: " + src.type);
simulate = true;
break;
}
if (!simulate) {
frame[2].dispatchEvent(e);
}
}
if (jpf.uirecorder.playStack.length && jpf.uirecorder.isPlaying) {
timeout = setTimeout(function() {
playFrame();
}, jpf.uirecorder.playStack[0][0] - lastTime);
}
else {
jpf.uirecorder.stop();
clearInterval(timeout);
}
};
function fireScroll(frame) {
var el = frame[2];
while (el != document.body && el.scrollHeight == el.offsetHeight) {
el = el.parentNode || el.parentElement;
}
el.scrollTop = el.scrollTop - (jpf.isGecko
? 39
: (jpf.isChrome
? 120
: (jpf.isIE
? Math.round(el.offsetHeight / 6.73)
: 20))) * frame[3].delta;
}
jpf.layout = {
timer : null,
qlist : {},
queue : function(oHtml, obj, compile){
if (this.qlist[oHtml.getAttribute("id")]) {
if (obj)
this.qlist[oHtml.getAttribute("id")][2].push(obj);
return;
}
this.qlist[oHtml.getAttribute("id")] = [oHtml, compile, [obj]];
if(!this.timer)
this.timer = setTimeout("jpf.layout.processQueue()");
},
processQueue : function(){
clearTimeout(this.timer);
this.timer = null;
var i, id, l, qItem, list;
for (id in this.qlist) {
qItem = this.qlist[id];
if (qItem[1])
jpf.layout.compileAlignment(qItem[1]);
list = qItem[2];
for (i = 0, l = list.length; i < l; i++) {
if (list[i])
list[i].$updateLayout();
}
jpf.layout.activateRules(qItem[0]);
}
this.qlist = {};
},
rules     : {},
onresize  : {},
getHtmlId : function(oHtml){
return oHtml.getAttribute ? oHtml.getAttribute("id") : 1;
},
setRules : function(oHtml, id, rules, overwrite){
if (!this.getHtmlId(oHtml))
jpf.setUniqueHtmlId(oHtml);
if (!this.rules[this.getHtmlId(oHtml)])
this.rules[this.getHtmlId(oHtml)] = {};
var ruleset = this.rules[this.getHtmlId(oHtml)][id];
if (!overwrite && ruleset) {
this.rules[this.getHtmlId(oHtml)][id] = rules + "\n" + ruleset;
}
else
this.rules[this.getHtmlId(oHtml)][id] = rules;
},
getRules : function(oHtml, id){
return id
? this.rules[this.getHtmlId(oHtml)][id]
: this.rules[this.getHtmlId(oHtml)];
},
removeRule : function(oHtml, id){
if (!this.rules[this.getHtmlId(oHtml)])
return;
var ret = this.rules[this.getHtmlId(oHtml)][id] ||  false;
delete this.rules[this.getHtmlId(oHtml)][id];
var prop;
for (prop in this.rules[this.getHtmlId(oHtml)]) {
}
if (!prop)
delete this.rules[this.getHtmlId(oHtml)]
return ret;
},
activateRules : function(oHtml, no_exec){
if (!oHtml) { 
var prop, obj;
for(prop in this.rules) {
obj = document.getElementById(prop);
if (!obj || obj.onresize) 
continue;
this.activateRules(obj);
}
if (jpf.hasSingleRszEvent && window.onresize)
window.onresize();
return;
}
var rsz, id, rule, rules, strRules = [];
if (!jpf.hasSingleRszEvent) {
rules = this.rules[this.getHtmlId(oHtml)];
if (!rules){
oHtml.onresize = null;
return false;
}
for (id in rules) { 
if (typeof rules[id] != "string")
continue;
strRules.push(rules[id]);
}
rsz = jpf.needsCssPx
? new Function(strRules.join("\n"))
: new Function(strRules.join("\n").replace(/ \+ 'px'|try\{\}catch\(e\)\{\}\n/g,""))
oHtml.onresize = rsz;
if (!no_exec)
rsz();
}
else {
var htmlId = this.getHtmlId(oHtml);
rules = this.rules[htmlId];
if (!rules){
delete this.onresize[htmlId];
return false;
}
for (id in rules) { 
if (typeof rules[id] != "string")
continue;
strRules.push(rules[id]);
}
this.onresize[htmlId] = new Function(strRules.join("\n"));
if (!no_exec)
this.onresize[htmlId]();
if (!window.onresize) {
var f = jpf.layout.onresize;
window.onresize = function(){
var s = [];
for (var name in f)
s.unshift(f[name]);
for (var i = 0; i < s.length; i++)
s[i]();
}
}
}
},
forceResize : function(oHtml){
if (jpf.hasSingleRszEvent)
return window.onresize && window.onresize();
var rsz = oHtml.onresize;
if (rsz)
rsz();
},
paused : {},
pause  : function(oHtml, replaceFunc){
if (jpf.hasSingleRszEvent) {
var htmlId = this.getHtmlId(oHtml);
this.paused[htmlId] = this.onresize[htmlId] || true;
if (replaceFunc) {
this.onresize[htmlId] = replaceFunc;
replaceFunc();
}
else
delete this.onresize[htmlId];
}
else {
this.paused[this.getHtmlId(oHtml)] = oHtml.onresize || true;
if (replaceFunc) {
oHtml.onresize = replaceFunc;
replaceFunc();
}
else
oHtml.onresize = null;
}
},
play : function(oHtml){
if (!this.paused[this.getHtmlId(oHtml)])
return;
if (jpf.hasSingleRszEvent) {
var htmlId = this.getHtmlId(oHtml);
var oldFunc = this.paused[htmlId];
if (typeof oldFunc == "function") {
this.onresize[htmlId] = oldFunc;
}
else
delete this.onresize[htmlId];
if (window.onresize)
window.onresize();
this.paused[this.getHtmlId(oHtml)] = null;
}
else {
var oldFunc = this.paused[this.getHtmlId(oHtml)];
if (typeof oldFunc == "function") {
oHtml.onresize = oldFunc;
oldFunc();
}
else
oHtml.onresize = null;
this.paused[this.getHtmlId(oHtml)] = null;
}
}
};
jpf.tween = {
left: function(oHtml, value){
oHtml.style.left = value + "px";
},
right: function(oHtml, value){
oHtml.style.left  = "";
oHtml.style.right = value + "px";
},
top: function(oHtml, value){
oHtml.style.top = value + "px";
},
bottom: function(oHtml, value){
oHtml.style.top    = "";
oHtml.style.bottom = value + "px";
},
width: function(oHtml, value, center){
oHtml.style.width = value + "px";
},
height: function(oHtml, value, center){
oHtml.style.height = value + "px";
},
scrollTop: function(oHtml, value, center){
oHtml.scrollTop = value;
},
"height-rsz": function(oHtml, value, center){
oHtml.style.height = value + "px";
if (jpf.hasSingleResizeEvent)
window.onresize();
},
mwidth: function(oHtml, value, info) {
var diff = jpf.getDiff(oHtml);
oHtml.style.width = value + "px";
oHtml.style.marginLeft = -1*(value/2 + (parseInt(jpf.getStyle(oHtml, "borderLeftWidth")) || diff[0]/2) +
(info.margin || 0)) + "px";
},
mheight: function(oHtml, value, info) {
var diff = jpf.getDiff(oHtml);
oHtml.style.height = value + "px";
oHtml.style.marginTop = (-1*value/2 - (parseInt(jpf.getStyle(oHtml, "borderTopWidth")) || diff[1]/2) +
(info.margin || 0)) + "px";
},
scrollwidth: function(oHtml, value){
oHtml.style.width = value + "px";
oHtml.scrollLeft  = oHtml.scrollWidth;
},
scrollheight_old: function(oHtml, value){
try {
oHtml.style.height = value + "px";
oHtml.scrollTop    = oHtml.scrollHeight;
} catch (e) {
alert(value)
}
},
scrollheight: function(oHtml, value, info){
var diff = jpf.getHeightDiff(oHtml);
oHtml.style.height = value + "px";
var oInt = info.oInt || oHtml;
oInt.scrollTop     = oInt.scrollHeight - oInt.offsetHeight - diff;
},
scrolltop: function(oHtml, value){
oHtml.style.height = value + "px";
oHtml.style.top    = (-1 * value - 2) + "px";
oHtml.scrollTop    = 0;
},
clipright: function(oHtml, value, center){
oHtml.style.clip       = "rect(auto, auto, auto, " + value + "px)";
oHtml.style.marginLeft = (-1 * value) + "px";
},
fade: function(oHtml, value){
if (jpf.hasStyleFilters)
oHtml.style.filter  = "alpha(opacity=" + parseInt(value * 100) + ")";
else
oHtml.style.opacity = value;
},
bgcolor: function(oHtml, value){
oHtml.style.backgroundColor = value;
},
textcolor: function(oHtml, value){
oHtml.style.color = value;
},
htmlcss : function(oHtml, value, obj){
if (jpf.hasStyleFilters && obj.type == "filter")
oHtml.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + value + ")";
else
oHtml.style[obj.type] = value + (obj.needsPx ? "px" : "");
},
NORMAL: 0,
EASEIN: 1,
EASEOUT: 2,
queue : {},
current: null,
setQueue : function(oHtml, stepFunction){
if(!oHtml.getAttribute("id"))
jpf.setUniqueHtmlId(oHtml);
if(!this.queue[oHtml.getAttribute("id")])
this.queue[oHtml.getAttribute("id")] = [];
this.queue[oHtml.getAttribute("id")].push(stepFunction);
if(this.queue[oHtml.getAttribute("id")].length == 1)
stepFunction(0);
},
nextQueue : function(oHtml){
var q = this.queue[oHtml.getAttribute("id")];
if(!q) return;
q.shift(); 
if(q.length)
q[0](0);
},
clearQueue : function(oHtml, bStop){
var q = this.queue[oHtml.getAttribute("id")];
if(!q) return;
if (bStop && this.current && this.current.control)
this.current.control.stop = true;
q.length = 0;
},
$calcSteps : function(animtype, fromValue, toValue, nrOfSteps){
var i, value;
var steps     = [fromValue]; 
var step      = 0;
var scalex    = (toValue - fromValue) / ((Math.pow(nrOfSteps, 2)
+ 2 * nrOfSteps + 1) / (4 * nrOfSteps));
for (i = 0; i < nrOfSteps; i++) {
if (!animtype && !value)
value = (toValue - fromValue) / nrOfSteps;
else if (animtype == 1)
value = scalex * Math.pow(((nrOfSteps - i)) / nrOfSteps, 3);
else if (animtype == 2)
value = scalex * Math.pow(i / nrOfSteps, 3);
steps.push(steps[steps.length - 1]
+ value);
}
steps[steps.length - 1] = toValue;
return steps;
},
$calcColorSteps : function(animtype, fromValue, toValue, nrOfSteps){
var beginEnd = [fromValue, toValue];
for (var i = 0; i < 2; i++) {
if(beginEnd[i].match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/)){
beginEnd[i] = [parseInt(RegExp.$1), parseInt(RegExp.$2), parseInt(RegExp.$3)];
continue;
}
beginEnd[i] = beginEnd[i].replace(/^#/, "");
if(beginEnd[i].length == 3) beginEnd[i] += beginEnd[i];
beginEnd[i] = [
Math.hexToDec(beginEnd[i].substr(0,2)),
Math.hexToDec(beginEnd[i].substr(2,2)),
Math.hexToDec(beginEnd[i].substr(4,2))
];
}
var stepParts = [
jpf.tween.$calcSteps(animtype, beginEnd[0][0], beginEnd[1][0], nrOfSteps),
jpf.tween.$calcSteps(animtype, beginEnd[0][1], beginEnd[1][1], nrOfSteps),
jpf.tween.$calcSteps(animtype, beginEnd[0][2], beginEnd[1][2], nrOfSteps)
];
for (var steps = [], i = 0; i < stepParts[0].length; i++) {
steps.push("#" + Math.decToHex(stepParts[0][i])
+ Math.decToHex(stepParts[1][i])
+ Math.decToHex(stepParts[2][i]));
}
return steps;
},
single : function(oHtml, info){
info = jpf.extend({steps: 3, interval: 20, anim: jpf.tween.NORMAL, control: {}}, info);
if (oHtml.nodeFunc > 100) {
info.oInt = oHtml.oInt;
oHtml = oHtml.oExt;
}
if ("fixed|absolute|relative".indexOf(jpf.getStyle(oHtml, "position")) == -1)
oHtml.style.position = "relative";
info.method = jpf.tween[info.type];
var steps = info.color
? jpf.tween.$calcColorSteps(info.anim, info.from, info.to, info.steps)
: jpf.tween.$calcSteps(info.anim, parseFloat(info.from), parseFloat(info.to), info.steps);
var _self = this;
var stepFunction = function(step){
_self.current = info;
if (info.control && info.control.stop) {
info.control.stop = false;
jpf.tween.clearQueue(oHtml);
return;
}
try {
info.method(oHtml, steps[step], info);
} catch (e) {}
if (info.oneach)
info.oneach(oHtml, info.userdata);
if (step < info.steps)
timer = setTimeout(function(){stepFunction(step + 1)}, info.interval);
else {
_self.current = null;
if (info.control)
info.control.stopped = true;
if (info.onfinish)
info.onfinish(oHtml, info.userdata);
jpf.tween.nextQueue(oHtml);
}
};
this.setQueue(oHtml, stepFunction);
return this;
},
multi : function(oHtml, info){
info = jpf.extend({steps: 3, interval: 20, anim: jpf.tween.NORMAL, control: {}}, info);
if (oHtml.nodeFunc > 100) {
info.oInt = oHtml.oInt;
oHtml = oHtml.oExt;
}
for (var steps = [], i = 0; i < info.tweens.length; i++) {
var data = info.tweens[i];
data.method = jpf.tween[data.type] || jpf.tween.htmlcss;
steps.push(data.color
? jpf.tween.$calcColorSteps(info.anim, data.from, data.to, info.steps)
: jpf.tween.$calcSteps(info.anim, parseFloat(data.from), parseFloat(data.to), info.steps));
}
var tweens = info.tweens;
var _self  = this;
var stepFunction = function(step){
_self.current = info;
if (info.control && info.control.stop) {
info.control.stop = false;
return;
}
try {
for (var i = 0; i < steps.length; i++) {
tweens[i].method(oHtml, steps[i][step], tweens[i]);
}
} catch (e) {}
if (info.oneach)
info.oneach(oHtml, info.userdata);
if (step < info.steps)
timer = setTimeout(function(){stepFunction(step + 1)}, info.interval);
else {
_self.current = null;
if (info.control)
info.control.stopped = true;
if (info.onfinish)
info.onfinish(oHtml, info.userdata);
jpf.tween.nextQueue(oHtml);
}
};
this.setQueue(oHtml, stepFunction);
return this;
},
css : function(oHtml, className, info, remove){
(info = info || {}).tweens = [];
if (oHtml.nodeFunc > 100)
oHtml = oHtml.oExt;
if(remove)
jpf.setStyleClass(oHtml, "", [className]);
var callback = info.onfinish;
info.onfinish = function(){
if(remove)
jpf.setStyleClass(oHtml, "", [className]);
else
jpf.setStyleClass(oHtml, className);
for(var i=0;i<info.tweens.length;i++){
if (info.tweens[i].type == "filter")
continue;
oHtml.style[info.tweens[i].type] = "";
}
if (callback)
callback.apply(this, arguments);
}
var result, newvalue, curvalue, j, isColor, style, rules, i;
for(i = 0; i < document.styleSheets.length; i++){
rules = document.styleSheets[i][jpf.styleSheetRules];
for (j = 0; j < rules.length; j++) {
var rule = rules[j];
if (!rule.style || !rule.selectorText.match('\.' + className + '$'))
continue;
for(style in rule.style){
if(!rule.style[style] || this.cssProps.indexOf("|" + style + "|") == -1)
continue;
if (style == "filter") {
if (!rule.style[style].match(/opacity\=([\d\.]+)/))
continue;
newvalue = RegExp.$1;
result   = (jpf.getStyleRecur(oHtml, style) || "")
.match(/opacity\=([\d\.]+)/);
curvalue = result ? RegExp.$1 : 100;
isColor  = false;
if (newvalue == curvalue) {
if (remove) curvalue = 100;
else newvalue = 100;
}
}
else {
newvalue = remove && oHtml.style[style] || rule.style[style];
if (remove) oHtml.style[style] = "";
curvalue = jpf.getStyleRecur(oHtml, style);
isColor = style.match(/color/i) ? true : false;
}
info.tweens.push({
type    : style,
from    : (isColor ? String : parseFloat)(remove
? newvalue
: curvalue),
to      : (isColor ? String : parseFloat)(remove
? curvalue
: newvalue),
color   : isColor,
needsPx : jpf.tween.needsPix[style.toLowerCase()] || false
});
}
}
}
if(remove)
jpf.setStyleClass(oHtml, className);
return this.multi(oHtml, info);
},
needsPix : {
"left"       : true,
"top"        : true,
"bottom"     : true,
"right"      : true,
"fontSize"   : true,
"lineHeight" : true,
"textIndent" : true
},
cssProps : "|backgroundColor|backgroundPosition|color|width|filter|\
|height|left|top|bottom|right|fontSize|\
|letterSpacing|lineHeight|textIndent|opacity|\
|paddingLeft|paddingTop|paddingRight|paddingBottom|\
|borderLeftWidth|borderTopWidth|borderRightWidth|borderBottomWidth|\
|borderLeftColor|borderTopColor|borderRightColor|borderBottomColor|\
|marginLeft|marginTop|marginRight|marginBottom|"
};
jpf.printer = {
tagName  : "printer",
nodeFunc : jpf.NODE_HIDDEN,
lastContent : "",
inited      : false,
init : function(jml){
this.inited = true;
this.$jml    = jml;
this.contentShower = document.body.appendChild(document.createElement("DIV"));
this.contentShower.id = "print_content"
with (this.contentShower.style) {
width           = "100%";
height          = "100%";
backgroundColor = "white";
zIndex          = 100000000;
}
jpf.importCssString(document, "#print_content{display:none}");
jpf.importCssString(document,
"body #print_content, body #print_content *{display:block} body *{display:none}", "print");
if (jml) {
var a, i, attr = jml.attributes;
for (i = 0; i < attr.length; i++) {
a = attr[i];
if (a.nodeName.indexOf("on") == 0)
jpf.addEventListener(a.nodeName, new Function(a.nodeValue));
}
}
window.onbeforeprint = function(){
jpf.dispatchEvent("onbeforeprint");
};
window.onafterprint = function(){
jpf.dispatchEvent("onafterprint");
};
},
preview : function(strHtml){
if (!this.inited)
this.init();
if (typeof strHtml != "string")
strHtml = strHtml.outerHTML || strHtml.xml || strHtml.serialize();
this.lastContent = strHtml;
this.contentShower.innerHTML = strHtml;
}
};
jpf.print = function(strHtml){
if (!jpf.printer.inited)
jpf.printer.init();
jpf.printer.preview(strHtml);
window.print();
}
jpf.flash = (function(){
function getControlVersion(){
var version, axo, e;
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
version = axo.GetVariable("$version");
}
catch (e) {}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
version = "WIN 6,0,21,0";
axo.AllowScriptAccess = "always";
version = axo.GetVariable("$version");
}
catch (e) {}
}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
version = axo.GetVariable("$version");
}
catch (e) {}
}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
version = "WIN 3,0,18,0";
}
catch (e) {}
}
if (!version) {
try {
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
version = "WIN 2,0,0,11";
}
catch (e) {
version = -1;
}
}
return version;
}
function getSwfVersion(){
var flashVer = -1;
var sAgent   = navigator.userAgent.toLowerCase();
if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
var swVer2   = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
var swfDescr = navigator.plugins["Shockwave Flash" + swVer2].description;
var aDescr   = swfDescr.split(" ");
var aTempMaj = aDescr[2].split(".");
var nMajor   = aTempMaj[0];
var nMinor   = aTempMaj[1];
var sRev     = aDescr[3];
if (sRev == "")
sRev = aDescr[4];
if (sRev[0] == "d")
sRev = sRev.substring(1);
else if (sRev[0] == "r") {
sRev = sRev.substring(1);
if (sRev.indexOf("d") > 0)
sRev = sRev.substring(0, sRev.indexOf("d"));
}
var flashVer = nMajor + "." + nMinor + "." + sRev;
}
}
else if (sAgent.indexOf("webtv/2.6") != -1)
flashVer = 4;
else if (sAgent.indexOf("webtv/2.5") != -1)
flashVer = 3;
else if (sAgent.indexOf("webtv") != -1)
flashVer = 2;
else if (jpf.isIE && !jpf.isOpera)
flashVer = getControlVersion();
return flashVer;
}
function detectFlashVersion(reqMajorVer, reqMinorVer, reqRevision){
var versionStr = getSwfVersion();
if (versionStr == -1)
return false;
else if (versionStr != 0) {
var aVersions;
if (jpf.isIE && !jpf.isOpera) {
var aTemp = versionStr.split(" "); 
var sTemp = aTemp[1]; 
aVersions = sTemp.split(","); 
}
else
aVersions = versionStr.split(".");
var nMajor = aVersions[0];
var nMinor = aVersions[1];
var sRev   = aVersions[2];
if (nMajor > parseFloat(reqMajorVer))
return true;
else if (nMajor == parseFloat(reqMajorVer)) {
if (nMinor > parseFloat(reqMinorVer))
return true;
else if (nMinor == parseFloat(reqMinorVer)) {
if (sRev >= parseFloat(reqRevision))
return true;
}
}
return false;
}
}
function generateObj(objAttrs, params, embedAttrs, stdout){
if (stdout == "undefined")
stdout = false;
var str = [];
if (jpf.isIE && !jpf.isOpera) {
str.push('<object ');
for (var i in objAttrs)
str.push(i, '="', objAttrs[i], '" ');
str.push('>');
for (var i in params)
str.push('<param name="', i, '" value="', params[i], '" /> ');
str.push('</object>');
} else {
str.push('<embed ');
for (var i in embedAttrs)
str.push(i, '="', embedAttrs[i], '" ');
str.push('> </embed>');
}
var sOut = str.join('');
if (stdout === true)
document.write(sOut);
return sOut;
}
function AC_FL_RunContent(){
var ret = AC_GetArgs(arguments,
"movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",
"application/x-shockwave-flash");
return generateObj(ret.objAttrs, ret.params, ret.embedAttrs);
}
function buildContent() {
var hasRequestedVersion = isEightAvailable();
if (isAvailable() && !hasRequestedVersion)
return jpf.flash.buildInstaller();
if (hasRequestedVersion)
return AC_FL_RunContent.apply(null, Array.prototype.slice.call(arguments));
return 'This content requires the \
<a href="http://www.adobe.com/go/getflash/">Adobe Flash Player</a>.';
}
function buildInstaller() {
var MMPlayerType  = (jpf.isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
var MMdoctitle = document.title;
return AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL=" + MMredirectURL + "&MMplayerType="
+ MMPlayerType + "&MMdoctitle=" + MMdoctitle + "",
"width", "100%",
"height", "100%",
"align", "middle",
"id", this.name,
"quality", "high",
"bgcolor", "#000000",
"name", this.name,
"allowScriptAccess","always",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
}
function AC_GetArgs(args, srcParamName, classid, mimeType){
var ret        = {};
ret.embedAttrs = {};
ret.params     = {};
ret.objAttrs   = {};
for (var i = 0; i < args.length; i = i + 2) {
var currArg = args[i].toLowerCase();
switch (currArg) {
case "classid":
break;
case "pluginspage":
ret.embedAttrs[args[i]] = args[i + 1];
break;
case "src":
case "movie":
ret.embedAttrs["src"] = args[i + 1];
ret.params[srcParamName] = args[i + 1];
break;
case "onafterupdate":
case "onbeforeupdate":
case "onblur":
case "oncellchange":
case "onclick":
case "ondblClick":
case "ondrag":
case "ondragend":
case "ondragenter":
case "ondragleave":
case "ondragover":
case "ondrop":
case "onfinish":
case "onfocus":
case "onhelp":
case "onmousedown":
case "onmouseup":
case "onmouseover":
case "onmousemove":
case "onmouseout":
case "onkeypress":
case "onkeydown":
case "onkeyup":
case "onload":
case "onlosecapture":
case "onpropertychange":
case "onreadystatechange":
case "onrowsdelete":
case "onrowenter":
case "onrowexit":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
case "type":
case "codebase":
case "id":
ret.objAttrs[args[i]] = args[i + 1];
break;
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "title":
case "accesskey":
case "name":
case "tabindex":
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i + 1];
break;
default:
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i + 1];
}
}
ret.objAttrs["classid"] = classid;
if (mimeType)
ret.embedAttrs["type"] = mimeType;
return ret;
}
function getElement(id) {
var elem;
if (typeof id == "object")
return id;
if (jpf.isIE)
return window[id];
else {
elem = document[id] ? document[id] : document.getElementById(id);
if (!elem)
elem = jpf.lookup(id);
return elem;
}
}
var hash     = {};
var uniqueID = 1;
function addPlayer(player) {
hash[++uniqueID] = player;
return uniqueID;
}
function getPlayer(id) {
return hash[id];
}
function callMethod(id, methodName) {
var player = hash[id];
if (player == null)
throw new Error(jpf.formatErrorString(0, this, "Player with id: " + id + " not found"));
if (player[methodName] == null)
throw new Error(jpf.formatErrorString(0, this, "Method " + methodName + " Not found"));
var args = [];
for (var i = 2; i < arguments.length; i++)
args.push(decode(arguments[i]));
player[methodName].apply(player, args);
}
function encode(data) {
if (!data || typeof data != "string")
return data;
data = data.replace(/\&([^;]*)\;/g, "&amp;$1;");
data = data.replace(/</g, "&lt;");
data = data.replace(/>/g, "&gt;");
data = data.replace("\\", "&custom_backslash;");
data = data.replace(/\0/g, "\\0"); 
data = data.replace(/\"/g, "&quot;");
return data;
}
function decode(data) {
if (data && data.length && typeof data != "string")
data = data[0];
if (!data || typeof data != "string")
return data;
data = data.replace(/\&custom_lt\;/g, "<");
data = data.replace(/\&custom_gt\;/g, ">");
data = data.replace(/\&custom_backslash\;/g, '\\');
data = data.replace(/\\0/g, "\0");
return data;
}
var aIsAvailable = {};
function isAvailable(sVersion) {
if (typeof sVersion != "string")
sVersion = "6.0.65";
var aVersion = sVersion.split('.');
while (aVersion.length < 3)
aVersion.push('0');
if (typeof aIsAvailable[sVersion] == "undefined")
aIsAvailable[sVersion] = detectFlashVersion(parseInt(aVersion[0]),
parseInt(aVersion[1]), parseInt(aVersion[2]));
return aIsAvailable[sVersion];
}
function isEightAvailable() {
return isAvailable('8.0.0');
}
var oSandboxTypes = {
remote          : 'remote (domain-based) rules',
localwithfile   : 'local with file access (no internet access)',
localwithnetwork: 'local with network (internet access only, no local access)',
localtrusted    : 'local, trusted (local + internet access)'
};
function getSandbox(sType) {
var oSandbox = {
type       : null,
description: null,
noRemote   : false,
noLocal    : false,
error      : null
};
oSandbox.type = sType.toLowerCase();
oSandbox.description = oSandboxTypes[(typeof oSandboxTypes[oSandbox.type] != 'undefined'
? oSandbox.type
: 'unknown')];
if (oSandbox.type == 'localwithfile') {
oSandbox.noRemote = true;
oSandbox.noLocal  = false;
oSandbox.error    = "Flash security note: Network/internet URLs will not \
load due to security restrictions.\
Access can be configured via Flash Player Global Security\
Settings Page: \
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html";
}
else if (oSandbox.type == 'localwithnetwork') {
oSandbox.noRemote = false;
oSandbox.noLocal  = true;
}
else if (oSandbox.type == 'localtrusted') {
oSandbox.noRemote = false;
oSandbox.noLocal  = false;
}
return oSandbox;
}
return {
isAvailable     : isAvailable,
isEightAvailable: isEightAvailable,
buildContent    : buildContent,
encode          : encode,
decode          : decode,
getElement      : getElement,
addPlayer       : addPlayer,
getPlayer       : getPlayer,
callMethod      : callMethod,
getSandbox      : getSandbox
};
})();
jpf.formatXml = function(strXml){
if (!strXml) return "";
strXml = strXml.trim();
var lines = strXml.split("\n");
for (var i = 0; i < lines.length; i++)
lines[i] = lines[i].trim();
lines = lines.join("\n").replace(/\>\n/g, ">").replace(/\>/g, ">\n")
.replace(/\n\</g, "<").replace(/\</g, "\n<").split("\n");
lines.removeIndex(0);
lines.removeIndex(lines.length);
for (var depth = 0, i = 0; i < lines.length; i++)
lines[i] = "\t".repeat((lines[i].match(/^\s*\<\//)
? --depth
: (lines[i].match(/^\s*\<[^\?][^>]+[^\/]\>/) ? depth++ : depth))) + lines[i];
return lines.join("\n");
};
jpf.highlightXml = function(str){
return str.replace(/^[\r\n]/g,"").replace(/</g, "_@A@_")
.replace(/>/g, "_@B@_")
.replace(/(\s[\w-]+)(\s*=\s*)("[^"]*")/g, '<span style="color:#e61414">$1</span>$2<span style="color:black">$3</span>')
.replace(/(\s[\w-]+)(\s*=\s*)('[^']*')/g, "<span style='color:#e61414'>$1</span>$2<span style='color:black'>$3</span>")
.replace(/\t/g, "&nbsp;&nbsp;&nbsp;")
.replace(/\n/g, "<br />")
.replace(/_@B@_/g, "<span style='color:#0866ab'>&gt;</span>")
.replace(/_@A@_([\-\!\[\\/\w:\.]+)?/g, "<span style='color:#0866ab'>&lt;$1</span>");
}
jpf.highlightCode = function(strCode){
return strCode.replace(/^[\r\n]/g,"").replace(/</g, "_@A@_")
.replace(/>/g, "_@B@_")
.replace(/((?:\s|^)[\w-]+)(\s*=\s*)("[^"]*")/g, '<span style="color:red">$1</span>$2<span style="color:black">$3</span>')
.replace(/((?:\s|^)[\w-]+)(\s*=\s*)('[^']*')/g, "<span style='color:red'>$1</span>$2<span style='color:black'>$3</span>")
.replace(/(_@A@_[\s\S]*?_@B@_|<[\s\S]*?>)|(\/\/.*)$|("(?:[^"]+|\\.)*")|('(?:[^']+|\\.)*')|(\W)(break|continue|do|for|import|new|this|void|case|default|else|function|in|return|typeof|while|comment|delete|export|if|label|switch|var|with|abstract|implements|protected|boolean|instanceOf|public|byte|int|short|char|interface|static|double|long|synchronized|false|native|throws|final|null|transient|float|package|true|goto|private|catch|enum|throw|class|extends|try|const|finally|debugger|super)(\W)|(\W)(\w+)(\s*\()/gm,
function(m, tag, co, str1, str2, nw, kw, nw2, fW, f, fws) {
if (tag) return tag;
else if (f)
return fW + '<span style="color:#ff8000">' + f + '</span>' + fws;
else if (co)
return '<span style="color:green">' + co + '</span>';
else if (str1 || str2)
return '<span style="color:#808080">' + (str1 || str2) + '</span>';
else if (nw)
return nw + '<span style="color:#127ac6">' + kw + '</span>' + nw2;
})
.replace(/_@A@_(!--[\s\S]*?--)_@B@_/g, '<span style="color:green">&lt;$1&gt;</span>')
.replace(/\t/g, "&nbsp;&nbsp;&nbsp;")
.replace(/\n/g, "<br />")
.replace(/_@B@_/g, "<span style='color:#127ac6'>&gt;</span>")
.replace(/_@A@_([\-\!\[\\/\w:\.]+)?/g, "<span style='color:#127ac6'>&lt;$1</span>")
}
jpf.highlightCode2 = function(strCode){
var comment=[];
return strCode
.replace(/(\/\*[\s\S]*?\*\/|\/\/.*)/g, function(a){ comment.push(a); return '###n'+(comment.length-1)+'###';})        
.replace(/(\<)|(\>)/g,function(a,b){ return "<span stylecolorwhite>"+(a?'@lt@':'@gt@')+"</span>"})
.replace(/(\'.*?\'|\".*?\")/g, "<span stylecolorgray>$1</span>")
.replace(/(\W)-?([\d\.]+)(\W)/g, "$1<span stylecolor#127ac6>$2</span>$3")
.replace(/([\|\&\=\;\,\:\?\+\*\-]+)/g, "<span stylecolorwhite>$1</span>")
.replace(/(\W)(break|continue|do|for|import|new|this|void|case|default|else|function|in|return|typeof|while|comment|delete|export|if|label|switch|var|with|abstract|implements|protected|boolean|instanceOf|public|byte|int|short|char|interface|static|double|long|synchronized|false|native|throws|final|null|transient|float|package|true|goto|private|catch|enum|throw|class|extends|try|const|finally|debugger|super)(\W)/g,
"$1<span stylecolorgreen>$2</span>$3")
.replace(/([\(\)\{\}\[\]])/g, "<span stylecoloryellow>$1</span>")
.replace(/###n(\d+)###/g,function(a,b){ return "<span stylecolorpurple>"+comment[b]+"</span>"; } )
.replace(/stylecolor(.*?)\>/g,"style='color:$1'>")
.replace(/@(.*?)@/g,"&$1;");
}
jpf.formatJS = function(strJs){
var d = 0, r = 0;
var comment=[];
return strJs
.replace(/(\/\*[\s\S]*?\*\/|\/\/.*)/g, function(a){ comment.push(a); return '###n'+(comment.length-1)+'###';})    
.replace(/;+/g, ';').replace(/{;/g, '{').replace(/({)|(})|(\()|(\))|(;)/g,
function(m, co, cc, ro, rc, e){
if (co) d++;
if (cc) d--;
if (ro){ r++; return ro;}
if (rc){ r--; return rc;}
var o = '';
for (var i = 0; i < d; i++)
o += '\t';
if (co) return '{\n' + o;
if (cc) return '\n' + o + '}';
if (e) return (r>0)?e:(';\n' + o);
}).replace(/;\s*\n\s*\n/g, ';\n').replace(/}var/g, '}\nvar').replace(/([\n\s]*)###n(\d+)###[\n\s]*/g,function(a,b,c){ return b+comment[c]+b; } );
};
jpf.pasteWindow = function(str){
var win = window.open("about:blank");
win.document.write(str);
};
jpf.xmlEntityMap = {
'quot': '34', 'amp': '38', 'apos': '39', 'lt': '60', 'gt': '62',
'nbsp': '160', 'iexcl': '161', 'cent': '162', 'pound': '163', 'curren': '164',
'yen': '165', 'brvbar': '166', 'sect': '167', 'uml': '168', 'copy': '169',
'ordf': '170', 'laquo': '171', 'not': '172', 'shy': '173', 'reg': '174', 'macr': '175',
'deg': '176', 'plusmn': '177', 'sup2': '178', 'sup3': '179', 'acute': '180',
'micro': '181', 'para': '182', 'middot': '183', 'cedil': '184', 'sup1': '185',
'ordm': '186', 'raquo': '187', 'frac14': '188', 'frac12': '189', 'frac34': '190',
'iquest': '191', 'Agrave': '192', 'Aacute': '193', 'Acirc': '194', 'Atilde': '195',
'Auml': '196', 'Aring': '197', 'AElig': '198', 'Ccedil': '199', 'Egrave': '200',
'Eacute': '201', 'Ecirc': '202', 'Euml': '203', 'Igrave': '204', 'Iacute': '205',
'Icirc': '206', 'Iuml': '207', 'ETH': '208', 'Ntilde': '209', 'Ograve': '210',
'Oacute': '211', 'Ocirc': '212', 'Otilde': '213', 'Ouml': '214', 'times': '215',
'Oslash': '216', 'Ugrave': '217', 'Uacute': '218', 'Ucirc': '219', 'Uuml': '220',
'Yacute': '221', 'THORN': '222', 'szlig': '223', 'agrave': '224', 'aacute': '225',
'acirc': '226', 'atilde': '227', 'auml': '228', 'aring': '229', 'aelig': '230',
'ccedil': '231', 'egrave': '232', 'eacute': '233', 'ecirc': '234', 'euml': '235',
'igrave': '236', 'iacute': '237', 'icirc': '238', 'iuml': '239', 'eth': '240',
'ntilde': '241', 'ograve': '242', 'oacute': '243', 'ocirc': '244', 'otilde': '245',
'ouml': '246', 'divide': '247', 'oslash': '248', 'ugrave': '249', 'uacute': '250',
'ucirc': '251', 'uuml': '252', 'yacute': '253', 'thorn': '254', 'yuml': '255',
'OElig': '338', 'oelig': '339', 'Scaron': '352', 'scaron': '353', 'Yuml': '376',
'fnof': '402', 'circ': '710', 'tilde': '732', 'Alpha': '913', 'Beta': '914',
'Gamma': '915', 'Delta': '916', 'Epsilon': '917', 'Zeta': '918', 'Eta': '919',
'Theta': '920', 'Iota': '921', 'Kappa': '922', 'Lambda': '923', 'Mu': '924',
'Nu': '925', 'Xi': '926', 'Omicron': '927', 'Pi': '928', 'Rho': '929', 'Sigma': '931',
'Tau': '932', 'Upsilon': '933', 'Phi': '934', 'Chi': '935', 'Psi': '936', 'Omega': '937',
'alpha': '945', 'beta': '946', 'gamma': '947', 'delta': '948', 'epsilon': '949',
'zeta': '950', 'eta': '951', 'theta': '952', 'iota': '953', 'kappa': '954',
'lambda': '955', 'mu': '956', 'nu': '957', 'xi': '958', 'omicron': '959', 'pi': '960',
'rho': '961', 'sigmaf': '962', 'sigma': '963', 'tau': '964', 'upsilon': '965',
'phi': '966', 'chi': '967', 'psi': '968', 'omega': '969', 'thetasym': '977', 'upsih': '978',
'piv': '982', 'ensp': '8194', 'emsp': '8195', 'thinsp': '8201', 'zwnj': '8204',
'zwj': '8205', 'lrm': '8206', 'rlm': '8207', 'ndash': '8211', 'mdash': '8212',
'lsquo': '8216', 'rsquo': '8217', 'sbquo': '8218', 'ldquo': '8220', 'rdquo': '8221',
'bdquo': '8222', 'dagger': '8224', 'Dagger': '8225', 'bull': '8226', 'hellip': '8230',
'permil': '8240', 'prime': '8242', 'Prime': '8243', 'lsaquo': '8249', 'rsaquo': '8250',
'oline': '8254', 'frasl': '8260', 'euro': '8364', 'image': '8465', 'weierp': '8472',
'real': '8476', 'trade': '8482', 'alefsym': '8501', 'larr': '8592', 'uarr': '8593',
'rarr': '8594', 'darr': '8595', 'harr': '8596', 'crarr': '8629', 'lArr': '8656',
'uArr': '8657', 'rArr': '8658', 'dArr': '8659', 'hArr': '8660', 'forall': '8704',
'part': '8706', 'exist': '8707', 'empty': '8709', 'nabla': '8711', 'isin': '8712',
'notin': '8713', 'ni': '8715', 'prod': '8719', 'sum': '8721', 'minus': '8722',
'lowast': '8727', 'radic': '8730', 'prop': '8733', 'infin': '8734', 'ang': '8736',
'and': '8743', 'or': '8744', 'cap': '8745', 'cup': '8746', 'int': '8747', 'there4': '8756',
'sim': '8764', 'cong': '8773', 'asymp': '8776', 'ne': '8800', 'equiv': '8801', 'le': '8804',
'ge': '8805', 'sub': '8834', 'sup': '8835', 'nsub': '8836', 'sube': '8838',
'supe': '8839', 'oplus': '8853', 'otimes': '8855', 'perp': '8869', 'sdot': '8901',
'lceil': '8968', 'rceil': '8969', 'lfloor': '8970', 'rfloor': '8971', 'lang': '9001',
'rang': '9002', 'loz': '9674', 'spades': '9824', 'clubs': '9827', 'hearts': '9829',
'diams': '9830'
};
jpf.htmlentities = function(str){
return str.escapeHTML();
};
jpf.xmlentities = function(str) {
return str.replace(/&([a-z]+);/gi, function(a, m) {
if (jpf.xmlEntityMap[m])
return '&#' + jpf.xmlEntityMap[m] + ';';
return a;
});
};
jpf.html_entity_decode = function(str){
return (str || "").replace(/\&\#38;/g, "&").replace(/&lt;/g, "<")
.replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&nbsp;/g, " ");
};
jpf.randomGenerator = {
d: new Date(),
seed: null,
A: 48271,
M: 2147483647,
Q: null,
R: null,
oneOverM: null,
generate: function(lnr, unr) {
if (this.seed == null)
this.seed = 2345678901 + (this.d.getSeconds() * 0xFFFFFF) + (this.d.getMinutes() * 0xFFFF);
this.Q = this.M / this.A;
this.R = this.M % this.A;
this.oneOverM = 1.0 / this.M;
return Math.floor((unr - lnr + 1) * this.next() + lnr);
},
next: function() {
var hi = this.seed / this.Q;
var lo = this.seed % this.Q;
var test = this.A * lo - this.R * hi;
if (test > 0)
this.seed = test;
else
this.seed = test + this.M;
return (this.seed * this.oneOverM);
}
};
jpf.getNoCacheUrl = function(url){
return url
+ (url.indexOf("?") == -1 ? "?" : "&")
+ "nocache=" + new Date().getTime();
};
jpf.parseExpression = function(str){
if (!jpf.parseExpression.regexp.test(str))
return str;
return eval(RegExp.$1);
};
jpf.parseExpression.regexp = /^\{(.*)\}$/;
jpf.formatNumber = function(num, prefix){
var nr = parseFloat(num);
if (!nr) return num;
var str = new String(Math.round(nr * 100) / 100).replace(/(\.\d?\d?)$/, function(m1){
return m1.pad(3, "0", jpf.PAD_RIGHT);
});
if (str.indexOf(".") == -1)
str += ".00";
return prefix + str;
};
// Serialize Objects
jpf.JSONSerialize = {
object: function(o){
//XML support - NOTICE: Javeline PlatForm specific
if (o.nodeType && o.cloneNode)
return "jpf.xmldb.getXml("
+ this.string(jpf.xmldb.serializeNode(o)) + ")";
//Normal JS object support
var str = [];
for (var prop in o) {
str.push('"' + prop.replace(/(["\\])/g, '\\$1') + '": '
+ jpf.serialize(o[prop]));
}
return "{" + str.join(", ") + "}";
},
string: function(s){
s = '"' + s.replace(/(["\\])/g, '\\$1') + '"';
return s.replace(/(\n)/g, "\\n").replace(/\r/g, "");
},
number: function(i){
return i.toString();
},
"boolean": function(b){
return b.toString();
},
date: function(d){
var padd = function(s, p){
s = p + s;
return s.substring(s.length - p.length);
};
var y   = padd(d.getUTCFullYear(), "0000");
var m   = padd(d.getUTCMonth() + 1, "00");
var D   = padd(d.getUTCDate(), "00");
var h   = padd(d.getUTCHours(), "00");
var min = padd(d.getUTCMinutes(), "00");
var s   = padd(d.getUTCSeconds(), "00");
var isodate = y + m + D + "T" + h + ":" + min + ":" + s;
return '{"jsonclass":["sys.ISODate", ["' + isodate + '"]]}';
},
array: function(a){
for (var q = [], i = 0; i < a.length; i++)
q.push(jpf.serialize(a[i]));
return "[" + q.join(", ") + "]";
}
};
jpf.serialize = function(args){
if (typeof args == "function" || jpf.isNot(args))
return "null";
return jpf.JSONSerialize[args.dataType || "object"](args);
};
jpf.unserialize = function(str, secure){
if (!str) return str;
if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/)
.test(str.replace(/\\./g, '@').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, '')))
return str;
return eval('(' + str + ')');
};
jpf.exec = function(str, win){
if (!str)
return str;
if (!win)
win = self;
if (jpf.hasExecScript) {
win.execScript(str);
}
else {
var head = win.document.getElementsByTagName("head")[0];
if (head) {
var script = win.document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.text = str;
head.appendChild(script);
head.removeChild(script);
} else
eval(str, win);
}
return str;
};
jpf.K = function(){};
jpf.isNull = function(value){
if (value)
return false;
return (value == null || !String(value).length);
};
jpf.isNumber = function(value){
return parseFloat(value) == value;
};
jpf.isArray = function(value) {
return Object.prototype.toString.call(value) === "[object Array]";
};
jpf.isTrue = function(c){
return (c === true || c === "true" || c === "on" || typeof c == "number" && c > 0 || c === "1");
};
jpf.isFalse = function(c){
return (c === false || c === "false" || c === "off" || c === 0 || c === "0");
};
jpf.isNot = function(c){
return (!c && typeof c != "string" && c !== 0 || (typeof c == "number" && !isFinite(c)));
};
jpf.getDirname = function(url){
return ((url || "").match(/^(.*\/)[^\/]*$/) || {})[1]; 
};
jpf.getFilename = function(url){
return ((url || "").split("?")[0].match(/(?:\/|^)([^\/]+)$/) || {})[1];
};
jpf.getAbsolutePath = function(base, url){
return !url || url.match(/^\w+\:\/\//) ? url : base + url;
};
jpf.removePathContext = function(base, url){
if (!url)  return "";
if (url.indexOf(base) > -1)
return url.substr(base.length);
return url;
};
jpf.cancelBubble = function(e, o){
e.cancelBubble = true;
if (o.$focussable && !o.disabled)
jpf.window.$focus(o);
};
jpf.getXmlValue = function (xmlNode, xpath){
if (!xmlNode) return "";
xmlNode = xmlNode.selectSingleNode(xpath);
if (xmlNode && xmlNode.nodeType == 1)
xmlNode = xmlNode.firstChild;
return xmlNode ? xmlNode.nodeValue : "";
};
jpf.getXmlValues = function(xmlNode, xpath){
var out = [];
if (!xmlNode) return out;
var nodes = xmlNode.selectNodes(xpath);
if (!nodes.length) return out;
for (var i = 0; i < nodes.length; i++) {
var n = nodes[i];
if (n.nodeType == 1)
n = n.firstChild;
out.push(n.nodeValue || "");
}
return out;
};
jpf.removeNode = function (element) {
if (!element) return;
if (!jpf.isIE || element.ownerDocument != document) {
if (element.parentNode)
element.parentNode.removeChild(element);
return;
}
var garbageBin = document.getElementById('IELeakGarbageBin');
if (!garbageBin) {
garbageBin    = document.createElement('DIV');
garbageBin.id = 'IELeakGarbageBin';
garbageBin.style.display = 'none';
document.body.appendChild(garbageBin);
}
garbageBin.appendChild(element);
garbageBin.innerHTML = '';
};
jpf.getRules = function(node){
var rules = {};
for (var w = node.firstChild; w; w = w.nextSibling){
if (w.nodeType != 1)
continue;
else {
if (!rules[w[jpf.TAGNAME]])
rules[w[jpf.TAGNAME]] = [];
rules[w[jpf.TAGNAME]].push(w);
}
}
return rules;
};
jpf.getBox = function(value, base){
if (!base) base = 0;
if (value == null || (!parseInt(value) && parseInt(value) != 0))
return [0, 0, 0, 0];
var x = value.split(" ");
for (var i = 0; i < x.length; i++)
x[i] = parseInt(x[i]) || 0;
switch (x.length) {
case 1:
x[1] = x[0];
x[2] = x[0];
x[3] = x[0];
break;
case 2:
x[2] = x[0];
x[3] = x[1];
break;
case 3:
x[3] = x[1];
break;
}
return x;
};
jpf.getNode = function(data, tree){
var nc = 0;
if (data != null) {
for (var i = 0; i < data.childNodes.length; i++) {
if (data.childNodes[i].nodeType == 1) {
if (nc == tree[0]) {
data = data.childNodes[i];
if (tree.length > 1) {
tree.shift();
data = this.getNode(data, tree);
}
return data;
}
nc++
}
}
}
return null;
};
jpf.getFirstElement = function(xmlNode){
return xmlNode.firstChild.nodeType == 1
? xmlNode.firstChild
: xmlNode.firstChild.nextSibling;
};
jpf.getLastElement = function(xmlNode){
return xmlNode.lastChild.nodeType == 1
? xmlNode.lastChild
: xmlNode.lastChild.previousSibling;
};
jpf.selectTextHtml = function(oHtml){
if (!jpf.hasMsRangeObject) return;
var r = document.selection.createRange();
try {r.moveToElementText(oHtml);} catch(e){}
r.select();
};
jpf.popup = {
cache      : {},
setContent : function(cacheId, content, style, width, height){
if (!this.popup) this.init();
this.cache[cacheId] = {
content : content,
style   : style,
width   : width,
height  : height
};
content.style.position = "absolute";
content.onmousedown  = function(e) {
if (!e) e = event;
(e || event).cancelBubble = true;
};
return content.ownerDocument;
},
removeContent : function(cacheId){
this.cache[cacheId] = null;
delete this.cache[cacheId];
},
init : function(){
this.popup = {};
jpf.addEventListener("hotkey", function(e){
if (e.keyCode == "27" || e.altKey) 
jpf.popup.forceHide();
});
},
show : function(cacheId, options){
options = jpf.extend({
x            : 0,
y            : 0,
animate      : false,
ref          : null,
width        : null,
height       : null,
callback     : null,
draggable    : false,
resizable    : false,
allowTogether: false
}, options);
if (!this.popup)
this.init();
if ((!options.allowTogether || options.allowTogether != this.last) && this.last != cacheId)
this.hide();
var o = this.cache[cacheId];
o.options = options;
var popup = o.content;
if (!o.content.style.zIndex)
o.content.style.zIndex = 10000000;
if (o.content.style.display && o.content.style.display.indexOf('none') > -1)
o.content.style.display = "";
if (options.ref) {
var pos    = jpf.getAbsolutePosition(options.ref);
var top    = (options.y || 0) + pos[1];
var p      = jpf.getOverflowParent(o.content); 
if (options.width || o.width)
popup.style.width = ((options.width || o.width) - 3) + "px";
var moveUp = false;
if (moveUp)
popup.style.top = (pos[1] - (options.height || o.height || o.content.offsetHeight)) + "px"
else
popup.style.top = top + "px";
popup.style.left = ((options.x || 0) + pos[0]) + "px";
}
if (options.animate) {
if (options.animate == "fade") {
jpf.tween.single(popup, {
type  : 'fade',
from  : 0,
to    : 1,
anim  : jpf.tween.NORMAL,
steps : jpf.isIE ? 5 : 10
});
}
else { 
var iVal, steps = 7, i = 0;
iVal = setInterval(function(){
var value = ++i * ((options.height || o.height) / steps);
popup.style.height = value + "px";
if (moveUp)
popup.style.top = (top - value - options.y) + "px";
else
popup.scrollTop = -1 * (i - steps - 1) * ((options.height || o.height) / steps);
popup.style.display = "block";
if (i >= steps) {
clearInterval(iVal)
if (options.callback)
options.callback(popup);
}
}, 10);
}
}
else {
if (options.height || o.height)
popup.style.height = (options.height || o.height) + "px";
if (options.callback)
options.callback(popup);
}
setTimeout(function(){
jpf.popup.last = cacheId;
});
if (options.draggable) {
options.id = cacheId;
this.makeDraggable(options);
}
},
hide : function(){
if (this.isDragging) return;
var o = this.cache[this.last];
if (o) {
if (o.content)
o.content.style.display = "none";
if (o.options.onclose) {
o.options.onclose(jpf.extend(o.options, {htmlNode: o.content}));
o.options.onclose = false;
}
}
},
isShowing : function(cacheId){
return this.last && this.last == cacheId && this.cache[this.last]
&& this.cache[this.last].content.style.display != "none";
},
isDragging   : false,
makeDraggable: function(options) {
if (!jpf.Interactive || this.cache[options.id].draggable) 
return;
var oHtml = this.cache[options.id].content;
this.cache[options.id].draggable = true;
var o = {
$propHandlers : {},
minwidth      : 10,
minheight     : 10,
maxwidth      : 10000,
maxheight     : 10000,
dragOutline   : false,
resizeOutline : false,
draggable     : true,
resizable     : options.resizable,
oExt          : oHtml,
oDrag         : oHtml.firstChild
};
oHtml.onmousedown =
oHtml.firstChild.onmousedown = function(e){
if (!e) e = event;
(e || event).cancelBubble = true;
}
jpf.inherit.call(o, jpf.Interactive);
o.$propHandlers["draggable"].call(o, true);
o.$propHandlers["resizable"].call(o, true);
},
forceHide : function(){
if (this.last && !jpf.plane.current && this.isShowing(this.last)) {
var o = jpf.lookup(this.last);
if (!o)
this.last = null;
else if (o.dispatchEvent("popuphide") !== false)
this.hide();
}
},
destroy : function(){
for (var cacheId in this.cache) {
if (this.cache[cacheId]) {
this.cache[cacheId].content.onmousedown = null;
jpf.removeNode(this.cache[cacheId].content);
this.cache[cacheId].content = null;
}
}
if (!this.popup) return;
}
}
if (typeof isFinite == "undefined") {
function isFinite(val){
return val + 1 != val;
}
}
Array.prototype.dataType    = "array";
Number.prototype.dataType   = "number";
Date.prototype.dataType     = "date";
Boolean.prototype.dataType  = "boolean";
String.prototype.dataType   = "string";
RegExp.prototype.dataType   = "regexp";
Function.prototype.dataType = "function";
jpf.getCgiString = function(args, multicall, mcallname){
var vars = [];
function recur(o, stack) {
if (jpf.isArray(o)) {
for (var j = 0; j < o.length; j++)
recur(o[j], stack + "%5B%5D");
} 
else if (typeof o == "object") {
for (prop in o) {
if (jpf.isSafariOld && (!o[prop] || typeof p[prop] != "object"))
continue;
if (typeof o[prop] == "function")
continue;
recur(o[prop], stack + "%5B" + encodeURIComponent(prop) + "%5D");
}
}
else
vars.push(stack + "=" + encodeURIComponent(o));
};
if (multicall) {
vars.push("func=" + mcallname);
for (var i = 0; i < args[0].length; i++)
recur(args[0][i], "f%5B" + i + "%5D");
} else {
for (prop in args) {
if (jpf.isSafariOld && (!args[prop] || typeof args[prop] == "function"))
continue;
recur(args[prop], prop);
}
}
return vars.join("&");
}
jpf.fromCgiString = function(args) {
if (!args)
return false;
var obj = {};
args = args.split("&");
for (var data, i = 0; i < args.length; i++) {
data = args[i].split("=");
data[0] = decodeURIComponent(data[0]);
var path = data[0].replace(/\]/g, "").split("[");
var spare = obj;
for (var j = 0; j < path.length; j++) {
if (spare[path[j]])
spare = spare[path[j]];
else if (path.length == j+1) {
if (path[j])
spare[path[j]] = decodeURIComponent(data[1]);
else
spare.push(decodeURIComponent(data[1]));
break; 
}
else{
spare[path[j]] = !path[j+1] ? [] : {};
spare = spare[path[j]];
}
}
}
return obj;
}
Function.prototype.extend = function() {
jpf.extend.apply(this, [this].concat(Array.prototype.slice.call(arguments)));
return this;
};
Function.prototype.bindWithEvent = function() {
var __method = this, args = Array.prototype.slice.call(arguments), 
o  = args.shift(),
ev = args.shift();
return function(event) {
if (!event) event = window.event;
return __method.apply(o, [event].concat(args)
.concat(Array.prototype.slice.call(arguments)));
}
};
Array.prototype.copy = function(){
var ar = [];
for (var i = 0, j = this.length; i < j; i++)
ar[i] = this[i] && this[i].copy ? this[i].copy() : this[i];
return ar;
};
Array.prototype.merge = function(){
for (var i = 0, k = arguments.length; i < k; i++) {
for (var j = 0, l = arguments[i].length; j < l; j++) {
this.push(arguments[i][j]);
}
}
};
Array.prototype.arrayAdd = function(){
var s = this.copy();
for (var i = 0, k = arguments.length; i < k; i++) {
for (var j = 0, l = s.length; j < l; j++) {
s[j] += arguments[i][j];
}
}
return s;
};
Array.prototype.equals = function(obj){
for (var i = 0, j = this.length; i < j; i++)
if (this[i] != obj[i])
return false;
return true;
};
Array.prototype.makeUnique = function(){
var i, length, newArr = [];
for (i = 0, length = this.length; i < length; i++)
if (newArr.indexOf(this[i]) == -1)
newArr.push(this[i]);
this.length = 0;
for (i = 0, length = newArr.length; i < length; i++)
this.push(newArr[i]);
return this;
};
Array.prototype.contains = function(obj, from){
return this.indexOf(obj, from) != -1;
};
Array.prototype.indexOf = Array.prototype.indexOf || function(obj, from){
var len = this.length;
for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++) {
if (this[i] === obj)
return i;
}
return -1;
};
Array.prototype.lastIndexOf = Array.prototype.lastIndexOf || function(obj, from) {
var len = this.length;
for (var i = (from >= len) ? len - 1 : (from < 0) ? from + len : len - 1; i >= 0; i--) {
if (this[i] === obj)
return i;
}
return -1;
};
Array.prototype.pushUnique = function(item){
if (this.indexOf(item) == -1)
this.push(item);
return this;
};
Array.prototype.search = function(){
for (var i = 0, length = arguments.length; i < length; i++) {
if (typeof this[i] != "array")
continue;
for (var j = 0; j < length; j++) {
if (this[i][j] != arguments[j])
break;
else if (j == (length - 1))
return this[i];
}
}
};
Array.prototype.each =
Array.prototype.forEach = Array.prototype.forEach || function(fn) {
for (var i = 0, l = this.length; i < l; i++)
fn.call(this, this[i], i, this);
return this;
}
Array.prototype.remove = function(obj){
for (var i = this.length - 1; i >= 0; i--) {
if (this[i] != obj)
continue;
this.splice(i, 1);
}
return this;
};
Array.prototype.removeIndex = function(i){
if (!this.length) return;
return this.splice(i, 1);
};
Array.prototype.insertIndex = function(obj, i){
this.splice(i, 0, obj);
};
Array.prototype.invert =
Array.prototype.reverse = Array.prototype.reverse || function(){
var l = this.length - 1;
for (var temp, i = 0; i < Math.ceil(0.5 * l); i++) {
temp        = this[i];
this[i]     = this[l - i]
this[l - i] = temp;
}
return this;
};
Number.prototype.toPrettyDigit = Number.prototype.toPrettyDigit || function() {
var n = this.toString();
return (n.length == 1) ? "0" + n : n;
};
Array.prototype.filter = Array.prototype.filter || function(fn, bind){
var results = [];
for (var i = 0, l = this.length; i < l; i++) {
if (fn.call(bind, this[i], i, this))
results.push(this[i]);
}
return results;
};
Array.prototype.every = Array.prototype.every || function(fn, bind){
for (var i = 0, l = this.length; i < l; i++) {
if (!fn.call(bind, this[i], i, this))
return false;
}
return true;
};
Array.prototype.map = Array.prototype.map || function(fn, bind){
var results = [];
for (var i = 0, l = this.length; i < l; i++)
results[i] = fn.call(bind, this[i], i, this);
return results;
};
Array.prototype.some = Array.prototype.some || function(fn, bind){
for (var i = 0, l = this.length; i < l; i++) {
if (fn.call(bind, this[i], i, this))
return true;
}
return false;
};
Math.hexlist  = "0123456789ABCDEF";
Math.decToHex = function(value){
var hex = this.floor(value / 16);
hex = (hex > 15 ? this.decToHex(hex) : this.hexlist.charAt(hex));
return hex + "" + this.hexlist.charAt(this.floor(value % 16));
};
Math.hexToDec = function(value){
if (!/(.)(.)/.exec(value.toUpperCase()))
return false;
return this.hexlist.indexOf(RegExp.$1) * 16 + this.hexlist.indexOf(RegExp.$2);
};
RegExp.prototype.getNativeFlags = function() {
return (this.global     ? "g" : "") +
(this.ignoreCase ? "i" : "") +
(this.multiline  ? "m" : "") +
(this.extended   ? "x" : "") +
(this.sticky     ? "y" : "");
};
RegExp.prototype.addFlags = function(flags){
return new RegExp(this.source, (flags || "") + this.getNativeFlags());
};
String.prototype.uCaseFirst = function(){
return this.substr(0, 1).toUpperCase() + this.substr(1)
};
String.prototype.trim = function(){
return this.replace(/\s*$/, "").replace(/^\s*/, "");
};
String.prototype.repeat = function(times){
return Array(times + 1).join(this);
};
String.prototype.count = function(str){
return this.split(str).length - 1;
};
String.prototype.stripTags = function() {
return this.replace(/<\/?[^>]+>/gi, '');
};
String.prototype.escape = function() {
return escape(this);
};
String.prototype.escapeHTML = function() {
var div  = document.createElement('div');
var text = document.createTextNode(this);
div.appendChild(text);
return div.innerHTML;
};
String.prototype.unescapeHTML = function() {
var div = document.createElement('div');
div.innerHTML = this.stripTags();
if (div.childNodes[0]) {
if (div.childNodes.length > 1) {
var out = [];
for (var i = 0; i < div.childNodes.length; i++)
out.push(div.childNodes[i].nodeValue);
return out.join('');
}
else
return div.childNodes[0].nodeValue;
}
return "";
};
String.prototype.truncate = function(nr, ellipsis){
return this.length >= nr
? this.substring(0, nr - (ellipsis ? 4 : 1)) + (ellipsis ? "..." : "")
: this;
};
String.prototype.pad = function(len, pad, dir) {
return dir ? (this + Array(len).join(pad)).slice(0, len)
: (Array(len).join(pad) + this).slice(-len);
};
jpf.PAD_LEFT  = false;
jpf.PAD_RIGHT = true;
String.prototype.splitSafe = function(separator, limit, bLowerCase) {
return (bLowerCase && this.toLowerCase() || this)
.replace(/(?:^\s+|\n|\s+$)/g, "")
.split(new RegExp("[\\s ]*" + separator + "[\\s ]*", "g"), limit || 999);
};
var _oldSplit = String.prototype.split;
String.prototype.appendRandomNumber = function(length) {
var source = this.toString();
for (var i = 1; i <= length; i++) {
source += jpf.randomGenerator.generate(1, 9);
}
return source;
};
String.prototype.prependRandomNumber = function(length) {
var source = this.toString();
for (var i = 1; i <= length; i++) {
source = jpf.randomGenerator.generate(1, 9) + source;
}
return source;
};
String.prototype.sprintf = function() {
var str = this.toString();
var i = 0, inx = str.indexOf('%s');
while (inx >= 0) {
var replacement = arguments[i++] || ' ';
str = str.substr(0, inx) + replacement + str.substr(inx + 2);
inx = str.indexOf('%s');
}
return str;
};
jpf.dragmode = {};
jpf.namespace("nameserver", {
lookup : {},
add : function(type, item){
if (!this.lookup[type])
this.lookup[type] = [];
return this.lookup[type].push(item) - 1;
},
register : function(type, id, item){
if (!this.lookup[type])
this.lookup[type] = {};
return (this.lookup[type][id] = item);
},
get : function(type, id){
return this.lookup[type] ? this.lookup[type][id] : null;
},
getAll : function(type){
var name, arr = [];
for (name in this.lookup[type]) {
if (jpf.isSafariOld
&& (!this.lookup[type][name]
|| typeof this.lookup[type][name] != "object"))
continue;
arr.push(this.lookup[type][name]);
}
return arr;
}, 
getAllNames : function(type){
var name, arr = [];
for (name in this.lookup[type]){
if (parseInt(name) == name) continue;
arr.push(name);
}
return arr;
}
});
jpf.registry = jpf.extend({
put : function(key, value, namespace){
this.register(namespace, key, value);
},
getNamespaces : function(){
},
getKeys : function(namespace){
return this.getAllNames(namespace);
},
remove : function(key, namespace){
delete this.lookup[namespace][key];
},
clear : function(namespace){
this.lookup = {}; 
},
$export : function(storage){
var namespace, key;
for (namespace in this.lookup) {
for (key in this.lookup[namespace]) {
storage.put(key, this.lookup[key][namespace], namespace);
}
}
}
}, jpf.nameserver);
jpf.registry.lookup = {};
jpf.registry.get    = function(key, namespace){
return this.lookup[namespace] ? this.lookup[namespace][key] : null;
};
jpf.setStyleRule = function(name, type, value, stylesheet, win){
var rules = (win || self).document.styleSheets[stylesheet || 0][jpf.styleSheetRules];
for (var i = 0; i < rules.length; i++) {
if (rules.item(i).selectorText == name) {
rules.item(i).style[type] = value;
return true;
}
}
return false;
};
jpf.setStyleClass = function(oHtml, className, exclusion, special){
if (!oHtml || this.disabled)
return;
if (!className) className = " ";
if (exclusion)
exclusion.push(className);
else
exclusion = [className];
var re = new RegExp("(?:(^| +)" + exclusion.join("|") + "($| +))", "gi");
oHtml.className != null
? (oHtml.className = oHtml.className.replace(re, " ") + " " + className)
: oHtml.setAttribute("class", (oHtml.getAttribute("class") || "")
.replace(re, " ") + " " + className);
return oHtml;
};
jpf.importCssString = function(doc, cssString, media){
var htmlNode = doc.getElementsByTagName("head")[0];
if (!jpf.supportOpacity) {
cssString = cssString.replace(/opacity[ \s]*\:[ \s]*([\d\.]+)/g,
function(m, m1){
return "filter:progid:DXImageTransform.Microsoft.Alpha(opacity=" + (m1*100) + ")";
});
}
if (jpf.canCreateStyleNode) {
var style = document.createElement("style");
style.appendChild(document.createTextNode(cssString));
htmlNode.appendChild(style);
}
else {
htmlNode.insertAdjacentHTML("beforeend", ".<style media='"
+ (media || "all") + "'>" + cssString + "</style>");
}
};
jpf.getStyle = function(el, prop) {
return jpf.hasComputedStyle
? window.getComputedStyle(el,'').getPropertyValue(prop)
: el.currentStyle[prop];
};
jpf.getStyleRecur = function(el, prop) {
var value = jpf.hasComputedStyle
? document.defaultView.getComputedStyle(el,'').getPropertyValue(
prop.replace(/([A-Z])/g, function(m, m1){
return "-" + m1.toLowerCase();
}))
: el.currentStyle[prop]
return ((!value || value == "transparent" || value == "inherit")
&& el.parentNode && el.parentNode.nodeType == 1)
? this.getStyleRecur(el.parentNode, prop)
: value;
};
jpf.isInRect = function(oHtml, x, y){
var pos = this.getAbsolutePosition(oHtml);
if (x < pos[0] || y < pos[1] || x > oHtml.offsetWidth + pos[0] - 10
|| y > oHtml.offsetHeight + pos[1] - 10)
return false;
return true;
};
jpf.getOverflowParent = function(o){
o = o.offsetParent;
while (o && (this.getStyle(o, "overflow") != "hidden"
|| "absolute|relative".indexOf(this.getStyle(o, "position")) == -1)) {
o = o.offsetParent;
}
return o || document.documentElement;
};
jpf.getPositionedParent = function(o){
o = o.offsetParent;
while (o && o.tagName.toLowerCase() != "body"
&& "absolute|relative".indexOf(this.getStyle(o, "position")) == -1) {
o = o.offsetParent;
}
return o || document.documentElement;
};
jpf.getAbsolutePosition = function(o, refParent, inclSelf){
var wt = inclSelf ? 0 : o.offsetLeft, ht = inclSelf ? 0 : o.offsetTop;
o = inclSelf ? o : o.offsetParent;
var z, bw, bh, foundPosRel = 0;
while (o && o != refParent) {
bw = jpf.isOpera ? 0 : this.getStyle(o, jpf.descPropJs
? "borderLeftWidth" : "border-left-width");
wt += (jpf.isIE && o.currentStyle.borderLeftStyle != "none" && bw == "medium"
? 2
: parseInt(bw) || 0) + o.offsetLeft;
bh = jpf.isOpera ? 0 : this.getStyle(o, jpf.descPropJs
? "borderTopWidth" : "border-top-width");
ht += (jpf.isIE && o.currentStyle.borderTopStyle != "none" && bh == "medium"
? 2
: parseInt(bh) || 0) + o.offsetTop;
wt -= o.scrollLeft;
ht -= o.scrollTop;
if (o.tagName.toLowerCase() == "table") {
ht -= parseInt(o.border || 0) + parseInt(o.cellSpacing || 0);
wt -= parseInt(o.border || 0) + parseInt(o.cellSpacing || 0) * 2;
}
else if (o.tagName.toLowerCase() == "tr") {
ht -= (cp = parseInt(o.parentNode.parentNode.cellSpacing));
while (o.previousSibling)
ht -= (o = o.previousSibling).offsetHeight + cp;
}
if (!o.offsetParent && o.parentNode.nodeType == 1) {
wt -= o.parentNode.scrollLeft;
ht -= o.parentNode.scrollTop;
}
o = o.offsetParent;
}
return [wt, ht];
};
jpf.plane = {
init : function(){
if (!this.plane) {
this.plane                  = document.createElement("DIV");
document.body.appendChild(this.plane);
this.plane.style.background = "url(images/spacer.gif)";
this.plane.style.position   = "absolute";
this.plane.style.zIndex     = 100000000;
this.plane.style.left       = 0;
this.plane.style.top        = 0;
}
},
lastCursor : null,
show : function(o, dontAppend, copyCursor){
this.init();
var plane    = this.plane;
this.current = o;
if (!dontAppend) {
this.lastZ = this.current.style.zIndex;
this.current.style.zIndex = 100000;
}
else {
this.plane.appendChild(o);
}
var pWidth = (plane.parentNode == document.body
? (jpf.isIE 
? document.documentElement.offsetWidth 
: window.innerWidth)
: plane.parentNode.offsetWidth);
var pHeight = (plane.parentNode == document.body
? (jpf.isIE 
? document.documentElement.offsetHeight
: window.innerHeight)
: plane.parentNode.offsetHeight);
if (copyCursor) {
if (this.lastCursor === null)
this.lastCursor = document.body.style.cursor;
document.body.style.cursor = jpf.getStyle(o, "cursor");
}
this.plane.style.display = "block";
var diff = jpf.getDiff(plane.parentNode);
this.plane.style.width  = (pWidth - diff[0]) + "px";
this.plane.style.height = (pHeight - diff[1]) + "px";
return plane;
},
hide : function(){
var isChild = jpf.xmldb.isChildOf(this.plane, document.activeElement);
if (this.lastZ) {
if (this.current.style.zIndex == 100000)
this.current.style.zIndex = this.lastZ;
this.lastZ = null;
}
if (this.current.parentNode == this.plane)
this.plane.parentNode.appendChild(this.current);
this.plane.style.display  = "none";
if (isChild) {
if (!jpf.isIE)
document.activeElement.focus();
jpf.window.focussed.$focus();
}
this.current = null;
if (this.lastCursor !== null) {
document.body.style.cursor = this.lastCursor;
this.lastCursor = null;
}
return this.plane;
}
};
jpf.runOpera = function (){
var x = new DOMParser();
XMLDocument = DOMParser.constructor;
x = null;
Node.prototype.serialize        = 
XMLDocument.prototype.serialize =
Element.prototype.serialize     = function(){
return (new XMLSerializer()).serializeToString(this);
};
Document.prototype.selectNodes     = 
XMLDocument.prototype.selectNodes  =
HTMLDocument.prototype.selectNodes = function(sExpr, contextNode){
var oResult = this.evaluate(sExpr, (contextNode ? contextNode : this),
this.createNSResolver(this.documentElement),
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var nodeList = new Array(oResult.snapshotLength);
nodeList.expr = sExpr;
for (var i = 0; i < nodeList.length; i++) 
nodeList[i] = oResult.snapshotItem(i);
return nodeList;
};
Element.prototype.selectNodes = function(sExpr){
var doc = this.ownerDocument;
if (!doc.selectSingleNode) {
doc.selectSingleNode = HTMLDocument.prototype.selectSingleNode;
doc.selectNodes = HTMLDocument.prototype.selectNodes;
}
if (doc.selectNodes) 
return doc.selectNodes(sExpr, this);
else 
throw new Error(jpf.formatErrorString(1047, null, "XPath Selection", "Method selectNodes is only supported by XML Nodes"));
};
Document.prototype.selectSingleNode     =
XMLDocument.prototype.selectSingleNode  =
HTMLDocument.prototype.selectSingleNode = function(sExpr, contextNode){
var nodeList = this.selectNodes(sExpr + "[1]", contextNode ? contextNode : null);
return nodeList.length > 0 ? nodeList[0] : null;
};
Element.prototype.selectSingleNode = function(sExpr){
var doc = this.ownerDocument;
if (!doc.selectSingleNode) {
doc.selectSingleNode = HTMLDocument.prototype.selectSingleNode;
doc.selectNodes = HTMLDocument.prototype.selectNodes;
}
if (doc.selectSingleNode) 
return doc.selectSingleNode(sExpr, this);
else 
throw new Error(jpf.formatErrorString(1048, null, "XPath Selection", "Method selectSingleNode is only supported by XML Nodes. \nInfo : " + e));
};
if (jpf.runNonIe)
jpf.runNonIe();
}
jpf.runIE = function(){
var hasIE7Security = hasIESecurity = false;
if (self.XLMHttpRequest)
try {
new XLMHttpRequest()
}
catch (e) {
hasIE7Security = true
}
try {
new ActiveXObject("microsoft.XMLHTTP")
}
catch (e) {
hasIESecurity = true
}
if(hasIESecurity) jpf.importClass(function(){
__CONTENT_IFRAME
}, true, self);
jpf.getHttpReq = hasIESecurity
? function(){
if (jpf.teleport.availHTTP.length)
return jpf.teleport.availHTTP.pop();
return new XMLHttpRequest();
}
: function(){
if (jpf.teleport.availHTTP.length)
return jpf.teleport.availHTTP.pop();
return new ActiveXObject("microsoft.XMLHTTP");
};
jpf.getXmlDom = hasIESecurity
? function(message, noError){
var xmlParser = getDOMParser(message, noError);
return xmlParser;
}
: function(message, noError, preserveWhiteSpaces){
var xmlParser = new ActiveXObject("microsoft.XMLDOM");
xmlParser.setProperty("SelectionLanguage", "XPath");
if (preserveWhiteSpaces)
xmlParser.preserveWhiteSpace = true;
if (message) {
if (jpf.cantParseXmlDefinition)
message = message.replace(/\] \]/g, "] ]").replace(/^<\?[^>]*\?>/, "");
xmlParser.loadXML(message);
if (!noError)
this.xmlParseError(xmlParser);
}
return xmlParser;
};
jpf.xmlParseError = function(xml){
var xmlParseError = xml.parseError;
if (xmlParseError != 0) {
throw new Error(jpf.formatErrorString(1050, null, "XML Parse error on line " + xmlParseError.line, xmlParseError.reason + "Source Text:\n" + xmlParseError.srcText.replace(/\t/gi, " ")));
}
return xml;
};
if (jpf.XmlDatabase) {
jpf.XmlDatabase.prototype.htmlImport = function(xmlNode, htmlNode, beforeNode, pre, post){
var id;
if (xmlNode.length != null && !xmlNode.nodeType) {
var str, i, l;
for (str = [], i = 0, l = xmlNode.length; i < l; i++)
str.push(xmlNode[i].xml);
str = str.join("");
str = jpf.html_entity_decode(str)
.replace(/style="background-image:([^"]*)"/g, "find='$1' style='background-image:$1'");
if (pre) {
(beforeNode || htmlNode).insertAdjacentHTML(beforeNode
? "beforebegin"
: "beforeend", pre + str + post);
}
try {
(beforeNode || htmlNode).insertAdjacentHTML(beforeNode
? "beforebegin"
: "beforeend", str);
}
catch (e) {
document.body.insertAdjacentHTML("beforeend", "<table><tr>"
+ str + "</tr></table>");
var x = document.body.lastChild.firstChild.firstChild;
for (i = x.childNodes.length - 1; i >= 0; i--)
htmlNode.appendChild(x.childNodes[jpf.hasDynamicItemList ? 0 : i]);
}
if (!this.nodes)
this.nodes = [];
id = this.nodes.push(htmlNode.getElementsByTagName("*")) - 1;
setTimeout('jpf.xmldb.doNodes(' + id + ')');
return null;
}
if (htmlNode.ownerDocument && htmlNode.ownerDocument != document
&& xmlNode.ownerDocument == htmlNode.ownerDocument)
return htmlNode.insertBefore(xmlNode, beforeNode);
var strHTML = jpf.html_entity_decode(xmlNode.outerHTML || xmlNode.xml || xmlNode.nodeValue);
var pNode = (beforeNode || htmlNode);
if (pNode.nodeType == 11) {
id = xmlNode.getAttribute("id");
if (!id)
throw new Error(jpf.formatErrorString(1049, null, "xmldb", "Inserting Cache Item in Document Fragment without an ID"));
document.body.insertAdjacentHTML(beforeNode ? "beforebegin" : "beforeend", strHTML);
pNode.appendChild(document.getElementById(id));
}
else
pNode.insertAdjacentHTML(beforeNode ? "beforebegin" : "beforeend", strHTML);
return beforeNode ? beforeNode.previousSibling : htmlNode.lastChild;
};
jpf.XmlDatabase.prototype.doNodes = function(id){
var nodes = this.nodes[id];
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].getAttribute("find"))
nodes[i].style.backgroundImage = nodes[i].getAttribute("find");
}
this.nodes[id] = null;
};
jpf.xmldb = new jpf.XmlDatabase();
}
if (!hasIESecurity)
jpf.Init.run('xmldb');
jpf.getHorBorders = function(oHtml){
return Math.max(0,
(parseInt(jpf.getStyle(oHtml, "borderLeftWidth")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderRightWidth")) || 0))
};
jpf.getVerBorders = function(oHtml){
return Math.max(0,
(parseInt(jpf.getStyle(oHtml, "borderTopWidth")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderBottomWidth")) || 0))
};
jpf.getWidthDiff = function(oHtml){
return Math.max(0, (parseInt(jpf.getStyle(oHtml, "paddingLeft")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "paddingRight")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderLeftWidth")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderRightWidth")) || 0))
};
jpf.getHeightDiff = function(oHtml){
return Math.max(0, (parseInt(jpf.getStyle(oHtml, "paddingTop")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "paddingBottom")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderTopWidth")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderBottomWidth")) || 0))
};
jpf.getDiff = function(oHtml){
return [Math.max(0, (parseInt(jpf.getStyle(oHtml, "paddingLeft")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "paddingRight")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderLeftWidth")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderRightWidth")) || 0)),
Math.max(0, (parseInt(jpf.getStyle(oHtml, "paddingTop")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "paddingBottom")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderTopWidth")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "borderBottomWidth")) || 0))]
};
jpf.importClass(jpf.runXpath, true, self);
}
jpf.runGecko = function(){
if (jpf.runNonIe)
jpf.runNonIe();
HTMLDocument.prototype.selectNodes = XMLDocument.prototype.selectNodes = function(sExpr, contextNode){
var oResult = this.evaluate(sExpr, (contextNode || this),
this.createNSResolver(this.documentElement),
7, null);
var nodeList = new Array(oResult.snapshotLength);
nodeList.expr = sExpr;
for (var i = 0; i < nodeList.length; i++) 
nodeList[i] = oResult.snapshotItem(i);
return nodeList;
};
Element.prototype.selectNodes = function(sExpr){
var doc = this.ownerDocument;
if (doc.selectNodes) 
return doc.selectNodes(sExpr, this);
else 
throw new Error(jpf.formatErrorString(1047, null, "xPath selection", "Method selectNodes is only supported by XML Nodes"));
};
HTMLDocument.prototype.selectSingleNode = XMLDocument.prototype.selectSingleNode = function(sExpr, contextNode){
var nodeList = this.selectNodes(sExpr + "[1]", contextNode || null);
return nodeList.length > 0 ? nodeList[0] : null;
};
Element.prototype.selectSingleNode = function(sExpr){
var doc = this.ownerDocument;
if (doc.selectSingleNode) 
return doc.selectSingleNode(sExpr, this);
else 
throw new Error(jpf.formatErrorString(1048, null, "XPath Selection", "Method selectSingleNode is only supported by XML Nodes. \nInfo : " + e));
};
function Error(nr, msg){
this.message = msg;
this.nr = nr;
}
}
jpf.runNonIe = function (){
DocumentFragment.prototype.getElementById = function(id){
return this.childNodes.length ? this.childNodes[0].ownerDocument.getElementById(id) : null;
};
if (XMLDocument.prototype.__defineGetter__) {
XMLDocument.prototype.__defineGetter__("xml", function(){
return (new XMLSerializer()).serializeToString(this);
});
XMLDocument.prototype.__defineSetter__("xml", function(){
throw new Error(jpf.formatErrorString(1042, null, "XML serializer", "Invalid assignment on read-only property 'xml'."));
});
Node.prototype.__defineGetter__("xml", function(){
if (this.nodeType == 3 || this.nodeType == 4 || this.nodeType == 2) 
return this.nodeValue;
return (new XMLSerializer()).serializeToString(this);
});
Element.prototype.__defineGetter__("xml", function(){
return (new XMLSerializer()).serializeToString(this);
});
}
if (typeof HTMLElement!="undefined") {
if (!HTMLElement.prototype.insertAdjacentElement) {
HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode){
switch (where.toLowerCase()) {
case "beforebegin":
this.parentNode.insertBefore(parsedNode,this);
break;
case "afterbegin":
this.insertBefore(parsedNode,this.firstChild);
break;
case "beforeend":
this.appendChild(parsedNode);
break;
case "afterend":
if (this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else
this.parentNode.appendChild(parsedNode);
break;
}
};
}
if (!HTMLElement.prototype.insertAdjacentHTML) {
HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr){
var r = this.ownerDocument.createRange();
r.setStartBefore(jpf.isSafari ? document.body : (self.document ? document.body : this));
var parsedHTML = r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where, parsedHTML);
};
}
if (jpf.isSafari || jpf.isChrome)
HTMLBodyElement.prototype.insertAdjacentHTML = HTMLElement.prototype.insertAdjacentHTML;
if (!HTMLElement.prototype.insertAdjacentText) {
HTMLElement.prototype.insertAdjacentText = function(where,txtStr){
var parsedText = document.createTextNode(txtStr);
this.insertAdjacentElement(where,parsedText);
};
}
HTMLElement.prototype.removeNode = function(){
if (!this.parentNode) return;
this.parentNode.removeChild(this);
};
if (HTMLElement.prototype.__defineSetter__) {
HTMLElement.prototype.__defineSetter__("innerText", function(sText){
var s = "" + sText;
this.innerHTML = s.replace(/\&/g, "&amp;")
.replace(/</g, "&lt;").replace(/>/g, "&gt;");
});
HTMLElement.prototype.__defineGetter__("innerText", function(){
return this.innerHTML.replace(/<[^>]+>/g,"")
.replace(/\s\s+/g, " ").replace(/^\s*|\s*$/g, " ")
});
HTMLElement.prototype.__defineGetter__("outerHTML", function(){
return (new XMLSerializer()).serializeToString(this);
});
}
}
var ASYNCNOTSUPPORTED = false;
try {
XMLDocument.prototype.async = true;
ASYNCNOTSUPPORTED           = true;
} catch(e) {} 
Document.prototype.onreadystatechange = null;
Document.prototype.parseError         = 0;
Array.prototype.item = function(i){return this[i];};
Array.prototype.expr = "";
XMLDocument.prototype.readyState = 0;
XMLDocument.prototype.$clearDOM = function(){
while (this.hasChildNodes())
this.removeChild(this.firstChild);
};
XMLDocument.prototype.$copyDOM = function(oDoc){
this.$clearDOM();
if (oDoc.nodeType == 9 || oDoc.nodeType == 11) {
var oNodes = oDoc.childNodes;
for (var i = 0; i < oNodes.length; i++)
this.appendChild(this.importNode(oNodes[i], true));
} else if(oDoc.nodeType == 1)
this.appendChild(this.importNode(oDoc, true));
};
XMLDocument.prototype.loadXML = function(strXML){
jpf.xmldb.setReadyState(this, 1);
var sOldXML = this.xml || this.serialize();
var oDoc    = (new DOMParser()).parseFromString(strXML, "text/xml");
jpf.xmldb.setReadyState(this, 2);
this.$copyDOM(oDoc);
jpf.xmldb.setReadyState(this, 3);
jpf.xmldb.loadHandler(this);
return sOldXML;
};
Node.prototype.getElementById = function(id){};
HTMLElement.prototype.replaceNode = 
Element.prototype.replaceNode     = function(xmlNode){
if (!this.parentNode) return;
this.parentNode.insertBefore(xmlNode, this);
this.parentNode.removeChild(this);
};
XMLDocument.prototype.$load = XMLDocument.prototype.load;
XMLDocument.prototype.load  = function(sURI){
var oDoc = document.implementation.createDocument("", "", null);
oDoc.$copyDOM(this);
this.parseError = 0;
jpf.xmldb.setReadyState(this, 1);
try {
if (this.async == false && ASYNCNOTSUPPORTED) {
var tmp = new XMLHttpRequest();
tmp.open("GET", sURI, false);
tmp.overrideMimeType("text/xml");
tmp.send(null);
jpf.xmldb.setReadyState(this, 2);
this.$copyDOM(tmp.responseXML);
jpf.xmldb.setReadyState(this, 3);
} else
this.$load(sURI);
}
catch (objException) {
this.parseError = -1;
}
finally {
jpf.xmldb.loadHandler(this);
}
return oDoc;
};
HTMLDocument.prototype.setProperty = 
XMLDocument.prototype.setProperty  = function(x,y){};
jpf.getHttpReq = function(){
if (jpf.teleport.availHTTP.length)
return jpf.teleport.availHTTP.pop();
return new XMLHttpRequest();
};
jpf.getXmlDom = function(message, noError){
var xmlParser;
if (message) {
xmlParser = new DOMParser();
xmlParser     = xmlParser.parseFromString(message, "text/xml");
if (!noError)
this.xmlParseError(xmlParser);
}
else {
xmlParser = document.implementation.createDocument("", "", null);
}
return xmlParser;
};
jpf.xmlParseError = function(xml){
if (xml.documentElement.tagName == "parsererror") {
var str     = xml.documentElement.firstChild.nodeValue.split("\n");
var linenr  = str[2].match(/\w+ (\d+)/)[1];
var message = str[0].replace(/\w+ \w+ \w+: (.*)/, "$1");
var srcText = xml.documentElement.lastChild.firstChild.nodeValue.split("\n")[0];
throw new Error(jpf.formatErrorString(1050, null, 
"XML Parse Error on line " +  linenr, message + 
"\nSource Text : " + srcText.replace(/\t/gi, " ")));
}
return xml;
};
if (jpf.XmlDatabase) {
jpf.XmlDatabase.prototype.htmlImport = function(xmlNode, htmlNode, beforeNode, test){
if (!htmlNode)
alert("No HTML node given in htmlImport:" + this.htmlImport.caller);
if (xmlNode.length != null && !xmlNode.nodeType) {
for (var str = [], i = 0, l = xmlNode.length; i < l; i++) 
str.push(xmlNode[i].xml || xmlNode[i].serialize());
str = str.join("").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&")
.replace(/<([^>]+)\/>/g, "<$1></$1>");
(beforeNode || htmlNode).insertAdjacentHTML(beforeNode 
? "beforebegin" 
: "beforeend", str);
return null;
}
if (htmlNode.ownerDocument && htmlNode.ownerDocument != document
&& xmlNode.ownerDocument == htmlNode.ownerDocument)
return htmlNode.insertBefore(xmlNode, beforeNode);
var strHTML = jpf.html_entity_decode(xmlNode.outerHTML || xmlNode.xml || xmlNode.nodeValue);
var pNode = (beforeNode || htmlNode);
if (pNode.nodeType == 11){
var id = xmlNode.getAttribute("id");
if (!id)
throw new Error(jpf.formatErrorString(1049, null, "xmldb", "Inserting Cache Item in Document Fragment without an ID"));
document.body.insertAdjacentHTML(beforeNode ? "beforebegin" : "beforeend", strHTML);
pNode.appendChild(document.getElementById(id));
}
else {
if (xmlNode.tagName.match(/tbody|td|tr/))
pNode.insertBefore(pNode.ownerDocument
.createElement(xmlNode.tagName.toLowerCase()), beforeNode || null);
else {
pNode.insertAdjacentHTML(beforeNode ? "beforebegin" : "beforeend", strHTML);
}
}
return beforeNode ? beforeNode.previousSibling : htmlNode.lastChild;
};
jpf.XmlDatabase.prototype.setReadyState = function(oDoc, iReadyState) {
oDoc.readyState = iReadyState;
if (oDoc.onreadystatechange != null && typeof oDoc.onreadystatechange == "function")
oDoc.onreadystatechange();
};
jpf.XmlDatabase.prototype.loadHandler = function(oDoc){
if (!oDoc.documentElement || oDoc.documentElement.tagName == "parsererror")
oDoc.parseError = -1;
jpf.xmldb.setReadyState(oDoc, 4);
};
jpf.xmldb = new jpf.XmlDatabase();
}
jpf.Init.add(function(){
var i, nodes = document.getElementsByTagName("form");
for (i = 0; i < nodes.length; i++)
nodes[i].removeNode();
nodes = document.getElementsByTagName("xml");
for(i = 0; i < nodes.length; i++)
nodes[i].removeNode();
nodes = null;
});
var MAXMSG      = 3;
var ERROR_COUNT = 0;
if (document.body)
document.body.focus = function(){};
if (!document.elementFromPoint) {
Document.prototype.elementFromPointRemove = function(el){
if (!this.RegElements) return;
this.RegElements.remove(el);
};
Document.prototype.elementFromPointAdd = function(el){
if (!this.RegElements)
this.RegElements = [];
this.RegElements.push(el);
};
Document.prototype.elementFromPointReset = function(RegElements){
FoundValue   = [];
FoundNode    = null;
LastFoundAbs = document.documentElement;
};
Document.prototype.elementFromPoint = function(x, y){
document.elementFromPointReset();
if (this.RegElements) {
for (var calc_z = -1, calc, i = 0; i < this.RegElements.length; i++) {
var n = this.RegElements[i];
if (getStyle(n, "display") == "none") continue;
var sx = getElementPosX(n); 
var sy = getElementPosY(n);
var ex = sx + n.offsetWidth;
var ey = sy + n.offsetHeight;
if (x > sx && x < ex && y > sy && y < ey) {
var z = getElementZindex(n);
if (z > calc_z) { 
calc   = [n, x, y, sx, sy];
calc_z = z;
}
}
}
if (calc) {
efpi(calc[0], calc[1], calc[2], 0, FoundValue, calc[3], calc[4]);
if (!FoundNode) {
FoundNode    = calc[0];
LastFoundAbs = calc[0];
FoundValue   = [calc_z];
}
}
}
if (!this.RegElements || !this.RegElements.length)
efpi(document.body, x, y, 0, [], getElementPosX(document.body),
getElementPosY(document.body));
return FoundNode;
};
function getStyle(el, prop) {
return document.defaultView.getComputedStyle(el,'').getPropertyValue(prop);
}
function efpi(from, x, y, CurIndex, CurValue, px, py){
var StartValue = CurValue;
var StartIndex = CurIndex;
var nodes = from.childNodes;
for(var n, i = 0; i < from.childNodes.length; i++) {
n = from.childNodes[i];
if (n.nodeType == 1 && getStyle(n, 'display') != 'none' && n.offsetParent) {
var sx = px + n.offsetLeft - n.offsetParent.scrollLeft;
var sy = py + n.offsetTop - n.offsetParent.scrollTop;
var ex = sx + n.offsetWidth;
var ey = sy + n.offsetHeight;
var isAbs    = getStyle(n, "position");
isAbs        = (isAbs == "absolute") || (isAbs == "relative");
var isHidden = getStyle(n, "overflow") == "hidden";
var inSpace  = (x > sx && x < ex && y > sy && y < ey);
if (isAbs && isHidden && !inSpace) continue;
CurIndex = StartIndex;
CurValue = StartValue.copy();
var z = parseInt(getStyle(n, "z-index")) || 0;
if (isAbs && (z || z == 0) || isHidden) {
if (!isAbs) z = 0;
if (z >= (FoundValue[CurIndex] || 0)) {
if (z > (CurValue[CurIndex] || 0)) {
CurValue[CurIndex] = z;
}
CurIndex++;
if (inSpace && CurIndex >= FoundValue.length) {
FoundNode = n;
FoundValue = CurValue;
LastFoundAbs = n;
}
}
else
continue; 
}
else if(inSpace && CurIndex >= FoundValue.length){
FoundNode = n;
FoundValue = CurValue;
}
efpi(n, x, y, CurIndex, CurValue, isAbs ? sx : px, isAbs ? sy : py)
}
}
}
function getElementPosY(myObj){
return myObj.offsetTop + parseInt(jpf.getStyle(myObj, "border-top-width"))
+ (myObj.offsetParent ? getElementPosY(myObj.offsetParent) : 0);
}
function getElementPosX(myObj){
return myObj.offsetLeft + parseInt(jpf.getStyle(myObj, "border-left-width"))
+ (myObj.offsetParent ? getElementPosX(myObj.offsetParent) : 0);
}
function getElementZindex(myObj){
var z = 0, n, p = myObj;
while(p && p.nodeType == 1){
z = Math.max(z, parseInt(getStyle(p, "z-index")) || -1);
p = p.parentNode;
}
return z;
}
}
jpf.getHorBorders = function(oHtml){
return Math.max(0, 
(parseInt(jpf.getStyle(oHtml, "border-left-width")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "border-right-width")) || 0));
};
jpf.getVerBorders = function(oHtml){
return Math.max(0, 
(parseInt(jpf.getStyle(oHtml, "border-top-width")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "border-bottom-width")) || 0));
};
jpf.getWidthDiff = function(oHtml){
return Math.max(0, (parseInt(jpf.getStyle(oHtml, "padding-left")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "padding-right")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "border-left-width")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "border-right-width")) || 0));
};
jpf.getHeightDiff = function(oHtml){
return Math.max(0, (parseInt(jpf.getStyle(oHtml, "padding-top")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "padding-bottom")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "border-top-width")) || 0)
+ (parseInt(jpf.getStyle(oHtml, "border-bottom-width")) || 0));
};
jpf.getDiff = function(oHtml){
return [Math.max(0, parseInt(jpf.getStyle(oHtml, "padding-left"))
+ parseInt(jpf.getStyle(oHtml, "padding-right"))
+ parseInt(jpf.getStyle(oHtml, "border-left-width"))
+ parseInt(jpf.getStyle(oHtml, "border-right-width")) || 0),
Math.max(0, parseInt(jpf.getStyle(oHtml, "padding-top"))
+ parseInt(jpf.getStyle(oHtml, "padding-bottom"))
+ parseInt(jpf.getStyle(oHtml, "border-top-width"))
+ parseInt(jpf.getStyle(oHtml, "border-bottom-width")) || 0)];
};
jpf.Init.run('xmldb');
}
jpf.runSafari = function(){
if (!jpf.isChrome) {
var setTimeoutSafari = window.setTimeout;
lookupSafariCall = [];
window.setTimeout = function(call, time){
if (typeof call == "string") 
return setTimeoutSafari(call, time);
return setTimeoutSafari("lookupSafariCall["
+ (lookupSafariCall.push(call) - 1) + "]()", time);
}
if (jpf.isSafariOld) {
HTMLHtmlElement = document.createElement("html").constructor;
Node            = HTMLElement = {};
HTMLElement.prototype = HTMLHtmlElement.__proto__.__proto__;
HTMLDocument    = Document = document.constructor;
var x           = new DOMParser();
XMLDocument     = x.constructor;
Element         = x.parseFromString("<Single />", "text/xml").documentElement.constructor;
x               = null;
}
if (!XMLDocument.__defineGetter__) {
Document.prototype.serialize    = 
Node.prototype.serialize        =
XMLDocument.prototype.serialize = function(){
return (new XMLSerializer()).serializeToString(this);
};
}
}
if (jpf.isSafariOld || jpf.isSafari || jpf.isChrome) {
HTMLDocument.prototype.selectNodes =
XMLDocument.prototype.selectNodes  = function(sExpr, contextNode){
return jpf.XPath.selectNodes(sExpr, contextNode || this);
};
Element.prototype.selectNodes = function(sExpr, contextNode){
return jpf.XPath.selectNodes(sExpr, contextNode || this);
};
HTMLDocument.prototype.selectSingleNode =
XMLDocument.prototype.selectSingleNode  = function(sExpr, contextNode){
return jpf.XPath.selectNodes(sExpr, contextNode || this)[0];
};
Element.prototype.selectSingleNode = function(sExpr, contextNode){
return jpf.XPath.selectNodes(sExpr, contextNode || this)[0];
};
jpf.importClass(jpf.runXpath, true, self);
jpf.importClass(jpf.runXslt, true, self);
}
if (jpf.runNonIe)
jpf.runNonIe();
}
jpf.JmlParser = {
sbInit     : {},
stateStack : [],
modelInit  : [],
parse : function(x){
this.$jml = x;
jpf.isParsing = true;
jpf.window          = new jpf.WindowImplementation();
jpf.document        = new jpf.DocumentImplementation();
jpf.window.document = jpf.document;
jpf.window.$at      = new jpf.actiontracker();
jpf.window.$at.name = "default";
jpf.nameserver.register("actiontracker", "default", jpf.window.$at);
for (var docs = [x], i = 0; i < jpf.includeStack.length; i++) {
if (jpf.includeStack[i].nodeType)
docs.push(jpf.includeStack[i]);
}
this.docs = docs;
this.parseSettings(docs);
if (!this.shouldWait)
this.continueStartup();
},
continueStartup : function(){
this.parseFirstPass(this.docs);
jpf.JmlParser.parseChildren(this.$jml, document.body, jpf.document.documentElement);
setTimeout('jpf.JmlParser.parseLastPass();', 1);
this.inited = true;
},
parseSettings : function(xmlDocs) {
for (var i = 0; i < xmlDocs.length; i++)
this.preLoadRef(xmlDocs[i], ["appsettings"]);
},
parseFirstPass: function(xmlDocs){
for (var i = 0; i < xmlDocs.length; i++)
this.preLoadRef(xmlDocs[i], ["teleport", "settings",
"skin[not(@j_preparsed=9999)]", "bindings[@id]", "actions[@id]", "dragdrop[@id]", "remote"]);
for (var i = 0; i < xmlDocs.length; i++)
this.preLoadRef(xmlDocs[i], ["model[@id]",
"smartbinding[@id]", "iconmap"], true);
},
preparsed : [],
preLoadRef : function(xmlNode, sel, parseLocalModel){
var prefix = jpf.findPrefix(xmlNode, jpf.ns.jml);
if (prefix) prefix += ":";
var nodes  = jpf.xmldb.selectNodes(".//" + prefix + sel.join("|.//"
+ prefix) + (parseLocalModel ? "|" + prefix + "model" : ""), xmlNode);
var i, o, name, tagName, x, l;
for (i = 0, l = nodes.length; i < l; i++) {
x = nodes[i];
if (jpf.xmldb.getInheritedAttribute(x, "render") == "runtime")
continue;
var tagName = x[jpf.TAGNAME];
if (this.handler[tagName]) {
o = this.handler[tagName](x);
name = x.getAttribute("id"); 
if (o && name)
jpf.nameserver.register(tagName, name, o);
if (!o || !o.nodeType)
o = new jpf.JmlDom(tagName, null, jpf.NODE_HIDDEN, x, o);
o.$jmlLoaded = true;
if (name) jpf.setReference(name, o);
x.setAttribute("j_preparsed", this.preparsed.push(o) - 1);
}
else if (x.parentNode) {
x.parentNode.removeChild(x);
}
}
},
parseMoreJml : function(x, pHtmlNode, jmlParent, noImpliedParent, parseSelf, beforeNode){
var parsing = jpf.isParsing;
jpf.isParsing = true;
if (!jpf.window) {
jpf.window          = new jpf.WindowImplementation();
jpf.document        = new jpf.DocumentImplementation();
jpf.window.document = jpf.document;
jpf.window.$at      = new jpf.actiontracker();
jpf.nameserver.register("actiontracker", "default", jpf.window.$at);
}
if (!jmlParent)
jmlParent = jpf.document.documentElement;
this.parseFirstPass([x]);
if (parseSelf) {
if (jmlParent.loadJml)
jmlParent.loadJml(x, jmlParent.parentNode);
jmlParent.$jmlLoaded = true;
if (jmlParent.pData || jmlParent.tagName == "grid")
jpf.layout.activateRules(pNode.oInt || document.body);
}
else {
var lastChild = pHtmlNode.lastChild;
this.parseChildren(x, pHtmlNode, jmlParent, false, noImpliedParent);
if (beforeNode) {
var loop = pHtmlNode.lastChild;
while (lastChild != loop) {
pHtmlNode.insertBefore(loop, beforeNode);
loop = pHtmlNode.lastChild;
}
}
}
jpf.layout.activateRules();
this.parseLastPass();
jpf.isParsing = parsing;
},
reWhitespaces : /[\t\n\r]+/g,
parseChildren : function(x, pHtmlNode, jmlParent, checkRender, noImpliedParent){
if (pHtmlNode == jmlParent.oInt && jmlParent.childNodes.length
&& jmlParent != jpf.document.documentElement)
return pHtmlNode;
if (checkRender && jmlParent && jmlParent.hasFeature(__DELAYEDRENDER__)
&& jmlParent.$checkDelay(x)) {
return pHtmlNode;
}
if (jmlParent)
jmlParent.isRendered = true;
if (x.namespaceURI == jpf.ns.jml || x.tagUrn == jpf.ns.jml)
this.lastNsPrefix = x.prefix || x.scopeName;
for (var oCount = 0,i = 0; i < x.childNodes.length; i++) {
var q = x.childNodes[i];
if (q.nodeType == 8) continue;
if (q.nodeType != 1) {
if (!pHtmlNode) continue;
if (jpf.isIE && !q.nodeValue.trim())
continue;
if (q.nodeType == 3 || pHtmlNode.style && q.nodeType == 4) {
pHtmlNode.appendChild(pHtmlNode.ownerDocument
.createTextNode(!jpf.hasTextNodeWhiteSpaceBug
? q.nodeValue
: q.nodeValue.replace(this.reWhitespaces, " ")));
}
else if (q.nodeType == 4) {
pHtmlNode.appendChild(pHtmlNode.ownerDocument
.createCDataSection(q.nodeValue));
}
continue;
}
if (!this.nsHandler[q.namespaceURI || q.tagUrn || jpf.ns.xhtml])
continue; 
this.nsHandler[q.namespaceURI || q.tagUrn || jpf.ns.xhtml].call(
this, q, pHtmlNode, jmlParent, noImpliedParent);
}
if (pHtmlNode) {
jpf.layout.activateRules(pHtmlNode);
}
return pHtmlNode;
},
addNamespaceHandler : function(xmlns, func){
this.nsHandler[xmlns] = func;
},
nsHandler : {
"http://www.javeline.com/2005/jml" : function(x, pHtmlNode, jmlParent, noImpliedParent){
var tagName = x[jpf.TAGNAME];
if (tagName == "include") {
var xmlNode = jpf.includeStack[x.getAttribute("iid")];
this.parseChildren(xmlNode, pHtmlNode, jmlParent, null, true);
}
else
if (this.handler[tagName]) {
var o, id, name;
if (id = x.getAttribute("j_preparsed")) {
x.removeAttribute("j_preparsed");
o = this.preparsed[id];
delete this.preparsed[id];
if (o && !o.parentNode) {
if (jmlParent.hasFeature && jmlParent.hasFeature(__WITH_JMLDOM__))
o.$setParent(jmlParent);
else {
o.parentNode = jmlParent;
jmlParent.childNodes.push(o);
}
}
return o;
}
o = this.handler[tagName](x, (noImpliedParent
? null
: jmlParent), pHtmlNode);
name = x.getAttribute("id"); 
if (o && name)
jpf.nameserver.register(tagName, name, o);
if (!o || !o.nodeType)
o = new jpf.JmlDom(tagName, jmlParent, jpf.NODE_HIDDEN, x, o);
else if(noImpliedParent)
o.$setParent(jmlParent);
o.$jmlLoaded = true;
if (name)
jpf.setReference(name, o);
}
else if (pHtmlNode) {
if (!jpf[tagName])
throw new Error("Could not find class " + tagName);
var objName = tagName;
var o = new jpf[objName](pHtmlNode, tagName, x);
if (x.getAttribute("id"))
jpf.setReference(x.getAttribute("id"), o);
if (o.loadJml)
o.loadJml(x, jmlParent);
o.$jmlLoaded = true;
}
return o;
}
,"http://www.w3.org/1999/xhtml" :  function(x, pHtmlNode, jmlParent, noImpliedParent){
var parseWhole = x.tagName.match(/table|object|embed/i) ? true : false;
if (x.tagName == "script") {
return;
}
else if (x.tagName == "option") {
var o = pHtmlNode.appendChild(pHtmlNode.ownerDocument.createElement("option"));
if (x.getAttribute("value"))
o.setAttribute("value", x.getAttribute("value"));
}
else if (jpf.isIE) {
var o = (x.ownerDocument == pHtmlNode.ownerDocument)
? pHtmlNode.appendChild(x.cloneNode(false))
: jpf.xmldb.htmlImport(x.cloneNode(parseWhole), pHtmlNode);
}
else if (jpf.isSafari) { 
var o = (x.ownerDocument == pHtmlNode.ownerDocument)
? pHtmlNode.appendChild(x)
: jpf.xmldb.htmlImport(x.cloneNode(parseWhole), pHtmlNode);
}
else {
var o = (x.ownerDocument == pHtmlNode.ownerDocument)
? pHtmlNode.appendChild(x.cloneNode(false))
: jpf.xmldb.htmlImport(x.cloneNode(false), pHtmlNode);
}
var tagName;
var prefix = this.lastNsPrefix || jpf.findPrefix(x.parentNode, jpf.ns.jml) || "";
if (prefix && !x.style) {
if (!jpf.supportNamespaces)
x.ownerDocument.setProperty("SelectionNamespaces", "xmlns:"
+ prefix + "='" + jpf.ns.jml + "'");
prefix += ":";
}
var done = {}, aNodes = !x.style && x.selectNodes("@" + prefix + "*") || [];
for (var i = 0; i < aNodes.length; i++) {
tagName = aNodes[i][jpf.TAGNAME];
if (tagName.match(/^(left|top|right|bottom|width|height|align)$/)) {
if (done["position"]) continue;
done["position"] = true;
var html = new jpf.HtmlWrapper(pHtmlNode, o, prefix);
if (x.getAttribute(prefix + "align")
|| x.getAttribute(prefix + "align-position")) {
html.enableAlignment()
}
else if (x.getAttribute(prefix + "width")
|| x.getAttribute(prefix + "height")
|| x.getAttribute(prefix + "left")
|| x.getAttribute(prefix + "top")
|| x.getAttribute(prefix + "right")
|| x.getAttribute(prefix + "bottom")
|| x.getAttribute(prefix + "anchoring") == "true") {
html.getDiff();
html.setHorizontal(x.getAttribute(prefix + "left"),
x.getAttribute(prefix + "right"),
x.getAttribute(prefix + "width"));
html.setVertical(x.getAttribute(prefix + "top"),
x.getAttribute(prefix + "bottom"),
x.getAttribute(prefix + "height"));
}
}
}
if ((jpf.canUseInnerHtmlWithTables || !parseWhole) && x.tagName.toUpperCase() != "IFRAME")
this.parseChildren(x, o, jmlParent);
else {
}
return o;
}
},
invalidJml : function(jml, message){
},
handler : {
"script" : function(q){
if (q.getAttribute("src")) {
if (jpf.isOpera) {
setTimeout(function(){
jpf.window.loadCodeFile(jpf.hostPath
+ q.getAttribute("src"));
}, 1000);
}
else {
jpf.window.loadCodeFile(jpf.hostPath
+ q.getAttribute("src"));
}
}
else if (q.firstChild) {
var scode = q.firstChild.nodeValue;
jpf.exec(scode);
}
},
"state-group" : function(q, jmlParent){
var name = q.getAttribute("name") || "stategroup" + jpf.all.length;
var pState = jpf.StateServer.addGroup(name, null, jmlParent);
var nodes = q.childNodes, attr = q.attributes, al = attr.length;
for (var j, i = 0, l = nodes.length; i < l; i++){
var node = nodes[i];
if (node.nodeType != 1 || node[jpf.TAGNAME] != "state")
continue;
for (j = 0; j < al; j++) {
if (!node.getAttribute(attr[j].nodeName))
node.setAttribute(attr[j].nodeName, attr[j].nodeValue);
}
node.setAttribute("group", name);
new jpf.state(jmlParent ? jmlParent.pHtmlNode : document.body, "state", node)
.loadJml(node, pState);
}
return pState;
},
"iconmap" : function(q, jmlParent){
var name = q.getAttribute("id");
return jpf.skins.addIconMap({
name   : name,
src    : q.getAttribute("src"),
type   : q.getAttribute("type"),
size   : parseInt(q.getAttribute("size")),
width  : parseInt(q.getAttribute("width")),
height : parseInt(q.getAttribute("height")),
offset : (q.getAttribute("offset") || "0,0").splitSafe(",")
});
},
"window" : function(q, jmlParent, pHtmlNode){
var o = new jpf.modalwindow(pHtmlNode, "window", q);
o.loadJml(q, jmlParent);
return o;
},
"style" : function(q){
jpf.importCssString(document, q.firstChild.nodeValue);
},
"comment" : function (q){
},
"presentation" : function(q){
var name = "skin" + Math.round(Math.random() * 100000);
q.parentNode.setAttribute("skin", name);
jpf.skins.skins[name] = {name:name,templates:{}}
var t    = q.parentNode[jpf.TAGNAME];
var skin = q.ownerDocument.createElement("skin"); skin.appendChild(q);
jpf.skins.skins[name].templates[t] = skin;
},
"skin" : function(q, jmlParent){
if (jmlParent) {
var name = "skin" + Math.round(Math.random() * 100000);
q.parentNode.setAttribute("skin", name);
jpf.skins.skins[name] = {name: name, templates: {}};
jpf.skins.skins[name].templates[q.parentNode[jpf.TAGNAME]] = q;
}
else if (q.childNodes.length) {
jpf.skins.Init(q);
}
else {
var path = q.getAttribute("src")
? jpf.getAbsolutePath(jpf.hostPath, q.getAttribute("src"))
: jpf.getAbsolutePath(jpf.hostPath, q.getAttribute("name")) + "/index.xml";
jpf.loadJmlInclude(q, true, path);
}
},
"model" : function(q, jmlParent){
var model = new jpf.model().loadJml(q, jmlParent);
if (jmlParent && jmlParent.hasFeature(__DATABINDING__)) {
modelId = "model" + jmlParent.uniqueId;
jmlParent.$jml.setAttribute("model", modelId);
model.register(jmlParent);
jpf.nameserver.register("model", modelId, model);
}
return model;
},
"smartbinding" : function(q, jmlParent){
var bc = new jpf.smartbinding(q.getAttribute("id"), q, jmlParent);
if (jmlParent && jmlParent.hasFeature(__DATABINDING__))
jpf.JmlParser.addToSbStack(jmlParent.uniqueId, bc);
return bc;
},
"ref" : function(q, jmlParent){
if (!jmlParent || !jmlParent.hasFeature(__DATABINDING__))
return jpf.JmlParser.invalidJml(q);
jpf.JmlParser.getFromSbStack(jmlParent.uniqueId)
.addBindRule(q, jmlParent);
}, 
"bindings" : function(q, jmlParent){
var rules = jpf.getRules(q);
if (jmlParent && jmlParent.hasFeature(__DATABINDING__))
jpf.JmlParser.getFromSbStack(jmlParent.uniqueId)
.addBindings(rules, q);
return rules;
},
"action" : function(q, jmlParent){
if (!jmlParent || !jmlParent.hasFeature(__DATABINDING__))
return jpf.JmlParser.invalidJml(q);
jpf.JmlParser.getFromSbStack(jmlParent.uniqueId)
.addActionRule(q, jmlParent);
}, 
"actions" : function(q, jmlParent){
var rules = jpf.getRules(q);
if (jmlParent && jmlParent.hasFeature(__DATABINDING__)) {
jpf.JmlParser.getFromSbStack(jmlParent.uniqueId)
.addActions(rules, q);
}
return rules;
},
"actiontracker" : function(q, jmlParent){
var at = new jpf.actiontracker(jmlParent);
at.loadJml(q);
if (jmlParent)
jmlParent.$at = at;
return at;
},
"teleport" : function(q, jmlParent){
return jpf.teleport.loadJml(q, jmlParent);
},
"appsettings" : function(q, jmlParent){
return jpf.appsettings.loadJml(q, jmlParent);
}
, "loader" : function(q){
}
},
getSmartBinding : function(id){
return jpf.nameserver.get("smartbinding", id);
},
getActionTracker : function(id){
var at = jpf.nameserver.get("actiontracker", id);
if (at)
return at;
if (self[id])
return self[id].getActionTracker();
},
replaceNode : function(newNode, oldNode){
var nodes = oldNode.childNodes;
for (var i = nodes.length - 1; i >= 0; i--) {
if (nodes[i].host) {
nodes[i].host.pHtmlNode = newNode;
}
newNode.insertBefore(nodes[i], newNode.firstChild);
}
newNode.onresize = oldNode.onresize;
return newNode;
},
parseLastPass : function(){
jpf.parsingFinalPass = true;
while (this.hasNewSbStackItems) {
var sbInit              = this.sbInit;
this.sbInit             = {};
this.hasNewSbStackItems = false;
for (var uniqueId in sbInit) {
if (parseInt(uniqueId) != uniqueId)
continue;
var jNode = jpf.lookup(uniqueId);
if (sbInit[uniqueId][0]) {
jNode.$propHandlers["smartbinding"]
.call(jNode, sbInit[uniqueId][0], true);
}
if (sbInit[uniqueId][1])
jNode.$setMultiBind(sbInit[uniqueId][1]);
}
}
this.sbInit = {};
var s = this.stateStack;
for (var i = 0; i < s.length; i++) {
s[i].node.setDynamicProperty(s[i].name, s[i].value);
}
this.stateStack = [];
while (this.hasNewModelStackItems) {
var jmlNode, modelInit     = this.modelInit;
this.modelInit             = {};
this.hasNewModelStackItems = false;
for (var data,i = 0; i < modelInit.length; i++) {
data    = modelInit[i][1];
data[0] = data[0].substr(1);
jmlNode = eval(data[0]);
if (jmlNode.connect)
jmlNode.connect(modelInit[i][0], null, data[2], data[1] || "select");
else
jmlNode.setModel(new jpf.model().loadFrom(data.join(":")));
}
}
this.modelInit = [];
if (!jpf.loaded)
jpf.dispatchEvent("load");
jpf.loaded = true;
jpf.layout.activateRules();
if (!this.loaded) {
jpf.window.focusDefault();
this.loaded = true;
}
jpf.isParsing = false;
jpf.parsingFinalPass = false;
}
,
addToSbStack : function(uniqueId, sNode, nr){
this.hasNewSbStackItems = true;
return ((this.sbInit[uniqueId]
|| (this.sbInit[uniqueId] = []))[nr||0] = sNode);
},
getFromSbStack : function(uniqueId, nr, create){
this.hasNewSbStackItems = true;
if (nr) {
if (!create)
return (this.sbInit[uniqueId] || {})[nr];
return this.sbInit[uniqueId]
&& (this.sbInit[uniqueId][nr]
|| (this.sbInit[uniqueId][nr] = new jpf.smartbinding()))
|| ((this.sbInit[uniqueId] = [])[nr] = new jpf.smartbinding());
}
return !this.sbInit[uniqueId]
&& (this.sbInit[uniqueId] = [new jpf.smartbinding()])[0]
|| this.sbInit[uniqueId][0]
|| (this.sbInit[uniqueId][0] = new jpf.smartbinding());
},
stackHasBindings : function(uniqueId){
return (this.sbInit[uniqueId] && this.sbInit[uniqueId][0]
&& this.sbInit[uniqueId][0].bindings);
}
,
addToModelStack : function(o, data){
this.hasNewModelStackItems = true;
this.modelInit.push([o, data]);
}
};
jpf.Init.run('jpf.JmlParser');
jpf.runXslt = function(){
jpf.XSLTProcessor = function(){
this.templates = {};
this.p = {
"value-of": function(context, xslNode, childStack, result){
var xmlNode = jpf.XPath.selectNodes(xslNode.getAttribute("select"), context)[0];
if (!xmlNode)
value = "";
else {
if (xmlNode.nodeType == 1)
value = xmlNode.firstChild ? xmlNode.firstChild.nodeValue : "";
else
value = typeof xmlNode == "object" ? xmlNode.nodeValue : xmlNode;
}
result.appendChild(this.xmlDoc.createTextNode(value));
},
"copy-of": function(context, xslNode, childStack, result){
var xmlNode = jpf.XPath.selectNodes(xslNode.getAttribute("select"), context)[0];
if (xmlNode)
result.appendChild(jpf.canImportNode
? result.ownerDocument.importNode(xmlNode, true)
: xmlNode.cloneNode(true));
},
"if": function(context, xslNode, childStack, result){
if (jpf.XPath.selectNodes(xslNode.getAttribute("test"), context)[0]) {
this.parseChildren(context, xslNode, childStack, result);
}
},
"for-each": function(context, xslNode, childStack, result){
var nodes = jpf.XPath.selectNodes(xslNode.getAttribute("select"), context);
for (var i = 0; i < nodes.length; i++) {
this.parseChildren(nodes[i], xslNode, childStack, result);
}
},
"choose": function(context, xslNode, childStack, result){
var nodes = xslNode.childNodes;
for (var i = 0; i < nodes.length; i++) {
if (!nodes[i].tagName)
continue;
if (nodes[i][jpf.TAGNAME]  == "otherwise"
|| nodes[i][jpf.TAGNAME] == "when"
&& jpf.XPath.selectNodes(nodes[i].getAttribute("test"), context)[0])
return this.parseChildren(context, nodes[i], childStack[i][2], result);
}
},
"output": function(context, xslNode, childStack, result){},
"param": function(context, xslNode, childStack, result){},
"attribute": function(context, xslNode, childStack, result){
var nres = this.xmlDoc.createDocumentFragment();
this.parseChildren(context, xslNode, childStack, nres);
result.setAttribute(xslNode.getAttribute("name"), nres.xml);
},
"apply-templates": function(context, xslNode, childStack, result){
if (!xslNode) {
var t = this.templates["/"] || this.templates[context.tagName];
if (t)
this.parseChildren(t == this.templates["/"]
? context.ownerDocument : context, t[0], t[1], result);
}
else {
if (xslNode.getAttribute("select")) {
var t = this.templates[xslNode.getAttribute("select")];
if (t) {
if (xslNode.getAttribute("select") == "/")
return alert("Something went wrong. The / template was executed as a normal template");
var nodes = context.selectNodes(xslNode.getAttribute("select"));
for (var i = 0; i < nodes.length; i++)
this.parseChildren(nodes[i], t[0], t[1], result);
}
}
else {
if (xslNode.getAttribute("name")) {
var t = this.templates[xslNode.getAttribute("name")];
if (t)
this.parseChildren(context, t[0], t[1], result);
}
else {
var ncontext = context.cloneNode(true); 
var nres = this.xmlDoc.createDocumentFragment();
var nodes = ncontext.childNodes;
for (var tName, i = nodes.length - 1; i >= 0; i--) {
if (nodes[i].nodeType == 3 || nodes[i].nodeType == 4) {
continue;
}
if (!nodes[i].nodeType == 1)
continue;
var n = nodes[i];
for (tName in this.templates) {
if (tName == "/")
continue;
var t = this.templates[tName];
var snodes = n.selectNodes("self::" + tName);
for (var j = snodes.length - 1; j >= 0; j--) {
var s = snodes[j], p = s.parentNode;
this.parseChildren(s, t[0], t[1], nres);
if (nres.childNodes) {
for (var k = nres.childNodes.length - 1; k >= 0; k--)
p.insertBefore(nres.childNodes[k], s);
}
p.removeChild(s);
}
}
if (n.parentNode) {
var p = n.parentNode;
this.p["apply-templates"].call(this, n, xslNode, childStack, nres);
if (nres.childNodes) {
for (var k = nres.childNodes.length - 1; k >= 0; k--)
p.insertBefore(nres.childNodes[k], n);
}
p.removeChild(n);
}
}
for (var i = ncontext.childNodes.length - 1; i >= 0; i--)
result.insertBefore(ncontext.childNodes[i], result.firstChild);
}
}
}
},
cache   : {},
"import": function(context, xslNode, childStack, result){
var file = xslNode.getAttribute("href");
if (!this.cache[file]) {
var data = new jpf.http().get(file);
this.cache[file] = data;
}
},
"include"  : function(context, xslNode, childStack, result){},
"when"     : function(){},
"otherwise": function(){},
"copy-clone": function(context, xslNode, childStack, result){
result = result.appendChild(jpf.canImportNode ? result.ownerDocument.importNode(xslNode, false) : xslNode.cloneNode(false));
if (result.nodeType == 1) {
for (var i = 0; i < result.attributes.length; i++) {
var blah = result.attributes[i].nodeValue; 
if (!jpf.isSafariOld && result.attributes[i].nodeName.match(/^xmlns/))
continue;
result.attributes[i].nodeValue = result.attributes[i].nodeValue.replace(/\{([^\}]+)\}/g, function(m, xpath){
var xmlNode = jpf.XPath.selectNodes(xpath, context)[0];
if (!xmlNode) {
value = "";
}
else {
if (xmlNode.nodeType == 1)
value = xmlNode.firstChild ? xmlNode.firstChild.nodeValue : "";
else
value = typeof xmlNode == "object" ? xmlNode.nodeValue : xmlNode;
}
return value;
});
result.attributes[i].nodeValue; 
}
}
this.parseChildren(context, xslNode, childStack, result);
}
}
this.parseChildren = function(context, xslNode, childStack, result){
if (!childStack)
return;
for (var i = 0; i < childStack.length; i++) {
childStack[i][0].call(this, context, childStack[i][1], childStack[i][2], result);
}
};
this.compile = function(xslNode){
var nodes = xslNode.childNodes;
for (var stack = [], i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1 && nodes[i].nodeType != 3 && nodes[i].nodeType != 4)
continue;
if (nodes[i][jpf.TAGNAME] == "template") {
this.templates[nodes[i].getAttribute("match") || nodes[i].getAttribute("name")] = [nodes[i], this.compile(nodes[i])];
}
else {
if (nodes[i][jpf.TAGNAME] == "stylesheet") {
this.compile(nodes[i])
}
else {
if (nodes[i].prefix == "xsl") {
var func = this.p[nodes[i][jpf.TAGNAME]];
if (!func)
alert("xsl:" + nodes[i][jpf.TAGNAME] + " is not supported at this time on this platform");
else
stack.push([func, nodes[i], this.compile(nodes[i])]);
}
else {
stack.push([this.p["copy-clone"], nodes[i], this.compile(nodes[i])]);
}
}
}
}
return stack;
};
this.importStylesheet = function(xslDoc){
this.xslDoc = xslDoc.nodeType == 9 ? xslDoc.documentElement : xslDoc;
xslStack = this.compile(xslDoc);
this.xslStack = [[this.p["apply-templates"], null]];
};
this.transformToFragment = function(doc, newDoc){
this.xmlDoc = newDoc.nodeType != 9 ? newDoc.ownerDocument : newDoc;
var docfrag = this.xmlDoc.createDocumentFragment();
if (!jpf.isSafariOld && doc.nodeType == 9)
doc = doc.documentElement;
var result = this.parseChildren(doc, this.xslDoc, this.xslStack, docfrag);
return docfrag;
};
};
self.XSLTProcessor = jpf.XSLTProcessor;
}
jpf.url = function(str) {
var base;
if (str.indexOf(":") == -1 && (base = window.location.toString()).indexOf(":") != -1) {
base = new jpf.url(base);
str = jpf.getAbsolutePath("http://" + base.host + "/"
+ (base.directory.charAt(base.directory.length - 1) == "/"
? base.directory
: base.directory + '/'), str);
}
var o    = jpf.url.options,
m        = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
i        = 14;
this.uri = str.toString(); 
while (i--)
this[o.key[i]] = m[i] || "";
this[o.q.name] = {};
var _self = this;
this[o.key[12]].replace(o.q.parser, function($0, $1, $2){
if ($1)
_self[o.q.name][$1] = $2;
});
};
jpf.url.prototype = {
isSameLocation: function(){
if (this.uri.length && this.uri.charAt(0) == "#")
return false;
if (!this.protocol && !this.port && !this.host)
return true;
if (!this.protocol && this.host && this.port
&& window.location.hostname == this.host
&& window.location.port     == this.port) {
return true;
}
if (!this.protocol && this.host && !this.port
&& window.location.hostname == this.host
&& window.location.port     == 80) {
return true;
}
return window.location.protocol == (this.protocol + ":")
&& window.location.hostname == this.host
&& (window.location.port    == this.port || !window.location.port && !this.port);
}
};
jpf.url.options = {
strictMode: false,
key: ["source", "protocol", "authority", "userInfo", "user", "password",
"host", "port", "relative", "path", "directory", "file", "query",
"anchor"],
q  : {
name  : "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
loose : /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}
};
jpf.JSImplementation = function(){
var types = ['[', '{', '(', 'text', 'xpath', 'word', 'sep', 'ws', 'semi', 'sh', 'op', 'col', 'str', 'regex', 'comment'];
var closes = [']', '}', ')'];
var reParse = new RegExp();
reParse.compile("([\\w_\\.]+)|([\\s]*,[\\s]*)|([\\s]*;[\\s]*)|(\\/\\*)|(\\*\\/)|(\\/\\/)|([\\r\\n])|((?:[\\s]*)[\\$\\@\\#\\%\\^\\&\\*\\?\\!](?:[\\s]*))|([\\s]*[\\+\\-\\<\\>\\|\\=]+[\\s]*)|(\\s*\\:\\s*)|(\\s+)|(\\\\[\\\\\\{\\}\\[\\]\\\"\\'\\/])|(\\[)|(\\])|([\\s]*\\([\\s]*)|([\\s]*\\)[\\s]*)|([\\s]*\\{[\\s]*)|([\\s]*\\}[\\s]*)|(\\')|(\\\")|(\\/)", "g");
this.dump_tree = function(n, s, w){
for (var i = 0; i < n.length; i++) {
var m = n[i], t = m[0];
if (t < 3) {
s.push(w + types[t]);
this.dump_tree(m[1], s, '  ' + w);
s.push(closes[t]);
s.push('\n');
}
else {
s.push(w + types[t] + ': ' + m[1] + '\n');
}
}
return s;
};
this.parse = function(str, trim_startspace){
var err    = []; 
var tree   = []; 
var stack  = []; 
var node   = tree;
var blevel = 0, tpos = 0;
var istr   = 0, icc = 0;
var lm     = 0;
var count  = [0, 0, 0];
str.replace(reParse, function(m, word, sep, semi, c1, c2, c3, nl, sh,
op, col, ws, bs1, bo, bc, po, pc, co, cc, q1, q2, re, pos){
function add_track(t){
var txt = trim_startspace
? str.substr(tpos, pos - tpos)
.replace(/[\r\n]\s*/, '').replace(/^\s*[\r\n]/, '')
.replace(/[\r\n\t]/g, '')
: str.substr(tpos, pos - tpos).replace(/[\r\n\t]/g, '');
if (txt.length > 0) {
node[node.length] = [t, txt, tpos, pos];
}
}
function add_node(t, data){
node[node.length] = [t, data, pos];
}
function add_sub(t){
count[t]++;
var n = [];
node[node.length] = [t, n, pos];
stack[stack.length] = node;
node = n;
}
function pop_sub(t){
count[t]--;
if (stack.length == 0) {
err[err.length] = ["extra " + closes[t], pos];
}
else {
node = stack.pop();
var ot = node[node.length - 1][0];
if (ot != t) {
err[err.length] = ["scope mismatch " + types[ot] + " with " + types[t], pos];
}
}
}
if (!istr) {
if (word) {
add_node(5, m);
if (m == 'macro') 
lm = 1;
else 
if (lm) 
macros[m] = 1, lm = 0;
}
if (sep) 
add_node(6, ',');
if (ws) 
add_node(7, m);
if (semi) 
add_node(8, m);
if (sh) 
add_node(9, m);
if (op) 
add_node(10, m);
if (col) 
add_node(11, m);
if (bo) {
add_sub(0);
}
if (bc) {
pop_sub(0);
}
if (co) 
add_sub(1);
if (cc) 
pop_sub(1);
if (po) 
add_sub(2);
if (pc) 
pop_sub(2);
}
if (c3) {
if (istr == 0) {
istr = 5;
tpos = pos + 2;
}
};
if (nl) {
if (istr == 5) {
istr = 0;
pos += 1;
add_track(14);
}
}
if (q1) {
if (istr == 0) {
istr = 1;
tpos = pos;
} else 
if (istr == 1) {
istr = 0;
pos += 1;
add_track(12);
}
}
if (q2) {
if (istr == 0) {
istr = 2;
tpos = pos;
} else 
if (istr == 2) {
istr = 0;
pos += 1;
add_track(12);
}
}
if (c1) {
if (istr == 0) {
istr = 4;
tpos = pos + 2;
};
}
if (c2) {
if (istr == 4) {
istr = 0;
add_track(14);
}
}
if (re) {
if (istr == 0) {
if (node.length == 0 || node[node.length - 1][0] == 6) {
istr = 3;
tpos = pos;
} else 
add_node(10, m);
}
else 
if (istr == 3) {
istr = 0;
pos += 1;
add_track(13);
}
}
return m;
});
if (stack.length > 0) 
for (var i = stack.length - 1; i >= 0; i--) {
var j = stack[i][stack[i].length - 1];
err[err.length] = ["unclosed tag " + types[j[0]], j[2]];
}
return {
'tree' : tree,
'stack': stack,
'err'  : err,
'count': count
};
};
};
jpf.JavascriptParser = new jpf.JSImplementation();
jpf.JsltImplementation = function(){
var bigRegExp = /([\w_\.]+)|(\s*,\s*)|(\s*;\s*)|((?:\s*)[\$\@\#\%\^\&\*\?\!](?:\s*))|(\s*[\+\-\<\>\|\=]+\s*)|(\s*\:\s*)|(\\[\\\{\}\[\]\"\'\/])|(\[)|(\])|(\s*\(\s*)|(\s*\)\s*)|(\s*\{\s*)|(\s*\}\s*)|(\')|(\")|(\/)|(\s+)/g;
function isString(){
if (typeof arguments[0] == 'string') 
return true;
if (typeof arguments[0] == 'object' && arguments[0].constructor) 
return (arguments[0].constructor.toString().match(/string/i) != null);
return false;
}
function jesc(s, esc){
if (!esc) 
return s;
if (!s) 
return '';
if (esc.toLowerCase() == 'q') 
return s.replace(/&/g, "&amp;").replace(/\'/g, "\\&squot")
.replace(/\"/g, "\\&quot").replace(/\r?\n/g, "\\n");
return s;
}
function jcpy(s, n, p){
if (!n) 
return;
if (p) {
var t = n.selectNodes(p);
if (!t || t.length == 0) 
return;
for (var i = 0; i < t.length; i++) 
s[s.length] = t[i].xml;
}
else 
s[s.length] = n.xml;
}
function jxml(n, p){
if (!n) 
return;
if (p) {
var o = [];
var t = n.selectNodes(p);
if (!t || t.length == 0) 
return;
for (var i = 0; i < t.length; i++) 
o[o.length] = t[i].xml;
}
else 
return n.xml;
return o.join('');
}
function jval(n, p){
if (!n) 
return '';
if (p) 
n = n.selectSingleNode(p);
if (!n) 
return '';
if (n.nodeType == 1) 
n = n.firstChild;
return n ? n.nodeValue : '';
}
function jloc(n, f, p){
if (!n || !p) 
return;
n = isString(p) ? n.selectSingleNode(p) : p;
if (!n) 
return;
f(n);
}
function jdbg(a){
jpf.console.info(a)
}
function jnod(n, p){
if (!n) 
return '';
if (p) 
n = n.selectSingleNode(p);
if (!n) 
return null;
return n;
}
function jnds(n, p){
if (!n) 
return '';
if (p) 
n = n.selectNodes(p);
if (!n) 
return null;
return n;
}
function jexs(n, p){
if (!n) 
return false;
if (p) 
n = n.selectSingleNode(p);
return n != null;
}
function jemp(n, p){
if (!n) 
return false;
if (p) 
n = n.selectSingleNode(p);
if (!n) 
return true;
if (n.nodeType == 1) 
n = n.firstChild;
return (n ? n.nodeValue : '').match(/^[\s\r\n\t]*$/) != null;
}
function jcnt(n, p){
if (!n) 
return 0;
var t = n.selectNodes(p);
return t ? t.length : 0;
}
function jpak(n, f, p){
var s = [];
f(s, n);
return s.join('');
}
function jstore(n, pk, f, p){
if (!p) 
p = 'def';
if (!pk[p]) 
pk[p] = [];
f(pk[p], n);
return;
}
function jfetch(pk, p){
if (!p) 
p = 'def';
if (pk[p]) 
return pk[p].join('');
return '';
}
function jfra(f, t, sp, ep){
if (!t) 
return;
var end = ep == null ? t.length : Math.min(t.length, (sp + ep));
for (var i = (sp == null) ? 0 : sp; i < end; i++) 
f(i, end, t[i]);
}
function jvls(n, p){
var r = [];
if (!n) 
return r;
var t = n.selectNodes(p);
if (!t) 
return r;
for (var i = 0; i < t.length; i++) {
n = t[i];
if (n.nodeType == 1) 
n = n.firstChild;
r[i] = n ? n.nodeValue : '';
}
return r;
}
function jpar(f, str){
f ((typeof str != "string")
? str
: parseXML(str).documentElement);
}
function jfor(n, f, p, sp, ep){
if (!n) 
return;
var t = n.selectNodes(p);
var end = ep == null ? t.length : Math.min(t.length, (sp + ep));
for (var i = (sp == null) ? 0 : sp; i < end; i++) 
f(i, end, t[i]);
}
var sort_intmask = ["", "0", "00", "000", "0000", "00000", "000000",
"0000000", "00000000", "000000000", "0000000000", "00000000000",
"000000000000", "0000000000000", "00000000000000"];
var sort_dateFmtStr;
var sort_dateFormat;
var sort_dateReplace;
function sort_dateFmt(str){
sort_dateFmtStr = str;
var result = str.match(/(D+|Y+|M+|h+|m+|s+)/g);
if (!result) 
return;
for (var pos = {}, i = 0; i < result.length; i++) 
pos[result[i].substr(0, 1)] = i + 1;
sort_dateFormat = new RegExp(str.replace(/[^\sDYMhms]/g, '\\$1')
.replace(/YYYY/, "(\\d\\d\\d\\d)")
.replace(/(DD|YY|MM|hh|mm|ss)/g, "(\\d\\d)"));
sort_dateReplace = "$" + pos["M"] + "/$" + pos["D"] + "/$" + pos["Y"];
if (pos["h"]) 
sort_dateReplace += " - $" + pos["h"] + ":$" + pos["m"] + ":$" + pos["s"];
}
function sort_alpha(n){
if (!n) 
return '';
if (n.nodeType == 1) 
n = n.firstChild;
return n ? n.nodeValue : '';
}
function sort_number(n){
var t = sort_alpha(n);
return (t.length < sort_intmask.length
? sort_intmask[sort_intmask.length - t.length]
: "") + t;
}
function sort_date(n, args){
if (!sort_dateFormat || (args && sort_dateFmtStr != args[0])) 
sort_dateFmt(args ? args[0] : "*");
var t = sort_alpha(n), d;
if (sort_dateFmtStr == '*') 
d = Date.parse(t);
else 
d = (new Date(t.replace(sort_dateFormat, sort_dateReplace))).getTime();
t = "" + parseInt(d);
if (t == "NaN") 
t = "0";
return (t.length < sort_intmask.length
? sort_intmask[sort_intmask.length - t.length]
: "") + t;
}
function jsort(n, f, p, ps, sm, desc, sp, ep){
sm = sm ? sm : sort_alpha;
var sa = [], t = n.selectNodes(p), i = t.length, args = null;
if (typeof sm != "function") {
var m = sm.shift();
args = sm;
sm = m;
}
while (i--) {
n = t[i].selectSingleNode(ps);
if (n) 
sa[sa.length] = {
toString: function(){
return this.v;
},
pn: t[i],
v: sm(n, args)
};
else 
sa[sa.length] = {
toString: function(){
return this.v;
},
pn: t[i],
v: ''
};
}
sa.sort();
var end = ep == null ? sa.length : Math.min(sa.length, (sp + ep));
var start = (sp == null) ? 0 : sp;
if (desc) {
for (i = end - 1; i >= start; i--) 
f(end - i - 1, end, sa[i].pn, sa[i].v);
}
else {
for (i = start; i < end; i++) 
f(i, end, sa[i].pn, sa[i].v);
}
}
function japl(s, n, ma, p){
if (!n) 
return;
var m = n.selectNodes(p || 'node()');
for (var i = 0; i < m.length; i++) {
n = m[i];
var f = ma[0][n.tagName];
if (f) 
f(s, n);
else {
for (var k = 1; k < ma.length; k++) {
var sn = n.selectSingleNode(ma[k][0]);
if (sn) {
ma[k][1](s, sn);
break;
}
}
}
}
}
function jmat(ma, f, p){
var s = p.split(/\|/), all = true;
for (var i = 0; i < s.length; i++) {
if (!s[i].match(/^[\w_]+$/)) 
all = false;
ma[0][s[i]] = f;
}
if (!all) {
p = "self::" + p.replace(/\|/g, "|self::");
ma[ma.length] = [p, f];
}
}
function joff(n){
for (var p = n.parentNode.childNodes, i = p.length-1; i>=0; i--)
if (p[i] == n)
return i;
return '';
}
var types = ['[', '{', '(', 'text', 'xpath', 'word', 'sep', 'ws', 'semi',
'sh', 'op', 'col', 'str', 'regex'];
var closes = [']', '}', ')'];
var func = {
'last'    : [0, '(i==len-1)'],
'first'   : [0, '(i==0)'],
'offset'  : [0, 'joff(n)'],
'out'     : [0, 's[s.length]'],
'apply'   : [1, ';japl(s,n,ma,', ');'],
'copy'    : [1, ';jcpy(s,n,', ');'],
'xml'     : [1, 'jxml(n,', ')'],
'value'   : [1, 'jval(n,', ')'],
'exists'  : [1, 'jexs(n,', ')'],
'empty'   : [1, 'jemp(n,', ')'],
'values'  : [1, 'jvls(n,', ')'],
'node'    : [1, 'jnod(n,', ')'],
'nodes'   : [1, 'jnds(n,', ')'],
'count'   : [1, 'jcnt(n,', ')'],
'context' : [1, '(n=n.selectSingleNode(', '))'],
'foreach' : [2, ';jfor(n,function(i,len,n){', '},', ');'],
'sort'    : [2, ';jsort(n,function(i,len,n,sv){', '},', ');'],
'local'   : [2, ';jloc(n,function(n){', '},', ');'],
'match'   : [2, ';jmat(ma,function(s,n){', '},', ');'],
'pack'    : [2, 'jpak(n,function(s,n){', '},', ')'],
'store'   : [2, 'jstore(n,os,function(s,n){', '},', ');'],
'fetch'   : [1, 'jfetch(os,', ')'],
'parse'   : [2, 'jpar(function(n){', '},', ');'],
'forarray': [3],
'macro'   : [4],
'pragma'  : [5],
'_'       : [6]
};
var short_0 = {
'%': 's[s.length]='
};
var short_1 = {
'$': ['jval(n,', ')'],
'&': ['jnod(n,', ')'],
'@': ['(n=n.selectSingleNode(', '))'],
'~': ['jexs(n,', ')'],
'!': ['!jexs(n,', ')'],
'#': ['jcnt(n,', ')'],
'^': [';japl(s,n,ma,', ');']
};
var short_2 = {
'*': [';jfor(n,function(i,len,n){', '},', ')']
};
function dump_tree(n, s, w){
for (var i = 0; i < n.length; i++) {
var m = n[i], t = m[0];
if (t < 3) {
s.push(w + types[t]);
dump_tree(m[1], s, '&nbsp;&nbsp;' + w);
s.push(closes[t]);
s.push('\n');
} else {
s.push(w + types[t] + ': ' + m[1] + '\n');
}
}
}
this.jslt_inline = [];  
this.compile = function(str, trim_startspace){
var pre;
if (pre=str.match(/^var s\=\[(\d*)\]/)){
if (pre[1] != '')
return [this.jslt_inline[pre[1]], str];
try {
eval("var f = function(n){" + str + "};");
} catch (e) {
jpf.console.info(jpf.formatJS(str));
throw new Error("Could not parse Precompiled JSLT with: " + e.message);
}
return [f, str];
}
var err    = []; 
var tree   = []; 
var stack  = []; 
var node   = tree;
var blevel = 0, tpos = 0;
var istr   = 0, icc = 0;
var lm     = 0;
var macros = {};
str        = str.replace(/\/\*[\s\S]*?\*\//gm, "");
str.replace(bigRegExp,
function(m, word, sep, semi, sh, op, col, bs1, bo, bc, po, pc, co, cc, q1, q2, re, ws, pos){
function add_track(t){
var txt = trim_startspace ? str.substr(tpos, pos - tpos).replace(/[\r\n]\s*/, '').replace(/^\s*[\r\n]/, '').replace(/\\s/g, ' ').replace(/[\r\n\t]/g, '') : str.substr(tpos, pos - tpos).replace(/[\r\n\t]/g, '');
if (txt.length > 0) {
node[node.length] = [t, txt, tpos, pos];
}
}
function add_node(t, data){
node[node.length] = [t, data, pos];
}
function add_sub(t){
var n = [];
node[node.length] = [t, n, pos];
stack[stack.length] = node;
node = n;
}
function pop_sub(t){
if (stack.length == 0) {
err[err.length] = ["extra " + closes[t], pos];
}
else {
node = stack.pop();
var ot = node[node.length - 1][0];
if (ot != t) {
err[err.length] = ["scope mismatch " + types[ot] + " with " + types[t], pos];
}
}
}
if (blevel == 0 || (bc && blevel == 1 && !istr)) {
if (icc == 0) {
if (bo) {
add_track(3);
blevel++;
} 
if (bc) {
if (blevel == 0) 
err[err.length] = ["extra ]", pos];
else {
blevel--;
tpos = pos + 1;
}
} 
}
if (co) {
					pos+=co.indexOf('{');
add_track(3);
tpos = pos + 1;
icc++;
} 
if (cc) {
add_track(4);
tpos = pos + cc.indexOf('}') + 1;
icc--;
if (icc < 0) 
err[err.length] = ["extra }", pos];
} 
}
else {
if (!istr) {
if (word) {
add_node(5, m);
if (m == 'macro') 
lm = 1;
else 
if (lm) 
macros[m] = 1, lm = 0;
}
if (sep) 
add_node(6, ',');
if (ws) 
add_node(7, m);
if (semi) 
add_node(8, m);
if (sh) 
add_node(9, m);
if (op) 
add_node(10, m);
if (col) 
add_node(11, m);
if (bo) {
blevel++;
add_sub(0);
}
if (bc) {
blevel--;
pop_sub(0);
}
if (co) 
add_sub(1);
if (cc) 
pop_sub(1);
if (po) 
add_sub(2);
if (pc) 
pop_sub(2);
}
if (q1) {
if (istr == 0) {
istr = 1;
tpos = pos;
}
else 
if (istr == 1) {
istr = 0;
pos += 1;
add_track(12);
}
}
if (q2) {
if (istr == 0) {
istr = 2;
tpos = pos;
}
else 
if (istr == 2) {
istr = 0;
pos += 1;
add_track(12);
}
}
if (re) {
if (istr == 0) {
if (node.length == 0 || node[node.length - 1][0] == 6) {
istr = 3;
tpos = pos;
} else 
add_node(10, m);
}
else 
if (istr == 3) {
istr = 0;
pos += 1;
add_track(13);
}
}
}
return m;
});
if (blevel == 0) {
var txt = str.substr(tpos, str.length - tpos).replace(/[\r\n\t]/g, '');
if (txt.length > 0) {
node[node.length] = [3, txt, tpos, str.length];
}
}
if (stack.length > 0) 
for (var i = stack.length - 1; i >= 0; i--) {
var j = stack[i][stack[i].length - 1];
err[err.length] = ["unclosed tag " + types[j[0]], j[2]];
}
var s = ['var s=[],ma=[{}],os={};'];
var pragma_trace = 0;
function line_pos(cpos){
var l = 0;
str.replace(/\n/g, function(m, pos){
if (pos < cpos) 
l++;
return m;
});
return l;
}
function compile_recur(s, n, offset){
var k = n.length;
var d, e;
for (var i = ((offset == null) ? 0 : offset); i < k; i++) {
var t = n[i][0];
if (t == 5) {
var nt1 = (i < k - 1) ? n[i + 1][0] : -1, nt2 = (i < k - 2) ? n[i + 2][0] : -1;
var m = n[i][1];
var d = func[m];
if (d) {
switch (d[0]) {
case 0:
s[s.length] = d[1];
break;
case 1: 
if (nt1 != 2) {
err[err.length] = ["Function " + m + " syntax error", n[i][2]];
}
else {
s[s.length] = d[1];
if (!compile_recur(s, n[i + 1][1])) 
s[s.length] = 'null';
s[s.length] = d[2];
i++;
}
break;
case 2: 
if (nt1 != 2 || nt2 != 1) {
err[err.length] = ["Function " + m + " syntax error", n[i][2]];
}
else {
s[s.length] = d[1];
compile_recur(s, n[i + 2][1]);
s[s.length] = d[2];
if (!compile_recur(s, n[i + 1][1])) 
s[s.length] = 'null';
s[s.length] = d[3];
i += 2;
}
break;
case 3:
var o, ok;
if (i > k - 3 || n[i + 1][0] != 2 || n[i + 2][0] != 1 || (o = n[i + 1][1])[0][0] != 5 ||
(ok = o.length) < 5 ||
o[1][0] != 7 ||
o[2][0] != 5 ||
o[2][1] != 'in') {
err[err.length] = ["forarray syntax error", n[i][2]];
}
else {
s[s.length] = ';jfra(function(i,len,' + o[0][1] + '){';
compile_recur(s, n[i + 2][1]);
s[s.length] = '},';
compile_recur(s, o, 3);
s[s.length] = ');';
i += 2;
}
break;
case 4:
if (i >= k - 4 || n[i + 1][0] != 7 || n[i + 2][0] != 5 || n[i + 3][0] != 2 || n[i + 4][0] != 1) {
err[err.length] = ["macro syntax error at", n[0][2]];
}
else {
s[s.length] = 'function ' + n[i + 2][1] + '(s,n,';
if (!compile_recur(s, n[i + 3][1])) 
s[s.length] = 'null';
s[s.length] = '){';
compile_recur(s, n[i + 4][1]);
s[s.length] = '}';
i += 4;
}
break;
case 5:
{
if (i >= k - 3 || n[i + 1][0] != 7 || n[i + 2][0] != 5 || n[i + 3][0] != 2) {
err[err.length] = ["macro syntax error at", n[0][2]];
}
else {
switch (n[i + 2][1]) {
case 'trace':{
var ts = [];
compile_recur(ts, n[i + 3][1]);
pragma_trace = eval(ts.join(''));
}
break;
}
}
i += 3;
}
case 6:
{
s[s.length] = ';alert("Trace: ' + line_pos(n[i][2]) + '");';
}
}
}
else {
if (macros[m] && nt1 == 2) {
s[s.length] = m + '(s,n,';
if (!compile_recur(s, n[i + 1][1])) 
s[s.length] = 'null';
s[s.length] = ')';
i++;
}
else 
s[s.length] = m;
}
}
else 
if (t == 9) {
var nt1 = (i < k - 1) ? n[i + 1][0] : -1, nt2 = (i < k - 2) ? n[i + 2][0] : -1;
var m = n[i][1];
if (nt1 == 12) {
if (nt2 == 1) {
if (d = short_2[m]) {
s[s.length] = d[0];
compile_recur(s, n[i + 2][1]);
s[s.length] = d[1] + n[i + 1][1] + d[2];
i += 2;
lt = 1;
} else 
s[s.length] = m;
}
else {
if (d = short_1[m]) {
if (nt2 == 11) 
s[s.length] = m;
else {
s[s.length] = d[0] + n[i + 1][1] + d[1];
i++;
}
} else {
if (d = short_0[m]) 
s[s.length] = d;
else 
s[s.length] = m;
}
}
}
else {
if (d = short_0[m]) 
s[s.length] = d;
else 
s[s.length] = m;
}
}
else { 
if (t < 3) {
s[s.length] = types[t];
compile_recur(s, n[i][1]);
s[s.length] = closes[t];
if ((t == 1 && i < k - 1 && n[i + 1][0] == 5 && n[i + 1][1] != 'else') || 
(t == 2 && i < k - 1 && n[i + 1][0] == 5 && !n[i + 1][1].match(/^\./) && 
(i == 0 || n[i - 1][0] != 5 || !n[i - 1][1].match(/^(if|for)$/)))) {
s[s.length] = ';';
}
}
else {
if (t == 3) 
s[s.length] = ';s[s.length]="' + n[i][1]
.replace(/\"/g, "\\\"").replace(/\n/g, "\\n") + '";';
else 
if (t == 4) {
var m = n[i][1].match(/^\^([\w])\s?/);
if (m) {
s[s.length] = ';s[s.length]=jesc(jval(n,"'
+ n[i][1].substr(2)
.replace(/"/g, "\\\"") + '"),"' + m[1] + '");';
} else {
s[s.length] = ';s[s.length]=jval(n,"'
+ n[i][1].replace(/"/g, "\\\"") + '");';
}
}
else 
s[s.length] = n[i][1];
}
}
//lt = n[i][0];
}
return k;
}
if (err.length == 0) 
compile_recur(s, tree);
// return all parse errors
if (err.length > 0) {
var e = [];
for (var i = 0; i < err.length; i++) {
e[e.length] = 'Parse error(' + line_pos(err[i][1]) + '): ' + err[i][0] + '\n';
}
// lets spit out our parse tree
//var out=[];
//dump_tree(tree,out,'');
throw new Error("Could not parse JSLT with: " + e.join('') + "\n");
}
s[s.length] = ";return s.join('');";
var strJS = s.join('');
try {
eval("var f = function(n){" + strJS + "};");
}
catch (e) {
//var treedump=[];
//dump_tree(tree,treedump,'');	
jpf.console.info(jpf.formatJS(strJS));
throw new Error("Could not parse JSLT with: " + e.message );
}
return [f, strJS];
};
this.cache = [];
this.apply = function(jsltNode, xmlNode){
var jsltFunc, cacheId, jsltStr, doTest;
//Type detection xmlNode
xmlNode = jpf.xmldb.getBindXmlNode(xmlNode);
//Type detection jsltNode
if (typeof jsltNode == "object") {
//check the jslt node for cache setting
cacheId = jsltNode.getAttribute("cache");
jsltFunc = this.cache[cacheId];
if (!jsltFunc) {
var jsltStr = [], textNodes = jsltNode.selectNodes('text()');
for (var i = 0; i < textNodes.length; i++) {
jsltStr = textNodes[i].nodeValue;
if (jsltStr.trim()) 
break;
}
}
}
else {
cacheId = jsltNode;
jsltFunc = this.cache[cacheId];
if (!jsltFunc) {
jsltStr = jsltNode;
cacheId = null;
}
}
//Compile string
if (!jsltFunc) 
jsltFunc = this.compile(jsltStr);
this.lastJslt = jsltStr;
this.lastJs   = jsltFunc[0]; //if it crashes here there is something seriously wrong
//Invalid code - Syntax Error
if (!jsltFunc[0]) 
return false;
//Caching
if (!cacheId) {
if (typeof jsltNode == "object") {
cacheId = this.cache.push(jsltFunc) - 1
jsltNode.setAttribute("cache", cacheId);
}
else 
this.cache[jsltStr] = jsltFunc;
}
//Execute JSLT
try {
if (!xmlNode) 
return '';
return jsltFunc[0](xmlNode);
}
catch (e) {
jpf.console.info(jpf.formatJS(jsltFunc[1]));
throw new Error(jpf.formatErrorString(0, null, "JSLT parsing", "Could not execute JSLT with: " + e.message));
}
};
};
jpf.JsltInstance = new jpf.JsltImplementation();
jpf.runXpath = function(){
jpf.XPath = {
cache : {},
getSelf : function(htmlNode, tagName, info, count, num, sResult){
var numfound = 0, result = null, data = info[count];
if (data)
data[0](htmlNode, data[1], info, count + 1, numfound++ , sResult);
else
sResult.push(htmlNode);
},
getChildNode : function(htmlNode, tagName, info, count, num, sResult){
var numfound = 0, result = null, data = info[count];
var nodes = htmlNode.childNodes;
if (!nodes) return; //Weird bug in Safari
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1)
continue;
if (tagName && (tagName != nodes[i].tagName) && (nodes[i].style
? nodes[i].tagName.toLowerCase()
: nodes[i].tagName) != tagName)
continue;// || numsearch && ++numfound != numsearch
if (data)
data[0](nodes[i], data[1], info, count + 1, numfound++ , sResult);
else
sResult.push(nodes[i]);
}
//commented out :  && (!numsearch || numsearch == numfound)
},
doQuery : function(htmlNode, qData, info, count, num, sResult){
var result = null, data = info[count];
var query = qData[0];
var returnResult = qData[1];
try {
var qResult = eval(query);
}catch(e){
return;
}
if (returnResult)
return sResult.push(qResult);
if (!qResult) return;
if (data)
data[0](htmlNode, data[1], info, count + 1, 0, sResult);
else
sResult.push(htmlNode);
},
getTextNode : function(htmlNode, empty, info, count, num, sResult){
var result = null, data = info[count];
var nodes = htmlNode.childNodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 3 && nodes[i].nodeType != 4)
continue;
if (data)
data[0](nodes[i], data[1], info, count + 1, i, sResult);
else
sResult.push(nodes[i]);
}
},
getAnyNode : function(htmlNode, empty, info, count, num, sResult){
var result = null, data = info[count];
var sel = [], nodes = htmlNode.childNodes;
for (var i = 0; i < nodes.length; i++) {
if (data)
data[0](nodes[i], data[1], info, count + 1, i, sResult);
else
sResult.push(nodes[i]);
}
},
getAttributeNode : function(htmlNode, attrName, info, count, num, sResult){
if (!htmlNode || htmlNode.nodeType != 1) return;
var result = null, data = info[count];
var value = htmlNode.getAttributeNode(attrName);//htmlNode.attributes[attrName];//
if (data)
data[0](value, data[1], info, count + 1, 0, sResult);
else if (value)
sResult.push(value);
},
getAllNodes : function(htmlNode, x, info, count, num, sResult){
var result   = null, data = info[count];
var tagName  = x[0];
var inclSelf = x[1];
var prefix   = x[2];
if (inclSelf && (htmlNode.tagName == tagName || tagName == "*")) {
if (data)
data[0](htmlNode, data[1], info, count + 1, 0, sResult);
else
sResult.push(htmlNode);
}
var nodes = htmlNode.getElementsByTagName((prefix
&& (jpf.isGecko || jpf.isOpera) ? prefix + ":" : "") + tagName);
for (var i = 0; i < nodes.length; i++) {
if (data)
data[0](nodes[i], data[1], info, count + 1, i, sResult);
else
sResult.push(nodes[i]);
}
},
getAllAncestorNodes : function(htmlNode, x, info, count, num, sResult){
var result   = null, data = info[count];
var tagName  = x[0];
var inclSelf = x[1];
var prefix   = x[2];
var i = 0, s = inclSelf ? htmlNode : htmlNode.parentNode;
while (s && s.nodeType == 1) {
if (s.tagName == tagName || tagName == "*" || tagName == "node()") {
if (data)
data[0](s, data[1], info, count + 1, ++i, sResult);
else
sResult.push(s);
}
s = s.parentNode
}
},
getParentNode : function(htmlNode, empty, info, count, num, sResult){
var result = null, data = info[count];
var node   = htmlNode.parentNode;
if (data)
data[0](node, data[1], info, count + 1, 0, sResult);
else if (node)
sResult.push(node);
},
//precsiblg[3] might not be conform spec
getPrecedingSibling : function(htmlNode, tagName, info, count, num, sResult){
var result = null, data = info[count];
var node = htmlNode.previousSibling;
while (node) {
if (tagName != "node()" && (node.style
? node.tagName.toLowerCase()
: node.tagName) != tagName){
node = node.previousSibling;
continue;
}
if (data)
data[0](node, data[1], info, count+1, 0, sResult);
else if (node) {
sResult.push(node);
break;
}
}
},
//flwsiblg[3] might not be conform spec
getFollowingSibling : function(htmlNode, tagName, info, count, num, sResult){
var result = null, data = info[count];
var node = htmlNode.nextSibling;
while (node) {
if (tagName != "node()" && (node.style
? node.tagName.toLowerCase()
: node.tagName) != tagName) {
node = node.nextSibling;
continue;
}
if (data)
data[0](node, data[1], info, count+1, 0, sResult);
else if (node) {
sResult.push(node);
break;
}
}
},
multiXpaths : function(contextNode, list, info, count, num, sResult){
for (var i = 0; i < list.length; i++) {
info = list[i][0];
var rootNode = (info[3]
? contextNode.ownerDocument.documentElement
: contextNode);//document.body
info[0](rootNode, info[1], list[i], 1, 0, sResult);
}
sResult.makeUnique();
},
compile : function(sExpr){
var isAbsolute = sExpr.match(/^\//);//[^\/]/
sExpr = sExpr.replace(/\[(\d+)\]/g, "/##$1");
sExpr = sExpr.replace(/\|\|(\d+)\|\|\d+/g, "##$1");
sExpr = sExpr.replace(/\.\|\|\d+/g, ".");
sExpr = sExpr.replace(/\[([^\]]*)\]/g, function(match, m1){
return "/##" + m1.replace(/\|/g, "_@_");
}); //wrong assumption think of |
if(sExpr == "/" || sExpr == ".") return sExpr;
//Mark // elements
//sExpr = sExpr.replace(/\/\//g, "/[]/self::");
sExpr = sExpr.replace(/\/\//g, "descendant::");
//Check if this is an absolute query
return this.processXpath(sExpr, isAbsolute);
},
processXpath : function(sExpr, isAbsolute){
var results = new Array();
sExpr = sExpr.replace(/('[^']*)\|([^']*')/g, "$1_@_$2");
sExpr = sExpr.split("\|");
for (var i = 0; i < sExpr.length; i++)
sExpr[i] = sExpr[i].replace(/_\@\_/g, "|");//replace(/('[^']*)\_\@\_([^']*')/g, "$1|$2");
if (sExpr.length == 1)
sExpr = sExpr[0];
else {
for (var i = 0; i < sExpr.length; i++)
sExpr[i] = this.processXpath(sExpr[i]);
results.push([this.multiXpaths, sExpr]);
return results;
}
var sections   = sExpr.split("/");
for (var i = 0; i < sections.length; i++) {
if (sections[i] == "." || sections[i] == "")
continue;
else if (sections[i] == "..")
results.push([this.getParentNode, null]);
else if (sections[i].match(/^[\w-_\.]+(?:\:[\w-_\.]+){0,1}$/))
results.push([this.getChildNode, sections[i]]);//.toUpperCase()
else if (sections[i].match(/^\#\#(\d+)$/))
results.push([this.doQuery, ["num+1 == " + parseInt(RegExp.$1)]]);
else if (sections[i].match(/^\#\#(.*)$/)) {
//FIX THIS CODE
var query = RegExp.$1;
var m = [query.match(/\(/g), query.match(/\)/g)];
if (m[0] || m[1]) {
while (!m[0] && m[1] || m[0] && !m[1]
|| m[0].length != m[1].length){
if (!sections[++i]) break;
query += "/" + sections[i];
m = [query.match(/\(/g), query.match(/\)/g)];
}
}
results.push([this.doQuery, [this.compileQuery(query)]]);
}
else if (sections[i] == "*")
results.push([this.getChildNode, null]); //FIX - put in def function
else if (sections[i].substr(0,2) == "[]")
results.push([this.getAllNodes, ["*", false]]);//sections[i].substr(2) ||
else if (sections[i].match(/descendant-or-self::node\(\)$/))
results.push([this.getAllNodes, ["*", true]]);
else if (sections[i].match(/descendant-or-self::([^\:]*)(?:\:(.*)){0,1}$/))
results.push([this.getAllNodes, [RegExp.$2 || RegExp.$1, true, RegExp.$1]]);
else if (sections[i].match(/descendant::([^\:]*)(?:\:(.*)){0,1}$/))
results.push([this.getAllNodes, [RegExp.$2 || RegExp.$1, false, RegExp.$1]]);
else if (sections[i].match(/ancestor-or-self::([^\:]*)(?:\:(.*)){0,1}$/))
results.push([this.getAllAncestorNodes, [RegExp.$2 || RegExp.$1, true, RegExp.$1]]);
else if (sections[i].match(/ancestor::([^\:]*)(?:\:(.*)){0,1}$/))
results.push([this.getAllAncestorNodes, [RegExp.$2 || RegExp.$1, false, RegExp.$1]]);
else if (sections[i].match(/^\@(.*)$/))
results.push([this.getAttributeNode, RegExp.$1]);
else if (sections[i] == "text()")
results.push([this.getTextNode, null]);
else if (sections[i] == "node()")
results.push([this.getAnyNode, null]);//FIX - put in def function
else if (sections[i].match(/following-sibling::(.*)$/))
results.push([this.getFollowingSibling, RegExp.$1.toLowerCase()]);
else if (sections[i].match(/preceding-sibling::(.*)$/))
results.push([this.getPrecedingSibling, RegExp.$1.toLowerCase()]);
else if (sections[i] == "self::node()")
results.push([this.getSelf, null]);
else if (sections[i].match(/self::(.*)$/))
results.push([this.doQuery, ["jpf.XPath.doXpathFunc('local-name', htmlNode) == '" + RegExp.$1 + "'"]]);
else {
var query = sections[i];
//@todo FIX THIS CODE
//add some checking here
var m = [query.match(/\(/g), query.match(/\)/g)];
if (m[0] || m[1]) {
while (!m[0] && m[1] || m[0] && !m[1] || m[0].length != m[1].length) {
if (!sections[++i]) break;
query += "/" + sections[i];
m = [query.match(/\(/g), query.match(/\)/g)];
}
}
results.push([this.doQuery, [this.compileQuery(query), true]])
//throw new Error("---- Javeline Error ----\nMessage : Could not match XPath statement: '" + sections[i] + "' in '" + sExpr + "'");
}
}
results[0][3] = isAbsolute;
return results;
},
compileQuery : function(code){
var c = new jpf.CodeCompilation(code);
return c.compile();
},
doXpathFunc : function(type, arg1, arg2, arg3){
switch(type){
case "not":
return !arg1;
case "position()":
return num == arg1;
case "format-number":
return jpf.formatNumber(arg1); //@todo this should actually do something
case "floor":
return Math.floor(arg1);
case "ceiling":
return Math.ceil(arg1);
case "starts-with":
return arg1 ? arg1.substr(0, arg2.length) == arg2 : false;
case "string-length":
return arg1 ? arg1.length : 0;
case "count":
return arg1 ? arg1.length : 0;
case "last":
return arg1 ? arg1[arg1.length-1] : null;
case "local-name":
return arg1 ? arg1.tagName : "";//[jpf.TAGNAME]
case "substring":
return arg1 && arg2 ? arg1.substring(arg2, arg3 || 0) : "";
case "contains":
return arg1 && arg2 ? arg1.indexOf(arg2) > -1 : false;
case "concat":
for (var str="", i = 1; i < arguments.length; i++) {
if (typeof arguments[i] == "object") {
str += getNodeValue(arguments[i][0]);
continue;
}
str += arguments[i];
}
return str;
}
},
selectNodeExtended : function(sExpr, contextNode, match){
var sResult = this.selectNodes(sExpr, contextNode);
if (sResult.length == 0) return null;
if (!match) return sResult[0];
for (var i = 0; i < sResult.length; i++) {
if(getNodeValue(sResult[i]) == match)
return sResult[i];
}
return null;
},
selectNodes : function(sExpr, contextNode){
if (!this.cache[sExpr])
this.cache[sExpr] = this.compile(sExpr);
if (typeof this.cache[sExpr] == "string"){
if (this.cache[sExpr] == ".")
return [contextNode];
if (this.cache[sExpr] == "/")
return [(contextNode.nodeType == 9
? contextNode
: contextNode.ownerDocument).documentElement];
}
if (typeof this.cache[sExpr] == "string" && this.cache[sExpr] == ".")
return [contextNode];
var info = this.cache[sExpr][0];
var rootNode = (info[3]
? (contextNode.nodeType == 9
? contextNode
: contextNode.ownerDocument).documentElement
: contextNode);//document.body*/
var sResult = [];
info[0](rootNode, info[1], this.cache[sExpr], 1, 0, sResult);
return sResult;
}
};
function getNodeValue(sResult){
if (sResult.nodeType == 1)
return sResult.firstChild ? sResult.firstChild.nodeValue : "";
if (sResult.nodeType > 1 || sResult.nodeType < 5)
return sResult.nodeValue;
return sResult;
}
jpf.CodeCompilation = function(code){
this.data = {
F : [],
S : [],
I : [],
X : []
};
this.compile = function(){
code = code.replace(/ or /g, " || ");
code = code.replace(/ and /g, " && ");
code = code.replace(/!=/g, "{}");
code = code.replace(/=/g, "==");
code = code.replace(/\{\}/g, "!=");
// Tokenize
this.tokenize();
// Insert
this.insert();
code = code.replace(/, \)/g, ", htmlNode)");
return code;
};
this.tokenize = function(){
//Functions
var data = this.data.F;
code = code.replace(/(format-number|contains|substring|local-name|last|node|position|round|starts-with|string|string-length|sum|floor|ceiling|concat|count|not)\s*\(/g,
function(d, match){
return (data.push(match) - 1) + "F_";
}
);
//Strings
var data = this.data.S;
code = code.replace(/'([^']*)'/g, function(d, match){
return (data.push(match) - 1) + "S_";
});
code = code.replace(/"([^"]*)"/g, function(d, match){
return (data.push(match) - 1) + "S_";}
);
var data = this.data.X;
code = code.replace(/(^|\W|\_)([\@\.\/A-Za-z][\.\@\/\w]*(?:\(\)){0,1})/g,
function(d, m1, m2){
return m1 + (data.push(m2) - 1) + "X_";
});
code = code.replace(/(\.[\.\@\/\w]*)/g, function(d, m1, m2){
return (data.push(m1) - 1) + "X_";
});
var data = this.data.I;
code = code.replace(/(\d+)(\W)/g, function(d, m1, m2){
return (data.push(m1) - 1) + "I_" + m2;
});
};
this.insert = function(){
var data = this.data;
code = code.replace(/(\d+)X_\s*==\s*(\d+S_)/g, function(d, nr, str){
return "jpf.XPath.selectNodeExtended('"
+  data.X[nr].replace(/'/g, "\\'") + "', htmlNode, " + str + ")";
});
code = code.replace(/(\d+)([FISX])_/g, function(d, nr, type){
var value = data[type][nr];
if (type == "F") {
return "jpf.XPath.doXpathFunc('" + value + "', ";
}
else if (type == "S") {
return "'" + value + "'";
}
else if (type == "I") {
return value;
}
else if (type == "X") {
return "jpf.XPath.selectNodeExtended('"
+ value.replace(/'/g, "\\'") + "', htmlNode)";
}
});
};
};
}
jpf.profiler = {
stackTrace     : {},    
previousStack  : null,  
isRunning      : false, 
pointers       : {},    
hasPointers    : false, 
precision      : 3,     
runs           : 0,     
sortMethod     : 2,     
startBusy      : false, 
startQueue     : [],    
startQueueTimer: null,  
endBusy        : false, 
endQueue       : [],    
endQueueTimer  : null,  
init: function() {
var i, j, obj, objName, pName, canProbe;
for (i = 0; i < arguments.length; i += 2) {
if (typeof arguments[i] == "object") {
obj = arguments[i];
if (obj == this) 
continue;
if (!obj || (typeof obj['__profilerId'] != "undefined" && (!obj.prototype
|| obj.prototype.$profilerId != obj.$profilerId))) 
continue;
if (obj.nodeType) 
continue;
obj.$profilerId = this.recurDetect.push(obj) - 1;
objName = arguments[(i + 1)];
if (objName.indexOf('contentDocument') > -1)
alert(1);
for (j in obj) {
pName = objName + "." + j;
canProbe = false;
try {
var tmp  = typeof obj[j];
canProbe = true;
}
catch(e) {}
if (canProbe === false)
continue;
if (typeof obj[j] == "function" && typeof obj[j]['nameSelf'] == "undefined") {
obj[j].nameSelf = pName;
this.pointers['pointer_to_' + pName] = obj[j];
var k, props = {};
for (k in obj[j]) props[k] = obj[j][k];
var _proto = obj[j].prototype ? obj[j].prototype : null;
obj[j] = Profiler_functionTemplate();
for (k in props) obj[j][k] = props[k];
if (_proto) {
obj[j].prototype = _proto;
this.init(_proto, pName + '.prototype');
}
obj[j].nameSelf = pName;
if (!this.hasPointers)
this.hasPointers = true;
}
else if (typeof obj[j] == "object") {
this.init(obj[j], pName);
}
}
}
}
},
recurDetect : [],
uniqueNumber: 0,
wrapFunction: function(func){
var pName = "anonymous" + this.uniqueNumber++;
func.nameSelf = pName;
this.pointers['pointer_to_' + pName] = func;
func = Profiler_functionTemplate();
func.nameSelf = pName;
},
reinit: function() {
this.stackTrace     = {}
this.previousStack  = null;
this.isRunning      = false;
this.startBusy      = this.endBusy = false;
this.startQueue     = [];
this.endQueue       = [];
this.endQueueTimer  = this.startQueueTimer = null;
this.init.apply(this, arguments);
},
isInitialized: function() {
return (this.hasPointers === true);
},
registerStart: function(sName) {
if (this.isRunning) {
if (this.startBusy) {
if (sName) this.startQueue.push(sName);
this.startQueueTimer = setTimeout("jpf.profiler.registerStart()", 200);
}
else {
this.startBusy = true;
clearTimeout(this.startQueueTimer);
var todo = (this.startQueue.length) ? this.startQueue : [];
this.startQueue = [];
if (sName) todo.push(sName);
for (var i = 0; i < todo.length; i++) {
if (!this.stackTrace[todo[i]]) {
this.stackTrace[todo[i]] = {
called      : 1,
fullName    : sName,
internalExec: 0,
executions  : [[new Date(), null]]
};
}
else {
this.stackTrace[todo[i]].called++;
this.stackTrace[todo[i]].executions.push([new Date(), null]);
}
}
this.startBusy = false;
}
}
},
registerEnd: function(sName) {
if (this.isRunning) {
if (!this.stackTrace[sName]) return;
if (this.endBusy) {
if (sName)
this.endQueue.push([sName, arguments.callee.caller.caller
? arguments.callee.caller.caller.nameSelf
: null]);
this.endQueueTimer = setTimeout("jpf.profiler.registerEnd()", 200);
}
else {
this.endBusy = true;
clearTimeout(this.endQueueTimer);
var todo = (this.endQueue.length) ? this.endQueue : [];
this.endQueue = [];
if (sName)
todo.push([sName, arguments.callee.caller.caller
? arguments.callee.caller.caller.nameSelf
: null]);
for (var i = 0; i < todo.length; i++) {
iLength = this.stackTrace[todo[i][0]].executions.length - 1;
if (this.stackTrace[todo[i][0]].executions[iLength][1] == null) {
this.stackTrace[todo[i][0]].executions[iLength][1] = new Date();
if (todo[i][1] && this.stackTrace[todo[i][1]]) {
this.stackTrace[todo[i][1]].internalExec += 
this.stackTrace[todo[i][0]].executions[iLength][1]
- this.stackTrace[todo[i][0]].executions[iLength][0];
}
}
}
this.endBusy = false;
}
}
},
start: function() {
this.reset();
this.isRunning = true;
},
stop: function() {
if (this.isRunning) this.runs++;
this.isRunning = false;
return this.report();
},
reset: function() {
delete this.stackTrace;
this.stackTrace = {};
this.isRunning  = false;
},
report: function() {
var i, j, dur, stack, trace, callsNo;
this.stackTrace.totalCalls = this.stackTrace.totalAvg = this.stackTrace.totalDur = 0;
for (i in this.stackTrace) {
if (!this.stackTrace[i].fullName) continue;
stack = this.stackTrace[i];
callsNo = stack.executions.length;
stack.time = stack.max = 0;
stack.min = Infinity;
for (j = 0; j < stack.executions.length; j++) {
trace = stack.executions[j];
dur   = (trace[1] - trace[0]);
if (isNaN(dur) || !isFinite(dur) || dur < 0) dur = 0;
if (stack.max < dur)
stack.max = dur;
if (stack.min > dur)
stack.min = dur;
else if (stack.min == Infinity && stack.max > 0)
stack.min = stack.max;
stack.time += dur;
}
stack.avg = stack.time / callsNo;
stack.avg = parseFloat(((isNaN(stack.avg) || !isFinite(stack.avg)) ? 0 : stack.avg).toFixed(this.precision));
stack.min = parseFloat(((isNaN(stack.min) || !isFinite(stack.min)) ? 0 : stack.min).toFixed(this.precision));
stack.max = parseFloat(stack.max.toFixed(this.precision));
this.stackTrace.totalCalls += callsNo;
this.stackTrace.totalDur   += stack.time;
}
this.stackTrace.totalDur = parseFloat(this.stackTrace.totalDur.toFixed(this.precision));
this.stackTrace.totalAvg = parseFloat(this.stackTrace.totalDur / this.stackTrace.totalCalls);
this.stackTrace.totalAvg = parseFloat(this.stackTrace.totalAvg.toFixed(this.precision));
return this.buildReport(this.stackTrace);
},
buildReport: function(stackTrace, withContainer) {
if (typeof wihContainer == "undefined") withContainer = true;
var out = withContainer ? ['<div id="profiler_report_' + this.runs + '">'] : [''];
var row0      = '#fff';
var row1      = '#f5f5f5';
var funcColor = '#006400';
var active    = "background: url(./core/debug/resources/tableHeaderSorted.gif) repeat-x top left;";
out.push('<table border="0" style="border: 1px solid #d7d7d7; width: 100%; margin: 0 4px 0 0; padding: 0;" cellpadding="2" cellspacing="0">\
<tr style="\
background:#d9d9d9 url(./core/debug/resources/tableHeader.gif) repeat-x top left;\
height: 16px;\
cursor: hand;\
cursor: pointer;\
">\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_FUNCTIONNAME ? active : ""),
'" rel="3" \
onclick="jpf.debugwin.resortResult(this);" \
title="" width="110">Function</th>\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_CALLS ? active : ""),
'" rel="1" \
onclick="jpf.debugwin.resortResult(this);"\
title="Number of times function was called.">Calls</th>\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_PERCENTAGE ? active : ""),
'" rel="2" \
onclick="jpf.debugwin.resortResult(this);" \
title="Percentage of time spent on this function.">Percentage</th>\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_OWNTIME ? active : ""),
'" rel="8" \
onclick="jpf.debugwin.resortResult(this);" \
title="Time spent in function, excluding nested calls.">Own Time</th>\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_TIME ? active : ""),
'" rel="4" \
onclick="jpf.debugwin.resortResult(this);" \
title="Time spent in function, including nested calls.">Time</th>\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_AVERAGE ? active : ""),
'" rel="5" \
onclick="jpf.debugwin.resortResult(this);" \
title="Average time, including function calls.">Avg</th>\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_MINIMUM ? active : ""),
'" rel="6" \
onclick="jpf.debugwin.resortResult(this);" \
title="Minimum time, including function calls.">Min</th>\
<th style="\
border-right: 1px solid #9c9c9c;\
border-left: 1px solid #d9d9d9;\
border-bottom: 1px solid #9c9c9c;\
padding: 0; margin: 0;',
(this.sortMethod == jpf.profiler.SORT_BY_MAXIMUM ? active : ""),
'" rel="7" \
onclick="jpf.debugwin.resortResult(this);" \
title="Maximum time, including function calls.">Max</th>\
</tr>');
var rowColor, sortedStack = this.sortStack(stackTrace);
for (i = 0; i < sortedStack.length; i++) {
stack = stackTrace[sortedStack[i][0]];
rowColor = (i % 2 == 0) ? row0 : row1;
out.push('<tr style="background-color: ', rowColor, '; padding: 0; margin: 0; ">\
<td class="functionname" style="\
color: ', funcColor, ';\
font-family: Monaco, Courier New;\
font-size: 10px;\
">' + stack.fullName + '</td>\
<td class="callscount">' + stack.executions.length + '</td>\
<td class="duration_percentage">' + stack.perc + '%</td>\
<td class="duration_owntime">' + (stack.time - stack.internalExec) + 'ms</td>\
<td class="duration_time">' + stack.time + 'ms</td>\
<td class="duration_average">' + stack.avg + 'ms</td>\
<td class="duration_min">' + stack.min + 'ms</td>\
<td class="duration_max">' + stack.max + 'ms</td>\
</tr>');
}
out.push('</table>');
if (withContainer)
out.push('</div>');
this.previousStack = stackTrace;
return {
html    : out.join(''),
total   : stackTrace.totalCalls,
duration: stackTrace.totalDur
};
},
sortStack: function(stackTrace) {
var i, stack, aSorted = [];
for (i in stackTrace) {
if (!stackTrace[i].fullName) continue;
stack = stackTrace[i];
stack.perc = 100 - Math.round((Math.abs(stack.time - stackTrace.totalDur) / stackTrace.totalDur) * 100);
switch (this.sortMethod) {
case jpf.profiler.SORT_BY_CALLS :
aSorted.push([i, (stack.executions.length - 1)]);
break;
default:
case jpf.profiler.SORT_BY_PERCENTAGE :
aSorted.push([i, stack.perc]);
break;
case jpf.profiler.SORT_BY_FUNCTIONNAME :
aSorted.push([i, stack.fullName.toLowerCase()]);
break;
case jpf.profiler.SORT_BY_TIME :
aSorted.push([i, stack.time]);
break;
case jpf.profiler.SORT_BY_AVERAGE :
aSorted.push([i, stack.avg]);
break;
case jpf.profiler.SORT_BY_MINIMUM :
aSorted.push([i, stack.min]);
break;
case jpf.profiler.SORT_BY_MAXIMUM :
aSorted.push([i, stack.max]);
break;
case jpf.profiler.SORT_BY_OWNTIME :
aSorted.push([i, (stack.time - stack.internalExec)]);
break;
}
}
return aSorted.sort((this.sortMethod == jpf.profiler.SORT_BY_FUNCTIONNAME)
? this.sortingHelperAsc
: this.sortingHelperDesc);
},
resortStack: function(sortMethod) {
if (this.previousStack) {
this.sortMethod = parseInt(sortMethod);
return this.buildReport(this.previousStack, false);
}
return "";
},
sortingHelperAsc: function(a, b) {
if (a[1] < b[1])
return -1;
else if (a[1] > b[1])
return 1;
else
return 0;
},
sortingHelperDesc: function(a, b) {
if (a[1] > b[1])
return -1;
else if (a[1] < b[1])
return 1;
else
return 0;
},
getFunctionName: function(funcPointer) {
var regexpResult = funcPointer.toString().match(/function(\s*)(\w*)/);
if (regexpResult && regexpResult.length >= 2 && regexpResult[2]) {
return regexpResult[2];
}
return 'anonymous';
}
};
jpf.profiler.SORT_BY_CALLS        = 1;
jpf.profiler.SORT_BY_PERCENTAGE   = 2;
jpf.profiler.SORT_BY_FUNCTIONNAME = 3;
jpf.profiler.SORT_BY_TIME         = 4;
jpf.profiler.SORT_BY_AVERAGE      = 5;
jpf.profiler.SORT_BY_MINIMUM      = 6;
jpf.profiler.SORT_BY_MAXIMUM      = 7;
jpf.profiler.SORT_BY_OWNTIME      = 8;
jpf.profiler.BLACKLIST = {
'jpf.profiler' : 1
};
var Profiler_functionTemplate = function() {
return function() {
jpf.profiler.registerStart(arguments.callee.nameSelf);
var ret = jpf.profiler.pointers['pointer_to_' + arguments.callee.nameSelf].apply(this, arguments);
jpf.profiler.registerEnd(arguments.callee.nameSelf);
return ret;
};
};
jpf.BaseTab = function(){
this.isPaged         = true;
this.$focussable     = jpf.KEYBOARD;
this.canHaveChildren = true;
this.set = function(page, noEvent){
if (noEvent)
return this.$propHandlers["activepage"].call(this, page, noEvent);
return this.setProperty("activepage", page);
}
var inited = false;
var ready  = false;
this.$supportedProperties.push("activepage", "activepagenr");
this.$propHandlers["activepagenr"] =
this.$propHandlers["activepage"]   = function(next, noEvent){
if (!inited) return;
var page, info = {};
var page = this.$findPage(next, info);
if (!page) {
return false;
}
if (page.parentNode != this) {
return false;
}
if (!page.visible || page.disabled) {
return false;
}
if (next.tagName) {
next = info.position;
this.activepage = page.name || next;
}
if (!noEvent) {
var oEvent = {
previous     : this.activepage,
previousId   : this.activepagenr,
previousPage : this.$activepage,
next         : next,
nextId       : info.position,
nextpage     : page
};
if (this.dispatchEvent("beforeswitch", oEvent) === false) {
if (this.hideLoader)
this.hideLoader();
return false;
}
}
this.activepagenr = info.position;
this.setProperty("activepagenr", info.position);
if (this.$activepage)
this.$activepage.$deactivate();
page.$activate();
this.$activepage = page;
if (this.hideLoader) {
if (page.isRendered)
this.hideLoader();
else {
page.addEventListener("afterrender", function(){
this.parentNode.hideLoader();
});
}
}
if (!noEvent) {
if (page.isRendered)
this.dispatchEvent("afterswitch", oEvent);
else {
page.addEventListener("afterrender", function(){
this.parentNode.dispatchEvent("afterswitch", oEvent);
});
}
}
return true;
};
this.getPages = function(){
var r = [], nodes = this.childNodes;
for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].tagName == "page")
r.push(nodes[i]);
}
return r;
};
this.getPage = function(nameOrId){
return !jpf.isNot(nameOrId)
&& this.$findPage(nameOrId) || this.$activepage;
};
this.add = function(caption, name){
var page = jpf.document.createElement("page");
if (name)
page.setAttribute("id", name);
page.setAttribute("caption", caption);
this.appendChild(page);
return page;
};
this.remove = function(nameOrId){
var page = this.$findPage(nameOrId);
if (!page)
return false;
page.removeNode();
return page;
};
this.$domHandlers["removechild"].push(function(jmlNode, doOnlyAdmin){
if (doOnlyAdmin)
return;
if (this.firstChild == jmlNode && jmlNode.nextSibling)
jmlNode.nextSibling.$first();
if (this.lastChild == jmlNode && jmlNode.previousSibling)
jmlNode.previousSibling.$last();
if (this.$activepage == jmlNode) {
if (jmlNode.nextSibling || jmlNode.previousSibling)
this.set(jmlNode.nextSibling || jmlNode.previousSibling);
else {
this.$activepage  =
this.activepage   =
this.activepagenr = null;
}
}
else
this.setScrollerState();
});
this.$domHandlers["insert"].push(function(jmlNode, beforeNode, withinParent){
if (jmlNode.tagName != "page")
return;
if (!beforeNode) {
if (this.lastChild)
this.lastChild.$last(true);
jmlNode.$last();
}
if(!this.firstChild || beforeNode == this.firstChild) {
if (this.firstChild)
this.firstChild.$first(true);
jmlNode.$first();
}
if (this.$activepage) {
var info = {};
this.$findPage(this.$activepage, info);
if (this.activepagenr != info.position) {
if (parseInt(this.activepage) == this.activepage) {
this.activepage = info.position;
this.setProperty("activepage", info.position);
}
this.activepagenr = info.position;
this.setProperty("activepagenr", info.position);
}
}
else if (!this.$activepage)
this.set(jmlNode);
});
this.$findPage = function(nameOrId, info){
var node, nodes = this.childNodes;
for (var t = 0, i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
if (node.tagName == "page" && (t++ == nameOrId
|| (nameOrId.tagName && node || node.name) == nameOrId)) {
if (info)
info.position = t - 1;
return node;
}
}
return null;
};
this.$enable = function(){
var nodes = this.childNodes;
for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].enable)
nodes[i].enable();
}
};
this.$disable = function(){
var nodes = this.childNodes;
for (var i = 0, l = nodes.length; i < l; i++) {
if (nodes[i].disable)
nodes[i].disable();
}
};
this.addEventListener("keydown", function(e){
if (!this.$hasButtons)
return;
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
switch (key) {
case 9:
break;
case 13:
break;
case 32:
break;
case 37:
var pages = this.getPages();
prevPage = this.activepagenr - 1;
while (prevPage >= 0 && !pages[prevPage].visible)
prevPage--;
if (prevPage >= 0)
this.setProperty("activepage", prevPage)
break;
case 39:
var pages = this.getPages();
nextPage = this.activepagenr + 1;
while (nextPage < pages.length && !pages[nextPage].visible)
nextPage++;
if (nextPage < pages.length)
this.setProperty("activepage", nextPage)
break;
default:
return;
}
}, true);
this.inherit(jpf.Presentation); 
this.$loadChildren = function(callback){
var page = false, f = false, i, _self = this;
inited = true;
if (this.$hasButtons) {
this.oButtons = this.$getLayoutNode("main", "buttons", this.oExt);
this.oButtons.setAttribute("id", this.uniqueId + "_buttons");
}
this.oPages = this.$getLayoutNode("main", "pages", this.oExt);
if (this.oInt) {
this.oInt = this.oPages;
page      = true;
var node, nodes = this.childNodes;
for (i = 0; i < nodes.length; i++) {
node = nodes[i];
node.$draw(true);
node.$skinchange();
node.$loadJml();
}
}
else {
this.oInt = this.oPages;
if (this.childNodes.length) {
ready = true;
return;
}
var node, nodes = this.$jml.childNodes;
for (i = 0; i < nodes.length; i++) {
node = nodes[i];
if (node.nodeType != 1) continue;
var tagName = node[jpf.TAGNAME];
if ("page|case".indexOf(tagName) > -1) {
page = new jpf.page(this.oPages, tagName).loadJml(node, this);
if (!f) page.$first(f = page);
if (callback)
callback.call(page, node);
}
else if(tagName == "comment"){
}
else if (callback) {
callback(tagName, node);
}
}
if (page !== f)
page.$last();
}
if (page) {
this.activepage = (this.activepage !== undefined
? this.activepage
: this.activepagenr) || 0;
this.$propHandlers.activepage.call(this, this.activepage);
}
else {
jpf.JmlParser.parseChildren(this.$jml, this.oExt, this);
this.isPages = false;
}
ready = true;
};
};
jpf.page = jpf.component(jpf.NODE_HIDDEN, function(){
this.visible         = true;
this.canHaveChildren = 2;
this.$focussable     = false;
this.setCaption = function(caption){
this.setProperty("caption", caption);
};
this.addEventListener("beforerender", function(){
this.parentNode.dispatchEvent("beforerender", {
page : this
});
});
this.addEventListener("afterrender",  function(){
this.parentNode.dispatchEvent("afterrender", {
page : this
});
});
this.$booleanProperties["visible"]  = true;
this.$booleanProperties["fake"]     = true;
this.$supportedProperties.push("fake", "caption", "icon", "type");
this.$propHandlers["caption"] = function(value){
if (!this.parentNode)
return;
var node = this.parentNode
.$getLayoutNode("button", "caption", this.oButton);
if (node.nodeType == 1)
node.innerHTML = value;
else
node.nodeValue = value;
};
this.$propHandlers["visible"] = function(value){
if (!this.parentNode)
return;
if (value) {
this.oExt.style.display = "";
if (this.parentNode.$hasButtons)
this.oButton.style.display = "block";
if (!this.parentNode.$activepage) {
this.parentNode.set(this);
}
}
else {
if (this.$active) {
this.$deactivate();
var nextPage = this.parentNode.activepagenr + 1;
var pages = this.parentNode.getPages()
var len = pages.length
while (nextPage < len && !pages[nextPage].visible)
nextPage++;
if (nextPage == len) {
nextPage = this.parentNode.activepagenr - 1;
while (nextPage >= 0 && len && !pages[nextPage].visible)
nextPage--;
}
if (nextPage >= 0)
this.parentNode.set(nextPage);
else {
this.parentNode.activepage   =
this.parentNode.activepagenr =
this.parentNode.$activepage = null;
}
}
this.oExt.style.display = "none";
if (this.parentNode.$hasButtons)
this.oButton.style.display = "none";
}
};
this.$propHandlers["fake"] = function(value){
if (this.oExt) {
jpf.removeNode(this.oExt);
this.oInt = this.oExt = null;
}
};
this.$propHandlers["type"] = function(value) {
this.setProperty("fake", true);
this.relPage = this.parentNode.getPage(value);
if (this.$active)
this.$activate();
};
this.$domHandlers["remove"].push(function(doOnlyAdmin){
if (this.oButton) {
if (position & 1)
this.parentNode.$setStyleClass(this.oButton, "", ["firstbtn", "firstcurbtn"]);
if (position & 2)
this.parentNode.$setStyleClass(this.oButton, "", ["lastbtn"]);
}
if (!doOnlyAdmin) {
if (this.oButton)
this.oButton.parentNode.removeChild(this.oButton);
if (this.parentNode.$activepage == this) {
if (this.oButton)
this.parentNode.$setStyleClass(this.oButton, "", ["curbtn"]);
this.parentNode.$setStyleClass(this.oExt, "", ["curpage"]);
}
}
});
this.$domHandlers["reparent"].push(function(beforeNode, pNode, withinParent){
if (!this.$jmlLoaded)
return;
if (!withinParent && this.skinName != pNode.skinName) {
this.$draw();
this.$skinchange();
this.$loadJml();
}
else if (this.oButton && pNode.$hasButtons)
pNode.oButtons.insertBefore(this.oButton,
beforeNode && beforeNode.oButton || null);
});
var position = 0;
this.$first = function(remove){
if (remove) {
position -= 1;
this.parentNode.$setStyleClass(this.oButton, "",
["firstbtn", "firstcurbtn"]);
}
else {
position = position | 1;
this.parentNode.$setStyleClass(this.oButton, "firstbtn"
+ (this.parentNode.$activepage == this ? " firstcurbtn" : ""));
}
};
this.$last = function(remove){
if (remove) {
position -= 2;
this.parentNode.$setStyleClass(this.oButton, "", ["lastbtn"]);
}
else {
position = position | 2;
this.parentNode.$setStyleClass(this.oButton, "lastbtn");
}
};
this.$deactivate = function(fakeOther){
if (this.disabled)
return false;
this.$active = false
if (this.parentNode.$hasButtons) {
if (position > 0)
this.parentNode.$setStyleClass(this.oButton, "", ["firstcurbtn"]);
this.parentNode.$setStyleClass(this.oButton, "", ["curbtn"]);
}
if ((!this.fake || this.relPage) && !fakeOther)
this.parentNode.$setStyleClass(this.fake
? this.relPage.oExt
: this.oExt, "", ["curpage"]);
};
this.$activate = function(){
if (this.disabled)
return false;
if (this.parentNode.$hasButtons) {
if (position > 0)
this.parentNode.$setStyleClass(this.oButton, "firstcurbtn");
this.parentNode.$setStyleClass(this.oButton, "curbtn");
}
if (!this.fake || this.relPage) {
this.parentNode.$setStyleClass(this.fake
? this.relPage.oExt
: this.oExt, "curpage");
if (jpf.layout)
jpf.layout.forceResize(this.fake ? this.relPage.oInt : this.oInt);
}
this.$active = true;
this.$render();
};
this.$skinchange = function(){
if (this.caption)
this.$propHandlers["caption"].call(this, this.caption);
if (this.icon)
this.$propHandlers["icon"].call(this, this.icon);
};
this.$draw = function(isSkinSwitch){
this.skinName = this.parentNode.skinName;
var sType = this.$jml.getAttribute("type")
if (sType) {
this.fake = true;
this.relPage = this.parentNode.getPage(sType) || null;
}
if (this.parentNode.$hasButtons) {
this.parentNode.$getNewContext("button");
var elBtn = this.parentNode.$getLayoutNode("button");
elBtn.setAttribute(this.parentNode.$getOption("main", "select") || "onmousedown",
'jpf.lookup(' + this.parentNode.uniqueId + ').set(jpf.lookup('
+ this.uniqueId + '));if(!jpf.isSafariOld) this.onmouseout()');
elBtn.setAttribute("onmouseover", 'var o = jpf.lookup('
+ this.parentNode.uniqueId + ');if(jpf.lookup(' + this.uniqueId
+ ') != o.$activepage) o.$setStyleClass(this, "over");');
elBtn.setAttribute("onmouseout", 'var o = jpf.lookup('
+ this.parentNode.uniqueId + '); o.$setStyleClass(this, "", ["over"]);');
this.oButton = jpf.xmldb.htmlImport(elBtn, this.parentNode.oButtons);
if (!isSkinSwitch && this.nextSibling && this.nextSibling.oButton)
this.oButton.parentNode.insertBefore(this.oButton, this.nextSibling.oButton);
this.oButton.host = this;
}
if (this.fake)
return;
if (this.oExt)
this.oExt.parentNode.removeChild(this.oExt); 
this.oExt = this.parentNode.$getExternal("page",
this.parentNode.oPages, null, this.$jml);
this.oExt.host = this;
};
this.$loadJml = function(x){
if (this.fake)
return;
if (this.oInt) {
var oInt = this.parentNode
.$getLayoutNode("page", "container", this.oExt);
oInt.setAttribute("id", this.oInt.getAttribute("id"));
this.oInt = jpf.JmlParser.replaceNode(oInt, this.oInt);
}
else {
this.oInt = this.parentNode
.$getLayoutNode("page", "container", this.oExt);
jpf.JmlParser.parseChildren(this.$jml, this.oInt, this, true);
}
};
this.$destroy = function(){
if (this.oButton) {
this.oButton.host = null;
this.oButton = null;
}
};
}).implement(
jpf.DelayedRender
);
jpf.BaseButton = function(pHtmlNode){
var refKeyDown   = 0;     
var refMouseDown = 0;     
var mouseOver    = false; 
var mouseLeft    = false; 
var _self        = this;
this.$propHandlers["background"] = function(value){
var oNode = this.$getLayoutNode("main", "background", this.oExt);
if (!oNode) return;
if (value) {
var b = value.split("|");
this.$background = b.concat(["vertical", 2, 16].slice(b.length - 1));
oNode.style.backgroundImage  = "url(" + this.mediaPath + b[0] + ")";
oNode.style.backgroundRepeat = "no-repeat";
}
else {
oNode.style.backgroundImage  = "";
oNode.style.backgroundRepeat = "";
this.$background = null;
}
}
this.addEventListener("keydown", function(e){
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
switch (key) {
case 13:
if (this.tagName != "checkbox")
this.oExt.onmouseup(e.htmlEvent, true);
break;
case 32:
if (!e.htmlEvent.repeat) { 
refKeyDown++;
return this.$updateState(e.htmlEvent);
} else
return false;
}
}, true);
this.addEventListener("keyup", function(e){
var key = e.keyCode;
switch (key) {
case 32:
refKeyDown--;
if (refKeyDown < 0) {
refKeyDown = 0;
return;
}
if (refKeyDown + refMouseDown == 0 && !this.disabled) {
this.oExt.onmouseup(e, true);
}
return this.$updateState(e);
}
}, true);
this.states = {
"Out"   : 1,
"Over"  : 2,
"Down"  : 3
};
this.$updateState = function(e, strEvent) {
if (this.disabled || e.reset) {
refKeyDown   = 0;
refMouseDown = 0;
mouseOver    = false;
return false;
}
if (refKeyDown > 0
|| (refMouseDown > 0 && mouseOver)
|| (this.isBoolean && this.value)) {
this.$setState ("Down", e, strEvent);
}
else if (mouseOver)
this.$setState ("Over", e, strEvent);
else
this.$setState ("Out", e, strEvent);
}
this.$setupEvents = function() {
this.oExt.onmousedown = function(e) {
if (!e) e = event;
if (_self.$notfromext && (e.srcElement || e.target) == this)
return;
refMouseDown = 1;
mouseLeft    = false;
_self.$updateState(e, "mousedown");
};
this.oExt.onmouseup = function(e, force) {
if (!e) e = event;
if (!force && (!mouseOver || !refMouseDown))
return;
refMouseDown = 0;
_self.$updateState (e, "mouseup");
if (_self.disabled || (e && e.type == "click" && mouseLeft == true))
return false;
if (refMouseDown + _self.refKeyDown)
return false;
if (_self.$clickHandler && _self.$clickHandler())
_self.$updateState (e || event, "click");
else
_self.dispatchEvent("click", {htmlEvent : e});
return false;
};
this.oExt.onmousemove = function(e) {
if (!mouseOver) {
if (!e) e = event;
if (_self.$notfromext && (e.srcElement || e.target) == this)
return;
mouseOver = true;
_self.$updateState(e, "mouseover");
}
};
this.oExt.onmouseout = function(e) {
if(!e) e = event;
var tEl = e.explicitOriginalTarget || e.toElement;
if (this == tEl || jpf.xmldb.isChildOf(this, tEl))
return;
mouseOver    = false;
refMouseDown = 0;
mouseLeft    = true;
_self.$updateState (e || event, "mouseout");
};
if (jpf.hasClickFastBug)
this.oExt.ondblclick = this.oExt.onmouseup;
}
this.$doBgSwitch = function(nr){
if (this.bgswitch && (this.$background[2] >= nr || nr == 4)) {
if (nr == 4)
nr = this.$background[2] + 1;
var strBG = this.$background[1] == "vertical"
? "0 -" + (parseInt(this.$background[3]) * (nr - 1)) + "px"
: "-" + (parseInt(this.$background[3]) * (nr - 1)) + "px 0";
this.$getLayoutNode("main", "background",
this.oExt).style.backgroundPosition = strBG;
}
}
this.$focus = function(){
if (!this.oExt)
return;
this.$setStyleClass(this.oExt, this.baseCSSname + "Focus");
}
this.$blur = function(oBtn){
if (!this.oExt)
return; 
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Focus"]);
if (oBtn)
this.$updateState(oBtn);
}
this.$destroy = function(skinChange){
if (!skinChange) {
this.oExt.onmousedown = this.oExt.onmouseup = this.oExt.onmouseover =
this.oExt.onmouseout = this.oExt.onclick = this.oExt.ondblclick = null;
}
}
}
jpf.BaseList = function(){
this.inherit(jpf.Validation);
this.$focussable = true; 
this.multiselect = true; 
this.$propHandlers["fill"] = function(value){
if (value)
this.loadFillData(this.$jml.getAttribute("fill"));
else
this.clear();
}
this.$keyHandler = function(e){
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
var selHtml  = this.$selected || this.$indicator;
if (!selHtml || this.renaming) 
return;
var selXml = this.indicator || this.selected;
var oExt   = this.oExt;
switch (key) {
case 13:
if (this.$tempsel)
this.selectTemp();
if (this.ctrlselect == "enter")
this.select(this.indicator, true);
this.choose(selHtml);
break;
case 32:
this.select(this.indicator, true);
break;
case 109:
case 46:
if (this.disableremove)
return;
if (this.$tempsel)
this.selectTemp();
this.remove(this.mode != "normal" ? this.indicator : null); 
break;
case 36:
this.select(this.getFirstTraverseNode(), false, shiftKey);
this.oInt.scrollTop = 0;
break;
case 35:
this.select(this.getLastTraverseNode(), false, shiftKey);
this.oInt.scrollTop = this.oInt.scrollHeight;
break;
case 107:
if (this.more)
this.startMore();
break;
case 37:
if (!selXml && !this.$tempsel)
return;
var node = this.$tempsel
? jpf.xmldb.getNode(this.$tempsel)
: selXml;
var margin    = jpf.getBox(jpf.getStyle(selHtml, "margin"));
var items     = Math.floor((oExt.offsetWidth
- (hasScroll ? 15 : 0)) / (selHtml.offsetWidth
+ margin[1] + margin[3]));
var margin = jpf.getBox(jpf.getStyle(selHtml, "margin"));
node = this.getNextTraverseSelected(node, false);
if (node)
this.setTempSelected(node, ctrlKey, shiftKey);
else return;
selHtml = jpf.xmldb.findHTMLNode(node, this);
if (selHtml.offsetTop < oExt.scrollTop) {
oExt.scrollTop = Array.prototype.indexOf.call(this.getTraverseNodes(), node) < items
? 0
: selHtml.offsetTop - margin[0];
}
break;
case 38:
if (!selXml && !this.$tempsel)
return;
var node = this.$tempsel
? jpf.xmldb.getNode(this.$tempsel)
: selXml;
var margin    = jpf.getBox(jpf.getStyle(selHtml, "margin"));
var hasScroll = oExt.scrollHeight > oExt.offsetHeight;
var items     = Math.floor((oExt.offsetWidth
- (hasScroll ? 15 : 0)) / (selHtml.offsetWidth
+ margin[1] + margin[3]));
node = this.getNextTraverseSelected(node, false, items);
if (node)
this.setTempSelected(node, ctrlKey, shiftKey);
else return;
selHtml = jpf.xmldb.findHTMLNode(node, this);
if (selHtml.offsetTop < oExt.scrollTop) {
oExt.scrollTop = Array.prototype.indexOf.call(this.getTraverseNodes(), node) < items
? 0
: selHtml.offsetTop - margin[0];
}
break;
case 39:
if (!selXml && !this.$tempsel)
return;
var node = this.$tempsel
? jpf.xmldb.getNode(this.$tempsel)
: selXml;
var margin = jpf.getBox(jpf.getStyle(selHtml, "margin"));
node = this.getNextTraverseSelected(node, true);
if (node)
this.setTempSelected(node, ctrlKey, shiftKey);
else return;
selHtml = jpf.xmldb.findHTMLNode(node, this);
if (selHtml.offsetTop + selHtml.offsetHeight
> oExt.scrollTop + oExt.offsetHeight)
oExt.scrollTop = selHtml.offsetTop
- oExt.offsetHeight + selHtml.offsetHeight
+ margin[0];
break;
case 40:
if (!selXml && !this.$tempsel)
return;
var node = this.$tempsel
? jpf.xmldb.getNode(this.$tempsel)
: selXml;
var margin    = jpf.getBox(jpf.getStyle(selHtml, "margin"));
var hasScroll = oExt.scrollHeight > oExt.offsetHeight;
var items     = Math.floor((oExt.offsetWidth
- (hasScroll ? 15 : 0)) / (selHtml.offsetWidth
+ margin[1] + margin[3]));
node = this.getNextTraverseSelected(node, true, items);
if (node)
this.setTempSelected(node, ctrlKey, shiftKey);
else return;
selHtml = jpf.xmldb.findHTMLNode(node, this);
if (selHtml.offsetTop + selHtml.offsetHeight
> oExt.scrollTop + oExt.offsetHeight) 
oExt.scrollTop = selHtml.offsetTop
- oExt.offsetHeight + selHtml.offsetHeight
+ margin[0]; 
break;
case 33:
if (!selXml && !this.$tempsel)
return;
var node = this.$tempsel
? jpf.xmldb.getNode(this.$tempsel)
: selXml;
var margin     = jpf.getBox(jpf.getStyle(selHtml, "margin"));
var hasScrollY = oExt.scrollHeight > oExt.offsetHeight;
var hasScrollX = oExt.scrollWidth > oExt.offsetWidth;
var items      = Math.floor((oExt.offsetWidth
- (hasScrollY ? 15 : 0)) / (selHtml.offsetWidth
+ margin[1] + margin[3]));
var lines      = Math.floor((oExt.offsetHeight
- (hasScrollX ? 15 : 0)) / (selHtml.offsetHeight
+ margin[0] + margin[2]));
node = this.getNextTraverseSelected(node, false, items * lines);
if (!node)
node = this.getFirstTraverseNode();
if (node)
this.setTempSelected(node, ctrlKey, shiftKey);
else return;
selHtml = jpf.xmldb.findHTMLNode(node, this);
if (selHtml.offsetTop < oExt.scrollTop) {
oExt.scrollTop = Array.prototype.indexOf.call(this.getTraverseNodes(), node) < items
? 0
: selHtml.offsetTop - margin[0];
}
break;
case 34:
if (!selXml && !this.$tempsel)
return;
var node = this.$tempsel
? jpf.xmldb.getNode(this.$tempsel)
: selXml;
var margin     = jpf.getBox(jpf.getStyle(selHtml, "margin"));
var hasScrollY = oExt.scrollHeight > oExt.offsetHeight;
var hasScrollX = oExt.scrollWidth > oExt.offsetWidth;
var items      = Math.floor((oExt.offsetWidth - (hasScrollY ? 15 : 0))
/ (selHtml.offsetWidth + margin[1] + margin[3]));
var lines      = Math.floor((oExt.offsetHeight - (hasScrollX ? 15 : 0))
/ (selHtml.offsetHeight + margin[0] + margin[2]));
node = this.getNextTraverseSelected(selXml, true, items * lines);
if (!node)
node = this.getLastTraverseNode();
if (node)
this.setTempSelected(node, ctrlKey, shiftKey);
else return;
selHtml = jpf.xmldb.findHTMLNode(node, this);
if (selHtml.offsetTop + selHtml.offsetHeight
> oExt.scrollTop + oExt.offsetHeight) 
oExt.scrollTop = selHtml.offsetTop
- oExt.offsetHeight + selHtml.offsetHeight
+ margin[0]; 
break;
default:
if (key == 65 && ctrlKey) {
this.selectAll();
} else if (this.caption || (this.bindingRules || {})["caption"]) {
if (!this.xmlRoot) return;
if (!this.lookup || new Date().getTime()
- this.lookup.date.getTime() > 300)
this.lookup = {
str  : "",
date : new Date()
};
this.lookup.str += String.fromCharCode(key);
var nodes = this.getTraverseNodes(); 
for (var v, i = 0; i < nodes.length; i++) {
v = this.applyRuleSetOnNode("caption", nodes[i]);
if (v && v.substr(0, this.lookup.str.length)
.toUpperCase() == this.lookup.str) {
if (!this.isSelected(nodes[i])) {
if (this.mode == "check")
this.setIndicator(nodes[i]);
else
this.select(nodes[i]);
}
if (selHtml)
this.oInt.scrollTop = selHtml.offsetTop
- (this.oInt.offsetHeight
- selHtml.offsetHeight) / 2;
return;
}
}
return;
}
break;
};
this.lookup = null;
return false;
};
this.$deInitNode   = function(xmlNode, htmlNode){
if (!htmlNode) return;
htmlNode.parentNode.removeChild(htmlNode);
}
this.$updateNode   = function(xmlNode, htmlNode, noModifier){
var elIcon = this.$getLayoutNode("item", "icon", htmlNode);
if (elIcon) {
if (elIcon.nodeType == 1)
elIcon.style.backgroundImage = "url(" + 
jpf.getAbsolutePath(this.iconPath, this.applyRuleSetOnNode("icon", xmlNode)) + ")";
else
elIcon.nodeValue =jpf.getAbsolutePath(this.iconPath, this.applyRuleSetOnNode("icon", xmlNode));
}
else {
var elImage = this.$getLayoutNode("item", "image", htmlNode);
if (elImage) {
if (elImage.nodeType == 1)
elImage.style.backgroundImage = "url(" + 
jpf.getAbsolutePath(this.mediaPath, this.applyRuleSetOnNode("image", xmlNode)) + ")";
else
elImage.nodeValue = 
jpf.getAbsolutePath(this.mediaPath, this.applyRuleSetOnNode("image", xmlNode));
}
}
var elCaption = this.$getLayoutNode("item", "caption", htmlNode);
if (elCaption) {
if (elCaption.nodeType == 1)
elCaption.innerHTML = this.applyRuleSetOnNode("caption", xmlNode);
else
elCaption.nodeValue = this.applyRuleSetOnNode("caption", xmlNode);
}
htmlNode.title = this.applyRuleSetOnNode("title", xmlNode) || "";
if (!noModifier && this.$updateModifier)
this.$updateModifier(xmlNode, htmlNode);
}
this.$moveNode = function(xmlNode, htmlNode){
if (!htmlNode) return;
var oPHtmlNode = htmlNode.parentNode;
var beforeNode = xmlNode.nextSibling
? jpf.xmldb.findHTMLNode(this.getNextTraverse(xmlNode), this)
: null;
oPHtmlNode.insertBefore(htmlNode, beforeNode);
}
var nodes = [];
this.$add = function(xmlNode, Lid, xmlParentNode, htmlParentNode, beforeNode){
this.$getNewContext("item");
var Item       = this.$getLayoutNode("item");
var elSelect   = this.$getLayoutNode("item", "select");
var elIcon     = this.$getLayoutNode("item", "icon");
var elImage    = this.$getLayoutNode("item", "image");
var elCheckbox = this.$getLayoutNode("item", "checkbox");
var elCaption  = this.$getLayoutNode("item", "caption");
Item.setAttribute("id", Lid);
elSelect.setAttribute("onmouseover", 'jpf.setStyleClass(this, "hover");');
elSelect.setAttribute("onmouseout", 'jpf.setStyleClass(this, "", ["hover"]);');
if (this.hasFeature(__RENAME__)) {
elSelect.setAttribute("ondblclick", 'var o = jpf.lookup(' + this.uniqueId + '); ' +
' o.choose()');
elSelect.setAttribute(this.itemSelectEvent || "onmousedown",
'var o = jpf.lookup(' + this.uniqueId
+ ');if(!o.renaming && o.hasFocus() \
&& jpf.xmldb.isChildOf(o.$selected, this, true) \
&& o.selected) this.dorename = true;\
if (!o.hasFeature(__DRAGDROP__) || !event.ctrlKey)\
o.select(this, event.ctrlKey, event.shiftKey)');
elSelect.setAttribute("onmouseup", 'var o = jpf.lookup(' + this.uniqueId + ');\
if(this.dorename && o.mode == "normal")\
o.startDelayedRename(event); \
this.dorename = false;\
if (o.hasFeature(__DRAGDROP__) && event.ctrlKey)\
o.select(this, event.ctrlKey, event.shiftKey)');
}
else {
elSelect.setAttribute("ondblclick", 'var o = jpf.lookup('
+ this.uniqueId + '); o.choose()');
elSelect.setAttribute(this.itemSelectEvent
|| "onmousedown", 'var o = jpf.lookup(' + this.uniqueId
+ '); o.select(this, event.ctrlKey, event.shiftKey)');
}
if (elIcon) {
if (elIcon.nodeType == 1)
elIcon.setAttribute("style", "background-image:url("
+ jpf.getAbsolutePath(this.iconPath, this.applyRuleSetOnNode("icon", xmlNode))
+ ")");
else
elIcon.nodeValue = jpf.getAbsolutePath(this.iconPath, this.applyRuleSetOnNode("icon", xmlNode));
}
else if (elImage) {
if (elImage.nodeType == 1)
elImage.setAttribute("style", "background-image:url("
+ jpf.getAbsolutePath(this.mediaPath, this.applyRuleSetOnNode("image", xmlNode))
+ ")");
else {
if (jpf.isSafariOld) { 
var p = elImage.ownerElement.parentNode;
var img = p.appendChild(p.ownerDocument.createElement("img"));
img.setAttribute("src", 
jpf.getAbsolutePath(this.mediaPath, this.applyRuleSetOnNode("image", xmlNode)));
}
else {
elImage.nodeValue = 
jpf.getAbsolutePath(this.mediaPath, this.applyRuleSetOnNode("image", xmlNode));
}
}
}
if (elCaption) {
jpf.xmldb.setNodeValue(elCaption,
this.applyRuleSetOnNode("caption", xmlNode));
if (this.lastRule && this.lastRule.getAttribute("parse") == "jml")
this.doJmlParsing = true;
}
Item.setAttribute("title", this.applyRuleSetOnNode("tooltip", xmlNode) || "");
if (this.$addModifier)
this.$addModifier(xmlNode, Item);
if (htmlParentNode)
jpf.xmldb.htmlImport(Item, htmlParentNode, beforeNode);
else
nodes.push(Item);
}
this.$fill = function(){
if (this.more && !this.moreItem) {
this.$getNewContext("item");
var Item      = this.$getLayoutNode("item");
var elCaption = this.$getLayoutNode("item", "caption");
var elSelect  = this.$getLayoutNode("item", "select");
Item.setAttribute("class", "more");
elSelect.setAttribute("onmousedown", 'jpf.lookup(' + this.uniqueId
+ ').$setStyleClass(this, "more_down");');
elSelect.setAttribute("onmouseout", 'jpf.lookup(' + this.uniqueId
+ ').$setStyleClass(this, "", ["more_down"]);');
elSelect.setAttribute("onmouseup", 'jpf.lookup(' + this.uniqueId
+ ').startMore(this)');
if (elCaption)
jpf.xmldb.setNodeValue(elCaption,
this.more.match(/caption:(.*)(;|$)/)[1]);
nodes.push(Item);
}
jpf.xmldb.htmlImport(nodes, this.oInt);
nodes.length = 0;
if (this.doJmlParsing) {
var x = document.createElement("div");
while (this.oExt.childNodes.length)
x.appendChild(this.oExt.childNodes[0]);
Application.loadSubNode(x, this.oExt, null, null, true);
}
if (this.more && !this.moreItem) {
this.moreItem = this.oInt.lastChild;
}
}
var lastAddedMore;
this.startMore = function(o){
this.$setStyleClass(o, "", ["more_down"]);
var xmlNode;
if (!this.actionRules || !this.actionRules["add"])
xmlNode = "<j:item xmlns:j='" + jpf.ns.jml + "' />";
var addedNode = this.add(xmlNode);
this.select(addedNode, null, null, null, null, true);
this.oInt.appendChild(this.moreItem);
var undoLastAction = function(){
this.getActionTracker().undo(this.autoselect ? 2 : 1);
this.removeEventListener("stoprename", undoLastAction);
this.removeEventListener("beforerename", removeSetRenameEvent);
this.removeEventListener("afterrename",  afterRename);
}
var afterRename = function(){
this.removeEventListener("afterrename",  afterRename);
};
var removeSetRenameEvent = function(e){
this.removeEventListener("stoprename", undoLastAction);
this.removeEventListener("beforerename", removeSetRenameEvent);
var xmlNode = this.findXmlNodeByValue(e.args[1]);
if (xmlNode || !e.args[1]) {
this.getActionTracker().undo(this.autoselect ? 2 : 1);
if (!this.isSelected(xmlNode))
this.select(xmlNode);
this.removeEventListener("afterrename", afterRename);
return false;
}
};
this.addEventListener("stoprename",   undoLastAction);
this.addEventListener("beforerename", removeSetRenameEvent);
this.addEventListener("afterrename",  afterRename);
this.startDelayedRename({}, 1);
}
this.$calcSelectRange = function(xmlStartNode, xmlEndNode){
var r = [];
var nodes = this.getTraverseNodes();
for (var f = false, i = 0; i < nodes.length; i++) {
if (nodes[i] == xmlStartNode)
f = true;
if (f)
r.push(nodes[i]);
if (nodes[i] == xmlEndNode)
f = false;
}
if (!r.length || f) {
r = [];
for (var f = false, i = nodes.length - 1; i >= 0; i--) {
if (nodes[i] == xmlStartNode)
f = true;
if (f)
r.push(nodes[i]);
if (nodes[i] == xmlEndNode)
f = false;
}
}
return r;
}
this.$selectDefault = function(XMLRoot){
this.select(this.getTraverseNodes()[0]);
}
this.inherit(jpf.MultiSelect,
jpf.Cache,
jpf.Presentation,
jpf.DataBinding);
this.loadFillData = function(str){
var parts = str.split("-");
var start = parseInt(parts[0]);
var end   = parseInt(parts[1]);
var strData = [];
for (var i = start; i < end + 1; i++) {
strData.push("<item>" + (i + "")
.pad(Math.max(parts[0].length, parts[1].length), "0")
+ "</item>");
}
if (strData.length) {
var sNode = new jpf.smartbinding(null,
jpf.getXmlDom("<smartbindings xmlns='"
+ jpf.ns.jml
+ "'><bindings><caption select='text()' /><value select='text()'/><traverse select='item' /></bindings><model><items>"
+ strData.join("") + "</items></model></smartbindings>")
.documentElement);
jpf.JmlParser.addToSbStack(this.uniqueId, sNode);
}
}
}
jpf.BaseSimple = function(){
this.inherit(jpf.Presentation);
this.inherit(jpf.DataBinding); 
this.getValue = function(){
return this.value;
}
}
jpf["switch"] =
jpf.pages     =
jpf.tab       = jpf.component(jpf.NODE_VISIBLE, function(){
this.$hasButtons = this.tagName == "tab";
this.$focussable = jpf.KEYBOARD; 
this.$draw = function(bSkinChange){
this.oExt = this.$getExternal();
};
this.$loadJml = function(x){
this.switchType = x.getAttribute("switchtype") || "incremental";
this.$loadChildren();
};
this.$destroy = function() {
jpf.layout.removeRule(this.oExt, this.uniqueId + "_tabscroller");
};
}).implement(jpf.BaseTab);
jpf.slideshow = jpf.component(jpf.NODE_VISIBLE, function() {
this.pHtmlNode      = document.body;
this.title          = "number";
this.thumbheight    = 50;
this.loadmsg        = "Loading...";
this.defaultthumb   = null;
this.defaultimage   = null;
this.defaulttitle   = "No description";
this.delay          = 5;
this.scalewidth     = false;
this.$supportedProperties.push("model", "thumbheight", "title", "loadmsg",
"defaultthumb", "defaulttitle",
"defaultimage", "scalewidth");
var _self = this;
var previous, next, current, last;
var lastIHeight = 0,
lastIWidth  = 0,
onuse       = false,
play        = false,
thumbnails  = true,
titleHeight = 30,
vSpace      = 210,
hSpace      = 150;
var lastChoose = [];
this.$positioning = "basic";
this.$booleanProperties["scalewidth"] = true;
this.$propHandlers["thumbheight"] = function(value) {
if (parseInt(value))
this.thumbheight = parseInt(value);
}
this.$propHandlers["delay"] = function(value) {
if (parseInt(value))
this.delay = parseInt(value);
}
var timer5;
var onmousescroll_;
var onkeydown_ = function(e) {
e = (e || event);
var key    = e.keyCode,
temp   = current,
temp_n = _self.getNextTraverse(current),
temp_p = _self.getNextTraverse(current, true);
next     = temp_n ? temp_n : _self.getFirstTraverseNode();
previous = temp_p ? temp_p : _self.getLastTraverseNode();
current  = key == 39 ? next : (key == 37 ? previous : current);
_self.addSelection(key == 39 ? -1 : (key == 37 ? 1 : 0));
if (current !== temp) {
clearInterval(timer5);
timer5 = setInterval(function() {
_self.$refresh();
clearInterval(timer5);
}, 550);
};
return false;
}
this.addEventListener("onkeydown", onkeydown_);
function setSiblings() {
var temp_n = _self.getNextTraverse(current),
temp_p = _self.getNextTraverse(current, true);
next     = temp_n ? temp_n : _self.getFirstTraverseNode();
previous = temp_p ? temp_p : _self.getLastTraverseNode();
}
this.select = function(badge) {
current = badge;
}
this.paint = function() {
current = _self.getFirstTraverseNode();
this.oInt.style.display    = "block";
this.oBody.style.display   = "";
this.oImage.style.display  = "";
this.oImage.src            = "about:blank";
this.oBody.style.height    = this.oBody.style.width      = "100px";
this.oBody.style.marginTop = this.oBody.style.marginLeft = "-50px";
this.oLoading.innerHTML    = this.loadmsg;
this.lastOverflow = document.documentElement.style.overflow;
document.documentElement.style.overflow = "hidden";
if (current) {
this.addSelection();
}
else {
this.oConsole.style.display      = "none";
this.otPrevious.style.visibility = "hidden";
this.otNext.style.visibility     = "hidden";
}
jpf.tween.single(this.oCurtain, {
steps    : 3,
type     : "fade",
from     : 0,
to       : 0.7,
onfinish : function() {
_self.oImage.onload = function() {
last                           = current;
_self.oBody.style.display      = "block";
this.style.display             = "block";
var imgWidth                   = this.offsetWidth || this.width;
var imgHeight                  = this.offsetHeight || this.height;
var b                          = _self.oBody;
var im                         = _self.oImage;
this.style.display             = "none";
_self.oThumbnails.style.height = _self.thumbheight + "px";
if (current)
_self.addSelection(); 
clearTimeout(_self.timer);
var ww = jpf.isIE
? document.documentElement.offsetWidth
: window.innerWidth;
var wh = jpf.isIE
? document.documentElement.offsetHeight
: window.innerHeight;
_self.otBody.style.height = _self.thumbheight + "px";
var bottomPanel = thumbnails 
? Math.max(_self.oBeam.offsetHeight / 2,
_self.thumbheight / 2 + titleHeight / 2
+ _self.oConsole.offsetHeight / 2)
: Math.max(_self.oBeam.offsetHeight / 2,
titleHeight / 2
+ _self.oConsole.offsetHeight / 2);
var diff = jpf.getDiff(b);
var checkWH = [false, false];
jpf.tween.single(b, {
steps    : jpf.isGecko
? 20
: (Math.abs(imgWidth - b.offsetWidth) > 40
? 10
: 3),
anim     : jpf.tween.EASEIN,
type     : "mwidth",
from     : b.offsetWidth - diff[0],
to       : Math.min(imgWidth, ww - hSpace),
onfinish : function() {
checkWH[0] = true;
}
});
jpf.tween.single(b, {
steps    : jpf.isGecko
? 20
: (Math.abs(imgHeight - b.offsetHeight) > 40
? 10
: 3),
anim     : jpf.tween.EASEIN,
type     : "mheight",
margin   : -1*(bottomPanel - 10),
from     : b.offsetHeight - diff[1],
to       : Math.min(imgHeight,
wh - vSpace - bottomPanel),
onfinish : function() {
checkWH[1] = true;
}
});
var timer2;
timer2 = setInterval(function() {
if (checkWH[0] && checkWH[1]) {
if (current)
setSiblings();
_self.oTitle.style.visibility = "visible";
_self.oConsole.style.visibility = "visible";
_self.checkThumbSize();
if (thumbnails) {
_self.oThumbnails.style.visibility = "visible";
}
_self.oMove.style.display = imgWidth < ww - hSpace
&& imgHeight < wh - vSpace - bottomPanel
? "none"
: "block";
_self.oImage.style.cursor = imgWidth < ww - hSpace
&& imgHeight < wh - vSpace - bottomPanel
? "default"
: "move";
im.style.display = "block";
jpf.tween.single(im, {
steps : 5,
type  : "fade",
from  : 0,
to    : 1
});
jpf.tween.single(_self.oTitle, {
steps : 10,
type  : "fade",
from  : 0,
to    : 1
});
clearInterval(timer2);
onuse = false;
_self.addSelection();
if (play) {
_self.$play();
}
}
}, 30);
};
_self.oImage.onerror = function() {
onuse = false;
}
_self.oImage.onabort = function() {
onuse = false;
}
_self.oImage.src = (_self.applyRuleSetOnNode("src", current)
|| _self.defaultimage || "about:blank");
_self.oContent.innerHTML = _self.title == "text"
? _self.applyRuleSetOnNode("title", current)
: (_self.title == "number+text"
? "<b>Image " + (_self.getPos() + 1) + " of "
+ _self.getTraverseNodes().length
+ "</b><br />"
+ (_self.applyRuleSetOnNode("title", current)
|| _self.defaulttitle)
: "Image " + (_self.getPos() + 1)
+ " of " + _self.getTraverseNodes().length);
}
});
};
this.getPos = function() {
return Array.prototype.indexOf.call(_self.getTraverseNodes(), current);
}
this.addSelection = function(move) {
var htmlElement = jpf.xmldb.findHTMLNode(current, this),
ww          = jpf.isIE
? document.documentElement.offsetWidth
: window.innerWidth,
diffp       = jpf.getDiff(_self.otPrevious),
diffn       = jpf.getDiff(_self.otNext),
bp          = parseInt(jpf.getStyle(_self.otPrevious, "width")),
bn          = parseInt(jpf.getStyle(_self.otNext, "width")),
ew          = parseInt(jpf.getStyle(htmlElement, "width"));
if (htmlElement.offsetLeft + ew + 5 >
ww - bp - bn - diffp[0] - diffn[0]) {
if (move) {
if (move > 0)
this.$tPrevious();
else if (move < 0)
this.$tNext();
this.addSelection(move);
}
}
if (this.$selected)
this.$selected.className = "sspictureBox";
if (htmlElement)
htmlElement.className = "sspictureBox ssselected";
this.$selected = htmlElement;
};
this.$Next = function() {
current = next;
this.addSelection(-1);
this.$refresh();
};
this.$Previous = function() {
current = previous;
this.addSelection(1);
this.$refresh();
};
this.$tNext = function() {
_self.otBody.appendChild(_self.otBody.childNodes[0]);
};
this.$tPrevious = function() {
_self.otBody.insertBefore(
_self.otBody.childNodes[_self.otBody.childNodes.length - 1],
_self.otBody.firstChild); 
};
this.showLast = function() {
var timer8;
clearInterval(timer8);
timer8 = setInterval(function() {
if (!onuse) {
if (lastChoose.length) {
current = lastChoose.pop();
lastChoose = [];
_self.$refresh();
}
clearInterval(timer8);
}
}, 100);
}
this.$refresh = function() {
if (onuse) {
lastChoose.push(current);
this.showLast();
return;
}
if (play)
clearInterval(timer7);
var img = _self.oImage;
setSiblings();
onuse = true;
jpf.tween.single(img, {
steps : 3,
type  : "fade",
from  : 1,
to    : 0
});
jpf.tween.single(_self.oTitle, {
steps    : 3,
type     : "fade",
from     : 1,
to       : 0,
onfinish : function() {
_self.oTitle.style.visibility = "hidden";
img.style.left                = "0px";
img.style.top                 = "0px";
var _src = (_self.applyRuleSetOnNode("src", current) || _self.defaultimage || _self.defaultthumb);
var _src_temp = img.src;
img.src = _src;
if (img.src == _src_temp && (jpf.isChrome || jpf.isSafari)) {
onuse = false;
jpf.tween.single(img, {
steps : 3,
type  : "fade",
from  : 0,
to    : 1
});
jpf.tween.single(_self.oTitle, {
steps : 3,
type  : "fade",
from  : 0,
to    : 1
});
_self.oTitle.style.visibility = "visible";
}
_self.oContent.innerHTML = _self.title == "text"
? _self.applyRuleSetOnNode("title", current)
: (_self.title == "number+text"
? "<b>Image " + (_self.getPos() + 1) + " of "
+ _self.getTraverseNodes().length
+ "</b><br />"
+ (_self.applyRuleSetOnNode("title", current)
|| _self.defaulttitle)
: "Image " + (_self.getPos() + 1) + " of "
+ _self.getTraverseNodes().length);
}
});
clearTimeout(_self.timer);
};
var timer7;
this.$play = function() {
timer7 = setInterval(function() {
play = true;
if (onuse) {
return;
}
_self.$Next();
}, _self.delay * 1000);
};
this.$stop = function() {
clearInterval(timer7);
timer7 = null;
play = false;
};
this.$draw = function() {
this.oExt        = this.$getExternal();
this.oInt        = this.$getLayoutNode("main", "container", this.oExt);
this.oCurtain    = this.$getLayoutNode("main", "curtain", this.oExt);
this.oMove       = this.$getLayoutNode("main", "move", this.oExt);
this.oBody       = this.$getLayoutNode("main", "body", this.oExt);
this.oContent    = this.$getLayoutNode("main", "content", this.oExt);
this.oImage      = this.$getLayoutNode("main", "image", this.oExt);
this.oClose      = this.$getLayoutNode("main", "close", this.oExt);
this.oBeam       = this.$getLayoutNode("main", "beam", this.oExt);
this.oTitle      = this.$getLayoutNode("main", "title", this.oExt);
this.oThumbnails = this.$getLayoutNode("main", "thumbnails", this.oExt);
this.otBody      = this.$getLayoutNode("main", "tbody", this.oExt);
this.otPrevious  = this.$getLayoutNode("main", "tprevious", this.oExt);
this.otNext      = this.$getLayoutNode("main", "tnext", this.oExt);
this.oLoading    = this.$getLayoutNode("main", "loading", this.oExt);
this.oEmpty      = this.$getLayoutNode("main", "empty", this.oExt);
this.oConsole    = this.$getLayoutNode("main", "console", this.oExt);
this.oPrevious   = this.$getLayoutNode("main", "previous", this.oExt);
this.oPlay       = this.$getLayoutNode("main", "play", this.oExt);
this.oNext       = this.$getLayoutNode("main", "next", this.oExt);
var rules = "jpf.lookup(" + this.uniqueId + ").$resize()";
jpf.layout.setRules(this.pHtmlNode, this.uniqueId + "_scaling",
rules, true);
this.oPrevious.onclick =
this.oNext.onclick = function(e) {
if ((this.className || "").indexOf("ssprevious") != -1)
_self.$Previous();
else if ((this.className || "").indexOf("ssnext") != -1)
_self.$Next();
};
var timer3;
this.otPrevious.onmousedown = function(e) {
timer3 = setInterval(function() {
_self.$tPrevious();
}, 50);
};
this.otNext.onmousedown = function(e) {
timer3 = setInterval(function() {
_self.$tNext();
}, 50);
};
this.otNext.onmouseover = function(e) {
_self.$setStyleClass(_self.otNext, "ssnhover");
};
this.otPrevious.onmouseover = function(e) {
_self.$setStyleClass(_self.otPrevious, "ssphover");
}
this.otNext.onmouseout = function(e) {
_self.$setStyleClass(_self.otNext, "", ["ssnhover"]);
};
this.otPrevious.onmouseout = function(e) {
_self.$setStyleClass(_self.otPrevious, "", ["ssphover"]);
};
this.oPlay.onclick = function(e) {
if (timer7) {
_self.$stop();
_self.$setStyleClass(_self.oPlay, "", ["ssstop"]);
_self.$setStyleClass(_self.oPlay, "ssplay");
_self.oNext.style.visibility     = "visible";
_self.oPrevious.style.visibility = "visible";
_self.oThumbnails.style.display  = "block";
}
else {
_self.$play();
_self.$setStyleClass(_self.oPlay, "", ["ssplay"]);
_self.$setStyleClass(_self.oPlay, "ssstop");
_self.oNext.style.visibility     = "hidden";
_self.oPrevious.style.visibility = "hidden";
_self.oThumbnails.style.display  = "none";
}
};
document.onmouseup = function(e) {
clearInterval(timer3);
clearInterval(timer);
document.onmousemove = null;
return false;
};
var timer4, SafariChromeFix = false;
onmousescroll_ = function(e) {
if (!_self.xmlRoot || _self.oExt.style.display == "none")
return;
e = e || event;
if (jpf.isChrome || jpf.isSafari) {
SafariChromeFix = SafariChromeFix ? false : true;
if (!SafariChromeFix)
return;
}
var delta  = e.delta;
var temp   = current;
var temp_n = _self.getNextTraverse(current);
var temp_p = _self.getNextTraverse(current, true);
next     = temp_n ? temp_n : _self.getFirstTraverseNode();
previous = temp_p ? temp_p : _self.getLastTraverseNode();
current  = delta < 0 ? next : previous;
_self.addSelection(delta);
if (current !== temp) {
clearInterval(timer4);
timer4 = setInterval(function() {
_self.$refresh();
clearInterval(timer4);
}, 400);
};
return false;
};
jpf.addEventListener("mousescroll", onmousescroll_);
this.oClose.onclick = function() {
_self.hide();
};
var timer;
this.oImage.onmousedown = function(e) {
e = e || event;
var ww = jpf.isIE
? document.documentElement.offsetWidth
: window.innerWidth,
wh = jpf.isIE
? document.documentElement.offsetHeight
: window.innerHeight,
b = _self.oBody,
diff = jpf.getDiff(b),
dx = b.offsetWidth - diff[0] - _self.oImage.offsetWidth,
dy = b.offsetHeight - diff[1] - _self.oImage.offsetHeight;
var t = parseInt(_self.oImage.style.top),
l = parseInt(_self.oImage.style.left);
var cy = e.clientY, cx = e.clientX;
if (e.preventDefault) {
e.preventDefault();
}
document.onmousemove = function(e) {
e = e || event;
if (dx < 0) {
if (l + e.clientX - cx >= dx && l + e.clientX - cx <= 0) {
_self.oImage.style.left = (l + e.clientX - cx) + "px";
}
}
if (dy < 0) {
if (t + e.clientY - cy >= dy && t + e.clientY - cy <= 0) {
_self.oImage.style.top = (t + e.clientY - cy) + "px";
}
}
return false;
};
};
this.oImage.onmouseover = function(e) {
onuse = true;
};
this.oImage.onmouseout = function(e) {
onuse = false;
};
};
this.$xmlUpdate = function() {
};
this.$resize = function() {
var ww        = jpf.isIE
? document.documentElement.offsetWidth
: window.innerWidth,
wh        = jpf.isIE
? document.documentElement.offsetHeight
: window.innerHeight,
b         = _self.oBody,
img       = _self.oImage,
imgWidth  = img.offsetWidth,
imgHeight = img.offsetHeight,
diff      = jpf.getDiff(b),
wt        = Math.min(imgWidth, ww - hSpace);
if (wt > -1) {
b.style.width      = wt + "px";
b.style.marginLeft = -1 * (wt / 2
+ (parseInt(jpf.getStyle(b, "borderLeftWidth")) || diff[0] / 2))
+ "px";
}
var bottomPanel = thumbnails
? Math.max(_self.oBeam.offsetHeight / 2,
_self.thumbheight / 2 + titleHeight / 2)
: Math.max(_self.oBeam.offsetHeight / 2,
titleHeight / 2);
var ht = Math.min(imgHeight, wh - vSpace - bottomPanel);
if (ht > -1) {
b.style.height    = ht + "px";
b.style.marginTop = -1 * (ht / 2
+ (parseInt(jpf.getStyle(b, "borderTopWidth")) || diff[1] / 2)
+ bottomPanel)
+ "px";
}
_self.oMove.style.display =
imgWidth < ww - hSpace && imgHeight < wh - vSpace
? "none"
: "block";
img.style.cursor =
imgWidth < ww - hSpace && imgHeight < wh - vSpace
? "default"
: "move";
img.style.left = "0px";
img.style.top  = "0px";
}
this.clickThumb = function(oThumb) {
current = jpf.xmldb.getNode(oThumb);
this.addSelection();
this.$refresh();
}
this.checkThumbSize = function() {
var nodes = this.getTraverseNodes(), length = nodes.length;
var widthSum = 0;
for (var i = 0, diff, thumb, pictureBox, h, w, bh; i < length; i++) {
pictureBox = this.otBody.childNodes[i];
thumb = this.applyRuleSetOnNode("thumb", nodes[i]);
diff = jpf.getDiff(pictureBox);
bh = this.thumbheight - 10 - diff[1];
img = new Image();
document.body.appendChild(img);
img.src = thumb ? thumb : this.defaultthumb;
if (this.scalewidth) {
h = bh;
if (img.height < bh) {
w = img.width;
}
else {
img.setAttribute("height", bh);
w = img.width;
}
}
else {
h = w = bh;
}
widthSum += w + diff[0]
+ (parseInt(jpf.getStyle(pictureBox, "margin-left")
|| jpf.getStyle(pictureBox, "marginLeft")))
+ (parseInt(jpf.getStyle(pictureBox, "margin-right")
|| jpf.getStyle(pictureBox, "marginRight")));
document.body.removeChild(img);
pictureBox.style.width = w + "px";
}
var thumbDiff = jpf.getDiff(this.otBody);
this.otPrevious.style.visibility = this.otNext.style.visibility =
widthSum < this.oThumbnails.offsetWidth - thumbDiff[0]
? "hidden"
: "visible";
}
this.$load = function(xmlRoot) {
jpf.xmldb.addNodeListener(xmlRoot, this);
var nodes = this.getTraverseNodes(),
length = nodes.length;
for (var i = 0, diff, thumb, pictureBox, h, w, bh; i < length; i++) {
pictureBox = this.otBody.appendChild(document.createElement("div"));
thumb = this.applyRuleSetOnNode("thumb", nodes[i]);
pictureBox.style.backgroundImage = 'url(' + (thumb ? thumb : this.defaultthumb) +  ')';
this.$setStyleClass(pictureBox, "sspictureBox");
diff = jpf.getDiff(pictureBox);
bh = this.thumbheight - 10 - diff[1];
img = new Image();
document.body.appendChild(img);
img.src = thumb ? thumb : this.defaultthumb;
if (this.scalewidth) {
h = bh;
if (img.height < bh) {
w = img.width;
}
else {
img.setAttribute("height", bh);
w = img.width;
}
}
else {
h = w = bh;
}
document.body.removeChild(img);
pictureBox.style.height = h + "px";
pictureBox.style.width = w + "px";
pictureBox.style.marginTop = pictureBox.style.marginBottom = "5px";
jpf.xmldb.nodeConnect(this.documentId, nodes[i], pictureBox, this);
pictureBox.onclick = function(e) {
_self.clickThumb(this);
}
}
if (length != this.length)
this.setProperty("length", length);
this.paint();
}
this.$show = function() {
this.lastOverflow = document.documentElement.style.overflow == "hidden"
? "auto"
: document.documentElement.style.overflow;
document.documentElement.style.overflow = "hidden";
_self.oExt.style.display = "block";
_self.oInt.style.display = "block";
_self.oBody.style.display = "block";
jpf.tween.single(_self.oCurtain, {
steps    : 10, 
type     : "fade",
from     : 0,
to       : 0.7,
onfinish : function() {
}
});
this.$refresh();
}
this.$hide = function () {
document.documentElement.style.overflow = this.lastOverflow;
_self.oExt.style.display = "block";
_self.oBody.style.display = "none";
jpf.tween.single(_self.oCurtain, {
steps    : 10, 
type     : "fade",
from     : 0.7,
to       : 0,
onfinish : function() {
_self.oInt.style.display  = "none";
_self.oExt.style.display  = "none";
_self.oBody.style.display = "none";
}
});
}
this.$destroy = function() {
this.otNext.onmouseover =
this.otPrevious.onmouseover =
this.otNext.onmouseout =
this.otPrevious.onmouseout =
this.oExt.onresize =
this.oImage.onmousedown =
this.otNext.onmousedown =
this.otPrevious.onmousedown =
this.oNext.onclick =
this.oPrevious.onclick = null;
this.removeEventListener("onkeydown", onkeydown_);
this.removeEventListener("mousescroll", onmousescroll_);
this.x = null;
}
this.$loadJml = function(x) {
var nodes = x.childNodes;
jpf.JmlParser.parseChildren(x, null, this);
};
var oEmpty;
this.$setClearMessage = function(msg, className) {
var ww = jpf.isIE
? document.documentElement.offsetWidth
: window.innerWidth;
var bp = parseInt(jpf.getStyle(_self.otPrevious, "width"));
var bn = parseInt(jpf.getStyle(_self.otNext, "width"));
var ew = parseInt(jpf.getStyle(_self.oEmpty, "width"));
oEmpty = this.oCurtain.appendChild(this.oEmpty.cloneNode(true));
jpf.xmldb.setNodeValue(oEmpty, msg || "");
oEmpty.setAttribute("id", "empty" + this.uniqueId);
oEmpty.style.display = "block";
oEmpty.style.left = ((ww - ew) / 2 - bp - bn) + "px";
jpf.setStyleClass(oEmpty, className, ["ssloading", "ssempty", "offline"]);
};
this.$removeClearMessage = function() {
if (!oEmpty)
oEmpty = document.getElementById("empty" + this.uniqueId);
if (oEmpty && oEmpty.parentNode)
oEmpty.parentNode.removeChild(oEmpty);
};
this.$setCurrentFragment = function(fragment) {
this.otBody.appendChild(fragment);
this.dataset = fragment.dataset;
if (!jpf.window.hasFocus(this))
this.blur();
};
this.$getCurrentFragment = function() {
var fragment = document.createDocumentFragment();
while (this.otBody.childNodes.length) {
fragment.appendChild(this.otBody.childNodes[0]);
}
fragment.dataset = this.dataset;
return fragment;
};
}).implement(jpf.Presentation, jpf.DataBinding, jpf.Cache,
jpf.MultiselectBinding);
jpf.template = jpf.component(jpf.NODE_HIDDEN, function(){
this.canHaveChildren = true;
this.$focussable     = false;
var instances = [];
this.render = function(pHtmlNode, forceNewInstance){
if (!instances.length || forceNewInstance) {
instances.push(this.childNodes = []);
}
else {
var nodes = this.childNodes = instances[0];
for (var i = 0, l = nodes.length; i < l; i++) {
pHtmlNode.appendChild(nodes[i].oExt);
}
return nodes;
}
jpf.JmlParser.parseMoreJml(this.$jml, pHtmlNode, this, true);
return this.childNodes;
}
this.detach = function(){
var nodes = this.childNodes;
var p = nodes[0].oExt.parentNode;
if (!p || p.nodeType != 1)
return;
for (var i = 0, l = nodes.length; i < l; i++) {
p.removeChild(nodes[i].oExt);
}
}
this.$loadJml = function(x){
if (this.autoinit) {
jpf.JmlParser.parseChildren(this.$jml, document.body, this);
this.detach();
instances.push(this.childNodes);
}
};
});
jpf.actiontracker = function(parentNode){
jpf.makeClass(this);
var _self       = this;
var stackDone   = [];
var stackUndone = [];
var execStack   = [];
var lastExecStackItem;
this.realtime   = true;
this.undolength = 0;
this.redolength = 0;
this.tagName    = "actiontracker";
if (parentNode)
this.parentNode = parentNode;
this.inherit(jpf.JmlDom); 
this.$booleanProperties = {};
this.$booleanProperties["realtime"] = true;
this.$supportedProperties = ["realtime", "undolength", "redolength", "alias"];
this.$handlePropSet = function(prop, value, force){
switch (prop) {
case "undolength":
this.undolength = stackDone.length;
break;
case "redolength":
this.redolength = stackUndone.length;
break;
case "alias":
jpf.JmlElement.propHandlers.alias.call(this, value);
default:
this[prop] = value;
}
};
this.loadJml = function(x){
this.$jml = x;
var value, a, i, attr = x.attributes;
for (i = 0; i < attr.length; i++) {
a = attr[i];
if (a.nodeName.indexOf("on") == 0) {
this.addEventListener(a.nodeName, new Function(a.nodeValue));
}
else {
value = this.$booleanProperties[a.nodeName]
? jpf.isTrue(a.nodeValue)
: a.nodeValue;
this.setProperty(a.nodeName, value);
}
}
}
this.define = function(action, func){
jpf.actiontracker.actions[action] = func;
};
this.getParent = function(){
return this.parentNode && this.parentNode.getActionTracker
? this.parentNode.getActionTracker(true)
: (jpf.window.$at != this
? jpf.window.$at
: null);
};
this.execute = function(options){
if (this.dispatchEvent("beforechange", options) === false)
return;
var UndoObj = new jpf.UndoData(options, this);
if (options.action)
jpf.actiontracker.actions[options.action](UndoObj, false, this);
UndoObj.id = stackDone.push(UndoObj) - 1;
this.setProperty("undolength", stackDone.length);
this.$addToQueue(UndoObj, false);
stackUndone.length = 0;
this.setProperty("redolength", stackUndone.length);
return UndoObj;
};
this.$addActionGroup = function(done, rpc){
var UndoObj = new jpf.UndoData("group", null, [
jpf.copyArray(done, UndoData), jpf.copyArray(rpc, UndoData)
]);
stackDone.push(UndoObj);
this.setProperty("undolength", stackDone.length);
this.dispatchEvent("afterchange", {action: "group", done: done});
};
this.purge = function(nogrouping, forcegrouping){
if (true) {
if (execStack.length) {
execStack[0].undoObj.saveChange(execStack[0].undo, this);
lastExecStackItem = execStack[execStack.length - 1];
}
}
else if (parent) {
this.reset();
}
};
this.reset = function(){
stackDone.length = stackUndone.length;
this.setProperty("undolength", 0);
this.setProperty("redolength", 0);
this.dispatchEvent("afterchange", {action: "reset"});
};
this.undo = function(id, single, rollback){
change.call(this, id, single, true, rollback);
};
this.redo = function(id, single, rollback){
change.call(this, id, single, false, rollback);
};
function change(id, single, undo, rollback){
var undoStack = undo ? stackDone : stackUndone; 
var redoStack = undo ? stackUndone : stackDone; 
if (!undoStack.length) return;
if (single) {
var UndoObj = undoStack[id];
if (!UndoObj) return;
undoStack.length--;
redoStack.push(UndoObj); 
if (UndoObj.action)
jpf.actiontracker.actions[UndoObj.action](UndoObj, undo, this);
if (!rollback)
this.$addToQueue(UndoObj, undo);
this.setProperty("undolength", stackDone.length);
this.setProperty("redolength", stackUndone.length);
return UndoObj;
}
if (id == -1)
id = undoStack.length;
if (!id)
id = 1;
var i = 0;
while (i < id && undoStack.length > 0) {
if (!undoStack[undoStack.length - 1]) {
undoStack.length--;
stackDone = [];
stackUndone = [];
return false;
}
else {
change.call(this, undoStack.length - 1, true, undo);
i++;
}
}
this.dispatchEvent("afterchange", {
action   : undo ? "undo" : "redo",
rollback : rollback
})
}
this.$receive = function(data, state, extra, UndoObj, callback){
if (state == jpf.TIMEOUT
&& extra.tpModule.retryTimeout(extra, state, this) === true)
return true;
if (state != jpf.SUCCESS) {
if (this.dispatchEvent("actionfail", jpf.extend(extra, {
state   : state,
message : "Could not sent Action RPC request for control "
+ this.name
+ "[" + this.tagName + "] \n\n"
+ extra.message,
bubbles : true
})) === false) {
return true; 
}
if (!jpf.offline.reloading)
this.undo(UndoObj.id, extra.userdata, true);
if (callback)
callback(!extra.userdata);
if (!extra.userdata) {
execStack = [];
throw new Error(jpf.formatErrorString(0, this, 
"Executing action",
"Error sending action to the server:\n"
+ (extra.url ? "Url:" + extra.url + "\n\n" : "") 
+ extra.message));
return;
}
}
else {
this.dispatchEvent("actionsuccess", jpf.extend(extra, {
state   : state,
bubbles : true
}, extra));
UndoObj.processRsbQueue();
if (callback)
callback();
}
this.$queueNext(UndoObj, callback);
};
this.$addToQueue = function(UndoObj, undo, isGroup){
if (execStack.length && !UndoObj.state
&& execStack[execStack.length - 1].undoObj == UndoObj) {
execStack.length--;
UndoObj.clearRsbQueue();
return;
}
if (isGroup) { 
var qItem = execStack.shift();
for (var i = 0; i < UndoObj.length; i++) {
execStack.unshift({
undoObj : UndoObj[i],
undo   : undo
});
}
if (qItem)
execStack.unshift(qItem);
return;
}
var qItem = {
undoObj : UndoObj.preparse(undo, this),
undo   : undo
};
execStack.push(qItem) - 1;
if (execStack.length == 1 && this.realtime)
UndoObj.saveChange(undo, this);
};
this.$queueNext = function(UndoObj, callback){
if (execStack[0].undoObj != UndoObj){
throw new Error(jpf.formatErrorString(0, this, "Executing Next \
action in queue", "The execution stack was corrupted. This is \
a fatal error. The application should be restarted. You will \
lose all your changes. Please contact the administrator."));
}
UndoObj.state = null;
var lastItem = execStack.shift();
if (!execStack[0] || lastItem == lastExecStackItem)
return;
execStack[0].undoObj.saveChange(execStack[0].undo, this, callback);
};
};
jpf.UndoData = function(settings, at){
this.tagName = "UndoData";
this.extra   = {};
jpf.extend(this, settings);
if (at)
this.at = at;
else if (settings && settings.tagName == "UndoData") {
this.args    = settings.args.slice();
this.rsbArgs = settings.rsbArgs.slice();
}
else {
this.selNode = this.selNode || (this.action == "removeNode"
? this.args[0]
: (this.jmlNode
? this.jmlNode.selected
: null));
}
var options, _self = this;
this.getActionXmlNode = function(undo){
if (!this.xmlActionNode)  return false;
if (!undo) return this.xmlActionNode;
var xmlNode = $xmlns(this.xmlActionNode, "undo", jpf.ns.jml)[0];
if (!xmlNode)
xmlNode = this.xmlActionNode;
return xmlNode;
};
this.processRsbQueue = function(){
if (this.rsbModel)
this.rsbModel.rsb.processQueue(this);
};
this.clearRsbQueue = function(){
this.rsbQueue = null;
this.rsbModel = null;
};
this.saveChange = function(undo, at, callback){
if (this.action == "group") {
var rpcNodes = this.args[1];
at.$addToQueue(rpcNodes, undo, true);
return at.$queueNext(this);
}
var xmlActionNode = this.getActionXmlNode(undo);
if (!xmlActionNode || !xmlActionNode.getAttribute("set"))
return at.$queueNext(this);
this.state = undo ? "restoring" : "saving";
options.preparse = false;
jpf.saveData(xmlActionNode.getAttribute("set"), null, options,
function(data, state, extra){
return at.$receive(data, state, extra, _self, callback);
}, {ignoreOffline: true});
};
this.preparse = function(undo, at, multicall){
var xmlActionNode = this.getActionXmlNode(undo);
if (!xmlActionNode || !xmlActionNode.getAttribute("set"))
return this;
options = jpf.extend({
userdata  : jpf.isTrue(xmlActionNode.getAttribute("ignore-fail")),
multicall : multicall,
preparse  : true
}, this.extra);
jpf.saveData(xmlActionNode.getAttribute("set"),
this.selNode || this.xmlNode, options); 
return this;
};
};
jpf.actiontracker.actions = {
"setTextNode" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo)
jpf.xmldb.setTextNode(q[0], q[1], q[2], UndoObj);
else 
jpf.xmldb.setTextNode(q[0], UndoObj.extra.oldValue, q[2]);
},
"setAttribute" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo) {
UndoObj.extra.name = q[1];
UndoObj.extra.oldValue = q[0].getAttribute(q[1]);
jpf.xmldb.setAttribute(q[0], q[1], q[2], q[3], UndoObj);
}
else {
if (!UndoObj.extra.oldValue)
jpf.xmldb.removeAttribute(q[0], q[1]);
else
jpf.xmldb.setAttribute(q[0], q[1], UndoObj.extra.oldValue, q[3]);
}
},
"removeAttribute" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo) {
UndoObj.extra.name = q[1];
UndoObj.extra.oldValue = q[0].getAttribute(q[1]);
jpf.xmldb.removeAttribute(q[0], q[1], q[2], UndoObj);
}
else
jpf.xmldb.setAttribute(q[0], q[1], UndoObj.extra.oldValue, q[2]);
},
"setAttributes" : function(UndoObj, undo){
var prop, q = UndoObj.args;
if (!undo) {
var oldValues = {};
for (prop in q[1]) {
oldValues[prop] = q[0].getAttribute(prop);
q[0].setAttribute(prop, q[1][prop]);
}
UndoObj.extra.oldValues = oldValues;
jpf.xmldb.applyChanges("attribute", q[0], UndoObj);
}
else {
for (prop in UndoObj.oldValues) {
if (!UndoObj.extra.oldValues[prop])
q[0].removeAttribute(prop);
else
q[0].setAttribute(prop, UndoObj.extra.oldValues[prop]);
}
jpf.xmldb.applyChanges("attribute", q[0], UndoObj);
}
},
"replaceNode" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo)
jpf.xmldb.replaceNode(q[0], q[1], q[2], UndoObj);
else
jpf.xmldb.replaceNode(q[1], q[0], q[2]);
},
"addChildNode" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo)
jpf.xmldb.addChildNode(q[0], q[1], q[2], q[3], UndoObj);
else
jpf.xmldb.removeNode(UndoObj.extra.addedNode);
},
"appendChild" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo)
jpf.xmldb.appendChild(q[0], q[1], q[2], q[3], q[4], UndoObj);
else
jpf.xmldb.removeNode(q[1]);
},
"moveNode" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo)
jpf.xmldb.moveNode(q[0], q[1], q[2], q[3], UndoObj);
else
jpf.xmldb.moveNode(UndoObj.extra.pNode, q[1],
UndoObj.extra.beforeNode, q[3]);
},
"removeNode" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo)
jpf.xmldb.removeNode(q[0], q[1], UndoObj);
else
jpf.xmldb.appendChild(UndoObj.extra.pNode,
UndoObj.extra.removedNode, UndoObj.extra.beforeNode);
},
"removeNodeList" : function(UndoObj, undo){
if (undo) {
var d = UndoObj.extra.removeList;
for (var i = d.length - 1; i >= 0; i--) {
jpf.xmldb.appendChild(d[i].pNode,
d[i].removedNode, d[i].beforeNode);
}
}
else
jpf.xmldb.removeNodeList(UndoObj.args, UndoObj);
},
"setUndoObject" : function(UndoObj, undo){
var q = UndoObj.args;
UndoObj.xmlNode = q[0];
},
"group" : function(UndoObj, undo, at){
if (!UndoObj.stackDone) {
var done = UndoObj.args[0];
UndoObj.stackDone = done;
UndoObj.stackUndone = [];
}
at[undo ? "undo" : "redo"](UndoObj.stackDone.length, false,
UndoObj.stackDone, UndoObj.stackUndone);
},
"setValueByXpath" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo) {
if (UndoObj.extra.newNode) {
jpf.xmldb.appendChild(UndoObj.extra.parentNode, UndoObj.extra.newNode);
}
else {
var newNodes = [];
jpf.xmldb.setNodeValue(q[0], q[1], true, {
undoObj  : UndoObj,
xpath    : q[2],
newNodes : newNodes,
forceNew : q[3]
});
UndoObj.extra.newNode = newNodes[0];
}
}
else {
if (UndoObj.extra.newNode) {
UndoObj.extra.parentNode = UndoObj.extra.newNode.parentNode;
jpf.xmldb.removeNode(UndoObj.extra.newNode);
}
else
jpf.xmldb.setNodeValue(UndoObj.extra.appliedNode, UndoObj.extra.oldValue, true);
}
},
"multicall" : function(UndoObj, undo, at){
var prop, q = UndoObj.args;
var dUpdate = jpf.xmldb.delayUpdate;
jpf.xmldb.delayUpdate = true;
if (!undo) {
for(var i = 0; i < q.length; i++) {
if (!q[i].extra)
q[i].extra = {}
jpf.actiontracker.actions[q[i].func](q[i], false, at);
}
}
else {
for (var i = q.length - 1; i >= 0; i--)
jpf.actiontracker.actions[q[i].func](q[i], true, at);
}
jpf.xmldb.delayUpdate = dUpdate;
},
"addRemoveNodes" : function(UndoObj, undo){
var q = UndoObj.args;
if (!undo) {
for (var i = 0; i < q[1].length; i++){
jpf.xmldb.appendChild(q[0], q[1][i],
null, null, null, UndoObj);
}
for (var i = 0; i < q[2].length; i++)
jpf.xmldb.removeNode(q[2][i], null, UndoObj);
}
else {
for (var i = 0; i < q[2].length; i++)
jpf.xmldb.appendChild(q[0], q[2][i]);
for (var i = 0; i < q[1].length; i++)
jpf.xmldb.removeNode(q[1][i]);
}
}
};
jpf.tree = jpf.component(jpf.NODE_VISIBLE, function(){
this.isTreeArch   = true; 
this.$focussable  = true; 
this.multiselect  = false; 
this.bufferselect = true;
this.startClosed  = true;
this.animType     = jpf.tween.NORMAL;
this.animOpenStep = 3;
this.animCloseStep= 1;
this.animSpeed    = 10;
var HAS_CHILD = 1 << 1;
var IS_CLOSED = 1 << 2;
var IS_LAST   = 1 << 3;
var IS_ROOT   = 1 << 4;
var _self     = this;
var treeState = {};
this.nodes    = [];
treeState[0]                               = "";
treeState[HAS_CHILD]                       = "min";
treeState[HAS_CHILD | IS_CLOSED]           = "plus";
treeState[IS_LAST]                         = "last";
treeState[IS_LAST | HAS_CHILD]             = "minlast";
treeState[IS_LAST | HAS_CHILD | IS_CLOSED] = "pluslast";
treeState[IS_ROOT]                         = "root";
this.mode = "normal";
this.$propHandlers["mode"] = function(value){
this.mode = value || "normal";
if ("check|radio".indexOf(this.mode) > -1) {
this.allowdeselect = false;
this.addEventListener("afterrename", $afterRenameMode);
if (this.mode == "check") {
this.autoselect    = false;
this.ctrlselect    = true;
this.bufferselect  = false;
this.multiselect   = true;
this.delayedselect = false;
this.addEventListener("afterselect", function(e){
var pNode = this.getTraverseParent(e.xmlNode);
if (pNode != this.xmlRoot) {
var nodes = this.getTraverseNodes(pNode);
var sel   = e.list;
var count = 0;
for (var i = 0; i < nodes.length; i++) {
if (sel.contains(nodes[i]))
count++;
}
if (count) {
var htmlNode = jpf.xmldb.findHTMLNode(this.getTraverseParent(e.xmlNode), this);
jpf.setStyleClass(htmlNode, count == nodes.length 
? "selected"
: "partial", ["partial", "selected"]);
if (!this.isSelected(pNode))
this.select(pNode, null, null, null, null, true);
}
else {
var htmlNode = jpf.xmldb.findHTMLNode(pNode, this);
jpf.setStyleClass(htmlNode, "", ["partial", "selected"]);
if (this.isSelected(pNode))
this.select(pNode);
}
}
var to = this.isSelected(e.xmlNode);
nodes  = this.getTraverseNodes(e.xmlNode);
if (nodes.length) {
for (var i = 0; i < nodes.length; i++) {
if (to != this.isSelected(nodes[i]))
this.select(nodes[i]);
}
jpf.setStyleClass(jpf.xmldb.findHTMLNode(e.xmlNode, this), 
to ? "selected" : "", ["partial", "selected"]);
}
this.setIndicator(e.xmlNode);
});
}
else if (this.mode == "radio")
this.multiselect = false;
}
else {
this.ctrlselect = false;
this.bufferselect = true;
this.multiselect = false;
this.removeEventListener("afterrename", $afterRenameMode);
}
};
function $afterRenameMode(){
var sb = this.$getMultiBind();
if (!sb) 
return;
sb.$updateSelection();
}
this.openAll    = function(){};
this.closeAll   = function(){};
this.selectPath = function(path){};
this.slideToggle = function(htmlNode, force){
if(this.noCollapse) 
return;
if (!htmlNode)
htmlNode = this.$selected;
var id = htmlNode.getAttribute(jpf.xmldb.htmlIdTag);
while (!id && htmlNode.parentNode)
var id = (htmlNode = htmlNode.parentNode)
.getAttribute(jpf.xmldb.htmlIdTag);
var container = this.$getLayoutNode("item", "container", htmlNode);
if (jpf.getStyle(container, "display") == "block") {
if(force == 1) return;
htmlNode.className = htmlNode.className.replace(/min/, "plus");
this.slideClose(container, jpf.xmldb.getNode(htmlNode));
}
else {
if (force == 2) return;
htmlNode.className = htmlNode.className.replace(/plus/, "min");
this.slideOpen(container, jpf.xmldb.getNode(htmlNode));
}
};
var lastOpened = {};
this.slideOpen = function(container, xmlNode, immediate){
if (!xmlNode)
xmlNode = this.selected;
var htmlNode = jpf.xmldb.findHTMLNode(xmlNode, this);
if (!container)
container = this.$findContainer(htmlNode);
if (this.singleopen) {
var pNode = this.getTraverseParent(xmlNode)
var p = (pNode || this.xmlRoot).getAttribute(jpf.xmldb.xmlIdTag);
if (lastOpened[p] && lastOpened[p][1] != xmlNode 
&& this.getTraverseParent(lastOpened[p][1]) == pNode) 
this.slideToggle(lastOpened[p][0], 2);
lastOpened[p] = [htmlNode, xmlNode];
}
container.style.display = "block";
if (immediate) {
container.style.height = "auto";
return;
}
jpf.tween.single(container, {
type    : 'scrollheight', 
from    : 0, 
to      : container.scrollHeight, 
anim    : this.animType, 
steps   : this.animOpenStep,
interval: this.animSpeed,
onfinish: function(container){
if (xmlNode && _self.hasLoadStatus(xmlNode, "potential")) {
setTimeout(function(){
_self.$extend(xmlNode, container);
});
container.style.height = "auto";
}
else {
container.style.height = "auto";
}
}
});
};
this.slideClose = function(container, xmlNode){
if (this.noCollapse) 
return;
if (!xmlNode)
xmlNode = this.selected;
if (this.singleopen) {
var p = (this.getTraverseParent(xmlNode) || this.xmlRoot)
.getAttribute(jpf.xmldb.xmlIdTag);
lastOpened[p] = null;
}
container.style.height   = container.offsetHeight;
container.style.overflow = "hidden";
jpf.tween.single(container, {
type    : 'scrollheight', 
from    : container.scrollHeight, 
to      : 0, 
anim    : this.animType, 
steps   : this.animCloseStep,
interval: this.animSpeed,
onfinish: function(container, data){
container.style.display = "none";
}
});
};
this.$add = function(xmlNode, Lid, xmlParentNode, htmlParentNode, beforeNode, isLast){
var loadChildren = this.bindingRules && this.bindingRules["insert"] 
? this.getNodeFromRule("insert", xmlNode) 
: false;
var hasTraverseNodes = xmlNode.selectSingleNode(this.traverse) ? true : false;
var hasChildren = loadChildren || hasTraverseNodes;
var startClosed = this.startClosed;
var state       = (hasChildren ? HAS_CHILD : 0) | (startClosed && hasChildren 
|| loadChildren ? IS_CLOSED : 0) | (isLast ? IS_LAST : 0);
var htmlNode  = this.$initNode(xmlNode, state, Lid);
var container = this.$getLayoutNode("item", "container");
if (!startClosed && !this.noCollapse)
container.setAttribute("style", "overflow:visible;height:auto;display:block;");
var removeContainer = (!this.removecontainer || hasChildren);
if (!hasChildren || loadChildren) {
container.setAttribute("style", "display:none;");
}
if (!this.prerender)
var traverseLength = this.getTraverseNodes(xmlNode).length;
if (loadChildren && !this.hasLoadStatus(xmlNode) || hasChildren && !this.prerender && traverseLength > 2)
this.$setLoading(xmlNode, container);
else if (!hasTraverseNodes && this.applyRuleSetOnNode("empty", xmlNode))
this.$setClearMessage(container);
if ((!htmlParentNode || htmlParentNode == this.oInt) 
&& xmlParentNode == this.xmlRoot && !beforeNode) {
this.nodes.push(htmlNode);
if (!jpf.xmldb.isChildOf(htmlNode, container, true) && removeContainer)
this.nodes.push(container);
this.$setStyleClass(htmlNode,  "root");
this.$setStyleClass(container, "root");
}
else {
if (!htmlParentNode) {
htmlParentNode = jpf.xmldb.findHTMLNode(xmlNode.parentNode, this);
htmlParentNode = htmlParentNode 
? this.$getLayoutNode("item", "container", htmlParentNode) 
: this.oInt;
}
if (htmlParentNode == this.oInt) {
this.$setStyleClass(htmlNode,  "root");
this.$setStyleClass(container, "root");
}
if (!beforeNode && this.getNextTraverse(xmlNode))
beforeNode = jpf.xmldb.findHTMLNode(this.getNextTraverse(xmlNode), this);
if (beforeNode && beforeNode.parentNode != htmlParentNode)
beforeNode = null;
if (htmlParentNode.style 
&& this.getTraverseNodes(xmlNode.parentNode).length == 1) 
this.$removeClearMessage(htmlParentNode);
if (htmlParentNode.style) {
jpf.xmldb.htmlImport(htmlNode, htmlParentNode, beforeNode);
if (!jpf.xmldb.isChildOf(htmlNode, container, true) && removeContainer) 
var container = jpf.xmldb.htmlImport(container, 
htmlParentNode, beforeNode);
}
else {
htmlParentNode.insertBefore(htmlNode, beforeNode);
if (!jpf.xmldb.isChildOf(htmlParentNode, container, true) && removeContainer) 
htmlParentNode.insertBefore(container, beforeNode);
}
if (htmlParentNode.style) {
if (!startClosed && this.openOnAdd && htmlParentNode != this.oInt 
&& htmlParentNode.style.display != "block") 
this.slideOpen(htmlParentNode, xmlParentNode, true);
this.$fixItem(xmlParentNode, jpf.xmldb.findHTMLNode(xmlParentNode, this));
if (this.getNextTraverse(xmlNode, true)) { 
this.$fixItem(this.getNextTraverse(xmlNode, true), 
jpf.xmldb.findHTMLNode(this.getNextTraverse(xmlNode, true),
this));
}
}
}
if (this.prerender || traverseLength < 3)
this.$addNodes(xmlNode, container, true); 
return container;
};
this.$fill = function(){
jpf.xmldb.htmlImport(this.nodes, this.oInt);
this.nodes.length = 0;
};
this.$getParentNode = function(htmlNode){
return htmlNode 
? this.$getLayoutNode("item", "container", htmlNode) 
: this.oInt;
};
this.$fixItem = function(xmlNode, htmlNode, isDeleting, oneLeft, noChildren){
if (!htmlNode) return;
if (isDeleting) {
if (prevSib = this.getNextTraverse(xmlNode, true))
this.$fixItem(prevSib, this.getNodeFromCache(prevSib
.getAttribute(jpf.xmldb.xmlIdTag) + "|" 
+ this.uniqueId), null, true);
if (!this.emptyMessage && xmlNode.parentNode.selectNodes(this.traverse).length == 1)
this.$fixItem(xmlNode.parentNode, this.getNodeFromCache(
xmlNode.parentNode.getAttribute(jpf.xmldb.xmlIdTag) 
+ "|" + this.uniqueId), null, false, true); 
}
else {
var container   = this.$getLayoutNode("item", "container", htmlNode);
var hasChildren = false;
if (noChildren) 
hasChildren = false;
else if (xmlNode.selectNodes(this.traverse).length > 0)
hasChildren = true;
else if (this.bindingRules && this.bindingRules["insert"] 
&& this.getNodeFromRule("insert", xmlNode))
hasChildren = true;
else
hasChildren = false;
var isClosed = hasChildren && container.style.display != "block";
var isLast   = this.getNextTraverse(xmlNode, null, oneLeft ? 2 : 1) 
? false 
: true;
var state = (hasChildren ? HAS_CHILD : 0) 
| (isClosed ? IS_CLOSED : 0) | (isLast ? IS_LAST : 0);
this.$setStyleClass(this.$getLayoutNode("item", "class", htmlNode),
treeState[state], ["min", "plus", "last", "minlast", "pluslast"]);
this.$setStyleClass(this.$getLayoutNode("item", "container", htmlNode),
treeState[state], ["min", "plus", "last", "minlast", "pluslast"]);
if (!hasChildren && container)
container.style.display = "none";
if (state & HAS_CHILD) {
var elOpenClose = this.$getLayoutNode("item", "openclose", htmlNode);
if (elOpenClose) {
elOpenClose.onmousedown = new Function('e', "if(!e) e = event;\
if (e.button == 2) return;\
var o = jpf.lookup(" + this.uniqueId + ");\
o.slideToggle(this);\
if (o.onmousedown) o.onmousedown(e, this);\
jpf.cancelBubble(e, o);");
}
var elIcon = this.$getLayoutNode("item", "icon", htmlNode);
if (elIcon) {
elIcon[this.opencloseaction || "ondblclick"]
= new Function("var o = jpf.lookup(" + this.uniqueId + "); " +
" o.slideToggle(this);\
o.choose();");
}
this.$getLayoutNode("item", "select", htmlNode)[this.opencloseaction || "ondblclick"]
= new Function("var o = jpf.lookup(" + this.uniqueId + "); " +
" this.dorename=false;\
o.slideToggle(this);\
o.choose();");
}
}
};
this.$initNode = function(xmlNode, state, Lid){
this.$getNewContext("item");
var hasChildren = state & HAS_CHILD || this.emptyMessage && this.applyRuleSetOnNode("empty", xmlNode);
var oItem = this.$getLayoutNode("item");
oItem.setAttribute("onmouseover",
"var o = jpf.lookup(" + this.uniqueId + ");\
if (o.onmouseover) o.onmouseover(event, this);\
jpf.setStyleClass(this, 'hover');");
oItem.setAttribute("onmouseout",
"var o = jpf.lookup(" + this.uniqueId + ");\
if (o.onmouseout) o.onmouseout(event, this);\
jpf.setStyleClass(this, '', ['hover']);");
oItem.setAttribute("onmousedown",
"var o = jpf.lookup(" + this.uniqueId + ");\
if (o.onmousedown) o.onmousedown(event, this);");
this.$setStyleClass(this.$getLayoutNode("item", "class"), treeState[state]).setAttribute(jpf.xmldb.htmlIdTag, Lid);
this.$setStyleClass(this.$getLayoutNode("item", "container"), treeState[state])
var elOpenClose = this.$getLayoutNode("item", "openclose");
if (hasChildren && elOpenClose) {
elOpenClose.setAttribute(this.opencloseaction || "onmousedown",
"var o = jpf.lookup(" + this.uniqueId + ");\
o.slideToggle(this);\
if (o.onmousedown) o.onmousedown(event, this);\
jpf.cancelBubble(event, o);");
}
var elIcon = this.$getLayoutNode("item", "icon");
if (elIcon) {
if (hasChildren) {
var strFunc = "var o = jpf.lookup(" + this.uniqueId + ");\
o.choose()" + 
"o.slideToggle(this);\
jpf.cancelBubble(event,o);";
if (this.opencloseaction != "onmousedown")
elIcon.setAttribute(this.opencloseaction || "ondblclick", strFunc);
}
elIcon.setAttribute("onmousedown", 
"jpf.lookup(" + this.uniqueId + ").select(this, event.ctrlKey, event.shiftKey);" 
+ (strFunc && this.opencloseaction == "onmousedown" ? strFunc : ""));
if (!elIcon.getAttribute("ondblclick"))
elIcon.setAttribute("ondblclick", "var o = jpf.lookup(" + this.uniqueId + ");\
o.choose();" +
""
);
}
var elSelect = this.$getLayoutNode("item", "select");
if (hasChildren) {
var strFunc2 = "var o = jpf.lookup(" + this.uniqueId + ");\
o.choose();" +
"o.slideToggle(this);\
jpf.cancelBubble(event,o);";
if (this.opencloseaction != "onmousedown")
elSelect.setAttribute(this.opencloseaction || "ondblclick", strFunc2);
}
elSelect.setAttribute("onmousedown",
"var o = jpf.lookup(" + this.uniqueId + ");\
if (!o.renaming && o.hasFocus() \
&& jpf.xmldb.isChildOf(o.$selected, this) && o.selected)\
this.dorename = true;\
o.select(this, event.ctrlKey, event.shiftKey);\
if (o.onmousedown)\
o.onmousedown(event, this);" 
+ (strFunc2 && this.opencloseaction == "onmousedown" ? strFunc2 : ""));
if (!elSelect.getAttribute("ondblclick"))
elSelect.setAttribute("ondblclick", 
"var o = jpf.lookup(" + this.uniqueId + ");" +
"o.choose();");
if (elIcon) {
var iconURL = this.applyRuleSetOnNode("icon", xmlNode);
if (iconURL) {
if (elIcon.tagName.match(/^img$/i))
elIcon.setAttribute("src", this.iconPath + iconURL);
else
elIcon.setAttribute("style", "background-image:url(" + this.iconPath + iconURL + ")");
}
}
var elCaption = this.$getLayoutNode("item", "caption");
if (elCaption) 
jpf.xmldb.setNodeValue(elCaption,
this.applyRuleSetOnNode("caption", xmlNode));
var strTooltip = this.applyRuleSetOnNode("tooltip", xmlNode)
if (strTooltip)
oItem.setAttribute("title", strTooltip);
return oItem;
};
this.$deInitNode = function(xmlNode, htmlNode){
var containerNode = this.$getLayoutNode("item", "container", htmlNode);
var pContainer    = htmlNode.parentNode;
containerNode.parentNode.removeChild(containerNode);
pContainer.removeChild(htmlNode);
if (xmlNode.parentNode != this.xmlRoot)
this.$fixItem(xmlNode, htmlNode, true);
if (this.emptyMessage && !pContainer.childNodes.length)
this.$setClearMessage(pContainer);
this.$fixItem(xmlNode, htmlNode, true);
};
this.$moveNode = function(xmlNode, htmlNode){
if (!self.jpf.debug && !htmlNode) return;
var oPHtmlNode = htmlNode.parentNode;
var pHtmlNode  = jpf.xmldb.findHTMLNode(xmlNode.parentNode, this);
var nSibling = this.getNextTraverse(xmlNode);
var beforeNode = nSibling 
? jpf.xmldb.findHTMLNode(nSibling, this) 
: null;
var pContainer = pHtmlNode 
? this.$getLayoutNode("item", "container", pHtmlNode) 
: this.oInt;
var container  = this.$getLayoutNode("item", "container", htmlNode);
if (pContainer != oPHtmlNode && this.getTraverseNodes(xmlNode.parentNode).length == 1)
this.$removeClearMessage(pContainer);
pContainer.insertBefore(htmlNode, beforeNode);
pContainer.insertBefore(container, beforeNode);
if (this.emptyMessage && !oPHtmlNode.childNodes.length)
this.$setClearMessage(oPHtmlNode);
if (this.openOnAdd && pHtmlNode != this.oInt && pContainer.style.display != "block") 
this.slideOpen(pContainer, pHtmlNode, true);
this.$fixItem(xmlNode, htmlNode);
this.$fixItem(xmlNode.parentNode,
jpf.xmldb.findHTMLNode(xmlNode.parentNode, this));
if (this.getNextTraverse(xmlNode, true)) { 
this.$fixItem(this.getNextTraverse(xmlNode, true),
jpf.xmldb.findHTMLNode(this.getNextTraverse(xmlNode, true),
this));
}
};
this.$updateNode = function(xmlNode, htmlNode){
var elIcon = this.$getLayoutNode("item", "icon", htmlNode);
var iconURL = this.applyRuleSetOnNode("icon", xmlNode);
if (elIcon && iconURL) {
if (elIcon.tagName && elIcon.tagName.match(/^img$/i))
elIcon.src = this.iconPath + iconURL;
else
elIcon.style.backgroundImage = "url(" + this.iconPath + iconURL + ")";
}
var elCaption = this.$getLayoutNode("item", "caption", htmlNode);
if (elCaption) {
if (elCaption.nodeType != 1)
elCaption = elCaption.parentNode;
elCaption.innerHTML = this.applyRuleSetOnNode("caption", xmlNode);
}
var strTooltip = this.applyRuleSetOnNode("tooltip", xmlNode);
if (strTooltip) 
htmlNode.setAttribute("title", strTooltip);
};
this.$setLoading = function(xmlNode, container){
this.$getNewContext("loading");
this.setLoadStatus(xmlNode, "potential");
jpf.xmldb.htmlImport(this.$getLayoutNode("loading"), container);
};
this.$removeLoading = function(htmlNode){
if (!htmlNode) return;
this.$getLayoutNode("item", "container", htmlNode).innerHTML = "";
};
this.$extend = function(xmlNode, container){
var rule       = this.getNodeFromRule("insert", xmlNode, null, true);
var xmlContext = rule 
? xmlNode.selectSingleNode(rule.getAttribute("select") || ".") 
: null;
if (rule && xmlContext) {
this.setLoadStatus(xmlNode, "loading");
if (rule.getAttribute("get")) {
this.getModel().insertFrom(rule.getAttribute("get"), xmlContext, {
insertPoint : xmlContext, 
jmlNode     : this
});
}
else {
var data = this.applyRuleSetOnNode("insert", xmlNode);
if (data)
this.insert(data, xmlContext);
}
}
else if (!this.prerender) {
this.setLoadStatus(xmlNode, "loading");
this.$removeLoading(jpf.xmldb.findHTMLNode(xmlNode, this));
var result = this.$addNodes(xmlNode, container, true); 
xmlUpdateHandler.call(this, {
action  : "insert", 
xmlNode : xmlNode, 
result  : result,
anim    : true
});
}
};
function xmlUpdateHandler(e){
if (e.action == "move-away")
this.$fixItem(e.xmlNode, jpf.xmldb.findHTMLNode(e.xmlNode, this), true);
if (e.action != "insert") return;
var htmlNode = this.getNodeFromCache(e.xmlNode.getAttribute(
jpf.xmldb.xmlIdTag) + "|" + this.uniqueId);
if (!htmlNode) return;
if (this.hasLoadStatus(e.xmlNode, "loading") && e.result.length > 0) {
var container = this.$getLayoutNode("item", "container", htmlNode);
this.slideOpen(container, e.xmlNode, e.anim ? false : true);
}
else
this.$fixItem(e.xmlNode, htmlNode);
if (this.hasLoadStatus(e.xmlNode, "loading"))
this.setLoadStatus(e.xmlNode, "loaded");
}
this.addEventListener("xmlupdate", xmlUpdateHandler);
this.addEventListener("keydown", function(e){
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
var selHtml  = this.$indicator || this.$selected;
if (!selHtml || this.renaming) 
return;
var selXml = this.indicator || this.selected;
var oExt   = this.oExt;
switch (key) {
case 13:
if (this.$tempsel)
this.selectTemp();
if (this.ctrlselect == "enter")
this.select(this.indicator, true);
this.choose(selHtml);
break;
case 32:
this.select(this.indicator, true);
break;
case 46:
if (this.$tempsel)
this.selectTemp();
this.remove(this.mode ? this.indicator : null); 
break;
case 109:
case 37:
if (this.$tempsel)
this.selectTemp();
if (this.indicator.selectSingleNode(this.traverse))
this.slideToggle(this.$indicator || this.$selected, 2)
break;
case 107:
case 39:
if (this.$tempsel)
this.selectTemp();
if (this.indicator.selectSingleNode(this.traverse))
this.slideToggle(this.$indicator || this.$selected, 1)
break;
case 187:
if (shiftKey)
arguments.callee(39);
break;
case 189:
if (!shiftKey)
arguments.callee(37);
break;
case 38:
if (!selXml && !this.$tempsel) 
return;
var node = this.$tempsel 
? jpf.xmldb.getNode(this.$tempsel) 
: selXml;
var sNode = this.getNextTraverse(node, true);
if (sNode) {
var nodes = this.getTraverseNodes(sNode);
do {
var container = this.$getLayoutNode("item", "container",
this.getNodeFromCache(jpf.xmldb.getID(sNode, this)));
if (container && jpf.getStyle(container, "display") == "block" 
&& nodes.length) {
sNode = nodes[nodes.length-1];
}
else 
break;
}
while (sNode && (nodes = this.getTraverseNodes(sNode)).length);
}
else if (this.getTraverseParent(node) == this.xmlRoot) {
this.dispatchEvent("selecttop");
return;
}
else
sNode = this.getTraverseParent(node);
if (sNode && sNode.nodeType == 1)
this.setTempSelected(sNode, ctrlKey, shiftKey);
if (this.$tempsel && this.$tempsel.offsetTop < oExt.scrollTop)
oExt.scrollTop = this.$tempsel.offsetTop;
return false;
break;
case 40:
if (!selXml && !this.$tempsel) 
return;
var node = this.$tempsel 
? jpf.xmldb.getNode(this.$tempsel) 
: selXml;
var sNode = this.getFirstTraverseNode(node);
if (sNode) {
var container = this.$getLayoutNode("item", "container",
this.getNodeFromCache(jpf.xmldb.getID(node, this)));
if (container && jpf.getStyle(container, "display") != "block")
sNode = null;
}
while (!sNode) {
var pNode = this.getTraverseParent(node);
if (!pNode) break;
var i = 0;
var nodes = this.getTraverseNodes(pNode);
while (nodes[i] && nodes[i] != node)
i++;
sNode = nodes[i+1];
node  = pNode;
}
if (sNode && sNode.nodeType == 1)
this.setTempSelected(sNode, ctrlKey, shiftKey);
if (this.$tempsel && this.$tempsel.offsetTop + this.$tempsel.offsetHeight
> oExt.scrollTop + oExt.offsetHeight)
oExt.scrollTop = this.$tempsel.offsetTop 
- oExt.offsetHeight + this.$tempsel.offsetHeight + 10;
return false;
break;
case 33: 
break;
case 34: 
break;
case 36: 
break;
case 35: 
break;
}
}, true);
this.$calcSelectRange = function(xmlStartNode, xmlEndNode){
var r = [];
var nodes = this.getTraverseNodes();
for (var f = false, i = 0; i < nodes.length; i++) {
if (nodes[i] == xmlStartNode)
f = true;
if (f)
r.push(nodes[i]);
if (nodes[i] == xmlEndNode)
f = false;
}
if (!r.length || f) {
r = [];
for (var f = false, i = nodes.length - 1; i >= 0; i--) {
if (nodes[i] == xmlStartNode)
f = true;
if (f)
r.push(nodes[i]);
if (nodes[i] == xmlEndNode)
f = false;
}
}
return r;
}
this.$findContainer = function(htmlNode){
return this.$getLayoutNode("item", "container", htmlNode);
};
this.$selectDefault = function(xmlNode){
if (this.select(this.getFirstTraverseNode(xmlNode)))
return true;
else {
var nodes = this.getTraverseNodes(xmlNode);
for (var i = 0; i < nodes.length; i++) {
if (this.$selectDefault(nodes[i]))
return true;
}
}
};
this.$draw = function(){
if (!this.$jml.getAttribute("skin")) {
var mode = this.$jml.getAttribute("mode");
if (mode == "check")
this.$loadSkin("default:checktree"); 
else if (mode == "radio")
this.$loadSkin("default:radiotree"); 
}
this.oExt = this.$getExternal(); 
this.oInt = this.$getLayoutNode("main", "container", this.oExt);
this.opencloseaction = this.$getOption("main", "openclose");
if (jpf.hasCssUpdateScrollbarBug && !this.mode)
this.$fixScrollBug();
this.oExt.onclick = function(e){
_self.dispatchEvent("click", {htmlEvent : e || event});
};
};
this.$loadJml = function(x){
this.openOnAdd   = !jpf.isFalse(x.getAttribute("openonadd"));
this.startClosed = !jpf.isFalse(this.$jml.getAttribute("startclosed") 
|| this.$getOption("main", "startclosed"));
this.noCollapse  = jpf.isTrue(this.$jml.getAttribute("nocollapse"));
if (this.noCollapse)
this.startClosed = false;
this.singleopen  = jpf.isTrue(this.$jml.getAttribute("singleopen"));
this.prerender   = !jpf.isFalse(this.$jml.getAttribute("prerender"));
if (this.$jml.childNodes.length) 
this.$loadInlineData(this.$jml);
};
this.$destroy = function(){
this.oExt.onclick = null;
jpf.removeNode(this.oDrag);
this.oDrag = null;
};
}).implement(
jpf.Validation, 
jpf.MultiSelect, 
jpf.Cache,
jpf.Presentation, 
jpf.DataBinding
);
jpf.text = jpf.component(jpf.NODE_VISIBLE, function(){
this.$focussable = true; 
this.focussable  = false;
this.$hasStateMessages = true;
var _self        = this;
this.$booleanProperties["scrolldown"] = true;
this.$booleanProperties["secure"]     = true;
this.$supportedProperties.push("behavior", "scrolldown", "secure", "value");
this.$propHandlers["behavior"] = function(value){
this.addOnly = value == "addonly";
}
this.$propHandlers["value"] = function(value){
var cacheObj = false;
if (value)
this.$removeClearMessage();
if (typeof value != "string")
value = value ? value.toString() : "";
if (this.secure) {
value = value.replace(/<a /gi, "<a target='_blank' ")
.replace(/<object.*?\/object>/g, "")
.replace(/<script.*?\/script>/g, "")
.replace(new RegExp("ondblclick|onclick|onmouseover|onmouseout|onmousedown|onmousemove|onkeypress|onkeydown|onkeyup|onchange|onpropertychange", "g"), "ona")
}
if (this.addOnly) {
if (cacheObj)
cacheObj.contents += value;
else
this.oInt.insertAdjacentHTML("beforeend", value);
}
else {
value = value.replace(/\<\?xml version="1\.0" encoding="UTF-16"\?\>/, "");
if (cacheObj)
cacheObj.contents = value;
else
this.oInt.innerHTML = value;
}
if (jpf.cannotSizeIframe && this.oIframe)
this.oIframe.style.width = this.oIframe.offsetWidth + "px";
if (this.scrolldown && this.$scrolldown)
this.oScroll.scrollTop = this.oScroll.scrollHeight;
};
this.setValue = function(value){
this.setProperty("value", value);
};
this.getValue = function(){
return this.oInt.innerHTML;
};
this.addEventListener("keydown", function(e){
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
switch (key) {
case 33:
this.oInt.scrollTop -= this.oInt.offsetHeight;
break;
case 34:
this.oInt.scrollTop += this.oInt.offsetHeight;
break;
case 35:
this.oInt.scrollTop = this.oInt.scrollHeight;
break;
case 36:
this.oInt.scrollTop = 0;
break;
case 38:
this.oInt.scrollTop -= 10;
break;
case 40:
this.oInt.scrollTop += 10;
break;
default:
return;
}
return false;
}, true);
this.$xmlUpdate = function(action, xmlNode, listenNode, UndoObj){
if (this.addOnly && action != "add") return;
if (UndoObj)
UndoObj.xmlNode = this.addOnly ? xmlNode : this.xmlRoot;
if (this.addOnly) {
jpf.xmldb.nodeConnect(this.documentId, xmlNode, null, this);
var cacheObj = this.getNodeFromCache(listenNode.getAttribute("id")
+ "|" + this.uniqueId);
this.$propHandlers["value"].call(this,
this.applyRuleSetOnNode("value", xmlNode) || "");
}
else {
this.$propHandlers["value"].call(this,
this.applyRuleSetOnNode("value", this.xmlRoot) || "");
}
};
this.$load = function(node){
jpf.xmldb.addNodeListener(node, this);
var value = this.applyRuleSetOnNode("value", node);
if (value || typeof value == "string") {
if (this.caching) {
var cacheObj = this.getNodeFromCache(node.getAttribute("id")
+ "|" + this.uniqueId);
if (cacheObj)
cacheObj.contents = value;
}
this.$propHandlers["value"].call(this, value);
}
else
this.$propHandlers["value"].call(this, "");
};
this.$getCurrentFragment = function(){
return {
nodeType : 1,
contents : this.oInt.innerHTML
}
};
this.$setCurrentFragment = function(fragment){
this.oInt.innerHTML = fragment.contents;
if (this.scrolldown)
this.oInt.scrollTop = this.oInt.scrollHeight;
};
this.$findNode = function(cacheNode, id){
id = id.split("\|");
if ((cacheNode ? cacheNode : this).xmlRoot
.selectSingleNode("descendant-or-self::node()[@id='" + (id[0]+"|"+id[1]) + "']"))
return (cacheNode ? cacheNode : null);
return false;
};
this.$setClearMessage = this.$updateClearMessage = function(msg){
this.$setStyleClass(this.oExt, this.baseCSSname + "Empty");
this.oInt.innerHTML = msg;
};
this.$removeClearMessage = function(){
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Empty"]);
this.oInt.innerHTML = ""; 
};
this.$clear = function(){
this.setProperty("value", "");
};
this.caching = false; 
this.$draw = function(){
this.oExt = this.$getExternal();
this.oInt = this.$getLayoutNode("main", "container", this.oExt);
if (jpf.hasCssUpdateScrollbarBug && !jpf.getStyle(this.oInt, "padding"))
this.$fixScrollBug();
this.oScroll = this.oFocus ? this.oFocus.parentNode : this.oInt;
this.$scrolldown = true;
this.oScroll.onscroll = function(){
_self.$scrolldown = this.scrollTop >= this.scrollHeight
- this.offsetHeight + jpf.getVerBorders(this);
}
setInterval(function(){
if (_self.$scrolldown && _self.scrolldown) {
_self.oScroll.scrollTop = _self.oScroll.scrollHeight;
}
}, 60);
if (this.oInt.tagName.toLowerCase() == "iframe") {
if (jpf.isIE) {
this.oIframe = this.oInt;
var iStyle = this.skin.selectSingleNode("iframe_style");
this.oIframe.contentWindow.document.write(
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\
<head>\
<style>" + (iStyle ? iStyle.firstChild.nodeValue : "") + "</style>\
<script>\
document.onkeydown = function(e){\
if (!e) e = event;\
if (" + 'top.jpf.disableF5' + " && e.keyCode == 116) {\
e.keyCode = 0;\
return false;\
}\
}\
</script>\
</head>\
<body oncontextmenu='return false'></body>");
this.oInt = this.oIframe.contentWindow.document.body;
}
else {
var node = document.createElement("div");
this.oExt.parentNode.replaceChild(node, this.oExt);
node.className = this.oExt.className;
this.oExt = this.oInt = node;
}
}
else {
this.oInt.onselectstart = function(e){
(e ? e : event).cancelBubble = true;
}
this.oInt.oncontextmenu = function(e){
if (!this.host.contextmenus)
(e ? e : event).cancelBubble = true;
}
this.oInt.style.cursor = "";
this.oInt.onmouseover = function(e){
if (!self.STATUSBAR) return;
if (!e)
e = event;
if (e.srcElement.tagName.toLowerCase() == "a") {
if (!this.lastStatus)
this.lastStatus = STATUSBAR.getStatus();
STATUSBAR.status("icoLink.gif", e.srcElement.getAttribute("href"));
}
else if (this.lastStatus) {
STATUSBAR.status(this.lastStatus[0], this.lastStatus[1]);
this.lastStatus = false;
}
}
}
};
this.$loadJml = function(x){
this.caching = false;
if (this.emptyMsg && !this.childNodes.length)
this.$setClearMessage(this.emptyMsg);
if (jpf.xmldb.isOnlyChild(x.firstChild, [3,4]))
this.$handlePropSet("value", x.firstChild.nodeValue.trim());
else
jpf.JmlParser.parseChildren(this.$jml, null, this);
};
this.$destroy = function(){
jpf.removeNode(this.oDrag);
this.oDrag   = null;
this.oIframe = null;
this.oScroll.onscoll = null;
this.oScroll = null;
this.oFocus  = null;
};
}).implement(
jpf.Cache,
jpf.BaseSimple
);
jpf.panel = 
jpf.bar   = jpf.component(jpf.NODE_VISIBLE, function(){
this.canHaveChildren = true;
this.$focussable     = false;
this.$domHandlers["reparent"].push(
function(beforeNode, pNode, withinParent){
if (!this.$jmlLoaded)
return;
if (isUsingParentSkin && !withinParent 
&& this.skinName != pNode.skinName
|| !isUsingParentSkin 
&& this.parentNode.$hasLayoutNode 
&& this.parentNode.$hasLayoutNode(this.tagName)) {
isUsingParentSkin = true;
this.$forceSkinChange(this.parentNode.skinName.split(":")[0] + ":" + skinName);
}
});
var isUsingParentSkin = false;
this.$draw = function(){
if (this.parentNode && this.parentNode.$hasLayoutNode 
&& this.parentNode.$hasLayoutNode(this.tagName)) {
isUsingParentSkin = true;
if (this.skinName != this.parentNode.skinName)
this.$loadSkin(this.parentNode.skinName);
}
else if(isUsingParentSkin){
isUsingParentSkin = false;
this.$loadSkin();
}
this.oExt = this.$getExternal(isUsingParentSkin 
? this.tagName 
: "main");
if (this.oDrag) 
this.oDrag.parentNode.removeChild(this.oDrag);
this.oDrag = this.$getLayoutNode(isUsingParentSkin 
? this.tagName 
: "main", "dragger", this.oExt);
};
this.$loadJml = function(x){
var oInt = this.$getLayoutNode(isUsingParentSkin 
? this.tagName 
: "main", "container", this.oExt);
this.oInt = this.oInt
? jpf.JmlParser.replaceNode(oInt, this.oInt)
: jpf.JmlParser.parseChildren(x, oInt, this);
};
this.$skinchange = function(){
}
}).implement(jpf.Presentation);
jpf.model = function(data, caching){
jpf.register(this, "model", jpf.NODE_HIDDEN);
this.data    = data;
this.caching = caching;
this.cache   = {};
var _self    = this;
if (!jpf.globalModel)
jpf.globalModel = this;
this.saveOriginal = true;
this.loadInJmlNode = function(jmlNode, xpath){
if (this.data && xpath) {
if (!jpf.supportNamespaces && (this.data.prefix || this.data.scopeName))
(this.data.nodeType == 9 ? this.data : this.data.ownerDocument)
.setProperty("SelectionNamespaces", "xmlns:"
+ (this.data.prefix || this.data.scopeName) + "='"
+ this.data.namespaceURI + "'");
var xmlNode = this.data.selectSingleNode(xpath);
if (!xmlNode)
jmlNode.$listenRoot = jpf.xmldb.addNodeListener(this.data, jmlNode);
}
else
xmlNode = this.data || null;
jmlNode.load(xmlNode);
};
var jmlNodes = {};
this.register = function(jmlNode, xpath){
if (!jmlNode)
return this;
jmlNodes[jmlNode.uniqueId] = [jmlNode, xpath];
jmlNode.$model = this;
if (this.connect) {
if (this.connect.type)
this.connect.node.connect(jmlNode, null, this.connect.select, this.connect.type);
else
this.connect.node.connect(jmlNode, true, this.connect.select);
}
else {
if (this.data)
this.loadInJmlNode(jmlNode, xpath);
}
return this;
};
this.$register = function(jmlNode, xpath){
jmlNodes[jmlNode.uniqueId][1] = xpath;
};
this.unregister = function(jmlNode){
if(jmlNode.dataParent)
jmlNode.dataParent.parent.disconnect(jmlNode);
delete jmlNodes[jmlNode.uniqueId]
};
this.getXpathByJmlNode = function(jmlNode){
var n = jmlNodes[jmlNode.uniqueId];
if (!n)
return false;
return n[1];
};
this.toString = function(){
var xml = jpf.xmldb.clearConnections(this.data.cloneNode(true));
return this.data
? jpf.formatXml(xml.xml || xml.serialize())
: "Model has no data.";
};
this.getXml = function(){
return this.data
? jpf.xmldb.clearConnections(this.data.cloneNode(true))
: false;
};
this.setQueryValue = function(xpath, value){
var node = jpf.xmldb.createNodeFromXpath(this.data, xpath);
if (!node)
return null;
jpf.xmldb.setTextNode(node, value);
return node;
};
this.queryValue = function(xpath){
return jpf.getXmlValue(this.data, xpath);
};
	
	
this.queryValues = function(xpath){
return jpf.getXmlValue(this.data, xpath);
};
	
this.queryNode = function(xpath){
return this.data.selectSingleNode(xpath)
};
this.queryNodes = function(xpath){
return this.data.selectNodes(xpath);
};
this.appendXml = function(xmlNode){
if (typeof xmlNode == "string")
xmlNode = jpf.getXml(xmlNode);
xmlNode = !model.nodeType 
? model.getXml()
: jpf.xmldb.copyNode(xmlNode);
if(!xmlNode) return;
jpf.xmldb.appendChild(this.data, xmlNode);
};
this.clear = function(){
this.load(null);
doc = null; 
};
this.reset = function(){
this.load(this.copy);
};
this.savePoint = function(){
this.copy = jpf.xmldb.copyNode(this.data);
};
this.reloadJmlNode = function(uniqueId){
if (!this.data)
return;
var xmlNode = jmlNodes[uniqueId][1] ? this.data.selectSingleNode(jmlNodes[uniqueId][1]) : this.data;
jmlNodes[uniqueId][0].load(xmlNode);
};
var bindValidation = [], defSubmission, submissions = {}, loadProcInstr;
this.loadJml = function(x, parentNode){
this.name = x.getAttribute("id");
this.$jml  = x;
this.parentNode = parentNode;
this.inherit(jpf.JmlDom); 
var attr  = x.attributes;
for (var i = 0, l = attr.length; i < l; i++) {
if (attr[i].nodeName.indexOf("on") == 0)
this.addEventListener(attr[i].nodeName, new Function(attr[i].nodeValue));
}
if (x.getAttribute("save-original") == "true")
this.saveOriginal = true;
var oSub;
if (!defSubmission)
defSubmission = x.getAttribute("submission"); 
this.submitType    = x.getAttribute("submittype");
this.useComponents = x.getAttribute("useComponents");
this.session = x.getAttribute("session");
var instanceNode;
loadProcInstr = jpf.parseExpression(x.getAttribute("load") || x.getAttribute("get"));
if (!loadProcInstr) {
var prefix = jpf.findPrefix(x, jpf.ns.jml);
if (!jpf.supportNamespaces)
if (prefix)
(x.nodeType == 9
? x
: x.ownerDocument).setProperty("SelectionNamespaces",
"xmlns:" + prefix + "='" + jpf.ns.jml + "'");
if (prefix)
prefix += ":";
var loadNode = x.selectSingleNode(prefix + "load");
if (loadNode)
loadProcInstr = loadNode.getAttribute("get");
}
if (!oSub && !loadProcInstr) {
var xmlNode = instanceNode || x;
if (xmlNode.childNodes.length && jpf.getNode(xmlNode, [0])) {
this.load((xmlNode.xml || xmlNode.serialize())
.replace(new RegExp("^<" + xmlNode.tagName + "[^>]*>"), "")
.replace(new RegExp("<\/\s*" + xmlNode.tagName + "[^>]*>$"), "")
.replace(/xmlns=\"[^"]*\"/g, ""));
}
}
if (oSub && !this.data && !instanceNode)
this.load("<data />");
if (!jpf.isFalse(x.getAttribute("init")))
this.init();
if (x.getAttribute("remote")) {
this.rsb = jpf.nameserver.get("remote", x.getAttribute("remote"));
this.rsb.models.push(this);
}
return this;
};
this.setConnection = function(jmlNode, type, select){
if (!this.connect)
this.connect = {};
var oldNode = this.connect.node;
this.connect.type   = type;
this.connect.node   = jmlNode;
this.connect.select = select;
for (var uniqueId in jmlNodes) {
if (oldNode)
oldNode.disconnect(jmlNodes[uniqueId][0]);
this.register(jmlNodes[uniqueId][0]);
}
};
this.init = function(callback){
if (this.session) {
this.loadFrom(this.session, null, {isSession: true});
}
else {
if (loadProcInstr)
this.loadFrom(loadProcInstr, null, {callback: callback});
}
};
this.loadFrom = function(instruction, xmlContext, options){
var data      = instruction.split(":");
var instrType = data.shift();
if (instrType.substr(0, 1) == "#") {
instrType = instrType.substr(1);
try {
eval(instrType).test
}
catch (e) {
throw new Error(jpf.formatErrorString(1031, null,
"Model Creation", "Could not find object reference to \
connect databinding: '" + instrType + "'", dataNode))
}
this.setConnection(eval(instrType), data[0] || "select", data[1]);
return this;
}
this.dispatchEvent("beforeretrieve");
jpf.getData(instruction, xmlContext, options, function(data, state, extra){
_self.dispatchEvent("afterretrieve");
if (state != jpf.SUCCESS) {
var oError;
if (extra.tpModule.retryTimeout(extra, state, _self, oError) === true)
return true;
throw oError;
}
if (options && options.isSession && !data) {
if (loadProcInstr)
return _self.loadFrom(loadProcInstr);
}
else {
if (options && options.cancel)
return;
_self.load(data);
_self.dispatchEvent("receive", {
data: data
});
if (options && options.callback)
options.callback.apply(this, arguments);
}
});
return this;
};
var doc;
this.load = function(xmlNode, nocopy){
if (this.dispatchEvent("beforeload") === false)
return false;
if (typeof xmlNode == "string")
xmlNode = jpf.getXmlDom(xmlNode).documentElement;
doc = xmlNode ? xmlNode.ownerDocument : null; 
if (xmlNode) {
jpf.xmldb.nodeConnect(
jpf.xmldb.getXmlDocId(xmlNode, this), xmlNode, null, this);
if (!nocopy && this.saveOriginal)
this.copy = jpf.xmldb.copyNode(xmlNode);
}
this.data = xmlNode;
var uniqueId;
for (uniqueId in jmlNodes) {
if (!jmlNodes[uniqueId] || !jmlNodes[uniqueId][0])
continue;
this.loadInJmlNode(jmlNodes[uniqueId][0], jmlNodes[uniqueId][1]);
}
this.dispatchEvent("afterload");
return this;
};
this.insertFrom = function(instruction, xmlContext, options, callback){
if (!instruction) return false;
this.dispatchEvent("beforeretrieve");
jpf.getData(instruction, xmlContext, options, function(data, state, extra){
_self.dispatchEvent("afterretrieve");
if (state != jpf.SUCCESS) {
var oError;
if (extra.tpModule.retryTimeout(extra, state, 
_self, oError) === true)
return true;
throw oError;
}
if (typeof options.insertPoint == "string")
insertPoint = _self.data.selectSingleNode(options.insertPoint);
(options.jmlNode || _self).insert(data, options.insertPoint, jpf.extend({
clearContents: jpf.isTrue(extra.userdata[1])
}, options));
if (callback)
callback.call(this, extra.data);
});
};
this.insert = function(XMLRoot, parentXMLNode, options, jmlNode){
if (typeof XMLRoot != "object")
XMLRoot = jpf.getXmlDom(XMLRoot).documentElement;
if (!parentXMLNode)
parentXMLNode = this.data;
var newNode = jpf.xmldb.integrate(XMLRoot, parentXMLNode,
jpf.extend({copyAttributes: true}, options));
jpf.xmldb.applyChanges("insert", parentXMLNode);
return XMLRoot;
};
this.getJsonObject = function(){
var data = {};
for (var p in this.elements) {
var name = this.elements[p].$jml.getAttribute("name") || this.elements[p].name;
if (name)
data[name] = this.elements[p].getValue();
}
return data;
};
this.getCgiString = function(){
var uniqueId, k, sel, oJmlNode, name, value, str = [];
for (uniqueId in jmlNodes) {
oJmlNode = jmlNodes[uniqueId][0];
if (oJmlNode.disabled || !oJmlNode.change && !oJmlNode.hasFeature(__MULTISELECT__))
continue;
if (oJmlNode.tagName == "MultiBinding")
oJmlNode = oJmlNode.getHost();
if (oJmlNode.multiselect) {
sel = oJmlNode.getSelection();
for (k = 0; k < sel.length; k++) {
name = oJmlNode.$jml.getAttribute("name");
if (!name && oJmlNode.$jml.getAttribute("ref"))
name = oJmlNode.$jml.getAttribute("ref").replace(/[\/\]\[@]/g, "_");
if (!name)
name = sel[k].tagName;
if (!name.match(/\]$/))
name += "[]";
value = oJmlNode.applyRuleSetOnNode("value", sel[k])
|| oJmlNode.applyRuleSetOnNode("caption", sel[k]);
if (value)
str.push(name + "=" + encodeURIComponent(value));
}
}
else {
name = oJmlNode.$jml.getAttribute("name")
|| oJmlNode.$jml.getAttribute("id");
if (!name && oJmlNode.$jml.getAttribute("ref"))
name = oJmlNode.$jml.getAttribute("ref").replace(/[\/\]\[@]/g, "_");
if (!name && oJmlNode.xmlRoot)
name = oJmlNode.xmlRoot.tagName;
if (!name)
continue;
value = oJmlNode.getValue();
if (value)
str.push(name + "=" + encodeURIComponent(value));
}
}
return str.join("&");
};
this.submit = function(instruction, xmlNode, type, useComponents, xSelectSubTree){
if (!instruction && !defSubmission)
return false;
if (!xmlNode)
xmlNode = this.data;
if (!instruction && typeof defSubmission == "string")
instruction = defSubmission;
var sub;
if (submissions[instruction] || !instruction && defSubmission) {
sub = submissions[instruction] || defSubmission;
useComponents  = false;
type           = sub.getAttribute("method")
.match(/^(?:urlencoded-post|get)$/) ? "native" : "xml";
xSelectSubTree = sub.getAttribute("ref") || "/";
instruction    = (sub.getAttribute("method")
.match(/post/) ? "url.post:" : "url:") + sub.getAttribute("action");
var file       = sub.getAttribute("action");
}
else
if (instruction) {
if (!type)
type = this.submitType || "native";
if (!useComponents)
useComponents = this.useComponents;
}
else {
}
if (this.dispatchEvent("beforesubmit", {
instruction: instruction
}) === false)
return false;
var model = this;
function cbFunc(data, state, extra){
if (state == jpf.TIMEOUT && extra.retries < jpf.maxHttpRetries)
return extra.tpModule.retry(extra.id);
else
if (state != jpf.SUCCESS) {
model.dispatchEvent("submiterror", extra);
}
else {
model.dispatchEvent("submitsuccess", jpf.extend({
data: data
}, extra));
}
}
if (type == "array" || type == "xml") {
var data = type == "array"
? this.getJsonObject()
: jpf.xmldb.serializeNode(xmlNode);
jpf.saveData(instruction, xmlNode, {args : [data]}, cbFunc);
}
else {
var data = useComponents
? this.getCgiString()
: jpf.xmldb.convertXml(jpf.xmldb.copyNode(xmlNode), type != "native" ? type : "cgivars");
if (instruction.match(/^rpc\:/)) {
rpc = rpc.split(".");
var oRpc = self[rpc[0]];
oRpc.callWithString(rpc[1], data, cbFunc);
}
else {
if (instruction.match(/^url/))
instruction += (instruction.match(/\?/) ? "&" : "?") + data;
jpf.saveData(instruction, xmlNode, null, cbFunc);
}
}
this.dispatchEvent("aftersubmit");
};
this.$destroy = function(){
if (this.session && this.data)
jpf.saveData(this.session, this.getXml());
};
};
jpf.fieldset = 
jpf.frame    = jpf.component(jpf.NODE_VISIBLE, function(){
this.canHaveChildren = true;
this.$focussable     = false;
this.$supportedProperties.push("caption");
this.$propHandlers["caption"] = function(value){
if (this.oCaption) 
this.oCaption.nodeValue = value;
};
this.setTitle = function(value){
this.setProperty("title", value);
};
this.$draw = function(){
this.oExt     = this.$getExternal(); 
this.oCaption   = this.$getLayoutNode("main", "caption", this.oExt);
var oInt      = this.$getLayoutNode("main", "container", this.oExt);
this.oInt = this.oInt 
? jpf.JmlParser.replaceNode(oInt, this.oInt) 
: jpf.JmlParser.parseChildren(this.$jml, oInt, this);
};
this.$loadJml = function(x){
};
}).implement(jpf.Presentation);
jpf.smartbinding = function(name, xmlNode, parentNode){
this.xmlbindings = null;
this.xmlactions  = null;
this.xmldragdrop = null;
this.bindings    = null;
this.actions     = null;
this.dragdrop    = null;
this.jmlNodes    = {};
this.$modelXpath = {};
this.name        = name;
var _self        = this;
this.tagName    = "smartbinding";
this.nodeFunc   = jpf.NODE_HIDDEN;
this.parentNode = parentNode;
jpf.inherit.call(this, jpf.JmlDom); 
var parts        = {
bindings: 'loadBindings',
actions : 'loadActions',
dragdrop: 'loadDragDrop'
};
this.initialize = function(jmlNode, part){
this.jmlNodes[jmlNode.uniqueId] = jmlNode;
if (part)
return jmlNode[parts[part]](this[part], this["xml" + part]);
if (jmlNode.$jml && this.name) 
jmlNode.$jml.setAttribute("smartbinding", this.name);
for (part in parts) {
if (typeof parts[part] != "string") continue;
if (!this[part]) continue;
jmlNode[parts[part]](this[part], this["xml" + part]);
}
if (this.$model) {
this.$model.register(jmlNode, this.$modelXpath[jmlNode.getHost
? jmlNode.getHost().uniqueId
: jmlNode.uniqueId] || this.modelBaseXpath); 
}
else if (jmlNode.$model && (jmlNode.smartBinding && jmlNode.smartBinding != this))
jmlNode.$model.reloadJmlNode(jmlNode.uniqueId);
return this;
};
this.deinitialize = function(jmlNode){
this.jmlNodes[jmlNode.uniqueId] = null;
delete this.jmlNodes[jmlNode.uniqueId];
for (part in parts) {
if (typeof parts[part] != "string") continue;
if (!this[part]) continue;
jmlNode["un" + parts[part]]();
}
if (this.model)
this.model.unregister(jmlNode);
};
var timer, queue = {};
this.markForUpdate = function(jmlNode, part){
(queue[jmlNode.uniqueId] 
|| (queue[jmlNode.uniqueId] = {}))[part || "all"] = jmlNode;
if (!this.jmlNodes[jmlNode.uniqueId])
this.jmlNodes[jmlNode.uniqueId] = jmlNode;
if (!timer) {
timer = setTimeout(function(){
_self.$updateMarkedItems();
});
}
return this;
};
this.$isMarkedForUpdate = function(jmlNode){
return queue[jmlNode.uniqueId] ? true : false;
}
this.$updateMarkedItems = function(){
clearTimeout(timer);
var jmlNode, model, q = queue; timer = null; queue = {}
for (var id in q) {
if (!this.jmlNodes[id])
continue;
if (q[id]["all"]) {
jmlNode = q[id]["all"];
for (part in parts) {
if (!this[part]) continue;
jmlNode[parts[part]](this[part], this["xml" + part]);
}
model = jmlNode.getModel();
if (model)
model.reloadJmlNode(jmlNode.uniqueId);
else
jmlNode.reload();
}
else {
for (part in q[id]) {
jmlNode = q[id][part];
if (part == "model") {
jmlNode.getModel().reloadJmlNode(jmlNode.uniqueId);
continue;
}
jmlNode[parts[part]](this[part], this["xml" + part]);
if (part == "bindings")
jmlNode.reload();
}
}
}
};
this.addBindRule = function(xmlNode, jmlParent){
var str = xmlNode[jpf.TAGNAME] == "ref"
? jmlParent ? jmlParent.mainBind : "value"
: xmlNode.tagName;
if (!this.bindings)
this.bindings = {};
if (!this.bindings[str])
this.bindings[str] = [xmlNode];
else
this.bindings[str].push(xmlNode);
};
this.addBindings = function(rules){
this.bindings    = rules;
this.xmlbindings = xmlNode;
if (!jpf.isParsing) {
}
if (!jpf.isParsing)
this.markForUpdate(null, "bindings");
};
this.addActionRule = function(xmlNode){
var str = xmlNode[jpf.TAGNAME] == "action" ? "Change" : xmlNode.tagName;
if (!this.actions)
this.actions = {};
if (!this.actions[str])
this.actions[str] = [xmlNode];
else
this.actions[str].push(xmlNode);
};
this.addActions = function(rules, xmlNode){
this.actions    = rules;
this.xmlactions = xmlNode;
if (!jpf.isParsing)
this.markForUpdate(null, "bindings");
};
this.addDropRule = 
this.addDragRule = function(xmlNode){
if (!this.dragdrop)
this.dragdrop = {};
if (!this.dragdrop[xmlNode[jpf.TAGNAME]])
this.dragdrop[xmlNode[jpf.TAGNAME]] = [xmlNode];
else
this.dragdrop[xmlNode[jpf.TAGNAME]].push(xmlNode);
};
this.addDragDrop = function(rules, xmlNode){
this.dragdrop    = rules;
this.xmldragdrop = xmlNode;
if (!jpf.isParsing)
this.markForUpdate(null, "dragdrop");
};
this.setModel = function(model, xpath){
if (typeof model == "string")
model = jpf.nameserver.get("model", model);
this.model          = jpf.nameserver.register("model", this.name, model);
this.modelBaseXpath = xpath;
for (var uniqueId in this.jmlNodes) {
this.model.unregister(this.jmlNodes[uniqueId]);
this.model.register(jmlNode, this.$modelXpath[jmlNode.getHost
? jmlNode.getHost().uniqueId
: jmlNode.uniqueId] || this.modelBaseXpath); 
}
};
this.load = function(xmlNode){
this.setModel(new jpf.model().load(xmlNode));
};
var known = {
actions  : "addActions",
bindings : "addBindings",
dragdrop : "addDragDrop"
};
this.loadJml = function(xmlNode){
this.name = xmlNode.getAttribute("id");
this.$jml  = xmlNode;
var name, attr = xmlNode.attributes, l = attr.length;
for (var i = 0; i < l; i++) {
name = attr[i].nodeName;
if (name == "model")
continue;
if (!known[name])
continue;
var cNode = jpf.nameserver.get(name, attr[i].nodeValue);
this[known[name]](jpf.getRules(cNode), cNode);
}
var data_node, nodes = xmlNode.childNodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1) continue;
switch (nodes[i][jpf.TAGNAME]) {
case "model":
data_node = nodes[i];
break;
case "bindings":
this.addBindings(jpf.getRules(nodes[i]), nodes[i]);
break;
case "actions":
this.addActions(jpf.getRules(nodes[i]), nodes[i]);
break;
case "dragdrop":
this.addDragDrop(jpf.getRules(nodes[i]), nodes[i]);
break;
case "ref":
this.addBindRule(nodes[i]);
break;
case "action":
this.addActionRule(nodes[i]);
break;
default:
throw new Error(jpf.formatErrorString(1039, this, 
"setSmartBinding Method", 
"Could not find handler for '" 
+ nodes[i].tagName + "' node."));
break;
}
}
if (data_node)
this.setModel(new jpf.model().loadJml(data_node));
else if (xmlNode.getAttribute("model"))
jpf.setModel(xmlNode.getAttribute("model"), this);
};
if (xmlNode)
this.loadJml(xmlNode);
};
jpf.WinServer = {
count : 9000,
wins  : [],
setTop : function(win){
this.count += 2;
win.setProperty("zindex", this.count);
this.wins.remove(win);
this.wins.push(win);
return win;
},
setNext : function(){
if (this.wins.length < 2) return;
var nwin, start = this.wins.shift();
do {
if (this.setTop(nwin || start).visible)
break;
nwin = this.wins.shift();
} while (start != nwin);
},
setPrevious : function(){
if (this.wins.length < 2) return;
this.wins.unshift(this.wins.pop());
var nwin, start = this.wins.pop();
do {
if (this.setTop(nwin || start).visible)
break;
nwin = this.wins.pop();
} while (start != nwin);
},
remove : function(win){
this.wins.remove(win);
}
}
jpf.modalwindow = jpf.component(jpf.NODE_VISIBLE, function(){
this.isWindowContainer = true;
this.canHaveChildren   = 2;
this.animate           = true;
this.visible           = false;
this.showdragging      = false;
this.$focussable       = jpf.KEYBOARD;
this.state             = "normal";
this.edit              = false;
var _self              = this;
this.setTitle = function(caption){
this.setProperty("title", caption);
};
this.setIcon = function(icon){
this.setProperty("icon", icon);
};
this.close = function(){
this.setProperty("state", this.state.split("|")
.pushUnique("closed").join("|"));
};
this.minimize = function(){
this.setProperty("state", this.state.split("|")
.remove("maximized")
.remove("normal")
.pushUnique("minimized").join("|"));
};
this.maximize = function(){
this.setProperty("state", this.state.split("|")
.remove("minimized")
.remove("normal")
.pushUnique("maximized").join("|"));
};
this.restore = function(){
this.setProperty("state", this.state.split("|")
.remove("minimized")
.remove("maximized")
.pushUnique("normal").join("|"));
};
this.edit = function(value){
this.setProperty("state", this.state.split("|")
.pushUnique("edit").join("|"));
};
this.closeedit = function(value){
this.setProperty("state", this.state.split("|")
.remove("edit").join("|"));
};
this.bringToFront = function(){
jpf.WinServer.setTop(this);
};
var actions  = {
"min"   : ["minimized", "minimize", "restore"],
"max"   : ["maximized", "maximize", "restore"],
"edit"  : ["edit", "edit", "closeedit"],
"close" : ["closed", "close", "show"]
};
this.$toggle = function(type){
var c = actions[type][0];
this[actions[type][this.state.indexOf(c) > -1 ? 2 : 1]]();
};
this.$booleanProperties["modal"]        = true;
this.$booleanProperties["center"]       = true;
this.$booleanProperties["transaction"]  = true;
this.$booleanProperties["hideselects"]  = true;
this.$booleanProperties["animate"]      = true;
this.$booleanProperties["showdragging"] = true;
this.$supportedProperties.push("title", "icon", "modal", "minwidth",
"minheight", "hideselects", "center", "buttons", "state",
"maxwidth", "maxheight", "animate", "showdragging", "transaction");
this.$propHandlers["modal"] = function(value){
if (value && !this.oCover) {
var oCover = this.$getLayoutNode("cover");
if (oCover) {
this.oCover = jpf.xmldb.htmlImport(oCover, this.pHtmlNode);
if (!this.visible)
this.oCover.style.display = "none";
this.oCover.style.zIndex = this.zindex;
}
}
if (!value && this.oCover) {
this.oCover.style.display = "none";
}
};
this.$propHandlers["transaction"] = function(value){
if (!this.hasFeature(__TRANSACTION__))
this.inherit(jpf.DataBinding, jpf.Transaction, jpf.EditTransaction);
}
this.$propHandlers["center"] = function(value){
this.oExt.style.position = "absolute"; 
};
this.$propHandlers["title"] = function(value){
this.oTitle.nodeValue = value;
};
this.$propHandlers["icon"] = function(value){
if (!this.oIcon) return;
this.oIcon.style.display = value ? "block" : "none";
jpf.skins.setIcon(this.oIcon, value, this.iconPath);
};
var hEls = [], wasVisible;
this.$propHandlers["visible"] = function(value){
if (jpf.isTrue(value)){
this.$render();
if (this.oCover){
this.oCover.style.display = "block";
}
this.state = this.state.split("|").remove("closed").join("|");
this.oExt.style.display = "block"; 
if (jpf.layout && this.oInt)
jpf.layout.forceResize(this.oInt); 
if (this.center) {
this.oExt.style.left = Math.max(0, ((
(jpf.isIE
? document.documentElement.offsetWidth
: window.innerWidth)
- this.oExt.offsetWidth)/2)) + "px";
this.oExt.style.top  = Math.max(0, ((
(jpf.isIE
? document.documentElement.offsetHeight
: window.innerHeight)
- this.oExt.offsetHeight)/3)) + "px";
}
if (!this.isRendered) {
this.addEventListener("afterrender", function(){
this.dispatchEvent("display");
this.removeEventListener("display", arguments.callee);
});
}
else
this.dispatchEvent("display");
if (!jpf.canHaveHtmlOverSelects && this.hideselects) {
hEls = [];
var nodes = document.getElementsByTagName("select");
for (var i = 0; i < nodes.length; i++) {
var oStyle = jpf.getStyle(nodes[i], "display");
hEls.push([nodes[i], oStyle]);
nodes[i].style.display = "none";
}
}
if (wasVisible != true && this.$show)
this.$show();
if (this.modal) {
this.bringToFront();
this.focus(false, {mouse:true});
}
}
else if (jpf.isFalse(value)) {
if (this.oCover)
this.oCover.style.display = "none";
this.oExt.style.display = "none";
if (!jpf.canHaveHtmlOverSelects && this.hideselects) {
for (var i = 0; i < hEls.length; i++) {
hEls[i][0].style.display = hEls[i][1];
}
}
if (this.$hide)
this.$hide();
if (this.hasFocus())
jpf.window.moveNext(null, this, true)
this.dispatchEvent("close");
}
wasVisible = value;
};
this.$propHandlers["zindex"] = function(value){
this.oExt.style.zIndex = value + 1;
if (this.oCover)
this.oCover.style.zIndex = value;
};
var lastheight = null;
var lastpos    = null;
var lastzindex = 0;
var lastState  = {"normal":1};
this.$propHandlers["state"] = function(value, noanim){
var i, o = {}, s = value.split("|");
for (i = 0; i < s.length; i++)
o[s[i]] = true;
var styleClass = [];
if (!o.maximized && !o.minimized)
o.normal = true;
if (o.closed == this.visible) {
this.setProperty("visible", !o["closed"]);
}
if (o.normal != lastState.normal
|| !o.normal && (o.minimized != lastState.minimized
|| o.maximized != lastState.maximized)) {
if (lastheight) { 
this.oExt.style.height = (lastheight
- jpf.getHeightDiff(this.oExt)) + "px";
}
if (lastpos) {
if (this.animate && !noanim) {
if (jpf.hasSingleRszEvent)
delete jpf.layout.onresize[jpf.layout.getHtmlId(this.pHtmlNode)];
jpf.tween.multi(this.oExt, {
steps    : 5,
interval : 10,
tweens   : [
{type: "left",   from: this.oExt.offsetLeft,   to: lastpos[0]},
{type: "top",    from: this.oExt.offsetTop,    to: lastpos[1]},
{type: "width",  from: this.oExt.offsetWidth,  to: lastpos[2]},
{type: "height", from: this.oExt.offsetHeight, to: lastpos[3]}
],
oneach   : function(){
if (jpf.hasSingleRszEvent)
jpf.layout.forceResize(_self.oInt);
},
onfinish : function(){
_self.$propHandlers["state"].call(_self, value, true);
}
});
return;
}
this.oExt.style.left   = lastpos[0] + "px";
this.oExt.style.top    = lastpos[1] + "px";
this.oExt.style.width  = lastpos[2] + "px";
this.oExt.style.height = lastpos[3] + "px";
var pNode = (this.oExt.parentNode == document.body
? document.documentElement
: this.oExt.parentNode);
pNode.style.overflow = lastpos[4];
}
if (jpf.layout)
jpf.layout.play(this.pHtmlNode);
if (lastzindex)
this.oExt.style.zIndex = lastzindex
lastheight = lastpos = lastzindex = null;
if (o.normal)
styleClass.push("",
this.baseCSSname + "Max",
this.baseCSSname + "Min");
}
if (o.minimized != lastState.minimized) {
if (o.minimized) {
styleClass.unshift(
this.baseCSSname + "Min",
this.baseCSSname + "Max",
this.baseCSSname + "Edit");
if (!this.aData || !this.aData.minimize) {
lastheight = this.oExt.offsetHeight;
this.oExt.style.height = Math.max(0, this.collapsedHeight
- jpf.getHeightDiff(this.oExt)) + "px";
}
if (this.hasFocus())
jpf.window.moveNext(null, this, true);
}
else {
styleClass.push(this.baseCSSname + "Min");
setTimeout(function(){
jpf.window.$focusLast(_self);
});
}
}
if (o.maximized != lastState.maximized) {
if (o.maximized) {
styleClass.unshift(
this.baseCSSname + "Max",
this.baseCSSname + "Min",
this.baseCSSname + "Edit");
var pNode = (this.oExt.parentNode == document.body
? document.documentElement
: this.oExt.parentNode);
lastpos = [this.oExt.offsetLeft, this.oExt.offsetTop,
this.oExt.offsetWidth - hordiff, this.oExt.offsetHeight - verdiff,
pNode.style.overflow];
pNode.style.overflow = "hidden";
var animstate = 0, hasAnimated = false, htmlNode = this.oExt;
function setMax(){
var w = !jpf.isIE && pNode == document.documentElement
? window.innerWidth
: pNode.offsetWidth;
var h = !jpf.isIE && pNode == document.documentElement
? window.innerHeight
: pNode.offsetHeight;
if (_self.animate && !hasAnimated) {
animstate = 1;
hasAnimated = true;
jpf.tween.multi(htmlNode, {
steps    : 5,
interval : 10,
tweens   : [
{type: "left",   from: htmlNode.offsetLeft,   to: -1 * marginBox[3]},
{type: "top",    from: htmlNode.offsetTop,    to: -1 * marginBox[0]},
{type: "width",  from: htmlNode.offsetWidth,  to: (w - hordiff + marginBox[1] + marginBox[3])},
{type: "height", from: htmlNode.offsetHeight, to: (h - verdiff + marginBox[0] + marginBox[2])}
],
oneach   : function(){
if (jpf.hasSingleRszEvent)
jpf.layout.forceResize(_self.oInt);
},
onfinish : function(){
animstate = 0;
}
});
}
else if (!animstate) {
htmlNode.style.left = (-1 * marginBox[3]) + "px";
htmlNode.style.top  = (-1 * marginBox[0]) + "px";
htmlNode.style.width  = (w
- hordiff + marginBox[1] + marginBox[3]) + "px";
htmlNode.style.height = (h
- verdiff + marginBox[0] + marginBox[2]) + "px";
}
}
if (jpf.layout)
jpf.layout.pause(this.pHtmlNode, setMax);
lastzindex = this.oExt.style.zIndex;
this.oExt.style.zIndex = jpf.WinServer.count + 1;
}
else {
styleClass.push(this.baseCSSname + "Max");
}
}
if (o.edit != lastState.edit) {
if (o.edit) {
styleClass.unshift(
this.baseCSSname + "Edit",
this.baseCSSname + "Max",
this.baseCSSname + "Min");
if (this.btnedit)
oButtons.edit.innerHTML = "close"; 
this.dispatchEvent('editstart');
}
else {
if (this.dispatchEvent('editstop') === false)
return false;
styleClass.push(this.baseCSSname + "Edit");
if (styleClass.length == 1)
styleClass.unshift("");
if (this.btnedit)
oButtons.edit.innerHTML = "edit"; 
}
}
if (styleClass.length) {
this.$setStyleClass(this.oExt, styleClass.shift(), styleClass);
this.dispatchEvent('statechange', o);
lastState = o;
if (!this.animate && jpf.hasSingleRszEvent && jpf.layout)
jpf.layout.forceResize(_self.oInt);
}
};
var oButtons = {}
this.$propHandlers["buttons"] = function(value){
var buttons = value.split("|");
var nodes   = this.oButtons.childNodes;
var re      = new RegExp("(" + value + ")");
var found   = {};
var idleNodes = [];
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1)
continue;
if (!nodes[i].className || !nodes[i].className.match(re)) {
nodes[i].style.display = "none";
this.$setStyleClass(nodes[i], "", ["min", "max", "close", "edit"]);
idleNodes.push(nodes[i]);
}
else
found[RegExp.$1] = nodes[i];
}
for (i = 0; i < buttons.length; i++) {
if (found[buttons[i]]) {
this.oButtons.insertBefore(found[buttons[i]], this.oButtons.firstChild);
continue;
}
var btn = idleNodes.pop();
if (!btn) {
this.$getNewContext("button");
btn = this.$getLayoutNode("button");
setButtonEvents(btn);
btn = jpf.xmldb.htmlImport(btn, this.oButtons);
}
this.$setStyleClass(btn, buttons[i], ["min", "max", "close", "edit"]);
btn.onclick = new Function("jpf.lookup(" + this.uniqueId + ").$toggle('"
+ buttons[i] + "')");
btn.style.display = "block";
oButtons[buttons[i]] = btn;
this.oButtons.insertBefore(btn, this.oButtons.firstChild);
}
};
this.addEventListener("keydown", function(e){
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
if (key > 36 && key < 41) {
if (_self.hasFeature && _self.hasFeature(__ANCHORING__))
_self.disableAnchoring();
}
switch (key) {
case 27:
if (this.buttons.indexOf("close") > -1 && !this.aData)
this.close();
return;
case 38:
if (shiftKey && this.resizable)
this.setProperty("height", Math.max(this.minheight || 0,
this.oExt.offsetHeight - (ctrlKey ? 50 : 10)));
else if (this.draggable)
this.setProperty("top",
this.oExt.offsetTop - (ctrlKey ? 50 : 10));
break;
case 37:
if (shiftKey && this.resizable)
this.setProperty("width", Math.max(this.minwidth || 0,
this.oExt.offsetWidth - (ctrlKey ? 50 : 10)));
else if (this.draggable)
this.setProperty("left",
this.oExt.offsetLeft - (ctrlKey ? 50 : 10));
break;
case 39:
if (shiftKey && this.resizable)
this.setProperty("width", Math.min(this.maxwidth || 10000,
this.oExt.offsetWidth + (ctrlKey ? 50 : 10)));
else if (this.draggable)
this.setProperty("left",
this.oExt.offsetLeft + (ctrlKey ? 50 : 10));
break;
case 40:
if (shiftKey && this.resizable)
this.setProperty("height", Math.min(this.maxheight || 10000,
this.oExt.offsetHeight + (ctrlKey ? 50 : 10)));
else if (this.draggable)
this.setProperty("top",
this.oExt.offsetTop + (ctrlKey ? 50 : 10));
break;
default:
return;
}
if (jpf.hasSingleRszEvent)
jpf.layout.forceResize(this.oInt);
}, true);
function setButtonEvents(btn){
btn.setAttribute("onmousedown",
"jpf.setStyleClass(this, 'down');\
event.cancelBubble = true; \
jpf.findHost(this).oExt.onmousedown(event);\
document.onmousedown(event);");
btn.setAttribute("onmouseup",
"jpf.setStyleClass(this, '', ['down'])");
btn.setAttribute("onmouseover",
"jpf.setStyleClass(this, 'hover')");
btn.setAttribute("onmouseout",
"jpf.setStyleClass(this, '', ['hover', 'down'])");
}
var marginBox, hordiff, verdiff;
this.$draw = function(){
this.popout = jpf.isTrue(this.$jml.getAttribute("popout"));
if (this.popout)
this.pHtmlNode = document.body;
this.oExt = this.$getExternal(null, null, function(oExt){
var oButtons = this.$getLayoutNode("main", "buttons", oExt);
var len = (this.$jml.getAttribute("buttons") || "").split("|").length;
for (var btn, i = 0; i < len; i++) {
this.$getNewContext("button");
btn = oButtons.appendChild(this.$getLayoutNode("button"));
setButtonEvents(btn);
}
});
this.oTitle   = this.$getLayoutNode("main", "title", this.oExt);
this.oIcon    = this.$getLayoutNode("main", "icon",  this.oExt);
this.oDrag    = this.$getLayoutNode("main", "drag",  this.oExt);
this.oButtons = this.$getLayoutNode("main", "buttons",  this.oExt);
this.oDrag.host = this;
if (this.oIcon)
this.oIcon.style.display = "none";
(this.oTitle.nodeType != 1
? this.oTitle.parentNode
: this.oTitle).ondblclick = function(e){
if (_self.state.indexOf("normal") == -1)
_self.restore();
else if (_self.buttons.indexOf("max") > -1)
_self.maximize();
else if (_self.buttons.indexOf("min") > -1)
_self.minimize();
}
this.oDrag.onmousedown = function(e){
if (!e) e = event;
if (!_self.isWidget && (!_self.aData || _self.aData.hidden == 3))
jpf.WinServer.setTop(_self);
if (lastState.maximized)
return false;
};
this.oExt.onmousedown = function(){
if (!_self.isWidget && (!_self.aData || _self.aData.hidden == 3))
jpf.WinServer.setTop(_self);
if (!lastState.normal)
return false;
}
this.oExt.onmousemove = function(){
if (!lastState.normal)
return false;
}
var diff = jpf.getDiff(this.oExt);
hordiff  = diff[0];
verdiff  = diff[1];
marginBox = jpf.getBox(jpf.getStyle(this.oExt, "borderWidth"));
};
this.$loadJml = function(x){
jpf.WinServer.setTop(this);
var oInt = this.$getLayoutNode("main", "container", this.oExt);
this.oInt = this.oInt
? jpf.JmlParser.replaceNode(oInt, this.oInt)
: jpf.JmlParser.parseChildren(this.$jml, oInt, this, true);
if (this.draggable === undefined) {
(this.$propHandlers.draggable
|| jpf.JmlElement.propHandlers.draggable).call(this, true);
this.draggable = true;
}
if (this.modal === undefined && this.oCover) {
this.$propHandlers.modal.call(this, true);
this.modal = true;
}
if (!this.visible) {
this.oExt.style.display = "none";
if (this.oCover)
this.oCover.style.display = "none";
}
this.collapsedHeight = this.$getOption("Main", "collapsed-height");
if (this.minwidth === undefined)
this.minwidth  = this.$getOption("Main", "min-width");
if (this.minheight === undefined)
this.minheight = this.$getOption("Main", "min-height");
if (this.maxwidth === undefined)
this.maxwidth  = this.$getOption("Main", "max-width");
if (this.maxheight === undefined)
this.maxheight = this.$getOption("Main", "max-height");
if (this.center && this.visible) {
this.visible = false;
this.oExt.style.display = "none"; 
jpf.JmlParser.stateStack.push({
node  : this,
name  : "visible",
value : "true"
});
}
if (!this.hasFeature(__DATABINDING__)
&& !this.transaction && (this.$jml.getAttribute("smartbinding")
|| this.$jml.getAttribute("actions"))) {
this.$propHandlers.transaction.call(this, true);
}
};
this.$skinchange = function(){
if (this.title)
this.$propHandlers["title"].call(this, this.title);
if (this.icon)
this.$propHandlers["icon"].call(this, this.icon);
}
this.$destroy = function(skinChange){
if (this.oDrag) {
this.oDrag.host = null;
this.oDrag.onmousedown = null;
jpf.removeNode(this.oDrag);
this.oDrag = null;
}
this.oTitle =  this.oIcon = this.oCover = null;
for (var name in oButtons) {
oButtons[name].onclick = null;
}
if (this.oExt && !skinChange) {
this.oExt.onmousedown = null;
this.oExt.onmousemove = null;
}
};
}).implement(
jpf.DelayedRender,
jpf.Presentation
);
jpf.video = jpf.component(jpf.NODE_VISIBLE, function(){
this.$booleanProperties["fullscreen"] = true;
var oldStyle = null; 
this.$propHandlers["fullscreen"] = function(value) {
if (!this.player) return;
if (typeof this.player.setFullscreen == "function")
this.player.setFullscreen(value);
else if (this.parentNode && this.parentNode.tagName != "application"
&& this.parentNode.setWidth) {
var i, node, oParent = this.parentNode.oExt;
if (value) {
oldStyle = {
width    : this.parentNode.getWidth(),
height   : this.parentNode.getHeight(),
top      : this.parentNode.getTop(),
left     : this.parentNode.getLeft(),
position : jpf.getStyle(oParent, 'position'),
zIndex   : jpf.getStyle(oParent, 'z-index'),
resizable: this.parentNode.resizable,
nodes    : []
}
if (oParent != document.body) {
while (oParent.parentNode != document.body) {
var node = oParent.parentNode;
i = oldStyle.nodes.push({
pos:  jpf.getSyle(node, 'position') || "",
top:  jpf.getSyle(node, 'top')  || node.offsetTop + "px",
left: jpf.getSyle(node, 'left') || node.offsetLeft + "px",
node: node
}) - 1;
node.style.position = "absolute";
node.style.top      = "0";
node.style.left     = "0";
}
}
this.parentNode.oExt.style.position = "absolute";
this.parentNode.oExt.style.zIndex = "1000000";
this.parentNode.setWidth('100%');
this.parentNode.setHeight('100%');
this.parentNode.setTop('0');
this.parentNode.setLeft('0');
if (this.parentNode.resizable)
this.parentNode.setAttribute("resizable", false);
}
else if (oldStyle) {
var coll;
if (oldStyle.nodes.length) {
for (i = oldStyle.nodes.length - 1; i >= 0; i--) {
coll = oldStyle.nodes[i];
node = coll.node;
node.style.position = coll.pos;
node.style.top      = coll.top;
node.style.left     = coll.left;
}
}
this.parentNode.oExt.style.zIndex = oldStyle.zIndex;
this.parentNode.oExt.style.position = oldStyle.position;
this.parentNode.setWidth(oldStyle.width);
this.parentNode.setHeight(oldStyle.height);
this.parentNode.setTop(oldStyle.top);
this.parentNode.setLeft(oldStyle.left);
if (oldStyle.resizable)
this.parentNode.setAttribute("resizable", true);
oldStyle = null;
delete oldStyle;
}
if (this.player.onAfterFullscreen)
this.player.onAfterFullscreen(value);
var _self = this;
window.setTimeout(function() {
jpf.layout.forceResize(_self.parentNode.oExt);
}, 100)
}
};
this.addEventListener("keydown", function(e){
window.console.log('keydown on media element');
switch (e.keyCode) {
case 13 && (e.ctrlKey || e.altKey): 
case 70: 
this.setPropery("fullscreen", true);
return false;
break;
case 80:
this.setProperty("paused", !this.paused);
return false;
break;
case 27: 
this.setProperty("fullscreen", false);
return false;
break;
default:
break;
};
}, true);
this.mainBind = "src";
this.loadMedia = function() {
if (!arguments.length) {
if (this.player) {
this.setProperty('currentSrc',   this.src);
this.setProperty('networkState', jpf.Media.NETWORK_LOADING);
this.player.load(this.src);
}
}
else {
dbLoad.apply(this, arguments);
}
return this;
};
this.seek = function(iTo) {
if (this.player && iTo >= 0 && iTo <= this.duration)
this.player.seek(iTo);
};
this.setVolume = function(iVolume) {
if (this.player) {
this.player.setVolume(iVolume);
}
};
this.$guessType = function(path) {
var ext  = path.substr(path.lastIndexOf('.') + 1);
var type = "";
switch (ext) {
case "mov":
type = "video/quicktime";
break;
case "flv":
type = "video/flv";
break;
case "asf":
case "asx":
case "avi":
case "wmv":
type = "video/wmv";
break;
case "3gp"  :
case "3gpp" :
case "3g2"  :
case "3gpp2":
case "divx" :
case "mp4"  :
case "mpg4" :
case "mpg"  :
case "mpeg" :
case "mpe"  :
case "ogg"  :
case "vob"  :
type = "video/vlc";
break;
}
if (ext == "mpg" || ext == "mpeg" || ext == "mpe")
type = jpf.isMac ? "video/quicktime" : "video/wmv";
if (!jpf.isWin && !jpf.isMac && type == "video/wmv")
type = "video/vlc";
return type;
};
this.$getPlayerType = function(mimeType) {
if (!mimeType) return null;
var playerType = null;
var aMimeTypes = mimeType.splitSafe(',');
if (aMimeTypes.length == 1)
aMimeTypes = aMimeTypes[0].splitSafe(';');
for (var i = 0; i < aMimeTypes.length; i++) {
mimeType = aMimeTypes[i];
if (mimeType.indexOf('flv') > -1)
playerType = "TypeFlv";
else if (mimeType.indexOf('quicktime') > -1)
playerType = "TypeQT";
else if (mimeType.indexOf('wmv') > -1)
playerType = "TypeWmp";
else if (mimeType.indexOf('silverlight') > -1)
playerType = "TypeSilverlight";
else if (mimeType.indexOf('vlc') > -1)
playerType = "TypeVlc";
if (playerType == "TypeWmp") {
if (!jpf.isIE && typeof jpf.video.TypeVlc != "undefined"
&& jpf.video.TypeVlc.isSupported())
playerType = "TypeVlc";
else if (jpf.isMac)
playerType = "TypeQT";
}
if (playerType && jpf.video[playerType] &&
jpf.video[playerType].isSupported()) {
this.$lastMimeType = i;
return playerType;
}
}
this.$lastMimeType = -1;
return null;
};
this.$isSupported = function(sType) {
sType = sType || this.playerType;
return (jpf.video[sType] && jpf.video[sType].isSupported());
};
this.$initPlayer = function() {
this.player = new jpf.video[this.playerType](this, this.oExt, {
src         : this.src.splitSafe(",")[this.$lastMimeType] || this.src,
width       : this.width,
height      : this.height,
autoLoad    : true,
autoPlay    : this.autoplay,
showControls: this.controls,
volume      : this.volume,
mimeType    : this.type
});
return this;
};
this.$initHook = function() {
this.loadMedia();
};
this.$cuePointHook = function() {}; 
this.$playheadUpdateHook = function() {}; 
this.$errorHook = function(e) {
jpf.console.error(e.error);
};
this.$progressHook = function(e) {
this.setProperty('bufferedBytes', {start: 0, end: e.bytesLoaded});
this.setProperty('totalBytes', e.totalBytes);
var iDiff = Math.abs(e.bytesLoaded - e.totalBytes);
if (iDiff <= 20)
this.setProperty('readyState', jpf.Media.HAVE_ENOUGH_DATA);
};
this.$stateChangeHook = function(e) {
if (e.state == "loading")
this.setProperty('networkState', this.networkState = jpf.Media.NETWORK_LOADING);
else if (e.state == "connectionError")
this.$propHandlers["readyState"].call(this, this.networkState = jpf.Media.HAVE_NOTHING);
else if (e.state == "playing" || e.state == "paused") {
if (e.state == "playing")
this.$readyHook({type: 'ready'});
this.paused = Boolean(e.state == "paused");
this.setProperty('paused', this.paused);
}
else if (e.state == "seeking") {
this.seeking = true;
this.setProperty('seeking', true);
}
};
this.$changeHook = function(e) {
if (typeof e.volume != "undefined") {
this.volume = e.volume;
if (!this.muted)
this.setProperty("volume", this.volume);
}
else {
this.duration = this.player.getTotalTime();
this.position = e.playheadTime / this.duration;
if (isNaN(this.position)) return;
this.setProperty('position', this.position);
this.currentTime = e.playheadTime;
this.setProperty('currentTime', this.currentTime);
}
};
this.$completeHook = function(e) {
this.paused = true;
this.setProperty('paused', true);
};
this.$readyHook = function(e) {
this.setProperty('networkState', jpf.Media.NETWORK_LOADED);
this.setProperty('readyState',   jpf.Media.HAVE_FUTURE_DATA);
this.setProperty('duration', this.player.getTotalTime());
this.seeking  = false;
this.seekable = true;
this.setProperty('seeking', false);
return this;
};
this.$metadataHook = function(e) {
this.oVideo.setProperty('readyState', jpf.Media.HAVE_METADATA);
};
this.stopListening = function() {
if (!this.player) return this;
return this;
};
this.$draw = function(){
this.oExt = this.$getExternal();
};
this.$loadJml = function(x){
this.oInt = this.$getLayoutNode("main", "container", this.oExt);
this.width  = parseInt(this.width)  || null;
this.height = parseInt(this.height) || null;
if (this.setSource())
this.$propHandlers["type"].call(this, this.type);
else
jpf.JmlParser.parseChildren(this.$jml, null, this);
};
this.$destroy = function(bRuntime) {
if (this.player && this.player.$destroy)
this.player.$destroy();
delete this.player;
this.player = null;
if (bRuntime)
this.oExt.innerHTML = "";
};
}).implement(
jpf.DataBinding,
jpf.Presentation,
jpf.Media
);
jpf.video.TypeInterface = {
properties: ["src", "width", "height", "volume", "showControls",
"autoPlay", "totalTime", "mimeType"],
setOptions: function(options) {
if (options == null) return this;
var hash = this.properties;
for (var i = 0; i < hash.length; i++) {
var prop = hash[i];
if (options[prop] == null) continue;
this[prop] = options[prop];
}
return this;
},
getElement: function(id) {
var elem;
if (typeof id == "object")
return id;
if (jpf.isIE)
return window[id];
else {
elem = document[id] ? document[id] : document.getElementById(id);
if (!elem)
elem = jpf.lookup(id);
return elem;
}
}
};
jpf.jslt = jpf.component(jpf.NODE_VISIBLE, function(){
this.$hasStateMessages = true;
this.mainBind = "contents";
this.focussable = false;
this.parse = function(code){
this.setProperty("value", code);
};
this.$focus = function(){
if (!this.oExt)
return;
jpf.setStyleClass(this.oExt, this.baseCSSname + "Focus");
};
this.$blur = function(){
if (!this.oExt)
return;
jpf.setStyleClass(this.oExt, "", [this.baseCSSname + "Focus"]);
};
this.$clear = function(a, b){
this.setProperty("value", "");
};
this.$setClearMessage = this.$updateClearMessage = function(msg){
jpf.setStyleClass(this.oExt, this.baseCSSname + "Empty");
this.oInt.innerHTML = msg;
};
this.$removeClearMessage = function(){
jpf.setStyleClass(this.oExt, "", [this.baseCSSname + "Empty"]);
this.oInt.innerHTML = ""; 
};
this.$booleanProperties["selectable"] = true;
this.$supportedProperties.push("value");
this.$propHandlers["value"] = function(value){
if (value)
this.$removeClearMessage();
if (this.createJml) {
if (typeof code == "string") 
code = jpf.xmldb.getXml(code);
jpf.JmlParser.parseChildren(value, this.oInt, this);
if (jpf.JmlParser.inited) 
jpf.JmlParser.parseLastPass();
}
else {
this.oInt.innerHTML = value;
}
};
this.$propHandlers["selectable"] = function(value){
this.oExt.onselectstart = value 
? function(){
event.cancelBubble = true;
}
: null;
};
this.$draw = function(){
this.oInt = this.oExt = jpf.isParsing && jpf.xmldb.isOnlyChild(this.$jml)
? this.pHtmlNode 
: this.pHtmlNode.appendChild(document.createElement("div"));
this.oExt.host = this;
if (this.$jml.getAttribute("class")) 
this.oExt.className = this.$jml.getAttribute("class");
};
this.$loadJml = function(x){
this.createJml = jpf.isTrue(x.getAttribute("jml"));
var a, i, attr = x.attributes;
for (i = 0; i < attr.length; i++) {
a = attr[i];
if (a.nodeName.indexOf("on") == 0)
this.addEventListener(a.nodeName, new Function(a.nodeValue));
}
if (x.firstChild) {
var bind = x.getAttribute("ref") || ".";
x.removeAttribute("ref");
var strBind = "<smartbinding>\
<bindings>\
<value select='" + bind + "'>\
<![CDATA[" + x.firstChild.nodeValue + "]]>\
</value>\
</bindings>\
</smartbinding>";
jpf.JmlParser.addToSbStack(this.uniqueId, 
new jpf.smartbinding(null, jpf.xmldb.getXml(strBind)));
}
};
}).implement(
jpf.DataBinding
);
jpf.radiogroup = jpf.component(jpf.NODE_HIDDEN, function(){
this.radiobuttons = [];
this.visible = true;
this.$supportedProperties.push("value", "visible", "zindex", "disabled");
this.$propHandlers["value"] = function(value){
for (var i = 0; i < this.radiobuttons.length; i++) {
if (this.radiobuttons[i].value == value)
return this.setCurrent(this.radiobuttons[i]);
}
};
this.$propHandlers["zindex"] = function(value){
for (var i = 0; i < this.radiobuttons.length; i++) {
this.radiobuttons[i].setZIndex(value);
}
};
this.$propHandlers["visible"] = function(value){
if (value) {
for (var i = 0; i < this.radiobuttons.length; i++) {
this.radiobuttons[i].show();
}
}
else {
for (var i = 0; i < this.radiobuttons.length; i++) {
this.radiobuttons[i].hide();
}
};
}
this.$propHandlers["disabled"] = function(value){
this.disabled = false;
}
this.addRadio = function(oRB){
this.radiobuttons.push(oRB);
if (!this.visible) {
oRB.hide();
}
};
this.removeRadio = function(oRB){
this.radiobuttons.remove(oRB);
}
this.setValue = function(value){
for (var i = 0; i < this.radiobuttons.length; i++) {
if (this.radiobuttons[i].value == value) {
var oRB = this.radiobuttons[i];
if (this.current && this.current != oRB)
this.current.$uncheck();
oRB.check(true);
this.current = oRB;
break;
}
}
return this.setProperty("value", value);
};
this.setCurrent = function(oRB){
if (this.current && this.current != oRB)
this.current.$uncheck();
this.value = oRB.value;
oRB.check(true);
this.current = oRB;
};
this.getValue = function(){
return this.current ? this.current.value : "";
};
}).implement(
jpf.DataBinding
,jpf.Validation
);
jpf.radiobutton = jpf.component(jpf.NODE_VISIBLE, function(){
this.$focussable = true; 
this.value       = this.uniqueId;
var _self = this;
this.$booleanProperties["checked"] = true;
this.$supportedProperties.push("value", "background", "group",
"label", "checked", "tooltip", "icon");
this.$propHandlers["group"] = function(value){
if (this.radiogroup)
this.radiogroup.removeRadio(this);
this.radiogroup = jpf.nameserver.get("radiogroup", value);
if (!this.radiogroup) {
var rg = new jpf.radiogroup(this.pHtmlNode, "radiogroup");
rg.errBox     = this.errBox;
rg.parentNode = this.parentNode; 
jpf.nameserver.register("radiogroup", value, rg);
jpf.setReference(value, rg);
rg.$jml = this.$jml;
rg.loadJml(this.$jml);
this.radiogroup = rg;
}
if (this.oInput) {
this.oInput.setAttribute("name", this.group
|| "radio" + this.radiogroup.uniqueId);
}
this.radiogroup.addRadio(this);
if (this.checked)
this.radiogroup.setValue(this.value);
};
this.$propHandlers["tooltip"] = function(value){
this.oExt.setAttribute("title", value);
};
this.$propHandlers["icon"] = function(value){
if (!this.oIcon) return;
if (value)
this.$setStyleClass(this.oExt, this.baseCSSname + "Icon");
else
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Icon"]);
jpf.skins.setIcon(this.oIcon, value, this.iconPath);
};
this.$propHandlers["label"] = function(value){
if (value)
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Empty"]);
else
this.$setStyleClass(this.oExt, this.baseCSSname + "Empty");
if (this.oLabel)
this.oLabel.innerHTML = value;
};
this.$propHandlers["checked"] = function(value){
if (!this.radiogroup)
return;
if (value)
this.radiogroup.setValue(this.value);
else {
}
};
this.$propHandlers["background"] = function(value){
var oNode = this.$getLayoutNode("main", "background", this.oExt);
if (value) {
var b = value.split("|");
this.$background = b.concat(["vertical", 2, 16].slice(b.length - 1));
oNode.style.backgroundImage  = "url(" + this.mediaPath + b[0] + ")";
oNode.style.backgroundRepeat = "no-repeat";
}
else {
oNode.style.backgroundImage  = "";
oNode.style.backgroundRepeat = "";
this.$background = null;
}
}
this.setValue = function(value){
this.setProperty("value", value);
};
this.getValue = function(){
return this.value;
};
this.setError = function(value){
this.$setStyleClass(this.oExt, this.baseCSSname + "Error");
};
this.clearError = function(value){
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Error"]);
};
this.check = function(visually){
if (visually) {
this.$setStyleClass(this.oExt, this.baseCSSname + "Checked");
this.checked = true;
if (this.oInput)
this.oInput.checked = true;
this.doBgSwitch(2);
}
else
this.radiogroup.change(this.value);
};
this.$uncheck = function(){
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Checked"]);
this.checked = false;
if (this.oInput)
this.oInput.checked = false;
this.doBgSwitch(1);
};
this.$enable = function(){
if (this.oInput)
this.oInput.disabled = false;
this.oExt.onclick = function(e){
if (!e) e = event;
if ((e.srcElement || e.target) == this)
return;
_self.dispatchEvent("click", {
htmlEvent: e
});
_self.radiogroup.change(_self.value);
}
this.oExt.onmousedown = function(e){
if (!e) e = event;
if ((e.srcElement || e.target) == this)
return;
jpf.setStyleClass(this, _self.baseCSSname + "Down");
}
this.oExt.onmouseover = function(e){
if (!e) e = event;
if ((e.srcElement || e.target) == this)
return;
jpf.setStyleClass(this, _self.baseCSSname + "Over");
}
this.oExt.onmouseout =
this.oExt.onmouseup  = function(){
jpf.setStyleClass(this, "", [_self.baseCSSname + "Down", _self.baseCSSname + "Over"]);
}
};
this.$disable = function(){
if (this.oInput)
this.oInput.disabled = true;
this.oExt.onclick = null
this.oExt.onmousedown = null
};
this.doBgSwitch = function(nr){
if (this.bgswitch && (this.bgoptions[1] >= nr || nr == 4)) {
if (nr == 4)
nr = this.bgoptions[1] + 1;
var strBG = this.bgoptions[0] == "vertical"
? "0 -" + (parseInt(this.bgoptions[2]) * (nr - 1)) + "px"
: "-"   + (parseInt(this.bgoptions[2]) * (nr - 1)) + "px 0";
this.$getLayoutNode("main", "background", this.oExt)
.style.backgroundPosition = strBG;
}
};
this.$focus = function(){
if (!this.oExt)
return;
if (this.oInput && this.oInput.disabled)
return false;
this.$setStyleClass(this.oExt, this.baseCSSname + "Focus");
};
this.$blur = function(){
if (!this.oExt)
return;
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Focus"]);
};
this.addEventListener("keydown", function(e){
var key = e.keyCode;
if (key == 13 || key == 32) {
this.radiogroup.change(this.value);
return false;
}
else if (key == 38) {
var node = this;
while (node && node.previousSibling) {
node = node.previousSibling;
if (node.tagName == "radiobutton" && !node.disabled
&& node.radiogroup == this.radiogroup) {
node.check();
node.focus();
return;
}
}
}
else if (key == 40) {
var node = this;
while (node && node.nextSibling) {
node = node.nextSibling;
if (node.tagName == "radiobutton" && !node.disabled
&& node.radiogroup == this.radiogroup) {
node.check();
node.focus();
return;
}
}
}
}, true);
this.$draw = function(){
this.oExt = this.$getExternal();
this.oInput = this.$getLayoutNode("main", "input", this.oExt);
this.oLabel = this.$getLayoutNode("main", "label", this.oExt);
this.oIcon  = this.$getLayoutNode("main", "icon", this.oExt);
this.enable();
};
this.$loadJml = function(x){
if (x.firstChild) {
var content = x.innerHTML;
if (!content) {
content = (x.xml || x.serialize())
.replace(/^<[^>]*>/, "")
.replace(/<\/\s*[^>]*>$/, "");
}
this.$handlePropSet("label", content);
}
if (!this.radiogroup) {
this.$propHandlers["group"].call(this,
"radiogroup" + this.parentNode.uniqueId);
}
if (this.checked && !this.radiogroup.value)
this.$propHandlers["checked"].call(this, this.checked);
};
}).implement(
jpf.Presentation
);
jpf.thumbnail = 
jpf.select    = 
jpf.select1   = 
jpf.list      = jpf.component(jpf.NODE_VISIBLE, function(){
var _self = this;
this.$supportedProperties.push("appearance", "mode", "more");
this.$propHandlers["appearance"] = function(value){
};
this.mode = "normal";
this.$propHandlers["mode"] = function(value){
this.mode = value || "normal";
if ("check|radio".indexOf(this.mode) > -1) {
this.allowdeselect = false;
this.addEventListener("afterrename", $afterRenameMode);
if (this.mode == "check") {
this.autoselect = false;
this.ctrlselect    = true;
}
else if (this.mode == "radio")
this.multiselect = false;
}
else {
this.ctrlselect = false;
this.removeEventListener("afterrename", $afterRenameMode);
}
};
function $afterRenameMode(){
var sb = this.$getMultiBind();
if (!sb) 
return;
sb.$updateSelection();
}
this.addEventListener("keydown", this.$keyHandler, true);
this.$draw = function(){
this.oExt = this.$getExternal();
this.oInt = this.$getLayoutNode("main", "container", this.oExt);
if (jpf.hasCssUpdateScrollbarBug && !this.mode)
this.$fixScrollBug();
this.oExt.onclick = function(e){
_self.dispatchEvent("click", {
htmlEvent: e || event
});
}
this.listtype  = parseInt(this.$getOption("main", "type")) || 1;
this.behaviour = parseInt(this.$getOption("main", "behaviour")) || 1; 
};
this.$loadJml = function(x){
if (this.$jml.childNodes.length) 
this.$loadInlineData(this.$jml);
};
this.$destroy = function(){
this.oExt.onclick = null;
jpf.removeNode(this.oDrag);
this.oDrag = null;
};
}).implement(
jpf.BaseList
);
jpf.errorbox = jpf.component(jpf.NODE_VISIBLE, function(){
var _self = this;
this.setMessage = function(value){
if(value.indexOf(";")>-1){
value = value.split(";");
value = "<strong>" + value[0] + "</strong>" + value[1];
}
this.oInt.innerHTML = value;
};
this.$draw = function(){
this.oExt   = this.$getExternal(); 
this.oInt   = this.$getLayoutNode("main", "container", this.oExt);
this.oClose = this.$getLayoutNode("main", "close", this.oExt);
if (this.oClose) {
this.oClose.onclick = function(){
_self.hide();
if (_self.host)
_self.host.focus(null, {mouse:true});
};
}
this.oExt.onmousedown = function(e){
(e || event).cancelBubble = true;
}
this.hide();
};
this.$loadJml = function(x){
jpf.JmlParser.parseChildren(this.$jml, this.oInt, this);
};
this.$destroy = function(){
if (this.oClose)
this.oClose.onclick = null;
this.oExt.onmousedown = null;
}
}).implement(
jpf.Presentation
);
jpf.range  =
jpf.slider = jpf.component(jpf.NODE_VISIBLE, function(){
this.$focussable = true; 
var _self    = this;
var dragging = false;
this.disabled = false; 
this.realtime = true;
this.value    = 0;
this.mask     = "%";
this.min      = 0;
this.max      = 1;
this.$supportedProperties.push("step", "mask", "min",
"max", "slide", "value");
this.$booleanProperties["realtime"] = true;
this.$propHandlers["step"] = function(value){
this.step = parseInt(value) || 0;
if (!this.$hasLayoutNode("marker"))
return;
var markers = this.oMarkers.childNodes;
for (var i = markers.length - 1; i >= 0; i--) {
if (markers[i].nodeType == 1)
jpf.removeNode(markers[i]);
}
if (this.step) {
var leftPos, count = (this.max - this.min) / this.step;
for (var o, nodes = [], i = 0; i < count + 1; i++) {
this.$getNewContext("marker");
o = this.$getLayoutNode("marker");
leftPos = Math.max(0, (i * (1 / count) * 100) - 1);
o.setAttribute("style", "left:" + leftPos + "%");
nodes.push(o);
}
jpf.xmldb.htmlImport(markers, this.oMarkers);
}
}
this.$propHandlers["mask"] = function(value){
if (!value)
this.mask = "%";
if (!this.mask.match(/^(%|#)$/))
this.mask = value.split("|");
}
this.$propHandlers["progress"] = function(value){
if (!this.oProgress) {
this.oProgress =
jpf.xmldb.htmlImport(this.$getLayoutNode("progress"),
this.$getLayoutNode("main", "progress", this.oExt));
}
this.oProgress.style.width = ((value || 0) * 100) + "%";
}
this.$propHandlers["min"] = function(value){
this.min = parseInt(value) || 0;
}
this.$propHandlers["max"] = function(value){
this.max = parseInt(value) || 1;
}
this.$propHandlers["slide"] = function(value){
this.slideDiscreet = value == "discrete";
this.slideSnap     = value == "snap";
}
this.$propHandlers["value"] = function(value, force){
if (!this.$dir)
return; 
if (dragging && !force)
return;
this.value = Math.max(this.min, Math.min(this.max, value)) || 0;
var max, min, multiplier = (this.value - this.min) / (this.max - this.min);
if (this.$dir == "horizontal") {
max = (this.oContainer.offsetWidth
- jpf.getWidthDiff(this.oContainer))
- this.oSlider.offsetWidth;
min = parseInt(jpf.getBox(
jpf.getStyle(this.oContainer, "padding"))[3]);
this.oSlider.style.left = (((max - min) * multiplier) + min) + "px";
}
else {
max = (this.oContainer.offsetHeight
- jpf.getHeightDiff(this.oContainer))
- this.oSlider.offsetHeight;
min = parseInt(jpf.getBox(
jpf.getStyle(this.oContainer, "padding"))[0]);
this.oSlider.style.top = (((max - min) * (1 - multiplier)) + min) + "px";
}
if (this.oLabel) {
if (this.mask == "%") {
this.oLabel.nodeValue = Math.round(multiplier * 100) + "%";
}
else
if (this.mask == "#") {
status = this.value;
this.oLabel.nodeValue = this.step
? (Math.round(this.value / this.step) * this.step)
: this.value;
}
else {
this.oLabel.nodeValue = this.mask[Math.round(this.value - this.min)
/ (this.step || 1)]; 
}
}
};
this.setValue = function(value, onlySetXml){
this.$onlySetXml = onlySetXml;
this.setProperty("value", value);
this.$onlySetXml = false;
};
this.getValue = function(){
return this.step
? Math.round(parseInt(this.value) / this.step) * this.step
: this.value;
};
this.addEventListener("keydown", function(e){
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
switch (key) {
case 37:
if (this.$dir != "horizontal")
return;
this.setValue(this.value - (ctrlKey ? 0.01 : 0.1));
break;
case 38:
if (this.$dir != "vertical")
return;
this.setValue(this.value + (ctrlKey ? 0.01 : 0.1));
break;
case 39:
if (this.$dir != "horizontal")
return;
this.setValue(this.value + (ctrlKey ? 0.01 : 0.1));
break;
case 40:
if (this.$dir != "vertical")
return;
this.setValue(this.value - (ctrlKey ? 0.01 : 0.1));
break;
default:
return;
}
return false;
}, true);
this.$draw = function(){
this.oExt         = this.$getExternal();
this.oLabel       = this.$getLayoutNode("main", "status", this.oExt);
this.oMarkers     = this.$getLayoutNode("main", "markers", this.oExt);
this.oSlider      = this.$getLayoutNode("main", "slider", this.oExt);
this.oInt         = this.oContainer = this.$getLayoutNode("main",
"container", this.oExt);
this.$dir         = this.$getOption("main", "direction") || "horizontal";
this.oSlider.style.left = (parseInt(jpf.getBox(
jpf.getStyle(this.oExt, "padding"))[3])) + "px";
this.oSlider.onmousedown = function(e){
if (_self.disabled)
return false;
if (!e)
e = event;
document.dragNode = this;
this.x   = (e.clientX || e.x);
this.y   = (e.clientY || e.y);
this.stX = this.offsetLeft;
this.siX = this.offsetWidth
this.stY = this.offsetTop;
this.siY = this.offsetheight
this.startValue = _self.value;
if (_self.$dir == "horizontal") {
this.max = parseInt(jpf.getStyle(_self.oContainer, "width"))
- this.offsetWidth;
this.min = parseInt(jpf.getBox(
jpf.getStyle(_self.oContainer, "padding"))[3]);
}
else {
this.max = parseInt(jpf.getStyle(_self.oContainer, "height"))
- this.offsetHeight;
this.min = parseInt(jpf.getBox(
jpf.getStyle(_self.oContainer, "padding"))[0]);
}
_self.$setStyleClass(this, "btndown", ["btnover"]);
jpf.dragmode.mode = true;
function getValue(o, e, slideDiscreet){
var to = (_self.$dir == "horizontal")
? (e.clientX || e.x) - o.x + o.stX
: (e.clientY || e.y) - o.y + o.stY;
to = (to > o.max ? o.max : (to < o.min ? o.min : to));
var value = (((to - o.min) * 100 / (o.max - o.min) / 100)
* (_self.max - _self.min)) + _self.min;
value = slideDiscreet
? (Math.round(value / slideDiscreet) * slideDiscreet)
: value;
value = (_self.$dir == "horizontal") ? value : 1 - value;
return value;
}
dragging = true;
document.onmousemove = function(e){
var o = this.dragNode;
if (!o) {
document.onmousemove =
document.onmouseup   =
jpf.dragmode.mode    = null;
return; 
}
if (_self.realtime) {
_self.value = -1; 
_self.setValue(getValue(o, e || event, _self.slideDiscreet));
}
_self.$propHandlers["value"].call(_self, getValue(o, e || event, _self.slideDiscreet), true);
}
document.onmouseup = function(e){
var o = this.dragNode;
this.dragNode = null;
o.onmouseout();
dragging = false;
_self.$ignoreSignals = _self.realtime;
_self.change(getValue(o, e || event,
_self.slideDiscreet || _self.slideSnap));
_self.$ignoreSignals = false;
document.onmousemove =
document.onmouseup   =
jpf.dragmode.mode    = null;
}
return false;
};
this.oSlider.onmouseup = this.oSlider.onmouseover = function(){
if (document.dragNode != this)
_self.$setStyleClass(this, "btnover", ["btndown"]);
};
this.oSlider.onmouseout = function(){
if (document.dragNode != this)
_self.$setStyleClass(this, "", ["btndown", "btnover"]);
};
};
this.$loadJml = function(x){
this.$propHandlers["value"].call(this, this.value);
jpf.JmlParser.parseChildren(this.$jml, null, this);
};
this.$destroy = function(){
this.oSlider.onmousedown =
this.oSlider.onmouseup   =
this.oSlider.onmouseover =
this.oSlider.onmouseout  = null;
};
}).implement(
jpf.DataBinding,
jpf.Validation,
jpf.Presentation
);
jpf.textbox  =
jpf.secret   =
jpf.textarea =
jpf.input    = jpf.component(jpf.NODE_VISIBLE, function(){
this.$focussable       = true; 
var masking            = false;
var _self              = this;
this.value             = "";
this.isContentEditable = true;
this.multiline         = this.tagName == "textarea" ? true : false;
this.$booleanProperties["focusselect"] = true;
this.$booleanProperties["realtime"]    = true;
this.$supportedProperties.push("value", "mask", "initial",
"focusselect", "realtime", "type");
this.$propHandlers["value"] = function(value, initial){
if (this.isHTMLBox) {
if (this.oInt.innerHTML != value)
this.oInt.innerHTML = value;
}
else if (this.oInt.value.replace(/\r/g, "") != value) {
this.oInt.value = value;
}
if (this.oButton)
this.oButton.style.display = value && !initial ? "block" : "none";
};
this.$propHandlers["maxlength"] = function(value){
this.$setRule("maxlength", value
? "value.toString().length <= " + value
: null);
if (this.oInt.tagName.toLowerCase().match(/input|textarea/))
this.oInt.maxLength = parseInt(value) || null;
};
this.$propHandlers["mask"] = function(value){
if (jpf.hasMsRangeObject || this.mask == "PASSWORD")
return;
if (!value) {
throw new Error("Not Implemented");
}
if (!masking) {
masking = true;
this.inherit(jpf.textbox.masking); 
this.focusselect = false;
this.realtime    = false;
}
this.setMask(this.mask);
};
this.$propHandlers["initial-message"] = function(value){
this.initialMsg = value
|| jpf.xmldb.getInheritedAttribute(this.$jml, "initial-message");
if (this.initialMsg) {
this.oInt.onblur();
this.$propHandlers["value"].call(this, this.initialMsg, true);
}
};
this.$propHandlers["realtime"] = function(value){
this.realtime = typeof value == "boolean"
? value
: jpf.isTrue(jpf.xmldb.getInheritedAttribute(this.$jml, "realtime")) || false;
};
this.$propHandlers["focusselect"] = function(value){
this.oInt.onmousedown = function(){
_self.focusselect = false;
};
this.oInt.onmouseup  =
this.oInt.onmouseout = function(){
_self.focusselect = value;
};
};
this.$propHandlers["type"] = function(value){
if (value && "password|username".indexOf(value) > -1
&& typeof this.focusselect == "undefined") {
this.focusselect = true;
this.$propHandlers["focusselect"].call(this, true);
}
};
this.setValue = function(value){
return this.setProperty("value", value);
};
this.getValue = function(){
var v = this.isHTMLBox ? this.oInt.innerHTML : this.oInt.value;
return v == this.initialMsg ? "" : v.replace(/\r/g, "");
};
this.select   = function(){ this.oInt.select(); };
this.deselect = function(){ this.oInt.deselect(); };
this.$enable  = function(){ this.oInt.disabled = false; };
this.$disable = function(){ this.oInt.disabled = true; };
this.$insertData = function(str){
return this.setValue(str);
};
this.insert = function(text){
if (jpf.hasMsRangeObject) {
try {
this.oInt.focus();
}
catch(e) {}
var range = document.selection.createRange();
if (this.oninsert)
text = this.oninsert(text);
range.pasteHTML(text);
range.collapse(true);
range.select();
}
else {
this.oInt.value += text;
}
};
this.$clear = function(){
this.value = "";
if (this.initialMsg && jpf.window.focussed != this) {
this.$propHandlers["value"].call(this, this.initialMsg, true);
jpf.setStyleClass(_self.oExt, _self.baseCSSname + "Initial");
}
else {
this.$propHandlers["value"].call(this, "");
}
if (!this.oInt.tagName.toLowerCase().match(/input|textarea/i)) {
if (jpf.hasMsRangeObject) {
try {
var range = document.selection.createRange();
range.moveStart("sentence", -1);
range.select();
}
catch(e) {}
}
}
this.dispatchEvent("clear");
};
this.$keyHandler = function(key, ctrlKey, shiftKey, altKey, e){
if (this.dispatchEvent("keydown", {
keyCode   : key,
ctrlKey   : ctrlKey,
shiftKey  : shiftKey,
altKey    : altKey,
htmlEvent : e}) === false)
return false;
if (false && jpf.isIE && (key == 86 && ctrlKey || key == 45 && shiftKey)) {
var text = window.clipboardData.getData("Text");
if ((text = this.dispatchEvent("keydown", {
text : this.onpaste(text)}) === false))
return false;
if (!text)
text = window.clipboardData.getData("Text");
this.oInt.focus();
var range = document.selection.createRange();
range.text = "";
range.collapse();
range.pasteHTML(text.replace(/\n/g, "<br />").replace(/\t/g, "&nbsp;&nbsp;&nbsp;"));
return false;
}
};
var fTimer;
this.$focus = function(e){
if (!this.oExt || this.oExt.disabled)
return;
this.$setStyleClass(this.oExt, this.baseCSSname + "Focus");
if (this.initialMsg && this.oInt.value == this.initialMsg) {
this.$propHandlers["value"].call(this, "", true);
jpf.setStyleClass(this.oExt, "", [this.baseCSSname + "Initial"]);
}
function delay(){
try {
if (!fTimer || document.activeElement != _self.oInt) {
_self.oInt.focus();
}
else {
clearInterval(fTimer);
return;
}
}
catch(e) {}
if (masking)
_self.setPosition();
if (_self.focusselect)
_self.select();
};
if ((!e || e.mouse) && jpf.isIE) {
clearInterval(fTimer);
fTimer = setInterval(delay, 1);
}
else
delay();
};
this.$blur = function(e){
if (!this.oExt)
return;
if (!this.realtime)
this.change(this.getValue());
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Focus"]);
if (this.initialMsg && this.oInt.value == "") {
this.$propHandlers["value"].call(this, this.initialMsg, true);
jpf.setStyleClass(this.oExt, this.baseCSSname + "Initial");
}
try {
if (jpf.isIE || !e || e.srcElement != jpf.window)
this.oInt.blur();
}
catch(e) {}
if (this.oContainer) {
setTimeout("var o = jpf.lookup(" + this.uniqueId + ");\
o.oContainer.style.display = 'none'", 100);
}
clearInterval(fTimer);
};
this.$draw = function(){
this.oExt = this.$getExternal(null, null, function(oExt){
if (this.$jml.getAttribute("mask") == "PASSWORD"
|| "secret|password".indexOf(this.tagName) > -1
|| this.$jml.getAttribute("type") == "password") {
this.$jml.removeAttribute("mask");
this.$getLayoutNode("main", "input").setAttribute("type", "password");
}
oExt.setAttribute("onmousedown", "this.host.dispatchEvent('mousedown', {htmlEvent : event});");
oExt.setAttribute("onmouseup",   "this.host.dispatchEvent('mouseup', {htmlEvent : event});");
oExt.setAttribute("onclick",     "this.host.dispatchEvent('click', {htmlEvent : event});");
});
this.oInt    = this.$getLayoutNode("main", "input", this.oExt);
this.oButton = this.$getLayoutNode("main", "button", this.oExt);
if (!jpf.hasContentEditable && "input|textarea".indexOf(this.oInt.tagName.toLowerCase()) == -1) {
var node  = this.oInt;
this.oInt = node.parentNode.insertBefore(document.createElement("textarea"), node);
node.parentNode.removeChild(node);
this.oInt.className = node.className;
if (this.oExt == node)
this.oExt = this.oInt;
}
if (this.oInt.tagName.toLowerCase() == "textarea") {
this.addEventListener("focus", function(e){
});
}
this.oInt.onselectstart = function(e){
if (!e) e = event;
e.cancelBubble = true;
}
this.oInt.host = this;
this.oInt.onkeydown = function(e){
if (this.disabled) return false;
e = e || window.event;
if (!_self.realtime) {
var value = _self.getValue();
if (e.keyCode == 13 && value != this.value)
_self.change(value);
}
else if (jpf.isSafari && _self.xmlRoot && _self.getValue() != this.value) 
setTimeout("var o = jpf.lookup(" + _self.uniqueId + ");\
o.change(o.getValue())");
if (_self.multiline == "optional" && e.keyCode == 13 && !e.ctrlKey)
return false;
if (e.ctrlKey && (e.keyCode == 66 || e.keyCode == 73
|| e.keyCode == 85))
return false;
if (_self.oContainer) {
var oTxt    = _self;
var keyCode = e.keyCode;
setTimeout(function(){
oTxt.fillAutocomplete(keyCode);
});
}
if (!_self.mask) {
return _self.$keyHandler(e.keyCode, e.ctrlKey,
e.shiftKey, e.altKey, e);
}
};
this.oInt.onkeyup = function(e){
if (!e)
e = event;
var keyCode = e.keyCode;
if (_self.oButton)
_self.oButton.style.display = this.value ? "block" : "none";
if (_self.realtime) {
setTimeout(function(){
if (!_self.mask && _self.getValue() != _self.value)
_self.change(_self.getValue()); 
_self.dispatchEvent("keyup", {keyCode : keyCode});
});
}
else {
_self.dispatchEvent("keyup", {keyCode : keyCode});
}
if (_self.isValid() && e.keyCode != 13 && e.keyCode != 17)
_self.clearError();
};
this.oInt.onfocus = function(){
};
this.oInt.onblur = function(){
};
if (jpf.hasAutocompleteXulBug)
this.oInt.setAttribute("autocomplete", "off");
if (!this.oInt.tagName.toLowerCase().match(/input|textarea/)) {
this.isHTMLBox = true;
this.oInt.unselectable    = "Off";
this.oInt.contentEditable = true;
this.oInt.style.width     = "1px";
this.oInt.select = function(){
var r = document.selection.createRange();
r.moveToElementText(this);
r.select();
}
};
this.oInt.deselect = function(){
if (!document.selection) return;
var r = document.selection.createRange();
r.collapse();
r.select();
};
};
this.$loadJml = function(x){
var ac = $xmlns(x, "autocomplete", jpf.ns.jml)[0];
if (ac) {
this.inherit(jpf.textbox.autocomplete); 
this.initAutocomplete(ac);
}
if (typeof this.realtime == "undefined")
this.$propHandlers["realtime"].call(this);
if (jpf.xmldb.isOnlyChild(x.firstChild, [3,4]))
this.$handlePropSet("value", x.firstChild.nodeValue.trim());
else if (!ac)
jpf.JmlParser.parseChildren(this.$jml, null, this);
};
this.$destroy = function(){
this.oInt.onkeypress    =
this.oInt.onmouseup     =
this.oInt.onmouseout    =
this.oInt.onmousedown   =
this.oInt.onkeydown     =
this.oInt.onkeyup       =
this.oInt.onselectstart = null;
};
}).implement(
jpf.DataBinding,
jpf.Validation,
jpf.Presentation
);
jpf.submit  =
jpf.trigger =
jpf.reset   =
jpf.button  = jpf.component(jpf.NODE_VISIBLE, function(){
var useExtraDiv;
var _self = this;
this.$focussable = true; 
this.value       = null;
this.$booleanProperties["default"] = true;
this.$supportedProperties.push("icon", "value", "tooltip", "state",
"color", "caption", "action", "target", "default", "submenu");
this.$propHandlers["icon"] = function(value){
if (!this.oIcon) return;
if (value)
this.$setStyleClass(this.oExt, this.baseCSSname + "Icon");
else
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Icon"]);
jpf.skins.setIcon(this.oIcon, value, this.iconPath);
};
this.$propHandlers["value"] = function(value){
if (value === undefined)
value = !this.value;
this.value = value;
if (this.value)
this.$setState("Down", {});
else
this.$setState("Out", {});
};
this.$propHandlers["tooltip"] = function(value){
this.oExt.setAttribute("title", value);
};
this.$propHandlers["state"] = function(value){
this.$setStateBehaviour(value == 1);
};
this.$propHandlers["color"] = function(value){
if (this.oCaption)
this.oCaption.parentNode.style.color = value;
};
this.$propHandlers["caption"] = function(value){
if (value)
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Empty"]);
else
this.$setStyleClass(this.oExt, this.baseCSSname + "Empty");
if (this.oCaption)
this.oCaption.nodeValue = (value || "").trim();
};
var forceFocus;
this.$propHandlers["default"] = function(value){
if (!this.focussable && value || forceFocus)
this.setAttribute("focussable", forceFocus = value);
this.parentNode.removeEventListener("focus", setDefault);
this.parentNode.removeEventListener("blur", removeDefault);
if (!value)
return;
this.parentNode.addEventListener("focus", setDefault);
this.parentNode.addEventListener("blur", removeDefault);
};
function setDefault(e){
if (e.defaultButtonSet || e.returnValue === false)
return;
e.defaultButtonSet = true;
if (useExtraDiv)
_self.oExt.appendChild(jpf.button.$extradiv);
_self.$setStyleClass(_self.oExt, _self.baseCSSname + "Default");
if (e.srcElement != _self && _self.$focusParent) {
_self.$focusParent.addEventListener("keydown", btnKeyDown);
}
}
function removeDefault(e){
if (useExtraDiv && jpf.button.$extradiv.parentNode == _self.oExt)
_self.oExt.removeChild(jpf.button.$extradiv);
_self.$setStyleClass(_self.oExt, "", [_self.baseCSSname + "Default"]);
if (e.srcElement != _self && _self.$focusParent) {
_self.$focusParent.removeEventListener("keydown", btnKeyDown);
}
}
function btnKeyDown(e){
var ml;
var f = jpf.window.focussed;
if (f) {
if (f.hasFeature(__MULTISELECT__))
return;
ml = f.multiline;
}
if (ml && ml != "optional" && e.keyCode == 13
&& e.ctrlKey || (!ml || ml == "optional")
&& e.keyCode == 13 && !e.ctrlKey && !e.shiftKey && !e.altKey)
_self.oExt.onmouseup(e.htmlEvent, true);
}
this.addEventListener("focus", setDefault);
this.addEventListener("blur", removeDefault);
this.setValue = function(value){
this.setProperty("value", value);
};
this.setCaption = function(value){
this.setProperty("caption", value);
};
this.setIcon = function(url){
this.setProperty("icon", url);
};
this.$enable = function(){
if (this["default"]) {
setDefault({});
if (jpf.window.focussed)
jpf.window.focussed.focus(true);
}
if (this.state && this.value) {
this.$setState("Down", {});
}
this.$doBgSwitch(1);
};
this.$disable = function(){
if (this["default"])
removeDefault({});
this.$doBgSwitch(4);
this.$setStyleClass(this.oExt, "",
[this.baseCSSname + "Over", this.baseCSSname + "Down"]);
};
this.$setStateBehaviour = function(value){
this.value     = value || false;
this.isBoolean = true;
this.$setStyleClass(this.oExt, this.baseCSSname + "Bool");
if (this.value) {
this.$setStyleClass(this.oExt, this.baseCSSname + "Down");
this.$doBgSwitch(this.states["Down"]);
}
};
this.$setNormalBehaviour = function(){
this.value     = null;
this.isBoolean = false;
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Bool"]);
};
this.$setState = function(state, e, strEvent){
if (this.disabled)
return;
if (strEvent && this.dispatchEvent(strEvent, {htmlEvent: e}) === false)
return;
this.$doBgSwitch(this.states[state]);
var bs = this.baseCSSname;
this.$setStyleClass(this.oExt, (state != "Out" ? bs + state : ""),
[(this.value ? "" : bs + "Down"), bs + "Over"]);
if (this.submenu) {
bs = this.baseCSSname + "menu";
this.$setStyleClass(this.oExt, (state != "Out" ? bs + state : ""),
[(this.value ? "" : bs + "Down"), bs + "Over"]);
}
};
this.$clickHandler = function(){
if (this.isBoolean && !this.submenu) {
this.setProperty("value", !this.value);
return true;
}
};
this.$domHandlers["reparent"].push(
function(beforeNode, pNode, withinParent){
if (!this.$jmlLoaded)
return;
var skinName;
if (isUsingParentSkin && !withinParent
&& this.skinName != pNode.skinName
|| !isUsingParentSkin && (skinName = this.parentNode.$getOption
&& this.parentNode.$getOption("main", "button-skin"))) {
isUsingParentSkin = true;
this.$forceSkinChange(this.parentNode.skinName.split(":")[0] + ":" + skinName);
}
});
var inited = false, isUsingParentSkin = false;
this.$draw  = function(){
if (typeof this.focussable == "undefined") {
if (this.parentNode.parentNode
&& this.parentNode.parentNode.tagName == "toolbar"
&& !this.$jml.getAttribute("focussable"))
this.focussable = false;
}
var skinName;
if (this.parentNode && (skinName = this.parentNode.$getOption
&& this.parentNode.$getOption("main", "button-skin"))) {
isUsingParentSkin = true;
skinName = this.parentNode.skinName.split(":")[0] + ":" + skinName;
if (this.skinName != skinName)
this.$loadSkin(skinName);
this.$focussable = jpf.KEYBOARD;
}
else if(isUsingParentSkin){
isUsingParentSkin = false;
this.$loadSkin();
this.$focussable = true;
}
this.oExt     = this.$getExternal();
this.oIcon    = this.$getLayoutNode("main", "icon", this.oExt);
this.oCaption = this.$getLayoutNode("main", "caption", this.oExt);
useExtraDiv = jpf.isTrue(this.$getOption("main", "extradiv"));
if (!jpf.button.$extradiv && useExtraDiv) {
(jpf.button.$extradiv = document.createElement("div"))
.className = "extradiv"
}
if (this.tagName == "submit")
this.action = "submit";
else if (this.tagName == "reset")
this.action = "reset";
this.$setupEvents();
};
this.$skinchange = function(){
if (this.caption)
this.$propHandlers["caption"].call(this, this.caption);
if (this.icon)
this.$propHandlers["icon"].call(this, this.icon);
this.$updateState({reset:1});
}
this.$loadJml = function(x){
if (!this.caption && x.firstChild)
this.setProperty("caption", x.firstChild.nodeValue);
else if (typeof this.caption == "undefined")
this.$propHandlers["caption"].call(this, "");
if (!inited) {
jpf.JmlParser.parseChildren(this.$jml, null, this);
inited = true;
}
};
this.addEventListener("click", function(e){
var action = this.action;
if (!action)
action = this.tagName;
setTimeout(function(){
(jpf.button.actions[action] || jpf.K).call(_self);
});
});
}).implement(jpf.Presentation, jpf.BaseButton);
jpf.button.actions = {
"undo" : function(action){
var tracker;
if (this.target && self[this.target]) {
tracker = self[this.target].getActionTracker()
}
else {
var at, node = this;
while(node.parentNode)
at = (node = node.parentNode).$at;
}
(tracker || jpf.window.$at)[action || "undo"]();
},
"redo" : function(){
jpf.button.actions.undo.call(this, "redo");
},
"remove" : function(){
if (this.target && self[this.target])
self[this.target].remove()
},
"add" : function(){
if (this.target && self[this.target])
self[this.target].add()
},
"rename" : function(){
if (this.target && self[this.target])
self[this.target].startRename()
},
"submit" : function(doReset){
var vg, model;
var parent = this.target && self[this.target]
? self[this.target]
: this.parentNode;
if (parent.tagName == "model")
model = parent;
else {
if (!parent.$validgroup) {
parent.$validgroup = parent.validgroup
? self[parent.validgroup]
: new jpf.ValidationGroup();
}
vg = parent.$validgroup;
if (!vg.childNodes.length)
vg.childNodes = parent.childNodes.slice();
function loopChildren(nodes){
for (var node, i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
if (node.getModel) {
model = node.getModel();
if (model)
return false;
}
if (node.childNodes.length)
if (loopChildren(node.childNodes) === false)
return false;
}
}
loopChildren(parent.childNodes);
if (!model) {
return;
}
}
if (doReset) {
model.reset();
return;
}
if (vg && !vg.isValid())
return;
model.submit();
},
"reset" : function(){
jpf.button.actions["submit"].call(this, true);
},
"close" : function(){
var parent = this.target && self[this.target]
? self[this.target]
: this.parentNode;
while(parent && !parent.close)
parent = parent.parentNode;
if (parent && parent.close)
parent.close();
}
};
jpf.teleport = {
tagName  : "teleport",
nodeFunc : jpf.NODE_HIDDEN,
modules: new Array(),
named: {},
register: function(obj){
var id = false, data = {
obj: obj
};
return this.modules.push(data) - 1;
},
getModules: function(){
return this.modules;
},
getModuleByName: function(defname){
return this.named[defname]
},
loadJml: function(x, parentNode){
this.$jml        = x;
this.parentNode = parentNode;
jpf.inherit.call(this, jpf.JmlDom); 
var id, obj, nodes = this.$jml.childNodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1) 
continue;
obj = new jpf.BaseComm(nodes[i]);
if (id = nodes[i].getAttribute("id"))
jpf.setReference(id, obj);
}
this.loaded = true;
if (this.onload) 
this.onload();
return this;
},
availHTTP  : [],
releaseHTTP: function(http){
if (jpf.brokenHttpAbort) 
return;
if (self.XMLHttpRequestUnSafe && http.constructor == XMLHttpRequestUnSafe) 
return;
http.onreadystatechange = function(){};
http.abort();
this.availHTTP.push(http);
},
destroy: function(){
for (var i = 0; i < this.availHTTP.length; i++) {
this.availHTTP[i] = null;
}
}
};
jpf.BaseComm = function(x){
jpf.makeClass(this);
this.uniqueId = jpf.all.push(this) - 1;
this.$jml      = x;
this.toString = function(){
return "[Javeline Teleport Component : " + (this.name || "")
+ " (" + this.type + ")]";
}
if (this.$jml) {
this.name = x.getAttribute("id");
this.type = x[jpf.TAGNAME];
if (!jpf[this.type]) 
throw new Error(jpf.formatErrorString(1023, null, "Teleport baseclass", "Could not find Javeline Teleport Component '" + this.type + "'", this.$jml));
this.inherit(jpf[this.type]);
if (this.useHTTP) {
if (!jpf.http) 
throw new Error(jpf.formatErrorString(1024, null, "Teleport baseclass", "Could not find Javeline Teleport HTTP Component", this.$jml));
this.inherit(jpf.http);
}
if (this.$jml.getAttribute("protocol")) {
var proto = this.$jml.getAttribute("protocol").toLowerCase();
if (!jpf[proto]) 
throw new Error(jpf.formatErrorString(1025, null, "Teleport baseclass", "Could not find Javeline Teleport RPC Component '" + proto + "'", this.$jml));
this.inherit(jpf[proto]);
}
}
if (this.$jml) 
this.load(this.$jml);
};
jpf.Init.run('Teleport');
jpf.convertIframe = function(iframe, preventSelect){
var win = iframe.contentWindow;
var doc = win.document;
var pos;
if (!jpf.isIE)
jpf.importClass(jpf.runNonIe, true, win);
if (this.isSafari) 
this.importClass(jpf.runSafari, true, win);
if (this.isOpera) 
this.importClass(jpf.runOpera, true, win);
if (this.isGecko || !this.isIE && !this.isSafari && !this.isOpera)
this.importClass(jpf.runGecko, true, win);
doc.onkeydown = function(e){
if (!e) e = win.event;
if (document.onkeydown) 
return document.onkeydown.call(document, e);
};
doc.onmousedown = function(e){
if (!e) e = win.event;
var q = {
offsetX       : e.offsetX,
offsetY       : e.offsetY,
x             : e.x + pos[0],
y             : e.y + pos[1],
button        : e.button,
clientX       : e.x + pos[0],
clientY       : e.y + pos[1],
srcElement    : iframe,
target        : iframe,
targetElement : iframe
}
if (document.body.onmousedown)
document.body.onmousedown(q);
if (document.onmousedown)
document.onmousedown(q);
if (preventSelect && !jpf.isIE)
return false;
};
if (preventSelect) {
doc.onselectstart = function(e){
return false;
};
}
doc.onmouseup = function(e){
if (!e) e = win.event;
if (document.body.onmouseup)
document.body.onmouseup(e);
if (document.onmouseup)
document.onmouseup(e);
};
doc.onclick = function(e){
if (!e) e = win.event;
if (document.body.onclick)
document.body.onclick(e);
if (document.onclick)
document.onclick(e);
};
doc.documentElement.oncontextmenu = function(e){
if (!e) e = win.event;
if (!pos)
pos = jpf.getAbsolutePosition(iframe);
var q = {
offsetX       : e.offsetX,
offsetY       : e.offsetY,
x             : e.x + pos[0],
y             : e.y + pos[1],
button        : e.button,
clientX       : e.x + pos[0],
clientY       : e.y + pos[1],
srcElement    : e.srcElement,
target        : e.target,
targetElement : e.targetElement
};
if (document.body.oncontextmenu)
document.body.oncontextmenu(q);
if (document.oncontextmenu)
document.oncontextmenu(q);
return false;
};
doc.documentElement.onmouseover = function(e){
pos = jpf.getAbsolutePosition(iframe);
};
doc.documentElement.onmousemove = function(e){
if (!e) e = win.event;
if (!pos)
pos = jpf.getAbsolutePosition(iframe);
var q = {
offsetX       : e.offsetX,
offsetY       : e.offsetY,
x             : e.x + pos[0],
y             : e.y + pos[1],
button        : e.button,
clientX       : e.x + pos[0],
clientY       : e.y + pos[1],
srcElement    : e.srcElement,
target        : e.target,
targetElement : e.targetElement
}
if (iframe.onmousemove)
iframe.onmousemove(q);
if (document.body.onmousemove)
document.body.onmousemove(q);
if (document.onmousemove)
document.onmousemove(q);
return e.returnValue;
};
return doc;
};
jpf.checkbox = jpf.component(jpf.NODE_VISIBLE, function(){
this.$notfromext = true;
this.$focussable = true; 
this.checked     = false;
this.$booleanProperties["checked"] = true;
this.$supportedProperties.push("value", "checked", "label", "values");
this.$propHandlers["value"] = function(value){
value = (typeof value == "string" ? value.trim() : value);
this.checked = (value !== undefined
&& value.toString() == this.$values[0].toString());
if (!jpf.isNull(value) && value.toString() == this.$values[0].toString())
this.$setStyleClass(this.oExt, this.baseCSSname + "Checked");
else
this.$setStyleClass(this.oExt, "", [this.baseCSSname + "Checked"]);
};
this.$propHandlers["checked"] = function(value){
this.setProperty("value", this.$values[value ? 1 : 0]);
};
this.$propHandlers["label"] = function(value){
jpf.xmldb.setNodeValue(
this.$getLayoutNode("main", "label", this.oExt), value);
};
this.$propHandlers["values"] = function(value){
this.$values = typeof value == "string"
? value.split("\|")
: (value || [1, 0]);
};
this.setValue = function(value){
if (!this.$values) return;
this.setProperty("value", value);
};
this.getValue = function(){
return this.xmlRoot ? this.$values[this.checked ? 0 : 1] : this.value;
};
this.check = function(){
this.setProperty("value", this.$values[0]);
};
this.uncheck = function(){
this.setProperty("value", this.$values[1]);
};
this.$clear = function(){
this.setProperty("value", this.$values[1]);
}
this.$enable = function(){
if (this.oInt) this.oInt.disabled = false;
this.$doBgSwitch(1);
};
this.$disable = function(){
if (this.oInt) this.oInt.disabled = true;
this.$doBgSwitch(4);
};
this.$setState = function(state, e, strEvent){
if (this.disabled) return;
this.$doBgSwitch(this.states[state]);
this.$setStyleClass(this.oExt, (state != "Out" ? this.baseCSSname + state : ""),
[this.baseCSSname + "Down", this.baseCSSname + "Over"]);
this.state = state; 
this.dispatchEvent(strEvent, e);
};
this.$clickHandler = function(){
this.change(this.$values[(!this.checked) ? 0 : 1]);
this.validate(true);
return true;
};
this.$draw = function(){
this.oExt = this.$getExternal();
this.oInt = this.$getLayoutNode("main", "input", this.oExt);
this.$setupEvents();
};
this.$loadJml = function(x){
if (!this.label && x.firstChild)
this.setProperty("label", x.firstChild.nodeValue);
if (this.$values === undefined)
this.$values = [1, 0];
};
this.$skinchange = function(){
if (this.label)
this.$propHandlers["label"].call(this, this.label);
}
}).implement(
jpf.Validation,
jpf.DataBinding,
jpf.Presentation,
jpf.BaseButton
);
jpf.label = jpf.component(jpf.NODE_VISIBLE, function(){
var _self = this;
this.$focussable = false;
this.setValue = function(value){
this.setProperty("value", value);
};
this.getValue = function(){
return this.value;
}
this.$supportedProperties.push("value", "for");
this.$propHandlers["value"] = function(value){
this.oInt.innerHTML = value;
};
this.$draw = function(){
this.oExt = this.$getExternal();
this.oInt = this.$getLayoutNode("main", "caption", this.oExt);
if (this.oInt.nodeType != 1) 
this.oInt = this.oInt.parentNode;
this.oExt.onmousedown = function(){
var forElement = self[this["for"]];
if (forElement && forElement.$focussable && forElement.focussable)
forElement.focus();
}
};
this.$loadJml = function(x){
if (jpf.xmldb.isOnlyChild(x.firstChild, [3,4]))
this.$handlePropSet("value", x.firstChild.nodeValue.trim());
else
jpf.JmlParser.parseChildren(this.$jml, this.oInt, this);
};
}).implement(
jpf.DataBinding,
jpf.BaseSimple
)
jpf.StateServer = {
states: {},
groups: {},
locs  : {},
removeGroup: function(name, elState){
this.groups[name].remove(elState);
if (!this.groups[name].length) {
if (self[name]) {
self[name].destroy();
self[name] = null;
}
delete this.groups[name];
}
},
addGroup: function(name, elState, pNode){
if (!this.groups[name]) {
this.groups[name] = [];
var pState = new jpf.state(null, "state");
pState.parentNode = pNode;
pState.inherit(jpf.JmlDom);
pState.name   = name;
pState.toggle = function(){
for (var next = 0, i = 0; i < jpf.StateServer.groups[name].length; i++) {
if (jpf.StateServer.groups[name][i].active) {
next = i + 1;
break;
}
}
jpf.StateServer.groups[name][
(next == jpf.StateServer.groups[name].length) ? 0 : next
].activate();
}
this.groups[name].pState = self[name] = pState;
}
if (elState)
this.groups[name].push(elState);
return this.groups[name].pState;
},
removeState: function(elState){
delete this.states[elState.name];
},
addState: function(elState){
this.states[elState.name] = elState;
}
}
jpf.state = jpf.component(jpf.NODE_HIDDEN, function(){
this.$supportedProperties.push("active");
this.$propHandlers["active"] = function(value){
if (jpf.isTrue(value)) {
if (this.group) {
var nodes = jpf.StateServer.groups[this.group];
for (var i = 0; i < nodes.length; i++) {
if (nodes[i] != this && nodes[i].active !== false)
nodes[i].deactivate();
}
}
var q = this.$signalElements;
for (var i = 0; i < q.length; i++) {
self[q[i][0]].setProperty(q[i][1], this[q[i].join(".")]);
}
if (this.group) {
var attr = this.$jml.attributes;
for (var i = 0; i < attr.length; i++) {
if (attr[i].nodeName.match(/^on|^(?:group|id)$|^.*\..*$/))
continue;
self[this.group].setProperty(attr[i].nodeName,
attr[i].nodeValue);
}
}
this.dispatchEvent("change");
}
else {
this.setProperty("active", false);
this.dispatchEvent("change");
}
};
this.setValue = function(value){
this.active = 9999;
this.setProperty("active", value);
};
this.activate = function(){
this.active = 9999;
this.setProperty("active", true);
};
this.deactivate = function(){
this.setProperty("active", false);
};
this.$signalElements = [];
this.$loadJml = function(x){
jpf.StateServer.addState(this);
this.group = x.getAttribute("group");
if (this.group)
jpf.StateServer.addGroup(this.group, this);
if (x.getAttribute("location"))
jpf.StateServer.locs[x.getAttribute("location")] = this;
var attr = x.attributes;
for (var s, i = 0; i < attr.length; i++) {
if (attr[i].nodeName.match(/^on|^(?:group|id)$/))
continue;
s = attr[i].nodeName.split(".");
if (s.length == 2)
this.$signalElements.push(s);
this[attr[i].nodeName] = attr[i].nodeValue;
}
};
this.$destroy = function(){
this.$signalElements = null;
jpf.StateServer.removeState(this);
if (this.group)
jpf.StateServer.removeGroup(this.group, this);
};
});
jpf.appsettings = {
tagName            : "appsettings",
nodeType           : jpf.NODE_ELEMENT,
nodeFunc           : jpf.NODE_HIDDEN,
disableRightClick  : false,
allowSelect        : false,
allowBlur          : false,
autoDisableActions : false,
autoDisable        : false, 
disableF5          : true,
autoHideLoading    : true,
disableSpace       : true,
disableBackspace   : true,
useUndoKeys        : false,
outline            : false,
dragOutline        : false,
resizeOutline      : false,
disableTabbing     : false,
skinset            : "default",
name               : "",
tags               : {},
defaults           : {},
init : function(){
},
getDefault : function(type, prop){
var d = this.defaults[type];
if (!d)
return;
for (var i = d.length - 1; i >= 0; i--) {
if (d[i][0] == prop)
return d[i][1];
}
},
setProperty : function(name, value){
if (name == "outline") {
this.dragOutline   =
this.resizeOutline =
this.outline       = value;
}
else if (name == "skinset") {
this.skinset = value;
jpf.skins.changeSkinset(value);
}
},
loadJml: function(x, parentNode){
this.$jml = x;
this.parentNode = parentNode;
jpf.inherit.call(this, jpf.JmlDom); 
jpf.debug = jpf.isTrue(x.getAttribute("debug"));
if (x.getAttribute("debug-type"))
jpf.debugType = x.getAttribute("debug-type");
var nodes = x.attributes;
for (var i = 0, l = nodes.length; i < l; i++) {
this.tags[nodes[i].nodeName] = nodes[i].nodeValue;
}
this.name               = x.getAttribute("name")
|| window.location.href.replace(/[^0-9A-Za-z_]/g, "_");
this.baseurl            = jpf.parseExpression(x.getAttribute("baseurl") || "");
this.disableRightClick  = jpf.isTrue(x.getAttribute("disable-right-click"));
this.allowSelect        = jpf.isTrue(x.getAttribute("allow-select"));
this.allowBlur          = !jpf.isFalse(x.getAttribute("allow-blur"));
this.autoDisableActions = jpf.isTrue(x.getAttribute("auto-disable-actions"));
this.autoDisable        = jpf.isTrue(x.getAttribute("auto-disable")); 
this.disableF5          = jpf.isTrue(x.getAttribute("disable-f5"));
this.autoHideLoading    = !jpf.isFalse(x.getAttribute("auto-hide-loading"));
this.disableSpace       = !jpf.isFalse(x.getAttribute("disable-space"));
this.disableBackspace   = jpf.isTrue(x.getAttribute("disable-backspace"));
this.useUndoKeys        = jpf.isTrue(x.getAttribute("undokeys"));
this.queryAppend        = x.getAttribute("query-append");
if (x.getAttribute("outline")) {
this.dragOutline    =
this.resizeOutline  =
this.outline        = jpf.isTrue(jpf.parseExpression(x.getAttribute("outline")));
}
else {
this.dragOutline    = x.getAttribute("drag-outline")
? jpf.isTrue(jpf.parseExpression(x.getAttribute("drag-outline")))
: false;
this.resizeOutline  = x.getAttribute("resize-outline")
? !jpf.isFalse(jpf.parseExpression(x.getAttribute("resize-outline")))
: false;
}
this.layout  = x.getAttribute("layout") || null;
this.skinset = x.getAttribute("skinset") || "default";
var oFor, attr, d, j, i, l, node, nodes = x.childNodes;
for (i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
if (node.nodeType != 1)
continue;
var tagName = node[jpf.TAGNAME];
switch(tagName){
case "printer":
jpf.printer.init(node);
break;
default:
break;
}
}
return this;
}
};
jpf.video.TypeSilverlight = function(oVideo, node, options) {
this.oVideo         = oVideo;
if (!jpf.video.TypeSilverlight.INITED) {
jpf.silverlight.startup();
jpf.video.TypeSilverlight.INITED = true;
}
this.DEFAULT_PLAYER = jpf.basePath + "resources/wmvplayer.xaml";
this.htmlElement    = node;
this.options        = {
backgroundcolor: "000000",
windowless:      "false",
file:            "",
image:           "",
backcolor:       "000000",
frontcolor:      "FFFFFF",
lightcolor:      "FFFFFF",
screencolor:     "FFFFFF",
width:           "100%",
height:          "100%",
logo:            "",
overstretch:     "true",
shownavigation:  "false",
showstop:        "false",
showdigits:      "true",
usefullscreen:   "true",
usemute:         "false",
autostart:       "true",
bufferlength:    "3",
duration:        "0",
repeat:          "false",
sender:          "",
start:           "0",
volume:          "90",
link:            "",
linkfromdisplay: "false",
linktarget:      "_self"
};
this.options.file = options.src;
for (var itm in this.options) {
if (options[itm] != undefined) {
if (itm.indexOf("color") > 0)
this.options[itm] = options[itm].substr(options[itm].length - 6);
else
this.options[itm] = options[itm];
}
}
jpf.silverlight.createObjectEx({
id:            this.oVideo.uniqueId + "_Player",
source:        this.DEFAULT_PLAYER,
parentElement: node,
properties:    {
width:                "100%",
height:               "100%",
version:              "1.0",
inplaceInstallPrompt: true,
isWindowless:         this.options["windowless"],
background:           "#" + this.options["backgroundcolor"]
},
events:        {
onLoad:  this.onLoadHandler,
onError: jpf.silverlight.default_error_handler
},
context:       this
});
jpf.layout.setRules(this.oVideo.oExt, this.oVideo.uniqueId + "_silverlight",
"jpf.all[" + this.oVideo.uniqueId + "].player.resizePlayer()");
};
jpf.video.TypeSilverlight.isSupported = function(){
return jpf.silverlight.isAvailable("1.0");
};
jpf.video.TypeSilverlight.INITED = false;
jpf.video.TypeSilverlight.prototype = {
load: function(videoPath) {
this.video.Source = this.options["file"];
this.oVideo.$readyHook({ type: "ready" });
if (this.options["usemute"] == "true")
this.setVolume(0);
else
this.setVolume(this.options["volume"]);
if (this.options["autostart"] == "true")
this.play();
else
this.pause();
return this;
},
play: function() {
if (this.state == "buffering" || this.state == "playing") {
if (this.options["duration"] == 0)
this.stop();
else
this.pause();
}
else {
this.video.Visibility   = "Visible";
this.preview.Visibility = "Collapsed";
if (this.state == "closed")
this.video.Source = this.options["file"];
else
this.video.play();
}
return this;
},
pause: function() {
if (!this.video) return this;
this.video.pause();
return this;
},
stop: function() {
if (!this.video) return;
this.stopPlayPoll();
this.video.Visibility   = "Collapsed";
this.preview.Visibility = "Visible";
this.pause().seek(0);
this.video.Source = "null";
return this;
},
seek: function(iTo) {
if (!this.video) return;
this.stopPlayPoll();
if (iTo < 2)
iTo = 0;
else if (iTo > this.options["duration"] - 4)
iTo = this.options["duration"] - 4;
if (!isNaN(iTo)) {
try{ 
this.video.Position = this.oVideo.getCounter(iTo, "%H:%M:%S");
}
catch(e){}
}
if (this.state == "buffering" || this.state == "playing")
this.play();
else
this.pause();
return this;
},
setVolume: function(iVolume) {
if (!this.video) return;
this.video.Volume = iVolume / 100;
return this;
},
getTotalTime: function() {
if (!this.video) return 0;
return this.options["duration"] || 0;
},
spanstring: function(stp) {
var hrs = Math.floor(stp / 3600);
var min = Math.floor(stp % 3600 / 60);
var sec = Math.round(stp % 60 * 10) / 10;
var str = hrs + ":" + min + ":" + sec;
return str;
},
onLoadHandler: function(pId, _self, sender) {
_self.options["sender"] = sender;
_self.video   = _self.options["sender"].findName("VideoWindow");
_self.preview = _self.options["sender"].findName("PlaceholderImage");
var str = {
"true" : "UniformToFill",
"false": "Uniform",
"fit"  : "Fill",
"none" : "None"
}
_self.state = _self.video.CurrentState.toLowerCase();
_self.pollTimer;
_self.video.Stretch   = str[_self.options["overstretch"]];
_self.preview.Stretch = str[_self.options["overstretch"]];
_self.display               = sender.findName("PlayerDisplay");
_self.display.Visibility    = "Visible";
_self.video.BufferingTime = _self.spanstring(_self.options["bufferlength"]);
_self.video.AutoPlay      = true;
_self.video.AddEventListener("CurrentStateChanged", function() {
_self.handleState("CurrentStateChanged");
});
_self.video.AddEventListener("MediaEnded", function() {
_self.handleState("MediaEnded");
});
_self.video.AddEventListener("DownloadProgressChanged", function(o) {
_self.oVideo.$progressHook({
bytesLoaded: Math.round(o.downloadProgress * 100), 
totalBytes : 100
});
});
if (_self.options["image"] != "")
_self.preview.Source = _self.options["image"];
_self.resizePlayer();
_self.oVideo.$initHook({state: _self.state});
},
handleState: function(sEvent) {
var state = this.video.CurrentState.toLowerCase();
if (sEvent == "MediaEnded") {
this.stopPlayPoll();
this.oVideo.$changeHook({
type        : "change",
playheadTime: Math.round(this.video.Position.Seconds * 1000)
});
if (this.options["repeat"] == "true") {
this.seek(0).play();
} else {
this.state              = "completed";
this.video.Visibility   = "Collapsed";
this.preview.Visibility = "Visible";
this.seek(0).pause().oVideo.$completeHook({ type: "complete" });
}
}
else if (state != this.state) {
this.state = state;
this.options["duration"] = Math.round(this.video.NaturalDuration.Seconds * 1000);
if (state != "playing" && state != "buffering" && state != "opening") {
this.oVideo.$stateChangeHook({type: "stateChange", state: "paused"});
this.stopPlayPoll();
}
else {
this.oVideo.$stateChangeHook({type: "stateChange", state: "playing"});
this.startPlayPoll();
}
}
},
startPlayPoll: function() {
clearTimeout(this.pollTimer);
var _self = this;
this.pollTimer = setTimeout(function() {
if (_self.oVideo && !_self.oVideo.ready && _self.video.CanSeek)
_self.oVideo.setProperty("readyState", jpf.Media.HAVE_ENOUGH_DATA);
_self.oVideo.$changeHook({
type        : "change",
playheadTime: Math.round(_self.video.Position.Seconds * 1000)
});
_self.startPlayPoll();
}, 100);
return this;
},
stopPlayPoll: function() {
clearTimeout(this.pollTimer);
return this;
},
resizePlayer: function() {
var oSender  = this.options["sender"];
if (!oSender) return;
var oContent = this.display.getHost().content;
var width    = oContent.actualWidth;
var height   = oContent.actualHeight;
this.stretchElement("PlayerDisplay", width, height)
.stretchElement("VideoWindow", width,height)
.stretchElement("PlaceholderImage", width, height)
.centerElement("BufferIcon", width, height)
.centerElement("BufferText", width, height)
this.display.findName("OverlayCanvas")["Canvas.Left"] = width -
this.display.findName("OverlayCanvas").Width - 10;
this.display.Visibility = "Visible";
return this;
},
centerElement: function(sName, iWidth, iHeight) {
var elm = this.options["sender"].findName(sName);
elm["Canvas.Left"] = Math.round(iWidth  / 2 - elm.Width  / 2);
elm["Canvas.Top"]  = Math.round(iHeight / 2 - elm.Height / 2);
return this;
},
stretchElement: function(sName, iWidth, iHeight) {
var elm = this.options["sender"].findName(sName);
elm.Width = iWidth;
if (iHeight != undefined)
elm.Height = iHeight;
return this;
},
$destroy: function() {
jpf.layout.removeRule(this.oVideo.oExt, this.oVideo.uniqueId + "_silverlight");
this.stopPlayPoll();
if (this.player) {
this.player = this.video = this.preview = null;
delete this.player;
delete this.video;
delete this.preview
}
this.htmlElement.innerHTML = "";
this.oVideo = this.htmlElement = null;
delete this.oVideo;
delete this.htmlElement;
}
};
jpf.video.TypeFlv = function(oVideo, node, options) {
this.oVideo              = oVideo;
this.DEFAULT_SWF_PATH    = jpf.basePath + "resources/FAVideo.swf";
this.id = jpf.flash.addPlayer(this); 
this.inited       = false;
this.resizeTimer  = null;
this.divName      = this.oVideo.uniqueId;
this.htmlElement  = node;
this.name         = "FAVideo_" + this.oVideo.uniqueId;
this.videoPath    = options.src;
this.width        = "100%"; 
this.height       = "100%"; 
this.player = null;
jpf.extend(this, jpf.video.TypeInterface);
this.initProperties().setOptions(options).createPlayer();
}
jpf.video.TypeFlv.isSupported = function() {
return jpf.flash.isAvailable();
};
jpf.video.TypeFlv.prototype = {
load: function(videoPath, totalTime) {
videoPath = videoPath.splitSafe(",")[this.oVideo.$lastMimeType] || videoPath;
if (totalTime != null)
this.setTotalTime(totalTime);
if (videoPath != null)
this.videoPath = videoPath;
if (this.videoPath == null && !this.firstLoad)
return this.oVideo.$errorHook({type:"error", error:"FAVideo::play - No videoPath has been set."});
if (videoPath == null && this.firstLoad && !this.autoLoad) 
videoPath = this.videoPath;
this.firstLoad = false;
if (this.autoPlay)
this.callMethod("playVideo", videoPath, totalTime);
else
this.callMethod("loadVideo", this.videoPath);
return this;
},
play: function() {
return this.pause(false);
},
pause: function(pauseState) {
if (typeof pauseState == "undefined")
pauseState = true;
this.callMethod("pause", pauseState);
return this;
},
stop: function() {
this.callMethod("stop");
return this;
},
seek: function(millis) {
this.callMethod("seek", millis / 1000);
return this;
},
setVolume: function(iVolume) {
this.callMethod("setVolume", iVolume);
return this;
},
onResize: function() {
clearTimeout(this.resizeTimer);
var _self = this;
this.resizeTimer = window.setTimeout(function() {
_self.setSize();
}, 20);
},
setSize: function() {
this.callMethod("setSize", this.htmlElement.offsetWidth,
this.htmlElement.offsetHeight);
return this;
},
getPlayheadTime: function() {
return this.playheadTime;
},
setPlayheadTime: function(value) {
return this.setProperty("playheadTime", value);
},
getTotalTime: function() {
return this.totalTime;
},
setTotalTime: function(value) {
return this.setProperty("totalTime", value);
},
callMethod: function(param1, param2, param3) {
if (this.inited && this.player && this.player.callMethod)
this.player.callMethod(param1, param2, param3); 
else
this.delayCalls.push(arguments);
},
makeDelayCalls: function() {
for (var i = 0; i < this.delayCalls.length; i++)
this.callMethod.apply(this, this.delayCalls[i]);
return this;
},
update: function(props) {
for (var n in props) {
if (n.indexOf("Time") != -1 && typeof props[n] == "number")
props[n] = props[n] * 1000;
this[n] = props[n]; 
}
props.type = "change";
this.oVideo.$changeHook(props); 
},
event: function(eventName, evtObj) {
switch (eventName) {
case "progress":
this.bytesLoaded = evtObj.bytesLoaded;
this.totalBytes  = evtObj.bytesTotal;
this.oVideo.$progressHook({
type       : "progress",
bytesLoaded: this.bytesLoaded,
totalBytes : this.totalBytes
});
break;
case "playheadUpdate":
this.playheadTime = evtObj.playheadTime * 1000;
this.totalTime    = evtObj.totalTime * 1000;
this.oVideo.$playheadUpdateHook({
type        : "playheadUpdate",
playheadTime: this.playheadTime,
totalTime   : this.totalTime
});
break;
case "stateChange":
this.state = evtObj.state;
this.oVideo.$stateChangeHook({type:"stateChange", state:this.state});
break;
case "change":
this.oVideo.$changeHook({type:"change"});
break;
case "complete":
this.oVideo.$completeHook({type:"complete"});
break;
case "ready":
this.oVideo.$readyHook({type:"ready"});
break;
case "metaData":
this.oVideo.$metadataHook({type:"metadata", infoObject:evtObj});
break;
case "cuePoint":
this.oVideo.$cuePointHook({type:"cuePoint", infoObject:evtObj});
break;
case "fullscreen":
jpf.console.log('fullscreen: ', evtObj.state);
this.oVideo.fullscreen = false;
case "init":
this.inited = true;
this.invalidateProperty("clickToTogglePlay", "skinVisible",
"skinAutoHide", "autoPlay", "autoLoad", "volume", "bufferTime",
"videoScaleMode", "videoAlign", "playheadUpdateInterval",
"previewImagePath").validateNow().makeDelayCalls();
this.oVideo.$initHook({type:"init"});
this.onResize();
var node = this.oVideo.oInt;
setTimeout(function() {
jpf.layout.forceResize(node);
}, 1000);
break;
}
},
initProperties: function() {
this.delayCalls = [];
this.videoWidth = this.videoHeight = this.totalTime = this.bytesLoaded = this.totalBytes = 0;
this.state = null;
this.clickToTogglePlay = this.autoPlay = this.autoLoad = this.skinVisible = true;
this.volume                 = 50;
this.skinVisible            = false;
this.skinAutoHide           = false;
this.playheadTime           = null;
this.bufferTime             = 0.1;
this.videoScaleMode         = "maintainAspectRatio"; 
this.videoAlign             = "center";
this.playheadUpdateInterval = 1000;
this.previewImagePath       = this.themeColor = null
this.firstLoad   = true;
this.pluginError = false;
this.properties = ["volume", "skinAutoHide", "showControls", "autoPlay",
"clickToTogglePlay", "autoLoad", "playHeadTime", "totalTime",
"bufferTime", "videoScaleMode", "videoAlign", "playheadUpdateInterval",
"previewImagePath"];
jpf.layout.setRules(this.oVideo.oExt, this.oVideo.uniqueId + "_favideo",
"(jpf.all[" + this.oVideo.uniqueId + "].player || {onResize:jpf.K}).onResize()");
jpf.layout.activateRules(this.oVideo.oExt);
return this;
},
createPlayer: function() {
var content = jpf.flash.buildContent(
"src",              this.DEFAULT_SWF_PATH,
"width",            "100%",
"height",           "100%",
"align",            "middle",
"id",               this.name,
"quality",          "high",
"bgcolor",          "#000000",
"allowFullScreen",  "true",
"name",             this.name,
"flashvars",        "playerID=" + this.id + "&volume=" + this.volume
,
"allowScriptAccess","always",
"type",             "application/x-shockwave-flash",
"pluginspage",      "http://www.adobe.com/go/getflashplayer",
"menu",             "true");
if (this.htmlElement == null) return this;
this.pluginError = false;
this.htmlElement.innerHTML = content;
this.player    = this.getElement(this.name);
this.container = this.getElement(this.name + "_Container");
return this;
},
invalidateProperty: function() {
if (this.invalidProperties == null)
this.invalidProperties = {};
for (var i = 0; i < arguments.length; i++)
this.invalidProperties[arguments[i]] = true;
if (this.validateInterval == null && this.inited) {
var _this = this;
this.validateInterval = setTimeout(function() {
_this.validateNow();
}, 100);
}
return this;
},
validateNow: function() {
this.validateInterval = null;
var props = {};
for (var n in this.invalidProperties)
props[n] = this[n];
this.invalidProperties = {};
this.callMethod("update", props);
return this;
},
setProperty: function(property, value) {
this[property] = value; 
if (this.inited)
this.invalidateProperty(property); 
return this;
},
$destroy: function() {
jpf.layout.removeRule(this.oVideo.oExt, this.oVideo.uniqueId + "_favideo");
if (this.player) {
try {
this.stop();
}
catch(e) {}
this.player = this.container = null;
delete this.player;
delete this.container;
}
this.htmlElement.innerHTML = "";
this.oVideo = this.htmlElement = null;
delete this.oVideo;
delete this.htmlElement;
}
};
jpf.video.TypeWmpCompat = (function() {
var hasWMP = false;
function WMP_getVersion() {
var is_WMP64  = false,
is_WMP7up = false;
if (jpf.isWin && jpf.isIE) {  
var oMP;
try {
oMP      = new ActiveXObject("MediaPlayer.MediaPlayer.1");
hasWMP   = true;
is_WMP64 = true;
}
catch (objError) {
hasWMP   = false;
is_WMP64 = false;
}
if (hasWMP) {
try {
oMP       = new ActiveXObject("WMPlayer.OCX");
is_WMP7up = true;
}
catch (objError) {
is_WMP7up = false;
}
}
}
else {  
for (var i = 0, j = navigator.plugins.length; i < j; i++) {
if (navigator.plugins[i].name.indexOf("Windows Media Player") != -1) {
hasWMP    = true;
is_WMP64  = true;
is_WMP7up = true; 
oMP       = { versionInfo: "7.3" };
}
}
}
var WMPVer;
if (is_WMP7up) {
WMPVer = oMP.versionInfo;
oMP    = null;
}
else
WMPVer = "6.4";
return parseFloat(WMPVer);
}
function WMP_generateParamTag(name, value) {
if (!name || !value) return "";
return '<param name="' + name + '" value="' + value + '" />';
}
function WMP_generateOBJECTText(id, url, width, height, params) {
params.URL = url;
params.src = url;
params.SendPlayStateChangeEvents = "true";
params.StretchToFit = "true";
var out = ['<object id="', id, '" width="', width, '" height="', height, '" \
classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" \
type="application/x-oleobject">'];
var emb = ['<embed id="', id, 'emb" width="', width, '" height="', height, '"'];
for (var param in params) {
if (!param || !params[param]) continue;
out.push('<param name="', param, '" value="', params[param], '" />');
emb.push(' ', param, '="', params[param], '"');
}
return out.join("") + emb.join("") + " /></object>";
}
var bIsAvailable = null;
function WMP_isAvailable() {
if (bIsAvailable === null)
bIsAvailable = WMP_getVersion() >= 7 && hasWMP;
return bIsAvailable;
}
return  {
isAvailable       : WMP_isAvailable,
generateOBJECTText: WMP_generateOBJECTText
}
})();
jpf.video.TypeWmp = function(oVideo, node, options) {
this.oVideo      = oVideo;
this.name        = "WMP_" + this.oVideo.uniqueId;
this.htmlElement = node;
this.player    = this.pollTimer = null;
this.volume    = 50; 
this.videoPath = options.src;
jpf.extend(this, jpf.video.TypeInterface);
this.setOptions(options);
var _self = this;
window.setTimeout(function() {
_self.oVideo.$initHook({state: 1});
}, 1);
};
jpf.video.TypeWmp.isSupported = function(){
return jpf.video.TypeWmpCompat.isAvailable();
};
jpf.video.TypeWmp.prototype = {
load: function(videoPath) {
this.videoPath = videoPath.splitSafe(",")[this.oVideo.$lastMimeType] || videoPath;
return this.$draw();
},
play: function() {
if (this.player)
this.player.controls.play();
return this;
},
pause: function() {
if (this.player)
this.player.controls.pause();
return this;
},
stop: function() {
if (this.player)
this.player.controls.stop();
return this;
},
seek: function(iTo) {
if (this.player) {
this.player.controls.pause(); 
this.player.controls.currentPosition = iTo / 1000;
if (!this.oVideo.paused)
this.player.controls.play(); 
}
return this;
},
fullscreen : function(value){
this.player.fullscreen = value ? true : false;
},
setVolume: function(iVolume) {
if (this.player)
this.player.settings.volume = iVolume;
return this;
},
getTotalTime: function() {
if (!this.player)
return 0;
return Math.round(this.player.controls.currentItem.duration * 1000);
},
$draw: function() {
if (this.player) {
this.stopPlayPoll();
delete this.player;
this.player = null;
}
var playerId = this.name + "_Player";
this.htmlElement.innerHTML = jpf.video.TypeWmpCompat.generateOBJECTText(playerId,
this.videoPath, "100%", "100%", {
"AutoStart": this.autoPlay.toString(),
"uiMode"   : this.showControls ? "mini" : "none",
"PlayCount": 1 
});
this.player = this.getElement(playerId);
var _self = this;
try {
this.player[window.addEventListener ? "addEventListener" : "attachEvent"]("PlayStateChange", function(iState) {
_self.handleEvent(iState);
});
} catch (e) {
this.player.onplaystatechange = function(iState) {
_self.handleEvent(iState);
}
}
return this;
},
handleEvent: function(iState) {
switch (iState) {
case 1:   
case 8:   
this.oVideo.$completeHook({type: "complete"});
this.stopPlayPoll();
break;
case 2:   
this.oVideo.$stateChangeHook({type: "stateChange", state: "paused"});
this.stopPlayPoll();
break;
case 3:   
this.oVideo.$stateChangeHook({type: "stateChange", state: "playing"})
if (!this.oVideo.ready)
this.oVideo.setProperty("readyState", jpf.Media.HAVE_ENOUGH_DATA);
this.startPlayPoll();
break;
case 10:  
this.oVideo.$stateChangeHook({type: "ready"});
break;
case 4:  
case 5:  
case 6:  
case 7:  
case 9:  
case 11: 
break;
}
return this;
},
startPlayPoll: function() {
clearTimeout(this.pollTimer);
var _self = this;
this.pollTimer = setTimeout(function() {
if (!_self.player || !_self.player.controls) return;
_self.oVideo.$changeHook({
type        : "change",
playheadTime: Math.round(_self.player.controls.currentPosition * 1000)
});
_self.startPlayPoll();
}, 200);
return this;
},
stopPlayPoll: function() {
clearTimeout(this.pollTimer);
return this;
},
$destroy: function() {
this.stopPlayPoll();
if (this.player) {
try {
this.player.controls.stop();
} catch(e) {}
this.player = null;
delete this.player;
}
this.htmlElement.innerHTML = "";
this.oVideo = this.htmlElement = null;
delete this.oVideo;
delete this.htmlElement;
}
};
jpf.video.TypeQTCompat = (function(){
var gTagAttrs           = null;
var gQTBehaviorID       = "qt_event_source";
var gQTEventsEnabled    = true;
function _QTGenerateBehavior(){
return jpf.isIE
? '<object id="' + gQTBehaviorID
+ '" classid="clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598" \
codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=7,3,0,0"></object>'
: '';
}
function _QTPageHasBehaviorObject(callingFcnName, args){
var haveBehavior = false;
var objects = document.getElementsByTagName("object");
for (var ndx = 0, obj; obj = objects[ndx]; ndx++) {
if (obj.getAttribute("classid") == "clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598") {
if (obj.getAttribute("id") == gQTBehaviorID)
haveBehavior = false;
break;
}
}
return haveBehavior;
}
function _QTShouldInsertBehavior(){
var shouldDo = false;
if (gQTEventsEnabled && jpf.isIE && !_QTPageHasBehaviorObject())
shouldDo = true;
return shouldDo;
}
function _QTAddAttribute(prefix, slotName, tagName){
var value;
value = gTagAttrs[prefix + slotName];
if (null == value)
value = gTagAttrs[slotName];
if (null != value) {
if (0 == slotName.indexOf(prefix) && (null == tagName))
tagName = slotName.substring(prefix.length);
if (null == tagName)
tagName = slotName;
return ' ' + tagName + '="' + value + '"';
}
else
return "";
}
function _QTAddObjectAttr(slotName, tagName){
if (0 == slotName.indexOf("emb#"))
return "";
if (0 == slotName.indexOf("obj#") && (null == tagName))
tagName = slotName.substring(4);
return _QTAddAttribute("obj#", slotName, tagName);
}
function _QTAddEmbedAttr(slotName, tagName){
if (0 == slotName.indexOf("obj#"))
return "";
if (0 == slotName.indexOf("emb#") && (null == tagName))
tagName = slotName.substring(4);
return _QTAddAttribute("emb#", slotName, tagName);
}
function _QTAddObjectParam(slotName, generateXHTML){
var paramValue;
var paramStr = "";
var endTagChar = (generateXHTML) ? " />" : ">";
if (-1 == slotName.indexOf("emb#")) {
paramValue = gTagAttrs["obj#" + slotName];
if (null == paramValue)
paramValue = gTagAttrs[slotName];
if (0 == slotName.indexOf("obj#"))
slotName = slotName.substring(4);
if (null != paramValue)
paramStr = '<param name="' + slotName + '" value="' + paramValue + '"' + endTagChar;
}
return paramStr;
}
function _QTDeleteTagAttrs(){
for (var ndx = 0; ndx < arguments.length; ndx++) {
var attrName = arguments[ndx];
delete gTagAttrs[attrName];
delete gTagAttrs["emb#" + attrName];
delete gTagAttrs["obj#" + attrName];
}
}
function _QTGenerate(callingFcnName, generateXHTML, args){
gTagAttrs = {
src        : args[0],
width      : args[1],
height     : args[2],
classid    : "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B",
pluginspage: "http://www.apple.com/quicktime/download/"
};
var activexVers = args[3]
if ((null == activexVers) || ("" == activexVers))
activexVers = "7,3,0,0";
gTagAttrs["codebase"] = "http://www.apple.com/qtactivex/qtplugin.cab#version=" + activexVers;
var attrName, attrValue;
for (var ndx = 4; ndx < args.length; ndx += 2) {
attrName = args[ndx].toLowerCase();
attrValue = args[ndx + 1];
gTagAttrs[attrName] = attrValue;
if (("postdomevents" == attrName) && (attrValue.toLowerCase() != "false")) {
gQTEventsEnabled = true;
if (jpf.isIE)
gTagAttrs["obj#style"] = "behavior:url(#" + gQTBehaviorID + ")";
}
}
var objTag = ["<object ",
_QTAddObjectAttr("classid"),
_QTAddObjectAttr("width"),
_QTAddObjectAttr("height"),
_QTAddObjectAttr("codebase"),
_QTAddObjectAttr("name"),
_QTAddObjectAttr("id"),
_QTAddObjectAttr("tabindex"),
_QTAddObjectAttr("hspace"),
_QTAddObjectAttr("vspace"),
_QTAddObjectAttr("border"),
_QTAddObjectAttr("align"),
_QTAddObjectAttr("class"),
_QTAddObjectAttr("title"),
_QTAddObjectAttr("accesskey"),
_QTAddObjectAttr("noexternaldata"),
_QTAddObjectAttr("obj#style"),
">",
_QTAddObjectParam("src", generateXHTML)];
var embedTag = ["<embed ",
_QTAddEmbedAttr("src"),
_QTAddEmbedAttr("width"),
_QTAddEmbedAttr("height"),
_QTAddEmbedAttr("pluginspage"),
_QTAddEmbedAttr("name"),
_QTAddEmbedAttr("id"),
_QTAddEmbedAttr("align"),
_QTAddEmbedAttr("tabindex")];
_QTDeleteTagAttrs("src", "width", "height", "pluginspage", "classid",
"codebase", "name", "tabindex", "hspace", "vspace", "border",
"align", "noexternaldata", "class", "title", "accesskey", "id", "style");
for (var attrName in gTagAttrs) {
attrValue = gTagAttrs[attrName];
if (null != attrValue) {
embedTag.push(_QTAddEmbedAttr(attrName));
objTag.push(_QTAddObjectParam(attrName, generateXHTML));
}
}
return objTag.join("") + embedTag.join("") + "></em" + "bed></ob" + "ject" + ">";
}
function QT_GenerateOBJECTText(){
var txt = _QTGenerate("QT_GenerateOBJECTText_XHTML", true, arguments);
if (_QTShouldInsertBehavior())
txt = _QTGenerateBehavior() + txt;
return txt;
}
function QT_IsInstalled(){
var U = false;
if (navigator.plugins && navigator.plugins.length) {
for(var M = 0; M < navigator.plugins.length; M++) {
var g = navigator.plugins[M];
if (g.name.indexOf("QuickTime") > -1)
U = true;
}
}
else {
qtObj = false;
execScript("on error resume next: qtObj = IsObject(CreateObject(\"QuickTimeCheckObject.QuickTimeCheck.1\"))", "VBScript");
U = qtObj;
}
return U;
}
function QT_GetVersion() {
var U = "0";
if (navigator.plugins && navigator.plugins.length) {
for (var g = 0; g < navigator.plugins.length; g++) {
var S = navigator.plugins[g];
var M = S.name.match(/quicktime\D*([\.\d]*)/i);
if (M && M[1])
U = M[1];
}
}
else {
ieQTVersion = null;
execScript("on error resume next: ieQTVersion = CreateObject(\"QuickTimeCheckObject.QuickTimeCheck.1\").QuickTimeVersion", "VBScript");
if (ieQTVersion) {
var temp = "";
U = (ieQTVersion).toString(16) / 1000000 + "";
temp += parseInt(U) + ".";
temp += ((parseFloat(U) - parseInt(U)) * 1000) / 100 + "";
U = temp;
}
}
return U;
}
function QT_IsCompatible(g, j){
function M(w, R) {
var i = parseInt(w[0], 10);
if (isNaN(i))
i = 0;
var V = parseInt(R[0], 10);
if (isNaN(V))
V = 0;
if (i === V) {
if (w.length > 1)
return M(w.slice(1), R.slice(1));
else
return true;
}
else
return (i < V);
}
var S = g.split(/\./);
var U = j ? j.split(/\./) : QT_GetVersion().split(/\./);
return M(S, U);
}
var aIsAvailable = {};
function QT_IsValidAvailable(sVersion) {
if (typeof sVersion == "undefined")
sVersion = "7.2.1";
if (typeof aIsAvailable[sVersion] == "undefined")
aIsAvailable[sVersion] = QT_IsInstalled() && QT_IsCompatible(sVersion);
return aIsAvailable[sVersion];
}
return {
generateOBJECTText: QT_GenerateOBJECTText,
isAvailable       : QT_IsValidAvailable
};
})();
jpf.video.TypeQT = function(oVideo, node, options) {
this.oVideo      = oVideo;
this.name        = "QT_" + this.oVideo.uniqueId;
this.htmlElement = node;
this.videoWidth = this.videoHeight = this.totalTime =
this.bytesLoaded = this.totalBytes = 0;
this.state = null;
this.autoPlay = this.autoLoad = this.showControls = true;
this.volume   = 50;
this.mimeType = "video/quicktime";
this.firstLoad   = true;
this.pluginError = false;
this.pollTimer   = null;
this.videoPath   = options.src;
this.player = null;
jpf.extend(this, jpf.video.TypeInterface);
this.setOptions(options);
var _self = this;
window.setTimeout(function() {
_self.oVideo.$initHook({state: 1});
}, 1);
}
jpf.video.TypeQT.isSupported = function() {
return jpf.video.TypeQTCompat.isAvailable();
}
jpf.video.TypeQT.prototype = {
load: function(videoPath) {
this.videoPath = videoPath.splitSafe(",")[this.oVideo.$lastMimeType] || videoPath;
return this.$draw().attachEvents();
},
play: function() {
if (this.player) {
try {
this.player.Play();
if (jpf.isIE)
this.handleEvent({type: "qt_play"});
}
catch(e) {
this.oVideo.$stateChangeHook({type: "stateChange", state: "connectionError"});
}
}
return this;
},
pause: function() {
if (this.player) {
try {
this.player.Stop();
if (jpf.isIE)
this.handleEvent({type: "qt_pause"});
}
catch(e) {
this.oVideo.$stateChangeHook({type: "stateChange", state: "connectionError"});
}
}
return this;
},
stop: function() {
return this.pause();
},
seek: function(iTo) {
if (!this.player) return;
try {
this.player.SetTime(iTo);
}
catch(e) {
this.oVideo.$stateChangeHook({type: "stateChange", state: "connectionError"});
}
return this;
},
setVolume: function(iVolume) {
if (this.player) {
try {
this.player.SetVolume(Math.round((iVolume / 100) * 256));
}
catch(e) {
this.oVideo.$stateChangeHook({type: "stateChange", state: "connectionError"});
}
}
return this;
},
getTotalTime: function() {
if (!this.player) return 0;
return this.player.GetDuration();
},
$draw: function() {
if (this.player) {
this.stopPlayPoll();
delete this.player;
this.player = null;
}
this.htmlElement.innerHTML = jpf.video.TypeQTCompat.generateOBJECTText(
this.videoPath, "100%", "100%", "",
"autoplay",            jpf.isIE ? "false" : this.autoPlay.toString(), 
"controller",          this.showControls.toString(),
"kioskmode",           "true",
"showlogo",            "true",
"bgcolor",             "black",
"scale",               "aspect",
"align",               "middle",
"EnableJavaScript",    "True",
"postdomevents",       "True",
"target",              "myself",
"cache",               "false",
"qtsrcdontusebrowser", "true",
"type",                this.mimeType.splitSafe(",")[this.oVideo.$lastMimeType] || this.mimeType,
"obj#id",              this.name,
"emb#NAME",            this.name,
"emb#id",              this.name + "emb");
this.player = document[this.name];
return this;
},
events: ["qt_begin", "qt_abort", "qt_canplay", "qt_canplaythrough",
"qt_durationchange", "qt_ended", "qt_error", "qt_load",
"qt_loadedfirstframe", "qt_loadedmetadata", "qt_pause", "qt_play",
"qt_progress", "qt_stalled", "qt_timechanged", "qt_volumechange",
"qt_waiting"],
attachEvents: function() {
var nodeEvents = document.getElementById(this.name);
if (!nodeEvents) 
nodeEvents = document.getElementById(this.name + "emb");
var _self = this;
function exec(e) {
if (!e) e = window.event;
_self.handleEvent(e);
}
var hook = nodeEvents.addEventListener ? "addEventListener" : "attachEvent";
var pfx  = nodeEvents.addEventListener ? "" : "on";
this.events.forEach(function(evt) {
nodeEvents[hook](pfx + evt, exec, false);
});
if (jpf.isIE && this.autoPlay)
this.handleEvent({type: "qt_play"});
return this;
},
handleEvent: function(e) {
switch (e.type) {
case "qt_play":
this.oVideo.$stateChangeHook({type: "stateChange", state: "playing"});
this.startPlayPoll();
break;
case "qt_pause":
this.oVideo.$stateChangeHook({type: "stateChange", state: "paused"});
this.stopPlayPoll();
break;
case "qt_volumechange":
this.oVideo.$changeHook({
type  : "change",
volume: Math.round((this.player.GetVolume() / 256) * 100)
});
break;
case "qt_timechanged":
this.oVideo.$changeHook({
type        : "change",
playheadTime: this.player.GetTime()
});
break;
case "qt_stalled":
this.oVideo.$completeHook({type: "complete"});
this.stopPlayPoll();
break;
case "qt_canplay":
this.oVideo.$readyHook({type: "ready"});
break;
case "qt_load":
case "qt_canplaythrough":
this.oVideo.setProperty("readyState", jpf.Media.HAVE_ENOUGH_DATA);
if (this.autoPlay && jpf.isIE) 
this.player.Play();
break;
}
return this;
},
startPlayPoll: function() {
clearTimeout(this.pollTimer);
var _self = this;
this.pollTimer = setTimeout(function() {
if (!_self.player) return;
try {
_self.handleEvent({type: "qt_timechanged"});
var iLoaded = _self.player.GetMaxBytesLoaded();
var iTotal  = _self.player.GetMovieSize();
_self.oVideo.$progressHook({
bytesLoaded: iLoaded,
totalBytes : iTotal
});
if (!_self.oVideo.ready && Math.abs(iLoaded - iTotal) <= 20)
_self.handleEvent({type: "qt_load"});
}
catch (e) {}
_self.startPlayPoll();
}, 100);
return this;
},
stopPlayPoll: function() {
clearTimeout(this.pollTimer);
return this;
},
$destroy: function() {
this.stopPlayPoll();
if (this.player) {
try {
this.player.Stop();
}
catch (e) {}
this.player = null;
delete this.player;
}
this.oVideo = this.htmlElement = null;
delete this.oVideo;
delete this.htmlElement;
}
};
jpf.textbox.autocomplete = function(){
var autocomplete = {};
this.initAutocomplete = function(ac){
ac.parentNode.removeChild(ac);
autocomplete.nodeset   = ac.getAttribute("nodeset").split(":");
autocomplete.method    = ac.getAttribute("method");
autocomplete.value     = ac.getAttribute("value");
autocomplete.count     = parseInt(ac.getAttribute("count")) || 5;
autocomplete.sort      = ac.getAttribute("sort");
autocomplete.lastStart = -1;
this.oContainer = jpf.xmldb.htmlImport(this.$getLayoutNode("container"),
this.oExt.parentNode, this.oExt.nextSibling);	
};
this.fillAutocomplete = function(keyCode){
if (keyCode) {
switch(keyCode){
case 9:
case 27: 
case 13:  
return this.oContainer.style.display = "none";
case 40: 
if(autocomplete.suggestData 
&& autocomplete.lastStart < autocomplete.suggestData.length){
this.clear();
var value       = autocomplete.suggestData[autocomplete.lastStart++];
this.oInt.value = value; 
this.change(value);
this.oContainer.style.display = "none";
return;
}
break;
case 38: 
if (autocomplete.lastStart > 0) {
if(autocomplete.lastStart >= autocomplete.suggestData.length) 
autocomplete.lastStart = autocomplete.suggestData.length - 1;
this.clear();
var value = autocomplete.suggestData[autocomplete.lastStart--];
this.oInt.value = value; 
this.change(value);
this.oContainer.style.display = "none";
return;
}
break;
}
if (keyCode > 10 && keyCode < 20) return;
}
if (autocomplete.method) {
var start = 0, suggestData = self[autocomplete.method]();
autocomplete.count = suggestData.length;
}
else {
if (this.oInt.value.length == 0){
this.oContainer.style.display = "none";
return;
}
if (!autocomplete.suggestData) {
var nodes = self[autocomplete.nodeset[0]].data.selectNodes(autocomplete.nodeset[1]);
for(var value, suggestData = [], i = 0; i < nodes.length; i++) {
value = jpf.getXmlValue(nodes[i], autocomplete.value);
if (value)
suggestData.push(value.toLowerCase());
}
if (autocomplete.sort)
suggestData.sort();
autocomplete.suggestData = suggestData;
}
else {
suggestData = autocomplete.suggestData;
}
var value = this.oInt.value.toUpperCase();
for(var start = suggestData.length - autocomplete.count, i = 0; i < suggestData.length; i++) {
if (value <= suggestData[i].toUpperCase()) {
start = i;
break;
}
}
autocomplete.lastStart = start;
}
this.oContainer.innerHTML = "";
for (var arr = [], j = start; j < Math.min(start + autocomplete.count, suggestData.length); j++) {
this.$getNewContext("item")
var oItem = this.$getLayoutNode("item");
jpf.xmldb.setNodeValue(this.$getLayoutNode("item", "caption"), suggestData[j]);
oItem.setAttribute("onmouseover", 'this.className = "hover"');
oItem.setAttribute("onmouseout",  'this.className = ""');
oItem.setAttribute("onmousedown", 'event.cancelBubble = true');
oItem.setAttribute("onclick",
"var o = jpf.lookup(" + this.uniqueId + ");\
o.oInt.value = this.innerHTML;\
o.change(this.innerHTML);\
o.oInt.select();\
o.oInt.focus();\
o.oContainer.style.display = 'none';");
arr.push(this.$getLayoutNode("item"));
}
jpf.xmldb.htmlImport(arr, this.oContainer);
this.oContainer.style.display = "block";
};
this.setAutocomplete = function(model, traverse, value){
autocomplete.lastStart   = -1;
autocomplete.suggestData = null;
autocomplete.nodeset = [model, traverse];
autocomplete.value = value;
this.oContainer.style.display = "none";
};
};
jpf.textbox.masking = function(){
var _FALSE_ = 9128748732;
var _REF = {
"0" : "\\d",
"1" : "[12]",
"9" : "[\\d ]",
"#" : "[\\d +-]",
"L" : "[A-Za-z]",
"?" : "[A-Za-z ]",
"A" : "[A-Za-z0-9]",
"a" : "[A-Za-z0-9 ]",
"X" : "[0-9A-Fa-f]",
"V" : "[0-9A-Fa-fV]", 
"x" : "[0-9A-Fa-f ]",
"&" : "[^\s]",
"C" : "."
};
var lastPos = -1;
var masking = false;
var oExt    = this.oExt
var initial, pos, myvalue, format, fcase, replaceChar;
this.setPosition = function(setpos){
setPosition(setpos || lastPos || 0);
};
this.$clear = function(){
this.value = "";
if (this.mask) 
return this.setValue("");
};
this.$propHandlers["value"] = function(value){
var data = "";
if (this.includeNonTypedChars) {
for (var i = 0; i < initial.length; i++) {
if (initial.substr(i, 1) != value.substr(i, 1))
data += value.substr(i, 1);
}
}
this.$insertData(data || value);
};
this.addEventListener("keydown", function(e){
var key      = e.keyCode;
var ctrlKey  = e.ctrlKey;
var shiftKey = e.shiftKey;
switch (key) {
case 39:	
setPosition(lastPos+1);
break;
case 37:
setPosition(lastPos-1);
break;
case 35:
case 34:
setPosition(myvalue.length);
break;
case 33:
case 36:
setPosition(0);
break;
case 8:
deletePosition(lastPos-1);
setPosition(lastPos-1);
break;
case 46:
deletePosition(lastPos);
setPosition(lastPos);
break;
default:
if (key == 67 && ctrlKey)
window.clipboardData.setData("Text", this.getValue());  
else
return;
break;
}
return false;
}, true);
this.$initMasking = function(){
this.$keyHandler = null; 
masking = true;
this.oInt.onkeypress = function(){
var chr = String.fromCharCode(self.event.keyCode);
chr = (self.event.shiftKey ? chr.toUpperCase() : chr.toLowerCase());
if (setCharacter(chr))
setPosition(lastPos + 1);
return false;
};
this.oInt.onmouseup = function(){
var pos = Math.min(calcPosFromCursor(), myvalue.length);
setPosition(pos);
return false;
};
this.oInt.onpaste = function(e){
e = e || window.event;
e.returnValue = false;
this.host.setValue(window.clipboardData.getData("Text") || "");
setTimeout(function(){
setPosition(lastPos);
}, 1); 
};
this.getValue = function(){
if (this.includeNonTypedChars)
return initial == this.oInt.value 
? "" 
: this.oInt.value.replace(new RegExp(replaceChar, "g"), "");
else
return myvalue.join("");
};
this.setValue = function(value){
if (this.includeNonTypedChars) {
for (var data = "", i = 0; i < initial.length; i++) {
if (initial.substr(i,1) != value.substr(i,1))
data += value.substr(i,1);
}
}
this.$insertData(data);
};
};
this.setMask = function(m){
if (!masking)
this.$initMasking();
var m = m.split(";");
replaceChar = m.pop();
this.includeNonTypedChars = parseInt(m.pop()) !== 0;
var mask = m.join(""); 
var validation = "", visual="", mode_case = "-",
strmode = false, startRight = false, chr;
var pos = [], format = "", fcase = "";
for (var looppos = -1, i = 0; i < mask.length; i++) {
chr = mask.substr(i,1);
if (!chr.match(/[\!\'\"\>\<\\]/))
looppos++;
else {
if (chr == "!")
startRight = true;
else if (chr == "<" || chr == ">")
mode_case = chr;
else if (chr == "'" || chr == "\"")
strmode = !strmode;
continue;
}
if (!strmode && _REF[chr]) {
pos.push(looppos);
visual     += replaceChar;
format     += chr;
fcase      += mode_case;
validation += _REF[chr];
}
else
visual += chr;
}
this.oInt.value = visual;
initial         = visual;
myvalue = [];
replaceChar = replaceChar;
};
function checkChar(chr, p){
var f = format.substr(p, 1);
var c = fcase.substr(p, 1);
if (chr.match(new RegExp(_REF[f])) == null)
return _FALSE_;
if (c == ">")
return chr.toUpperCase();
if (c == "<")
return chr.toLowerCase();
return chr;
}
function setPosition(p){
if (p < 0)
p = 0;
var range = oExt.createTextRange();
range.expand("textedit");
range.select();
if (pos[p] == null) {
range.collapse(false);
range.select();
lastPos = pos.length;
return false;
}
range.collapse();
range.moveStart("character", pos[p]);
range.moveEnd("character", 1);
range.select();
lastPos = p;
}
function setCharacter(chr){
if (pos[lastPos] == null) return false;
chr = checkChar(chr, lastPos);
if (chr == _FALSE_) return false;
var range = oExt.createTextRange();
range.expand("textedit");
range.collapse();
range.moveStart("character", pos[lastPos]);
range.moveEnd("character", 1);
range.text = chr;
if (jpf.window.focussed == this)
range.select();
myvalue[lastPos] = chr;
return true;
}
function deletePosition(p){
if(pos[p] == null) return false;
var range = oExt.createTextRange();
range.expand("textedit");
range.collapse();
range.moveStart("character", pos[p]);
range.moveEnd("character", 1);
range.text = replaceChar;
range.select();
myvalue[p] = " ";
}
this.$insertData = function(str){
if (str == this.getValue()) return;
str = this.dispatchEvent("insert", { data : str }) || str;
if (!str) {
if (!this.getValue()) return; 
for (var i = this.getValue().length - 1; i >= 0; i--)
deletePosition(i);
setPosition(0);	
return;
}
for (var i = 0; i < str.length; i++) {
lastPos = i;
setCharacter(str.substr(i,1));
}
if (str.length)
lastPos++;
};
function calcPosFromCursor(){
var range = document.selection.createRange();
r2 = range.duplicate();
r2.expand("textedit");
r2.setEndPoint("EndToStart", range);
var lt = r2.text.length;
for (var i = 0; i < pos.length; i++)
if (pos[i] > lt)
return (i == 0) ? 0 : i - 1;
}
};
jpf.modalwindow.widget = function(){
var nX, nY, verdiff, hordiff, cData;
var _self   = this;
this.dragStart = function(e){
if (!e) e = event;
nX = _self.oExt.offsetLeft - e.clientX;
nY = _self.oExt.offsetTop - e.clientY;
var htmlNode = _self.oExt;
var p        = _self.positionHolder;
p.className  = "position_holder";
htmlNode.parentNode.insertBefore(p, htmlNode);
p.style.height  = (htmlNode.offsetHeight - (jpf.isIE6 ? 0 : 13)) + "px";
var diff     = jpf.getDiff(htmlNode);
var lastSize = [htmlNode.style.width, htmlNode.style.height];
htmlNode.style.width = (htmlNode.offsetWidth - diff[0]) + "px";
htmlNode.style.left = (e.clientX - nX) + "px";
htmlNode.style.top  = (e.clientY - nY) + "px";
htmlNode.style.position = "absolute";
htmlNode.style.zIndex   = htmlNode.parentNode.style.zIndex = 100000;
htmlNode.parentNode.style.position = "relative";
htmlNode.parentNode.style.left     = "0"; 
jpf.Animate.fade(htmlNode, 0.8);
jpf.dragmode.mode = true; 
cData                = [htmlNode, p];
document.onmousemove = _self.dragMove;
document.onmouseup   = function(){
document.onmousemove = document.onmouseup = null;
htmlNode.style.position = "";
htmlNode.style.left     = 0;
htmlNode.style.top      = 0;
htmlNode.style.width    = lastSize[0];
htmlNode.style.zIndex   = htmlNode.parentNode.style.zIndex = 1;
p.parentNode.insertBefore(htmlNode, p);
p.parentNode.removeChild(p);
jpf.Animate.fade(htmlNode, 1);
var grids = _self.getElementsByTagName("datagrid");
for(var i = 0; i < grids.length; i++) {
grids[i].updateWindowSize(true);
}
jpf.dragmode.mode = null;
};
e.cancelBubble = true;
return false;
};
function insertInColumn(el, ey){
var pos   = jpf.getAbsolutePosition(el);
var cy    = ey - pos[1];
var nodes = el.childNodes;
for (var th = 0, i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
if (node.nodeType != 1
|| jpf.getStyle(node, "position") == "absolute")
continue;
th = node.offsetTop + node.offsetHeight;
if (th > cy) {
el.insertBefore(cData[1],
th - (node.offsetHeight / 2) > cy
? node
: node.nextSibling);
}
}
if (i == nodes.length)
el.appendChild(cData[1]);
}
this.dragMove = function(e){
if (!e) e = event;
_self.oExt.style.top = "10000px";
var ex  = e.clientX + document.documentElement.scrollLeft;
var ey  = e.clientY + document.documentElement.scrollTop;
var el  = document.elementFromPoint(ex, ey);
if (el.isColumn){
insertInColumn(el, ey);
}
else {
while (el.parentNode && !el.isColumn) {
el = el.parentNode;
}
if (el.isColumn)
insertInColumn(el, ey);
}
_self.oExt.style.left = (e.clientX - nX) + "px";
_self.oExt.style.top  = (e.clientY - nY) + "px";
e.cancelBubble = true;
};
this.$loadJml = function(x) {
jpf.WinServer.setTop(this);
var diff = jpf.getDiff(this.oExt);
hordiff  = diff[0];
verdiff  = diff[1];
var oInt      = this.$getLayoutNode("main", "container", this.oExt);
var oSettings = this.$getLayoutNode("main", "settings_content", this.oExt);
this.positionHolder = document.body.appendChild(document.createElement("div"));
var oConfig = $xmlns(this.$jml, "config", jpf.ns.jml)[0];
if (oConfig)
oConfig.parentNode.removeChild(oConfig);
var oBody = $xmlns(this.$jml, "body", jpf.ns.jml)[0];
oBody.parentNode.removeChild(oBody);
jpf.JmlParser.parseChildren(this.$jml, null, this);
if (oConfig)
this.$jml.appendChild(oConfig);
this.$jml.appendChild(oBody);
if (oSettings && oConfig) {
this.oSettings = this.oSettings
? jpf.JmlParser.replaceNode(oSettings, this.oSettings)
: jpf.JmlParser.parseChildren(oConfig, oSettings, this, true);
}
this.oInt = this.oInt
? jpf.JmlParser.replaceNode(oInt, this.oInt)
: jpf.JmlParser.parseChildren(oBody, oInt, this, true);
if (oBody.getAttribute("class"))
this.$setStyleClass(this.oInt, oBody.getAttribute("class"))
this.oDrag.onmousedown = this.dragStart;
if (this.resizable)
this.resizable = false;
if (this.draggable === undefined)
this.draggable = true;
this.minwidth  = this.$getOption("Main", "min-width");
this.minheight = this.$getOption("Main", "min-height");
};
};
jpf.rpc = function(){
if (!this.supportMulticall)
this.multicall = false;
this.stack   = {};
this.urls    = {};
this.tagName = "rpc";
this.useHTTP = true;
this.TelePortModule = true;
this.routeServer    = jpf.host + "/cgi-bin/rpcproxy.cgi";
this.autoroute      = false;
this.namedArguments = false;
var _self = this;
this.addMethod = function(name, callback, names, async, caching, ignoreOffline){
this[name] = function(){
return this.call(name, arguments);
}
this[name].async         = async;
this[name].caching       = caching;
this[name].names         = names;
this[name].ignoreOffline = ignoreOffline;
if (callback)
this[name].callback = callback;
return true;
}
this.setCallback = function(name, func){
this[name].callback = func;
}
this.$convertArgs = function(name, args){
if (!this.namedArguments)
return args.slice();
var nodes = this[name].names;
if (!nodes || !nodes.length)
return {};
var name, value, result = {};
for (var j = 0, i = 0; i < nodes.length; i++) {
name = nodes[i].getAttribute("name");
if (nodes[i].getAttribute("value"))
value = jpf.parseExpression(nodes[i].getAttribute("value"));
else {
value = args[j++];
if (jpf.isNot(value) && nodes[i].getAttribute("default"))
value = jpf.parseExpression(nodes[i].getAttribute("default"));
}
value = jpf.isTrue(nodes[i].getAttribute("encoded"))
? encodeURIComponent(value)
: value;
result[name] = value;
}
return result;
}
this.call = function(name, args, options){
args = this.$convertArgs(name, args);
if (this.multicall) {
if (!this.stack[this.url])
this.stack[this.url] = this.getMulticallObject
? this.getMulticallObject()
: new Array();
this.getSingleCall(name, args, this.stack[this.url])
return true;
}
var callback = (typeof this[name].callback == "string"
? self[this[name].callback]
: this[name].callback) || function(){};
var data = this.serialize(name, args); 
function pCallback(data, state, extra){
extra.data = data;
if(state != jpf.SUCCESS)
callback(null, state, extra);
else if (_self.isValid && !_self.isValid(extra))
callback(null, jpf.ERROR, extra);
else
callback(_self.unserialize(extra.data), state, extra);
}
var url  = jpf.getAbsolutePath(this.baseurl, this.url);
var info = this.get(url, pCallback, jpf.extend({
async    : this[name].async,
userdata : this[name].userdata,
nocache  : true,
data     : data,
useXML   : this.useXML,
caching  : this[name].caching,
ignoreOffline : this[name].ignoreOffline
}, options));
return info;
}
this.purge = function(callback, userdata, async, extradata){
var data = this.serialize("multicall", [this.stack[this.url]]); 
var url  = jpf.getAbsolutePath(this.baseurl, this.url);
if (extradata) {
for (var vars = [], i = 0; i < extradata.length; i++) {
vars.push(encodeURIComponent(extradata[i][0]) + "="
+ encodeURIComponent(extradata[i][1] || ""))
}
url = url + (url.match(/\?/) ? "&" : "?") + vars.join("&");
}
var info = this.get(url, callback, {
async    : async,
userdata : userdata,
nocache  : true,
data     : data,
useXML   : this.useXML
});
this.stack[this.url] = this.getMulticallObject
? this.getMulticallObject()
: [];
}
this.revert = function(modConst){
this.stack[modConst.url] = this.getMulticallObject
? this.getMulticallObject()
: [];
}
this.getStackLength = function(){
return this.stack[this.url] ? this.stack[this.url].length : 0;
}
this.load = function(x){
this.$jml       = x;
this.timeout   = parseInt(x.getAttribute("timeout")) || this.timeout;
this.url       = jpf.parseExpression(x.getAttribute("url"))
this.baseurl   = jpf.parseExpression(
jpf.xmldb.getInheritedAttribute(
this.$jml, "baseurl")) || "";
this.multicall = x.getAttribute("multicall") == "true";
this.autoroute = x.getAttribute("autoroute") == "true";
if (this.url)
this.server = this.url.replace(/^(.*\/\/[^\/]*)\/.*$/, "$1") + "/";
if (this.$load)
this.$load(x);
var q = x.childNodes;
for (var url, i = 0; i < q.length; i++) {
if (q[i].nodeType != 1)
continue;
url = jpf.parseExpression(q[i].getAttribute("url"));
if (url)
this.urls[q[i].getAttribute("name")] = url;
this.addMethod(q[i].getAttribute("name"),
q[i].getAttribute("receive") || x.getAttribute("receive"),
q[i].getElementsByTagName("*"), 
!jpf.isFalse(q[i].getAttribute("async")),
jpf.isTrue(q[i].getAttribute("caching")),
jpf.isTrue(q[i].getAttribute("ignore-offline")));
}
}
}
jpf.datainstr.rpc = function(xmlContext, options, callback){
var parsed = options.parsed || this.parseInstructionPart(
options.instrData.join(":"), xmlContext, options.args, options);
if (options.preparse) {
options.parsed = parsed;
options.preparse = -1;
return;
}
var args   = parsed.arguments;
var q      = parsed.name.split(".");
var obj    = eval(q[0]);
var method = q[1];
if (options.multicall)
obj.forceMulticall = true;
if (options.userdata)
obj[method].userdata = options.userdata;
if (!obj.multicall)
obj[method].callback = callback; 
var retvalue = obj.call(method, args, options);
if (obj.multicall)
return obj.purge(callback, "&@^%!@"); 
else if (options.multicall) {
obj.forceMulticall = false;
return obj;
}
if (!obj.multicall && !obj[method].async && callback)
callback(retvalue);
}
jpf.http = function(){
this.queue     = [null];
this.callbacks = {};
this.cache     = {};
this.timeout   = 10000; 
if (!this.uniqueId)
this.uniqueId = jpf.all.push(this) - 1;
var _self = this;
jpf.teleport.register(this);
this.toString = this.toString || function(){
return "[Javeline TelePort Component : (HTTP)]";
}
this.getXml = function(url, callback, options){
if(!options) options = {};
options.useXML = true;
return this.get(url, callback, options);
};
this.get = function(url, callback, options, id){
if(!options)
options = {};
var async = options.async
|| typeof options.async == "undefined" || jpf.isOpera;
if (jpf.isSafari)
url = jpf.html_entity_decode(url);
var data = options.data || "";
if (jpf.isNot(id)) {
if (this.cache[url] && this.cache[url][data]) {
var http = {
responseText : this.cache[url][data],
responseXML  : {},
status       : 200,
isCaching    : true
}
}
else
var http = jpf.getHttpReq();
id = this.queue.push({
http     : http,
url      : url,
callback : callback,
retries  : 0,
options  : options
}) - 1;
if (http.isCaching) {
if (async)
return setTimeout("jpf.lookup(" + this.uniqueId
+ ").receive(" + id + ");", 50);
else
return this.receive(id);
}
}
else {
var http = this.queue[id].http;
if (http.isCaching)
http = jpf.getHttpReq();
else
http.abort();
}
if (async) {
if (jpf.hasReadyStateBug) {
this.queue[id].starttime = new Date().getTime();
this.queue[id].timer = setInterval(function(){
var diff = new Date().getTime() - _self.queue[id].starttime;
if (diff > _self.timeout) {
_self.$timeout(id);
return
};
if (_self.queue[id].http.readyState == 4) {
clearInterval(_self.queue[id].timer);
_self.receive(id);
}
}, 20);
}
else
{
http.onreadystatechange = function(){
if (!_self.queue[id] || http.readyState != 4)
return;
_self.receive(id);
}
}
}
var autoroute = this.autoroute && jpf.isOpera
? true 
: (options.autoroute || this.shouldAutoroute);
var httpUrl = autoroute ? this.routeServer : url;
var errorFound = false;
try {
if (options.nocache)
httpUrl = jpf.getNoCacheUrl(httpUrl);
if (jpf.appsettings.queryAppend) {
httpUrl += (httpUrl.indexOf("?") == -1 ? "?" : "&")
+ jpf.appsettings.queryAppend;
}
http.open(this.method || options.method || "GET", httpUrl,
async, options.username || null, options.password || null);
http.setRequestHeader("User-Agent", "Javeline TelePort 2.0"); 
http.setRequestHeader("X-Requested-With", "XMLHttpRequest");
http.setRequestHeader("Content-type", this.contentType
|| (this.useXML || options.useXML ? "text/xml" : "text/plain"));
if (autoroute) {
http.setRequestHeader("X-Route-Request", url);
http.setRequestHeader("X-Proxy-Request", url);
http.setRequestHeader("X-Compress-Response", "gzip");
}
}
catch (e) {
errorFound = true;
}
if (errorFound) {
var useOtherXH = false;
if (!useOtherXH && this.autoroute && !autoroute) {
if (!jpf.isNot(id))
clearInterval(this.queue[id].timer);
this.shouldAutoroute = true;
options.autoroute = true;
return this.get(url, receive, options, id);
}
if (!useOtherXH) {
var noClear = callback ? callback(null, jpf.ERROR, {
userdata: options.userdata,
http    : http,
url     : url,
tpModule: this,
id      : id,
message : "Permission denied accessing remote resource: " + url
}) : false;
if (!noClear)
this.clearQueueItem(id);
return;
}
}
if (this.$HeaderHook)
this.$HeaderHook(http);
if (options.headers) {
for (var name in options.headers)
http.setRequestHeader(name, options.headers[name]);
}
function send(isLocal){
var hasError;
if (isLocal)
http.send(data);
else {
try{
http.send(data);
}
catch(e){
hasError = true;
}
}
if (hasError) {
var msg = window.navigator.onLine
? "File or Resource not available " + url
: "Browser is currently working offline";
var state = window.navigator.onLine
? jpf.ERROR
: jpf.TIMEOUT;
var noClear = callback ? callback(null, state, {
userdata : options.userdata,
http     : http,
url      : url,
tpModule : this,
id       : id,
message  : msg
}) : false;
if(!noClear) this.clearQueueItem(id);
return;
}
}
if (!async) {
send.call(this);
return this.receive(id);
}
else {
if (jpf.isIE && location.protocol == "file:"
&& url.indexOf("http://") == -1) {
setTimeout(function(){
send.call(_self, true);
});
}
else
send.call(_self);
return id;
}
};
this.receive = function(id){
if (!this.queue[id])
return false;
var qItem    = this.queue[id];
var http     = qItem.http;
var callback = qItem.callback;
clearInterval(qItem.timer);
if (window.navigator.onLine === false && (location.protocol != "file:"
|| qItem.url.indexOf("http://") > -1))
return false;
try {
if (http.status) {}
}
catch (e) {
return setTimeout(function(){
_self.receive(id)
}, 10);
}
var errorMessage = [];
var extra = {
tpModule : this,
http     : http,
url      : qItem.url,
callback : callback,
id       : id,
retries  : qItem.retries || 0,
userdata : qItem.options.userdata
}
if (http.status > 600)
return this.$timeout(id); 
extra.data = http.responseText; 
if (http.status >= 400 && http.status < 600) {
errorMessage.push("HTTP error [" + id + "]:" + http.status + "\n" + http.responseText);
}
if (qItem.options.useXML || this.useXML) {
if ((http.responseText || "").replace(/^[\s\n\r]+|[\s\n\r]+$/g, "") == "")
errorMessage.push("Received an empty XML document (0 bytes)");
else {
try {
var xmlDoc = (http.responseXML && http.responseXML.documentElement)
? jpf.xmlParseError(http.responseXML)
: jpf.getXmlDom(http.responseText);
if (!jpf.supportNamespaces)
xmlDoc.setProperty("SelectionLanguage", "XPath");
extra.data = xmlDoc.documentElement;
}
catch(e){
errorMessage.push("Received invalid XML\n\n" + e.message);
}
}
}
if (errorMessage.length) {
extra.message = errorMessage.join("\n");
if (!callback || !callback(null, jpf.ERROR, extra))
this.clearQueueItem(id);
return;
}
if (qItem.options.caching) {
if (!this.cache[qItem.url])
this.cache[qItem.url] = {};
this.cache[qItem.url][qItem.options.data] = http.responseText;
}
if (!callback || !callback(extra.data, jpf.SUCCESS, extra))
this.clearQueueItem(id);
return extra.data;
};
this.$timeout = function(id){
if (!this.queue[id])
return false;
var qItem = this.queue[id];
var http  = qItem.http;
clearInterval(qItem.timer);
try {
if (http.status) {}
}
catch (e) {
return setTimeout(function(){
_self.$timeout(id)
}, 10);
}
var callback = qItem.callback;
http.abort();
var noClear = callback ? callback(null, jpf.TIMEOUT, {
userdata: qItem.options.userdata,
http    : http,
url     : qItem.url,
tpModule: this,
id      : id,
message : "HTTP Call timed out",
retries : qItem.retries || 0
}) : false;
if (!noClear)
this.clearQueueItem(id);
};
this.retryTimeout = function(extra, state, jmlNode, oError, maxRetries){
if (state == jpf.TIMEOUT
&& extra.retries < (maxRetries || jpf.maxHttpRetries))
return extra.tpModule.retry(extra.id);
if ((jmlNode || jpf).dispatchEvent("error", jpf.extend({
error   : oError,
state   : state,
bubbles : true
}, extra)) === false)
return true;
};
this.clearQueueItem = function(id){
if (!this.queue[id])
return false;
clearInterval(this.queue[id].timer);
jpf.teleport.releaseHTTP(this.queue[id].http);
this.queue[id] = null;
delete this.queue[id];
return true;
};
this.retry = function(id){
if (!this.queue[id])
return false;
var qItem = this.queue[id];
clearInterval(qItem.timer);
qItem.retries++;
this.get(qItem.url, qItem.callback, qItem.options, id);
return true;
};
this.cancel = function(id){
if (id === null)
id = this.queue.length - 1;
if (!this.queue[id])
return false;
this.clearQueueItem(id);
};
if (!this.load) {
this.load = function(x){
var receive = x.getAttribute("receive");
for (var i = 0; i < x.childNodes.length; i++) {
if (x.childNodes[i].nodeType != 1)
continue;
var url      = x.childNodes[i].getAttribute("url");
var callback = self[x.childNodes[i].getAttribute("receive") || receive];
var options  = {
useXML  : x.childNodes[i].getAttribute("type") == "XML",
async   : !jpf.isFalse(x.childNodes[i].getAttribute("async"))
}
this[x.childNodes[i].getAttribute("name")] = function(data, userdata){
options.userdata = userdata;
options.data     = data;
return this.get(url, callback, options);
}
}
};
this.instantiate = function(x){
var url     = x.getAttribute("src");
var options = {
async   : x.getAttribute("async") != "false",
nocache : true
}
this.getURL = function(data, userdata){
options.data     = data;
options.userdata = userdata;
return this.get(url, this.callbacks.getURL, options);
}
var name = "http" + Math.round(Math.random() * 100000);
jpf.setReference(name, this);
return name + ".getURL()";
};
this.call = function(method, args){
this[method].call(this, args);
};
}
};
jpf.Init.run('http');
jpf.Init.run('XmlDatabase');
jpf.xmlrpc = function(){
this.supportMulticall = true;
this.multicall        = false;
this.mcallname        = "system.multicall";
this.method         = "POST";
this.useXML           = true;
this.namedArguments   = false;
jpf.teleport.register(this);
if (!this.uniqueId) {
jpf.makeClass(this);
this.inherit(jpf.BaseComm, jpf.http, jpf.rpc);
}
var serialize = {
host: this,
object: function(o){
var wo = o;
retstr = "<struct>";
for (prop in wo) {
if (typeof wo[prop] != "function" && prop != "type") {
retstr += "<member><name>" + prop + "</name><value>"
+ this.host.doSerialize(wo[prop]) + "</value></member>";
}
}
retstr += "</struct>";
return retstr;
},
string: function(s){
return "<string><![CDATA[" + s.replace(/&/g, "&amp;")
.replace(/</g, "&lt;").replace(/>/g, "&gt;") + "]]></string>";
return str;
},
number: function(i){
if (i == parseInt(i)) {
return "<int>" + i + "</int>";
}
else 
if (i == parseFloat(i)) {
return "<double>" + i + "</double>";
}
else {
return this["boolean"](false);
}
},
"boolean": function(b){
if (b == true) 
return "<boolean>1</boolean>";
else 
return "<boolean>0</boolean>";
},
date: function(d){
return "<dateTime.iso8601>" + doYear(d.getUTCYear())
+ doZero(d.getMonth()) + doZero(d.getUTCDate()) + "T"
+ doZero(d.getHours()) + ":" + doZero(d.getMinutes()) + ":"
+ doZero(d.getSeconds()) + "</dateTime.iso8601>";
function doZero(nr){
nr = String("0" + nr);
return nr.substr(nr.length - 2, 2);
}
function doYear(year){
if (year > 9999 || year < 0) 
XMLRPC.handleError(new Error(jpf.formatErrorString(1085,
null, "XMLRPC serialization", "Unsupported year: " + year)));
year = String("0000" + year)
return year.substr(year.length - 4, 4);
}
},
array: function(a){
var retstr = "<array><data>";
for (var i = 0; i < a.length; i++) {
retstr += "<value>";
retstr += this.host.doSerialize(a[i])
retstr += "</value>";
}
return retstr + "</data></array>";
}
}
this.getSingleCall = function(name, args, obj){
obj.push({
m: name,
p: args
});
}
this.doSerialize = function(args){
if (typeof args == "function") {
throw new Error(jpf.formatErrorString(1086, null, "XMLRPC serialization", "Cannot Parse functions"));
}
else 
if (jpf.isNot(args)) 
return serialize["boolean"](false);
return serialize[args.dataType || "object"](args);
}
this.serialize = function(functionName, args){
var message = '<?xml version="1.0" encoding=\"UTF-8\"?><methodCall><methodName>'
+ functionName + '</methodName><params>';
for (var i = 0; i < args.length; i++) {
message += '<param><value>' + this.doSerialize(args[i]) + '</value></param>';
}
message += '</params></methodCall>';
return message;
}
this.unserialize = function(data){
var ret, i;
switch (data.tagName) {
case "string":
if (jpf.isGecko) {
data = (new XMLSerializer()).serializeToString(data);
data = data.replace(/^\<string\>/, '');
data = data.replace(/\<\/string\>$/, '');
data = data.replace(/\&lt;/g, "<");
data = data.replace(/\&gt;/g, ">");
return data;
}
return (data.firstChild) ? data.firstChild.nodeValue : "";
break;
case "int":
case "i4":
case "double":
return (data.firstChild) ? new Number(data.firstChild.nodeValue) : 0;
break;
case "dateTime.iso8601":
var sn = jpf.dateSeparator;
if (/^(\d{4})(\d{2})(\d{2})T(\d{2}):(\d{2}):(\d{2})/
.test(data.firstChild.nodeValue)) {
;
return new Date(RegExp.$2 + sn + RegExp.$3 + sn +
RegExp.$1 +
" " +
RegExp.$4 +
":" +
RegExp.$5 +
":" +
RegExp.$6);
}
else {
return new Date();
}
break;
case "array":
data = jpf.getNode(data, [0]);
if (data && data.tagName == "data") {
ret = new Array();
var i = 0;
while (child = jpf.getNode(data, [i++])) {
ret.push(this.unserialize(child));
}
return ret;
}
else {
this.handleError(new Error(jpf.formatErrorString(1087, null, "", "Malformed XMLRPC Message")));
return false;
}
break;
case "struct":
ret = {};
var i = 0;
while (child = jpf.getNode(data, [i++])) {
if (child.tagName == "member") {
ret[jpf.getNode(child, [0]).firstChild.nodeValue] =
this.unserialize(jpf.getNode(child, [1]));
}
else {
this.handleError(new Error(jpf.formatErrorString(1087, null, "", "Malformed XMLRPC Message2")));
return false;
}
}
return ret;
break;
case "boolean":
return Boolean(isNaN(parseInt(data.firstChild.nodeValue))
? (data.firstChild.nodeValue == "true")
: parseInt(data.firstChild.nodeValue))
break;
case "base64":
return jpf.crypt.Base64.decode(data.firstChild.nodeValue);
break;
case "value":
child = jpf.getNode(data, [0]);
return (!child) ? ((data.firstChild)
? new String(data.firstChild.nodeValue) : "")
: this.unserialize(child);
break;
default:
throw new Error(jpf.formatErrorString(1088, null, "", "Malformed XMLRPC Message: " + data.tagName));
return false;
break;
}
}
this.isValid = function(extra){
var data = extra.data;
if (jpf.getNode(data, [0]).tagName == "fault") {
if (!jpf.isSafari) {
var nr = data.selectSingleNode("//member[name/text()='faultCode']/value/int/text()").nodeValue;
var msg = "\n" + data.selectSingleNode("//member[name/text()='faultString']/value/string/text()").nodeValue;
}
else {
nr = msg = ""
}
extra.message = msg;
return false;
}
extra.data = jpf.getNode(data, [0, 0, 0]);
return true;
}
}
jpf.cgi = function(){
this.supportMulticall = false;
this.namedArguments   = true;
jpf.teleport.register(this);
if (!this.uniqueId) {
jpf.makeClass(this);
this.inherit(jpf.BaseComm, jpf.http, jpf.rpc);
}
this.unserialize = function(str){
return str;
}
this.getSingleCall = function(name, args, obj){
obj.push(args);
}
this.serialize = function(functionName, args){
var vars    = [];
function recur(o, stack){
if (o && o.dataType == "array") {
for (var j = 0; j < o.length; j++)
recur(o[j], stack + "%5B" + j + "%5D");
}
else if (typeof o == "object") {
for (prop in o) {
if (jpf.isSafariOld && (!o[prop] || typeof p[prop] != "object"))
continue;
if (typeof o[prop] == "function")
continue;
recur(o[prop], stack + "%5B" + encodeURIComponent(prop) + "%5D");
}
}
else {
if (typeof o != "undefined" && o !== null) 
vars.push(stack + "=" + encodeURIComponent(o));
}
};
if (this.multicall) {
vars.push("func" + "=" + this.mcallname);
for (var i = 0; i < args[0].length; i++)
recur(args[0][i], "f%5B" + i + "%5D");
}
else {
for (prop in args) {
if (jpf.isSafariOld && (!args[prop] || typeof args[prop] == "function"))
continue;
recur(args[prop], prop);
}
}
if (!this.baseUrl)
this.baseUrl = this.url;
this.url = this.urls[functionName]
? this.urls[functionName]
: this.baseUrl;
if (this.method != "GET")
return vars.join("&");
this.url = this.url + (vars.length
? (this.url.indexOf("?") > -1 ? "&" : "?") + vars.join("&")
: "");
return "";
}
this.$load = function(x){
this.method      = (x.getAttribute("http-method") || "GET").toUpperCase();
this.contentType = this.method == "GET"
? null
: "application/x-www-form-urlencoded";
if (x.getAttribute("method-name")) {
var mName = x.getAttribute("method-name");
var nodes = x.childNodes;
for (var v, i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType != 1)
continue;
v = nodes[i].insertBefore(x.ownerDocument.createElement("variable"),
nodes[i].firstChild);
v.setAttribute("name",  mName);
v.setAttribute("value", nodes[i].getAttribute("name"));
}
}
}
this.submitForm = function(form, callback){
if (!this['postform'])
this.addMethod('postform', callback);
var args = [];
for (var i = 0; i < form.elements.length; i++) {
if (!form.elements[i].name)
continue;
if (form.elements[i].tagname = 'input'
&& (form.elements[i].type == 'checkbox'
|| form.elements[i].type == 'radio')
&& !form.elements[i].checked)
continue;
if (form.elements[i].tagname = 'select' && form.elements[i].multiple) {
for (j = 0; j < form.elements[i].options.length; j++) {
if (form.elements[i].options[j].selected)
args.push(form.elements[i].name
+ "="
+ encodeURIComponent(form.elements[i].options[j].value));
}
}
else {
args.push(form.elements[i].name
+ "="
+ encodeURIComponent(form.elements[i].value));
}
}
var loc               = (form.action || location.href);
this.urls['postform'] = loc + (loc.indexOf("?") > -1 ? "&" : "?") + args.join("&");
this['postform'].call(this);
return false;
}
}
jpf.namespace("datainstr.url", function(xmlContext, options, callback){
if (!options.parsed) {
var url = options.instrData.join(":");
if (xmlContext) {
url = url.replace(/\{(.*?)\}/g,
function(m, xpath){
var o = xmlContext.selectSingleNode(xpath);
return o
? (o.nodeType >= 2 && o.nodeType <= 4
? o.nodeValue
: jpf.xmldb.convertXml(o, "cgivars"))
: ""
});
}
var split    = url.split("?");
url      = split.shift();
var query    = split.join("?");
var args     = options.args;
var httpBody = (args && args.length)
? (args[0].nodeType
? args[0].xml || args[0].serialize()
: jpf.serialize(args[0]))
: query;
if (options.preparse) {
options.parsed = [query, httpBody];
options.preparse = false;
return;
}
}
else {
var query    = options.parsed[0];
var httpBody = options.parsed[1];
}
var oHttp = new jpf.http();
oHttp.contentType = "application/x-www-form-urlencoded";
oHttp.method = (options.instrType.replace(/url.?/, "") || "GET").toUpperCase();
oHttp.get(jpf.getAbsolutePath(jpf.appsettings.baseurl, url + (oHttp.method == "GET" ? "?" + query : "")), callback,
jpf.extend({data : httpBody}, options));
});
jpf.Init.addConditional(function(){
jpf.dispatchEvent("domready");
}, null, ["body", "class"]);
jpf.addDomLoadEvent(function(){jpf.Init.run('body');});
jpf.start();
