var base2={name:"base2",version:"1.0 (beta 2)",exports:"Base,Package,Abstract,Module,Enumerable,Map,Collection,RegGrp,assert,assertArity,assertType,assignID,copy,detect,extend,forEach,format,global,instanceOf,match,rescape,slice,trim,typeOf,I,K,Undefined,Null,True,False,bind,delegate,flip,not,unbind",global:this,detect:new function(_){var global=_;var jscript=NaN/*@cc_on||@_jscript_version@*/;var java=_.java?true:false;if(_.navigator){var MSIE=/MSIE[\d.]+/g;var element=document.createElement("span");var userAgent=navigator.userAgent.replace(/([a-z])[\s\/](\d)/gi,"$1$2");if(!jscript){userAgent=userAgent.replace(MSIE,"")}if(MSIE.test(userAgent)){userAgent=userAgent.match(MSIE)[0]+" "+userAgent.replace(MSIE,"")}userAgent=navigator.platform+" "+userAgent;java&=navigator.javaEnabled()}return function(expression){var r=false;var not=expression.charAt(0)=="!";if(not){expression=expression.slice(1)}if(expression.charAt(0)=="("){try{eval("r=!!"+expression)}catch(e){}}else{r=new RegExp("("+expression+")","i").test(userAgent)}return !!(not^r)}}(this)};new function(_){var _namespace="function base(o,a){return o.base.apply(o,a)};";eval(_namespace);var detect=base2.detect;var Undefined=K(),Null=K(null),True=K(true),False=K(false);var _FORMAT=/%([1-9])/g;var _LTRIM=/^\s\s*/;var _RTRIM=/\s\s*$/;var _RESCAPE=/([\/()[\]{}|*+-.,^$?\\])/g;var _BASE=/eval/.test(detect)?/\bbase\s*\(/:/.*/;var _HIDDEN=["constructor","toString","valueOf"];var _MSIE_NATIVE_FUNCTION=detect("(jscript)")?new RegExp("^"+rescape(isNaN).replace(/isNaN/,"\\w+")+"$"):{test:False};var _counter=1;var _slice=Array.prototype.slice;var slice=Array.slice||function(array){return _slice.apply(array,_slice.call(arguments,1))};_Function_forEach();var _subclass=function(_instance,_static){base2.__prototyping=this.prototype;var _prototype=new this;extend(_prototype,_instance);delete base2.__prototyping;var _constructor=_prototype.constructor;function _class(){if(!base2.__prototyping){if(this.constructor==arguments.callee||this.__constructing){this.__constructing=true;_constructor.apply(this,arguments);delete this.__constructing}else{return extend(arguments[0],_prototype)}}return this}_prototype.constructor=_class;for(var i in Base){_class[i]=this[i]}_class.ancestor=this;_class.base=Undefined;_class.init=Undefined;extend(_class,_static);_class.prototype=_prototype;_class.init();_class.toString=K(String(_constructor));_class["#implements"]=[];_class["#implemented_by"]=[];return _class};var Base=_subclass.call(Object,{constructor:function(){if(arguments.length>0){this.extend(arguments[0])}},base:function(){},extend:delegate(extend)},Base={ancestorOf:delegate(_ancestorOf),extend:_subclass,forEach:delegate(_Function_forEach),implement:function(source){if(typeof source=="function"){if(_ancestorOf(Base,source)){source(this.prototype);this["#implements"].push(source);source["#implemented_by"].push(this)}}else{extend(this.prototype,source)}return this}});var Package=Base.extend({constructor:function(_private,_public){this.extend(_public);if(this.init){this.init()}if(this.name!="base2"){if(!this.parent){this.parent=base2}this.parent.addName(this.name,this);this.namespace=format("var %1=%2;",this.name,String(this).slice(1,-1))}var LIST=/[^\s,]+/g;if(_private){_private.imports=Array2.reduce(this.imports.match(LIST),function(namespace,name){eval("var ns=base2."+name);assert(ns,format("Package not found: '%1'.",name),ReferenceError);return namespace+=ns.namespace},_namespace+base2.namespace+JavaScript.namespace);_private.exports=Array2.reduce(this.exports.match(LIST),function(namespace,name){var fullName=this.name+"."+name;this.namespace+="var "+name+"="+fullName+";";return namespace+="if(!"+fullName+")"+fullName+"="+name+";"},"",this)}},exports:"",imports:"",name:"",namespace:"",parent:null,addName:function(name,value){if(!this[name]){this[name]=value;this.exports+=","+name;this.namespace+=format("var %1=%2.%1;",name,this.name)}},addPackage:function(name){this.addName(name,new Package(null,{name:name,parent:this}))},toString:function(){return format("[%1]",this.parent?String(this.parent).slice(1,-1)+"."+this.name:this.name)}});var Abstract=Base.extend({constructor:function(){throw new TypeError("Class cannot be instantiated.")}});var Module=Abstract.extend(null,{extend:function(_interface,_static){var module=this.base();module.implement(this);module.implement(_interface);extend(module,_static);module.init();return module},implement:function(_interface){var module=this;if(typeof _interface=="function"){if(!_ancestorOf(_interface,module)){this.base(_interface)}if(_ancestorOf(Module,_interface)){forEach(_interface,function(property,name){if(!module[name]){if(typeof property=="function"&&property.call&&_interface.prototype[name]){property=function(){return _interface[name].apply(_interface,arguments)}}module[name]=property}})}}else{extend(module,_interface);_Function_forEach(Object,_interface,function(source,name){if(name.charAt(0)=="@"){if(detect(name.slice(1))){forEach(source,arguments.callee)}}else{if(typeof source=="function"&&source.call){module.prototype[name]=function(){var args=_slice.call(arguments);args.unshift(this);return module[name].apply(module,args)};module.prototype[name]._module=module}}})}return module}});var Enumerable=Module.extend({every:function(object,test,context){var result=true;try{this.forEach(object,function(value,key){result=test.call(context,value,key,object);if(!result){throw StopIteration}})}catch(error){if(error!=StopIteration){throw error}}return !!result},filter:function(object,test,context){var i=0;return this.reduce(object,function(result,value,key){if(test.call(context,value,key,object)){result[i++]=value}return result},[])},invoke:function(object,method){var args=_slice.call(arguments,2);return this.map(object,(typeof method=="function")?function(item){return(item==null)?undefined:method.apply(item,args)}:function(item){return(item==null)?undefined:item[method].apply(item,args)})},map:function(object,block,context){var result=[],i=0;this.forEach(object,function(value,key){result[i++]=block.call(context,value,key,object)});return result},pluck:function(object,key){return this.map(object,function(item){return(item==null)?undefined:item[key]})},reduce:function(object,block,result,context){var initialised=arguments.length>2;this.forEach(object,function(value,key){if(initialised){result=block.call(context,result,value,key,object)}else{result=value;initialised=true}});return result},some:function(object,test,context){return !this.every(object,not(test),context)}},{forEach:forEach});var _HASH="#";var Map=Base.extend({constructor:function(values){this.merge(values)},copy:delegate(copy),forEach:function(block,context){for(var key in this){if(key.charAt(0)==_HASH){block.call(context,this[key],key.slice(1),this)}}},get:function(key){return this[_HASH+key]},getKeys:function(){return this.map(flip(I))},getValues:function(){return this.map(I)},has:function(key){/*@cc_on @*//*@if (@_jscript_version < 5.5)
    return $Legacy.has(this, _HASH + key);
  @else @*/return _HASH+key in this;/*@end @*/},merge:function(values){var put=flip(this.put);forEach(arguments,function(values){forEach(values,put,this)},this);return this},remove:function(key){delete this[_HASH+key]},put:function(key,value){if(arguments.length==1){value=key}this[_HASH+key]=value},size:function(){var size=0;for(var key in this){if(key.charAt(0)==_HASH){size++}}return size},union:function(values){return this.merge.apply(this.copy(),arguments)}});Map.implement(Enumerable);var _KEYS="~";var Collection=Map.extend({constructor:function(values){this[_KEYS]=new Array2;this.base(values)},add:function(key,item){assert(!this.has(key),"Duplicate key '"+key+"'.");this.put.apply(this,arguments)},copy:function(){var copy=this.base();copy[_KEYS]=this[_KEYS].copy();return copy},forEach:function(block,context){var keys=this[_KEYS];var length=keys.length;for(var i=0;i<length;i++){block.call(context,this[_HASH+keys[i]],keys[i],this)}},getAt:function(index){if(index<0){index+=this[_KEYS].length}var key=this[_KEYS][index];return(key===undefined)?undefined:this[_HASH+key]},getKeys:function(){return this[_KEYS].concat()},indexOf:function(key){return this[_KEYS].indexOf(String(key))},insertAt:function(index,key,item){assert(Math.abs(index)<this[_KEYS].length,"Index out of bounds.");assert(!this.has(key),"Duplicate key '"+key+"'.");this[_KEYS].insertAt(index,String(key));this[_HASH+key]==null;this.put.apply(this,_slice.call(arguments,1))},item:function(keyOrIndex){return this[typeof keyOrIndex=="number"?"getAt":"get"](keyOrIndex)},put:function(key,item){if(arguments.length==1){item=key}if(!this.has(key)){this[_KEYS].push(String(key))}var klass=this.constructor;if(klass.Item&&!instanceOf(item,klass.Item)){item=klass.create.apply(klass,arguments)}this[_HASH+key]=item},putAt:function(index,item){assert(Math.abs(index)<this[_KEYS].length,"Index out of bounds.");arguments[0]=this[_KEYS].item(index);this.put.apply(this,arguments)},remove:function(key){if(this.has(key)){this[_KEYS].remove(String(key));delete this[_HASH+key]}},removeAt:function(index){var key=this[_KEYS].removeAt(index);delete this[_HASH+key]},reverse:function(){this[_KEYS].reverse();return this},size:function(){return this[_KEYS].length},sort:function(compare){if(compare){var self=this;this[_KEYS].sort(function(key1,key2){return compare(self[_HASH+key1],self[_HASH+key2],key1,key2)})}else{this[_KEYS].sort()}return this},toString:function(){return String(this[_KEYS])}},{Item:null,create:function(key,item){return this.Item?new this.Item(key,item):item},extend:function(_instance,_static){var klass=this.base(_instance);klass.create=this.create;extend(klass,_static);if(!klass.Item){klass.Item=this.Item}else{if(typeof klass.Item!="function"){klass.Item=(this.Item||Base).extend(klass.Item)}}klass.init();return klass}});var _RG_BACK_REF=/\\(\d+)/g,_RG_ESCAPE_CHARS=/\\./g,_RG_ESCAPE_BRACKETS=/\(\?[:=!]|\[[^\]]+\]/g,_RG_BRACKETS=/\(/g,_RG_LOOKUP=/\$(\d+)/,_RG_LOOKUP_SIMPLE=/^\$\d+$/;var RegGrp=Collection.extend({constructor:function(values,flags){this.base(values);if(typeof flags=="string"){this.global=/g/.test(flags);this.ignoreCase=/i/.test(flags)}},global:true,ignoreCase:false,exec:function(string,replacement){var flags=(this.global?"g":"")+(this.ignoreCase?"i":"");string=String(string)+"";if(arguments.length==1){var self=this;var keys=this[_KEYS];replacement=function(match){if(match){var item,offset=1,i=0;while((item=self[_HASH+keys[i++]])){var next=offset+item.length+1;if(arguments[offset]){var replacement=item.replacement;switch(typeof replacement){case"function":return replacement.apply(self,_slice.call(arguments,offset,next));case"number":return arguments[offset+replacement];default:return replacement}}offset=next}}return""}}return string.replace(new RegExp(this,flags),replacement)},insertAt:function(index,expression,replacement){if(instanceOf(expression,RegExp)){arguments[1]=expression.source}return base(this,arguments)},test:function(string){return this.exec(string)!=string},toString:function(){var length=0;return"("+this.map(function(item){var ref=String(item).replace(_RG_BACK_REF,function(match,index){return"\\"+(1+Number(index)+length)});length+=item.length+1;return ref}).join(")|(")+")"}},{IGNORE:"$0",init:function(){forEach("add,get,has,put,remove".split(","),function(name){_override(this,name,function(expression){if(instanceOf(expression,RegExp)){arguments[0]=expression.source}return base(this,arguments)})},this.prototype)},Item:{constructor:function(expression,replacement){if(typeof replacement=="number"){replacement=String(replacement)}else{if(replacement==null){replacement=""}}if(typeof replacement=="string"&&_RG_LOOKUP.test(replacement)){if(_RG_LOOKUP_SIMPLE.test(replacement)){replacement=parseInt(replacement.slice(1))}else{var Q=/'/.test(replacement.replace(/\\./g,""))?'"':"'";replacement=replacement.replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\$(\d+)/g,Q+"+(arguments[$1]||"+Q+Q+")+"+Q);replacement=new Function("return "+Q+replacement.replace(/(['"])\1\+(.*)\+\1\1$/,"$1")+Q)}}this.length=RegGrp.count(expression);this.replacement=replacement;this.toString=K(String(expression))},length:0,replacement:""},count:function(expression){expression=String(expression).replace(_RG_ESCAPE_CHARS,"").replace(_RG_ESCAPE_BRACKETS,"");return match(expression,_RG_BRACKETS).length}});var JavaScript={name:"JavaScript",version:base2.version,exports:"Array2,Date2,String2",namespace:"",bind:function(host){forEach(this.exports.match(/\w+/g),function(name2){var name=name2.slice(0,-1);extend(host[name],this[name2]);this[name2](host[name].prototype)},this);return this}};if((new Date).getYear()>1900){Date.prototype.getYear=function(){return this.getFullYear()-1900};Date.prototype.setYear=function(year){return this.setFullYear(year+1900)}}Function.prototype.prototype={};if("".replace(/^/,K("$$"))=="$"){extend(String.prototype,"replace",function(expression,replacement){if(typeof replacement=="function"){var fn=replacement;replacement=function(){return String(fn.apply(null,arguments)).split("$").join("$$")}}return this.base(expression,replacement)})}var Array2=_createObject2(Array,Array,"concat,join,pop,push,reverse,shift,slice,sort,splice,unshift",[Enumerable,{combine:function(keys,values){if(!values){values=keys}return this.reduce(keys,function(hash,key,index){hash[key]=values[index];return hash},{})},contains:function(array,item){return this.indexOf(array,item)!=-1},copy:function(array){var copy=_slice.call(array);if(!copy.swap){this(copy)}return copy},flatten:function(array){var length=0;return this.reduce(array,function(result,item){if(this.like(item)){this.reduce(item,arguments.callee,result,this)}else{result[length++]=item}return result},[],this)},forEach:_Array_forEach,indexOf:function(array,item,fromIndex){var length=array.length;if(fromIndex==null){fromIndex=0}else{if(fromIndex<0){fromIndex=Math.max(0,length+fromIndex)}}for(var i=fromIndex;i<length;i++){if(array[i]===item){return i}}return -1},insertAt:function(array,index,item){this.splice(array,index,0,item);return item},item:function(array,index){if(index<0){index+=array.length}return array[index]},lastIndexOf:function(array,item,fromIndex){var length=array.length;if(fromIndex==null){fromIndex=length-1}else{if(fromIndex<0){fromIndex=Math.max(0,length+fromIndex)}}for(var i=fromIndex;i>=0;i--){if(array[i]===item){return i}}return -1},map:function(array,block,context){var result=[];this.forEach(array,function(item,index){result[index]=block.call(context,item,index,array)});return result},remove:function(array,item){var index=this.indexOf(array,item);if(index!=-1){this.removeAt(array,index)}return item},removeAt:function(array,index){return this.splice(array,index,1)},swap:function(array,index1,index2){if(index1<0){index1+=array.length}if(index2<0){index2+=array.length}var temp=array[index1];array[index1]=array[index2];array[index2]=temp;return array}}]);Array2.reduce=Enumerable.reduce;Array2.like=function(object){return !!(object&&typeof object=="object"&&typeof object.length=="number")};Enumerable["#implemented_by"].pop();Enumerable["#implemented_by"].push(Array2);var _DATE_PATTERN=/^((-\d+|\d{4,})(-(\d{2})(-(\d{2}))?)?)?T((\d{2})(:(\d{2})(:(\d{2})(\.(\d{1,3})(\d)?\d*)?)?)?)?(([+-])(\d{2})(:(\d{2}))?|Z)?$/;var _DATE_PARTS={FullYear:2,Month:4,Date:6,Hours:8,Minutes:10,Seconds:12,Milliseconds:14};var _TIMEZONE_PARTS={Hectomicroseconds:15,UTC:16,Sign:17,Hours:18,Minutes:20};var _TRIM_ZEROES=/(((00)?:0+)?:0+)?\.0+$/;var _TRIM_TIMEZONE=/(T[0-9:.]+)$/;var Date2=_createObject2(Date,function(yy,mm,dd,h,m,s,ms){switch(arguments.length){case 0:return new Date;case 1:return new Date(yy);default:return new Date(yy,mm,arguments.length==2?1:dd,h||0,m||0,s||0,ms||0)}},"",[{toISOString:function(date){var string="####-##-##T##:##:##.###";for(var part in _DATE_PARTS){string=string.replace(/#+/,function(digits){var value=date["getUTC"+part]();if(part=="Month"){value++}return("000"+value).slice(-digits.length)})}return string.replace(_TRIM_ZEROES,"").replace(_TRIM_TIMEZONE,"$1Z")}}]);Date2.now=function(){return(new Date).valueOf()};Date2.parse=function(string,defaultDate){if(arguments.length>1){assertType(defaultDate,"number","defaultDate should be of type 'number'.")}var match=String(string).match(_DATE_PATTERN);if(match){if(match[_DATE_PARTS.Month]){match[_DATE_PARTS.Month]--}if(match[_TIMEZONE_PARTS.Hectomicroseconds]>=5){match[_DATE_PARTS.Milliseconds]++}var date=new Date(defaultDate||0);var prefix=match[_TIMEZONE_PARTS.UTC]||match[_TIMEZONE_PARTS.Hours]?"UTC":"";for(var part in _DATE_PARTS){var value=match[_DATE_PARTS[part]];if(!value){continue}date["set"+prefix+part](value);if(date["get"+prefix+part]()!=match[_DATE_PARTS[part]]){return NaN}}if(match[_TIMEZONE_PARTS.Hours]){var Hours=Number(match[_TIMEZONE_PARTS.Sign]+match[_TIMEZONE_PARTS.Hours]);var Minutes=Number(match[_TIMEZONE_PARTS.Sign]+(match[_TIMEZONE_PARTS.Minutes]||0));date.setUTCMinutes(date.getUTCMinutes()+(Hours*60)+Minutes)}return date.valueOf()}else{return Date.parse(string)}};var String2=_createObject2(String,function(string){return new String(arguments.length==0?"":string)},"charAt,charCodeAt,concat,indexOf,lastIndexOf,match,replace,search,slice,split,substr,substring,toLowerCase,toUpperCase",[{trim:trim}]);function _createObject2(Native,constructor,generics,extensions){var INative=Module.extend();forEach(generics.match(/\w+/g),function(name){INative[name]=unbind(Native.prototype[name])});forEach(extensions,INative.implement,INative);var Native2=function(){return INative(this.constructor==INative?constructor.apply(null,arguments):arguments[0])};Native2.prototype=INative.prototype;forEach(INative,function(method,name){if(Native[name]){INative[name]=Native[name];delete INative.prototype[name]}Native2[name]=INative[name]});Native2.ancestor=Object;delete Native2.extend;if(Native!=Array){delete Native2.forEach}return Native2}function extend(object,source){if(object&&source){if(arguments.length>2){var key=source;source={};source[key]=arguments[2]}var proto=(typeof source=="function"?Function:Object).prototype;var i=_HIDDEN.length,key;if(base2.__prototyping){while(key=_HIDDEN[--i]){var value=source[key];if(value!=proto[key]){if(_BASE.test(value)){_override(object,key,value)}else{object[key]=value}}}}for(key in source){if(proto[key]===undefined){var value=source[key];if(key.charAt(0)=="@"){if(detect(key.slice(1))){arguments.callee(object,value)}continue}var ancestor=object[key];if(ancestor&&typeof value=="function"){if(value!=ancestor&&(!ancestor.method||!_ancestorOf(value,ancestor))){if(_BASE.test(value)){_override(object,key,value)}else{value.ancestor=ancestor;object[key]=value}}}else{object[key]=value}}}}return object}function _ancestorOf(ancestor,fn){while(fn){if(!fn.ancestor){return false}fn=fn.ancestor;if(fn==ancestor){return true}}return false}function _override(object,name,method){var ancestor=object[name];var superObject=base2.__prototyping;if(superObject&&ancestor!=superObject[name]){superObject=null}function _base(){var previous=this.base;this.base=superObject?superObject[name]:ancestor;var returnValue=method.apply(this,arguments);this.base=previous;return returnValue}_base.ancestor=ancestor;object[name]=_base;_base.toString=K(String(method))}if(typeof StopIteration=="undefined"){StopIteration=new Error("StopIteration")}function forEach(object,block,context,fn){if(object==null){return }if(!fn){if(typeof object=="function"&&object.call){fn=Function}else{if(typeof object.forEach=="function"&&object.forEach!=arguments.callee){object.forEach(block,context);return }else{if(typeof object.length=="number"){_Array_forEach(object,block,context);return }}}}_Function_forEach(fn||Object,object,block,context)}function _Array_forEach(array,block,context){if(array==null){return }var length=array.length,i;if(typeof array=="string"){for(i=0;i<length;i++){block.call(context,array.charAt(i),i,array)}}else{for(i=0;i<length;i++){/*@cc_on @*//*@if (@_jscript_version < 5.2)
      if ($Legacy.has(array, i))
    @else @*/if(i in array){/*@end @*/block.call(context,array[i],i,array)}}}}function _Function_forEach(fn,object,block,context){var Temp=function(){this.i=1};Temp.prototype={i:1};var count=0;for(var i in new Temp){count++}_Function_forEach=(count>1)?function(fn,object,block,context){var processed={};for(var key in object){if(!processed[key]&&fn.prototype[key]===undefined){processed[key]=true;block.call(context,object[key],key,object)}}}:function(fn,object,block,context){for(var key in object){if(fn.prototype[key]===undefined){block.call(context,object[key],key,object)}}};_Function_forEach(fn,object,block,context)}function typeOf(object){var type=typeof object;switch(type){case"object":return object===null?"null":typeof object.call=="function"||_MSIE_NATIVE_FUNCTION.test(object)?"function":type;case"function":return typeof object.call=="function"?type:"object";default:return type}}function instanceOf(object,klass){if(typeof klass!="function"){throw new TypeError("Invalid 'instanceOf' operand.")}if(object==null){return false;/*@cc_on  
  // COM objects don't have a constructor
  if (typeof object.constructor != "function") {
    return typeOf(object) == typeof klass.prototype.valueOf();
  }
  @*//*@if (@_jscript_version < 5.1)
    if ($Legacy.instanceOf(object, klass)) return true;
  @else @*/}if(object instanceof klass){return true;/*@end @*/}if(Base.ancestorOf==klass.ancestorOf){return false}if(Base.ancestorOf==object.constructor.ancestorOf){return klass==Object}switch(klass){case Array:return !!(typeof object=="object"&&object.join&&object.splice);case Function:return typeOf(object)=="function";case RegExp:return typeof object.constructor.$1=="string";case Date:return !!object.getTimezoneOffset;case String:case Number:case Boolean:return typeof object==typeof klass.prototype.valueOf();case Object:return true}return false}function assert(condition,message,ErrorClass){if(!condition){throw new (ErrorClass||Error)(message||"Assertion failed.")}}function assertArity(args,arity,message){if(arity==null){arity=args.callee.length}if(args.length<arity){throw new SyntaxError(message||"Not enough arguments.")}}function assertType(object,type,message){if(type&&(typeof type=="function"?!instanceOf(object,type):typeOf(object)!=type)){throw new TypeError(message||"Invalid type.")}}function assignID(object){if(!object.base2ID){object.base2ID="b2_"+_counter++}return object.base2ID}function copy(object){var fn=function(){};fn.prototype=object;return new fn}function format(string){var args=arguments;var pattern=new RegExp("%([1-"+arguments.length+"])","g");return String(string).replace(pattern,function(match,index){return args[index]})}function match(string,expression){return String(string).match(expression)||[]}function rescape(string){return String(string).replace(_RESCAPE,"\\$1")}function trim(string){return String(string).replace(_LTRIM,"").replace(_RTRIM,"")}function I(i){return i}function K(k){return function(){return k}}function bind(fn,context){var args=_slice.call(arguments,2);return args.length==0?function(){return fn.apply(context,arguments)}:function(){return fn.apply(context,args.concat.apply(args,arguments))}}function delegate(fn,context){return function(){var args=_slice.call(arguments);args.unshift(this);return fn.apply(context,args)}}function flip(fn){return function(){return fn.apply(this,Array2.swap(arguments,0,1))}}function not(fn){return function(){return !fn.apply(this,arguments)}}function unbind(fn){return function(context){return fn.apply(context,_slice.call(arguments,1))}}base2=new Package(this,base2);eval(this.exports);base2.extend=extend;forEach(Enumerable,function(method,name){if(!Module[name]){base2.addName(name,bind(method,Enumerable))}});JavaScript=new Package(this,JavaScript);eval(this.exports)};new function(_){var DOM=new base2.Package(this,{name:"DOM",version:"1.0 (beta 2)",exports:"Interface,Binding,Node,Document,Element,AbstractView,HTMLDocument,HTMLElement,Selector,Traversal,XPathParser,NodeSelector,DocumentSelector,ElementSelector,StaticNodeList,Event,EventTarget,DocumentEvent,ViewCSS,CSSStyleDeclaration",bind:function(node){if(node&&node.nodeType){var uid=assignID(node);if(!DOM.bind[uid]){switch(node.nodeType){case 1:if(typeof node.className=="string"){(HTMLElement.bindings[node.tagName]||HTMLElement).bind(node)}else{Element.bind(node)}break;case 9:if(node.writeln){HTMLDocument.bind(node)}else{Document.bind(node)}break;default:Node.bind(node)}DOM.bind[uid]=true}}return node},"@MSIE5.+win":{bind:function(node){if(node&&node.writeln){node.nodeType=9}return this.base(node)}}});eval(this.imports);var _MSIE=detect("MSIE");var _MSIE5=detect("MSIE5");var Interface=Module.extend(null,{implement:function(_interface){var module=this;if(Interface.ancestorOf(_interface)){forEach(_interface,function(property,name){if(_interface[name]._delegate){module[name]=function(){return _interface[name].apply(_interface,arguments)}}})}else{if(typeof _interface=="object"){this.forEach(_interface,function(source,name){if(name.charAt(0)=="@"){forEach(source,arguments.callee)}else{if(typeof source=="function"&&source.call){if(!module[name]){var FN="var fn=function _%1(%2){%3.base=%3.%1.ancestor;var m=%3.base?'base':'%1';return %3[m](%4)}";var args="abcdefghij".split("").slice(-source.length);eval(format(FN,name,args,args[0],args.slice(1)));fn._delegate=name;module[name]=fn}}}})}}return this.base(_interface)}});var Binding=Interface.extend(null,{bind:function(object){return extend(object,this.prototype)}});var Node=Binding.extend({"@!(element.compareDocumentPosition)":{compareDocumentPosition:function(node,other){if(Traversal.contains(node,other)){return 4|16}else{if(Traversal.contains(other,node)){return 2|8}}var nodeIndex=_getSourceIndex(node);var otherIndex=_getSourceIndex(other);if(nodeIndex<otherIndex){return 4}else{if(nodeIndex>otherIndex){return 2}}return 0}}});var _getSourceIndex=document.documentElement.sourceIndex?function(node){return node.sourceIndex}:function(node){var key=0;while(node){key=Traversal.getNodeIndex(node)+"."+key;node=node.parentNode}return key};var Document=Node.extend(null,{bind:function(document){extend(document,"createElement",function(tagName){return DOM.bind(this.base(tagName))});AbstractView.bind(document.defaultView);if(document!=window.document){new DOMContentLoadedEvent(document)}return this.base(document)},"@!(document.defaultView)":{bind:function(document){document.defaultView=Traversal.getDefaultView(document);return this.base(document)}}});var _EVALUATED=/^(href|src)$/;var _ATTRIBUTES={"class":"className","for":"htmlFor"};var Element=Node.extend({"@MSIE.+win":{getAttribute:function(element,name,iFlags){if(element.className===undefined){return this.base(element,name)}var attribute=_MSIE_getAttributeNode(element,name);if(attribute&&(attribute.specified||name=="value")){if(_EVALUATED.test(name)){return this.base(element,name,2)}else{if(name=="style"){return element.style.cssText}else{return attribute.nodeValue}}}return null},setAttribute:function(element,name,value){if(element.className===undefined){this.base(element,name,value)}else{if(name=="style"){element.style.cssText=value}else{value=String(value);var attribute=_MSIE_getAttributeNode(element,name);if(attribute){attribute.nodeValue=value}else{this.base(element,_ATTRIBUTES[name]||name,value)}}}}},"@!(element.hasAttribute)":{hasAttribute:function(element,name){return this.getAttribute(element,name)!=null}}});extend(Element.prototype,"cloneNode",function(deep){var clone=this.base(deep||false);clone.base2ID=undefined;return clone});if(_MSIE){var _PROPERCASE_ATTRIBUTES="colSpan,rowSpan,vAlign,dateTime,accessKey,tabIndex,encType,maxLength,readOnly,longDesc";extend(_ATTRIBUTES,Array2.combine(_PROPERCASE_ATTRIBUTES.toLowerCase().split(","),_PROPERCASE_ATTRIBUTES.split(",")));var _MSIE_getAttributeNode=_MSIE5?function(element,name){return element.attributes[name]||element.attributes[_ATTRIBUTES[name.toLowerCase()]]}:function(element,name){return element.getAttributeNode(name)}}var TEXT=_MSIE?"innerText":"textContent";var Traversal=Module.extend({getDefaultView:function(node){return this.getDocument(node).defaultView},getNextElementSibling:function(node){while(node&&(node=node.nextSibling)&&!this.isElement(node)){continue}return node},getNodeIndex:function(node){var index=0;while(node&&(node=node.previousSibling)){index++}return index},getOwnerDocument:function(node){return node.ownerDocument},getPreviousElementSibling:function(node){while(node&&(node=node.previousSibling)&&!this.isElement(node)){continue}return node},getTextContent:function(node){return node[TEXT]},isEmpty:function(node){node=node.firstChild;while(node){if(node.nodeType==3||this.isElement(node)){return false}node=node.nextSibling}return true},setTextContent:function(node,text){return node[TEXT]=text},"@MSIE":{getDefaultView:function(node){return(node.document||node).parentWindow},"@MSIE5":{getOwnerDocument:function(node){return node.ownerDocument||node.document}}}},{contains:function(node,target){while(target&&(target=target.parentNode)&&node!=target){continue}return !!target},getDocument:function(node){return this.isDocument(node)?node:this.getOwnerDocument(node)},isDocument:function(node){return !!(node&&node.documentElement)},isElement:function(node){return !!(node&&node.nodeType==1)},"@(element.contains)":{contains:function(node,target){return node!=target&&(this.isDocument(node)?node==this.getOwnerDocument(target):node.contains(target))}},"@MSIE5":{isElement:function(node){return !!(node&&node.nodeType==1&&node.nodeName!="!")}}});var AbstractView=Binding.extend();var Event=Binding.extend({"@!(document.createEvent)":{initEvent:function(event,type,bubbles,cancelable){event.type=type;event.bubbles=bubbles;event.cancelable=cancelable;event.timeStamp=new Date().valueOf()},"@MSIE":{initEvent:function(event,type,bubbles,cancelable){this.base(event,type,bubbles,cancelable);event.cancelBubble=!event.bubbles},preventDefault:function(event){if(event.cancelable!==false){event.returnValue=false}},stopPropagation:function(event){event.cancelBubble=true}}}},{"@!(document.createEvent)":{"@MSIE":{bind:function(event){if(!event.timeStamp){event.bubbles=!!_BUBBLES[event.type];event.cancelable=!!_CANCELABLE[event.type];event.timeStamp=new Date().valueOf()}if(!event.target){event.target=event.srcElement}event.relatedTarget=event[(event.type=="mouseout"?"to":"from")+"Element"];return this.base(event)}}}});if(_MSIE){var _BUBBLES="abort,error,select,change,resize,scroll";var _CANCELABLE="click,mousedown,mouseup,mouseover,mousemove,mouseout,keydown,keyup,submit,reset";_BUBBLES=Array2.combine((_BUBBLES+","+_CANCELABLE).split(","));_CANCELABLE=Array2.combine(_CANCELABLE.split(","))}var EventTarget=Interface.extend({"@!(element.addEventListener)":{addEventListener:function(target,type,listener,capture){var targetID=assignID(target);var listenerID=assignID(listener);var events=_eventMap[targetID];if(!events){events=_eventMap[targetID]={}}var listeners=events[type];var current=target["on"+type];if(!listeners){listeners=events[type]={};if(current){listeners[0]=current}}listeners[listenerID]=listener;if(current!==undefined){target["on"+type]=_eventMap._handleEvent}},dispatchEvent:function(target,event){return _handleEvent.call(target,event)},removeEventListener:function(target,type,listener,capture){var events=_eventMap[target.base2ID];if(events&&events[type]){delete events[type][listener.base2ID]}},"@(element.fireEvent)":{dispatchEvent:function(target,event){var type="on"+event.type;event.target=target;if(target[type]===undefined){return this.base(target,event)}else{return target.fireEvent(type,event)}}}}});var _eventMap=new Base({_handleEvent:_handleEvent,"@MSIE":{_handleEvent:function(){var target=this;var window=(target.document||target).parentWindow;if(target.Infinity){target=window}return _handleEvent.call(target,window.event)}}});function _handleEvent(event){var returnValue=true;var events=_eventMap[this.base2ID];if(events){Event.bind(event);var listeners=events[event.type];for(var i in listeners){var listener=listeners[i];if(listener.handleEvent){var result=listener.handleEvent(event)}else{result=listener.call(this,event)}if(result===false||event.returnValue===false){returnValue=false}}}return returnValue}var DocumentEvent=Interface.extend({"@!(document.createEvent)":{createEvent:function(document,type){return Event.bind({})},"@(document.createEventObject)":{createEvent:function(document,type){return Event.bind(document.createEventObject())}}},"@(document.createEvent)":{"@!(document.createEvent('Events'))":{createEvent:function(document,type){return this.base(document,type=="Events"?"UIEvents":type)}}}});var DOMContentLoadedEvent=Base.extend({constructor:function(document){var fired=false;this.fire=function(){if(!fired){fired=true;setTimeout(function(){var event=DocumentEvent.createEvent(document,"Events");Event.initEvent(event,"DOMContentLoaded",false,false);EventTarget.dispatchEvent(document,event)},1)}};EventTarget.addEventListener(document,"DOMContentLoaded",function(){fired=true},false);this.listen(document)},listen:function(document){EventTarget.addEventListener(Traversal.getDefaultView(document),"load",this.fire,false)},"@MSIE.+win":{listen:function(document){if(document.readyState!="complete"){var event=this;document.write("<script id=__ready defer src=//:><\/script>");document.all.__ready.onreadystatechange=function(){if(this.readyState=="complete"){this.removeNode();event.fire()}}}}},"@KHTML":{listen:function(document){if(document.readyState!="complete"){var event=this;var timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(timer);event.fire()}},100)}}}});new DOMContentLoadedEvent(document);Document.implement(DocumentEvent);Document.implement(EventTarget);Element.implement(EventTarget);var _PIXEL=/^\d+(px)?$/i;var _METRICS=/(width|height|top|bottom|left|right|fontSize)$/;var _COLOR=/^(color|backgroundColor)$/;var ViewCSS=Interface.extend({"@!(document.defaultView.getComputedStyle)":{"@MSIE":{getComputedStyle:function(view,element,pseudoElement){var currentStyle=element.currentStyle;var computedStyle={};for(var i in currentStyle){if(_METRICS.test(i)){computedStyle[i]=_MSIE_getPixelValue(element,computedStyle[i])+"px"}else{if(_COLOR.test(i)){computedStyle[i]=_MSIE_getColorValue(element,i=="color"?"ForeColor":"BackColor")}else{try{computedStyle[i]=currentStyle[i]}catch(x){}}}}return computedStyle}}},getComputedStyle:function(view,element,pseudoElement){return _CSSStyleDeclaration_ReadOnly.bind(this.base(view,element,pseudoElement))}},{toCamelCase:function(string){return string.replace(/\-([a-z])/g,function(match,chr){return chr.toUpperCase()})}});function _MSIE_getPixelValue(element,value){if(_PIXEL.test(value)){return parseInt(value)}var styleLeft=element.style.left;var runtimeStyleLeft=element.runtimeStyle.left;element.runtimeStyle.left=element.currentStyle.left;element.style.left=value||0;value=element.style.pixelLeft;element.style.left=styleLeft;element.runtimeStyle.left=runtimeStyleLeft;return value}function _MSIE_getColorValue(element,value){var range=element.document.body.createTextRange();range.moveToElementText(element);var color=range.queryCommandValue(value);return format("rgb(%1,%2,%3)",color&255,(color&65280)>>8,(color&16711680)>>16)}var _CSSStyleDeclaration_ReadOnly=Binding.extend({getPropertyValue:function(style,propertyName){return this.base(style,_CSSPropertyNameMap[propertyName]||propertyName)},"@MSIE.+win":{getPropertyValue:function(style,propertyName){return propertyName=="float"?style.styleFloat:style[ViewCSS.toCamelCase(propertyName)]}}});var CSSStyleDeclaration=_CSSStyleDeclaration_ReadOnly.extend({setProperty:function(style,propertyName,value,important){return this.base(style,_CSSPropertyNameMap[propertyName]||propertyName,value,important)},"@MSIE.+win":{setProperty:function(style,propertyName,value,priority){if(propertyName=="opacity"){value*=100;style.opacity=value;style.zoom=1;style.filter="Alpha(opacity="+value+")"}else{style.setAttribute(propertyName,value)}}}},{"@MSIE":{bind:function(style){style.getPropertyValue=this.prototype.getPropertyValue;style.setProperty=this.prototype.setProperty;return style}}});var _CSSPropertyNameMap=new Base({"@Gecko":{opacity:"-moz-opacity"},"@KHTML":{opacity:"-khtml-opacity"}});with(CSSStyleDeclaration.prototype){getPropertyValue.toString=setProperty.toString=function(){return"[base2]"}}AbstractView.implement(ViewCSS);var NodeSelector=Interface.extend({"@!(element.querySelector)":{querySelector:function(node,selector){return new Selector(selector).exec(node,1)},querySelectorAll:function(node,selector){return new Selector(selector).exec(node)}}});extend(NodeSelector.prototype,{querySelector:function(selector){return DOM.bind(this.base(selector))},querySelectorAll:function(selector){return extend(this.base(selector),"item",function(index){return DOM.bind(this.base(index))})}});var DocumentSelector=NodeSelector.extend();var ElementSelector=NodeSelector.extend({"@!(element.matchesSelector)":{matchesSelector:function(element,selector){return new Selector(selector).test(element)}}});var StaticNodeList=Base.extend({constructor:function(nodes){nodes=nodes||[];this.length=nodes.length;this.item=function(index){return nodes[index]}},length:0,forEach:function(block,context){for(var i=0;i<this.length;i++){block.call(context,this.item(i),i,this)}},item:Undefined,"@(XPathResult)":{constructor:function(nodes){if(nodes&&nodes.snapshotItem){this.length=nodes.snapshotLength;this.item=function(index){return nodes.snapshotItem(index)}}else{this.base(nodes)}}}});StaticNodeList.implement(Enumerable);var _CSS_ESCAPE=/'(\\.|[^'\\])*'|"(\\.|[^"\\])*"/g,_CSS_IMPLIED_ASTERISK=/([\s>+~,]|[^(]\+|^)([#.:\[])/g,_CSS_IMPLIED_SPACE=/(^|,)([^\s>+~])/g,_CSS_WHITESPACE=/\s*([\s>+~(),]|^|$)\s*/g,_CSS_WILD_CARD=/\s\*\s/g,_CSS_UNESCAPE=/\x01(\d+)/g,_QUOTE=/'/g;var CSSParser=RegGrp.extend({constructor:function(items){this.base(items);this.cache={};this.sorter=new RegGrp;this.sorter.add(/:not\([^)]*\)/,RegGrp.IGNORE);this.sorter.add(/([ >](\*|[\w-]+))([^: >+~]*)(:\w+-child(\([^)]+\))?)([^: >+~]*)/,"$1$3$6$4")},cache:null,ignoreCase:true,escape:function(selector){var strings=this._strings=[];return this.optimise(this.format(String(selector).replace(_CSS_ESCAPE,function(string){return"\x01"+strings.push(string.slice(1,-1).replace(_QUOTE,"\\'"))})))},format:function(selector){return selector.replace(_CSS_WHITESPACE,"$1").replace(_CSS_IMPLIED_SPACE,"$1 $2").replace(_CSS_IMPLIED_ASTERISK,"$1*$2")},optimise:function(selector){return this.sorter.exec(selector.replace(_CSS_WILD_CARD,">* "))},parse:function(selector){return this.cache[selector]||(this.cache[selector]=this.unescape(this.exec(this.escape(selector))))},unescape:function(selector){var strings=this._strings;return selector.replace(_CSS_UNESCAPE,function(match,index){return strings[index-1]})}});function _nthChild(match,args,position,last,not,and,mod,equals){last=/last/i.test(match)?last+"+1-":"";if(!isNaN(args)){args="0n+"+args}else{if(args=="even"){args="2n"}else{if(args=="odd"){args="2n+1"}}}args=args.split("n");var a=args[0]?(args[0]=="-")?-1:parseInt(args[0]):1;var b=parseInt(args[1])||0;var negate=a<0;if(negate){a=-a;if(a==1){b++}}var query=format(a==0?"%3%7"+(last+b):"(%4%3-%2)%6%1%70%5%4%3>=%2",a,b,position,last,and,mod,equals);if(negate){query=not+"("+query+")"}return query}var XPathParser=CSSParser.extend({constructor:function(){this.base(XPathParser.rules);this.sorter.putAt(1,"$1$4$3$6")},escape:function(selector){return this.base(selector).replace(/,/g,"\x02")},unescape:function(selector){return this.base(selector.replace(/\[self::\*\]/g,"").replace(/(^|\x02)\//g,"$1./").replace(/\x02/g," | ")).replace(/'[^'\\]*\\'(\\.|[^'\\])*'/g,function(match){return"concat("+match.split("\\'").join("',\"'\",'")+")"})},"@opera":{unescape:function(selector){return this.base(selector.replace(/last\(\)/g,"count(preceding-sibling::*)+count(following-sibling::*)+1"))}}},{init:function(){this.values.attributes[""]="[@$1]";forEach(this.types,function(add,type){forEach(this.values[type],add,this.rules)},this)},optimised:{pseudoClasses:{"first-child":"[1]","last-child":"[last()]","only-child":"[last()=1]"}},rules:extend({},{"@!KHTML":{"(^|\\x02) (\\*|[\\w-]+)#([\\w-]+)":"$1id('$3')[self::$2]","([ >])(\\*|[\\w-]+):([\\w-]+-child(\\(([^)]+)\\))?)":function(match,token,tagName,pseudoClass,$4,args){var replacement=(token==" ")?"//*":"/*";if(/^nth/i.test(pseudoClass)){replacement+=_xpath_nthChild(pseudoClass,args,"position()")}else{replacement+=XPathParser.optimised.pseudoClasses[pseudoClass]}return replacement+"[self::"+tagName+"]"}}}),types:{identifiers:function(replacement,token){this[rescape(token)+"([\\w-]+)"]=replacement},combinators:function(replacement,combinator){this[rescape(combinator)+"(\\*|[\\w-]+)"]=replacement},attributes:function(replacement,operator){this["\\[([\\w-]+)\\s*"+rescape(operator)+"\\s*([^\\]]*)\\]"]=replacement},pseudoClasses:function(replacement,pseudoClass){this[":"+pseudoClass.replace(/\(\)$/,"\\(([^)]+)\\)")]=replacement}},values:{identifiers:{"#":"[@id='$1'][1]",".":"[contains(concat(' ',@class,' '),' $1 ')]"},combinators:{" ":"/descendant::$1",">":"/child::$1","+":"/following-sibling::*[1][self::$1]","~":"/following-sibling::$1"},attributes:{"*=":"[contains(@$1,'$2')]","^=":"[starts-with(@$1,'$2')]","$=":"[substring(@$1,string-length(@$1)-string-length('$2')+1)='$2']","~=":"[contains(concat(' ',@$1,' '),' $2 ')]","|=":"[contains(concat('-',@$1,'-'),'-$2-')]","!=":"[not(@$1='$2')]","=":"[@$1='$2']"},pseudoClasses:{"empty":"[not(child::*) and not(text())]","first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","not()":_xpath_not,"nth-child()":_xpath_nthChild,"nth-last-child()":_xpath_nthChild,"only-child":"[not(preceding-sibling::*) and not(following-sibling::*)]","root":"[not(parent::*)]"}},"@opera":{init:function(){this.optimised.pseudoClasses["last-child"]=this.values.pseudoClasses["last-child"];this.optimised.pseudoClasses["only-child"]=this.values.pseudoClasses["only-child"];this.base()}}});var _notParser=new XPathParser;function _xpath_not(match,args){return"[not("+_notParser.exec(trim(args)).replace(/\[1\]/g,"").replace(/^(\*|[\w-]+)/,"[self::$1]").replace(/\]\[/g," and ").slice(1,-1)+")]"}function _xpath_nthChild(match,args,position){return"["+_nthChild(match,args,position||"count(preceding-sibling::*)+1","last()","not"," and "," mod ","=")+"]"}var Selector=Base.extend({constructor:function(selector){this.toString=K(trim(selector))},exec:function(context,single){return Selector.parse(this)(context,single)},test:function(element){var selector=new Selector(this+"[b2-test]");element.setAttribute("b2-test",true);var result=selector.exec(Traversal.getOwnerDocument(element),true);element.removeAttribute("b2-test");return result==element},toXPath:function(){return Selector.toXPath(this)},"@(XPathResult)":{exec:function(context,single){if(_NOT_XPATH.test(this)){return this.base(context,single)}var document=Traversal.getDocument(context);var type=single?9:7;var result=document.evaluate(this.toXPath(),context,null,type,null);return single?result.singleNodeValue:result}},"@MSIE":{exec:function(context,single){if(typeof context.selectNodes!="undefined"&&!_NOT_XPATH.test(this)){var method=single?"selectSingleNode":"selectNodes";return context[method](this.toXPath())}return this.base(context,single)}},"@(true)":{exec:function(context,single){try{var result=this.base(context||document,single)}catch(error){throw new SyntaxError(format("'%1' is not a valid CSS selector.",this))}return single?result:new StaticNodeList(result)}}},{toXPath:function(selector){if(!_xpathParser){_xpathParser=new XPathParser}return _xpathParser.parse(selector)}});var _NOT_XPATH=":(checked|disabled|enabled|contains)|^(#[\\w-]+\\s*)?\\w+$";if(detect("KHTML")){if(detect("WebKit5")){_NOT_XPATH+="|nth\\-|,"}else{_NOT_XPATH="."}}_NOT_XPATH=new RegExp(_NOT_XPATH);var _OPERATORS={"=":"%1=='%2'","!=":"%1!='%2'","~=":/(^| )%1( |$)/,"|=":/^%1(-|$)/,"^=":/^%1/,"$=":/%1$/,"*=":/%1/};_OPERATORS[""]="%1!=null";var _PSEUDO_CLASSES={"checked":"e%1.checked","contains":"e%1[TEXT].indexOf('%2')!=-1","disabled":"e%1.disabled","empty":"Traversal.isEmpty(e%1)","enabled":"e%1.disabled===false","first-child":"!Traversal.getPreviousElementSibling(e%1)","last-child":"!Traversal.getNextElementSibling(e%1)","only-child":"!Traversal.getPreviousElementSibling(e%1)&&!Traversal.getNextElementSibling(e%1)","root":"e%1==Traversal.getDocument(e%1).documentElement"};var _INDEXED=detect("(element.sourceIndex)");var _VAR="var p%2=0,i%2,e%2,n%2=e%1.";var _ID=_INDEXED?"e%1.sourceIndex":"assignID(e%1)";var _TEST="var g="+_ID+";if(!p[g]){p[g]=1;";var _STORE="r[r.length]=e%1;if(s)return e%1;";var _FN="var _selectorFunction=function(e0,s){_indexed++;var r=[],p={},reg=[%1],d=Traversal.getDocument(e0),c=d.body?'toUpperCase':'toString';";var _xpathParser;var _reg;var _index;var _wild;var _list;var _duplicate;var _cache={};var _parser=new CSSParser({"^ \\*:root":function(match){_wild=false;var replacement="e%2=d.documentElement;if(Traversal.contains(e%1,e%2)){";return format(replacement,_index++,_index)}," (\\*|[\\w-]+)#([\\w-]+)":function(match,tagName,id){_wild=false;var replacement="var e%2=_byId(d,'%4');if(e%2&&";if(tagName!="*"){replacement+="e%2.nodeName=='%3'[c]()&&"}replacement+="Traversal.contains(e%1,e%2)){";if(_list){replacement+=format("i%1=n%1.length;",_list)}return format(replacement,_index++,_index,tagName,id)}," (\\*|[\\w-]+)":function(match,tagName){_duplicate++;_wild=tagName=="*";var replacement=_VAR;replacement+=(_wild&&_MSIE5)?"all":"getElementsByTagName('%3')";replacement+=";for(i%2=0;(e%2=n%2[i%2]);i%2++){";return format(replacement,_index++,_list=_index,tagName)},">(\\*|[\\w-]+)":function(match,tagName){var children=_MSIE&&_list;_wild=tagName=="*";var replacement=_VAR;replacement+=children?"children":"childNodes";if(!_wild&&children){replacement+=".tags('%3')"}replacement+=";for(i%2=0;(e%2=n%2[i%2]);i%2++){";if(_wild){replacement+="if(e%2.nodeType==1){";_wild=_MSIE5}else{if(!children){replacement+="if(e%2.nodeName=='%3'[c]()){"}}return format(replacement,_index++,_list=_index,tagName)},"\\+(\\*|[\\w-]+)":function(match,tagName){var replacement="";if(_wild&&_MSIE){replacement+="if(e%1.nodeName!='!'){"}_wild=false;replacement+="e%1=Traversal.getNextElementSibling(e%1);if(e%1";if(tagName!="*"){replacement+="&&e%1.nodeName=='%2'[c]()"}replacement+="){";return format(replacement,_index,tagName)},"~(\\*|[\\w-]+)":function(match,tagName){var replacement="";if(_wild&&_MSIE){replacement+="if(e%1.nodeName!='!'){"}_wild=false;_duplicate=2;replacement+="while(e%1=e%1.nextSibling){if(e%1.b2_adjacent==_indexed)break;if(";if(tagName=="*"){replacement+="e%1.nodeType==1";if(_MSIE5){replacement+="&&e%1.nodeName!='!'"}}else{replacement+="e%1.nodeName=='%2'[c]()"}replacement+="){e%1.b2_adjacent=_indexed;";return format(replacement,_index,tagName)},"#([\\w-]+)":function(match,id){_wild=false;var replacement="if(e%1.id=='%2'){";if(_list){replacement+=format("i%1=n%1.length;",_list)}return format(replacement,_index,id)},"\\.([\\w-]+)":function(match,className){_wild=false;_reg.push(new RegExp("(^|\\s)"+rescape(className)+"(\\s|$)"));return format("if(e%1.className&&reg[%2].test(e%1.className)){",_index,_reg.length-1)},":not\\((\\*|[\\w-]+)?([^)]*)\\)":function(match,tagName,filters){var replacement=(tagName&&tagName!="*")?format("if(e%1.nodeName=='%2'[c]()){",_index,tagName):"";replacement+=_parser.exec(filters);return"if(!"+replacement.slice(2,-1).replace(/\)\{if\(/g,"&&")+"){"},":nth(-last)?-child\\(([^)]+)\\)":function(match,last,args){_wild=false;last=format("e%1.parentNode.b2_length",_index);var replacement="if(p%1!==e%1.parentNode)p%1=_register(e%1.parentNode);";replacement+="var i=e%1[p%1.b2_lookup];if(p%1.b2_lookup!='b2_index')i++;if(";return format(replacement,_index)+_nthChild(match,args,"i",last,"!","&&","%","==")+"){"},":([\\w-]+)(\\(([^)]+)\\))?":function(match,pseudoClass,$2,args){return"if("+format(_PSEUDO_CLASSES[pseudoClass]||"throw",_index,args||"")+"){"},"\\[([\\w-]+)\\s*([^=]?=)?\\s*([^\\]]*)\\]":function(match,attr,operator,value){var alias=_ATTRIBUTES[attr]||attr;if(operator){var getAttribute="e%1.getAttribute('%2',2)";if(!_EVALUATED.test(attr)){getAttribute="e%1.%3||"+getAttribute}attr=format("("+getAttribute+")",_index,attr,alias)}else{attr=format("Element.getAttribute(e%1,'%2')",_index,attr)}var replacement=_OPERATORS[operator||""];if(instanceOf(replacement,RegExp)){_reg.push(new RegExp(format(replacement.source,rescape(_parser.unescape(value)))));replacement="reg[%2].test(%1)";value=_reg.length-1}return"if("+format(replacement,attr,value)+"){"}});new function(_){var _byId=_MSIE?function(document,id){var result=document.all[id]||null;if(!result||result.id==id){return result}for(var i=0;i<result.length;i++){if(result[i].id==id){return result[i]}}return null}:function(document,id){return document.getElementById(id)};var _indexed=1;function _register(element){if(element.rows){element.b2_length=element.rows.length;element.b2_lookup="rowIndex"}else{if(element.cells){element.b2_length=element.cells.length;element.b2_lookup="cellIndex"}else{if(element.b2_indexed!=_indexed){var index=0;var child=element.firstChild;while(child){if(child.nodeType==1&&child.nodeName!="!"){child.b2_index=++index}child=child.nextSibling}element.b2_length=index;element.b2_lookup="b2_index"}}}element.b2_indexed=_indexed;return element}Selector.parse=function(selector){if(!_cache[selector]){_reg=[];var fn="";var selectors=_parser.escape(selector).split(",");for(var i=0;i<selectors.length;i++){_wild=_index=_list=0;_duplicate=selectors.length>1?2:0;var block=_parser.exec(selectors[i])||"throw;";if(_wild&&_MSIE){block+=format("if(e%1.nodeName!='!'){",_index)}var store=(_duplicate>1)?_TEST:"";block+=format(store+_STORE,_index);block+=Array(match(block,/\{/g).length+1).join("}");fn+=block}eval(format(_FN,_reg)+_parser.unescape(fn)+"return s?null:r}");_cache[selector]=_selectorFunction}return _cache[selector]}};Document.implement(DocumentSelector);Element.implement(ElementSelector);var HTMLDocument=Document.extend(null,{"@(document.activeElement===undefined)":{bind:function(document){document.activeElement=null;EventTarget.addEventListener(document,"focus",function(event){document.activeElement=event.target},false);return this.base(document)}}});var HTMLElement=Element.extend({addClass:function(element,className){if(!this.hasClass(element,className)){element.className+=(element.className?" ":"")+className}},hasClass:function(element,className){var regexp=new RegExp("(^|\\s)"+className+"(\\s|$)");return regexp.test(element.className)},removeClass:function(element,className){var regexp=new RegExp("(^|\\s)"+className+"(\\s|$)","g");element.className=trim(element.className.replace(regexp,"$2"))},toggleClass:function(element,className){if(this.hasClass(element,className)){this.removeClass(element,className)}else{this.addClass(element,className)}}},{bindings:{},tags:"*",bind:function(element){CSSStyleDeclaration.bind(element.style);return this.base(element)},extend:function(){var binding=base(this,arguments);var tags=(binding.tags||"").toUpperCase().split(",");forEach(tags,function(tagName){HTMLElement.bindings[tagName]=binding});return binding},"@!(element.ownerDocument)":{bind:function(element){element.ownerDocument=Traversal.getOwnerDocument(element);return this.base(element)}}});HTMLElement.extend(null,{tags:"APPLET,EMBED",bind:I});eval(this.exports)};if(navigator.appVersion.search(/Safari/)!=-1){NodeList.prototype.forEach=function(B,A){for(var C=0;C<this.length;C++){B.call(A,this.item(C),C,this)}}}if(typeof (base2)=="undefined"){throw new Error("Base2 not found. wForms 3.0 depends on the base2 library.")}if(typeof (wFORMS)=="undefined"){wFORMS={}}wFORMS.NAME="wFORMS";wFORMS.VERSION="3.1";wFORMS.__repr__=function(){return"["+this.NAME+" "+this.VERSION+"]"};wFORMS.toString=function(){return this.__repr__()};wFORMS.behaviors={};wFORMS.helpers={};wFORMS.instances=[];wFORMS.helpers.randomId=function(){var A=(new Date()).getTime();A=A.toString().substr(6);for(var B=0;B<6;B++){A+=String.fromCharCode(48+Math.floor((Math.random()*10)))}return"id_"+A};wFORMS.helpers.getFieldValue=function(C){switch(C.tagName){case"INPUT":if(C.type=="checkbox"){return C.checked?C.value:null}if(C.type=="radio"){return C.checked?C.value:null}return C.value;break;case"SELECT":if(C.selectedIndex==-1){return null}if(C.getAttribute("multiple")){var A=[];for(var B=0;B<C.options.length;B++){if(C.options[B].selected){A.push(C.options[B].value)}}return A}return C.options[C.selectedIndex].value;break;case"TEXTAREA":return C.value;break;default:return null;break}};wFORMS.helpers.getComputedStyle=function(B,A){return document.defaultView.getComputedStyle(B,"").getPropertyValue(A)};wFORMS.helpers.getForm=function(A){if(A.form){return A.form}else{if(A.parentNode){if(A.parentNode.tagName.toLowerCase()=="form"){return A.parentNode}else{return this.getForm(A.parentNode)}}else{return null}}};wFORMS.helpers.getLeft=function(B){var C=0;while(B.offsetParent){try{if(document.defaultView.getComputedStyle(B,"").getPropertyValue("position")=="relative"){return C}if(C>0&&document.defaultView.getComputedStyle(B,"").getPropertyValue("position")=="absolute"){return C}}catch(A){}C+=B.offsetLeft;B=B.offsetParent}if(!window.opera&&document.all&&document.compatMode&&document.compatMode!="BackCompat"){C+=parseInt(document.body.currentStyle.marginTop)}return C};wFORMS.helpers.getTop=function(B){var C=0;while(B.offsetParent){try{if(document.defaultView.getComputedStyle(B,"").getPropertyValue("position")=="relative"){return C}if(C>0&&document.defaultView.getComputedStyle(B,"").getPropertyValue("position")=="absolute"){return C}}catch(A){}C+=B.offsetTop;B=B.offsetParent}if(!window.opera&&document.all&&document.compatMode&&document.compatMode!="BackCompat"){C+=parseInt(document.body.currentStyle.marginLeft)+1}return C};wFORMS.helpers.position=function(B){var A=B.offsetLeft;var D=B.offsetTop;if(B.offsetParent){var C=this.position(B.offsetParent);A+=C.left;D+=C.top}return{left:A,top:D}};wFORMS.helpers.useSpotlight=false;wFORMS.helpers.spotlight=function(A){};wFORMS.helpers.activateStylesheet=function(C){if(document.getElementsByTagName){var B=document.getElementsByTagName("link")}else{if(document.styleSheets){var B=document.styleSheets}}for(var A=0;B[A];A++){if(B[A].href.indexOf(C)!=-1){B[A].disabled=true;B[A].disabled=false}}};wFORMS.helpers.contains=function(D,C){var A=D.length;for(var B=0;B<A;B++){if(D[B]===C){return true}}return false};wFORMS.onLoadHandler=function(){var A=document.getElementsByTagName("FORM");for(var B=0;B<A.length;B++){if(A[B].getAttribute("rel")!="no-behavior"){wFORMS.applyBehaviors(A[B])}}};wFORMS.standardizeElement=function(A){if(!A.addEventListener){A.addEventListener=function(C,B,D){base2.DOM.Element.addEventListener(this,C,B,D)}}if(!A.hasClass){A.hasClass=function(B){return base2.DOM.HTMLElement.hasClass(this,B)}}if(!A.removeClass){A.removeClass=function(B){return base2.DOM.HTMLElement.removeClass(this,B)}}if(!A.addClass){A.addClass=function(B){return base2.DOM.HTMLElement.addClass(this,B)}}};wFORMS.applyBehaviors=function(D){if(!D.querySelectorAll){base2.DOM.bind(D)}if(wFORMS.behaviors["switch"]){var A=wFORMS.behaviors["switch"].applyTo(D);if(!wFORMS.instances["switch"]){wFORMS.instances["switch"]=[A]}else{wFORMS.removeBehavior(D,"switch");wFORMS.instances["switch"].push(A)}}for(var B in wFORMS.behaviors){if(B=="switch"){continue}if(wFORMS.behaviors[B].applyTo){var A=wFORMS.behaviors[B].applyTo(D);if(A&&A.constructor!=Array){A=[A]}for(var C=0;A&&C<A.length;C++){if(!wFORMS.instances[B]){wFORMS.instances[B]=[A[C]]}else{wFORMS.removeBehavior(D,B);wFORMS.instances[B].push(A[C])}}}}if(wFORMS.behaviors.onApplyAll){wFORMS.behaviors.onApplyAll(D)}};wFORMS.removeBehavior=function(C,A){return null;if(!wFORMS.instances[A]){return null}for(var B=0;B<wFORMS.instances[A].length;B++){if(wFORMS.instances[A][B].target==C){wFORMS.instances[A][B]=null}}return null};wFORMS.getBehaviorInstance=function(C,A){if(!C||!wFORMS.instances[A]){return null}for(var B=0;B<wFORMS.instances[A].length;B++){if(wFORMS.instances[A][B].target==C){return wFORMS.instances[A][B]}}return null};base2.DOM.Element.addEventListener(document,"DOMContentLoaded",wFORMS.onLoadHandler,false);wFORMS.helpers.activateStylesheet("wforms-jsonly.css");if(typeof (wFORMS)=="undefined"){throw new Error("wFORMS core not found. This behavior depends on the wFORMS core.")}wFORMS.behaviors.hint={CSS_INACTIVE:"field-hint-inactive",CSS_ACTIVE:"field-hint",HINT_SELECTOR:'*[id$="-H"]',HINT_SUFFIX:"-H",instance:function(A){this.behavior=wFORMS.behaviors.hint;this.target=A}};wFORMS.behaviors.hint.applyTo=function(B){var A=new wFORMS.behaviors.hint.instance(B);B.querySelectorAll(wFORMS.behaviors.hint.HINT_SELECTOR).forEach(function(C){var D=A.getElementByHintId(C.id);if(D){if(!D.addEventListener){base2.DOM.bind(D)}if(D.tagName=="SELECT"||D.tagName=="TEXTAREA"||(D.tagName=="INPUT"&&D.type!="radio"&&D.type!="checkbox")){D.addEventListener("focus",function(E){A.run(E,this)},false);D.addEventListener("blur",function(E){A.run(E,this)},false)}else{D.addEventListener("mouseover",function(E){A.run(E,D)},false);D.addEventListener("mouseout",function(E){A.run(E,D)},false)}}});A.onApply();return A};wFORMS.behaviors.hint.instance.prototype.onApply=function(){};wFORMS.behaviors.hint.instance.prototype.run=function(B,A){var C=this.getHintElement(A);if(!C){return }if(B.type=="focus"||B.type=="mouseover"){C.removeClass(wFORMS.behaviors.hint.CSS_INACTIVE);C.addClass(wFORMS.behaviors.hint.CSS_ACTIVE);if(!wFORMS.helpers.getForm(A).hasClass("hintsSide")){this.setup(C,A)}}else{C.addClass(wFORMS.behaviors.hint.CSS_INACTIVE);C.removeClass(wFORMS.behaviors.hint.CSS_ACTIVE)}};wFORMS.behaviors.hint.instance.prototype.getElementByHintId=function(C){var B=C.substr(0,C.length-wFORMS.behaviors.hint.HINT_SUFFIX.length);var A=document.getElementById(B);return A};wFORMS.behaviors.hint.instance.prototype.getHintElement=function(A){var B=document.getElementById(A.id+this.behavior.HINT_SUFFIX);if(B&&!B.hasClass){base2.DOM.bind(B)}return B&&B!=""?B:null};wFORMS.behaviors.hint.instance.prototype.setup=function(F,E){var B=wFORMS.helpers.getForm(E);if(F.parentNode!=B){B.appendChild(F)}var A=wFORMS.helpers.position(E);var C=wFORMS.helpers.position(F);var D={left:A.left-C.left,top:A.top-C.top};if(E.tagName.toLowerCase()=="select"){F.style.left=F.offsetLeft+D.left+E.offsetWidth+"px";F.style.top=F.offsetTop+D.top+"px"}else{F.style.left=F.offsetLeft+D.left+"px";F.style.top=F.offsetTop+D.top+E.offsetHeight+"px"}};wFORMS.behaviors.hint.isHintId=function(A){return A.match(new RegExp(wFORMS.behaviors.hint.HINT_SUFFIX+"$"))!=null};if(typeof (wFORMS)=="undefined"){throw new Error("wFORMS core not found. This behavior depends on the wFORMS core.")}wFORMS.behaviors.paging={SELECTOR:".wfPage",CSS_PAGE:"wfPage",CSS_CURRENT_PAGE:"wfCurrentPage",CSS_BUTTON_NEXT:"wfPageNextButton",CSS_BUTTON_PREVIOUS:"wfPagePreviousButton",CSS_BUTTON_PLACEHOLDER:"wfPagingButtons",ID_BUTTON_NEXT_PREFIX:"wfPageNextId",ID_BUTTON_PREVIOUS_PREFIX:"wfPagePreviousId",CSS_SUBMIT_HIDDEN:"wfHideSubmit",ID_PAGE_PREFIX:"wfPgIndex-",ID_PLACEHOLDER_SUFFIX:"-buttons",ATTR_INDEX:"wfPageIndex_activate",MESSAGES:{CAPTION_NEXT:"Next Page",CAPTION_PREVIOUS:"Previous Page"},runValidationOnPageNext:true,onPageNext:function(){},onPagePrevious:function(){},onPageChange:function(){},instance:function(A){this.behavior=wFORMS.behaviors.paging;this.target=A;this.currentPageIndex=1}};wFORMS.behaviors.paging.applyTo=function(E){var B=new wFORMS.behaviors.paging.instance(E);var D=wFORMS.behaviors.paging;var C=(wFORMS.behaviors.validation&&wFORMS.behaviors.paging.runValidationOnPageNext);var A=false;E.querySelectorAll(wFORMS.behaviors.paging.SELECTOR).forEach(function(H){A=true;var L=B.getOrCreatePlaceHolder(H);var F=wFORMS.behaviors.paging.getPageIndex(H);if(F==1){var J=base2.DOM.bind(L.appendChild(D._createNextPageButton(F)));if(C){J.addEventListener("click",function(N){var M=wFORMS.getBehaviorInstance(B.target,"validation");if(M.run(N,H)){B.run(N,J)}},false)}else{J.addEventListener("click",function(M){B.run(M,J)},false)}wFORMS.behaviors.paging.showPage(H)}else{var J=base2.DOM.bind(D._createPreviousPageButton(F));L.insertBefore(J,L.firstChild);J.addEventListener("click",function(M){B.run(M,J)},false);if(!wFORMS.behaviors.paging.isLastPageIndex(F,true)){var G=base2.DOM.bind(L.appendChild(D._createNextPageButton(F)));if(C){G.addEventListener("click",function(N){var M=wFORMS.getBehaviorInstance(B.target,"validation");if(M.run(N,H)){B.run(N,G)}},false)}else{G.addEventListener("click",function(M){B.run(M,G)},false)}}}});if(A){p=B.findNextPage(0);B.currentPageIndex=0;B.activatePage(wFORMS.behaviors.paging.getPageIndex(p),false);B.onApply()}base2.DOM.Element.addEventListener(E,"submit",function(F){B.onSubmit(F,B)});return B};wFORMS.behaviors.paging.instance.prototype.onApply=function(){};wFORMS.behaviors.paging.instance.prototype.onSubmit=function(E,A){if(!wFORMS.behaviors.paging.isLastPageIndex(A.currentPageIndex)){var D=wFORMS.behaviors.paging.getPageByIndex(A.currentPageIndex);var B=A.findNextPage(A.currentPageIndex);var C=wFORMS.getBehaviorInstance(A.target,"validation");if(C.run(E,D)){A.activatePage(A.currentPageIndex+1);var F=base2.DOM.Element.querySelector(B,"input, textarea, select");if(F){F.focus()}}E.stopPropagation();E.preventDefault();E.pagingStopPropagation=true}};wFORMS.behaviors.paging.getPageIndex=function(B){if(B&&B.id){var A=B.id.replace(new RegExp(wFORMS.behaviors.paging.ID_PAGE_PREFIX+"(\\d+)"),"$1");A=parseInt(A);return !isNaN(A)?A:false}return false};wFORMS.behaviors.paging.isElementVisible=function(A){while(A&&A.tagName!="BODY"){if(A.className){if(A.className.indexOf(this.CSS_CURRENT_PAGE)!=-1){return true}if(A.className.indexOf(this.CSS_PAGE)!=-1){return false}}A=A.parentNode}return true};wFORMS.behaviors.paging._createNextPageButton=function(A){var B=this.createNextPageButton();B.setAttribute(this.ATTR_INDEX,A+1);B.id=this.ID_BUTTON_NEXT_PREFIX+A;return B};wFORMS.behaviors.paging.createNextPageButton=function(){var A=document.createElement("input");A.setAttribute("value",this.MESSAGES.CAPTION_NEXT);A.type="button";A.className=this.CSS_BUTTON_NEXT;return A};wFORMS.behaviors.paging._createPreviousPageButton=function(A){var B=this.createPreviousPageButton();B.setAttribute(this.ATTR_INDEX,A-1);B.id=this.ID_BUTTON_PREVIOUS_PREFIX+A;return B};wFORMS.behaviors.paging.createPreviousPageButton=function(){var A=document.createElement("input");A.setAttribute("value",this.MESSAGES.CAPTION_PREVIOUS);A.type="button";A.className=this.CSS_BUTTON_PREVIOUS;return A};wFORMS.behaviors.paging.instance.prototype.getOrCreatePlaceHolder=function(A){var C=A.id+this.behavior.ID_PLACEHOLDER_SUFFIX;var B=document.getElementById(C);if(!B){B=A.appendChild(document.createElement("div"));B.id=C;B.className=this.behavior.CSS_BUTTON_PLACEHOLDER}return B};wFORMS.behaviors.paging.hidePage=function(A){if(A){if(!A.removeClass){A.removeClass=function(B){return base2.DOM.HTMLElement.removeClass(this,B)}}if(!A.addClass){A.addClass=function(B){return base2.DOM.HTMLElement.addClass(this,B)}}A.removeClass(wFORMS.behaviors.paging.CSS_CURRENT_PAGE);A.addClass(wFORMS.behaviors.paging.CSS_PAGE)}};wFORMS.behaviors.paging.showPage=function(A){if(A){if(!A.removeClass){A.removeClass=function(B){return base2.DOM.HTMLElement.removeClass(this,B)}}A.removeClass(wFORMS.behaviors.paging.CSS_PAGE);if(!A.addClass){A.addClass=function(B){return base2.DOM.HTMLElement.addClass(this,B)}}A.addClass(wFORMS.behaviors.paging.CSS_CURRENT_PAGE)}};wFORMS.behaviors.paging.instance.prototype.activatePage=function(B){if(arguments.length>1){var E=arguments[1]}else{var E=true}if(B==this.currentPageIndex){return false}B=parseInt(B);if(B>this.currentPageIndex){var C=this.findNextPage(this.currentPageIndex)}else{var C=this.findPreviousPage(this.currentPageIndex)}if(C){var A=this;var B=A.behavior.getPageIndex(C);A.setupManagedControls(B);A.behavior.hidePage(A.behavior.getPageByIndex(A.currentPageIndex));A.behavior.showPage(C);var D=A.currentPageIndex;A.currentPageIndex=B;if(E){if(C.scrollIntoView){C.scrollIntoView()}else{location.hash="#"+wFORMS.behaviors.paging.ID_PAGE_PREFIX+B}}A.behavior.onPageChange(C);if(B>D){A.behavior.onPageNext(C)}else{A.behavior.onPagePrevious(C)}}};wFORMS.behaviors.paging.instance.prototype.setupManagedControls=function(B){if(!B){B=this.currentPageIndex}var A=wFORMS.behaviors.paging;if(A.isFirstPageIndex(B)){if(ctrl=A.getPreviousButton(B)){ctrl.style.visibility="hidden"}}else{if(ctrl=A.getPreviousButton(B)){ctrl.style.visibility="visible"}}if(A.isLastPageIndex(B)){if(ctrl=A.getNextButton(B)){ctrl.style.visibility="hidden"}this.showSubmitButtons()}else{if(ctrl=A.getNextButton(B)){ctrl.style.visibility="visible"}this.hideSubmitButtons()}};wFORMS.behaviors.paging.instance.prototype.showSubmitButtons=function(){var A=this.target.getElementsByTagName("input");for(var B=0;B<A.length;B++){if(A[B].type=="submit"){A[B].className=A[B].className.replace(new RegExp("(^|\\s)"+this.behavior.CSS_SUBMIT_HIDDEN+"(\\s|$)","g"),"$2")}}};wFORMS.behaviors.paging.instance.prototype.hideSubmitButtons=function(){var A=this.target.getElementsByTagName("input");for(var B=0;B<A.length;B++){if(A[B].type=="submit"){if(!(new RegExp("(^|\\s)"+this.behavior.CSS_SUBMIT_HIDDEN+"(\\s|$)")).test(A[B].className)){A[B].className+=" "+this.behavior.CSS_SUBMIT_HIDDEN}}}};wFORMS.behaviors.paging.getPageByIndex=function(A){var B=document.getElementById(wFORMS.behaviors.paging.ID_PAGE_PREFIX+A);return B?base2.DOM.bind(B):false};wFORMS.behaviors.paging.getNextButton=function(A){return document.getElementById(wFORMS.behaviors.paging.ID_BUTTON_NEXT_PREFIX+A)};wFORMS.behaviors.paging.getPreviousButton=function(A){return document.getElementById(wFORMS.behaviors.paging.ID_BUTTON_PREVIOUS_PREFIX+A)};wFORMS.behaviors.paging.isLastPageIndex=function(C,B){C=parseInt(C)+1;var A=wFORMS.behaviors.paging;var D=A.getPageByIndex(C);if((_b=wFORMS.behaviors["switch"])&&!B){while(D&&_b.isSwitchedOff(D)){C++;D=A.getPageByIndex(C)}}return D?false:true};wFORMS.behaviors.paging.isFirstPageIndex=function(C,B){C=parseInt(C)-1;var A=wFORMS.behaviors.paging;var D=A.getPageByIndex(C);if((_b=wFORMS.behaviors["switch"])&&!B){while(D&&_b.isSwitchedOff(D)){C--;D=A.getPageByIndex(C)}}return D?false:true};wFORMS.behaviors.paging.instance.prototype.findNextPage=function(B){B=parseInt(B)+1;var A=wFORMS.behaviors.paging;var C=A.getPageByIndex(B);if(_b=wFORMS.behaviors["switch"]){while(C&&_b.isSwitchedOff(C)){B++;C=A.getPageByIndex(B)}}return C};wFORMS.behaviors.paging.instance.prototype.findPreviousPage=function(B){B=parseInt(B)-1;var A=wFORMS.behaviors.paging;var C=A.getPageByIndex(B);if(_b=wFORMS.behaviors["switch"]){while(C&&_b.isSwitchedOff(C)){B--;C=A.getPageByIndex(B)}}return C?C:false};wFORMS.behaviors.paging.instance.prototype.run=function(B,A){this.activatePage(A.getAttribute(wFORMS.behaviors.paging.ATTR_INDEX))};if(typeof (wFORMS)=="undefined"){throw new Error("wFORMS core not found. This behavior depends on the wFORMS core.")}wFORMS.behaviors.repeat={SELECTOR_REPEAT:'*[class~="repeat"]',SELECTOR_REMOVEABLE:'*[class~="removeable"]',ID_SUFFIX_DUPLICATE_LINK:"-wfDL",ID_SUFFIX_COUNTER:"-RC",CSS_DUPLICATE_LINK:"duplicateLink",CSS_DUPLICATE_SPAN:"duplicateSpan",CSS_DELETE_LINK:"removeLink",CSS_DELETE_SPAN:"removeSpan",CSS_REMOVEABLE:"removeable",CSS_REPEATABLE:"repeat",ATTR_DUPLICATE:"wfr__dup",ATTR_DUPLICATE_ELEM:"wfr__dup_elem",ATTR_HANDLED:"wfr_handled",ATTR_MASTER_SECTION:"wfr__master_sec",ATTR_LINK_SECTION_ID:"wfr_sec_id",MESSAGES:{ADD_CAPTION:"Add another response",ADD_TITLE:"Will duplicate this question or section.",REMOVE_CAPTION:"Remove",REMOVE_TITLE:"Will remove this question or section"},UPDATEABLE_ATTR_ARRAY:["id","name","for"],preserveRadioName:false,CSS_PRESERVE_RADIO_NAME:"preserveRadioName",onRepeat:function(A){},onRemove:function(A){},allowRepeat:function(B,A){return true},instance:function(A){this.behavior=wFORMS.behaviors.repeat;this.target=A}};var _b=wFORMS.behaviors.repeat;var _i=wFORMS.behaviors.repeat.instance;_b.applyTo=function(F){var C=this;var B=new Array();if(!F.querySelectorAll){base2.DOM.bind(F)}F.querySelectorAll(this.SELECTOR_REPEAT).forEach(function(H){if(C.isHandled(H)){return }if(!H.id){H.id=wFORMS.helpers.randomId()}var G=new C.instance(H);var J=G.getOrCreateRepeatLink(H);J.addEventListener("click",function(L){G.run(L,J)},false);G.setElementHandled(H);B.push(G)});if(!F.hasClass){F=base2.DOM.bind(F)}if(F.hasClass(this.CSS_REMOVEABLE)){var A=this.getMasterSection(F);var E=wFORMS.getBehaviorInstance(A,"repeat");if(E){E.getOrCreateRemoveLink(F)}else{if(B[0]){B[0].getOrCreateRemoveLink(F)}}}F.querySelectorAll(this.SELECTOR_REMOVEABLE).forEach(function(J){var G=wFORMS.behaviors.repeat.getMasterSection(J);var H=wFORMS.getBehaviorInstance(G,"repeat");if(H){H.getOrCreateRemoveLink(J)}else{if(B[0]){B[0].getOrCreateRemoveLink(J)}}});for(var D=0;D<B.length;D++){B[D].onApply()}return B};_i.prototype.onApply=function(){};_i.prototype.getOrCreateRepeatLink=function(C){var E=C.id+this.behavior.ID_SUFFIX_DUPLICATE_LINK;var D=document.getElementById(E);if(!D||D==""){D=this.createRepeatLink(E);var A=document.createElement("span");A.className=this.behavior.CSS_DUPLICATE_SPAN;D=A.appendChild(D);if(C.tagName.toUpperCase()=="TR"){var B=C.getElementsByTagName("TD");if(!B){B=C.appendChild(document.createElement("TD"))}else{B=B[B.length-1]}B.appendChild(A)}else{C.appendChild(A)}}return base2.DOM.bind(D)};_i.prototype.createRepeatLink=function(B){var A=document.createElement("A");A.id=B;A.setAttribute("href","#");A.className=this.behavior.CSS_DUPLICATE_LINK;A.setAttribute("title",this.behavior.MESSAGES.ADD_TITLE);A.appendChild(document.createElement("span").appendChild(document.createTextNode(this.behavior.MESSAGES.ADD_CAPTION)));return A};_i.prototype.getOrCreateRemoveLink=function(C){var D=this.createRemoveLink(C.id);if(C.tagName=="TR"){var B=C.getElementsByTagName("TD");var A=B[B.length-1];A.appendChild(D)}else{C.appendChild(D)}};_i.prototype.createRemoveLink=function(D){var B=document.createElement("a");B.id=D+this.behavior.ID_SUFFIX_DUPLICATE_LINK;B.setAttribute("href","#");B.className=this.behavior.CSS_DELETE_LINK;B.setAttribute("title",this.behavior.MESSAGES.REMOVE_TITLE);B.setAttribute(this.behavior.ATTR_LINK_SECTION_ID,D);var C=document.createElement("span");C.appendChild(document.createTextNode(this.behavior.MESSAGES.REMOVE_CAPTION));B.appendChild(C);var A=this;B.onclick=function(E){A.onRemoveLinkClick(E,B)};var C=document.createElement("span");C.className=this.behavior.CSS_DELETE_SPAN;C.appendChild(B);return C};_i.prototype.duplicateSection=function(C){if(!this.behavior.allowRepeat(C,this)){return false}this.updateMasterSection(C);var B=C.cloneNode(true);var A=this.getNextDuplicateIndex(this.target);var D=this.createSuffix(C,A);this.updateDuplicatedSection(B,A,D);B=C.parentNode.insertBefore(B,this.getInsertNode(C));wFORMS.applyBehaviors(B);if(wFORMS.behaviors.calculation){_c=wFORMS.behaviors.calculation;inputItem=B.querySelector("input");if(inputItem){if(inputItem.className.search(_c.VARIABLE_SELECTOR_PREFIX)!=-1){_c.applyTo(inputItem.form)}}}this.behavior.onRepeat(B);wFORMS.helpers.spotlight(B)};_i.prototype.removeSection=function(A){if(A){var A=A.parentNode.removeChild(A);this.behavior.onRemove(A)}};_i.prototype.getInsertNode=function(B){var A=B.nextSibling;if(A&&A.nodeType==1&&!A.hasClass){A=base2.DOM.bind(A)}while(A&&(A.nodeType==3||A.hasClass(this.behavior.CSS_REMOVEABLE))){A=A.nextSibling;if(A&&A.nodeType==1&&!A.hasClass){A=base2.DOM.bind(A)}}return A};_i.prototype.onRemoveLinkClick=function(B,A){var C=document.getElementById(A.getAttribute(this.behavior.ATTR_LINK_SECTION_ID));this.removeSection(C);if(B){B.preventDefault()}};_i.prototype.updateMasterSection=function(A){if(A.doItOnce==true){return true}else{A.doItOnce=true}var B=this.createSuffix(A);A.id=this.clearSuffix(A.id)+B;this.updateMasterElements(A,B)};_i.prototype.updateMasterElements=function(B,J){if(!B||B.nodeType!=1){return }var G=B.childNodes;for(var E=0;E<G.length;E++){var A=G[E];if(A.nodeType!=1){continue}if(!A.hasClass){A.hasClass=function(L){return base2.DOM.HTMLElement.hasClass(this,L)}}var C=J;if(A.hasClass(this.behavior.CSS_REPEATABLE)){J+="[0]"}if(!A.hasClass(this.behavior.CSS_REMOVEABLE)){for(var D=0;D<this.behavior.UPDATEABLE_ATTR_ARRAY.length;D++){var F=this.behavior.UPDATEABLE_ATTR_ARRAY[D];var H=this.clearSuffix(A.getAttribute(F));if(!H){continue}if(F=="id"&&wFORMS.behaviors.hint&&wFORMS.behaviors.hint.isHintId(A.id)){A.id=H.replace(new RegExp("(.*)("+wFORMS.behaviors.hint.HINT_SUFFIX+")$"),"$1"+J+"$2")}else{if(F=="id"&&wFORMS.behaviors.validation&&wFORMS.behaviors.validation.isErrorPlaceholderId(A.id)){A.id=H.replace(new RegExp("(.*)("+wFORMS.behaviors.validation.ERROR_PLACEHOLDER_SUFFIX+")$"),"$1"+J+"$2")}else{if(F=="id"&&A.id.indexOf(this.behavior.ID_SUFFIX_DUPLICATE_LINK)!=-1){A.id=H.replace(new RegExp("(.*)("+this.behavior.ID_SUFFIX_DUPLICATE_LINK+")$"),"$1"+J+"$2")}else{if(F=="id"){A.id=H+J}else{if(F=="name"){A.name=H+J}else{A.setAttribute(F,H+J)}}}}}}this.updateMasterElements(A,J)}J=C}};_i.prototype.updateDuplicatedSection=function(C,A,D){C[this.behavior.ATTR_MASTER_SECTION]=C.id;C.id=this.clearSuffix(C.id)+D;C.className=C.className.replace(this.behavior.CSS_REPEATABLE,this.behavior.CSS_REMOVEABLE);if(!C.hasClass){C.hasClass=function(E){return base2.DOM.HTMLElement.hasClass(this,E)}}if(C.hasClass(this.behavior.CSS_PRESERVE_RADIO_NAME)){var B=true}else{var B=this.behavior.preserveRadioName}this.updateSectionChildNodes(C,D,B)};_i.prototype.updateSectionChildNodes=function(B,N,L){if(B.doItOnce){B.doItOnce=null}var D=new Array();var F=0;while(B&&B.childNodes&&B.childNodes[F]){var G=B.childNodes[F];F++;if(G.nodeType!=1){continue}if(!G.hasClass){G.hasClass=function(O){return base2.DOM.HTMLElement.hasClass(this,O)}}if(this.behavior.isDuplicate(G)){D.push(G);continue}if(G.hasClass(this.behavior.CSS_DUPLICATE_SPAN)){D.push(G);continue}if(G.hasClass(this.behavior.CSS_DUPLICATE_LINK)){D.push(G);continue}if((G.tagName=="INPUT"&&G.type!="button")||G.tagName=="TEXTAREA"){if(G.type!="radio"&&G.type!="checkbox"){G.value=""}else{G.checked=false}}if(G.tagName=="INPUT"&&G.type=="radio"&&document.all&&!window.opera&&!L){var H='<INPUT type="radio" name="'+G.name+N+'"></INPUT>';var A=G.parentNode.insertBefore(document.createElement(H),G);A.id=G.id;A.className=G.className;A.value=G.value;G=G.parentNode.removeChild(G);var C=this.behavior.UPDATEABLE_ATTR_ARRAY.length;for(var E=0;E<C;E++){var J=this.behavior.UPDATEABLE_ATTR_ARRAY[E];var M=G.getAttribute(J);A.setAttribute(J,M)}G=A;if(!G.hasClass){G.hasClass=function(O){return base2.DOM.HTMLElement.hasClass(this,O)}}}this.updateAttributes(G,N,L);if(G.hasClass(this.behavior.CSS_REPEATABLE)){this.updateSectionChildNodes(G,this.createSuffix(G),L)}else{this.updateSectionChildNodes(G,N,L)}}for(var F=0;F<D.length;F++){var G=D[F];if(G.clearAttributes){G.clearAttributes(false)}if(G.parentNode){G.parentNode.removeChild(G)}}};_i.prototype.createSuffix=function(E,B){var D="["+(B?B:"0")+"]";var C=/\[(\d+)\]$/;E=E.parentNode;while(E){if(!E.hasClass){E.hasClass=function(F){return base2.DOM.HTMLElement.hasClass(this,F)}}if(E.hasClass(this.behavior.CSS_REPEATABLE)||E.hasClass(this.behavior.CSS_REMOVEABLE)){var A=C.exec(E.id);if(A){A=A[1]}D="["+(A?A:"0")+"]"+D}E=E.parentNode}return D};_i.prototype.clearSuffix=function(A){if(!A){return }A=A.replace(/(\[\d+\])+(\-[HE])?$/,"$2");return A};_i.prototype.updateAttributes=function(F,D,H){var L=wFORMS.behaviors.hint&&wFORMS.behaviors.hint.isHintId(F.id);var C=wFORMS.behaviors.validation&&wFORMS.behaviors.validation.isErrorPlaceholderId(F.id);var B=F.id.indexOf(this.behavior.ID_SUFFIX_DUPLICATE_LINK)!=-1;this.setInDuplicateGroup(F);if(this.behavior.isHandled(F)){this.removeHandled(F)}if(wFORMS.behaviors["switch"]&&wFORMS.behaviors["switch"].isHandled(F)){wFORMS.behaviors["switch"].removeHandle(F)}var A=this.behavior.UPDATEABLE_ATTR_ARRAY.length;for(var E=0;E<A;E++){var G=this.behavior.UPDATEABLE_ATTR_ARRAY[E];var J=this.clearSuffix(F.getAttribute(G));if(!J){continue}if(G=="name"&&F.tagName=="INPUT"&&H){continue}else{if(C&&G=="id"){F.id=J.replace(new RegExp("(.*)("+wFORMS.behaviors.validation.ERROR_PLACEHOLDER_SUFFIX+")$"),"$1"+D+"$2")}else{if(L&&G=="id"){F.id=J.replace(new RegExp("(.*)("+wFORMS.behaviors.hint.HINT_SUFFIX+")$"),"$1"+D+"$2")}else{if(B&&G=="id"){F.id=J.replace(new RegExp("(.*)("+this.behavior.ID_SUFFIX_DUPLICATE_LINK+")$"),"$1"+D+"$2")}else{if(G=="id"){F.id=J+D}else{if(G=="name"){F.name=J+D}else{F.setAttribute(G,J+D)}}}}}}}};_i.prototype.getNextDuplicateIndex=function(A){var C=this.getOrCreateCounterField(A);var B=parseInt(C.value)+1;C.value=B;return B};_i.prototype.getOrCreateCounterField=function(C){var A=C.id+this.behavior.ID_SUFFIX_COUNTER;var B=document.getElementById(A);if(!B||B==""){B=this.createCounterField(A);var D=C.parentNode;while(D&&D.tagName.toUpperCase()!="FORM"){D=D.parentNode}D.appendChild(B)}return B};_i.prototype.createCounterField=function(A){cElem=document.createElement("input");cElem.id=A;cElem.setAttribute("type","hidden");cElem.setAttribute("name",A);cElem.value="0";return cElem};_i.prototype.getSectionsCount=function(){if(this.behavior.isDuplicate(this.target)){return false}return parseInt(this.getOrCreateCounterField(this.target).value)+1};_i.prototype.setInDuplicateGroup=function(A){return A.setAttribute(this.behavior.ATTR_DUPLICATE_ELEM,true)};_i.prototype.setElementHandled=function(A){return A.setAttribute(this.behavior.ATTR_HANDLED,true)};_i.prototype.removeHandled=function(A){return A.removeAttribute(this.behavior.ATTR_HANDLED)};_b.isDuplicate=function(A){return A.hasClass(this.CSS_REMOVEABLE)};_b.isInDuplicateGroup=function(A){return A.getAttribute(this.ATTR_DUPLICATE_ELEM)?true:false};_b.isHandled=function(A){return A.getAttribute(this.ATTR_HANDLED)};_b.getMasterSection=function(A){if(!this.isDuplicate(A)){return false}return document.getElementById(A[this.ATTR_MASTER_SECTION])};_i.prototype.run=function(A){this.duplicateSection(this.target);if(A){A.preventDefault()}};if(typeof (wFORMS)=="undefined"){throw new Error("wFORMS core not found. This behavior depends on the wFORMS core.")}wFORMS.behaviors["switch"]={SELECTOR:'*[class*="switch-"]',CSS_PREFIX:"switch-",CSS_OFFSTATE_PREFIX:"offstate-",CSS_ONSTATE_PREFIX:"onstate-",CSS_ONSTATE_FLAG:"swtchIsOn",CSS_OFFSTATE_FLAG:"swtchIsOff",onSwitchOn:function(A){},onSwitchOff:function(A){},onSwitch:function(A){},instance:function(A){this.behavior=wFORMS.behaviors["switch"];this.target=A;this.cache={}}};wFORMS.behaviors["switch"].applyTo=function(B){while(B&&B.tagName!="FORM"){B=B.parentNode}var A=wFORMS.getBehaviorInstance(B,"switch");if(A){A.cache={};ret=new Array({target:null})}else{A=new wFORMS.behaviors["switch"].instance(B);ret=A}A.buildCache();A.setupTriggers();A.setupTargets();A.onApply();return ret};wFORMS.behaviors["switch"].instance.prototype.setupTriggers=function(){for(var B in this.cache){var C=this.cache[B].triggers;for(var A=0;A<C.length;A++){this.setupTrigger(C[A])}}};wFORMS.behaviors["switch"].instance.prototype.setupTrigger=function(G){var C=this;if(!G.id){G.id=wFORMS.helpers.randomId()}switch(G.tagName.toUpperCase()){case"OPTION":var A=G.parentNode;while(A&&A.tagName!="SELECT"){A=A.parentNode}if(A&&!wFORMS.behaviors["switch"].isHandled(A)){A.addEventListener("change",function(J){C.run(J,A)},false);wFORMS.behaviors["switch"].handleElement(A)}break;case"SELECT":if(G&&!wFORMS.behaviors["switch"].isHandled(G)){G.addEventListener("change",function(J){C.run(J,G)},false);wFORMS.behaviors["switch"].handleElement(G)}break;case"INPUT":if(G.type&&G.type.toUpperCase()=="RADIO"){var D=G.form[G.name];if(!D){D=[];var H=G.form.getElementsByTagName("INPUT");for(var B=0;B<H.length;B++){if(H[B].type=="radio"&&H[B].name==G.name){D.push(H[B])}}}for(var F=D.length-1;F>=0;F--){var E=D[F];wFORMS.standardizeElement(E);if(!this.behavior.isHandled(E)){E.addEventListener("click",function(J){C.run(J,E)},false);this.behavior.handleElement(E)}}}else{if(!this.behavior.isHandled(G)){G.addEventListener("click",function(J){C.run(J,G)},false);this.behavior.handleElement(G)}}break;default:if(!this.behavior.isHandled(G)){G.addEventListener("click",function(J){C.run(J,G)},false);this.behavior.handleElement(G)}break}};wFORMS.behaviors["switch"].instance.prototype.onApply=function(){};wFORMS.behaviors["switch"].isHandled=function(A){return A.getAttribute("rel")&&A.getAttribute("rel").indexOf("wfHandled")>-1};wFORMS.behaviors["switch"].handleElement=function(A){return A.setAttribute("rel",(A.getAttribute("rel")||"")+" wfHandled")};wFORMS.behaviors["switch"].removeHandle=function(A){if(attr=A.getAttribute("rel")){if(attr=="wfHandled"){A.removeAttribute("rel")}else{if(attr.indexOf("wfHandled")!=-1){A.setAttribute("rel",attr.replace(/(.*)( wfHandled)(.*)/,"$1$3"))}}}};wFORMS.behaviors["switch"].instance.prototype.buildCache=function(){this.cache_processed=new Array();var A=this.target.getElementsByTagName("*");for(var B=0;B<A.length;B++){if(A[B].tagName){if(A[B].className&&A[B].className.indexOf(this.behavior.CSS_PREFIX)!=-1){this.addTriggerToCache(A[B])}if(A[B].className&&A[B].className.indexOf(this.behavior.CSS_OFFSTATE_PREFIX)!=-1){this.addTargetToCache(A[B])}if(A[B].className&&A[B].className.indexOf(this.behavior.CSS_ONSTATE_PREFIX)!=-1){this.addTargetToCache(A[B])}}}};wFORMS.behaviors["switch"].instance.prototype.invalidateCache=function(){var D=true;if(arguments.length>0){var C=document.getElementById(arguments[0]);if(C){var D=false;if(!C.querySelectorAll){base2.DOM.bind(C)}var A='*[class*="'+this.behavior.CSS_PREFIX+'"], *[class*="'+this.behavior.CSS_OFFSTATE_PREFIX+'"], *[class*="'+this.behavior.CSS_ONSTATE_PREFIX+'"]';var B=C.querySelectorAll(A);if(B.length>0||C.className&&(C.className.indexOf(this.behavior.CSS_PREFIX)!=-1||C.className.indexOf(this.behavior.CSS_OFFSTATE_PREFIX)!=-1||C.className.indexOf(this.behavior.CSS_ONSTATE_PREFIX)!=-1)){D=true}}}if(D){this.cache={};this.buildCache()}};wFORMS.behaviors["switch"].instance.prototype.addTriggerToCache=function(F){if(F.tagName=="OPTION"){var A=F.parentNode;while(A&&A.tagName!="SELECT"){A=A.parentNode}if(!A){return }F=A}if(!F.id){F.id=wFORMS.helpers.randomId()}for(var C=0;C<this.cache_processed.length;C++){if(this.cache_processed[C]==F.id){return }}this.cache_processed.push(F.id);wFORMS.standardizeElement(F);var E=this.getTriggers(new Array(F));for(var D=0;D<E.ON.length;D++){var B=E.ON[D];if(typeof this.cache[B]=="undefined"){this.cache[B]={triggers:[],targets:[]}}for(var C=0;C<this.cache[B].triggers.length;C++){if(this.cache[B].triggers[C]==F){break}}if(C==this.cache[B].triggers.length){this.cache[B].triggers.push(F)}}for(var D=0;D<E.OFF.length;D++){var B=E.OFF[D];if(typeof this.cache[B]=="undefined"){this.cache[B]={triggers:[],targets:[]}}for(var C=0;C<this.cache[B].triggers.length;C++){if(this.cache[B].triggers[C]==F){break}}if(C==this.cache[B].triggers.length){this.cache[B].triggers.push(F)}}};wFORMS.behaviors["switch"].instance.prototype.addTargetToCache=function(C){wFORMS.standardizeElement(C);var D=this.behavior.getSwitchNamesFromTarget(C);for(var B=0;B<D.length;B++){switchName=D[B];if(typeof this.cache[switchName]=="undefined"){this.cache[switchName]={triggers:[],targets:[]}}for(var A=0;A<this.cache[switchName].targets.length;A++){if(this.cache[switchName].targets[A]==C){break}}if(A==this.cache[switchName].targets.length){this.cache[switchName].targets.push(C)}}};wFORMS.behaviors["switch"].instance.prototype.getTriggers=function(A,M){var C={ON:new Array(),OFF:new Array(),toString:function(){return"ON: "+this.ON+"\nOFF: "+this.OFF}};for(var H=0;H<A.length;H++){var D=A[H];switch(D.tagName.toUpperCase()){case"OPTION":if(D.selected){C.ON=C.ON.concat(this.behavior.getSwitchNamesFromTrigger(D,M))}else{C.OFF=C.OFF.concat(this.behavior.getSwitchNamesFromTrigger(D,M))}break;case"SELECT":for(var F=0;F<D.options.length;F++){var B=D.options.item(F);if(B.selected){C.ON=C.ON.concat(this.behavior.getSwitchNamesFromTrigger(B,M))}else{C.OFF=C.OFF.concat(this.behavior.getSwitchNamesFromTrigger(B,M))}}break;case"INPUT":if(D.type&&D.type.toUpperCase()=="RADIO"){var G=D.form[D.name];if(!G){var G=[];var J=D.form.getElementsByTagName("INPUT");for(var E=0;E<J.length;E++){if(J[E].type=="radio"&&J[E].name==D.name){G.push(J[E])}}}for(var F=G.length-1;F>=0;F--){var O=G[F];if(O==D||!wFORMS.helpers.contains(A,O)){if(O.checked){C.ON=C.ON.concat(this.behavior.getSwitchNamesFromTrigger(O,M))}else{C.OFF=C.OFF.concat(this.behavior.getSwitchNamesFromTrigger(O,M))}}}}else{if(D.checked){C.ON=C.ON.concat(this.behavior.getSwitchNamesFromTrigger(D,M))}else{C.OFF=C.OFF.concat(this.behavior.getSwitchNamesFromTrigger(D,M))}}break;default:if(D.hasClass(this.behavior.CSS_ONSTATE_FLAG)){C.ON=C.ON.concat(this.behavior.getSwitchNamesFromTrigger(D,M))}else{C.OFF=C.OFF.concat(this.behavior.getSwitchNamesFromTrigger(D,M))}break}}var L=new Array();for(var H=0;H<C.ON.length;H++){if(!wFORMS.helpers.contains(L,C.ON[H])){L.push(C.ON[H])}}var N=new Array();for(var H=0;H<C.OFF.length;H++){if(!wFORMS.helpers.contains(N,C.OFF[H])){N.push(C.OFF[H])}}C.ON=L;C.OFF=N;return C};wFORMS.behaviors["switch"].getSwitchNamesFromTrigger=function(B,A){return wFORMS.behaviors["switch"].getSwitchNames(B.className,"trigger",A)};wFORMS.behaviors["switch"].getSwitchNamesFromTarget=function(B,A){return wFORMS.behaviors["switch"].getSwitchNames(B.className,"target",A)};wFORMS.behaviors["switch"].getSwitchNames=function(D,C,H){if(!D||D==""){return[]}var F=D.split(" ");var J=new Array();if(C=="trigger"){var E=true}else{var E=false}for(var B=F.length-1;B>=0;B--){var G=F[B];if(E){if(G.indexOf(this.CSS_PREFIX)==0){var A=G.substring(this.CSS_PREFIX.length)}}else{if(G.indexOf(this.CSS_ONSTATE_PREFIX)==0){var A=G.substring(this.CSS_ONSTATE_PREFIX.length)}else{if(G.indexOf(this.CSS_OFFSTATE_PREFIX)==0){var A=G.substring(this.CSS_OFFSTATE_PREFIX.length)}}}if(A&&(!H||wFORMS.helpers.contains(H,A))){J.push(A)}}return J};wFORMS.behaviors["switch"].instance.prototype.getTriggersByTarget=function(G){var D=new Array();var F=wFORMS.behaviors["switch"].getSwitchNamesFromTarget(G);var A=wFORMS.behaviors.repeat;for(var C=0;C<F.length;C++){var H=this.cache[F[C]];if(H){for(j=0;j<H.triggers.length;j++){var E=H.triggers[j];for(var B=0;B<D.length&&D[B]!=E;B++){}if(B==D.length){D.push(E)}}}}return this.getTriggers(D,F)};wFORMS.behaviors["switch"].isSwitchedOff=function(A){return(A.className.match(new RegExp(wFORMS.behaviors["switch"].CSS_OFFSTATE_PREFIX+"[^ ]*"))?true:false)&&(A.className.match(new RegExp(wFORMS.behaviors["switch"].CSS_ONSTATE_PREFIX+"[^ ]*"))?false:true)};wFORMS.behaviors["switch"].instance.prototype.setupTargets=function(){var A=[];for(var C in this.cache){for(var B=0;B<this.cache[C].triggers.length;B++){var D=this.cache[C].triggers[B];if(!wFORMS.helpers.contains(A,D)){if(D.tagName!="A"||D.hasClass(this.behavior.CSS_ONSTATE_FLAG)){A.push(D);this.run(null,D)}}}}};wFORMS.behaviors["switch"].instance.prototype.inScope=function(B,D){var C=wFORMS.behaviors.repeat;if(C){var A=B;while(A&&!A.hasClass(C.CSS_REMOVEABLE)&&!A.hasClass(C.CSS_REPEATABLE)){A=A.parentNode;if(A){wFORMS.standardizeElement(A)}}if(A){var E=false;while(D){if(D.hasClass(C.CSS_REMOVEABLE)||D.hasClass(C.CSS_REPEATABLE)){E=true}if(D==A){return true}D=D.parentNode;if(D){wFORMS.standardizeElement(D)}}return !E}}return true};wFORMS.behaviors["switch"].instance.prototype.run=function(H,D){wFORMS.standardizeElement(D);if(D.hasClass(this.behavior.CSS_ONSTATE_FLAG)){D.removeClass(this.behavior.CSS_ONSTATE_FLAG);D.addClass(this.behavior.CSS_OFFSTATE_FLAG);if(H){H.preventDefault()}}else{if(D.hasClass(this.behavior.CSS_OFFSTATE_FLAG)){D.removeClass(this.behavior.CSS_OFFSTATE_FLAG);D.addClass(this.behavior.CSS_ONSTATE_FLAG);if(H){H.preventDefault()}}}var E=this.getTriggers(new Array(D));for(var C=0;C<E.OFF.length;C++){var A=E.OFF[C];for(var B=0;B<this.cache[A].targets.length;B++){var G=this.cache[A].targets[B];if(!this.inScope(D,G)){continue}wFORMS.standardizeElement(G);G.addClass(wFORMS.behaviors["switch"].CSS_OFFSTATE_PREFIX+A);G.removeClass(wFORMS.behaviors["switch"].CSS_ONSTATE_PREFIX+A);var F=this.getTriggersByTarget(G);if(F.ON.length==0){this.behavior.onSwitchOff(G)}}}for(var C=0;C<E.ON.length;C++){var A=E.ON[C];for(var B=0;B<this.cache[A].targets.length;B++){var G=this.cache[A].targets[B];if(!this.inScope(D,G)){continue}wFORMS.standardizeElement(G);G.removeClass(this.behavior.CSS_OFFSTATE_PREFIX+A);G.addClass(this.behavior.CSS_ONSTATE_PREFIX+A);this.behavior.onSwitchOn(G)}}if(b=wFORMS.getBehaviorInstance(this.target,"paging")){b.setupManagedControls()}this.behavior.onSwitch(this.target)};if(typeof (wFORMS)=="undefined"){throw new Error("wFORMS core not found. This behavior depends on the wFORMS core.")}wFORMS.behaviors.validation={ERROR_PLACEHOLDER_SUFFIX:"-E",rules:{isRequired:{selector:".required",check:"validateRequired"},isAlpha:{selector:".validate-alpha",check:"validateAlpha"},isAlphanum:{selector:".validate-alphanum",check:"validateAlphanum"},isDate:{selector:".validate-date",check:"validateDate"},isTime:{selector:".validate-time",check:"validateTime"},isEmail:{selector:".validate-email",check:"validateEmail"},isInteger:{selector:".validate-integer",check:"validateInteger"},isFloat:{selector:".validate-float",check:"validateFloat"},isPhone:{selector:".validate-phone",check:"validatePhone"},isCustom:{selector:".validate-custom",check:"validateCustom"}},styling:{fieldError:"errFld",errorMessage:"errMsg"},messages:{isRequired:"This field is required. ",isAlpha:"The text must use alphabetic characters only (a-z, A-Z). Numbers are not allowed.",isEmail:"This does not appear to be a valid email address.",isInteger:"Please enter an integer.",isFloat:"Please enter a number (ex. 1.9).",isAlphanum:"Please use alpha-numeric characters only [a-z 0-9].",isDate:"This does not appear to be a valid date.",isPhone:"Please enter a valid phone number.",isCustom:"Please enter a valid value.",notification:"The form is not complete and has not been submitted yet. There was %% problem(s) with your submission."},instance:function(A){this.behavior=wFORMS.behaviors.validation;this.target=A},onPass:function(A){},onFail:function(A){}};wFORMS.behaviors.validation.applyTo=function(D){if(!D||!D.tagName){throw new Error("Can't apply behavior to "+D)}if(D.tagName!="FORM"){if(D.form){D=D.form}else{var E=D;for(D=D.parentNode;D&&D.tagName!="FORM";D=D.parentNode){continue}if(!D||D.tagName!="FORM"){D=E.getElementsByTagName("form")}}}if(!D.tagName&&D.length>0){var A=new Array();for(var B=0;B<D.length;B++){var C=new wFORMS.behaviors.validation.instance(D[B]);if(!D[B].addEventListener){base2.DOM.bind(D[B])}D[B].addEventListener("submit",function(F){return C.run(F,this)},false);A.push(C);C.onApply()}}else{var A=new wFORMS.behaviors.validation.instance(D);if(!D.addEventListener){base2.DOM.bind(D)}D.addEventListener("submit",function(F){return A.run(F,this)},false);A.onApply()}return A};wFORMS.behaviors.validation.instance.prototype.onApply=function(){};wFORMS.behaviors.validation.instance.prototype.run=function(E,B){if(E&&E.pagingStopPropagation){return false}var F=function(H){if(wFORMS.behaviors.paging&&!wFORMS.behaviors.paging.isElementVisible(H)){return }if(A.isSwitchedOff(H)){return }var J=wFORMS.helpers.getFieldValue(H);if(D.check.call){var L=D.check.call(A,H,J)}else{var L=A[D.check].call(A,H,J)}if(!L){if(!H.id){H.id=wFORMS.helpers.randomId()}A.elementsInError[H.id]={id:H.id,rule:C};A.removeErrorMessage(H);if(D.fail){D.fail.call(A,H,C)}else{A.fail.call(A,H,C)}G++}else{if(!A.elementsInError[H.id]){A.removeErrorMessage(H)}if(D.pass){D.pass.call(A,H)}else{A.pass.call(A,H)}}};var G=0;this.elementsInError={};for(var C in this.behavior.rules){var D=this.behavior.rules[C];var A=this;if(!B.matchesSelector){base2.DOM.bind(B)}if(B.matchesSelector(D.selector)){F(B)}B.querySelectorAll(D.selector).forEach(F)}if(G>0){if(E){E.preventDefault?E.preventDefault():E.returnValue=false}if(this.behavior.onFail){this.behavior.onFail(this)}return false}if(this.behavior.onPass){this.behavior.onPass(this)}return true};wFORMS.behaviors.validation.instance.prototype.fail=function(A,B){A.addClass(this.behavior.styling.fieldError);this.addErrorMessage(A,this.behavior.messages[B])},wFORMS.behaviors.validation.instance.prototype.pass=function(A){};wFORMS.behaviors.validation.instance.prototype.addErrorMessage=function(A,B){if(!A.id){A.id=wFORMS.helpers.randomId()}var C=document.createTextNode(B);var D=document.getElementById(A.id+this.behavior.ERROR_PLACEHOLDER_SUFFIX);if(!D){D=document.createElement("div");D.setAttribute("id",A.id+this.behavior.ERROR_PLACEHOLDER_SUFFIX);if(A.tagName=="TR"){D=(A.getElementsByTagName("TD")[0]).appendChild(D)}else{D=A.parentNode.insertBefore(D,A.nextSibling)}}D.appendChild(C);base2.DOM.bind(D);D.addClass(this.behavior.styling.errorMessage)};wFORMS.behaviors.validation.instance.prototype.removeErrorMessage=function(B){if(!B.hasClass){base2.DOM.bind(B)}if(B.hasClass(this.behavior.styling.fieldError)){B.removeClass(this.behavior.styling.fieldError);var A=document.getElementById(B.id+this.behavior.ERROR_PLACEHOLDER_SUFFIX);if(A){A.parentNode.removeChild(A)}}};wFORMS.behaviors.validation.instance.prototype.isSwitchedOff=function(B){var C=wFORMS.getBehaviorInstance(this.target,"switch");if(C){var A=B;while(A&&A.tagName!="BODY"){if(A.className&&A.className.indexOf(C.behavior.CSS_OFFSTATE_PREFIX)!=-1&&A.className.indexOf(C.behavior.CSS_ONSTATE_PREFIX)==-1){return true}A=A.parentNode}}return false};wFORMS.behaviors.validation.isErrorPlaceholderId=function(A){return A.match(new RegExp(wFORMS.behaviors.validation.ERROR_PLACEHOLDER_SUFFIX+"$"))!=null};wFORMS.behaviors.validation.instance.prototype.isEmpty=function(A){var B=/^\s+$/;return((A==null)||(A.length==0)||B.test(A))};wFORMS.behaviors.validation.instance.prototype.validateRequired=function(A,C){switch(A.tagName){case"INPUT":var B=A.getAttribute("type");if(!B){B="text"}switch(B.toLowerCase()){case"checkbox":case"radio":return A.checked;break;default:return !this.isEmpty(C)}break;case"SELECT":return !this.isEmpty(C);break;case"TEXTAREA":return !this.isEmpty(C);break;default:return this.validateOneRequired(A);break}return false};wFORMS.behaviors.validation.instance.prototype.validateOneRequired=function(B){if(B.nodeType!=1){return false}if(this.isSwitchedOff(B)){return false}switch(B.tagName){case"INPUT":var C=B.getAttribute("type");if(!C){C="text"}switch(C.toLowerCase()){case"checkbox":case"radio":return B.checked;break;default:return !this.isEmpty(wFORMS.helpers.getFieldValue(B))}break;case"SELECT":return !this.isEmpty(wFORMS.helpers.getFieldValue(B));break;case"TEXTAREA":return !this.isEmpty(wFORMS.helpers.getFieldValue(B));break;default:for(var A=0;A<B.childNodes.length;A++){if(this.validateOneRequired(B.childNodes[A])){return true}}break}return false};wFORMS.behaviors.validation.instance.prototype.validateAlpha=function(A,C){var B=/^[a-zA-Z\s]+$/;return this.isEmpty(C)||B.test(C)};wFORMS.behaviors.validation.instance.prototype.validateAlphanum=function(A,C){var B=/^[\w\s]+$/;return this.isEmpty(C)||B.test(C)};wFORMS.behaviors.validation.instance.prototype.validateDate=function(B,C){var A=new Date(C);return this.isEmpty(C)||!isNaN(A)};wFORMS.behaviors.validation.instance.prototype.validateTime=function(A,B){return true};wFORMS.behaviors.validation.instance.prototype.validateEmail=function(A,B){var C=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,}$/;return this.isEmpty(B)||C.test(B)};wFORMS.behaviors.validation.instance.prototype.validateInteger=function(A,C){var B=/^[+]?\d+$/;return this.isEmpty(C)||B.test(C)};wFORMS.behaviors.validation.instance.prototype.validateFloat=function(A,B){return this.isEmpty(B)||!isNaN(parseFloat(B))};wFORMS.behaviors.validation.instance.prototype.validatePhone=function(B,D){if(this.isEmpty(D)){return true}var A=[/^[\d\-\. \+\(\)]+$/,/^[\d\-\. \+\(\)]+ # {0,1}\d+ *$/,/^[\d\-\. \+\(\)]+ ext\.{0,1} \d+ *$/];for(var C in A){if(A[C].test(D)){return true}}return false};wFORMS.behaviors.validation.instance.prototype.validateCustom=function(A,D){var C=new RegExp("/(.*)/([gi]*)");var B=A.className.match(C);if(B&&B[0]){var E=new RegExp(B[1],B[2]);if(!D.match(E)){return false}}return true};if(typeof (wFORMS)=="undefined"){throw new Error("wFORMS core not found. This behavior depends on the wFORMS core.")}wFORMS.behaviors.calculation={VARIABLE_SELECTOR_PREFIX:"calc-",CHOICE_VALUE_SELECTOR_PREFIX:"calcval-",CALCULATION_SELECTOR:'*[class*="formula="]',CALCULATION_ERROR_MESSAGE:"There was an error computing this field.",instance:function(A){this.behavior=wFORMS.behaviors.calculation;this.target=A;this.calculations=[]}};wFORMS.behaviors.calculation.applyTo=function(B){var A=new wFORMS.behaviors.calculation.instance(B);B.querySelectorAll(wFORMS.behaviors.calculation.CALCULATION_SELECTOR).forEach(function(E){var G=E.className.substr(E.className.indexOf("formula=")+8).split(" ")[0];var F=G.split(/[^a-zA-Z]+/g);A.varFields=[];for(var D=0;D<F.length;D++){if(F[D]!=""){base2.DOM.Document.querySelectorAll(B,'*[class*="'+wFORMS.behaviors.calculation.VARIABLE_SELECTOR_PREFIX+F[D]+'"]').forEach(function(H){if(!H.addEventListener){base2.DOM.bind(H)}var L=((" "+H.className+" ").indexOf(" "+wFORMS.behaviors.calculation.VARIABLE_SELECTOR_PREFIX+F[D]+" ")!=-1);if(!L){return }if(!H._wforms_calc_handled){var J=H.tagName.toLowerCase();if(J=="input"||J=="textarea"){var M=H.type.toLowerCase();if(J=="input"&&(M=="radio"||M=="checkbox")){H.addEventListener("click",function(N){return A.run(N,this)},false);H._wforms_calc_handled=true}else{H.addEventListener("blur",function(N){return A.run(N,this)},false);H._wforms_calc_handled=true}}else{if(J=="select"){H.addEventListener("change",function(N){return A.run(N,this)},false);H._wforms_calc_handled=true}else{return }}}A.varFields.push({name:F[D],field:H})})}}var C={field:E,formula:G,variables:A.varFields};A.calculations.push(C);A.compute(C)});A.onApply();return A};wFORMS.behaviors.calculation.instance.prototype.onApply=function(){};wFORMS.behaviors.calculation.instance.prototype.run=function(E,D){for(var C=0;C<this.calculations.length;C++){var B=this.calculations[C];for(var A=0;A<B.variables.length;A++){if(D==B.variables[A].field){this.compute(B)}}}};wFORMS.behaviors.calculation.instance.prototype.refresh=function(D,C){for(var B=0;B<this.calculations.length;B++){var A=this.calculations[B];if(C==A.field){this.compute(A)}}};wFORMS.behaviors.calculation.instance.prototype.compute=function(calculation){var f=this.target;var formula=calculation.formula;var _processedVariables=new Array();for(var i=0;i<calculation.variables.length;i++){var v=calculation.variables[i];var varval=0;var _self=this;if(wFORMS.helpers.contains(_processedVariables,v.name)){continue}else{_processedVariables.push(v.name)}base2.DOM.Document.querySelectorAll(f,'*[class*="'+_self.behavior.VARIABLE_SELECTOR_PREFIX+v.name+'"]').forEach(function(variable){var exactMatch=((" "+variable.className+" ").indexOf(" "+wFORMS.behaviors.calculation.VARIABLE_SELECTOR_PREFIX+v.name+" ")!=-1);if(!exactMatch){return }if(_self.hasValueInClassName(variable)){var value=_self.getValueFromClassName(variable)}else{var value=wFORMS.helpers.getFieldValue(variable)}if(!value){value=0}if(value.constructor==Array){for(var j=0;j<value.length;j++){if(String(value[j]).search(/^[\d\.,]*$/)!=-1){varval+=parseFloat(value[j])}else{(!varval)?(varval=value[j]):(varval=String(varval).concat(value[j]))}}}else{if(String(value).search(/^[\d\.,]*$/)!=-1){varval+=parseFloat(value)}else{(!varval)?(varval=value):(varval=String(varval).concat(value))}}});if(String(varval).search(/^[\d\.,]*$/)!=-1){formula="var "+v.name+" = "+varval+"; "+formula}else{formula="var "+v.name+' = "'+varval.replace(/\"/g,'\\"')+'"; '+formula}}try{var calc=function(){return eval(formula)};var result=calc();if(result=="Infinity"||result=="NaN"||String(result).match("NaN")){result="error"}}catch(x){result="error"}var validationBehavior=wFORMS.getBehaviorInstance(this.target,"validation");if(validationBehavior){if(!wFORMS.behaviors.validation.messages["calculation"]){wFORMS.behaviors.validation.messages["calculation"]=this.behavior.CALCULATION_ERROR_MESSAGE}validationBehavior.removeErrorMessage(calculation.field);if(result=="error"){validationBehavior.fail(calculation.field,"calculation")}}calculation.field.value=result;if(calculation.field.className&&(calculation.field.className.indexOf(this.behavior.VARIABLE_SELECTOR_PREFIX)!=-1)){this.run(null,calculation.field)}};wFORMS.behaviors.calculation.instance.prototype.hasValueInClassName=function(B){switch(B.tagName){case"SELECT":for(var A=0;A<B.options.length;A++){if(B.options[A].className&&B.options[A].className.indexOf(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)!=-1){return true}}return false;break;default:if(!B.className||(" "+B.className).indexOf(" "+this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)==-1){return false}break}return true};wFORMS.behaviors.calculation.instance.prototype.getValueFromClassName=function(C){switch(C.tagName){case"INPUT":if(!C.className||C.className.indexOf(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)==-1){return null}var D=C.className.split(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)[1].split(" ")[0];if(C.type=="checkbox"){return C.checked?D:null}if(C.type=="radio"){return C.checked?D:null}return D;break;case"SELECT":if(C.selectedIndex==-1){return null}if(C.getAttribute("multiple")){var A=[];for(var B=0;B<C.options.length;B++){if(C.options[B].selected){if(C.options[B].className&&C.options[B].className.indexOf(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)!=-1){var D=C.options[B].className.split(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)[1].split(" ")[0];A.push(D)}}}if(A.length==0){return null}return A}if(C.options[C.selectedIndex].className&&C.options[C.selectedIndex].className.indexOf(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)!=-1){var D=C.options[C.selectedIndex].className.split(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)[1].split(" ")[0];return D}break;case"TEXTAREA":if(!C.className||C.className.indexOf(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)==-1){return null}var D=C.className.split(this.behavior.CHOICE_VALUE_SELECTOR_PREFIX)[1].split(" ")[0];return D;break;default:return null;break}return null}