/* * Web Forms 2.0 Cross-browser Implementation * Version: 0.5.4 (2008-07-29) * Copyright: 2007, Weston Ruter * License: GNU General Public License, Free Software Foundation * * * The comments contained in this code are largely quotations from the * WebForms 2.0 specification: * * Usage: */ if(!window.$wf2){var $wf2={};if(document.implementation&&document.implementation.hasFeature&&!document.implementation.hasFeature("WebForms","2.0")){$wf2={version:"0.5.4",isInitialized:false,libpath:"",globalEvent:null,hasElementExtensions:window.HTMLElement&&HTMLElement.prototype,hasGettersAndSetters:$wf2.__defineGetter__&&$wf2.__defineSetter__,hasBadImplementation:navigator.userAgent.indexOf("WebKit"),callBeforeValidation:new Array,callAfterValidation:new Array,callAfterDOMContentLoaded:new Array, onDOMContentLoaded:function(){if($wf2.isInitialized)return;$wf2.isInitialized=true;var i,j,k,node;if(document.createEventObject)$wf2.globalEvent=document.createEventObject();else if(document.createEvent)$wf2.globalEvent=document.createEvent("HTMLEvents");var style=document.createElement("link");style.setAttribute("type","text/css");style.setAttribute("rel","stylesheet");style.setAttribute("href",$wf2.libpath+"webforms2.css");var parent=document.getElementsByTagName("head")[0];if(!parent)parent=document.getElementsByTagName("*")[0]; parent.insertBefore(style,parent.firstChild);$wf2.zeroPoint={};$wf2.zeroPoint.datetime=$wf2.parseISO8601("1970-01-01T00:00:00.0Z");$wf2.zeroPoint["datetime-local"]=$wf2.parseISO8601("1970-01-01T00:00:00.0");$wf2.zeroPoint.date=$wf2.zeroPoint.datetime;$wf2.zeroPoint.month=$wf2.zeroPoint.datetime;$wf2.zeroPoint.week=$wf2.parseISO8601("1970-W01");$wf2.zeroPoint.time=$wf2.zeroPoint.datetime;$wf2.xhr=null;if(window.XMLHttpRequest)$wf2.xhr=new XMLHttpRequest;else if(window.ActiveXObject)try{$wf2.xhr=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{$wf2.xhr= new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}if($wf2.xhr){$wf2.prefillSelectElements();$wf2.prefillFormElements()}$wf2.initRepetitionBlocks();$wf2.initRepetitionTemplates();$wf2.initRepetitionButtons("add");$wf2.initRepetitionButtons("remove");$wf2.initRepetitionButtons("move-up");$wf2.initRepetitionButtons("move-down");$wf2.updateAddButtons();$wf2.updateMoveButtons();if(document.addEventListener){document.addEventListener("mousedown",$wf2.clearInvalidIndicators,false);document.addEventListener("keydown", $wf2.clearInvalidIndicators,false)}else if(document.attachEvent){document.attachEvent("onmousedown",$wf2.clearInvalidIndicators);document.attachEvent("onkeydown",$wf2.clearInvalidIndicators)}$wf2.initNonRepetitionFunctionality();for(var i=0;i<$wf2.callAfterDOMContentLoaded.length;i++)$wf2.callAfterDOMContentLoaded[i]()},prefillSelectElements:function(){var select,selects=$wf2.getElementsByTagNames.apply(document.documentElement,["select","datalist"]);for(var i=0;select=selects[i];i++){var xmlDoc= $wf2.loadDataURI(select);if(xmlDoc&&xmlDoc.documentElement&&/:?\bselect$/i.test(xmlDoc.documentElement.nodeName)&&xmlDoc.documentElement.namespaceURI=="http://www.w3.org/1999/xhtml"){var root=xmlDoc.documentElement;if(root.getAttribute("type")!="incremental")while(select.lastChild)select.removeChild(select.lastChild);node=root.firstChild;while(node){select.appendChild($wf2.cloneNode(node));node=node.nextSibling}}}},prefillFormElements:function(){var frm,frms=document.getElementsByTagName("form"); for(var i=0;frm=frms[i];i++){var xmlDoc=$wf2.loadDataURI(frm);if(xmlDoc&&xmlDoc.documentElement&&/:?\bformdata$/.test(xmlDoc.documentElement.nodeName)&&xmlDoc.documentElement.namespaceURI=="http://n.whatwg.org/formdata"){var rt;var root=xmlDoc.documentElement;if(root.getAttribute("type")!="incremental")frm.reset();var clr,clrs=root.getElementsByTagName("clear");for(j=0;clr=clrs[j];j++)if(clr.namespaceURI=="http://n.whatwg.org/formdata"&&clr.parentNode==root&&!clr.firstChild&&(rt=document.getElementById(clr.getAttribute("template")))&& rt.getAttribute("repeat")=="template"){var attr,node,next;node=rt.parentNode.firstChild;while(node)if(node.nodeType==1&&(attr=node.getAttributeNode("repeat"))&&attr.value!="template"){next=node.nextSibling;node.parentNode.removeChild(node);node=next}else node=node.nextSibling}var index,rpt,rpts=root.getElementsByTagName("repeat");for(j=0;rpt=rpts[j];j++)if(rpt.namespaceURI=="http://n.whatwg.org/formdata"&&rpt.parentNode==root&&!rpt.firstChild&&(rt=document.getElementById(rpt.getAttribute("template")))&& rt.getAttribute("repeat")=="template"&&/^-?\d+$/.test(index=rpt.getAttribute("index"))){var hasIndex,attr,node,next;node=rt.parentNode.firstChild;while(node){if(node.nodeType==1&&(attr=node.getAttributeNode("repeat"))&&attr.value==index){hasIndex=true;break}node=node.nextSibling}if(!hasIndex)$wf2.addRepetitionBlockByIndex.apply(rt,[null,index])}var fld,flds=root.getElementsByTagName("field");var formElements=$wf2.getFormElements.apply(frm);for(j=0;fld=flds[j];j++){var indexAttr=fld.getAttributeNode("index"); var name=fld.getAttribute("name");if(!name||indexAttr&&!/^\d+$/.test(indexAttr.value))continue;var value="";for(k=0;node=fld.childNodes[k];k++)if(node.nodeType==3||node.nodeType==4)value+=node.data;else break;var ctrl,count=0;for(k=0;ctrl=formElements[k];k++)if(ctrl.type=="image"){if(ctrl.name?ctrl.name+".x"==name||ctrl.name+".y"==name:name=="x"||name=="y")if(!indexAttr||++count-1>=indexAttr.value)break}else if(ctrl.name==name){if(indexAttr){if(++count-1this.repetitionIndex)this.repetitionIndex=index;var IDAttrName=this.getAttribute("id")?"id":this.getAttribute("name")?"name":"";var IDAttrValue=this.getAttribute(IDAttrName);var block;var replaceValue=this.repetitionIndex;var reTemplateName, processAttr;if(IDAttrValue&&!/\u005B|\u02D1|\u005D|\u00B7/.test(IDAttrValue)){reTemplateName=new RegExp("(\\[|\u02d1)"+IDAttrValue+"(\\]|\u00b7)","g");processAttr=function(attrVal){if(!attrVal)return attrVal;attrVal=attrVal.toString();if(attrVal.indexOf("\ufeff")===0)return attrVal.replace(/^\uFEFF/,"");return attrVal.replace(reTemplateName,replaceValue)}}block=$wf2.cloneNode(this,processAttr);block.wf2Initialized=false;reTemplateName=null;block.setAttribute("repeat",this.repetitionIndex);block.removeAttribute("repeat-min"); block.removeAttribute("repeat-max");block.removeAttribute("repeat-start");if(IDAttrName){block.setAttribute("repeat-template",IDAttrValue);block.removeAttribute(IDAttrName)}if(!refNode){refNode=this;while(refNode.previousSibling&&refNode.previousSibling.repetitionType!=RepetitionElement.REPETITION_BLOCK)refNode=refNode.previousSibling;this.parentNode.insertBefore(block,refNode);this.repetitionBlocks.push(block)}else{refNode.parentNode.insertBefore(block,refNode.nextSibling);this.repetitionBlocks.push(block); if($wf2.sortNodes)this.repetitionBlocks.sort($wf2.sortNodes)}this.repetitionIndex++;$wf2.constructRepetitionBlock.apply(block);$wf2.initRepetitionTemplates(block);$wf2.initRepetitionButtons("add",block);$wf2.initRepetitionButtons("remove",block);$wf2.initRepetitionButtons("move-up",block);$wf2.initRepetitionButtons("move-down",block);if($wf2.isInitialized){$wf2.updateAddButtons(this);$wf2.updateMoveButtons(this.parentNode)}$wf2.initNonRepetitionFunctionality(block);var addEvt;try{if(document.createEvent)addEvt= document.createEvent("UIEvents");else if(document.createEventObject)addEvt=document.createEventObject();RepetitionEvent._upgradeEvent.apply(addEvt);addEvt.initRepetitionEvent("added",true,false,block);if(this.dispatchEvent)this.dispatchEvent(addEvt);else if(this.fireEvent);}catch(err){addEvt=new Object;RepetitionEvent._upgradeEvent.apply(addEvt);addEvt.initRepetitionEvent("added",true,false,block)}var handlerAttr;if((handlerAttr=this.getAttribute("onadded"))&&(!this.onadded||typeof this.onadded!= "function"))this.onadded=new Function("event",handlerAttr);else if((handlerAttr=this.getAttribute("onadd"))&&(!this.onadd||typeof this.onadd!="function"))this.onadd=new Function("event",handlerAttr);try{if(this.onadded)this.onadded.apply(this,[addEvt]);else if(this.onadd)this.onadd.apply(this,[addEvt])}catch(err){setTimeout(function(){throw err;},0)}return block},addRepetitionBlockByIndex:function(refNode,index){$wf2.addRepetitionBlock.apply(this,[refNode,index])},removeRepetitionBlock:function(){if(this.repetitionType!= RepetitionElement.REPETITION_BLOCK)throw $wf2.DOMException(9);var parentNode=this.parentNode;var block=parentNode.removeChild(this);$wf2.updateMoveButtons(parentNode);if(this.repetitionTemplate!=null)for(var i=0;i=t.repeatMax)btns[i].disabled=true},updateMoveButtons:function(parent){var i;var rbs=[];if(!parent){var visitedParents=[];rbs=$wf2.getElementsByTagNamesAndAttribute.apply(document.documentElement,[["*"],"repeat","template",true]);for(i=0;block=rbs[i];i++)if(!$wf2.arrayHasItem(visitedParents,block.parentNode)){$wf2.updateMoveButtons(block.parentNode); visitedParents.push(block.parentNode)}return}var j,btn,block;var child=parent.firstChild;while(child){if(child.repetitionType==RepetitionElement.REPETITION_BLOCK)rbs.push(child);child=child.nextSibling}for(i=0;block=rbs[i];i++){var moveUpBtns=$wf2.getElementsByTagNamesAndAttribute.apply(block,[["button"],"type","move-up"]);for(j=0;btn=moveUpBtns[j];j++)btn.disabled=!(rb=$wf2.getRepetitionBlock(btn))||i==0;var moveDownBtns=$wf2.getElementsByTagNamesAndAttribute.apply(block,[["button"],"type","move-down"]); for(j=0;btn=moveDownBtns[j];j++)btn.disabled=!(rb=$wf2.getRepetitionBlock(btn))||i==rbs.length-1}},initNonRepetitionFunctionality:function(parent){parent=parent||document.documentElement;var i,j,frm,frms=parent.getElementsByTagName("form");for(i=0;frm=frms[i];i++){if(frm.checkValidity&&!$wf2.hasBadImplementation)continue;frm.checkValidity=$wf2.formCheckValidity;if(frm.addEventListener)frm.addEventListener("submit",$wf2.onsubmitValidityHandler,false);else frm.attachEvent("onsubmit",$wf2.onsubmitValidityHandler)}var ctrl, ctrls=$wf2.getElementsByTagNames.apply(parent,["input","select","textarea","button"]);for(i=0;ctrl=ctrls[i];i++){$wf2.applyValidityInterface(ctrl);$wf2.updateValidityState(ctrl)}var els=$wf2.getElementsByTagNamesAndAttribute.apply(document.documentElement,[["*"],"autofocus"]);if(parent.getAttribute("autofocus"))els.unshift(parent);for(i=0;inode.max}else if(type=="file"){if(minAttrNode&&/^\d+$/.test(minAttrNode.value))node.min=Number(minAttrNode.value); else node.min=0;if(maxAttrNode&&/^\d+$/.test(maxAttrNode.value))node.max=Number(maxAttrNode.value);else node.max=1}else{if(minAttrNode){node.min=$wf2.parseISO8601(minAttrNode.value,type);node.validity.rangeUnderflow=node.min&&node.wf2Valuenode.max}}if(doCheckPrecision&&!node.validity.rangeUnderflow&&!node.validity.rangeOverflow){var stepAttrNode=$wf2.getOriginalAttrNode(node, "step");if(!stepAttrNode)node.step=isTimeRelated?60:1;else if(stepAttrNode.value=="any")node.step="any";else if($wf2.numberRegExp.test(stepAttrNode.value)&&stepAttrNode.value>0)node.step=Number(stepAttrNode.value);else node.step=isTimeRelated?60:1;if(node.step!="any"){node.wf2StepDatum=null;if(minAttrNode)node.wf2StepDatum=node.min;else if(maxAttrNode)node.wf2StepDatum=node.max;else node.wf2StepDatum=$wf2.zeroPoint[type]?$wf2.zeroPoint[type]:0;var _step=node.step;if(type=="month"&&node.wf2StepDatum&& node.wf2StepDatum.getUTCFullYear){var month1=node.wf2StepDatum.getUTCFullYear()*12+node.wf2StepDatum.getUTCMonth();var month2=node.wf2Value.getUTCFullYear()*12+node.wf2Value.getUTCMonth();node.validity.stepMismatch=(month2-month1)%_step!=0}else{switch(type){case "datetime":case "datetime-local":case "time":_step=parseInt(_step*1E3);break;case "date":_step=parseInt(_step*24*60*60*1E3);break;case "week":_step=parseInt(_step*7*24*60*60*1E3);break}node.validity.stepMismatch=Math.round((node.wf2Value- node.wf2StepDatum)*1E3)%Math.round(_step*1E3)!=0}}}}if(doMaxLengthCheck&&node.maxLength>=0&&node.value!=node.defaultValue){var shortNewlines=0;var v=node.value;node.wf2ValueLength=v.length;for(var i=1;inode.maxLength}}node.validity.valid=!$wf2.hasInvalidState(node.validity)},applyValidityInterface:function(node){if($wf2.hasBadImplementation){if(node.type== "submit"||node.type=="button")node.formNoValidate=true}else if(node.validity&&node.validity.typeMismatch!==undefined)return node;node.validationMessage="";node.validity=$wf2.createValidityState();node.willValidate=true;var nodeName=node.nodeName.toLowerCase();if(nodeName=="button"||nodeName=="fieldset"){node.setCustomValidity=function(error){throw $wf2.DOMException(9);};node.checkValidity=function(){return true};return node}if(!node.setCustomValidity)node.setCustomValidity=$wf2.controlSetCustomValidity; node.checkValidity=$wf2.controlCheckValidity;var type=node.getAttribute("type")?node.getAttribute("type").toLowerCase():node.type;if(/(hidden|button|reset|add|remove|move-up|move-down)/.test(type)||!node.name||node.disabled)node.willValidate=false;else if(window.RepetitionElement){var parent=node;while(parent=parent.parentNode)if(parent.repetitionType==RepetitionElement.REPETITION_TEMPLATE){node.willValidate=false;break}}return node},onsubmitValidityHandler:function(event){var frm=event.currentTarget|| event.srcElement;var r;for(var i=0;i<$wf2.callBeforeValidation.length;i++)$wf2.callBeforeValidation[i](event);if(!frm.checkValidity()){if(event.preventDefault)event.preventDefault();event.returnValue=false;r=false}else{event.returnValue=true;r=true}for(var i=0;i<$wf2.callAfterValidation.length;i++)$wf2.callAfterValidation[i](event,r);return r},controlSetCustomValidity:function(error){if(error){this.validationMessage=String(error);this.validity.customError=true}else{this.validationMessage="";this.validity.customError= false}this.validity.valid=!$wf2.hasInvalidState(this.validity)},hasInvalidState:function(validity){return validity.typeMismatch||validity.rangeUnderflow||validity.rangeOverflow||validity.stepMismatch||validity.tooLong||validity.patternMismatch||validity.valueMissing||validity.customError},createValidityState:function(){return{typeMismatch:false,rangeUnderflow:false,rangeOverflow:false,stepMismatch:false,tooLong:false,patternMismatch:false,valueMissing:false,customError:false,valid:true}},invalidIndicators:[], indicatorTimeoutId:null,indicatorIntervalId:null,stepUnits:{datetime:"second","datetime-local":"second",time:"second",date:"day",week:"week",month:"month"},invalidMessages:{valueMissing:"A value must be supplied or selected.",typeMismatch:"The value is invalid for %s type.",rangeUnderflow:"The value must be equal to or greater than %s.",rangeOverflow:"The value must be equal to or less than %s.",stepMismatch:"The value has a step mismatch; it must be a certain number multiples of %s from %s.",tooLong:"The value is too long. The field may have a maximum of %s characters but you supplied %s. Note that each line-break counts as two characters.", patternMismatch:"The value is not in the format required."},valueToWF2Type:function(value,type){switch(String(type).toLowerCase()){case "datetime":case "datetime-local":case "date":case "month":case "week":case "time":return $wf2.dateToISO8601(value,type);default:return value}},addInvalidIndicator:function(target){var msg=document.createElement("div");msg.className="wf2_errorMsg";msg.id=(target.id||target.name)+"_wf2_errorMsg";msg.onmousedown=function(){this.parentNode.removeChild(this)};var type= target.getAttribute("type")?target.getAttribute("type").toLowerCase():target.type;var isDateTimeRelated=type=="datetime"||type=="datetime-local"||type=="time"||type=="date"||type=="month"||type=="week";var ol=document.createElement("ol");if(target.validity.valueMissing)ol.appendChild($wf2.createLI($wf2.invalidMessages.valueMissing));if(target.validity.typeMismatch)ol.appendChild($wf2.createLI($wf2.invalidMessages.typeMismatch.replace(/%s/,type)));if(target.validity.rangeUnderflow)ol.appendChild($wf2.createLI($wf2.invalidMessages.rangeUnderflow.replace(/%s/, $wf2.valueToWF2Type(target.min,type))));if(target.validity.rangeOverflow)ol.appendChild($wf2.createLI($wf2.invalidMessages.rangeOverflow.replace(/%s/,$wf2.valueToWF2Type(target.max,type))));if(target.validity.stepMismatch)ol.appendChild($wf2.createLI($wf2.invalidMessages.stepMismatch.replace(/%s/,target.step+($wf2.stepUnits[type]?" "+$wf2.stepUnits[type]+"(s)":"")).replace(/%s/,$wf2.valueToWF2Type(target.wf2StepDatum,type))));if(target.validity.tooLong)ol.appendChild($wf2.createLI($wf2.invalidMessages.tooLong.replace(/%s/, target.maxLength).replace(/%s/,target.wf2ValueLength?target.wf2ValueLength:target.value.length)));if(target.validity.patternMismatch)ol.appendChild($wf2.createLI($wf2.invalidMessages.patternMismatch.replace(/%s/,target.title?target.title:' "'+target.getAttribute("pattern")+'"')));if(target.validity.customError)ol.appendChild($wf2.createLI(target.validationMessage));if(ol.childNodes.length==1)ol.className="single";msg.appendChild(ol);var parent=document.body?document.body:document.documentElement; if($wf2.invalidIndicators.length)parent.insertBefore(msg,$wf2.invalidIndicators[$wf2.invalidIndicators.length-1].errorMsg);else parent.insertBefore(msg,null);var el=target;while(el&&(el.nodeType!=1||el.style.display=="none"||el.style.visibility=="hidden"||!el.offsetParent))el=el.parentNode;var top=left=0;var cur=el;if(cur&&cur.offsetParent){left=cur.offsetLeft;top=cur.offsetTop;while(cur=cur.offsetParent){left+=cur.offsetLeft;top+=cur.offsetTop}top+=el.offsetHeight}msg.style.top=top+"px";msg.style.left= left+"px";$wf2.invalidIndicators.push({target:target,errorMsg:msg});if(!target.className.match(/\bwf2_invalid\b/))target.className+=" wf2_invalid";if($wf2.indicatorIntervalId==null){$wf2.indicatorIntervalId=setInterval(function(){var invalidIndicator;for(var i=0;invalidIndicator=$wf2.invalidIndicators[i];i++)if(!invalidIndicator.target.className.match(/\bwf2_invalid\b/))invalidIndicator.target.className+=" wf2_invalid";else invalidIndicator.target.className=invalidIndicator.target.className.replace(/\s?wf2_invalid/, "")},500);setTimeout(function(){for(var i=0;i<$wf2.callAfterValidation.length;i++)$wf2.callAfterValidation[i](null,false)},1);$wf2.indicatorTimeoutId=setTimeout($wf2.clearInvalidIndicators,4E3)}},clearInvalidIndicators:function(){clearTimeout($wf2.indicatorTimeoutId);$wf2.indicatorTimeoutId=null;clearInterval($wf2.indicatorIntervalId);$wf2.indicatorIntervalId=null;var invalidIndicator;while(invalidIndicator=$wf2.invalidIndicators[0]){if(invalidIndicator.errorMsg&&invalidIndicator.errorMsg.parentNode)invalidIndicator.errorMsg.parentNode.removeChild(invalidIndicator.errorMsg); var target=invalidIndicator.target;target.className=target.className.replace(/\s?wf2_invalid/,"");$wf2.invalidIndicators.shift()}},cloneNode_customAttrs:{type:1,template:1,repeat:1,"repeat-template":1,"repeat-min":1,"repeat-max":1,"repeat-start":1,value:1,"class":1,required:1,pattern:1,form:1,autocomplete:1,autofocus:1,inputmode:1,max:1,min:1,step:1,onmoved:1,onadded:1,onremoved:1,onadd:1,onremove:1,onmove:1},cloneNode_skippedAttrs:{name:1,"class":1,"for":1,style:1,checked:1,addRepetitionBlock:1, addRepetitionBlockByIndex:1,moveRepetitionBlock:1,removeRepetitionBlock:1,repetitionBlocks:1,setCustomValidity:1,checkValidity:1,validity:1,validationMessage:1,willValidate:1,wf2StepDatum:1,wf2Value:1,wf2Initialized:1,wf2ValueLength:1},cloneNode_rtEventHandlerAttrs:{onmoved:1,onadded:1,onremoved:1,onadd:1,onremove:1,onmove:1},cloneNode:function(node,processAttr,rtNestedDepth){if(!rtNestedDepth)rtNestedDepth=0;var clone,i,attr;switch(node.nodeType){case 1:var isTemplate=node.getAttribute("repeat")== "template";if(isTemplate)rtNestedDepth++;var attrs=[];if(node.name)attrs.name=processAttr?processAttr(node.name):node.name;if(node.type=="radio")attrs.type=node.type;if(node.checked)attrs.checked="checked";clone=$wf2.createElement(node.nodeName,attrs);for(i=0;attr=node.attributes[i];i++)if((attr.specified||$wf2.cloneNode_customAttrs[attr.name])&&!$wf2.cloneNode_skippedAttrs[attr.name]&&(!isTemplate||rtNestedDepth>1||!$wf2.cloneNode_rtEventHandlerAttrs[attr.name]))if(rtNestedDepth<2&&attr.name.indexOf("on")=== 0&&typeof node[attr.name]=="function"){var funcBody=processAttr(node[attr.name].toString().match(/{((?:.|\n)+)}/)[1]);funcBody=processAttr(funcBody);clone[attr.name]=new Function("event",funcBody)}else{var attrValue=node.getAttribute(attr.name);attrValue=processAttr?processAttr(attrValue):attrValue;clone.setAttribute(attr.name,attrValue)}if(node.className){var _className=processAttr?processAttr(node.className):node.className;if(clone.getAttributeNode("class"))for(i=0;i');if(el.tagName.toLowerCase()!="div"||el.name!="foo")throw"create element error";return function(tag,attrs){var html="<"+tag;for(var name in attrs)html+=" "+name+'="'+attrs[name]+'"';html+=">";if(tag.toLowerCase()!="input")html+="";return document.createElement(html)}}catch(err){return function(tag, attrs){var el=document.createElement(tag);for(var name in attrs)el.setAttribute(name,attrs[name]);return el}}}(),sortNodes:function(){var n=document.documentElement.firstChild;if(n.sourceIndex)return function(a,b){return a.sourceIndex-b.sourceIndex};else if(n.compareDocumentPosition)return function(a,b){return 3-(a.compareDocumentPosition(b)&6)}}(),createLI:function(text){var li=document.createElement("li");li.appendChild(document.createTextNode(text));return li},ISO8601RegExp:/^(?:(\d\d\d\d)-(W(0[1-9]|[1-4]\d|5[0-2])|(0\d|1[0-2])(-(0\d|[1-2]\d|3[0-1])(T(0\d|1\d|2[0-4]):([0-5]\d)(:([0-5]\d)(\.(\d+))?)?(Z)?)?)?)|(0\d|1\d|2[0-4]):([0-5]\d)(:([0-5]\d)(\.(\d+))?)?)$/, parseISO8601:function(str,type){var d=$wf2.validateDateTimeType(str,type);if(!d)return null;var date=new Date(0);var _timePos=8;if(d[15]){if(type&&type!="time")return null;_timePos=15}else{date.setUTCFullYear(d[1]);if(d[3]){if(type&&type!="week")return null;date.setUTCDate(date.getUTCDate()+(8-date.getUTCDay())%7+(d[3]-1)*7);return date}else{date.setUTCMonth(d[4]-1);if(d[6])date.setUTCDate(d[6])}}if(d[_timePos+0])date.setUTCHours(d[_timePos+0]);if(d[_timePos+1])date.setUTCMinutes(d[_timePos+1]);if(d[_timePos+ 2])date.setUTCSeconds(d[_timePos+3]);if(d[_timePos+4])date.setUTCMilliseconds(Math.round(Number(d[_timePos+4])*1E3));if(d[4]&&d[_timePos+0]&&!d[_timePos+6])date.setUTCMinutes(date.getUTCMinutes()+date.getTimezoneOffset());return date},validateDateTimeType:function(value,type){var isValid=false;var d=$wf2.ISO8601RegExp.exec(value);if(!d||!type)return d;type=type.toLowerCase();if(type=="week")isValid=d[2].toString().indexOf("W")===0;else if(type=="time")isValid=!!d[15];else if(type=="month")isValid= !d[5];else if(d[6]){var date=new Date(d[1],d[4]-1,d[6]);if(date.getMonth()!=d[4]-1)isValid=false;else switch(type){case "date":isValid=d[4]&&!d[7];break;case "datetime":isValid=!!d[14];break;case "datetime-local":isValid=d[7]&&!d[14];break}}return isValid?d:null},zeroPad:function(num,pad){if(!pad)pad=2;var str=num.toString();while(str.length<"+"/script>");document.write("<\/script>");var script=document.getElementById("__wf2_ie_onload");script.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);$wf2.onDOMContentLoaded();if($wf2.repetitionTemplates.length==0)$wf2.isInitialized=false}};script=null;eventSet=1}if(!eventSet)if(window.onload){var oldonload=window.onload;window.onload=function(){$wf2.onDOMContentLoaded(); oldonload()}}else window.onload=function(){$wf2.onDOMContentLoaded()}})()}else if(document.addEventListener&&($wf2.oldRepetitionEventModelEnabled===undefined||$wf2.oldRepetitionEventModelEnabled)){$wf2.oldRepetitionEventModelEnabled=true;(function(){var deprecatedAttrs={added:"onadd",removed:"onremove",moved:"onmove"};function handleRepetitionEvent(evt){if(!$wf2.oldRepetitionEventModelEnabled)return;if(!evt.element&&evt.relatedNode)evt.element=evt.relatedNode;if(!evt.element||!evt.element.repetitionTemplate)return; var rt=evt.element.repetitionTemplate;var attrName="on"+evt.type;var handlerAttr=rt.getAttribute(attrName)||rt.getAttribute(deprecatedAttrs[evt.type]);if(handlerAttr&&(!rt[attrName]||typeof rt[attrName]!="function"))rt[attrName]=new Function("event",handlerAttr);if(evt.element.repetitionTemplate[attrName])evt.element.repetitionTemplate[attrName](evt);else if(evt.element.repetitionTemplate[deprecatedAttrs[evt.type]])evt.element.repetitionTemplate[deprecatedAttrs[evt.type]](evt)}document.addEventListener("added", handleRepetitionEvent,false);document.addEventListener("removed",handleRepetitionEvent,false);document.addEventListener("moved",handleRepetitionEvent,false)})()}};