 



Function.getClassName = function() {

 return "Function";

};





 

Function.prototype.Extend = function(superClass) {

 this.prototype = new superClass();



 this.prototype.getSuperClass = function() {

  return superClass;

 };

 this.getSuperClass = this.prototype.getSuperClass;

 return this;

};



 



Function.prototype.Super = function(context, methodName, args) {

 if (null != methodName) {

  var method = this.getSuperClass().prototype[methodName];

 }

 else {

  var method = this.getSuperClass();

 }



 if (!args) {

  return method.call(context);

 }

 else {

  return method.apply(context, args);

 }

};



 

Function.prototype.Implements = function(obj, members) {

 if(typeof obj == "function") {

  obj = obj.prototype;

 }

 var tObj = {}

 for(var i = 0, len = members.length; i < len; ++i) {

  tObj[members[i]] = obj[members[i]] || null;

 }

 var o = WSDOM.Util.copyObject(tObj);

 for(var i in o) {

  this.prototype[i] = o[i];

 }

};



 

Function.prototype.Context = function(obj) {

 var fnReference = this;

 return function () {

  return typeof fnReference == "function" ? fnReference.apply(obj, arguments) : obj[fnReference].apply(obj, arguments);

 };

};

Function.prototype.EmptyFunction = function() {};









WSDOM = new function() {

 var loadedClasses = {};

 var usingReferences = [];



 this.defineClass = function(className, superClass, constructor) {

  loadedClasses[className] = constructor;



  if (null != superClass) {

   loadedClasses[className].Extend(superClass);

  }



  

  loadedClasses[className].prototype.getClassName = function() {

   return className;

  };

  loadedClasses[className].getClassName = loadedClasses[className].prototype.getClassName;



  return loadedClasses[className];

 };



 this.loadClass = function(className) {

  var classDef = parseClassName(className);



  var o = this.getClass(classDef.className);

  if (o) {

   this[o.getClassName()] = o;

   this[o.getClassName()].prototype.namespace = classDef.namespace;

   this[o.getClassName()].prototype.version = classDef.version;

  };

 };



 this.loadSingleton = function(className) {

  var classDef = parseClassName(className);



  var o = this.getClass(classDef.className);

  if (o) {

   this[o.getClassName()] = new o();

   this[o.getClassName()].namespace = classDef.namespace;

   this[o.getClassName()].version = classDef.version;

  };

 };



 this.getClass = function(className) {

  return loadedClasses[className];

 };



 this.getLoadedClasses = function() {

  return loadedClasses;

 };



 this.using = function(originatingClassName, className) {

  usingReferences.push({originatingClassName:originatingClassName, className:className});

 }





 this._processUsingReferences = function() {



  var usingErrors = false;

  for (var x = 0; x < usingReferences.length; x++) {



   var originatingClassName = usingReferences[x].originatingClassName;

   var className = usingReferences[x].className;

   var classDef = parseClassName(className);



   if (!this[classDef.className]) {

    if (this.Console) {

     this.Console.warn("Missing class definition for " + className + ".  Called from " + originatingClassName + ".");

    };

    usingErrors = true;

   } else if (this[classDef.className].version != classDef.version) {

    if (this.Console) {

     this.Console.warn("Version incompatibility for loaded class, " + classDef.className + "." + this[classDef.className].version + ", versus requested class, version " + classDef.version + ".  Called from " + originatingClassName + ".");

    };

    usingErrors = false;

   };



  };

  if (!usingErrors) {

   this.Console.log("WSDOM Framework loaded successfully.");

  };

 };









  

 this._onload = function() {

  var element = window;

  var eventType = "load";

  var fnHandler = this._processUsingReferences.Context(this);



  if (element.addEventListener) {

   

   element.addEventListener(eventType, fnHandler, false);

  }

  else if (element.attachEvent) {

   

   element.attachEvent("on" + eventType, fnHandler);

  };

 };

 this._onload();





 function parseClassName(className) {

  var tokens = className.split('.');



  var classDef = {

   namespace:tokens[0],

   className:tokens[1],

   version:tokens[2]

  };



  return classDef;

 };







 this.identity = function(x) { return x };



}();



WSDOM.using("WSDOM", "WSDOM.Console.1");



Console_class = function () {

 this._isEnabled = false;



 this._origConsole;

 if (("console" in window) && ("firebug" in console)) {

  this._origConsole = console;

 };



 

 



  



 this._stub();

};



Console_class.prototype.enable = function() {



 if (!this._origConsole && (!("console" in window) || !("firebug" in console))) {

  this._origConsole = this._createBackupConsole();

 };



  

 for (var i in this._origConsole) {

  if (!i.match(/firebug/i)) {

   this[i] = this._origConsole[i];

  };

 };

 i = null;

 delete i;



  

 delete this.group;

 delete this.groupEnd;

 this.startGroup = this._origConsole.group;

 this.endGroup = this._origConsole.groupEnd;



 delete this.time;

 delete this.timeEnd;

 this.startTime = this._origConsole.time;

 this.endTime = this._origConsole.timeEnd;





};

Console_class.prototype.disable = function() {

 for (var i in this) {

  

  if (typeof this[i] == "function" && !this.constructor.prototype[i]) {

   this[i] = function() {};

  };

 };

};

Console_class.prototype._stub = function() {

 var methods = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd", "clear", "open", "close", "startGroup", "endGroup", "startTime", "endTime"];



 for (var x = 0; x < methods.length; x++) {

  this[methods[x]] = function() {};

 };



};

Console_class.prototype.link = function() {

 if(arguments.length == 2){

  var description = arguments[0];

  var link = arguments[1];

 } else if(arguments.length == 1) {

  var description = '';

  var link = arguments[0];

 } else {

  return false;

 }

 var a = document.createElement('a');

  a.setAttribute('href', link);

 this.log(description, a);

}

Console_class.prototype._createBackupConsole = function() {

 var backupConsole = new function(){

   this.log = function()

         {

             logFormatted(arguments, "");

         }



         this.link = this.log



         this.debug = function()

         {

             logFormatted(arguments, "debug");

         }



         this.info = function()

         {

             logFormatted(arguments, "info");

         }



         this.warn = function()

         {

             logFormatted(arguments, "warning");

         }



         this.error = function()

         {

             logFormatted(arguments, "error");

         }



         this.assert = function(truth, message)

         {

             if (!truth)

             {

                 var args = [];

                 for (var i = 1; i < arguments.length; ++i)

                     args.push(arguments[i]);



                 logFormatted(args.length ? args : ["Assertion Failure"], "error");

                 throw message ? message : "Assertion Failure";

             }

         }



         this.dir = function(object)

         {

             var html = [];



             var pairs = [];

             for (var name in object)

             {

                 try

                 {

                     pairs.push([name, object[name]]);

                 }

                 catch (exc)

                 {

                 }

             }



             pairs.sort(function(a, b) { return a[0] < b[0] ? -1 : 1; });



             html.push('<table>');

             for (var i = 0; i < pairs.length; ++i)

             {

                 var name = pairs[i][0], value = pairs[i][1];



                 html.push('<tr>',

                 '<td class="propertyNameCell"><span class="propertyName">',

                     escapeHTML(name), '</span></td>', '<td><span class="propertyValue">');

                 appendObject(value, html);

                 html.push('</span></td></tr>');

             }

             html.push('</table>');



             logRow(html, "dir");

         }



         this.dirxml = function(node)

         {

             var html = [];



             appendNode(node, html);

             logRow(html, "dirxml");

         }



         this.group = function()

         {

             logRow(arguments, "group", pushGroup);

         }



         this.groupEnd = function()

         {

             logRow(arguments, "", popGroup);

         }



         this.time = function(name)

         {

             timeMap[name] = (new Date()).getTime();

         }



         this.timeEnd = function(name)

         {

             if (name in timeMap)

             {

                 var delta = (new Date()).getTime() - timeMap[name];

                 logFormatted([name+ ":", delta+"ms"]);

                 delete timeMap[name];

             }

         }



         this.count = function()

         {

             this.warn(["count() not supported."]);

         }



         this.trace = function()

         {

             this.warn(["trace() not supported."]);

         }



         this.profile = function()

         {

             this.warn(["profile() not supported."]);

         }



         this.profileEnd = function()

         {

         }



         this.clear = function()

         {

             consoleBody.innerHTML = "";

         }



         this.open = function()

         {

             toggleConsole(true);

         }



         this.close = function()

         {

             if (frameVisible)

                 toggleConsole();

         }



     



     var consoleFrame = null;

     var consoleBody = null;

     var commandLine = null;



     var frameVisible = false;

     var messageQueue = [];

     var groupStack = [];

     var timeMap = {};



     var clPrefix = ">>> ";



     var isFirefox = navigator.userAgent.indexOf("Firefox") != -1;

     var isIE = navigator.userAgent.indexOf("MSIE") != -1;

     var isOpera = navigator.userAgent.indexOf("Opera") != -1;

     var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1;



     



     function toggleConsole(forceOpen)

     {

         frameVisible = forceOpen || !frameVisible;

         if (consoleFrame)

             consoleFrame.style.visibility = frameVisible ? "visible" : "hidden";

         else

             waitForBody();

     }



     function focusCommandLine()

     {

         toggleConsole(true);

         if (commandLine)

             commandLine.focus();

     }



     function waitForBody()

     {

         if (document.body)

             createFrame();

         else

             setTimeout(waitForBody, 200);

     }



     function createFrame()

     {

         if (consoleFrame)

             return;



         window.onFirebugReady = function(doc)

         {

             window.onFirebugReady = null;



             var toolbar = doc.getElementById("toolbar");

             toolbar.onmousedown = onSplitterMouseDown;



             commandLine = doc.getElementById("commandLine");

             addEvent(commandLine, "keydown", onCommandLineKeyDown);



             addEvent(doc, isIE || isSafari ? "keydown" : "keypress", onKeyDown);



             consoleBody = doc.getElementById("log");

             layout();

             flush();

         }



         var baseURL = window._WSDOM_Console_URL || "/includes/jslib/WSDOM/firebug";



         consoleFrame = document.createElement("iframe");

         consoleFrame.setAttribute("src", baseURL+"/firebug.html");

         consoleFrame.setAttribute("frameBorder", "0");

         consoleFrame.style.visibility = (frameVisible ? "visible" : "hidden");

         consoleFrame.style.zIndex = "2147483647";

         consoleFrame.style.position = "fixed";

         consoleFrame.style.width = "100%";

         consoleFrame.style.left = "0";

         consoleFrame.style.bottom = "0";

         consoleFrame.style.height = "200px";

         document.body.appendChild(consoleFrame);

     }



     function getFirebugURL()

     {

         var scripts = document.getElementsByTagName("script");

         for (var i = 0; i < scripts.length; ++i)

         {

             if (scripts[i].src.indexOf("firebug.js") != -1)

             {

                 var lastSlash = scripts[i].src.lastIndexOf("/");

                 return scripts[i].src.substr(0, lastSlash);

             }

         }

     }



     function evalCommandLine()

     {

         var text = commandLine.value;

         commandLine.value = "";



         logRow([clPrefix, text], "command");



         var value;

         try

         {

             value = eval(text);

         }

         catch (exc)

         {

         }



         WSDOM.Console.log(value);

     }



     function layout()

     {

         var toolbar = consoleBody.ownerDocument.getElementById("toolbar");

         var height = consoleFrame.offsetHeight - (toolbar.offsetHeight + commandLine.offsetHeight);

         consoleBody.style.top = toolbar.offsetHeight + "px";

         consoleBody.style.height = height + "px";



         commandLine.style.top = (consoleFrame.offsetHeight - commandLine.offsetHeight) + "px";

     }



     function logRow(message, className, handler)

     {

         if (consoleBody)

             writeMessage(message, className, handler);

         else

         {

             messageQueue.push([message, className, handler]);

             waitForBody();

         }

     }



     function flush()

     {

         var queue = messageQueue;

         messageQueue = [];



         for (var i = 0; i < queue.length; ++i)

             writeMessage(queue[i][0], queue[i][1], queue[i][2]);

     }



     function writeMessage(message, className, handler)

     {

         var isScrolledToBottom =

             consoleBody.scrollTop + consoleBody.offsetHeight >= consoleBody.scrollHeight;



         if (!handler)

             handler = writeRow;



         handler(message, className);



         if (isScrolledToBottom)

             consoleBody.scrollTop = consoleBody.scrollHeight - consoleBody.offsetHeight;

     }



     function appendRow(row)

     {

         var container = groupStack.length ? groupStack[groupStack.length-1] : consoleBody;

         container.appendChild(row);

     }



     function writeRow(message, className)

     {

         var row = consoleBody.ownerDocument.createElement("div");

         row.className = "logRow" + (className ? " logRow-"+className : "");

         row.innerHTML = message.join("");

         appendRow(row);

     }



     function pushGroup(message, className)

     {

         logFormatted(message, className);



         var groupRow = consoleBody.ownerDocument.createElement("div");

         groupRow.className = "logGroup";

         var groupRowBox = consoleBody.ownerDocument.createElement("div");

         groupRowBox.className = "logGroupBox";

         groupRow.appendChild(groupRowBox);

         appendRow(groupRowBox);

         groupStack.push(groupRowBox);

     }



     function popGroup()

     {

         groupStack.pop();

     }



     



     function logFormatted(objects, className)

     {

         var html = [];



         var format = objects[0];

         var objIndex = 0;



         if (typeof(format) != "string")

         {

             format = "";

             objIndex = -1;

         }



         var parts = parseFormat(format);

         for (var i = 0; i < parts.length; ++i)

         {

             var part = parts[i];

             if (part && typeof(part) == "object")

             {

                 var object = objects[++objIndex];

                 part.appender(object, html);

             }

             else

                 appendText(part, html);

         }



         for (var i = objIndex+1; i < objects.length; ++i)

         {

             appendText(" ", html);



             var object = objects[i];

             if (typeof(object) == "string")

                 appendText(object, html);

             else

                 appendObject(object, html);

         }



         logRow(html, className);

     }



     function parseFormat(format)

     {

         var parts = [];



         var reg = /((^%|[^\\]%)(\d+)?(\.)([a-zA-Z]))|((^%|[^\\]%)([a-zA-Z]))/;

         var appenderMap = {s: appendText, d: appendInteger, i: appendInteger, f: appendFloat};



         for (var m = reg.exec(format); m; m = reg.exec(format))

         {

             var type = m[8] ? m[8] : m[5];

             var appender = type in appenderMap ? appenderMap[type] : appendObject;

             var precision = m[3] ? parseInt(m[3]) : (m[4] == "." ? -1 : 0);



             parts.push(format.substr(0, m[0][0] == "%" ? m.index : m.index+1));

             parts.push({appender: appender, precision: precision});



             format = format.substr(m.index+m[0].length);

         }



         parts.push(format);



         return parts;

     }



     function escapeHTML(value)

     {

         function replaceChars(ch)

         {

             switch (ch)

             {

                 case "<":

                     return "&lt;";

                 case ">":

                     return "&gt;";

                 case "&":

                     return "&amp;";

                 case "'":

                     return "&#39;";

                 case '"':

                     return "&quot;";

             }

             return "?";

         };

         return String(value).replace(/[<>&"']/g, replaceChars);

     }



     function objectToString(object)

     {

         try

         {

             return object+"";

         }

         catch (exc)

         {

             return null;

         }

     }



     



     function appendText(object, html)

     {

         if (objectToString(object).match(/href/gi)) {

          html.push(objectToString(object));

         } else {

           html.push(escapeHTML(objectToString(object)));

         }

     }



     function appendNull(object, html)

     {

         html.push('<span class="objectBox-null">', escapeHTML(objectToString(object)), '</span>');

     }



     function appendString(object, html)

     {

         html.push('<span class="objectBox-string">&quot;', escapeHTML(objectToString(object)),

             '&quot;</span>');

     }



     function appendInteger(object, html)

     {

         html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');

     }



     function appendFloat(object, html)

     {

         html.push('<span class="objectBox-number">', escapeHTML(objectToString(object)), '</span>');

     }



     function appendFunction(object, html)

     {

         var reName = /function ?(.*?)\(/;

         var m = reName.exec(objectToString(object));

         var name = m ? m[1] : "function";

         html.push('<span class="objectBox-function">', escapeHTML(name), '()</span>');

     }



     function appendObject(object, html)

     {

         try

         {

             if (object == undefined)

                 appendNull("undefined", html);

             else if (object == null)

                 appendNull("null", html);

             else if (typeof object == "string")

                 appendString(object, html);

             else if (typeof object == "number")

                 appendInteger(object, html);

             else if (typeof object == "function")

                 appendFunction(object, html);

             else if (object.nodeType == 1)

                 appendSelector(object, html);

             else if (typeof object == "object")

                 appendObjectFormatted(object, html);

             else

                 appendText(object, html);

         }

         catch (exc)

         {

         }

     }



     function appendObjectFormatted(object, html)

     {

         var text = objectToString(object);

         var reObject = /\[object (.*?)\]/;



         var m = reObject.exec(text);

         html.push('<span class="objectBox-object">', m ? m[1] : text, '</span>')

     }



     function appendSelector(object, html)

     {

         html.push('<span class="objectBox-selector">');



         html.push('<span class="selectorTag">', escapeHTML(object.nodeName.toLowerCase()), '</span>');

         if (object.id)

             html.push('<span class="selectorId">#', escapeHTML(object.id), '</span>');

         if (object.className)

             html.push('<span class="selectorClass">.', escapeHTML(object.className), '</span>');



         html.push('</span>');

     }



     function appendNode(node, html)

     {

         if (node.nodeType == 1)

         {

             html.push(

                 '<div class="objectBox-element">',

                     '&lt;<span class="nodeTag">', node.nodeName.toLowerCase(), '</span>');



             for (var i = 0; i < node.attributes.length; ++i)

             {

                 var attr = node.attributes[i];

                 if (!attr.specified)

                     continue;



                 html.push('&nbsp;<span class="nodeName">', attr.nodeName.toLowerCase(),

                     '</span>=&quot;<span class="nodeValue">', escapeHTML(attr.nodeValue),

                     '</span>&quot;')

             }



             if (node.firstChild)

             {

                 html.push('&gt;</div><div class="nodeChildren">');



                 for (var child = node.firstChild; child; child = child.nextSibling)

                     appendNode(child, html);



                 html.push('</div><div class="objectBox-element">&lt;/<span class="nodeTag">',

                     node.nodeName.toLowerCase(), '&gt;</span></div>');

             }

             else

                 html.push('/&gt;</div>');

         }

         else if (node.nodeType == 3)

         {

             html.push('<div class="nodeText">', escapeHTML(node.nodeValue),

                 '</div>');

         }

     }



     



     function addEvent(object, name, handler)

     {

         if (document.all)

             object.attachEvent("on"+name, handler);

         else

             object.addEventListener(name, handler, false);

     }



     function removeEvent(object, name, handler)

     {

         if (document.all)

             object.detachEvent("on"+name, handler);

         else

             object.removeEventListener(name, handler, false);

     }



     function cancelEvent(event)

     {

         if (document.all)

             event.cancelBubble = true;

         else

             event.stopPropagation();

     }



     function onError(msg, href, lineNo)

     {

         var html = [];



         var lastSlash = href.lastIndexOf("/");

         var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1);



         html.push(

             '<span class="errorMessage">', msg, '</span>',

             '<div class="objectBox-sourceLink">', fileName, ' (line ', lineNo, ')</div>'

         );



         logRow(html, "error");

     };



     function onKeyDown(event)

     {

         if (event.keyCode == 123)

             toggleConsole();

         else if ((event.keyCode == 108 || event.keyCode == 76) && event.shiftKey

                  && (event.metaKey || event.ctrlKey))

             focusCommandLine();

         else

             return;



         cancelEvent(event);

     }



     function onSplitterMouseDown(event)

     {

         if (isSafari || isOpera)

             return;



         addEvent(document, "mousemove", onSplitterMouseMove);

         addEvent(document, "mouseup", onSplitterMouseUp);



         for (var i = 0; i < frames.length; ++i)

         {

             addEvent(frames[i].document, "mousemove", onSplitterMouseMove);

             addEvent(frames[i].document, "mouseup", onSplitterMouseUp);

         }

     }



     function onSplitterMouseMove(event)

     {

         var win = document.all

             ? event.srcElement.ownerDocument.parentWindow

             : event.target.ownerDocument.defaultView;



         var clientY = event.clientY;

         if (win != win.parent)

             clientY += win.frameElement ? win.frameElement.offsetTop : 0;



         var height = consoleFrame.offsetTop + consoleFrame.clientHeight;

         var y = height - clientY;



         consoleFrame.style.height = y + "px";

         layout();

     }



     function onSplitterMouseUp(event)

     {

         removeEvent(document, "mousemove", onSplitterMouseMove);

         removeEvent(document, "mouseup", onSplitterMouseUp);



         for (var i = 0; i < frames.length; ++i)

         {

             removeEvent(frames[i].document, "mousemove", onSplitterMouseMove);

             removeEvent(frames[i].document, "mouseup", onSplitterMouseUp);

         }

     }



     function onCommandLineKeyDown(event)

     {

         if (event.keyCode == 13)

             evalCommandLine();

         else if (event.keyCode == 27)

             commandLine.value = "";

     }



     window.onerror = onError;

     addEvent(document, isIE || isSafari ? "keydown" : "keypress", onKeyDown);



     

         toggleConsole(true);

 }();



 return backupConsole;

};



WSDOM.defineClass("Console", null, Console_class);

WSDOM.loadSingleton("WSDOM.Console.1");



 











Events_class = function() {

 this.init();

};



Events_class.prototype.init = function() {

 this.dbgColor = "#006666";

 this.debug = true;

 this.triggerElements = new Array();



 

 this.add({

  element: window,

  eventType: 'unload',

  handler: this.clearTriggers,

  context: this

 });

};



Events_class.prototype.add = function ( ) {





 



 var element;

 var eventType;

 var handler;

 var delay = 0;

 var dataPackage;

 var trace = false;

 var context = false;

 var label = "";



 if (arguments.length == 1) {



  element = arguments[0].element;

  eventType = arguments[0].type;

  handler = arguments[0].handler;

  delay = parseInt(arguments[0].delay) || 0;



  if (typeof element == "undefined" || typeof eventType == "undefined" || typeof handler == "undefined") {

   return false;

  };



  context = typeof arguments[0].context != "undefined" ? arguments[0].context : false;

  dataPackage = typeof arguments[0].data != "undefined" ? arguments[0].data : {};

  trace = (arguments[0].trace == true);

  label = typeof arguments[0].label != "undefined" ? arguments[0].label : "";



  if (context) {

   

   

   handler = handler.Context(context);

  };

 }

 else {



  element = arguments[0];

  eventType = arguments[1];



  

  if (typeof arguments[2] == "object" && typeof arguments[3] != "undefined") {

   

   

   handler = handler.Context(context);

   dataPackage = typeof arguments[4] == "undefined" ? {} : arguments[4];

  }

  else if (typeof arguments[2] == "function") {

   

   handler = arguments[2];

   dataPackage = typeof arguments[3] == "undefined" ? {} : arguments[3];

  }

  else {

   return false;

  };

 };







 

 

 

 



 

 var evtHandler = function(e) {

  if (trace) {

   WSDOM.Console.log("Event Triggered", "", "");

   WSDOM.Console.log("Event Info", eventType, "");

   WSDOM.Console.log("Object Info", element.tagName + (element.id ? ": " + element.id : ""));

   WSDOM.Console.log("Handler Label", label);

  };

  handler(e, element, dataPackage);

 }



 this.storeHandler(element, eventType, evtHandler);







 

 

 

 



 

 var self = this;



 

 var trigger = function () {

  

  var e = arguments.length ? arguments[0] : window.event;

  self.runHandlers(e, element, eventType);

 };



 

 if (delay) {

  trigger = this.createDelayedTrigger(element, eventType, trigger, delay);

 }



 return this.setTrigger(element, eventType, trigger);



};



Events_class.prototype.setTrigger = function(element, eventType, fnTrigger) {



 if (!fnTrigger) {

  WSDOM.Console.log("Events.setTrigger: no trigger function provided");

  return false;

 };



 

 element._triggers = element._triggers || new Object();



 

 this.removeTrigger(element, eventType);



 

 element._triggers[eventType] = fnTrigger;



 

 this.registerTriggerElement(element);



 

 return this.addJSEvent(element, eventType, fnTrigger);

};





Events_class.prototype.removeTrigger = function(element, eventType) {

 if (element._triggers && element._triggers[eventType]) {

  var fnTrigger = element._triggers[eventType] || null;

  this.removeJSEvent(element, eventType, fnTrigger);

  element._triggers[eventType] = null;

 };

}





Events_class.prototype.clearTriggers = function(els) {

 var rElements = new Array();

 if (els !== undefined) {

  if (els instanceof Array) {

   rElements = els;

  }

  else {

   rElements = new Array(els);

  };

 } else {

  rElements = this.triggerElements || new Array();

 };

 for(var i=0, thisEl, eventType; thisEl=rElements[i]; i++) {

  if (thisEl._triggers !== undefined) {

   for(eventType in thisEl._triggers) {

    this.removeTrigger(thisEl, eventType);

   };

   delete(thisEl._triggers);

  };

 };

};



Events_class.prototype.registerTriggerElement = function(element) {

 var found = false;

 for(var i=0, elCount = this.triggerElements.length, thisEl; thisEl = this.triggerElements[i]; i++) {

  found = found || ( thisEl == element );

  if (found) {

   return;

  };

 };

 if (!found) {

  this.triggerElements.push(element);

 };

};











Events_class.prototype.removeJSEvent = function(element, eventType, fnHandler) {

 if (fnHandler !== undefined) {

  if (element.removeEventListener) {

   

   element.removeEventListener(eventType, fnHandler, false);

   result = true;

  }

  else if (element.detachEvent) {

   

   result = element.detachEvent("on" + eventType, fnHandler);

  }

  return result

 }

 return false;

};



Events_class.prototype.addJSEvent = function(element, eventType, fnHandler) {

 if (element && eventType && fnHandler) {

  if (element.addEventListener) {

   

   element.addEventListener(eventType, fnHandler, false);

   return true;

  }

  else if (element.attachEvent) {

   

   return element.attachEvent("on" + eventType, fnHandler);

  };

 }

 return false;

};









Events_class.prototype.storeHandler = function(el, eventType, fnHandler) {

 

 if (el && eventType && fnHandler) {



  

  

  el._handlers = el._handlers || new Object();

  el._handlers[eventType] = el._handlers[eventType] || new Array()

  var rHandlers = el._handlers[eventType];



  

  rHandlers.push(fnHandler);

 };

};



Events_class.prototype.runHandlers = function(e, element, eventType) {

 var rHandlers = element._handlers[eventType];

 if (rHandlers && rHandlers instanceof Array) {

  for(var i=0, handlerCount = rHandlers.length; i < handlerCount; i++) {

   rHandlers[i](e);

  };

 };

};











Events_class.prototype.removeEvent = function(element, eventType) {

 this.removeTrigger(element, eventType);

 if (element._handlers && element._handlers[eventType]) {

  element._handlers[eventType] = new Array();

 }

};



Events_class.prototype.remove = Events_class.prototype.removeEvent;















Events_class.prototype._delayedTriggers = new Object();



Events_class.prototype.createDelayedTrigger = function(el, eventType, trigger, delay) {



 

 var d = new Date();

 var id = "delayed_event_" + this.getUniqueID(el) + "_" + eventType + "_" + d.getTime();



 

 this._delayedTriggers[id] = trigger;



 

 var eventTimer = null;

 var cmd = "Events._delayedTriggers['" + id + "']()";



 return function() {

  

  if (eventTimer) {

   clearTimeout(eventTimer);

  }

  eventTimer = setTimeout(cmd, delay);

 }

};





Events_class.prototype.idCounter = 0;



Events_class.prototype.getUniqueID = function(el) {

 if (el.id) return el.id;

 return this.idCounter++;

};



















Events_class.prototype.cancelEvent = function(event) {

 if (event) {

  if (event.stopPropagation) {

   event.stopPropagation();

  } else {

   event.cancelBubble = true;

  }

  if (event.preventDefault) {

   event.preventDefault();

  } else {

   event.returnValue = false;

  }

 };

 return false;

};



Events_class.prototype.cancel = Events_class.prototype.cancelEvent;



















Events_class.prototype.getSrcElement = function( ) {

 var el = arguments[0].srcElement || arguments[0].currentTarget || window;

 try {

   

  if (el.nodeType == 3) {

   el = el.parentNode;

  };

 }

 catch (e) {

  el = window;

 };

 return el;

};











Events_class.prototype.disableTextSelect = function() {

 if (!document.onselectstart) {

  document.onselectstart = function() {

   return false;

  };

 }

};



Events_class.prototype.removeTextSelect = Events_class.prototype.disableTextSelect; 



Events_class.prototype.enableTextSelect = function() {

 if (document.onselectstart) {

  document.onselectstart = null;

 }

};











WSDOM.using("WSDOM.Events.2", "WSDOM.Console.1");

WSDOM.defineClass("Events", null, Events_class);

WSDOM.loadSingleton("WSDOM.Events.2");



 



 

var Element_class = function() {



}











 

Element_class.prototype.get = function(el) {

 if (typeof el == "string" || typeof el == "number") el = document.getElementById(el);

 return el;

};



 

Element_class.prototype.create = function (tag, attributes, children, parent, ElementObjectInstance) {



 var element = document.createElement(tag);



 

 var attributeMap = {

  "for":["htmlFor"],

  "colspan":["colSpan"],

  "usemap":["useMap"]

 }



 for (var i in attributes)

 {

  if (i == "className" || i == "class")

  {

   element.className = attributes[i];

  }

  else if (document.all && attributeMap[i])

  {

   for (var j = 0; j <attributeMap[i].length; j++) {

    element.setAttribute(attributeMap[i][j], attributes[i]);

   }

   element.setAttribute(i, attributes[i]); 

  }

  else if (i == "style")

  {

   this.setStyle(element,attributes[i]);

  }

  else if (i == "WSDOM.Events" || i == "Events")

  {

   if (typeof WSDOM.Events != "undefined") {

    var elEvents = attributes[i];

    if (!this.isArray(elEvents)) {

     elEvents = [elEvents]

    }



    for (var j = 0; j < elEvents.length; j++) {

     elEvents[j].element = element;

     WSDOM.Events.add(elEvents[j]);

    }

   }

   else {

    

   }

  }

  else

  {

   element.setAttribute(i, attributes[i]);

  };

 };



 

 if (tag.match(/^map$/i) && attributes && attributes.name && !attributes.id) {

  element.setAttribute("id", attributes.name);

 }



 if (arguments.length > 2 && children != undefined && children !== "") {



  

  if (typeof children == "object" && children.constructor == Array)

  {

   for (var i = 0; i < children.length; i++)

   {

    this.addChild(element, children[i]);

   };

  }

  else

  {

   this.addChild(element, children);

  };

 };



 if (parent) {

  this.addChild(parent,element);

 }



 return (ElementObjectInstance) ? new ElementObject(element) : element;

};



 

Element_class.prototype.addChild = function (el, child) {

 el = this.get(el);



 if (!this.isArray(child)) {

  child = [child]

 }

 for (var i=0; i<child.length; i++) {

  if (typeof child[i] == "object") {

   el.appendChild(child[i]);

  }

  else if (typeof child[i] == "string" || typeof child[i] == "number") {

   

   el.innerHTML += child[i];

  };

 }



};







 

Element_class.prototype.remove = function(el) {

 el = this.get(el);



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  el[i].parentNode.removeChild(el[i])

 }

};



 

Element_class.prototype.setDisplay = function(el,d) {



 el = this.get(el);



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  el[i].style.display = d;

 }

};



 

Element_class.prototype.setVisibility = function(el,d) {

 el = this.get(el);



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  el[i].style.visibility = d;

 }

};





 

Element_class.prototype.removeChildNodes = function(el) {



 el = this.get(el);



 while (el.childNodes.length) {

  el.removeChild(el.firstChild);

 }

 return el;



};



 

Element_class.prototype.cloneNode = function(el, cloneChildren) {

 

 var cloneChildNodes = (cloneChildren) ? cloneChildren : false;



 if (document.all) {



  var node = el.outerHTML;



  if (cloneChildNodes && el.innerHTML) {

   node.innerHTML = el.innerHTML;

  }



  var container = document.createElement("DIV");

  container.innerHTML = node;



  node = container.firstChild;



 } else {

  var node = el.cloneNode(cloneChildNodes);

 }



 return node;



};



 

Element_class.prototype.getParent = function(el, tag, includeSelf) {



 var el = this.get(el);



 if (!tag) { tag = el.tagName; }



 if (!includeSelf && el.parentNode) { 

  el = el.parentNode;

 }



 if (el.tagName && el.tagName.match(/^BODY$/i) && !tag.match(/^BODY$/i)) {

  return null;

 }



 if (el.nodeType == 1 && el.tagName.toLowerCase() == tag.toLowerCase()) {

  return el;

 }

 else {

  return this.getParent(el.parentNode, tag, true);

 }

}







 

Element_class.prototype.setHTML = function(el,v,appendV) {

 el = this.get(el);



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

   el[i].innerHTML = (appendV) ? (el[i].innerHTML+v) : v;

 }

};



 

Element_class.prototype.parseSelector = function() {



 var context = this;

 var SEPERATOR = /\s*,\s*/;

 

 function parseSelector(selector, node, num) {



  node = node || document.documentElement;

  node = this.get(node);



  var argSelectors = selector.split(SEPERATOR);

  var result = [];

  

  for(var i = 0; i < argSelectors.length; i++) {



   

   

   

   if(node == document.documentElement) {

    var matches = argSelectors[i].match(/^\s*#([^\s.:@[~+>]*)\s+(.*)$/); 

    if(matches) {

     node = document.getElementById(matches[1]) || [];

     argSelectors[i] = matches[2];

    }

   }



   var stream = toStream(argSelectors[i]), prevToken;



   if (this.isArray(node)) {

    var nodes = node;

    

    if (!argSelectors[i].match(/^[A-Za-z1-9]/)) {

     while (stream[0] && stream[0].match(/[* ]/)) { stream.shift(); }

    }

   }

   else {

    var nodes = [node]

   }



   for(var j = 0;j < stream.length;) {



    var token = stream[j++];



    var args = '';

    if (token == "[") {

     args = stream[j];

     while(stream[j++] != ']' && j < stream.length) { args += stream[j] };

     args = args.slice(0, -1);

     var filter = "";

    }

    else {

     var filter = stream[j++];

    }



    if(stream[j] == '(') {

     while(stream[j++] != ')' && j < stream.length) args += stream[j];

     args = args.slice(0, -1);

    }



    prevToken = token;

    nodes = select(nodes, token, filter, args);

   }

   result = result.concat(nodes);

  }

  

  

    if (num != undefined) {



   if (result.length) {

    var REMatch;



    if (num == "first") {

     return result[0]

    }

    else if (num == "last") {

     return result[result.length-1]

    }

    else if (REMatch = String(num).match(/nth\((.*)\)/) || num == "even") { 

     if (num == "even") num = 2;

     else num = REMatch[1];



     var result2 = [];

     for (var i=0,len=result.length; i<len;i++) {

      if (i%num == 0) { result2.push(result[i]); }

     }

     return result2;

    }

    else if (num == "odd") {

     var result2 = [];

     for (var i=0,len=result.length; i<len;i++) {

      if (i%2 != 0) { result2.push(result[i]); }

     }

     return result2;

    }

    else if (!isNaN(num) && result.length >= num) {

     return result[num]

    }

    else {

     return null; 

    }

   }

   else {

    return null;

   }



    }



  return result;

 }



 var WHITESPACE = /\s*([\s>+~(),]|^|$)\s*/g;

 var IMPLIED_ALL = /([\s>+~,]|[^(]\+|^)([#.:@])/g;

 var STANDARD_SELECT = /^[^\s>+~]/;

 var STREAM = /[\s#.:>+~[\]()@!]|[^\s#.:>+~[\]()@!]+/g;



 function toStream(selector) {

  var stream = selector

   .replace(WHITESPACE, '$1')

   .replace(IMPLIED_ALL, '$1*$2');

  if(STANDARD_SELECT.test(stream)) {

   stream = ' ' + stream;

  }

  return stream.match(STREAM) || [];

 }



 function select(nodes, token, filter, args) {

  return (selectors[token]) ? selectors[token](nodes, filter, args) : [];

 }



 var util = {

  toArray: function(enumerable) {

   var a = [];

   for(var i = 0; i < enumerable.length; i++) a.push(enumerable[i]);

   return a;

  },



  push: function(arr,val) {

   arr.push(val)

        

        return arr.length;

     }

 };



 var dom = {

  isTag: function(node, tag) {

   return (tag == '*') || (

    tag.toLowerCase() == node.nodeName.toLowerCase().replace(':html', '')

   );

  },



  previousSiblingElement: function(node) {

   do node = node.previousSibling; while(node && node.nodeType != 1);

   return node;

  },



  nextSiblingElement: function(node) {

   do node = node.nextSibling; while(node && node.nodeType != 1);

   return node;

  },

  



  hasClass: function(name, node) {

      return (new RegExp('(^|\\s)' + name + '(\\s|$)')).test(node.className || '');

  },



  getByTag: function(tag, node) {

    

   if(tag == '*') {

     var nodes = node.getElementsByTagName(tag);

     if(nodes.length == 0 && node.all != null) return node.all

     return nodes;

    }

   return node.getElementsByTagName(tag);

  }

 };



 var selectors = {

  '#': function(nodes, filter) {

   for(var i = 0; i < nodes.length; i++) {

    if(nodes[i].getAttribute('id') == filter) return [nodes[i]];

   }

   return [];

  },



  ' ': function(nodes, filter) {

   var result = [];

   for(var i = 0; i < nodes.length; i++) {

    result = result.concat(util.toArray(dom.getByTag(filter, nodes[i])));

   }

   return result;

  },



  '>': function(nodes, filter) {

   var result = [];

   for(var i = 0, node; i < nodes.length; i++) {

    node = nodes[i];

    for(var j = 0, child; j < node.childNodes.length; j++) {

     child = node.childNodes[j];

     if(child.nodeType == 1 && dom.isTag(child, filter)) {

      result.push(child);

     }

    }

   }

   return result;

  },



  '.': function(nodes, filter) {

   var result = [];

   for(var i = 0, node; i < nodes.length; i++) {

    node = nodes[i];

    if(dom.hasClass([filter], node)) result.push(node);

   }

   return result;

  },



  '!': function(nodes, filter) {

   var result = [];

   for(var i = 0, node; i < nodes.length; i++) {

    node = nodes[i];

    if(!dom.hasClass([filter], node)) result.push(node);

   }

   return result;

  },



  ':': function(nodes, filter, args) {

   return (pseudoClasses[filter]) ? pseudoClasses[filter](nodes, args) : [];

  },





  '+': function(nodes, filter) {

   var result = [];

   for(var i = 0, node; i < nodes.length; i++) {

    node = nodes[i];

    var sibling = parseSelector.dom.nextSiblingElement(node);

    if(sibling && parseSelector.dom.isTag(sibling, filter)) {

     result.push(sibling);

    }

   }

   return result;

  },

  '~': function(nodes, filter) {

   var result = [];

   for(var i = 0, node; i < nodes.length; i++) {

    node = nodes[i];

    var sibling = parseSelector.dom.previousSiblingElement(node);

    if(parseSelector.dom.isTag(sibling, filter)) result.push(sibling);

   }





   return result;

  },

  '[': function(nodes, filter, args) { 

   args = args.replace(/'/g,'"'); 



   var attributeProps = [];

   if (!/[<>=]/.test(args)) { 

    attributeProps = ["",args,"",""];

   }

   else {

    var params = args.match(/([^!^$*\/.<>=]*)(!\*=|\*=|\$=|!\$=|\^=|\/=|!\/=|<=|>=|<|>|!=|=)(\.*)(i?)(["'`])([^\5]*)(\5)/);

         

    if (params) { attributeProps = params; }

   }



   

   attributeProps = {name:attributeProps[1],operator:attributeProps[2],isStyle:attributeProps[3]=="..",isProperty:attributeProps[3]==".",casei:attributeProps[4]?true:false,value:attributeProps[6],isValue:(attributeProps[5]=="`")};



   

   



   if (attributeProps.casei) { attributeProps.value = attributeProps.value.toLowerCase(); }



   var result = [];

   for(var i = 0, node, att, val, el; i < nodes.length; i++) {

    node = el = nodes[i];



    if (attributeProps.isStyle) {

     att = context.getStyle(node,attributeProps.name);

     if (!att) continue;

    }

    else if (attributeProps.isProperty) {

     if (node[attributeProps.name] != undefined) {

      var att = node[attributeProps.name];

     }

     else {

      continue;

     }

    }

    else {

     att = node.getAttribute(attributeProps.name);

     if (!att) continue;

    }



    if (/[*^$\/]/.test(attributeProps.operator)) { 

     att = String(att)

    }



    if (attributeProps.casei) { att = att.toLowerCase(); }



    val = attributeProps.value;



    

    if (attributeProps.isValue) { val = eval(val.replace(/`/g,"'")); }



    if (!attributeProps.operator) {

     result.push(nodes[i])

    }

    else {





     switch(attributeProps.operator){

      case '=': if (att == val) result.push(node); break;

      case '!=': if (att != val) result.push(node); break;

      case '*=': if (att.match(val)) result.push(node); break;

      case '!*=': if (!att.match(val)) result.push(node); break;

      case '^=': if (att.match('^'+val)) result.push(node); break;

      case '!^=': if (!att.match('^'+val)) result.push(node); break;

      case '$=': if (att.match(val+'$')) result.push(node); break;

      case '!$=': if (!att.match(val+'$')) result.push(node); break;

      case '/=': if (att.match(val)) result.push(node); break;

      case '!/=': if (!att.match(val)) result.push(node); break;

      case '>=': if (att >= val) result.push(node); break;

      case '>': if (att > val) result.push(node); break;

      case '<=': if (att <= val) result.push(node); break;

      case '<': if (att < val) result.push(node); break;

     }

    }

   }

   return result;



  }



 };



 parseSelector.selectors   = selectors;

 var pseudoClasses = { };

 parseSelector.pseudoClasses    = pseudoClasses;

 parseSelector.util       = util;

 parseSelector.dom       = dom;

 return parseSelector.apply(this,arguments);

};



 



Element_class.prototype.is = function( domNode, selector, parent, propagate ) {



 parent = parent || domNode.parentNode;

 

 var queriedEls = this.parseSelector(selector, parent);

  

 var  i

  ,l = queriedEls.length;

 

 while(domNode && domNode !== parent) {

  

  for(i = 0; i < l; i++) {

   if(domNode === queriedEls[i]) {

 

    return true;

   }

  }

  if(propagate) {

   domNode = domNode.parentNode;

   continue;

  }

  break;

 }

 return false;

};



Element_class.prototype.forEach = function(el, callback, context) {



 var returnEls = [];



 if (typeof el == "string") {

  el = this.parseSelector(el);

 }

 else if (!this.isArray(el)) {

  el = [el]

 }



 var success;



 for (var i=0,elLen = el.length; i<elLen; i++) {

  success = context ? callback.call(context,el[i],i,el) : callback(el[i],i,el)

  if (success === false) {

   break;

  }

  returnEls.push(el[i]);

 }



 return returnEls;

}



 

Element_class.prototype.insertBefore = function (el, sibling) {



 el = this.get(el); if (!el) return;



 sibling = this.get(sibling);



 if (!el || !sibling || !sibling.parentNode)

 {

  return null;

 };



 sibling.parentNode.insertBefore(el, sibling);

};



 

Element_class.prototype.insertAfter = function (el, sibling) {



 el = this.get(el); if (!el) return;



 sibling = this.get(sibling);



 if (!el || !sibling || !sibling.parentNode)

 {

  return null;

 };



 return sibling.nextSibling ? sibling.parentNode.insertBefore(el, sibling.nextSibling) : sibling.parentNode.appendChild(el);

};





 

Element_class.prototype.nextElement = function(el, tagName) {

 tagName = tagName ? String(tagName).toLowerCase() : null;



 var sibling = this.get(el);

 while(sibling = sibling.nextSibling) {

  if (sibling.nodeType == 1 && ( tagName == null || sibling.tagName.toLowerCase() == tagName ) ) {

   return sibling;

  }

 }

 return null;

}





 

Element_class.prototype.previousElement = function(el, tagName) {

 tagName = tagName ? String(tagName).toLowerCase() : null;

 var sibling = this.get(el);

 while(sibling = sibling.previousSibling) {

  if (sibling.nodeType == 1 && ( tagName == null || sibling.tagName.toLowerCase() == tagName ) ) {

   return sibling;

  }

 }

 return null;

}



 

Element_class.prototype.getXY = function(el) {



 el = this.get(el); if (!el) return;



 var x = 0, y = 0;



 while (el.offsetParent) {

  x += el.offsetLeft;

  y += el.offsetTop;

  el = el.offsetParent;

 }



 return { x: x, y: y };

};



 

Element_class.prototype.setXY = function(el, x, y) {



 el = this.get(el); if (!el) return;



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  if (x !== null) el[i].style.left = x + "px";

  if (y !== null) el[i].style.top = y + "px";

 }

};



 

Element_class.prototype.getSize = function(el) {



 el = this.get(el); if (!el) return;



 var height = el.offsetHeight;

 var width = el.offsetWidth;



 return { height: height, width: width };

};





 

Element_class.prototype.getSizeXY = function(el) {

 var size = this.getSize(el);

 return {x: size.width, y: size.height};

};



 

Element_class.prototype.setSize = function(el, width, height) {



 el = this.get(el); if (!el) return;



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  this.setWidth(el[i], width);

  this.setHeight(el[i], height);

 }

};



Element_class.prototype.setWidth = function(el, width) {



 el = this.get(el); if (!el) return;



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  el[i].style.width = width + "px";

 }

};



Element_class.prototype.setHeight = function(el, height) {



 el = this.get(el); if (!el) return;



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  el[i].style.height = height + "px";

 }

};



Element_class.prototype.getBorderSize = function(el) {



 el = this.get(el);



 var height = el.offsetHeight - el.clientHeight;

 var width = el.offsetWidth - el.clientWidth;



 return { height: height, width: width };

}













 

Element_class.prototype.switchClass = function(el, classname, b) {



 el = this.get(el); if (!el) return;



 if (!this.isArray(el)) {

  el = [el]

 }



 if (b) {

  this.addClass(el, classname);

 }

 else {

  this.removeClass(el, classname);

 }



 if (el.length) {

  return el[0].className;

 }



};



 

Element_class.prototype.replaceClass = function(el, sClassNameOld, sClassNameNew, bConditional) {



 el = this.get(el); if (!el) return;



 if (!this.isArray(el)) {

  el = [el]

 }



 if(bConditional) {



  for(var i=0;i<el.length;i++) {



   if(this.hasClass(el[i],sClassNameOld)) {



    this.removeClass(el[i],sClassNameOld);

    this.addClass(el[i],sClassNameNew);



   }



  }



 } else{



  this.removeClass(el, sClassNameOld);

  this.addClass(el, sClassNameNew);



 }



 if (el.length) {

  return el[0].className;

 }



};



 

Element_class.prototype.addClass = function(el, classname) {



 el = this.get(el); if (!el) return;



 if (!this.isArray(el)) {

  el = [el]

 }

 for (var i=0; i<el.length; i++) {

  if (!this.hasClass(el[i], classname)) {

       el[i].className += (el[i].className?" ":"") + classname;

  }

 }



 if (el.length) {

  return el[0].className;

 }

};



 

Element_class.prototype.removeClass = function(el, classname) {



 el = this.get(el);



 if (!this.isArray(el)) {

  el = [el]

 }



 var re = this._getClassnameRegEx(classname);



 for (var i=0; i<el.length; i++) {

   el[i].className = el[i].className.replace(re, "$1$3");

 }



 if (el.length) {

  return el[0].className;

 }



};



 

Element_class.prototype.toggleClass = function(el, classname) {

 el = this.get(el);

 



 if (!this.isArray(el)) {

  el = [el]

 }



 for (var i=0; i<el.length; i++) {

  if (this.hasClass(el[i], classname)) {

   this.removeClass(el[i], classname);

  } else {

   this.addClass(el[i], classname);

  }

 }



 if (el.length) {

  return el[0].className;

 }

};



 

Element_class.prototype.hasClass = function(el, classname) {



 el = this.get(el);



 return (el.className && el.className.match(this._getClassnameRegEx(classname)) != null);

};



Element_class.prototype._getClassnameRegEx = function(classname) {

 return new RegExp("(\\s|^)(" + classname + ")(\\s|$)", "g")

};











 

Element_class.prototype.getStyle = function (el, styleProp) {



 el = this.get(el); if (!el) return;



 if (document.defaultView && document.defaultView.getComputedStyle) { 



  var computedStyle = document.defaultView.getComputedStyle(el, null);

  return (computedStyle) ? computedStyle.getPropertyValue(styleProp) : null;



 } else if (el.currentStyle) { 



  styleProp = styleProp.replace(/\-(.)/g, function () {



   return arguments[1].toUpperCase();



  });



  return el.currentStyle[styleProp];



 }



 return null;



}



 

Element_class.prototype.setStyle = function (el, styles) {



 el = this.get(el); if (!el) return;



 var pairs = [];

 styles = styles.split(";");

 for (var i=0; i<styles.length; i++) {

  

  var nv = styles[i].replace(":","{:}").split("{:}");

  if (nv.length > 1) {

   nv[0] = nv[0].replace(/\-(.)/g, function() {

    return arguments[1].toUpperCase();

   }).replace(/\s/g, "");

   pairs.push({n:nv[0],v:nv[1].replace(/^\s*|\s*$/g, "")});

  }

 }



 if (!this.isArray(el)) {

  el = [el]

 }



 var attributeMap = {

  "float":["cssFloat","styleFloat"]

 }



 for (var i=0; i<el.length; i++) {

  for (var j=0; j<pairs.length; j++) {

   if (attributeMap[pairs[j].n]) {

    for (var k = 0; k <attributeMap[pairs[j].n].length; k++) {

     pairs.push({n:attributeMap[pairs[j].n][k],v:pairs[j].v});

    }

   }

   el[i].style[pairs[j].n] = pairs[j].v;

  }

 }



}

















Element_class.prototype.isArray = function(o) {

 return (o instanceof Array);

};





if (typeof WSDOM != "undefined") {

 WSDOM.using("WSDOM.Element.3", "WSDOM.Events.2");

 WSDOM.defineClass("Element", null, Element_class);

 WSDOM.loadSingleton("WSDOM.Element.3");

}

else {

 Element = new Element_class();

}





function Util_class() {};



 



 



 

Util_class.prototype.StringBuilder = function() {



 this.s = [];



};



Util_class.prototype.StringBuilder.prototype.append = function(who) {

 this.s.push(who);

};

Util_class.prototype.StringBuilder.prototype.toString = function(who) {

 return this.s.join("");

};









 





Util_class.prototype.copyObject = function(obj) {

 var Copy;

 if (obj != null){

  Copy = new obj.constructor;

  for (var property in obj) {

   if (typeof(obj[property]) == "object") {

    Copy[property] = this.copyObject(obj[property]);

   } else {

    Copy[property] = obj[property];

   };

  };

 };

 return Copy;

};





Util_class.prototype.MINUTES_IN_DAY = 60 * 24;

Util_class.prototype.MILLISECONDS_IN_DAY = 1000 * 60 * 60 * 24; 

Util_class.prototype.MS_DAYS = 25569;

Util_class.prototype.msToJsDate = function(msDate) {

 var jO=new Date(((msDate-this.MS_DAYS)*this.MILLISECONDS_IN_DAY));

 var tz=jO.getTimezoneOffset();

 var jO=new Date(((msDate-this.MS_DAYS+(tz/(this.MINUTES_IN_DAY))) * this.MILLISECONDS_IN_DAY));

 return jO;

};

Util_class.prototype.jsToMsDate = function(jsdate) {

 var timezoneOffset=jsdate.getTimezoneOffset()/this.MINUTES_IN_DAY;

 var msDateObj=(jsdate.getTime()/this.MILLISECONDS_IN_DAY)+(this.MS_DAYS - timezoneOffset);

 return msDateObj;

}











 



 



String.prototype.gsub = function(pattern, replacement) {

 var result = '', source = this, match;

 replacement = arguments.callee.prepareReplacement(replacement);



 while (source.length > 0) {

  if (match = source.match(pattern)) {

   result += source.slice(0, match.index);

   result += String.interpret(replacement(match));

   source  = source.slice(match.index + match[0].length);

  } else {

   result += source, source = '';

  }

 }

 return result;

};



String.prototype.sub = function(pattern, replacement, count) {

 replacement = this.gsub.prepareReplacement(replacement);

 count = count === undefined ? 1 : count;



 return this.gsub(pattern, function(match) {

  if (--count < 0) return match[0];

  return replacement(match);

 });

};



String.prototype.truncate = function(length, truncation) {

 length = length || 30;

 truncation = truncation === undefined ? '...' : truncation;

 return this.length > length ?

 this.slice(0, length - truncation.length) + truncation : this;

};



String.prototype.scan = function(pattern, iterator) {

 this.gsub(pattern, iterator);

 return this;

};





String.prototype.truncate = function(length, truncation) {

 length = length || 30;

 truncation = truncation === undefined ? '...' : truncation;

 return this.length > length ?

 this.slice(0, length - truncation.length) + truncation : this;

};



String.prototype.strip = function() {

 return this.replace(/^\s+/, '').replace(/\s+$/, '');

};



String.prototype.stripTags = function() {

 return this.replace(/<\/?[^>]+>/gi, '');

};



 



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();

 return div.childNodes[0] ? (div.childNodes.length > 1 ?

 new WSDOM.Enumerable(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) :

 div.childNodes[0].nodeValue) : '';

};



String.prototype.toQueryParams = function(separator) {

 var match = this.strip().match(/([^?#]*)(#.*)?$/);

 if (!match) return {};



 return match[1].split(separator || '&').inject({}, function(hash, pair) {

  if ((pair = pair.split('='))[0]) {

   var name = decodeURIComponent(pair[0]);

   var value = pair[1] ? decodeURIComponent(pair[1]) : undefined;



   if (hash[name] !== undefined) {

    if (hash[name].constructor != Array)

    hash[name] = [hash[name]];

    if (value) hash[name].push(value);

   }

   else hash[name] = value;

  }

  return hash;

 });

};



String.prototype.toArray = function() {

 return this.split('');

};



String.prototype.succ = function() {

 return this.slice(0, this.length - 1) +

 String.fromCharCode(this.charCodeAt(this.length - 1) + 1);

};



String.prototype.camelize = function() {

 var parts = this.split('-'), len = parts.length;

 if (len == 1) return parts[0];



 var camelized = this.charAt(0) == '-'

 ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)

 : parts[0];



 for (var i = 1; i < len; i++)

 camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);



 return camelized;

};



String.prototype.capitalize = function(){

 return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();

};



String.prototype.underscore = function() {

 return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();

};



String.prototype.dasherize = function() {

 return this.gsub(/_/,'-');

};



String.prototype.inspect = function(useDoubleQuotes) {

 var escapedString = this.replace(/\\/g, '\\\\');

 if (useDoubleQuotes) {

  return '"' + escapedString.replace(/"/g, '\\"') + '"';

 } else {

  return "'" + escapedString.replace(/'/g, '\\\'') + "'";

 };

};





 



 

Util_class.prototype.toEnumerable = function(arr) {

 return new WSDOM.Util.Enumerable(arr);

};



Util_class.prototype.Enumerable = function() {



 var arrayConstructor = [];



 

 

  

 for (var i in this) {

  arrayConstructor[i] = this[i];

 }



 if (arguments[0] && (arguments[0].length || arguments[0].length == 0)) {

  for (var x = 0; x < arguments[0].length; x++) {

   arrayConstructor.push(arguments[0][x]);

  };

 } else {

  for (var x = 0; x < arguments.length; x++) {

   arrayConstructor.push(arguments[x]);

  };

 };



 return arrayConstructor;

};





Util_class.prototype.Enumerable.prototype.$break = {};

Util_class.prototype.Enumerable.prototype.$continue = {};



Util_class.prototype.Enumerable.prototype.each = function(iterator) {

 var index = 0;

 try {

  this._each(function(value) {

   try {

    iterator(value, index++);

   } catch (e) {

    if (e != this.$continue) throw e;

   }

  });

 } catch (e) {

  if (e != this.$break) throw e;

 }

 return this;

};



Util_class.prototype.Enumerable.prototype._each = function(iterator) {

 for (var i = 0, length = this.length; i < length; i++)

 iterator(this[i]);

};





Util_class.prototype.Enumerable.prototype.eachSlice = function(number, iterator) {

 var index = -number, slices = [], array = this.toArray();

 while ((index += number) < array.length) {

  slices.push(array.slice(index, index+number));

 };

 return slices.map(iterator);

};



Util_class.prototype.Enumerable.prototype.all = function(iterator) {

 var result = true;

 this.each(function(value, index) {

  result = result && !!(iterator || WSDOM.identity)(value, index);

  if (!result) throw this.$break;

 });

 return result;

};



Util_class.prototype.Enumerable.prototype.any = function(iterator) {

 var result = false;

 this.each(function(value, index) {

  if (result = !!(iterator || WSDOM.identity)(value, index))

  throw this.$break;

 });

 return result;

};



Util_class.prototype.arrayFrom = function(iterable) {

 if (!iterable) return [];

 if (iterable.toArray) {

  return iterable.toArray();

 } else {

  var results = [];

  for (var i = 0, length = iterable.length; i < length; i++)

  results.push(iterable[i]);

  return results;

 }

};



Util_class.prototype.Enumerable.prototype.collect = function(iterator) {

 var results = [];

 this.each(function(value, index) {

  results.push((iterator || WSDOM.identity)(value, index));

 });

 return results;

};



Util_class.prototype.Enumerable.prototype.detect = function(iterator) {

 var result;

 this.each(function(value, index) {

  if (iterator(value, index)) {

   result = value;

   throw this.$break;

  }

 });

 return result;

};



Util_class.prototype.Enumerable.prototype.findAll = function(iterator) {

 var results = new WSDOM.Util.Enumerable();

 this.each(function(value, index) {

  if (iterator(value, index))

  results.push(value);

 });

 return results;

};



Util_class.prototype.Enumerable.prototype.grep = function(pattern, iterator) {

 var results = new WSDOM.Util.Enumerable();

 this.each(function(value, index) {

  var stringValue = value.toString();

  if (stringValue.match(pattern))

  results.push((iterator || WSDOM.identity)(value, index));

 })

 return results;

};



Util_class.prototype.Enumerable.prototype.include = function(object) {

 var found = false;

 this.each(function(value) {

  if (value == object) {

   found = true;

   throw this.$break;

  }

 });

 return found;

};



Util_class.prototype.Enumerable.prototype.inGroupsOf = function(number, fillWith) {

 fillWith = fillWith === undefined ? null : fillWith;

 return this.eachSlice(number, function(slice) {

  while(slice.length < number) slice.push(fillWith);

  return slice;

 });

};



Util_class.prototype.Enumerable.prototype.inject = function(memo, iterator) {

 this.each(function(value, index) {

  memo = iterator(memo, value, index);

 });

 return memo;

};



Util_class.prototype.Enumerable.prototype.invoke = function(method) {

 var args = new WSDOM.Enumerable(arguments).slice(1);

 return this.map(function(value) {

  return value[method].apply(value, args);

 });

};



Util_class.prototype.Enumerable.prototype.max = function(iterator) {

 var result;

 this.each(function(value, index) {

  value = (iterator || WSDOM.identity)(value, index);

  if (result == undefined || value >= result)

  result = value;

 });

 return result;

};



Util_class.prototype.Enumerable.prototype.min = function(iterator) {

 var result;

 this.each(function(value, index) {

  value = (iterator || WSDOM.identity)(value, index);

  if (result == undefined || value < result)

  result = value;

 });

 return result;

};



Util_class.prototype.Enumerable.prototype.partition = function(iterator) {

 var trues = [], falses = [];

 this.each(function(value, index) {

  ((iterator || WSDOM.identity)(value, index) ?

  trues : falses).push(value);

 });

 return [trues, falses];

};



Util_class.prototype.Enumerable.prototype.pluck = function(property) {

 var results = [];

 this.each(function(value, index) {

  results.push(value[property]);

 });

 return results;

};



Util_class.prototype.Enumerable.prototype.reject = function(iterator) {

 var results = [];

 this.each(function(value, index) {

  if (!iterator(value, index))

  results.push(value);

 });

 return results;

};



Util_class.prototype.Enumerable.prototype.sortBy = function(iterator) {

 return this.map(function(value, index) {

  return {value: value, criteria: iterator(value, index)};

 }).sort(function(left, right) {

  var a = left.criteria, b = right.criteria;

  return a < b ? -1 : a > b ? 1 : 0;

 }).pluck('value');

};



Util_class.prototype.Enumerable.prototype.sortByField = function(sortField, sortOrder, caseSensitive) {



 function Sort (a, b) {



  var aField = a[sortField];

  var bField = b[sortField];



  if (!caseSensitive && typeof(aField) == "string") aField = aField.toLowerCase();

  if (!caseSensitive && typeof(bField) == "string") bField = bField.toLowerCase();



  if (aField < bField) return (sortOrder > 0) ? -1 : 1;

  if (aField > bField) return (sortOrder > 0) ? 1 : -1;

  return 0;

 }



 if (!sortField) return this.sort();

 if (!sortOrder) sortOrder = 1;

 this.sort(Sort);

 return this;

};



Util_class.prototype.Enumerable.prototype.toArray = function() {

 return this.map();

};









Util_class.prototype.Enumerable.prototype.zip = function() {

 var iterator = WSDOM.identity, args = new WSDOM.Util.Enumerable(arguments);

 if (typeof args.last() == 'function')

 iterator = args.pop();



 var collections = [this].concat(args).map(new WSDOM.Util.Enumerable());

 return this.map(function(value, index) {

  return iterator(collections.pluck(index));

 });

};



Util_class.prototype.Enumerable.prototype.size = function() {

 return this.toArray().length;

};



 



Util_class.prototype.Enumerable.prototype.clear = function() {

 this.length = 0;

 return this;

};



Util_class.prototype.Enumerable.prototype.first = function() {

 return this[0];

};



Util_class.prototype.Enumerable.prototype.last = function() {

 return this[this.length - 1];

};



Util_class.prototype.Enumerable.prototype.compact = function() {

 return this.select(function(value) {

  return value != null;

 });

};



Util_class.prototype.Enumerable.prototype.flatten = function() {

 return this.inject([], function(array, value) {

  return array.concat(value && value.constructor == Array ?

  value.flatten() : [value]);

 });

};



Util_class.prototype.Enumerable.prototype.without = function() {

 var values = new WSDOM.Enumerable(arguments);

 return this.select(function(value) {

  return !values.include(value);

 });

};



Util_class.prototype.Enumerable.prototype.indexOf = function(object) {

 for (var i = 0, length = this.length; i < length; i++)

 if (this[i] == object) return i;

 return -1;

};



Util_class.prototype.Enumerable.prototype.reverse = function(inline) {

 return (inline !== false ? this : this.toArray())._reverse();

};



Util_class.prototype.Enumerable.prototype.reduce = function() {

 return this.length > 1 ? this : this[0];

};



Util_class.prototype.Enumerable.prototype.uniq = function() {

 return this.inject([], function(array, value) {

  return array.include(value) ? array : array.concat([value]);

 });

};



Util_class.prototype.Enumerable.prototype.clone = function() {

 return [].concat(this);

};



Util_class.prototype.Enumerable.prototype.size = function() {

 return this.length;

};



 



Util_class.prototype.Enumerable.prototype.toArray = Util_class.prototype.Enumerable.prototype.clone;

Util_class.prototype.Enumerable.prototype.map = Util_class.prototype.Enumerable.prototype.collect;

Util_class.prototype.Enumerable.prototype.find = Util_class.prototype.Enumerable.prototype.detect;

Util_class.prototype.Enumerable.prototype.select = Util_class.prototype.Enumerable.prototype.findAll;

Util_class.prototype.Enumerable.prototype.member = Util_class.prototype.Enumerable.prototype.include;

Util_class.prototype.Enumerable.prototype.entries = Util_class.prototype.Enumerable.prototype.toArray;









 



 

Util_class.prototype.toHash = function(o) {

 return new this.Hash(o);

};





Util_class.prototype.Hash = function() {

 

  



 

 var objectConstructor = {};



  

 for (var i in this) {

  objectConstructor[i] = this[i];

 }



 if (arguments[0]) {

  for (var i in arguments[0]) {

   objectConstructor[i] = arguments[0][i];

  };

 };







 return objectConstructor;





};







Util_class.prototype.Hash.prototype.toQueryString = function() {

 Console.log("here");

 var parts = [];



 

 this._each(function(pair) {



  if (!pair.key) return;



  if (pair.value) {

   pair.value = new WSDOM.Util.Enumerable(pair.value);

   var values = pair.value.compact();

   if (values.length < 2) pair.value = values.reduce();

   else {

    key = encodeURIComponent(pair.key);

    values.each(function(value) {

     value = value != undefined ? encodeURIComponent(value) : '';

     parts.push(key + '=' + encodeURIComponent(value));

    });

    return;

   }

  }

  if (pair.value == undefined) pair[1] = '';

  parts.push(pair.map(encodeURIComponent).join('='));

 });



 return parts.join('&');

};



Util_class.prototype.Hash.prototype._each = function(iterator) {

 for (var key in this) {

  var value = this[key];

  if (value && value == Util_class.prototype.Hash.prototype[key]) continue; 



  var pair = [key, value];

  pair.key = key;

  pair.value = value;

  iterator(pair);

 }

};



Util_class.prototype.Hash.prototype.keys = function() {

 return this.pluck('key');

};



Util_class.prototype.Hash.prototype.values = function() {

 return this.pluck('value');

};



Util_class.prototype.Hash.prototype.merge = function(hash) {

 return new WSDOM.Hash(hash).inject(this, function(mergedHash, pair) {

  mergedHash[pair.key] = pair.value;

  return mergedHash;

 });

};



Util_class.prototype.Hash.prototype.remove = function() {

 var result;

 for(var i = 0, length = arguments.length; i < length; i++) {

  var value = this[arguments[i]];

  if (value !== undefined){

   if (result === undefined) result = value;

   else {

    if (result.constructor != Array) result = [result];

    result.push(value)

   }

  }

  delete this[arguments[i]];

 }

 return result;

};



 



 



WSDOM.defineClass("Util", null, Util_class);

WSDOM.loadSingleton("WSDOM.Util.1");



 





Behaviour_class = function() { 

 this.timingEnabled = false;

 this._stackEvents = false;

 

 this.events;

 if (window["WSDOM"]) {

  this.Events = WSDOM.Events; 

 } else {

  this.Events = Events; 

 }

}







Behaviour_class.prototype.apply = function(map,parentEl,timingEnabled) {

 if (timingEnabled !== undefined) { this.timingEnabled = !!timingEnabled; }

 this.walkMap(map, parentEl||null);

}



Behaviour_class.prototype.applyRules = Behaviour_class.prototype.apply;







Behaviour_class.prototype.walkMap = function(map, parentEl) {

 var totalTime = 0;

 var startTime, endTime, selectorTime;

 var rElements, rule, i, el;

 for(var address in map) {

  startTime = new Date();

  rElements = Element.parseSelector(address,parentEl||null);

  for(i=0; el = rElements[i]; i++) {

   if (typeof map[address] == "function") {

    map[address](el,i)

   }

   else {

    this.applyEventRule.apply(this, [ map[address], el ]);

   }

  }

  endTime = new Date();

  selectorTime = endTime-startTime;

  

  this.outputTiming(selectorTime,"Behaviour timing for " + address + " ("+rElements.length+")");



  totalTime += selectorTime;

 }

 this.outputTiming(totalTime,"Total Behaviour timing");

}







Behaviour_class.prototype.applyEventRule = function(rule, el) {



 var evtArgs, prop;

 for(var eventType in rule) {



  eventDesc = rule[eventType];



  

  var evtArgs = {

   label: eventType + ": " + rule,

   element: el,

   type: eventType,

   handler: eventDesc,

   data: new Object(),

   context: window,

   trace: false

  }



  

  

  

  if (typeof(eventDesc) == "object") {

   

   evtArgs.handler = null;

   if (this.validEventParameter(eventDesc)) {

    for(prop in eventDesc) {

     evtArgs[prop] = eventDesc[prop];

    }

   } else {

    var elementDbg = el.tagName + ( (el.id) ? "#" + el.id : "" ) + ( (el.className) ? "." + el.className : "" );

    dbg("Invalid event parameter for eventType: " + eventType, elementDbg);

   }

  }



  

  if (this.Events.remove && !this._stackEvents) {

   this.Events.remove(el, eventType);

  }



  this.Events.add(evtArgs);

 }



}



Behaviour_class.prototype.validEventParameter = function(o) {

 return (o.handler !== undefined);

}



Behaviour_class.prototype.outputTiming = function(timing,desc) {

 if (this.timingEnabled) {

  try { console.info((desc?desc+": ":"")+timing);  } catch(e) {}

 }

}







Behaviour_class.prototype.setEventStacking = function(bStackEvents) {

 this._stackEvents = bStackEvents;

}



if (window["WSDOM"]) {

 WSDOM.using("WSDOM.Behaviour.2", "WSDOM.Events.2");

 WSDOM.defineClass("Behaviour", null, Behaviour_class);

 WSDOM.loadSingleton("WSDOM.Behaviour.2");

} else {

 var Behaviour = new Behaviour_class(); 

}





 









function Remoting_class()

{

 this.connections = [];

 this.connectionsMax = 100;

 this.connectionsActive = 0;

 this.connectionsPending = [];

 this.debug = false;

 this.context; 

 this.connectionId = 0;



 if (arguments.length && typeof arguments[0] == "object")

 {

  this.context = arguments[0];

 };

};











 



Remoting_class.prototype.load = function (contentPackage)

{



 

 try

 {

  contentPackage.method = contentPackage.method.toLowerCase();



  if (contentPackage.method != "get" && contentPackage.method != "post")

  {

   contentPackage.method = "post";

  };

 }

 catch (e)

 {

  contentPackage.method = "post";

 };



 if (!contentPackage.data)

 {

  contentPackage.data = {};

 };



 

 if (document.location.search.match(/\.\.nocache\.\.=on/i))

 {

  contentPackage.data["..nocache.."] = "on";

 };



 

 var dbgChartSrv = document.location.search.match(/\.\.debugchartsrv\.\.=([a-zA-Z]+)/i);

 if (dbgChartSrv) {

  contentPackage.data["..debugchartsrv.."] = dbgChartSrv[1];

 }



 if (contentPackage.protocolType && contentPackage.protocolType.toString().match(/JsonRPC/gi)) {

  return new JsonRPC_Connection_class(this, this.connectionId++, contentPackage);

 } else {

  return new Connection_class(this, this.connectionId++, contentPackage);

 }



};









Remoting_class.prototype._loadXMLHTTP = function (connection) {



    var thisConnection = connection;

    var contentPackage = thisConnection.contentPackage;



 function stateMonitor () {

  thisBuffer._monitorConnectionState(thisConnection);

 };



 this.connectionsActive++;



     



 var dataPackage = null;

 var thisBuffer = this;



 thisConnection.active = true;

 



 contentPackage.params = {};



 if (typeof contentPackage.contentType == "string") {

  contentPackage.params["..contenttype.."] = contentPackage.contentType;

 };



 if (this.debug || contentPackage.debug) {

  WSDOM.Console.startGroup("Remoting");

 };



 

 contentPackage.params["..requester.."] = "ContentBuffer";



 if (contentPackage.method == "post") {



  dataPackage = "";



  WSDOM.Console.dir(contentPackage);

  dataPackage = "inputs=" + this.encode(WSDOM.Serializer.serialize(contentPackage.data));



  for (var i in contentPackage.params) {

   dataPackage += (dataPackage.length ? "&" : "") + this.encode(i) + "=" + this.encode(contentPackage.params[i]);

  };



  if (this.debug || contentPackage.debug) {

   WSDOM.Console.log("ContentBuffer post data", dataPackage);

  };



 } else {

   



  contentPackage.url += (contentPackage.url.indexOf("?") == -1 ? "?" : "&") + "data=" + this.encode(WSDOM.Serializer.serialize(contentPackage.data));



 };



 if (this.debug || contentPackage.debug) {

  WSDOM.Console.log("ContentBuffer loading [" + thisConnection.connectionId + "]", contentPackage.url + " [" + contentPackage.method + "]");

 };



 if (this.debug || contentPackage.debug) {



  var debugUrl = contentPackage.url;



  if (dataPackage) {

   debugUrl += (debugUrl.indexOf("?") == -1 ? "?" : "&") + dataPackage;

  };



  debugUrl = debugUrl.replace(/\&?\.\.[^\=\&]*\.\.\=[^\&]*/g, "");



  if (debugUrl.indexOf("/") != 0 && debugUrl.indexOf("http") != 0) {

   var path = String(window.location).replace(/https*:\/\//, "");

   debugUrl = path.substr(path.indexOf("/"), path.lastIndexOf("/") + 1 - path.indexOf("/")) + debugUrl;

  }



  WSDOM.Console.link("ContentBuffer URL", debugUrl);

 };



 try {

  

      thisConnection.c.open(contentPackage.method.toUpperCase(), contentPackage.url, true);

  thisConnection.c.onreadystatechange = stateMonitor;

 } catch (e) {

  

 };



 if (contentPackage.method == "post") {

  thisConnection.c.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

 };



 

 



 thisConnection.c.send(dataPackage);



 if (this.debug || contentPackage.debug) {

  WSDOM.Console.endGroup("Remoting");

 };



 

};









Remoting_class.prototype._monitorConnectionState = function (connection) {



 try {



  if (connection.c.readyState == 4) {



   if (connection.c.status != 200) {



     



    try {

     var result = connection.c.responseText;

    } catch (e) {

     var result = null;

    };



    connection.contentPackage.result = result;



    if (typeof connection.contentPackage.onerror == "function") {

     connection.contentPackage.onerror.apply(connection.context || window, [connection]);

    };



    return;

   };



   var responseType = connection.contentPackage.contentType || connection.c.getResponseHeader("Content-Type");

   var result = null;





   if (responseType.match(/text\/html/g) || responseType.match(/text\/plain/g)) {

    result = connection.c.responseText;

   } else if (responseType.match(/text\/xml/g)) {

    result = connection.c.responseXML;

   } else if (responseType.match(/text\/javascript/g)) {

    try {

     result = connection.c.responseText;



     if (!connection.contentPackage.preventEval) {



                       connection.context.__evalBuffer = function() {

                           eval(result);

                       }



                       connection.context.__evalBuffer();



     };





    } catch (e) {

     if (this.debug || connection.contentPackage.debug) {

      WSDOM.Console.error("Remoting javascript eval error", e.message);

      WSDOM.Console.dir(e);

      

     };

    };

   } else if (responseType.match(/application\/json/gi)) {

    try {

     result = connection.c.responseText;

     result = WSDOM.Serializer.deserialize(result);



    } catch (e) {

     if (this.debug || connection.contentPackage.debug) {



      WSDOM.Console.error("Remoting Serializer Error", e.message);

      

      WSDOM.Console.dir(e);

     };

    };

   };



   connection.contentPackage.result = result;



   if (this.debug || connection.contentPackage.debug) {

    

   };



   if (typeof connection.contentPackage.onload == "function") {

    connection.contentPackage.onload.apply(connection.context || window, [connection]);

   };



   this.finishConnection(connection);

  };



 } catch (e) {

  if (this.debug || connection.contentPackage.debug) {

   WSDOM.Console.error("state monitoring error", e.message);

   WSDOM.Console.dir(e);

   

   

  };



  this.finishConnection(connection);

 };

};









Remoting_class.prototype.isActive = function() {

 for (var i=0; i<this.connections.length; i++) {

  if (this.connections[i].active) {

   return true;

  }

 }



 return false;

}









Remoting_class.prototype.abortRequests = function () {

 for (var i = 0; i < this.connections.length; i++) {

  this.connections[i].abort();

 };

}









Remoting_class.prototype.abortRequests = function () {

 for (var i = 0; i < this.connections.length; i++) {

  this.connections[i].abort();

 };

}









Remoting_class.prototype.encode = function(str) {

 



  

 return encodeURIComponent(str);

};



Remoting_class.prototype.finishConnection = function(connection)

{

 if(connection.active)

 {

  this.connectionsActive--;

  connection.active = false;

 }



 if(this.connectionsPending.length)

 {

  this._loadXMLHTTP(this.connectionsPending.shift());

 }



 for (var x=0; x < this.connections.length; x++){

  if (connection === this.connections[x]){

   this.connections.splice(x,1);

   break;

  }

 }

}













function RemotingBase_class() {};

RemotingBase_class.Extend(Remoting_class);























function Connection_class(contentBuffer, id, contentPackage) {

 this.active = false;

 this.parent = contentBuffer;

 this.connectionId = id;

 this.contentPackage = contentPackage;

 this.context = (contentPackage && contentPackage.context) || (this.parent && this.parent.context);

 this._init();

};



Connection_class.prototype._init = function() {



    var c = false;



 try {

  c = new ActiveXObject("Msxml2.XMLHTTP");

 } catch (e) {

  try {

   c = new ActiveXObject("Microsoft.XMLHTTP");

  } catch (f) {

   c = false;

  };

 };



 if (!c && typeof XMLHttpRequest != "undefined") {

  c = new XMLHttpRequest();

 };



 if (c) {

  this.c = c;

 } else {

    WSDOM.Console.log("Remoting initialization error.", "Not supported by this browser", "red");

 };



 if (this.parent) {

     if (this.parent.connectionsActive < this.parent.connectionsMax) {

         this.parent.connections.push(this);

         this.parent._loadXMLHTTP(this);

     } else {

         WSDOM.Console.log("queuing request");

         this.parent.connectionsPending.push(this);

     };

 };

};



Connection_class.prototype.getResult = function() {

    return this.contentPackage.result;

};



Connection_class.prototype.status = function() {

 return (this.c.readyState == 4 && this.c.status == 200);

};



Connection_class.prototype.abort = function() {

 if (this.active) {

  try {

   this.c.onreadystatechange = function() {};

   this.c.abort();

  } catch (e) {

   WSDOM.Console.log("connection abort failed", e, "red");

  };



  this.parent.finishConnection(this);

 };

};











function JsonRPC_Connection_class(contentBuffer, id, contentPackage) {

 this.protocolType = "JsonRPC";

 this.active = false;

 this.parent = contentBuffer;

 this.connectionId = id;

 this.contentPackage = contentPackage;

 this.context = (contentPackage && contentPackage.context) || (this.parent && this.parent.context);

 this._init();

};

JsonRPC_Connection_class.Extend(Connection_class);











WSDOM.using("WSDOM.Remoting.1", "WSDOM.Console.1");

WSDOM.using("WSDOM.Remoting.1", "WSDOM.Serializer.3");

WSDOM.defineClass("Remoting", null, Remoting_class);

WSDOM.loadClass("WSDOM.Remoting.1");





function Serializer_class() {



 this._nameExclusions = {};

 this._typeExclusions = {};

 

 this._encode = true;

 this._strictJson = true;

 this._safeDeserialize = false;



 this._sBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";



};





Serializer_class.prototype.serialize = function (o) {



 this._data = [];

 this._serializeNode([o], o, 0);

 this._data = this._data.join("");

 this._data = this._data.replace(/,}/g, "}");

 this._data = this._data.replace(/,]/g, "]");

 this._data = this._data.substr(0, this._data.length-1);



 if (this.allowEncoding()) {



  this._data = this.base64encode(this._data);



 }



 return this._data;



}





Serializer_class.prototype.addNameExclusion = function () {



 var l = arguments.length;



 for (var i=0; i<l; i++) {



  this._nameExclusions[arguments[i]] = true;



 }



}





Serializer_class.prototype.removeNameExclusion = function () {



 var l = arguments.length;



 for (var i=0; i<l; i++) {



  this._nameExclusions[arguments[i]] = false;



 }



}





Serializer_class.prototype.addTypeExclusion = function () {



 var l = arguments.length;



 for (var i=0; i<l; i++) {



  this._typeExclusions[arguments[i].toLowerCase()] = true;



 }



}





Serializer_class.prototype.removeTypeExclusion = function () {



 var l = arguments.length;



 for (var i=0; i<l; i++) {



  this._typeExclusions[arguments[i].toLowerCase()] = false;



 }



}





Serializer_class.prototype.requireStrictJson = function (value) {



 if (typeof(value) != "undefined") {



  this._strictJson = value;



 }



 return this._strictJson;



}





Serializer_class.prototype.requireSafeDeserialize = function (value) {



 if (typeof(value) != "undefined") {



  this._safeDeserialize = value;



 }



 return this._safeDeserialize;



}





Serializer_class.prototype.allowEncoding = function (value) {



 if (typeof(value) != "undefined") {



  this._encode = value;



 }



 return this._encode;



}



Serializer_class.prototype._unicodeEscape = function (str) {

 var dec = str.charCodeAt(0);

 var hexStr = "\\u";

 var hexVals = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' ];



 var hexPlace;



 

 hexPlace = 4096 

 hexStr += hexVals[Math.floor(dec / hexPlace)];

 dec = dec % hexPlace;



 hexPlace = 256  

 hexStr += hexVals[Math.floor(dec / hexPlace)];

 dec = dec % hexPlace;



 hexPlace = 16   

 hexStr += hexVals[Math.floor(dec / hexPlace)];

 dec = dec % hexPlace;



 hexPlace = 1    

 hexStr += hexVals[Math.floor(dec / hexPlace)];

 dec = dec % hexPlace;



 return hexStr;

}





Serializer_class.prototype._serializeNode = function (o, startObj, depth, parentType) {



 var t, f, d1, d2;



 

 for (var i in o) {



  if (o[i] === null) {

   t = "null";

  } else {

   t = typeof(o[i]);

  }





  f = t == "object" ? true : false;

  t = t == "object" && typeof(o[i].length) != "undefined" && o[i].constructor == Array ? "array" : t;



  if (!this._typeExclusions[t] && !this._nameExclusions[i] && !(this._strictJson && t == "function")) {



   switch (t) {



    case "string" :



     d1 = "\"";

     d2 = "\"";

     break;



    case "object" :



     d1 = "{";

     d2 = "}";

     break;



    case "array" :



     d1 = "[";

     d2 = "]";

     break;



    default :



     d1 = "";

     d2 = "";

     break;



    }



   

   if (isFinite(i) && !(parentType && parentType == "object")) {



    this._data.push(d1);



   } else {



    var n = typeof(i) == "string" ? "\"" + i + "\"" : i;

    this._data.push(n + ":" + d1);



   }



   if (f) {



    if (depth == 0 || o[i] !== startObj) {



     this._serializeNode(o[i],null,null,t);



    }



   } else {



    if (t == "string") {



    

     this._data.push(o[i].replace(/[^ -~]|[\"\\]/g, this._unicodeEscape));



    } else if (t == "undefined" || t == "null") {



     this._data.push(t);



    } else {



     this._data.push(o[i]);



    }

   }



   this._data.push(d2 + ",");



  }



 }

}



Serializer_class.prototype.deserialize = function (o) {



 try {



  

  

  if (this.hasEncodingLeader(o)) {

   

   

   



   var indexR = o.indexOf('\r');

   var indexN = o.indexOf('\n');

   var index = Math.min(indexR+1 || indexN+1, indexN+1 || indexR+1)-1;



   if (index == -1) {

    o = this.base64decode(o);

   }

   else {

    o = this.base64decode(o.substring(0, index)) + o.substring(index);

   }

  }



  



  if (this._safeDeserialize) {

   return this.safeDeserialize(o);

  } else {

   return this.unsafeDeserialize(o);

  }



 } catch(e) {



  WSDOM.Console.log("Serializer.deserialize() error", "", "red");

  WSDOM.Console.dir(e);

  WSDOM.Console.log("Serializer Source", o);



  var x = "";



 }



 return x;



}

Serializer_class.prototype.safeDeserialize = function (o) {

 try {

  var p = new JsonParser_class();

  p.parse(o);

  eval("var x = " + o);

 } catch(e) {

  var x = null;

 }

 return x;

}

Serializer_class.prototype.unsafeDeserialize = function (o) {

 try {

  eval("var x = " + o);

 } catch(e) {

  WSDOM.Console.dir(e);

  var x = null;

 }

 return x;

}



Serializer_class.prototype.hasEncodingLeader = function (s) {



 return s.indexOf("B64ENC") == 0 ? true : false;



}



Serializer_class.prototype.stripLeader = function (s) {



 return s.substr(6, s.length);



}



Serializer_class.prototype.prependLeader = function (s) {



 return "B64ENC" + s;



}





Serializer_class.prototype.base64decode = function (sIn) {



 var i;

 var iBits;

 var sOut = [];



 if (this.hasEncodingLeader(sIn)) {



  sIn = this.stripLeader(sIn);



 } else {



  return sIn;



 }



 sIn = sIn.replace(/=/g, "");



 for(i = 0; i < sIn.length; i += 4) {



  iBits = (this._sBase64.indexOf(sIn.charAt(i)) << 18) |

   (this._sBase64.indexOf(sIn.charAt(i + 1)) << 12) |

   ((this._sBase64.indexOf(sIn.charAt(i + 2)) & 0xff) << 6) |

   (this._sBase64.indexOf(sIn.charAt(i + 3)) & 0xff);



   

   



  sOut.push(String.fromCharCode(iBits >> 16 & 0xff));

  sOut.push((i > sIn.length - 3) ? "" : String.fromCharCode(iBits >> 8 & 0xff));

  sOut.push((i > sIn.length - 4) ? "" : String.fromCharCode(iBits & 0xff));



 }



 return sOut.join("");



}





Serializer_class.prototype.base64encode = function (sIn) {



 var i;

 var iBits;

 var sOut = [];



 for(i = 0; i < sIn.length; i += 3) {



  iBits = (sIn.charCodeAt(i) << 16) +

   ((sIn.charCodeAt(i + 1) & 0xff) << 8) +

   (sIn.charCodeAt(i + 2) & 0xff);



   

   



  sOut.push(this._sBase64.charAt(iBits >> 18 & 0x3f));

  sOut.push(this._sBase64.charAt(iBits >> 12 & 0x3f));

  sOut.push((i > sIn.length - 2) ? "=" : this._sBase64.charAt(iBits >> 6 & 0x3f));

  sOut.push((i > sIn.length - 3) ? "=" : this._sBase64.charAt(iBits & 0x3f));



 }



 sOut = this.prependLeader(sOut.join(""));



 return sOut;



}

































function JsonParser_class () {

 this.lexer = null;

 this.tokens = [ ];

}



JsonParser_class.prototype.parse = function (str) {

 this.lexer = new JsonLexer_class(str);



 return this._json();

}







JsonParser_class.prototype.lookAhead = function (k) {

 while (this.tokens.length <= k) {

  this.tokens.push(this.lexer.nextToken());

 }

 return this.tokens[k].type;

}









JsonParser_class.prototype.consume = function (type) {

 if (this.tokens.length == 0) {

  this.tokens.push(this.lexer.nextToken());

 }



 if (this.tokens[0].type == type) {

  this.tokens.shift();

 } else {

  throw { message: 'JSON: invalid token encountered validating string; Expected '+type+', got '+this.tokens[0].type };

 }

}





JsonParser_class.prototype._json = function () {

 this._value();

 this.consume('_EOF');

}















JsonParser_class.prototype._value = function () {

 switch(this.lookAhead(0)) {

  case '_OBJ_OPEN':

   this._object();

   break;

  case '_ARR_OPEN':

   this._array();

   break;

  case '_DIGITS':

  case '_NEG':

   this._number();

   break;

  case '_STRING':

   this.consume('_STRING');

   break;

  case '_TRUE':

   this.consume('_TRUE');

   break;

  case '_FALSE':

   this.consume('_FALSE');

   break;

  case '_NULL':

   this.consume('_NULL');

   break;

 }

}







JsonParser_class.prototype._object = function () {

 this.consume('_OBJ_OPEN');

 if (this.lookAhead(0) != '_OBJ_CLOSE') {

  this._member();

 }

 while (this.lookAhead(0) != '_OBJ_CLOSE') {

  this.consume('_SEP');

  this._member();

 }

 this.consume('_OBJ_CLOSE');

}



JsonParser_class.prototype._member = function () {

 this.consume('_STRING');

 this.consume('_ASSIGN');

 this._value();

}







JsonParser_class.prototype._array = function () {

 this.consume('_ARR_OPEN');

 if (this.lookAhead(0) != '_ARR_CLOSE') {

  this._value();

 }

 while (this.lookAhead(0) != '_ARR_CLOSE') {

  this.consume('_SEP');

  this._value();

 }

 this.consume('_ARR_CLOSE');

}







JsonParser_class.prototype._number = function () {

 if (this.lookAhead(0) == '_NEG') {

  this.consume('_NEG');

 }



 this.consume('_DIGITS');



 if (this.lookAhead(0) == '_DOT') {

  this.consume('_DOT');

  this.consume('_DIGITS');

 }



 if (this.lookAhead(0) == '_EXP') {

  this.consume('_EXP');

  if (this.lookAhead(0) == '_POS') {

   this.consume('_POS');

  } else if (this.lookAhead(0) == '_NEG') {

   this.consume('_NEG');

  }

  this.consume('_DIGITS');

 }

}



function JsonLexer_class (input) {

 

 

 

 input = input.replace(/"([^"\\]|\\"|\\)*"/g, 'S');

 input = input.replace(/[0-9]+/g, '0');



 this.input = input;

}





JsonLexer_class.prototype.charTokens = {

        '{': '_OBJ_OPEN',

        '}': '_OBJ_CLOSE',

        '[': '_ARR_OPEN',

        ']': '_ARR_CLOSE',

        ':': '_ASSIGN',

        ',': '_SEP',

        '.': '_DOT',

        '-': '_NEG',

        '+': '_POS',

        'e': '_EXP',

        'E': '_EXP',

        'S': '_STRING',

        '0': '_DIGITS'

       };











JsonLexer_class.prototype.nextToken = function () {

 if (this.input.length == 0) {

  return new JsonToken_object("_EOF", null);

 }



 var first = this.input.substr(0,1);

 if (this.charTokens[first]) {

  this.input = this.input.substr(1);

  return new JsonToken_object(this.charTokens[first], first);

 }



 switch (first) {

  case 't':

  case 'T':

   if (this.input.substr(0,4).toLowerCase() == 'true') {

    this.input = this.input.substr(4);

    return new JsonToken_object('_TRUE', true);

   }

   break;



  case 'f':

  case 'F':

   if (this.input.substr(0,5).toLowerCase() == 'false') {

    this.input = this.input.substr(5);

    return new JsonToken_object('_FALSE', true);

   }

   break;



  case 'n':

   if (this.input.substr(0,4) == 'null') {

    this.input = this.input.substr(4);

    return new JsonToken_object('_NULL', true);

   }

   break;

 }



 throw { message: 'JSON: Unexpected character ('+first+') encountered validating string' };

}





function JsonToken_object (type, value) {

 this.type = type;

 this.value = value;

}













WSDOM.using("WSDOM.Serializer.3", "WSDOM.Console.1");

WSDOM.defineClass("Serializer", null, Serializer_class);

WSDOM.loadSingleton("WSDOM.Serializer.3");









Effects_class = function () {

 this.namedQueues = { };

 this.globalQueue = [ ];

}



Effects_class.prototype.enqueue = function (effectList, params) {

 if (!params) {

  params = { };

 }



 var global = params.global || false;

 var qName = params.global ? null : (params.shared || 'r'+Math.random());



 if (qName && !this.namedQueues[qName]) {

  this.namedQueues[qName] = [ ];

  this.namedQueues[qName].name = qName;

 }

 var queue = qName ? this.namedQueues[qName] : this.globalQueue;



 if (params.onComplete) {

  if (params.context) {

   queue.onComplete = function () { params.onComplete.apply(params.context, [ ]); }

  } else {

   queue.onComplete = params.onComplete;

  }

 }



 for (var i = 0; i < effectList.length; i++) {

  queue.push(effectList[i]);

 }



 this._runQueue(queue);

}



Effects_class.prototype.createParallel = function (effectList, params) {

 var onComplete = null;

 if (params) {

  if (params.onComplete) {

   if (params.context) {

    onComplete = function () { params.onComplete.apply(params.context, [ ]); }

   } else {

    onComplete = params.onComplete;

   }

  }

 }



 var InitClosure = function(context) {

  return function() {

   context._initParallel(effectList, onComplete);

  };

 };

  

 effectList.animate = InitClosure(this);

 return effectList;

}



Effects_class.prototype.runParallel = function (effectList, params) {

 var ef = this.createParallel(effectList, params);

 ef.animate();

 return ef;

}



Effects_class.prototype.create = function (element, type, params) {

 var ef = new Effect(element, type, params);

 return ef;

}



Effects_class.prototype.run = function (element, type, params) {

 var ef = this.create(element, type, params);

 ef.animate();

 return ef;

}



Effects_class.prototype._runQueue = function (queue) {

 if (queue.length) {

  var ef = queue.shift();

  ef.runningQueue = queue;

  ef.animate();

 } else {

  if (queue.onComplete) {

   queue.onComplete();

   queue.onComplete = null;

  }

  if (queue.name) {

   

   delete this.namedQueues[queue.name];

  }

 }

}



Effects_class.prototype._initParallel = function (effectList, onComplete) {

 for (var i = 0; i < effectList.length; i++) {

  effectList[i].animateParallel();

 }



 this._animateParallel(effectList, onComplete);

}



Effects_class.prototype._animateParallel = function (effectList, onComplete) {

 var isAnimating = false;

 for (var i = 0; i < effectList.length; i++) {

  effectList[i].nextFrame();

  isAnimating = isAnimating || effectList[i].isAnimating;

 }



 if (isAnimating) {

  var ParaClosure = function(context) {

   return function() {

    context._animateParallel(effectList, onComplete);

   };

  };

   

  setTimeout(ParaClosure(this), 0);

 } else {

  if (effectList.runningQueue) {

   this._runQueue(effectList.runningQueue);

   effectList.runningQueue = null;

  }



  if (onComplete) {

   onComplete();

  }

 }

}



Effects = new Effects_class();



 



var Effect = function(oEl,sType,oParams) {

 

 

 oParams = oParams || false;

 

 if(!oParams) {

 

  return;

  

 }

 

 

 

 this.oEl = Element.get(oEl);

 

 this._animType = sType || false;

 

 this.valueGetter = this.getValueGetterSetters().getter;

 

 this.valueSetter = this.getValueGetterSetters().setter;

 

 this._rawTo = oParams.to;

 

 this._rawFrom = oParams.from !== undefined ? oParams.from : this.valueGetter();

 

 this._easing = Easing; 

 

 this._easeMethod = oParams.easing && this._easing[oParams.easing] && this._easing[oParams.easing] !== undefined ? this._easing[oParams.easing] : this._easing.easeNone;

 

 this._duration = oParams.duration;

 

 this.isAnimating = false;

 

 this.setOnCompleteHandler(oParams.onComplete, oParams.context);

 

 

 

 this._startTime = 0;

 

 this._prevTime = 0;

 

 this._time = 0;

 

}







Effect.prototype.animate = function(){

 

 this.animateParallel();



 this.onEnterFrame();

 

}



Effect.prototype.animateParallel = function(){

 this._to = (typeof this._rawTo == 'function') ? this._rawTo() : this._rawTo;

 this._from = (typeof this._rawFrom == 'function') ? this._rawFrom() : this._rawFrom;

 

 

 

 if (this._animType == 'background') {

  if (!(this._to instanceof Array)) {

   this._to = this.toRGB(this._to);

  }

  if (!(this._from instanceof Array)) {

   this._from = this.toRGB(this._from);

  }

 }



 this._delta = this.getDelta();

 

 this._startTime = new Date().getTime();

 

 this.isAnimating = true;



 

 

 

}



Effect.prototype.onEnterFrame = function() {



 if(this.isAnimating) {

  

  this.nextFrame();

  

  var AnimClosure = function(context) {

   return function() {

    context.onEnterFrame()

   };

  };

  

  setTimeout(AnimClosure(this), 0);

  

 }



}



Effect.prototype.nextFrame = function() {



 this.setTime((this.getTimer() - this._startTime) / 1000);

 

}



Effect.prototype.getTimer = function() {



 return new Date().getTime() - this._time; 



}



Effect.prototype.setTime = function(t){

 

 this._prevTime = this._time;

 

 if (t > this._duration) {

  

  this._time = this._duration;

  

  this.update();

  

  this.stop();

  

 }  else {

  

  this._time = t;

  

  this.update();

  

 }

}



Effect.prototype.update = function(value) {



 if (this._from instanceof Array) {

  this.valueSetter([  this._easeMethod(this._time,this._from[0],this._delta[0],this._duration),

       this._easeMethod(this._time,this._from[1],this._delta[1],this._duration),

       this._easeMethod(this._time,this._from[2],this._delta[2],this._duration)

      ]);

 } else {

  this.valueSetter(this._easeMethod(this._time,this._from,this._delta,this._duration));

 }

 

}

 

Effect.prototype.stop = function() {

 

 this.isAnimating = false;

 

 if (this.runningQueue) {

  Effects._runQueue(this.runningQueue);

  this.runningQueue = null;

 }



 this.onComplete();



}



Effect.prototype.getDelta = function(){

 

 return (this._to instanceof Array) ? 

  [ this._to[0] - this._from[0],this._to[1] - this._from[1],  this._to[2] - this._from[2] ] :

  this._to - this._from;

 

}



Effect.prototype.setOnCompleteHandler = function(f,c){

 if (c && f) {

  this.onComplete = function () { f.apply(c, arguments) };

 } else {

  this.onComplete = f || function(){return false;}; 

 }

}



 

Effect.prototype.getValueGetterSetters = function() {



 var oGS; 



 switch(this._animType) {

 

  case "width":



   return {

    getter:function() { 

     return Element.getSize(this.oEl).width

    },

    setter:function(iWidth) {

     iWidth = iWidth >= 0 ? iWidth : 0;

     Element.setWidth(this.oEl,iWidth);

    }

   }

  

  break;

  case "height":

  

   return {

    getter:function() { 

     return Element.getSize(this.oEl).height

    },

    setter:function(iHeight) {

     iHeight = iHeight >= 0 ? iHeight : 0;

     Element.setHeight(this.oEl,iHeight);

    }

   }

  

  break;

   

  case "x":

   

   return {

    getter:function() { 

     return this.oEl.offsetLeft;

    },

    setter:function(iX) {

     this.oEl.style.left = iX + "px";

    }

   }

  

  break;

  case "y":

   

   return {

    getter:function() { 

     return this.oEl.offsetTop;

    },

    setter:function(iY) {

     this.oEl.style.top = iY + "px";

    }

   }

  

  break;

  case "opacity":

  

   return {

    getter:function() { 

     var iOpac = this.oEl.style.opacity;

     return iOpac == "" || isNaN(iOpac) ? 100 : iOpac * 100;

    },

    setter:function(iOpacity) {

     Element.setOpacity(this.oEl,iOpacity);

    }

   }

  

  break;

  case "scrollLeft":

  

   return {

    getter:function() { 

     return this.oEl.scrollLeft;

    },

    setter:function(iScrollLeft) {

     this.oEl.scrollLeft = iScrollLeft;

    }

   }

  

  break;

  case "scrollTop":

  

   return {

    getter:function() { 

     return this.oEl.scrollTop;

    },

    setter:function(iScrollTop) {

     return this.oEl.scrollTop = iScrollTop;

    }

   }

  case "background":

  

   return {

    getter:function() { 

     return this.toRGB(this.oEl.style.backgroundColor);

    },

    setter:function(aRGB) {

     this.oEl.style.backgroundColor = this.toHex(aRGB);

     return aRGB

    }

   }

  

  break;

  default:

   return false;

  break

 

 }

}



Effect.prototype.toRGB = function (hex) {

 hexInt = parseInt(hex.substr(1), 16);

 return [ hexInt >> 16, hexInt >> 8 & 255, hexInt & 255 ];

}



Effect.prototype.toHex = function (rgb) {

 var hex = '#';

 for (var i = 0; i < 3; i++) {

  rgb[i] = Math.min(255, Math.max(0, Math.round(rgb[i]))).toString(16);

  while (rgb[i].length < 2) {

   rgb[i] = '0' + rgb[i];

  }

  hex += rgb[i];

 }



 return hex;

}



 

var Easing = {};



Easing.easeNone =  function (t, b, c, d) {

    return c*t/d + b;

}



Easing.backEaseIn = function(t,b,c,d,a,p){

 if (s == undefined) var s = 1.70158;

 return c*(t/=d)*t*((s+1)*t - s) + b;

}

Easing.backEaseOut = function(t,b,c,d,a,p){

 if (s == undefined) var s = 1.70158;

 return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;

}

Easing.backEaseInOut = function(t,b,c,d,a,p){

 if (s == undefined) var s = 1.70158; 

 if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;

 return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;

}

Easing.elasticEaseIn = function(t,b,c,d,a,p){

  if (t==0) return b;  

  if ((t/=d)==1) return b+c;  

  if (!p) p=d*.3;

  if (!a || a < Math.abs(c)) {

   a=c; var s=p/4;

  }

  else 

   var s = p/(2*Math.PI) * Math.asin (c/a);

  

  return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;

 

}

Easing.elasticEaseOut = function (t,b,c,d,a,p){

  if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;

  if (!a || a < Math.abs(c)) { a=c; var s=p/4; }

  else var s = p/(2*Math.PI) * Math.asin (c/a);

  return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b);

 }

Easing.elasticEaseInOut = function (t,b,c,d,a,p){

 if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) var p=d*(.3*1.5);

 if (!a || a < Math.abs(c)) {var a=c; var s=p/4; }

 else var s = p/(2*Math.PI) * Math.asin (c/a);

 if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;

 return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;

}



Easing.bounceEaseOut = function(t,b,c,d){

 if ((t/=d) < (1/2.75)) {

  return c*(7.5625*t*t) + b;

 } else if (t < (2/2.75)) {

  return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;

 } else if (t < (2.5/2.75)) {

  return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;

 } else {

  return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;

 }

}

Easing.bounceEaseIn = function(t,b,c,d){

 return c - Easing.bounceEaseOut (d-t, 0, c, d) + b;

 }

Easing.bounceEaseInOut = function(t,b,c,d){

 if (t < d/2) return Easing.bounceEaseIn (t*2, 0, c, d) * .5 + b;

 else return Easing.bounceEaseOut (t*2-d, 0, c, d) * .5 + c*.5 + b;

 }



Easing.strongEaseInOut = function(t,b,c,d){

 return c*(t/=d)*t*t*t*t + b;

 }



Easing.regularEaseIn = function(t,b,c,d){

 return c*(t/=d)*t + b;

 }

Easing.regularEaseOut = function(t,b,c,d){

 return -c *(t/=d)*(t-2) + b;

 }



Easing.regularEaseInOut = function(t,b,c,d){

 if ((t/=d/2) < 1) return c/2*t*t + b;

 return -c/2 * ((--t)*(t-2) - 1) + b;

 }

Easing.strongEaseIn = function(t,b,c,d){

 return c*(t/=d)*t*t*t*t + b;

 }

Easing.strongEaseOut = function(t,b,c,d){

 return c*((t=t/d-1)*t*t*t*t + 1) + b;

 }



Easing.strongEaseInOut = function(t,b,c,d){

 if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;

 return c/2*((t-=2)*t*t*t*t + 2) + b;

 }





WSDOM.defineClass("Effects", null, Effects_class);

WSDOM.loadSingleton("WSDOM.Effects.1");





UnitTester_class = function() {};



 







 



UnitTester_class.prototype.TestCase = function() {

     

    this.name = 'TestCase';



    this.initialize = function(reporter) {

        

        

        this._exceptions = new Array();

        this._reporter = reporter;

    };



    this.setUp = function() {

         

    };



    this.tearDown = function() {

         

    };



    this.assertEquals = function(var1, var2) {

         

        if (var1 && var1.toSource && var2 && var2.toSource) {

            if (var1.toSource() != var2.toSource()) {

                throw('Assertion failed: ' + var1 + ' != ' + var2);

            };

        } else {

            if (var1 != var2) {

                throw('Assertion failed: ' + var1 + ' != ' + var2);

            };

        };

    };



    this.assert = function(statement) {

         

        if (!statement) {

            throw('Assertion ' + statement.toString ? statement.toString() : statement + ' failed');

        };

    };



    this.assertTrue = this.assert;



    this.assertFalse = function(statement) {

         

        if (statement) {

            throw('Assertion ' + statement.toString() + ' failed');

        };

    };



    this.fail = function(message) {

        throw("Failure: " + message);

    };



    this.assertThrows = function(func, exception, context) {

         

        if (!context) {

            context = null;

        };

        if (!exception) {

            return;

        };

        var exception_thrown = false;

        try {

            func.apply(context, arguments);

        } catch(e) {

            if (exception.toSource && e.toSource) {

                exception = exception.toSource();

                e = e.toSource();

            } else if (exception.toString && e.toString) {

                exception = exception.toString();

                e = e.toString();

            };

            if (e != exception) {

                throw('Function threw the wrong exception ' +

                        e.toString() + ', while expecting ' +

                        exception.toString());

            };

            exception_thrown = true;

        };

        if (!exception_thrown) {

            if (exception) {

                throw("function didn\'t raise exception \'" +

                        exception.toString() + "'");

            } else {

                throw('function didn\'t raise exception');

            };

        };

    };



    this.runTests = function() {

         

        var ret = this._runHelper();

        this._reporter.summarize(ret[0], ret[1], this._exceptions);

    };



    this._runHelper = function() {

         

        var now = new Date();

        var starttime = now.getTime();

        var numtests = 0;

        for (var attr in this) {

            if (attr.substr(0, 4) == 'test') {

                this.setUp();

                try {

                    this[attr]();

                    this._reporter.reportSuccess(this.name, attr);

                } catch(e) {

                    this._reporter.reportError(this.name, attr, e);

                    this._exceptions.push(new Array(this.name, attr, e));

                };

                this.tearDown();

                numtests++;

            };

        };

        var now = new Date();

        var totaltime = now.getTime() - starttime;

        return new Array(numtests, totaltime);

    };



};



UnitTester_class.prototype.TestSuite = function(reporter) {

     

    this._reporter = reporter;

    this._tests = new Array();

    this._exceptions = new Array();



    this.add = function(test) {

         

        if (!test) {

            throw('TestSuite.add() requires a testcase as argument');

        };

        this._tests.push(test);

    };



    this.run = function() {

         



        this._reporter.start();





        var now = new Date();

        var starttime = now.getTime();

        var testsran = 0;

        for (var i=0; i < this._tests.length; i++) {

            var test = this._tests[i];

            test.initialize(this._reporter);

            testsran += test._runHelper()[0];

            

            

            if (test._exceptions.length) {

                for (var j=0; j < test._exceptions.length; j++) {

                    

                    

                    var excinfo = test._exceptions[j];

                    this._exceptions.push(excinfo);

                };

            };

        };

        var now = new Date();

        var totaltime = now.getTime() - starttime;

        this._reporter.summarize(testsran, totaltime, this._exceptions);





        this._reporter.end();

    };

};





UnitTester_class.prototype.ConsoleReporter = function() {



 this.start = function() {

  WSDOM.Console.startGroup("WSDOM.UnitTester");

 };



 this.end = function() {

  WSDOM.Console.endGroup("WSDOM.UnitTester");

 };



 this.reportSuccess = function(testcase, attr) {

         

  WSDOM.Console.log("+ " + testcase + '.' + attr);

    };



    this.reportError = function(testcase, attr, exception) {



  WSDOM.Console.error(testcase + '.' + attr);



    };



    this.summarize = function(numtests, time, exceptions) {



      WSDOM.Console.startGroup("WSDOM.UnitTesting Summary");



       WSDOM.Console.log(numtests + ' tests ran in ' +  time / 1000.0 + ' seconds');



       if (exceptions.length) {

        for (var i=0; i < exceptions.length; i++) {

         var testcase = exceptions[i][0];

     var attr = exceptions[i][1];

     var exception = exceptions[i][2];



     var text = testcase + '.' + attr + ', exception: ' + exception;



     WSDOM.Console.log(text);

        };



        WSDOM.Console.error("NOT OK!");



       } else {

        WSDOM.Console.log("OK!");

       };



  WSDOM.Console.endGroup("WSDOM.UnitTesting Summary");

 };

};



UnitTester_class.prototype.AlertReporter = function(verbose) {

    this.buffer = "";

    this.reportSuccess = function(testcase, attr) {

        this.buffer = this.buffer + ".";

    };

    this.reportError = function(testcase, attr, exception) {

        this.buffer = this.buffer + "F";

    };

    this.summarize = function(numtests, time, exceptions) {

        alert(this.buffer);

    };

}



UnitTester_class.prototype.HTMLReporter = function(outputelement, verbose) {

    this.outputelement = outputelement;

    this.document = outputelement.ownerDocument;

    this.verbose = verbose; 



    this.reportSuccess = function(testcase, attr) {

         

        

        var dot = this.document.createTextNode('+');

        this.outputelement.appendChild(dot);

    };



    this.reportError = function(testcase, attr, exception) {

         

        var f = this.document.createTextNode('F');

        this.outputelement.appendChild(f);

    };



    this.summarize = function(numtests, time, exceptions) {

         

        var p = this.document.createElement('p');

        var text = this.document.createTextNode(numtests + ' tests ran in ' +  time / 1000.0 + ' seconds');

        p.appendChild(text);

        this.outputelement.appendChild(p);

        if (exceptions.length) {

            for (var i=0; i < exceptions.length; i++) {

                var testcase = exceptions[i][0];

                var attr = exceptions[i][1];

                var exception = exceptions[i][2];

                var div = this.document.createElement('div');

                var text = this.document.createTextNode(

                    testcase + '.' + attr + ', exception: ' + exception);

                div.appendChild(text);

                div.style.color = 'red';

                this.outputelement.appendChild(div);

            };

            var div = this.document.createElement('div');

            var text = this.document.createTextNode('NOT OK!');

            div.appendChild(text);

            div.style.backgroundColor = 'red';

            div.style.color = 'black';

            div.style.fontWeight = 'bold';

            div.style.textAlign = 'center';

            div.style.marginTop = '1em';

            this.outputelement.appendChild(div);

        } else {

            var div = this.document.createElement('div');

            var text = this.document.createTextNode('OK!');

            div.appendChild(text);

            div.style.backgroundColor = 'lightgreen';

            div.style.color = 'black';

            div.style.fontWeight = 'bold';

            div.style.textAlign = 'center';

            div.style.marginTop = '1em';

            this.outputelement.appendChild(div);

        };

    };

};





WSDOM.using("WSDOM.UnitTester.1", "WSDOM.Console.1");

WSDOM.defineClass("UnitTester", null, UnitTester_class);

WSDOM.loadSingleton("WSDOM.UnitTester.1");



WSDOM.Events.add({element:window, type:"load", handler:function() {

 WSDOM.Console.log("window loaded");

 MainNav.behaviour();

}});



function MainNavClass() {

    this.delayTimeouts = [];

    this.pageForm = WSDOM.Element.parseSelector('form')[0];

 this.mainNavContainer = WSDOM.Element.get('mainNav');

 this.subNavContainer = WSDOM.Element.get('subNav');

 this.subNavTables = WSDOM.Element.parseSelector('table', this.subNavContainer);

 

 this.textSizeWrap = WSDOM.Element.get('textSize');

 this.textSizeItems = WSDOM.Element.parseSelector('a',this.textSizeWrap);

 

 this.wsodPanel = WSDOM.Element.get('ctl00_wsodPanel');

 

 this.mainNavLinks = WSDOM.Element.parseSelector('a', this.mainNavContainer);

};



function loadControl(fontSize)

{

    var c = font.setFontSize(

            {

                onload:loadControlCallback,

                onerror:function() { alert(r.error.value); },

                arguments: { "size": fontSize } 

            });

}



function loadControlCallback(result)

{ 

    var loadedControl = WSDOM.Element.parseSelector('span[id*="loadedControl"]', null, "first");

    loadedControl.innerHTML = "";

    loadedControl.innerHTML = result.getResult();

}



MainNavClass.prototype.behaviour = function() {



 WSDOM.Behaviour.apply({

  '#mainNav table td a' : {

      'mouseover' : function(e, el) {

          var useContext = this;

          this.highlight(e,el)

      

      

      }.Context(this),

      'mouseout' : function(e, el) {

      this.clearDelayTimeouts();

      var useContext = this;

      this.delayTimeouts.push(window.setTimeout(function() {useContext.subNavOut(e,el)}, "100"));

      }.Context(this)

  },

  '#subNav' : {

      'mouseover' : function(e, el) {

       this.subNavHover(e,el)

      }.Context(this),

      'mouseout' : function(e, el) {

          var useContext = this;

       this.delayTimeouts.push(window.setTimeout(function() {useContext.subNavOut(e,el)}, "500"));

      }.Context(this)

  },

  '#textSize a' : {

      'click' : function(e, el) {

          this.doThis(e,el);



      }.Context(this)

  },

  '#terms' : {

      'click' : function(e, el) {

          WSDOM.Events.cancel(e);

          

       var termsWrap = WSDOM.Element.get("disclaimer");

       WSDOM.Element.toggleClass(termsWrap,"displayNone");

       

      }.Context(this)

  }

  

  

 }); 

}



MainNavClass.prototype.doThis = function(e,el) {

    WSDOM.Events.cancel(e)

    var elStyle = el.id;



    var useClass = "mdFont";

    

    if (elStyle && -1 < elStyle.indexOf("smFont")){

        useClass = "smFont";

    } else if (-1 < elStyle.indexOf("lgFont")) {

        useClass = "lgFont";

    }



    WSDOM.Element.removeClass(this.textSizeItems, 'on');

    WSDOM.Element.addClass(el,'on');

    

    WSDOM.Element.removeClass(this.wsodPanel, 'smFont');

    WSDOM.Element.removeClass(this.wsodPanel, 'mdFont');

    WSDOM.Element.removeClass(this.wsodPanel, 'lgFont');

    

    WSDOM.Element.addClass(this.wsodPanel, useClass);

    

     var c = font.setFontSize(

            {

                onload:function(){},

                onerror:function() { alert(r.error.value); },

                arguments: { "size": useClass } 

            });

}



MainNavClass.prototype.highlight = function(e,el) {

    if(WSDOM.Element.get("mainNavHover")) {

        WSDOM.Element.remove("mainNavHover");

    }

    

    var navItemXY = WSDOM.Element.getXY(el);

    var navItemHREF = el.getAttribute("HREF");

    var navItemID = el.getAttribute("ID");

    var navSubMenu = (el.getAttribute("id")) ? "sub_"+ el.getAttribute("id") : el.getAttribute("id");

    var text = el.innerHTML;



    var hoverEL = WSDOM.Element.create("a", {id:"mainNavHover", href:navItemHREF}, text, this.pageForm);

    WSDOM.Element.setXY(hoverEL, navItemXY.x - 1, navItemXY.y);

    WSDOM.Element.setStyle(hoverEL,"display:block");

    

     WSDOM.Behaviour.apply({

  '#mainNavHover' : {

      'mouseover' : function(e, el) {

          

          this.clearDelayTimeouts();

      }.Context(this),

      'mouseout' : function(e, el) {

         if(navSubMenu) {

          var useContext = this;

       this.delayTimeouts.push(window.setTimeout(function() {useContext.navHoverOut(e,el)}, "500"));

      } else {

       this.navHoverOut(e,el);

       

      }

      }.Context(this)

  }

 });

 

 WSDOM.Element.addClass(this.subNavTables, "displayNone");

 

 if(navSubMenu) {

       var subNavTable = WSDOM.Element.get(navSubMenu);

       WSDOM.Element.removeClass(this.subNavContainer, "displayNone");

       WSDOM.Element.removeClass(subNavTable, "displayNone");

    }

 

}



MainNavClass.prototype.navHoverOut = function(e,el) {

    

    WSDOM.Element.remove(el);

    WSDOM.Element.addClass(this.subNavTables, "displayNone");

    WSDOM.Element.addClass(this.subNavContainer, "displayNone");



}



MainNavClass.prototype.subNavHover = function(e,el) {

    this.clearDelayTimeouts();

}

MainNavClass.prototype.subNavOut = function(e,el) {

   var hoveEL = WSDOM.Element.get("mainNavHover");

   if(hoveEL){

    WSDOM.Element.remove("mainNavHover");

   }

   WSDOM.Element.addClass(this.subNavTables, "displayNone");

   WSDOM.Element.addClass(this.subNavContainer, "displayNone");

}



MainNavClass.prototype.clearDelayTimeouts = function() {

 for (var i=0; i<this.delayTimeouts.length; i++) {

  window.clearTimeout(this.delayTimeouts[i]);

 }

 this.delayTimeouts = [];

};



var MainNav = new MainNavClass();



function req(variable) {

  var query = window.location.search.substring(1);

 var vars = query.split("&");

  for (var i=0;i<vars.length;i++) {

 var pair = vars[i].split("=");

    if (pair[0] == variable) {

      return pair[1];

    }

  }

}





var Element = WSDOM.Element;

var Events = WSDOM.Events;

var Console = WSDOM.Console;

var Behaviour = WSDOM.Behaviour;

var Util = WSDOM.Util;

var Remoting = WSDOM.Remoting;

var Serializer = WSDOM.Serializer;

var Effects = WSDOM.Effects;

var UnitTester = WSDOM.UnitTester;



