
var jpf = {
VERSION:'1.0rc1',
CDN            : "http://cdn.ajax.org/platform/",
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.hasContentEditable        = jpf.isIE || jpf.isSafari;
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(){
var sHref = location.href.split("?")[0];
this.host     = location.hostname;
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();
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 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)) {
this.namespace(ns, this.nsqueue[ns]);
}
}
}catch(e){
this.nsqueue[name] = oNamespace;
}
},
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 = {
"draggable"        : true,
"resizable"        : true,
"visible"          : true,
"focussable"       : true,
"disabled"         : true,
"disable-keyboard" : true
}
o.$supportedProperties = [
"draggable", "resizable",
"focussable", "zindex", "disabled", "tabindex",
"disable-keyboard", "contextmenu", "visible", "autosize",
"loadjml", "actiontracker"];
}
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){
},
include : function(sourceFile, doBase){
jpf.console.info("including js file: " + sourceFile);
var sSrc = doBase ? (jpf.basePath || "") + sourceFile : sourceFile;
if (/WebKit/i.test(navigator.userAgent)) {
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;
},
jmlParts : [],
parseStrategy : 0,
parsePartialJml : function(docElement){
if (jpf.isIE) {
var findJml = function(htmlNode){
var tags = {"IMG":1,"LINK":1,"META":1,"INPUT":1,"BR":1,"HR":1,"AREA":1,"BASEFONT":1};
var strXml = (htmlNode.parentNode.outerHTML.replace(/\n/g, "").match(
new RegExp(htmlNode.outerHTML.replace(/([\(\)\|\\\.\^\$\{\}\[\]])/g, "\\$1")
+ ".*" + htmlNode.tagName))[0] + ">")
.replace(/(\w+)\s*=\s*([^\>"'\s ]+)( |\s|\>|\/\>)/g, "$1=\"$2\"$3")
.replace(/ disabled /g, " disabled='true' ")
.replace(/<(\w+)(\s[^>]*[^\/])?>/g, function(m, tag, c){
if (tags[tag]) {
return "<" + tag + (c||"") + "/>";
}
else {
return m;
}
});
var p = prefix.toLowerCase();
var xmlNode = jpf.getJmlDocFromString("<div jid='"
+ (id++) + "' " + strXmlns + ">"
+ strXml + "</div>").documentElement;
while(xmlNode.childNodes.length > 1) {
xmlNode.removeChild(xmlNode.lastChild);
}
jpf.AppNode.appendChild(xmlNode);
}
}
else {
var findJml = function(htmlNode){
var strXml = htmlNode.outerHTML
.replace(/ _moz-userdefined=""/g, "");
var p = prefix.toLowerCase();
var xmlNode = jpf.getJmlDocFromString("<div jid='"
+ (id++) + "' " + strXmlns + ">"
+ strXml + "</div>").documentElement;
while(xmlNode.childNodes.length > 1) {
xmlNode.removeChild(xmlNode.lastChild);
}
if (jpf.isSafari)
xmlNode = jpf.AppNode.ownerDocument.importNode(xmlNode, true);
jpf.AppNode.appendChild(xmlNode);
}
}
var strHtml = document.body.outerHTML;
var match = strHtml.match(/(\w+)\s*=\s*["']http:\/\/www\.javeline\.com\/2005\/jml["']/);
if (!match)
return false;
var strXmlns = "xmlns:" + match[0];
var prefix = (RegExp.$1 || "").toUpperCase();
if (jpf.isOpera)
prefix = prefix.toLowerCase();
if (!prefix)
return false;
prefix += ":";
jpf.AppNode = jpf.getJmlDocFromString("<" + prefix.toLowerCase()
+ "application " + strXmlns + " />").documentElement;
var temp;
var cnode, isPrefix = false, id = 0, str, x, node = document.body;
while (node) {
isPrefix = node.nodeType == 1
&& node.tagName.substr(0,2) == prefix;
if (isPrefix) {
findJml(cnode = node);
if (jpf.isIE) {
loop = node;
var count = 1, next = loop.nextSibling;
if (next) {
loop.parentNode.removeChild(loop);
while (next && (next.nodeType != 1 || next.tagName.indexOf(prefix) > -1)){
if (next.nodeType == 1)
count += next.tagName.charAt(0) == "/" ? -1 : 1;
if (count == 0) {
if (temp)
temp.parentNode.removeChild(temp);
temp = next;
break;
}
next = (loop = next).nextSibling;
if (!next) {
next = loop;
break;
}
if (loop.nodeType == 1) {
loop.parentNode.removeChild(loop);
if (temp) {
temp.parentNode.removeChild(temp);
temp = null;
}
}
else {
if (temp)
temp.parentNode.removeChild(temp);
temp = loop;
}
}
node = next; 
}
else {
if (temp)
temp.parentNode.removeChild(temp);
temp = loop;
}
}
else {
if (temp)
temp.parentNode.removeChild(temp);
temp = node;
}
if (jpf.jmlParts.length
&& jpf.jmlParts[jpf.jmlParts.length-1][1] == cnode)
jpf.jmlParts[jpf.jmlParts.length-1][1] = -1;
jpf.jmlParts.push([node.parentNode, jpf.isIE
? node.nextSibling : node.nextSibling]);
}
else if (node.tagName == "SCRIPT" && node.getAttribute("src")
&& (node.getAttribute("src").indexOf("ajax.org") > -1
|| node.getAttribute("src").indexOf("javeline.com") > -1)) {
var strXml = node.outerHTML
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&amp;/g, "&")
.replace(/<SCRIPT[^>]*\>\s*<\!\[CDATA\[>?/i, "")
.replace(/<SCRIPT[^>]*\>(?:<\!\-\-)?/i, "")
.replace(/(\/\/)?\s*\&\#8211;>\s*<\/SCRIPT>/i, "")
.replace(/\-\->\s*<\/SCRIPT>/i, "")
.replace(/\]\](?:\&gt\;|>)\s*<\/SCRIPT>/i, "")
.replace(/<\/SCRIPT>$/mi, "")
.replace(/<\/?\s*(?:p|br)\s*\/?>/ig, "")
.replace(/<\!--\s*.*?\s*--><script.*/ig, "");
if (strXml.trim()) {
var xmlNode = jpf.getJmlDocFromString("<div jid='"
+ (id++) + "' " + strXmlns + ">"
+ strXml + "</div>").documentElement;
if (jpf.isSafari)
xmlNode = jpf.AppNode.ownerDocument.importNode(xmlNode, true);
jpf.AppNode.appendChild(xmlNode);
jpf.jmlParts.push([node.parentNode, node.nextSibling]);
}
}
if (!isPrefix && node.firstChild
|| node.nextSibling) {
if (!isPrefix && node.firstChild) {
node = node.firstChild;
}
else {
node = node.nextSibling;
}
}
else {
do {
node = node.parentNode;
if (node.tagName == "BODY")
node = null;
} while (node && !node.nextSibling)
if (node) {
node = node.nextSibling;
}
}
}
if (temp)
temp.parentNode.removeChild(temp);
},
loadIncludes : function(docElement){
if (this.parseStrategy == 1 || !this.parseStrategy && !docElement
&& document.documentElement.outerHTML.split(">", 1)[0]
.indexOf(jpf.ns.jml) == -1) {
this.parsePartialJml(docElement);
if (this.parseStrategy == 1 || jpf.jmlParts.length) {
jpf.isParsingPartial = true;
jpf.loadJmlIncludes(jpf.AppNode);
if (!self.ERROR_HAS_OCCURRED) {
jpf.Init.interval = setInterval(function(){
if (jpf.checkLoaded())
jpf.initialize();
}, 20);
}
return;
}
else {
}
}
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) {
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(); 
jpf.skins.defaultSkin = '<?xml version="1.0" encoding="utf-8"?><j:skin xmlns:j="http://www.javeline.com/2005/jml" xmlns="http://www.w3.org/1999/xhtml"><j:bar name="bar"><j:style><![CDATA[#jem.jpf_bar{position: relative;color: #4b4b4b;font-family: Tahoma;font-size: 10px;padding: 10px;border: 1px solid #f3f3f3;cursor : default;margin : 0;background:white url(images/resizehandle.gif) no-repeat right bottom;z-index:10000;}#jem.jpf_bar img {position:absolute;bottom:13px;left:216px;}#jem.jpf_bar .jpf_volume {position: absolute;bottom: 7px;right: 6px;}#jem.jpf_bar .jpf_counter {position: absolute;bottom: 5px;left: 45px;}#jem.jpf_bar .jpf_countdown {position: absolute;bottom: 5px;right: 140px;}#jem.jpf_bar .jpf_mute {position: absolute;bottom: 6px;right: 114px;left: auto;background: none;width: 16px;height: 16px;margin: 0;padding: 0;} #jem.jpf_bar .jpf_mute span {margin: 0;padding: 0;width: 16px;height: 16px;}]]></j:style><j:presentation><j:main container="." resize-corner="17"><div class="jpf_bar" id="jem"> </div></j:main></j:presentation></j:bar><j:label name="label"><j:style><![CDATA[#jem .jpf_label{font-size: 8pt;font-family: Tahoma;overflow: hidden;cursor: default;line-height : 1.5em;margin : 0;}#jem .jpf_labelDisabled{color: #bebebe;}#jem .tiny {font-size : 9px;}#jem .error .jpf_label{background : url(images/alert.png) no-repeat 0 0;min-height : 37px;padding : 3px 0 0 45px;}]]></j:style><j:presentation><j:main caption="." for="@for"><div class="jpf_label"> </div></j:main></j:presentation></j:label><j:slider name="slider"><j:style><![CDATA[#jem .jpf_slider {background: url("images/bar_right.png") no-repeat top right;height: 8px;position: relative;font-family : Tahoma;font-size : 9px;text-align : center;position: absolute;bottom: 10px;right: 28px;margin : 0;}#jem .jpf_sliderDisabled {background-position: right -8px;}#jem .jpf_slider .jpf_left{background: url("images/bar_left.png") no-repeat top left;height: 8px;overflow: hidden;margin : 0;margin-right : 4px;}#jem .jpf_sliderDisabled .jpf_left{background-position: left -8px;}#jem .jpf_sliderDisabled .jpf_filledbar {background-position: 0 -8px;}#jem .jpf_slider .jpf_grabber {background: url("images/slider.png") no-repeat top left;width: 20px;height: 8px;overflow: hidden;position: absolute;margin : 0;}#jem .jpf_sliderDisabled .jpf_grabber {background-position: left -8px;}]]></j:style><j:presentation><j:main slider="div[1]" container="." status2="div[2]/text()" markers="." direction="horizontal"><div class="jpf_slider"><div class="jpf_grabber"> </div><div class="jpf_left"> </div></div></j:main><marker><u> </u></marker></j:presentation></j:slider><j:slider name="slider16"><j:style><![CDATA[#jem .jpf_slider16 {background: url("images/bar16x_right.png") no-repeat top right;width: 300px;height: 16px;position: relative;padding-right: 7px;font-family : Tahoma;font-size : 9px;text-align : center;position: absolute;bottom: 6px;left: 82px;margin : 0;}#jem .jpf_slider16Disabled {background-position: right -16px;}#jem .jpf_slider16 .jpf_left{background: url("images/bar16x_left.png") no-repeat top left;height: 16px;overflow: hidden;margin : 0;}#jem .jpf_slider16Disabled .jpf_left{background-position: left -16px;}#jem .jpf_slider16 .jpf_grabber {background: url("images/slider16x.png") no-repeat top right;width: 40px;height: 16px;overflow: hidden;position: absolute;margin : 0;}#jem .jpf_slider16Disabled .jpf_grabber {background-position: left -16px;margin-left : 7px;}#jem .jpf_slider16 .jpf_sldprogress{background : #ddd;display : block;overflow : hidden;height : 4px;margin-left : 6px;margin-top : 6px;z-index : 0;}]]></j:style><j:presentation><j:main slider="div[1]" container="." progress="div[2]" status2="div[2]/text()" markers="." direction="horizontal"><div class="jpf_slider16"><div class="jpf_grabber"> </div><div class="jpf_left"> </div></div></j:main><progress><span class="jpf_sldprogress"> </span></progress><marker><u> </u></marker></j:presentation></j:slider><j:button name="button"><j:style><![CDATA[#jem .jpf_button{color: #4b4b4b;font-family: Tahoma;font-size: 8pt;height: 19px;width : 34px;overflow: hidden;cursor : default;background : url(images/mediabtn.png) no-repeat 0 0;position: absolute;bottom: 3px;left: 3px;margin : 0;}#jem .jpf_buttonDefault {background-position: 0 0;}#jem .jpf_buttonDisabled {background-position: 0 -38px;}#jem .jpf_buttonDown {background-position: 0 -38px;}#jem .jpf_button span{display : block;background : no-repeat 0 0;width : 11px;height : 10px;margin : 4px auto 0 auto;}]]></j:style><j:presentation><j:main background="span"><div class="jpf_button"><span> </span></div></j:main></j:presentation></j:button><j:video name="video"><j:style><![CDATA[#jem .jpf_video {line-height:300px;margin:0;padding:0;text-align:center;vertical-align:middle;overflow : hidden;background : black;}#jem .jpf_video #qt_event_source{position : absolute;left : 0;top : 0;}]]></j:style><j:presentation><j:main container="."><div class="jpf_video"> </div></j:main></j:presentation></j:video></j:skin>';
if (!jpf.skins.skins["default"] && jpf.skins.defaultSkin) {
var xmlNode = jpf.getJmlDocFromString(jpf.skins.defaultSkin).documentElement; 
xmlNode.setAttribute("media-path", jpf.CDN + jpf.VERSION + "/images/")
xmlNode.setAttribute("icon-path", jpf.CDN + jpf.VERSION + "/icons/")
jpf.skins.Init(xmlNode);
}
if (jpf.isParsingPartial) {
if (!jpf.window) {
jpf.window          = new jpf.WindowImplementation();
jpf.document        = new jpf.DocumentImplementation();
}
jpf.appsettings.init();
jpf.hasSingleRszEvent = true;
var pHtmlNode = document.body;
var lastChild = pHtmlNode.lastChild;
jpf.JmlParser.parseMoreJml(jpf.AppNode, pHtmlNode, null,
true, false);
var pNode, firstNode, lastBefore = null, next, info, loop = pHtmlNode.lastChild;
while (loop && lastChild != loop) {
info = jpf.jmlParts[loop.getAttribute("jid")];
next = loop.previousSibling;
if (info) {
pNode = info[0];
if ("P".indexOf(pNode.tagName) > -1) {
lastBefore = pNode.parentNode.insertBefore(jpf.getNode(loop, [0]),
pNode);
}
else {
firstNode = jpf.getNode(loop, [0]);
if (firstNode) {
lastBefore = pNode.insertBefore(firstNode,
typeof info[1] == "number" ? lastBefore : info[1]);
}
else
lastBefore = typeof info[1] == "number" ? lastBefore : info[1];
}
loop.parentNode.removeChild(loop);
}
loop = next;
}
setTimeout("jpf.layout.forceResize();");
}
else
{
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){
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);
}
};
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 (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.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(";") : []);
if (!nodes.contains(o.uniqueId)) 
nodes.push(o.uniqueId);
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.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.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, undoObj){
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); 
(xpath ? pNode.selectSingleNode(xpath) : 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 ("|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 ("|remove|move-away|".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) {
undoObj.xmlNode = xmlNode;
jpf.xmldb.notifyQueued();
}
else if (runTimer) {
clearTimeout(notifyTimer);
notifyTimer = setTimeout(function(){
jpf.xmldb.notifyQueued();
});
}
};
this.notifyQueued = function(){
for (var uId in notifyQueue) {
var q = notifyQueue[uId];
jmlNode = jpf.lookup(uId);
if (!jmlNode)
continue;
if (jmlNode.$listenRoot) {
var model = o.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){
var xmlNode, foundpath = "", paths = xPath.split("\|")[0].split("/");
if (xmlNode = contextNode.selectSingleNode(xPath)) 
return xmlNode;
for (var addedNode, isAdding = false, i = 0; i < paths.length - 1; i++) {
if (!isAdding && contextNode.selectSingleNode(foundpath
+ (i != 0 ? "/" : "") + paths[i])) {
foundpath += (i != 0 ? "/" : "") + paths[i];
continue;
}
isAdding = true;
addedNode = contextNode.selectSingleNode(foundpath || ".")
.appendChild(contextNode.ownerDocument.createElement(paths[i]));
if (addedNodes)
addedNodes.push(addedNode);
foundpath += paths[i] + "/";
}
if (!foundpath) 
foundpath = ".";
else 
foundpath = foundpath.substr(0, foundpath.length-1);
var lastpath = paths[paths.length - 1];
if (lastpath.match(/^\@(.*)$/)) {
var attrNode = contextNode.ownerDocument.createAttribute(RegExp.$1);
contextNode.selectSingleNode(foundpath).setAttributeNode(attrNode);
return attrNode;
}
else if (lastpath.trim() == "text()") 
return contextNode.selectSingleNode(foundpath)
.appendChild(contextNode.ownerDocument.createTextNode(""));
else 
return contextNode.selectSingleNode(foundpath)
.appendChild(contextNode.ownerDocument.createElement(lastpath));
};
this.getXmlDocId = function(xmlNode, model){
var docId = (xmlNode.ownerDocument.documentElement || xmlNode)
.getAttribute(this.xmlDocTag) || xmlDocLut.indexOf(xmlNode.ownerDocument);
if (docId && docId > -1)
return docId;
docId = xmlDocLut.push(xmlNode.ownerDocument.documentElement
|| xmlNode.ownerDocument || xmlNode) - 1;
if (xmlNode.ownerDocument.documentElement) 
xmlNode.ownerDocument.documentElement.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){
var str = [], 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(name);
if (sameNodes.length > 1) {
for (var j = 0; j < sameNodes.length; j++) {
str.push(this.cgivars(sameNodes[j],
(basename ? basename + "." : "") + name + "[" + j + "]"));
}
}
else 
str.push(this.cgivars(nodes[i],
(basename ? basename + "." : "") + name));
}
return filled
? str.join("&")
: (basename || "") + "=" + encodeURIComponent(
jpf.getXmlValue(xml, "text()"));
}
};
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.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      = {};
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;
}
}
		
		
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;
}
}
}
		
		
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.preventDefault = function(){
	    this.returnValue = false;
	}
	
	this.stopPropagation = function(){
	    this.cancelBubble = true;
	}
	
jpf.extend(this, data);
};
jpf.inherit(jpf.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 = {
"draggable"        : true,
"resizable"        : true,
"disable-keyboard" : true,
"visible"          : true,
"focussable"       : true,
"disabled"         : true
};
this.$supportedProperties = [
"draggable", "resizable",
"focussable", "zindex", "disabled", "tabindex",
"disable-keyboard", "contextmenu", "visible", "autosize", 
"loadjml", "actiontracker"];
} 
else {
this.$booleanProperties   = {}; 
this.$supportedProperties = []; 
}
this.inherit(jpf.Class);
this.inherit.apply(this, aImpl);
this.inherit(jpf.JmlElement, this.base || jpf.K);
if (this['init'] && 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 (this['init'] && 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;
this.focussed = null;
jpf.dispatchEvent("movefocus", {
fromElement : jmlNode
});
};
var lastFocusParent;
this.addEventListener("focus", function(e){
if (!jpf.window.focussed && lastFocusParent) {
jpf.window.$focusLast(lastFocusParent);
}
});
this.addEventListener("blur", function(e){
if (!jpf.window.focussed)
return;
jpf.window.focussed.blur(true, {srcElement: this});
lastFocusParent = jpf.window.focussed.$focusParent;
jpf.window.focussed = null;
});
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();
};
var timer, state = "", last = "";
this.$focusfix = function(){
state += "a";
clearTimeout(timer);
setTimeout("window.focus();");
timer = setTimeout(determineAction);
}
this.$focusfix2 = function(){
state += "b";
clearTimeout(timer);
timer = setTimeout(determineAction);
}
this.$blurfix = function(){
state += "c";
clearTimeout(timer);
timer = setTimeout(determineAction);
}
function determineAction(){
clearTimeout(timer);
if (state == "e" || state == "c"
|| state.charAt(0) == "x" && !state.match(/eb$/)
|| state == "ce" || state == "de") { 
if (last != "blur") {
last = "blur";
jpf.window.dispatchEvent("blur");
}
}
else {
if (last != "focus") {
last = "focus";
jpf.window.dispatchEvent("focus");
}
}
state = "";
timer = null;
}
window.onfocus = function(){
if (jpf.hasFocusBug) {
state += "d";
clearTimeout(timer);
timer = setTimeout(determineAction);
}
else {
clearTimeout(iframeFixTimer)
iframeFix.newState = "focus";
iframeFixTimer = setTimeout(iframeFix, 10);
}
};
window.onblur = function(){
if (jpf.hasFocusBug) {
state += "e";
clearTimeout(timer);
timer = setTimeout(determineAction);
}
else {
clearTimeout(iframeFixTimer)
iframeFix.newState = "blur";
iframeFixTimer = setTimeout(iframeFix, 10);
}
};
var iframeFixTimer;
function iframeFix(){
clearTimeout(iframeFixTimer);
var newState = iframeFix.newState;
if (last == newState)
return;
last = newState;
jpf.window.dispatchEvent(last);
}
this.hasFocus = function(){
return last == "focus";
}
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);
var p;
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)
jpf.window.$focusLast(jmlNode, {mouse: true});
else
jpf.window.$focusDefault(jmlNode, {mouse: true});
}
else
jpf.window.$focusDefault(jmlNode, {mouse: true});
if (jpf.hasFocusBug) {
var isContentEditable = ta[(e.srcElement || e.target).tagName]
&& !(e.srcElement || e.target).disabled || jmlNode.$isContentEditable
&& jmlNode.$isContentEditable(e) && !jmlNode.disabled;
if (!jmlNode || !isContentEditable)
jpf.window.$focusfix();
}
else if (!last) {
window.onfocus();
}
if (!jpf.isIE && (jpf.JmlParser && !jpf.appsettings.allowSelect
&& (!jpf.isParsingPartial || jmlNode)
|| jpf.dragmode.mode
) && !ta[e.target.tagName])
return false;
};
document.onselectstart = function(e){
if (!e) e = event;
if (jpf.JmlParser && !jpf.appsettings.allowSelect
|| jpf.dragmode.mode
|| jpf.dragmode.isDragging
)
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);
};
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
};
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 && 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))) {
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.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 {};
};
};
jpf.sanitizeTextbox = function(oTxt){
oTxt.onfocus = function(){
jpf.window.$focusfix2();
};
oTxt.onblur = function(){
jpf.window.$blurfix();
};
}
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){
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){
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 = false;        
jpf.dragmode.isDragging = true;
overThreshold           = false;
posAbs = "absolute|fixed".indexOf(jpf.getStyle(_self.oExt, "position")) > -1;
if (!posAbs)
_self.oExt.style.position = "relative";
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();
jpf.dragmode.mode = true;
document.onmousemove = dragMove;
document.onmouseup   = function(){
document.onmousemove = document.onmouseup = null;
jpf.dragmode.mode = false;
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 (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 = false;        
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.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 (lastCursor === null)
lastCursor = document.body.style.cursor;
document.body.style.cursor = resizeType + "-resize";
jpf.dragmode.mode = true;
document.onmousemove = resizeMove;
document.onmouseup   = function(e){
document.onmousemove = document.onmouseup = null;
jpf.dragmode.mode = false;
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 (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 (y < rszborder + marginBox[0])
cursor = posAbs ? "n" : "";
else if (y > this.offsetHeight - rszborder) 
cursor = "s";
else if (y > this.offsetHeight - rszcorner) 
tcursor = "s";
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 __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"]      = false;
this.$booleanProperties["fullscreen"] = true;
this.$supportedProperties.push("position", "networkState", "readyState",
"progress", "buffered", "bufferedBytes", "totalBytes", "currentTime",
"paused", "seeking", "volume", "type", "src", "autoplay", "controls");
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) 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.load();
}
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.$propHandlers["fullscreen"] = function(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.setProperty('buffered',      {start: 0, end: 0, length: 0});
this.setProperty('bufferedBytes', {start: 0, end: 0, length: 0});
this.setProperty('totalBytes',    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.load = 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
var __DATABINDING__ = 1 << 1;
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 nodes = $xmlns(xmlNode, "style", jpf.ns.jml), tnode, node;
for (var 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 {
var test = eval(node.getAttribute("condition"));
}
catch (e) {
test = false;
}
}
if (test) {
tnode = node.firstChild;
while (tnode) {
this.css.push(tnode.nodeValue);
tnode = tnode.nextSibling;
}
}
}
}
var nodes = xmlNode.selectNodes("alias");
for (var 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;
}
};
},
setIcon : function(oHtml, strQuery, iconPath){
if (!strQuery) {
oHtml.style.backgroundImage = "";
return;
}
if (oHtml.tagName.toLowerCase() == "img") {
oHtml.setAttribute("src", strQuery
? (iconPath || "") + strQuery
: "");
return;
}
{
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){
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);
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 l, newclasses = [],
classes    = (oExt.className || "").splitSafe("\s+");
for (var 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.value)
this.$propHandlers["value"].call(this, this.value);
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)
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"]);
};
}
this.$setClearMessage    = function(msg){};
this.$updateClearMessage = function(){}
this.$removeClearMessage = function(){};
};
var __ALIGNMENT__ = 1 << 12;
var __VALIDATION__ = 1 << 6;
var __CACHE__ = 1 << 2;
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.sentToBack    = function(){
this.setProperty("zindex", 0);
};
this.bringToFront  = function(){
this.setProperty("zindex", jpf.all.length + 1);
};
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);
if (!nofix && jpf.hasFocusBug)
jpf.window.$focusfix();
}
return;
}
this.$focus(e);
this.dispatchEvent("focus", {
srcElement : this,
bubbles    : true
});
};
this.blur = function(noset, e){
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) {
this.inherit(jpf.MultiLang); 
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)
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 (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].destroySelf)
nodes[k].destroySelf();
if (oItem.$jml && oItem.$jml.parentNode)
oItem.$jml.parentNode.removeChild(oItem.$jml);
oItem.destroySelf();
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(__MULTISELECT__) && !this.change) {
this.change = function(value){
if (this.dispatchEvent("beforechange", {value : value}) === false)
return;
this.setProperty("value", value);
return this.dispatchEvent("afterchange", {value : 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) || 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))
jpf.window.moveNext();
}
else if(jpf.isTrue(value)) {
this.oExt.style.display = "block"; 
if (this.$show && !this.$noAlignUpdate)
this.$show();
}
},
"disabled": function(value){
if (this.canHaveChildren) {
function loopChildren(nodes){
for (var node, i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
node.setProperty("disabled", value);
if (node.childNodes.length)
loopChildren(node.childNodes);
}
}
loopChildren(this.childNodes);
this.disabled = undefined;
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);
},
"jml": function(value){
this.insertJml(value);
this.$isSelfLoading = true;
}
};
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) {
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){
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) {
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;
var __TRANSACTION__ = 1 << 3;
var __RENAME__ = 1 << 10;
var __XFORMS__ = 1 << 17;
var __EDITMODE__  = 1 << 15;
var __MULTILANG__ = 1 << 16;
jpf.language = {
automatch : false,
prefix    : "sub.main.",
words     : {},
texts     : {},
elements  : {},
count     :  0,
loadXml   : function(xmlNode, prefix){
if (typeof xmlNode == "string") 
xmlNode = jpf.getXmlDom(xmlNode).documentElement;
this.parseSection(xmlNode, prefix);
},
loadForm  : function(instruction) {
jpf.setModel(instruction, {
load: function(xmlNode){
if (!xmlNode || this.isLoaded) return;
jpf.language.loadXml(xmlNode);
this.isLoaded = true;
},
setModel: function(model, xpath){
if (typeof model == "string")
model = jpf.nameserver.get("model", model);
model.register(this, xpath);
}
});
},
parseSection: function(xmlNode, prefix){
if (!prefix) 
prefix = "";
if (xmlNode.tagName == "key") {
prefix += "." + xmlNode.getAttribute("id");
this.update(prefix, xmlNode.firstChild ? xmlNode.firstChild.nodeValue : "");
return;
}
if (xmlNode.tagName == "group") 
prefix += (prefix ? "." : "") + xmlNode.getAttribute("id");
var nodes = xmlNode.childNodes;
for (var i = 0; i < nodes.length; i++) 
this.parseSection(nodes[i], prefix);
},
update: function(key, value){
this.words[key] = value;
if (!this.elements[key]) 
return;
for (var i = 0; i < this.elements[key].length; i++) {
if (this.elements[key][i].htmlNode.nodeType == 1) 
this.elements[key][i].htmlNode.innerHTML = value;
else 
this.elements[key][i].htmlNode.nodeValue = value;
}
},
addElement: function(key, oEl){
if (!this.elements[key]) 
this.elements[key] = [];
return this.elements[key].push(oEl) - 1;
},
removeElement: function(key, id){
this.elements[key].removeIndex(id);
},
getWord: function(key){
return this.words[key];
}
};
jpf.MultiLang = function(){
this.$regbase = this.$regbase | __MULTILANG__;
var reggedItems = [];
this.$makeEditable = function(type, htmlNode, jmlNode){
if (jmlNode.prefix != "j") 
return;
var config = this.editableParts[type];
for (var i = 0; i < config.length; i++) {
var subNode = this.$getLayoutNode(type, config[i][0], htmlNode);
if (!subNode) 
continue;
var xmlNode = config
? jpf.xmldb.selectSingleNode(config[i][1], jmlNode)
: jpf.xmldb.getTextNode(jmlNode);
if (!xmlNode) 
continue;
var key = xmlNode.nodeValue.match(/^\$(.*)\$$/); 
if (key) {
subNode = subNode.nodeType == 1
? subNode
: (subNode.nodeType == 3 || subNode.nodeType == 4
? subNode.parentNode
: subNode); 
reggedItems.push([key[1], jpf.language.addElement(key[1], {
htmlNode: subNode
})]);
}
}
};
this.$removeEditable = function(){
for (var i = 0; i < reggedItems.length; i++) {
jpf.language.removeElement(reggedItems[i][0], reggedItems[i][1]);
}
reggedItems = [];
};
this.$jmlDestroyers.push(function(){
this.$removeEditable();
});
};
var __DOCKING__ = 1 << 18;
var __ANCHORING__ = 1 << 13;
jpf.Anchoring = function(){
this.$regbase = this.$regbase | __ANCHORING__;
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["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["left"]  = 
this.$propHandlers["width"] = 
this.$propHandlers["right"] = function(value){
if (!updateQueue && jpf.loaded)
l.queue(this.pHtmlNode, this);
updateQueue = updateQueue | HORIZONTAL;
};
this.$propHandlers["top"]    = 
this.$propHandlers["height"] = 
this.$propHandlers["bottom"] = function(value){
if (!updateQueue && jpf.loaded)
l.queue(this.pHtmlNode, this);
updateQueue = updateQueue | VERTICAL;
};
this.$domHandlers["remove"].push(remove);
this.$domHandlers["reparent"].push(reparent);
this.$hide = function(){
l.removeRule(this.pHtmlNode, this.uniqueId + "_anchors");
l.queue(this.pHtmlNode)
};
this.$show = function(){
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);
};
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 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.oExt.style.position = "absolute";
var rules;
if (updateQueue & HORIZONTAL) {
rules = [];
var left  = this.left;
var right = this.right;
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;
var bottom = this.bottom;
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);
}
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.layout = {
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;
for( prop in this.rules) {
if (document.getElementById(prop).onresize) 
continue;
this.activateRules(document.getElementById(prop));
}
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.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@_)|(\/\/.*)$|("[^"]*")|('[^']*')|\.(\w+)(\s*\()|(\W)(jpf\.document|jpf|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)/gm, 
	        function(m, tag, co, str1, str2, f, fws, nw, kw, nw2) {
	            if (tag) return tag;
	            else if (f)
	                return '.<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.formatJS = function(strJs){
var d = 0;
return strJs.replace(/;+/g, ';').replace(/;}/g, '}').replace(/{;/g, '{').replace(/({)|(})|(;)/g,
function(m, a, b, c){
if (a) d++;
if (b) d--;
var o = '';
for (var i = 0; i < d; i++) 
o += '\t\t';
if (a) return '{\n' + o;
if (b) return '\n' + o + '}';
if (c) return ';\n' + o;
}).replace(/\>/g, '&gt;').replace(/\</g, '&lt;');
};
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.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.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.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();
};
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";
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();
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);
};
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);
};
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 = {
modes : {},
removeMode : function(mode){
this.modes[mode] = null;
},
defineMode : function(mode, struct){
this.modes[mode] = struct;
},
setMode : function(mode){
for (var prop in this.modes[mode])
if (prop.match(/^on/))
document[prop] = this.modes[mode][prop];
this.mode = mode;
},
clear : function(){
for (var prop in this.modes[this.mode])
if (prop.match(/^on/))
document[prop] = null;
this.mode = null;
}
};
jpf.Init.run('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.silverlight = (function() {
var silverlightCount = 0;
var __onSilverlightInstalledCalled = false;
var fwlinkRoot = 'http://go2.microsoft.com/fwlink/?LinkID=';
var __installationEventFired = false;
var onGetSilverlight = null;
function onSilverlightInstalled() {
window.location.reload(false);
}
function isInstalled(version){
if (version == undefined)
version = null;
var isVersionSupported = false;
var container = null;
try {
var control = null;
var tryNS = false;
if (window.ActiveXObject) {
try {
control = new ActiveXObject('AgControl.AgControl');
if (version === null) {
isVersionSupported = true;
}
else if (control.IsVersionSupported(version)) {
isVersionSupported = true;
}
control = null;
}
catch (e) {
tryNS = true;
}
}
else {
tryNS = true;
}
if (tryNS) {
var plugin = navigator.plugins["Silverlight Plug-In"];
if (plugin) {
if (version === null) {
isVersionSupported = true;
}
else {
var actualVer = plugin.description;
if (actualVer === "1.0.30226.2")
actualVer = "2.0.30226.2";
var actualVerArray = actualVer.split(".");
while (actualVerArray.length > 3) {
actualVerArray.pop();
}
while (actualVerArray.length < 4) {
actualVerArray.push(0);
}
var reqVerArray = version.split(".");
while (reqVerArray.length > 4) {
reqVerArray.pop();
}
var requiredVersionPart;
var actualVersionPart;
var index = 0;
do {
requiredVersionPart = parseInt(reqVerArray[index]);
actualVersionPart = parseInt(actualVerArray[index]);
index++;
}
while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) {
isVersionSupported = true;
}
}
}
}
}
catch (e) {
isVersionSupported = false;
}
return isVersionSupported;
}
function WaitForInstallCompletion(){
if (!jpf.silverlight.isBrowserRestartRequired && onSilverlightInstalled) {
try {
navigator.plugins.refresh();
}
catch(e) {}
if (isInstalled(null) && !__onSilverlightInstalledCalled) {
onSilverlightInstalled();
__onSilverlightInstalledCalled = true;
}
else {
setTimeout(WaitForInstallCompletion, 3000);
}    
}
}
function startup() {
navigator.plugins.refresh();
jpf.silverlight.isBrowserRestartRequired = isInstalled(null);
if (!jpf.silverlight.isBrowserRestartRequired) {
WaitForInstallCompletion();
if (!__installationEventFired) {
onInstallRequired();
__installationEventFired = true;
}
}
else if (window.navigator.mimeTypes) {
var mimeSL2 =   navigator.mimeTypes["application/x-silverlight-2"];
var mimeSL2b2 = navigator.mimeTypes["application/x-silverlight-2-b2"];
var mimeSL2b1 = navigator.mimeTypes["application/x-silverlight-2-b1"];
var mimeHighestBeta = mimeSL2b1;
if (mimeSL2b2)
mimeHighestBeta = mimeSL2b2;
if (!mimeSL2 && (mimeSL2b1 || mimeSL2b2)) {
if (!__installationEventFired) {
onUpgradeRequired();
__installationEventFired = true;
}
}
else if (mimeSL2 && mimeHighestBeta) {
if (mimeSL2.enabledPlugin &&
mimeHighestBeta.enabledPlugin) {
if (mimeSL2.enabledPlugin.description !=
mimeHighestBeta.enabledPlugin.description) {
if (!__installationEventFired) {
onRestartRequired();
__installationEventFired = true;
}
}
}
}
}
}
function createObject(source, parentElement, id, properties, events, initParams, userContext) {
var slPluginHelper = {},
slProperties   = properties,
slEvents       = events;
slPluginHelper.version = slProperties.version;
slProperties.source    = source;    
slPluginHelper.alt     = slProperties.alt;
if (initParams)
slProperties.initParams = initParams;
if (slProperties.isWindowless && !slProperties.windowless)
slProperties.windowless = slProperties.isWindowless;
if (slProperties.framerate && !slProperties.maxFramerate)
slProperties.maxFramerate = slProperties.framerate;
if (id && !slProperties.id)
slProperties.id = id;
delete slProperties.ignoreBrowserVer;
delete slProperties.inplaceInstallPrompt;
delete slProperties.version;
delete slProperties.isWindowless;
delete slProperties.framerate;
delete slProperties.data;
delete slProperties.src;
delete slProperties.alt;
if (isInstalled(slPluginHelper.version)) {
for (var name in slEvents) {
if (slEvents[name]) {
if (name == "onLoad" && typeof slEvents[name] == "function" 
&& slEvents[name].length != 1 ) {
var onLoadHandler = slEvents[name];
slEvents[name] = function (sender) {
return onLoadHandler(document.getElementById(id), 
userContext, sender)
};
}
var handlerName = __getHandlerName(slEvents[name]);
if (handlerName != null) {
slProperties[name] = handlerName;
slEvents[name] = null;
}
else {
throw "typeof events."+name+" must be 'function' or 'string'";
}
}
}
slPluginHTML = buildHTML(slProperties);
}
else {
slPluginHTML = buildPromptHTML(slPluginHelper);
}
if (parentElement)
parentElement.innerHTML = slPluginHTML;
else
return slPluginHTML;
}
function buildHTML(slProperties) {
var htmlBuilder = [];
htmlBuilder.push('<object type=\"application/x-silverlight\" data="data:application/x-silverlight,"');
if (slProperties.id != null)
htmlBuilder.push(' id="' + HtmlAttributeEncode(slProperties.id) + '"');
if (slProperties.width != null)
htmlBuilder.push(' width="' + slProperties.width+ '"');
if (slProperties.height != null)
htmlBuilder.push(' height="' + slProperties.height + '"');
htmlBuilder.push(' >');
delete slProperties.id;
delete slProperties.width;
delete slProperties.height;
for (var name in slProperties) {
if (slProperties[name])
htmlBuilder.push('<param name="' + HtmlAttributeEncode(name) 
+ '" value="' + HtmlAttributeEncode(slProperties[name]) + '" />');
}
htmlBuilder.push('<\/object>');
return htmlBuilder.join('');
}
function createObjectEx(params) {
var parameters = params;
var html = createObject(parameters.source, parameters.parentElement, 
parameters.id, parameters.properties, parameters.events, 
parameters.initParams, parameters.context);
if (parameters.parentElement == null)
return html;
}
function buildPromptHTML(slPluginHelper) {
var slPluginHTML = "";
var urlRoot = fwlinkRoot;
var version = slPluginHelper.version ;
if (slPluginHelper.alt) {
slPluginHTML = slPluginHelper.alt;
}
else {
if (!version)
version="";
slPluginHTML = "<a href='javascript:Silverlight.getSilverlight(\"{1}\");' style='text-decoration: none;'><img src='{2}' alt='Get Microsoft Silverlight' style='border-style: none'/></a>";
slPluginHTML = slPluginHTML.replace('{1}', version);
slPluginHTML = slPluginHTML.replace('{2}', urlRoot + '108181');
}
return slPluginHTML;
}
function getSilverlight(version) {
if (onGetSilverlight )
onGetSilverlight();
var shortVer = "";
var reqVerArray = String(version).split(".");
if (reqVerArray.length > 1) {
var majorNum = parseInt(reqVerArray[0]);
if (isNaN(majorNum) || majorNum < 2)
shortVer = "1.0";
else
shortVer = reqVerArray[0]+'.'+reqVerArray[1];
}
var verArg = "";
if (shortVer.match(/^\d+\056\d+$/) )
verArg = "&v="+shortVer;
followFWLink("114576" + verArg);
}
function followFWLink(linkid) {
top.location = fwlinkRoot + String(linkid);
}
function HtmlAttributeEncode(strInput) {
var c;
var retVal = '';
if (strInput == null) return null;
for (var cnt = 0; cnt < strInput.length; cnt++) {
c = strInput.charCodeAt(cnt);
if (((c > 96) && (c < 123)) || (( c > 64) && (c < 91)) 
|| ((c > 43) && (c < 58) && (c != 47)) || (c == 95))
retVal = retVal + String.fromCharCode(c);
else
retVal = retVal + '&#' + c + ';';
}
return retVal;
}
function default_error_handler(sender, args) {
var iErrorCode;
var errorType = args.ErrorType;
iErrorCode = args.ErrorCode;
var errMsg = ["\nSilverlight error message     \n\
ErrorCode: ", iErrorCode, "\n\
ErrorType: ", errorType, "       \n\
Message: ", args.ErrorMessage, "     \n"];
if (errorType == "ParserError") {
errMsg.push("XamlFile: ", args.xamlFile, "     \n\
Line: ", args.lineNumber, "     \n\
Position: ", args.charPosition, "     \n");
}
else if (errorType == "RuntimeError") {
if (args.lineNumber != 0) {
errMsg.push("Line: ", args.lineNumber, "     \n\
Position: ",  args.charPosition, "     \n");
}
errMsg.push("MethodName: ", args.methodName, "     \n");
}
throw new Error(jpf.formatErrorString(0, this, errMsg.join('')));
}
function __cleanup() {
for (var i = silverlightCount - 1; i >= 0; i--)
window['__slEvent' + i] = null;
silverlightCount = 0;
if (window.removeEventListener)
window.removeEventListener('unload', __cleanup , false);
else 
window.detachEvent('onunload', __cleanup );
}
function __getHandlerName(handler) {
var handlerName = "";
if (typeof handler == "string") {
handlerName = handler;
}
else if (typeof handler == "function" ) {
if (silverlightCount == 0) {
if (window.addEventListener) 
window.addEventListener('onunload', __cleanup , false);
else 
window.attachEvent('onunload', __cleanup);
}
var count = silverlightCount++;
handlerName = "__slEvent"+count;
window[handlerName]=handler;
}
else {
handlerName = null;
}
return handlerName;
}
function onRequiredVersionAvailable() {};
function onRestartRequired() {};
function onUpgradeRequired() {};
function onInstallRequired() {};
function IsVersionAvailableOnError(sender, args) {
var retVal = false;
try {
if (args.ErrorCode == 8001 && !__installationEventFired) {
onUpgradeRequired();
__installationEventFired = true;
}
else if (args.ErrorCode == 8002 && !__installationEventFired) {
onRestartRequired();
__installationEventFired = true;
}
else if (args.ErrorCode == 5014 || args.ErrorCode == 2106) {
if (__verifySilverlight2UpgradeSuccess(args.getHost()))
retVal = true;
}
else {
retVal = true;
}
}
catch (e) { }
return retVal;
};
function IsVersionAvailableOnLoad(sender) {
var retVal = false;
try {
if (__verifySilverlight2UpgradeSuccess(sender.getHost()))
retVal = true;
}
catch (e) {}
return retVal;
};
function __verifySilverlight2UpgradeSuccess(host) {
var retVal = false,
version = "2.0.31005",
installationEvent = null;
try {
if (host.IsVersionSupported(version + ".99")) {
installationEvent = onRequiredVersionAvailable;
retVal = true;
}
else if (host.IsVersionSupported(version + ".0")) {
installationEvent = onRestartRequired;
}
else {
installationEvent = onUpgradeRequired;
}
if (installationEvent && !__installationEventFired) {
installationEvent();
__installationEventFired = true;
}
}
catch (e) {}
return retVal;
};
var aIsAvailable = {};
function isAvailable(sVersion) {
if (typeof sVersion == "undefined")
sVersion = "1.0";
if (typeof aIsAvailable[sVersion] == "undefined")
aIsAvailable[sVersion] = isInstalled(sVersion);
return aIsAvailable[sVersion];
}
return {
onGetSilverlight        : null,
isBrowserRestartRequired: false,
startup                 : startup,
createObject            : createObject,
createObjectEx          : createObjectEx,
getSilverlight          : getSilverlight,
default_error_handler   : default_error_handler,
isAvailable             : isAvailable
};
})();
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.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 bw, bh;
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;
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;
}
o = o.offsetParent;
}
return [wt, ht];
};
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));
};
jpf.importClass(jpf.runNonIe, true, self);
}
jpf.runIE = function(){
var hasIE7Security = hasIESecurity = false;
if (hasIESecurity)
jpf.include(jpf.basePath + "teleport/iframe.js");
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){
if (xmlNode.length != null && !xmlNode.nodeType) {
for (var 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 (var i = x.childNodes.length - 1; i >= 0; i--)
htmlNode.appendChild(x.childNodes[jpf.hasDynamicItemList ? 0 : i]);
}
if (!this.nodes)
this.nodes = [];
var id = this.nodes.push(htmlNode.getElementsByTagName("*")) - 1;
setTimeout('jpf.xmldb.doNodes(' + id + ')');
return;
}
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
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(){
jpf.runNonIe();
HTMLDocument.prototype.selectNodes = XMLDocument.prototype.selectNodes = function(sExpr, contextNode){
var oResult = this.evaluate(sExpr, (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.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 : this);
var parsedHTML = r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML);
};
}
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){
if (message) {
var xmlParser = new DOMParser();
xmlParser     = xmlParser.parseFromString(message, "text/xml");
if (!noError)
this.xmlParseError(xmlParser);
}
else {
var 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;
}
if (htmlNode.ownerDocument && htmlNode.ownerDocument != document
&& xmlNode.ownerDocument == htmlNode.ownerDocument)
return htmlNode.insertBefore(xmlNode, beforeNode);
var strHTML = (xmlNode.outerHTML
|| (xmlNode.nodeType == 1 ? xmlNode.xml || xmlNode.serialize() : xmlNode.nodeValue)).replace(/&amp;/g, "&")
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(){};
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);
}
jpf.importClass(jpf.runNonIe, true, self);
}
jpf.JmlParser = {
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;
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", "presentation", "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], ["style", "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();
}
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 (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));
}
jpf.language.addElement(q.nodeValue.replace(/^\$(.*)\$$/,
"$1"), {htmlNode : pHtmlNode});
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 += ":";
}
if (jpf.canUseInnerHtmlWithTables || !parseWhole)
this.parseChildren(x, o, jmlParent);
else {
}
if (jpf.xmldb.getTextNode(x)) {
var data = {
jmlNode  : x,
htmlNode : o
}
jpf.language.addElement(jpf.xmldb.getTextNode(x)
.nodeValue.replace(/^\$(.*)\$$/, "$1"), data);
}
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);
}
},
"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);
}
},
"teleport" : function(q, jmlParent){
return jpf.teleport.loadJml(q, jmlParent);
},
"appsettings" : function(q, jmlParent){
return jpf.appsettings.loadJml(q, jmlParent);
}
, "loader" : function(q){
}
},
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(){
var s = this.stateStack;
for (var i = 0; i < s.length; i++) {
s[i].node.setDynamicProperty(s[i].name, s[i].value);
}
this.stateStack = [];
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.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) {
if (str.indexOf(":") == -1) {
var base = new jpf.url(window.location.toString());
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.runXpath = function(){
jpf.XPath = {
cache : {},
getChildNode : function(htmlNode, tagName, info, count, num, sResult){
var numfound = 0, result = null, data = info[count];
var nodes = htmlNode.childNodes;
if (!nodes) return; 
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;
if (data)
data[0](nodes[i], data[1], info, count + 1, numfound++ , sResult);
else
sResult.push(nodes[i]);
}
},
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);
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);
},
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;
}
}
},
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);
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, "_@_");
}); 
if(sExpr == "/" || sExpr == ".") return sExpr;
sExpr = sExpr.replace(/\/\//g, "descendant::");
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, "|");
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].match(/^[\w-_\.]+(?:\:[\w-_\.]+){0,1}$/))
results.push([this.getChildNode, sections[i]]);
else if (sections[i].match(/^\#\#(\d+)$/))
results.push([this.doQuery, ["num+1 == " + parseInt(RegExp.$1)]]);
else if (sections[i].match(/^\#\#(.*)$/)) {
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]); 
else if (sections[i].substr(0,2) == "[]")
results.push([this.getAllNodes, ["*", false]]);
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]);
else if (sections[i] == "..")
results.push([this.getParentNode, null]);
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].match(/self::(.*)$/))
results.push([this.doQuery, ["jpf.XPath.doXpathFunc('local-name', htmlNode) == '" + RegExp.$1 + "'"]]);
else {
var query = sections[i];
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]])
}
}
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); 
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 : "";
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);
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, "!=");
this.tokenize();
this.insert();
return code;
};
this.tokenize = function(){
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_";});
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.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 (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.BaseSimple = function(){
this.inherit(jpf.Presentation);
this.getValue = function(){
return this.value;
}
}
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);
};
}).implement(jpf.Presentation);
jpf.video = jpf.component(jpf.NODE_VISIBLE, function(){
this.mainBind = "src";
var dbLoad = this.load;
this.load = 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";
}
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.load();
};
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);
}
};
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.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.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"]);
};
jpf.layout.setRules(this.oExt, "knob", "var o = jpf.all[" + this.uniqueId + "];\
o.$propHandlers.value.call(o, o.value);", true);
};
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.Presentation
);
jpf.submit  =
jpf.trigger =
jpf.reset   =
jpf.button  = jpf.component(jpf.NODE_VISIBLE, function(){
var useExtraDiv;
var _self = this;
this.editableParts = {
"main": [["caption", "text()"]]
};
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.dispatchEvent("click");
};
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 (this.oCaption) 
this.oCaption.nodeValue = (value || "").trim();
};
this.$propHandlers["default"] = function(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);
}
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.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(){
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"
}
this.$setupEvents();
};
this.$loadJml = function(x){
if (!this.caption && x.firstChild)
this.setProperty("caption", x.firstChild.nodeValue);
this.$makeEditable("main", this.oExt, this.$jml);
if (!inited) {
jpf.JmlParser.parseChildren(this.$jml, null, this);
inited = true;
}
};
}).implement(jpf.Presentation, jpf.BaseButton);
jpf.audio = jpf.component(jpf.NODE_HIDDEN, function() {
this.$supportedProperties.push("waveform", "peak", "EQ", "ID3");
this.mainBind = "src";
var dbLoad = this.load;
this.load = 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) {
default:
case "mp3":
type = "audio/flash";
break;
}
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++) {
if (mimeType.indexOf('flash') > -1)
playerType = "TypeFlash";
else if (mimeType.indexOf('quicktime') > -1)
playerType = "TypeQT";
else if (mimeType.indexOf('wmv') > -1)
playerType = jpf.isMac ? "TypeQT" : "TypeWmp";
else if (mimeType.indexOf('silverlight') > -1)
playerType = "TypeSilverlight";
if (playerType && jpf.audio[playerType] &&
jpf.audio[playerType].isSupported()) {
return playerType;
}
}
return playerType;
};
this.$isSupported = function() {
return (jpf.audio[this.playerType]
&& jpf.audio[this.playerType].isSupported());
};
this.$initPlayer = function() {
this.player = new jpf.audio[this.playerType](this, this.oExt, {
src         : 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(e) {
if (e.error) {
var oError = this.MediaError(e.error);
if (this.dispatchEvent('error', {
error  : oError,
bubbles: true
}) === false)
throw oError;
}
this.load();
};
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, length: 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 == "connectionError") {
this.networkState = jpf.Media.HAVE_NOTHING;
this.$propHandlers["readyState"].call(this, this.networkState);
}
};
this.$changeHook = function(e) {
if (typeof e.volume != "undefined") {
this.volume = e.volume;
this.muted  = (e.volume > 0);
this.setProperty('volume', e.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);
if (this.autoplay)
this.play();
return this;
};
this.$metadataHook = function(e) {
this.oVideo.setProperty('readyState', jpf.Media.HAVE_METADATA);
if (e.waveData)
this.setProperty('waveform', e.waveData);
if (e.peakData)
this.setProperty('peak', e.peakData);
if (e.eqData)
this.setProperty('EQ', e.eqData);
if (e.id3Data)
this.setProperty('ID3', e.id3Data);
};
this.$draw = function(){
this.oExt = this.pHtmlNode.appendChild(document.createElement("div"));
this.oExt.className = "jpf_audio " + (this.$jml.getAttributeNode("class") || "");
this.oInt = this.oExt;
};
this.$loadJml = function(x){
if (this.setSource()) {
this.$propHandlers["type"].call(this, this.type);
}
};
this.$destroy = function(bRuntime) {
if (this.player && this.player.$detroy)
this.player.$destroy();
delete this.player;
this.player = null;
if (bRuntime)
this.oExt.innerHTML = "";
};
}).implement(
jpf.Media
);
jpf.audio.TypeInterface = {
properties: ["src", "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.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;
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;
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);
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);
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.label = jpf.component(jpf.NODE_VISIBLE, function(){
var _self = this;
this.$focussable = false;
this.editableParts = {
"main": [["caption", "text()"]]
};
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);
this.$makeEditable("main", this.oExt, this.$jml);
};
}).implement(
jpf.BaseSimple
)
jpf.appsettings = {
tagName            : "appsettings",
nodeType           : jpf.NODE_ELEMENT,
nodeFunc           : jpf.NODE_HIDDEN,
disableRightClick  : false,
allowSelect        : false,
autoDisableActions : false,
autoDisable        : true,
disableF5          : true,
autoHideLoading    : true,
disableSpace       : true,
disableBackspace   : true,
useUndoKeys        : false,
outline            : true,
dragOutline        : true,
resizeOutline      : true,
disableTabbing     : false,
skinset            : "default",
name               : "",
tags               : {},
defaults           : {},
init : function(){
if (jpf.isParsingPartial) {
this.disableRightClick  = false;
this.allowSelect        = true;
this.autoDisableActions = true;
this.autoDisable        = false;
this.disableF5          = false;
this.autoHideLoading    = true;
this.disableSpace       = false;
this.disableBackspace   = false;
this.useUndoKeys        = false;
this.disableTabbing     = true;
}
},
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.disableRightClick  = jpf.isTrue(x.getAttribute("disable-right-click"));
this.allowSelect        = jpf.isTrue(x.getAttribute("allow-select"));
this.autoDisableActions = jpf.isTrue(x.getAttribute("auto-disable-actions"));
this.autoDisable        = !jpf.isFalse(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("undo-keys"));
if (x.getAttribute("outline")) {
this.dragOutline    =
this.resizeOutline  =
this.outline        = !jpf.isFalse(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")))
: true;
}
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){
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.DEFAULT_PLAYER = jpf.CDN + jpf.VERSION + "/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.DEFAULT_SWF_PATH    = jpf.CDN + jpf.VERSION + "/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;
return this.callMethod("pause", pauseState);
},
stop: function() {
return this.callMethod("stop");
},
seek: function(millis) {
return this.callMethod("seek", millis / 1000);
},
setVolume: function(iVolume) {
return this.callMethod("setVolume", iVolume);
},
onResize: function() {
clearTimeout(this.resizeTimer);
var _self = this;
this.resizeTimer = window.setTimeout(function() {
_self.setSize();
}, 20);
},
setSize: function() {
return this.callMethod("setSize", this.htmlElement.offsetWidth,
this.htmlElement.offsetHeight);
},
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);
return this;
},
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 "init":
this.inited = true;
this.setSize()
.invalidateProperty("clickToTogglePlay", "skinVisible",
"skinAutoHide", "autoPlay", "autoLoad", "volume", "bufferTime",
"videoScaleMode", "videoAlign", "playheadUpdateInterval",
"previewImagePath").validateNow().makeDelayCalls();
this.oVideo.$initHook({type:"init"});
break;
case "debug":
jpf.console.log('debug: ' + evtObj.msg);
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()");
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
+ "&secureDomain=" + window.location.protocol + "//" + window.location.host
,
"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.player.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) {
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.audio.TypeFlash = function(oAudio, oNode, options) {
this.oAudio              = oAudio;
this.isNine              = jpf.flash.isAvailable('9.0.0');
this.DEFAULT_SWF_PATH    = jpf.basePath + "resources/soundmanager2"
+ (this.isNine ? "_flash9" : "") + ".swf";
this.NULL_MP3_PATH       = jpf.basePath + "resources/null.mp3";
this.id = jpf.flash.addPlayer(this); 
this.inited = false;
this.divName      = oAudio.uniqueId;
this.htmlElement  = oNode;
this.name         = "soundmgr_" + oAudio.uniqueId;
this.audioPath  = options.src;
this.paused     = false;
this.player = null;
jpf.extend(this, jpf.audio.TypeInterface);
this.initProperties().setOptions(options).createPlayer();
}
jpf.audio.TypeFlash.isSupported = function() {
return jpf.flash.isAvailable();
};
jpf.audio.TypeFlash.prototype = {
load: function(audioPath, totalTime) {
if (totalTime != null)
this.setTotalTime(totalTime);
if (audioPath != null)
this.audioPath = audioPath;
if (this.audioPath == null && !this.firstLoad)
return this.oAudio.$errorHook({type:"error", error:"SoundManager::play - No audioPath has been set."});
if (audioPath == null && this.firstLoad && !this.autoLoad) 
audioPath = this.audioPath;
this.firstLoad = false;
this.callMethod('unloadSound', this.NULL_MP3_PATH);
if (this.isNine)
this.callMethod("createSound", this.audioPath, 0, true, true, true, false, false);
else
this.callMethod("createSound", 0);
this.callMethod("setVolume", this.volume)
.callMethod("loadSound", this.audioPath, true, this.autoPlay);
return this;
},
play: function() {
if (!this.paused)
return this.callMethod("startSound", 1, 0);
return this.pause(); 
},
pause: function() {
this.paused = !this.paused;
return this.callMethod("pauseSound");
},
stop: function() {
return this.callMethod("stopSound", true);
},
seek: function(seconds) {
return this.callMethod("setPosition", seconds, this.paused);
},
setVolume: function(iVol) {
return this.callMethod("setVolume", iVol);
},
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() {
if (this.inited && this.player && this.player.callMethod) {
var args = arguments, l = args.length;
switch (l) {
case 1:
this.player.callMethod(args[0]);
break;
case 2:
this.player.callMethod(args[0], args[1]);
break;
case 3:
this.player.callMethod(args[0], args[1], args[2]);
break;
case 4:
this.player.callMethod(args[0], args[1], args[2], args[3]);
break;
case 5:
this.player.callMethod(args[0], args[1], args[2], args[3], args[4]); 
break;
case 6:
this.player.callMethod(args[0], args[1], args[2], args[3], args[4], args[5]);
break;
case 7:
this.player.callMethod(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
break;
case 8:
this.player.callMethod(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
break;
}
}
else
this.delayCalls.push(arguments);
return this;
},
makeDelayCalls: function() {
for (var i = 0; i < this.delayCalls.length; i++)
this.callMethod.apply(this, this.delayCalls[i]);
return this;
},
event: function(eventName, evtObj) {
switch (eventName) {
case "progress":
this.bytesLoaded = evtObj.bytesLoaded;
this.totalBytes  = evtObj.totalBytes;
this.oAudio.$progressHook({
type       : "progress",
bytesLoaded: this.bytesLoaded,
totalBytes : this.totalBytes
});
break;
case "playheadUpdate":
this.playheadTime = evtObj.playheadTime;
this.totalTime    = evtObj.totalTime;
this.oAudio.$changeHook({
type        : "change",
playheadTime: this.playheadTime,
totalTime   : this.totalTime
});
if (evtObj.waveData || evtObj.peakData || evtObj.eqData)
this.oAudio.$metadataHook({
type    : "metadata",
waveData: evtObj.waveData,
peakData: evtObj.peakData,
eqData  : evtObj.eqData
});
break;
case "stateChange":
this.state = evtObj.state;
this.oAudio.$stateChangeHook({type:"stateChange", state:this.state});
break;
case "change":
this.oAudio.$changeHook({type:"change"});
break;
case "complete":
this.oAudio.$completeHook({type:"complete"});
break;
case "ready":
this.callMethod("setPan", 0);
if (this.paused && this.autoPlay)
this.paused = false;
this.oAudio.$readyHook({type:"ready"});
break;
case "metaData":
this.oAudio.$metadataHook({type:"metaData", infoObject:evtObj});
break;
case "cuePoint":
this.oAudio.$cuePointHook({type:"cuePoint", infoObject:evtObj});
break;
case "init":
this.inited = true;
this.invalidateProperty("autoPlay", "autoLoad", "volume", "bufferTime",
"playheadUpdateInterval").validateNow().makeDelayCalls();
this.oAudio.$initHook(jpf.extend(evtObj, jpf.flash.getSandbox(evtObj.sandboxType)));
break;
case "id3":
this.oAudio.$metadataHook({
type: 'metadata',
id3Data: evtObj
});
break;
case "debug":
jpf.console.log(">> SWF DBUG: " + evtObj.msg);
break;
}
},
initProperties: function() {
this.delayCalls = [];
this.totalTime = this.bytesLoaded = this.totalBytes = 0;
this.state = null;
this.autoPlay = this.autoLoad = true;
this.volume                 = 50;
this.playheadTime           = null;
this.bufferTime             = 0.1;
this.playheadUpdateInterval = 1000;
this.firstLoad   = true;
this.pluginError = false;
this.properties = ["volume", "autoPlay", "autoLoad", "playHeadTime",
"totalTime", "bufferTime", "playheadUpdateInterval"];
return this;
},
createPlayer: function() {
var div = this.htmlElement;
if (div == null) return this;
this.pluginError = false;
div.style.position = "absolute";
div.style.width    = "1px";
div.style.height   = "1px";
div.style.left     = "-2000px";
div.innerHTML      = jpf.flash.buildContent(
"src",              this.DEFAULT_SWF_PATH,
"width",            "1",
"height",           "1",
"align",            "middle",
"id",               this.name,
"quality",          "high",
"bgcolor",          "#000000",
"allowFullScreen",  "true",
"name",             this.name,
"flashvars",        "playerID=" + this.id,
"allowScriptAccess","always",
"type",             "application/x-shockwave-flash",
"pluginspage",      "http://www.adobe.com/go/getflashplayer",
"menu",             "true");
this.player        = this.getElement(this.name);
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.player.callMethod("setPolling", true);
return this;
},
setProperty: function(property, value) {
this[property] = value; 
if (this.inited)
this.invalidateProperty(property); 
return this;
},
$destroy: function() {
this.callMethod('destroySound');
if (this.player) {
delete this.player;
this.player = null;
}
}
};
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 
|| options.async === undefined || jpf.isOpera;
if (jpf.isSafari) 
url = jpf.html_entity_decode(url);
var data = options.data || "";
if (jpf.isNot(id)) {
var http = jpf.getHttpReq();
id = this.queue.push({
http     : http, 
url      : url,
callback : callback, 
retries  : 0,
options  : options
}) - 1;
}
else {
var http = this.queue[id].http;
http.abort();
}
if (async) {
{
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);
http.open(this.method || options.method || "GET", httpUrl, 
async, options.username || null, options.password || null);
http.setRequestHeader("User-Agent", "Javeline TelePort 1.0.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) {
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;
if (!window.navigator.onLine && (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 (!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;
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;
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];
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.Init.addConditional(function(){
jpf.dispatchEvent("domready");
}, null, ["body"]);
jpf.addDomLoadEvent(function(){jpf.Init.run('body');});
jpf.start();
