wf={
version:1.0};
wf.apply=function(o,c,defaults){
if(defaults){
wf.apply(o,defaults);}
if(o&&c&&typeof c=='object'){
for(var p in c){
o[p]=c[p];}}
return o;};(function(){
var idSeed=0;
var ua=navigator.userAgent.toLowerCase();
var isStrict=document.compatMode=="CSS1Compat",
isOpera=ua.indexOf("opera")>-1,
isSafari=(/webkit|khtml/).test(ua),
isIE=!isOpera&&ua.indexOf("msie")>-1,
isIE7=!isOpera&&ua.indexOf("msie 7")>-1,
isGecko=!isSafari&&ua.indexOf("gecko")>-1,
isBorderBox=isIE&&!isStrict,
isWindows=(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1),
isMac=(ua.indexOf("macintosh")!=-1||ua.indexOf("mac os x")!=-1),
isLinux=(ua.indexOf("linux")!=-1),
isSecure=window.location.href.toLowerCase().indexOf("https")===0;
if(isIE&&!isIE7){
try{
document.execCommand("BackgroundImageCache",false,true);}
catch(e){}}
wf.apply(wf,{
emptyFn:function(){},
isOpera:isOpera,
isSafari:isSafari,
isIE:isIE,
isIE6:isIE&&!isIE7,
isIE7:isIE7,
isGecko:isGecko,
isBorderBox:isBorderBox,
isLinux:isLinux,
isWindows:isWindows,
isMac:isMac,
isAir:!!window.htmlControl,
isStrict:isStrict,
isSecure:isSecure,
isReady:false,
enableListenerCollection:false,
enableGarbageCollector:true,
SSL_SECURE_URL:"javascript:false",
BLANK_IMAGE_URL:"/lib/images/default/s.gif",
applyIf:function(o,c){
if(o&&c){
for(var p in c){
if(typeof o[p]=="undefined"){o[p]=c[p];}}}
return o;},
escapeRe:function(s){
return s.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");},
execScript:function(html){
var hd=document.getElementsByTagName("head")[0];
var re=/(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
var srcRe=/\ssrc=([\'\"])(.*?)\1/i;
var typeRe=/\stype=([\'\"])(.*?)\1/i;
var match;
while(match=re.exec(html)){
var attrs=match[1];
var srcMatch=attrs?attrs.match(srcRe):false;
if(srcMatch&&srcMatch[2]){
var s=document.createElement("script");
s.src=srcMatch[2];
var typeMatch=attrs.match(typeRe);
if(typeMatch&&typeMatch[2]){
s.type=typeMatch[2];}
hd.appendChild(s);}else if(match[2]&&match[2].length>0){
if(window.execScript){
window.execScript(match[2]);}else{
window.eval(match[2]);}}}},
extend:function(){
var io=function(o){
for(var m in o){
this[m]=o[m];}};
return function(sb,sp,overrides){
if(typeof sp=='object'){
overrides=sp;
sp=sb;
sb=function(){sp.apply(this,arguments);};}
var F=function(){},sbp,spp=sp.prototype;
F.prototype=spp;
sbp=sb.prototype=new F();
sbp.constructor=sb;
sb.superclass=spp;
if(spp.constructor==Object.prototype.constructor){
spp.constructor=sp;}
sb.override=function(o){
wf.override(sb,o);};
sbp.override=io;
wf.override(sb,overrides);
return sb;};}(),
override:function(origclass,overrides){
if(overrides){
var p=origclass.prototype;
for(var method in overrides){
p[method]=overrides[method];}}},
id:function(el,prefix){
prefix=prefix||"wf";
el=wf.getDom(el);
var id=prefix+(++idSeed);
return el?(el.id?el.id:(el.id=id)):id;},
ns:function(){
var a=arguments,o=null,i,j,d,rt;
for(i=0;i<a.length;++i){
d=a[i].split(".");
rt=d[0];
eval('if (typeof '+rt+' == "undefined"){'+rt+' = {};} o = '+rt+';');
for(j=1;j<d.length;++j){
o[d[j]]=o[d[j]]||{};
o=o[d[j]];}}},
urlEncode:function(o){
if(!o){
return "";}
var buf=[];
for(var key in o){
var ov=o[key],k=encodeURIComponent(key);
var type=typeof ov;
if(type=='undefined'){
buf.push(k,"=&");}else if(type!="function"&&type!="object"){
buf.push(k,"=",encodeURIComponent(ov),"&");}else if(ov instanceof Array){
if(ov.length){
for(var i=0,len=ov.length;i<len;i++){
buf.push(k,"=",encodeURIComponent(ov[i]===undefined?'':ov[i]),"&");}}else{
buf.push(k,"=&");}}}
buf.pop();
return buf.join("");},
urlDecode:function(string,overwrite){
if(!string||!string.length){
return{};}
var obj={};
var pairs=string.split('&');
var pair,name,value;
for(var i=0,len=pairs.length;i<len;i++){
pair=pairs[i].split('=');
name=decodeURIComponent(pair[0]);
value=decodeURIComponent(pair[1]);
if(overwrite!==true){
if(typeof obj[name]=="undefined"){
obj[name]=value;}else if(typeof obj[name]=="string"){
obj[name]=[obj[name]];
obj[name].push(value);}else{
obj[name].push(value);}}else{
obj[name]=value;}}
return obj;},
callback:function(cb,scope,args,delay){
if(typeof cb=="function"){
if(delay){
cb.defer(delay,scope,args||[]);}else{
cb.apply(scope,args||[]);}}},
removeNode:isIE?function(){
var d;
return function(n){
if(n){
d=d||document.createElement('div');
d.appendChild(n);
d.innerHTML='';}}}():function(n){
if(n&&n.parentNode){
n.parentNode.removeChild(n);}},
getDom:function(el){
if(!el||!document){
return null;}
if(el.dom){
return el.dom;}
return typeof el=='string'?document.getElementById(el):el;},
getDoc:function(){
return wf.get(document);},
getBody:function(){
return wf.get(document.body||document.documentElement);}});})();
wf.ns("wf","wf.data","wf.lib","wf.layout","wf.form","wf.util","wf.grid","wf.tree");
wf.apply(Function.prototype,{
createCallback:function(){
var args=arguments;
var method=this;
return function(){
return method.apply(window,args);};},
createDelegate:function(obj,args,appendArgs){
var method=this;
return function(){
var callArgs=args||arguments;
if(appendArgs===true){
callArgs=Array.prototype.slice.call(arguments,0);
callArgs=callArgs.concat(args);}else if(typeof appendArgs=="number"){
callArgs=Array.prototype.slice.call(arguments,0);
var applyArgs=[appendArgs,0].concat(args);
Array.prototype.splice.apply(callArgs,applyArgs);}
return method.apply(obj||window,callArgs);};},
defer:function(millis,obj,args,appendArgs){
var fn=this.createDelegate(obj,args,appendArgs);
if(millis){
return setTimeout(fn,millis);}
fn();
return 0;}});
wf.apply(String,{
escape:function(string){
return string.replace(/('|\\)/g,"\\$1");},
leftPad:function(val,size,ch){
var result=new String(val);
if(ch===null||ch===undefined||ch===''){
ch=" ";}
while(result.length<size){
result=ch+result;}
return result;},
format:function(format){
var args=Array.prototype.slice.call(arguments,1);
return format.replace(/\{(\d+)\}/g,function(m,i){
return args[i];});}});
wf.applyIf(Array.prototype,{
indexOf:function(o){
for(var i=0,len=this.length;i<len;i++){
if(this[i]==o)
return i;}
return -1;},
remove:function(o){
var index=this.indexOf(o);
if(index!=-1){
this.splice(index,1);}
return this;}});
wf.json=new(function(){
var useHasOwn={}.hasOwnProperty?true:false;
var pad=function(n){
return n<10?"0"+n:n;};
var m={
"\b":'\\b',
"\t":'\\t',
"\n":'\\n',
"\f":'\\f',
"\r":'\\r',
'"':'\\"',
"\\":'\\\\'};
var encodeString=function(s){
if(/["\\\x00-\x1f]/.test(s)){
return '"'+
s.replace(/([\x00-\x1f\\"])/g,function(a,b){
var c=m[b];
if(c){
return c;}
c=b.charCodeAt();
return "\\u00"+
Math.floor(c/16).toString(16)+(c%16).toString(16);})+
'"';}
return '"'+s+'"';};
var encodeArray=function(o){
var a=["["],b,i,l=o.length,v;
for(i=0;i<l;i+=1){
v=o[i];
switch(typeof v){
case "undefined":
case "function":
case "unknown":
break;
default:
if(b){
a.push(',');}
a.push(v===null?"null":wf.json.encode(v));
b=true;}}
a.push("]");
return a.join("");};
var encodeDate=function(o){
return '"'+o.getFullYear()+"-"+
pad(o.getMonth()+1)+
"-"+
pad(o.getDate())+
"T"+
pad(o.getHours())+
":"+
pad(o.getMinutes())+
":"+
pad(o.getSeconds())+
'"';};
this.encode=function(o){
if(typeof o=="undefined"||o===null){
return "null";}
else
if(o instanceof Array){
return encodeArray(o);}
else
if(o instanceof Date){
return encodeDate(o);}
else
if(typeof o=="string"){
return encodeString(o);}
else
if(typeof o=="number"){
return isFinite(o)?String(o):"null";}
else
if(typeof o=="boolean"){
return String(o);}
else{
var a=["{"],b,i,v;
for(i in o){
if(!useHasOwn||o.hasOwnProperty(i)){
v=o[i];
switch(typeof v){
case "undefined":
case "function":
case "unknown":
break;
default:
if(b){
a.push(',');}
a.push(this.encode(i),":",v===null?"null":this.encode(v));
b=true;}}}
a.push("}");
return a.join("");}};
this.decode=function(json){
return eval("("+json+')');};})();
wf.encode=wf.json.encode;
wf.decode=wf.json.decode;
wf.lib.Ajax={
defaultPostHeader:'application/x-www-form-urlencoded',
defaultXhrHeader:'XMLHttpRequest',
defaultHeaders:{},
headers:{},
hasDefaultHeaders:true,
hasHeaders:false,
useDefaultHeader:true,
useDefaultXhrHeader:true,
poll:{},
timeout:{},
pollInterval:50,
transactionId:0,
request:function(method,url,cb,data,options){
if(options){
var hs=options.headers;
if(hs){
for(var h in hs){
if(hs.hasOwnProperty(h)){
this.initHeader(h,hs[h],false);}}}
if(options.xmlData){
this.initHeader('Content-Type','text/xml',false);
method='POST';
data=options.xmlData;}
else
if(options.jsonData){
this.initHeader('Content-Type','text/javascript',false);
method='POST';
data=typeof options.jsonData=='object'?wf.encode(options.jsonData):options.jsonData;}}
return this.asyncRequest(method,url,cb,data);},
serializeForm:function(form){
if(typeof form=='string'){
form=(document.getElementById(form)||document.forms[form]);}
var el,name,val,disabled,data='',hasSubmit=false;
for(var i=0;i<form.elements.length;i++){
el=form.elements[i];
disabled=form.elements[i].disabled;
name=form.elements[i].name;
val=form.elements[i].value;
if(!disabled&&name){
switch(el.type){
case 'select-one':
case 'select-multiple':
for(var j=0;j<el.options.length;j++){
if(el.options[j].selected){
if(wf.isIE){
data+=encodeURIComponent(name)+'='+encodeURIComponent(el.options[j].attributes['value'].specified?el.options[j].value:el.options[j].text)+'&';}
else{
data+=encodeURIComponent(name)+'='+encodeURIComponent(el.options[j].hasAttribute('value')?el.options[j].value:el.options[j].text)+'&';}}}
break;
case 'radio':
case 'checkbox':
if(el.checked){
data+=encodeURIComponent(name)+'='+encodeURIComponent(val)+'&';}
break;
case 'file':
case undefined:
case 'reset':
case 'button':
break;
case 'submit':
if(hasSubmit==false){
data+=encodeURIComponent(name)+'='+encodeURIComponent(val)+'&';
hasSubmit=true;}
break;
default:
data+=encodeURIComponent(name)+'='+encodeURIComponent(val)+'&';
break;}}}
data=data.substr(0,data.length-1);
return data;},
createXhrObject:function(transactionId){
var obj,http;
try{
http=new XMLHttpRequest();
obj={
conn:http,
tId:transactionId};}
catch(e){
for(var i=0;i<this.activeX.length;++i){
try{
http=new ActiveXObject(this.activeX[i]);
obj={
conn:http,
tId:transactionId};
break;}
catch(e){}}}
finally{
return obj;}},
getConnectionObject:function(){
var o;
var tId=this.transactionId;
try{
o=this.createXhrObject(tId);
if(o){
this.transactionId++;}}
catch(e){}
finally{
return o;}},
asyncRequest:function(method,uri,callback,postData){
var o=this.getConnectionObject();
if(!o){
return null;}
else{
o.conn.open(method,uri,true);
if(this.useDefaultXhrHeader){
if(!this.defaultHeaders['X-Requested-With']){
this.initHeader('X-Requested-With',this.defaultXhrHeader,true);}}
if(postData&&this.useDefaultHeader){
this.initHeader('Content-Type',this.defaultPostHeader);}
if(this.hasDefaultHeaders||this.hasHeaders){
this.setHeader(o);}
this.handleReadyState(o,callback);
o.conn.send(postData||null);
return o;}},
handleReadyState:function(o,callback){
var oConn=this;
if(callback&&callback.timeout){
this.timeout[o.tId]=window.setTimeout(function(){
oConn.abort(o,callback,true);},callback.timeout);}
this.poll[o.tId]=window.setInterval(function(){
if(o.conn&&o.conn.readyState==4){
window.clearInterval(oConn.poll[o.tId]);
delete oConn.poll[o.tId];
if(callback&&callback.timeout){
window.clearTimeout(oConn.timeout[o.tId]);
delete oConn.timeout[o.tId];}
oConn.handleTransactionResponse(o,callback);}},this.pollInterval);},
handleTransactionResponse:function(o,callback,isAbort){
if(!callback){
this.releaseObject(o);
return;}
var httpStatus,responseObject;
try{
if(o.conn.status!==undefined&&o.conn.status!=0){
httpStatus=o.conn.status;}
else{
httpStatus=13030;}}
catch(e){
httpStatus=13030;}
if(httpStatus>=200&&httpStatus<300){
responseObject=this.createResponseObject(o,callback.argument);
if(callback.success){
if(!callback.scope){
callback.success(responseObject);}
else{
callback.success.apply(callback.scope,[responseObject]);}}}
else{
switch(httpStatus){
case 12002:
case 12029:
case 12030:
case 12031:
case 12152:
case 13030:
responseObject=this.createExceptionObject(o.tId,callback.argument,(isAbort?isAbort:false));
if(callback.failure){
if(!callback.scope){
callback.failure(responseObject);}
else{
callback.failure.apply(callback.scope,[responseObject]);}}
break;
default:
responseObject=this.createResponseObject(o,callback.argument);
if(callback.failure){
if(!callback.scope){
callback.failure(responseObject);}
else{
callback.failure.apply(callback.scope,[responseObject]);}}}}
this.releaseObject(o);
responseObject=null;},
createResponseObject:function(o,callbackArg){
var obj={};
var headerObj={};
try{
var headerStr=o.conn.getAllResponseHeaders();
var header=headerStr.split('\n');
for(var i=0;i<header.length;i++){
var delimitPos=header[i].indexOf(':');
if(delimitPos!=-1){
headerObj[header[i].substring(0,delimitPos)]=header[i].substring(delimitPos+2);}}}
catch(e){}
obj.tId=o.tId;
obj.status=o.conn.status;
obj.statusText=o.conn.statusText;
obj.getResponseHeader=headerObj;
obj.getAllResponseHeaders=headerStr;
obj.responseText=o.conn.responseText;
obj.responseXML=o.conn.responseXML;
if(typeof callbackArg!==undefined){
obj.argument=callbackArg;}
return obj;},
createExceptionObject:function(tId,callbackArg,isAbort){
var COMM_CODE=0;
var COMM_ERROR='communication failure';
var ABORT_CODE=-1;
var ABORT_ERROR='transaction aborted';
var obj={};
obj.tId=tId;
if(isAbort){
obj.status=ABORT_CODE;
obj.statusText=ABORT_ERROR;}
else{
obj.status=COMM_CODE;
obj.statusText=COMM_ERROR;}
if(callbackArg){
obj.argument=callbackArg;}
return obj;},
initHeader:function(label,value,isDefault){
var headerObj=(isDefault)?this.defaultHeaders:this.headers;
if(headerObj[label]===undefined){
headerObj[label]=value;}
else{
headerObj[label]=value+","+headerObj[label];}
if(isDefault){
this.hasDefaultHeaders=true;}
else{
this.hasHeaders=true;}},
setHeader:function(o){
if(this.hasDefaultHeaders){
for(var prop in this.defaultHeaders){
if(this.defaultHeaders.hasOwnProperty(prop)){
o.conn.setRequestHeader(prop,this.defaultHeaders[prop]);}}}
if(this.hasHeaders){
for(var prop in this.headers){
if(this.headers.hasOwnProperty(prop)){
o.conn.setRequestHeader(prop,this.headers[prop]);}}
this.headers={};
this.hasHeaders=false;}},
resetDefaultHeaders:function(){
delete this.defaultHeaders;
this.defaultHeaders={};
this.hasDefaultHeaders=false;},
abort:function(o,callback,isTimeout){
if(this.isCallInProgress(o)){
o.conn.abort();
window.clearInterval(this.poll[o.tId]);
delete this.poll[o.tId];
if(isTimeout){
delete this.timeout[o.tId];}
this.handleTransactionResponse(o,callback,true);
return true;}
else{
return false;}},
isCallInProgress:function(o){
if(o.conn){
return o.conn.readyState!=4&&o.conn.readyState!=0;}
else{
return false;}},
releaseObject:function(o){
o.conn=null;
o=null;},
activeX:['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP']};
var libFlyweight;
function fly(el){
if(!libFlyweight){
libFlyweight=new wf.Element.Flyweight();}
libFlyweight.dom=el;
return libFlyweight;};
wf.lib.Region=function(t,r,b,l){
this.top=t;
this.right=r;
this.bottom=b;
this.left=l;};
wf.lib.Region.prototype={
contains:function(region){
return(region.left>=this.left&&
region.right<=this.right&&
region.top>=this.top&&
region.bottom<=this.bottom);},
adjust:function(t,l,b,r){
this.top+=t;
this.left+=l;
this.right+=r;
this.bottom+=b;
return this;}};
wf.lib.Region.getRegion=function(el){
var el=wf.getDom(el);
var p=wf.lib.Dom.getXY(el);
var t=p[1];
var r=p[0]+el.offsetWidth;
var b=p[1]+el.offsetHeight;
var l=p[0];
return new wf.lib.Region(t,r,b,l);};
wf.lib.Point=function(x,y){
if(x instanceof Array){
y=x[1];
x=x[0];}
this.x=this.right=this.left=this[0]=x;
this.y=this.top=this.bottom=this[1]=y;};
wf.lib.Point.prototype=new wf.lib.Region();
wf.lib.Dom={
getViewWidth:function(full){
var w,w2;
if(wf.isIE){
w=wf.isStrict?document.documentElement.clientWidth:document.body.clientWidth;}else{
w=self.innerWidth;}
if(full){
w2=wf.isStrict?document.documentElement.scrollWidth:document.body.scrollWidth;
return Math.max(w2,w);}else{
return w;}},
getViewHeight:function(full){
var h,h2;
if(wf.isIE){
h=wf.isStrict?document.documentElement.clientHeight:document.body.clientHeight;}else{
h=self.innerHeight;}
if(full){
h2=wf.isStrict?document.documentElement.scrollHeight:document.body.scrollHeight;
return Math.max(h2,h);}else{
return h;}},
getXY:function(el){
var p,pe,b,scroll,bd=(document.body||document.documentElement);
el=wf.getDom(el);
if(el==bd){
return[0,0];}
if(el.getBoundingClientRect){
b=el.getBoundingClientRect();
scroll=fly(document).getScroll();
return[b.left+scroll.left,b.top+scroll.top];}
var x=0,y=0;
p=el;
var hasAbsolute=fly(el).getStyle("position")=="absolute";
while(p){
x+=p.offsetLeft;
y+=p.offsetTop;
if(!hasAbsolute&&fly(p).getStyle("position")=="absolute"){
hasAbsolute=true;}
if(wf.isGecko){
pe=fly(p);
var bt=parseInt(pe.getStyle("borderTopWidth"),10)||0;
var bl=parseInt(pe.getStyle("borderLeftWidth"),10)||0;
x+=bl;
y+=bt;
if(p!=el&&pe.getStyle('overflow')!='visible'){
x+=bl;
y+=bt;}}
p=p.offsetParent;}
if(wf.isSafari&&hasAbsolute){
x-=bd.offsetLeft;
y-=bd.offsetTop;}
if(wf.isGecko&&!hasAbsolute){
var dbd=fly(bd);
x+=parseInt(dbd.getStyle("borderLeftWidth"),10)||0;
y+=parseInt(dbd.getStyle("borderTopWidth"),10)||0;}
p=el.parentNode;
while(p&&p!=bd){
if(!wf.isOpera||(p.tagName!='TR'&&fly(p).getStyle("display")!="inline")){
x-=p.scrollLeft;
y-=p.scrollTop;}
p=p.parentNode;}
return[x,y];},
setXY:function(el,xy){
el=wf.fly(el,'_setXY');
el.position();
var pts=el.translatePoints(xy);
if(xy[0]!==false){
el.dom.style.left=pts.left+"px";}
if(xy[1]!==false){
el.dom.style.top=pts.top+"px";}}};
wf.lib.Event=function(){
var loadComplete=false;
var listeners=[];
var unloadListeners=[];
var retryCount=0;
var onAvailStack=[];
var counter=0;
var lastError=null;
return{
POLL_RETRYS:200,
POLL_INTERVAL:20,
EL:0,
TYPE:1,
FN:2,
WFN:3,
OBJ:3,
ADJ_SCOPE:4,
_interval:null,
startInterval:function(){
if(!this._interval){
var self=this;
var callback=function(){
self._tryPreloadAttach();};
this._interval=setInterval(callback,this.POLL_INTERVAL);}},
onAvailable:function(p_id,p_fn,p_obj,p_override){
onAvailStack.push({id:p_id,
fn:p_fn,
obj:p_obj,
override:p_override,
checkReady:false});
retryCount=this.POLL_RETRYS;
this.startInterval();},
on:function(el,eventName,fn){
el=wf.getDom(el);
if(!el||!fn){
return false;}
if("unload"==eventName){
unloadListeners[unloadListeners.length]=[el,eventName,fn];
return true;}
var wrappedFn=function(e){
return typeof wf!='undefined'?fn(wf.lib.Event.getEvent(e)):false;};
var li=[el,eventName,fn,wrappedFn];
var index=listeners.length;
listeners[index]=li;
this.doAdd(el,eventName,wrappedFn,false);
return true;},
un:function(el,eventName,fn){
var i,len;
el=wf.getDom(el);
if(!fn){
return this.purgeElement(el,false,eventName);}
if("unload"==eventName){
for(i=0,len=unloadListeners.length;i<len;i++){
var li=unloadListeners[i];
if(li&&
li[0]==el&&
li[1]==eventName&&
li[2]==fn){
unloadListeners.splice(i,1);
return true;}}
return false;}
var cacheItem=null;
var index=arguments[3];
if("undefined"==typeof index){
index=this._getCacheIndex(el,eventName,fn);}
if(index>=0){
cacheItem=listeners[index];}
if(!el||!cacheItem){
return false;}
this.doRemove(el,eventName,cacheItem[this.WFN],false);
delete listeners[index][this.WFN];
delete listeners[index][this.FN];
listeners.splice(index,1);
return true;},
getTarget:function(ev){
ev=ev.browserEvent||ev;
var t=ev.target||ev.srcElement;
return this.resolveTextNode(t);},
resolveTextNode:function(node){
if(wf.isSafari&&node&&3==node.nodeType){
return node.parentNode;}else{
return node;}},
getXY:function(ev){
ev=ev.browserEvent||ev;
var x=ev.pageX;
var y=ev.pageY;
if(!x&&0!==x){
x=ev.clientX||0;
if(wf.isIE){
x+=this.getScroll()[1];}}
if(!y&&0!==y){
y=ev.clientY||0;
if(wf.isIE){
y+=this.getScroll()[0];}}
return[x,y];},
stopEvent:function(ev){
this.stopPropagation(ev);
this.preventDefault(ev);},
stopPropagation:function(ev){
ev=ev.browserEvent||ev;
if(ev.stopPropagation){
ev.stopPropagation();}else{
ev.cancelBubble=true;}},
preventDefault:function(ev){
ev=ev.browserEvent||ev;
if(ev.preventDefault){
ev.preventDefault();}else{
ev.returnValue=false;}},
getEvent:function(e){
var ev=e||window.event;
if(!ev){
var c=this.getEvent.caller;
while(c){
ev=c.arguments[0];
if(ev&&Event==ev.constructor){
break;}
c=c.caller;}}
return ev;},
getCharCode:function(ev){
ev=ev.browserEvent||ev;
return ev.charCode||ev.keyCode||0;},
purgeElement:function(el,recurse,eventName){
var elListeners=this.getListeners(el,eventName);
if(elListeners){
for(var i=0,len=elListeners.length;i<len;++i){
var l=elListeners[i];
this.un(el,l.type,l.fn);}}
if(recurse&&el&&el.childNodes){
for(i=0,len=el.childNodes.length;i<len;++i){
this.purgeElement(el.childNodes[i],recurse,eventName);}}},
getListeners:function(el,eventName){
var results=[],searchLists;
if(!eventName){
searchLists=[listeners,unloadListeners];}else if(eventName=="unload"){
searchLists=[unloadListeners];}else{
searchLists=[listeners];}
for(var j=0;j<searchLists.length;++j){
var searchList=searchLists[j];
if(searchList&&searchList.length>0){
for(var i=0,len=searchList.length;i<len;++i){
var l=searchList[i];
if(l&&l[this.EL]===el&&(!eventName||eventName===l[this.TYPE])){
results.push({
type:l[this.TYPE],
fn:l[this.FN],
obj:l[this.OBJ],
adjust:l[this.ADJ_SCOPE],
index:i});}}}}
return(results.length)?results:null;},
_getCacheIndex:function(el,eventName,fn){
for(var i=0,len=listeners.length;i<len;++i){
var li=listeners[i];
if(li&&
li[this.FN]==fn&&
li[this.EL]==el&&
li[this.TYPE]==eventName){
return i;}}
return -1;},
_tryPreloadAttach:function(){
if(this.locked){
return false;}
this.locked=true;
var tryAgain=!loadComplete;
if(!tryAgain){
tryAgain=(retryCount>0);}
var notAvail=[];
for(var i=0,len=onAvailStack.length;i<len;++i){
var item=onAvailStack[i];
if(item){
var el=wf.getDom(item.id);
if(el){
if(!item.checkReady||loadComplete||
el.nextSibling||(document&&document.body)){
var scope=el;
if(item.override){
if(item.override===true){
scope=item.obj;}else{
scope=item.override;}}
item.fn.call(scope,item.obj);
onAvailStack[i]=null;}}else{
notAvail.push(item);}}}
retryCount=(notAvail.length===0)?0:retryCount-1;
if(tryAgain){
this.startInterval();}else{
clearInterval(this._interval);
this._interval=null;}
this.locked=false;
return true;},
_load:function(e){
loadComplete=true;
var EU=wf.lib.Event;
if(wf.isIE){
EU.doRemove(window,"load",EU._load);}},
_unload:function(e){
var EU=wf.lib.Event,i,j,l,len,index;
for(i=0,len=unloadListeners.length;i<len;++i){
l=unloadListeners[i];
if(l){
var scope=window;
if(l[EU.ADJ_SCOPE]){
if(l[EU.ADJ_SCOPE]===true){
scope=l[EU.OBJ];}else{
scope=l[EU.ADJ_SCOPE];}}
l[EU.FN].call(scope,EU.getEvent(e),l[EU.OBJ]);
unloadListeners[i]=null;
l=null;
scope=null;}}
unloadListeners=null;
if(listeners&&listeners.length>0){
j=listeners.length;
while(j){
index=j-1;
l=listeners[index];
if(l){
EU.un(l[EU.EL],l[EU.TYPE],
l[EU.FN],index);}
j=j-1;}
l=null;}
EU.doRemove(window,"unload",EU._unload);},
getScroll:function(){
var dd=document.documentElement,db=document.body;
if(dd&&(dd.scrollTop||dd.scrollLeft)){
return[dd.scrollTop,dd.scrollLeft];}else if(db){
return[db.scrollTop,db.scrollLeft];}else{
return[0,0];}},
doAdd:function(){
if(window.addEventListener){
return function(el,eventName,fn,capture){
el.addEventListener(eventName,fn,(capture));};}else if(window.attachEvent){
return function(el,eventName,fn,capture){
el.attachEvent("on"+eventName,fn);};}else{
return function(){};}}(),
doRemove:function(){
if(window.removeEventListener){
return function(el,eventName,fn,capture){
el.removeEventListener(eventName,fn,(capture));};}else if(window.detachEvent){
return function(el,eventName,fn){
el.detachEvent("on"+eventName,fn);};}else{
return function(){};}}()}}();
var E=wf.lib.Event;
if(document&&document.body){
E._load();}else{
E.doAdd(window,"load",E._load);}
E.doAdd(window,"unload",E._unload);
E._tryPreloadAttach();
wf.Observable=function(){
if(this.listeners){
this.on(this.listeners);
delete this.listeners;}};
wf.Observable.prototype={
fireEvent:function(){
if(this.eventsSuspended!==true){
var ce=this.events[arguments[0].toLowerCase()];
if(typeof ce=="object"){
return ce.fire.apply(ce,Array.prototype.slice.call(arguments,1));}}
return true;},
filterOptRe:/^(?:scope|delay|single)$/,
on:function(eventName,fn,scope,o){
if(typeof eventName=="object"){
o=eventName;
for(var e in o){
if(this.filterOptRe.test(e)){
continue;}
if(typeof o[e]=="function"){
this.on(e,o[e],o.scope,o);}else{
this.on(e,o[e].fn,o[e].scope,o[e]);}}
return;}
o=(!o||typeof o=="boolean")?{}:o;
eventName=eventName.toLowerCase();
var ce=this.events[eventName]||true;
if(typeof ce=="boolean"){
ce=new wf.Event(this,eventName);
this.events[eventName]=ce;}
ce.on(fn,scope,o);},
un:function(eventName,fn,scope){
var ce=this.events[eventName.toLowerCase()];
if(typeof ce=="object"){
ce.un(fn,scope);}},
purgeListeners:function(){
for(var evt in this.events){
if(typeof this.events[evt]=="object"){
this.events[evt].clearListeners();}}},
addEvents:function(o){
if(!this.events){
this.events={};}
if(typeof o=='string'){
for(var i=0,a=arguments,v;v=a[i];i++){
if(!this.events[a[i]]){
o[a[i]]=true;}}}else{
wf.applyIf(this.events,o);}},
suspendEvents:function(){
this.eventsSuspended=true;},
resumeEvents:function(){
this.eventsSuspended=false;}};(function(){
var createSingle=function(h,e,fn,scope){
return function(){
e.un(fn,scope);
return h.apply(scope,arguments);};};
var createDelayed=function(h,o,scope){
return function(){
var args=Array.prototype.slice.call(arguments,0);
setTimeout(function(){
h.apply(scope,args);},o.delay||10);};};
wf.Event=function(obj,name){
this.name=name;
this.obj=obj;
this.listeners=[];};
wf.Event.prototype={
on:function(fn,scope,options){
scope=scope||this.obj;
if(!this.isListening(fn,scope)){
var l=this.createListener(fn,scope,options);
if(!this.firing){
this.listeners.push(l);}else{
this.listeners=this.listeners.slice(0);
this.listeners.push(l);}}},
un:function(fn,scope){
var index;
if((index=this.findListener(fn,scope))!=-1){
if(!this.firing){
this.listeners.splice(index,1);}else{
this.listeners=this.listeners.slice(0);
this.listeners.splice(index,1);}
return true;}
return false;},
fire:function(){
var ls=this.listeners,scope,len=ls.length;
if(len>0){
this.firing=true;
var args=Array.prototype.slice.call(arguments,0);
for(var i=0;i<len;i++){
var l=ls[i];
if(l.fireFn.apply(l.scope||this.obj||window,arguments)===false){
this.firing=false;
return false;}}
this.firing=false;}
return true;},
clearListeners:function(){
this.listeners=[];},
createListener:function(fn,scope,o){
o=o||{};
scope=scope||this.obj;
var l={fn:fn,scope:scope,options:o};
var h=fn;
if(o.delay){
h=createDelayed(h,o,scope);}
if(o.single){
h=createSingle(h,this,fn,scope);}
l.fireFn=h;
return l;},
findListener:function(fn,scope){
scope=scope||this.obj;
var ls=this.listeners;
for(var i=0,len=ls.length;i<len;i++){
var l=ls[i];
if(l.fn==fn&&l.scope==scope){
return i;}}
return -1;},
isListening:function(fn,scope){
return this.findListener(fn,scope)!=-1;}}})();
wf.EventManager=function(){
var docReadyEvent,docReadyProcId,docReadyState=false;
var E=wf.lib.Event;
var fireDocReady=function(){
if(!docReadyState){
docReadyState=true;
wf.isReady=true;
if(docReadyProcId){
clearInterval(docReadyProcId);}
if(wf.isGecko||wf.isOpera){
document.removeEventListener("DOMContentLoaded",fireDocReady,false);}
if(wf.isIE){
var defer=document.getElementById("ie-deferred-loader");
if(defer){
defer.onreadystatechange=null;
defer.parentNode.removeChild(defer);}}
if(docReadyEvent){
docReadyEvent.fire();
docReadyEvent.clearListeners();}}};
var initDocReady=function(){
docReadyEvent=new wf.Event();
if(wf.isGecko||wf.isOpera){
document.addEventListener("DOMContentLoaded",fireDocReady,false);}else if(wf.isIE){
document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
var defer=document.getElementById("ie-deferred-loader");
defer.onreadystatechange=function(){
if(this.readyState=="complete"){
fireDocReady();}};}else if(wf.isSafari){
docReadyProcId=setInterval(function(){
var rs=document.readyState;
if(rs=="complete"){
fireDocReady();}},10);}
E.on(window,"load",fireDocReady);};
var createSingle=function(h,el,ename,fn){
return function(e){
wf.EventManager.un(el,ename,fn);
h(e);};};
var createDelayed=function(h,o){
return function(e){
e=new wf.EventObjectImpl(e);
setTimeout(function(){
h(e);},o.delay||10);};};
var listen=function(element,ename,opt,fn,scope){
var o=(!opt||typeof opt=="boolean")?{}:opt;
fn=fn||o.fn;scope=scope||o.scope;
var el=wf.getDom(element);
if(!el){
throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';}
var h=function(e){
e=wf.EventObject.setEvent(e);
var t;
if(o.delegate){
t=e.getTarget(o.delegate,el);
if(!t){
return;}}else{
t=e.target;}
if(o.stopEvent===true){
e.stopEvent();}
if(o.preventDefault===true){
e.preventDefault();}
if(o.stopPropagation===true){
e.stopPropagation();}
if(o.normalized===false){
e=e.browserEvent;}
fn.call(scope||el,e,t,o);};
if(o.delay){
h=createDelayed(h,o);}
if(o.single){
h=createSingle(h,el,ename,fn);}
fn._handlers=fn._handlers||[];
fn._handlers.push([wf.id(el),ename,h]);
E.on(el,ename,h);
if(ename=="mousewheel"&&el.addEventListener){
el.addEventListener("DOMMouseScroll",h,false);
E.on(window,'unload',function(){
el.removeEventListener("DOMMouseScroll",h,false);});}
if(ename=="mousedown"&&el==document){
wf.EventManager.stoppedMouseDownEvent.on(h);}
return h;};
var stopListening=function(el,ename,fn){
var id=wf.id(el),hds=fn._handlers,hd=fn;
if(hds){
for(var i=0,len=hds.length;i<len;i++){
var h=hds[i];
if(h[0]==id&&h[1]==ename){
hd=h[2];
hds.splice(i,1);
break;}}}
E.un(el,ename,hd);
el=wf.get(el);
if(ename=="mousewheel"&&el.addEventListener){
el.removeEventListener("DOMMouseScroll",hd,false);}
if(ename=="mousedown"&&el==document){
wf.EventManager.stoppedMouseDownEvent.un(hd);}};
var propRe=/^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
var pub={
on:function(element,eventName,fn,scope,options){
if(typeof eventName=="object"){
var o=eventName;
for(var e in o){
if(propRe.test(e)){
continue;}
if(typeof o[e]=="function"){
listen(element,e,o,o[e],o.scope);}else{
listen(element,e,o[e]);}}
return;}
return listen(element,eventName,options,fn,scope);},
un:function(element,eventName,fn){
return stopListening(element,eventName,fn);},
onDocumentReady:function(fn,scope,options){
if(docReadyState){
docReadyEvent.on(fn,scope,options);
docReadyEvent.fire();
docReadyEvent.clearListeners();
return;}
if(!docReadyEvent){
initDocReady();}
docReadyEvent.on(fn,scope,options);}};
pub.stoppedMouseDownEvent=new wf.Event();
return pub;}();
wf.onReady=wf.EventManager.onDocumentReady;
wf.onReady(function(){
var bd=wf.getBody();
if(!bd){return;}
var cls=[
wf.isIE?"ext-ie "+(wf.isIE6?'ext-ie6':'ext-ie7'):wf.isGecko?"ext-gecko":wf.isOpera?"ext-opera":wf.isSafari?"ext-safari":""];
if(wf.isMac){
cls.push("ext-mac");}
if(wf.isLinux){
cls.push("ext-linux");}
if(wf.isBorderBox){
cls.push('ext-border-box');}
if(wf.isStrict){
var p=bd.dom.parentNode;
if(p){
p.className+=' ext-strict';}}
bd.addClass(cls.join(' '));});
wf.EventObject=function(){
var E=wf.lib.Event;
var safariKeys={
63234:37,
63235:39,
63232:38,
63233:40,
63276:33,
63277:34,
63272:46,
63273:36,
63275:35};
var btnMap=wf.isIE?{1:0,4:1,2:2}:(wf.isSafari?{1:0,2:1,3:2}:{0:0,1:1,2:2});
wf.EventObjectImpl=function(e){
if(e){
this.setEvent(e.browserEvent||e);}};
wf.EventObjectImpl.prototype={
browserEvent:null,
button:-1,
shiftKey:false,
ctrlKey:false,
altKey:false,
BACKSPACE:8,
TAB:9,
RETURN:13,
ENTER:13,
SHIFT:16,
CONTROL:17,
ESC:27,
SPACE:32,
PAGEUP:33,
PAGEDOWN:34,
END:35,
HOME:36,
LEFT:37,
UP:38,
RIGHT:39,
DOWN:40,
DELETE:46,
F5:116,
setEvent:function(e){
if(e==this||(e&&e.browserEvent)){
return e;}
this.browserEvent=e;
if(e){
this.button=e.button?btnMap[e.button]:(e.which?e.which-1:-1);
if(e.type=='click'&&this.button==-1){
this.button=0;}
this.type=e.type;
this.shiftKey=e.shiftKey;
this.ctrlKey=e.ctrlKey||e.metaKey;
this.altKey=e.altKey;
this.keyCode=e.keyCode;
this.charCode=e.charCode;
this.target=E.getTarget(e);
this.xy=E.getXY(e);}else{
this.button=-1;
this.shiftKey=false;
this.ctrlKey=false;
this.altKey=false;
this.keyCode=0;
this.charCode=0;
this.target=null;
this.xy=[0,0];}
return this;},
stopEvent:function(){
if(this.browserEvent){
if(this.browserEvent.type=='mousedown'){
wf.EventManager.stoppedMouseDownEvent.fire(this);}
E.stopEvent(this.browserEvent);}},
preventDefault:function(){
if(this.browserEvent){
E.preventDefault(this.browserEvent);}},
isNavKeyPress:function(){
var k=this.keyCode;
k=wf.isSafari?(safariKeys[k]||k):k;
return(k>=33&&k<=40)||k==this.RETURN||k==this.TAB||k==this.ESC;},
isSpecialKey:function(){
var k=this.keyCode;
return(this.type=='keypress'&&this.ctrlKey)||k==9||k==13||k==40||k==27||(k==16)||(k==17)||(k>=18&&k<=20)||(k>=33&&k<=35)||(k>=36&&k<=39)||(k>=44&&k<=45);},
stopPropagation:function(){
if(this.browserEvent){
if(this.browserEvent.type=='mousedown'){
wf.EventManager.stoppedMouseDownEvent.fire(this);}
E.stopPropagation(this.browserEvent);}},
getCharCode:function(){
return this.charCode||this.keyCode;},
getKey:function(){
var k=this.keyCode||this.charCode;
return wf.isSafari?(safariKeys[k]||k):k;},
getXY:function(){
return this.xy;},
getTarget:function(selector,maxDepth,returnEl){
var t=wf.get(this.target);
return selector?t.findParent(selector,maxDepth,returnEl):(returnEl?t:this.target);},
getPoint:function(){
return new wf.lib.Point(this.xy[0],this.xy[1]);},
hasModifier:function(){
return((this.ctrlKey||this.altKey)||this.shiftKey)?true:false;}};
return new wf.EventObjectImpl();}();
wf.Connection=function(config){
wf.apply(this,config);
this.addEvents("complete");
wf.Connection.superclass.constructor.call(this);}
wf.extend(wf.Connection,wf.Observable,{
timeout:120,
autoAbort:false,
disableCaching:true,
request:function(o){
var p=o.params;
if(typeof p=="function"){
p=p.call(o.scope||window,o);}
if(typeof p=="object"){
p=wf.urlEncode(p);}
var url=o.url||this.url;
if(typeof url=='function'){
url=url.call(o.scope||window,o);}
if(o.form){
var form=wf.getDom(o.form);
url=url||form.action;
var enctype=form.getAttribute("enctype");
if(o.isUpload||(enctype&&enctype.toLowerCase()=='multipart/form-data')){
return this.doFormUpload(o,p,url);}
var f=wf.lib.Ajax.serializeForm(form);
p=p?(p+'&'+f):f;}
var hs=o.headers;
var cb={
success:this.handleResponse,
failure:this.handleFailure,
scope:this,
argument:{options:o},
timeout:this.timeout*1000};
var method=o.method||this.method||(p?"POST":"GET");
if(method=='GET'&&(this.disableCaching&&o.disableCaching!==false)||o.disableCaching===true){
url+=(url.indexOf('?')!=-1?'&':'?')+'_dc='+(new Date().getTime());}
if(typeof o.autoAbort=='boolean'){
if(o.autoAbort){
this.abort();}}else if(this.autoAbort!==false){
this.abort();}
if((method=='GET'&&p)||o.xmlData||o.jsonData){
url+=(url.indexOf('?')!=-1?'&':'?')+p;
p='';}
this.transId=wf.lib.Ajax.request(method,url,cb,p,o);
return this.transId;},
isLoading:function(transId){
if(transId){
return wf.lib.Ajax.isCallInProgress(transId);}else{
return this.transId?true:false;}},
abort:function(transId){
if(transId||this.isLoading()){
wf.lib.Ajax.abort(transId||this.transId);}},
handleResponse:function(o){
this.transId=false;
var options=o.argument.options;
o.argument=options?options.argument:null;
this.fireEvent("complete",this,o,options);
wf.callback(options.success,options.scope,[o,options]);
wf.callback(options.callback,options.scope,[options,true,o]);},
handleFailure:function(o,e){
this.transId=false;
var options=o.argument.options;
o.argument=options?options.argument:null;
this.fireEvent("complete",this,o,options,e);
wf.callback(options.failure,options.scope,[o,options]);
wf.callback(options.callback,options.scope,[options,false,o]);},
doFormUpload:function(o,ps,url){
var id=wf.id();
var frame=document.createElement('iframe');
frame.id=id;
frame.name=id;
frame.className='x-hidden';
if(wf.isIE){
frame.src=wf.SSL_SECURE_URL;}
document.body.appendChild(frame);
if(wf.isIE){
document.frames[id].name=id;}
var form=wf.getDom(o.form);
form.target=id;
form.method='POST';
form.enctype=form.encoding='multipart/form-data';
if(url){
form.action=url;}
var hiddens,hd;
if(ps){
hiddens=[];
ps=wf.urlDecode(ps,false);
for(var k in ps){
if(ps.hasOwnProperty(k)){
hd=document.createElement('input');
hd.type='hidden';
hd.name=k;
hd.value=ps[k];
form.appendChild(hd);
hiddens.push(hd);}}}
function cb(){
var r={
responseText:'',
responseXML:null};
r.argument=o?o.argument:null;
try{
var doc;
if(wf.isIE){
doc=frame.contentWindow.document;}else{
doc=(frame.contentDocument||window.frames[id].document);}
if(doc&&doc.body){
r.responseText=doc.body.innerHTML;}
if(doc&&doc.XMLDocument){
r.responseXML=doc.XMLDocument;}else{
r.responseXML=doc;}}
catch(e){}
wf.EventManager.un(frame,'load',cb,this);
this.fireEvent("complete",this,r,o);
wf.callback(o.success,o.scope,[r,o]);
wf.callback(o.callback,o.scope,[o,true,r]);
setTimeout(function(){wf.removeNode(frame);},100);}
wf.EventManager.on(frame,'load',cb,this);
form.submit();
if(hiddens){
for(var i=0,len=hiddens.length;i<len;i++){
wf.removeNode(hiddens[i]);}}}});
wf.Ajax=new wf.Connection();
wf.DomQuery=function(){
var cache={},simpleCache={},valueCache={};
var nonSpace=/\S/;
var trimRe=/^\s+|\s+$/g;
var tplRe=/\{(\d+)\}/g;
var modeRe=/^(\s?[\/>+~]\s?|\s|$)/;
var tagTokenRe=/^(#)?([\w-\*]+)/;
var nthRe=/(\d*)n\+?(\d*)/,nthRe2 =/\D/;
function child(p,index){
var i=0;
var n=p.firstChild;
while(n){
if(n.nodeType==1){
if(++i==index){
return n;}}
n=n.nextSibling;}
return null;};
function next(n){
while((n=n.nextSibling)&&n.nodeType!=1);
return n;};
function prev(n){
while((n=n.previousSibling)&&n.nodeType!=1);
return n;};
function children(d){
var n=d.firstChild,ni=-1;
while(n){
var nx=n.nextSibling;
if(n.nodeType==3&&!nonSpace.test(n.nodeValue)){
d.removeChild(n);}else{
n.nodeIndex=++ni;}
n=nx;}
return this;};
function byClassName(c,a,v){
if(!v){
return c;}
var r=[],ri=-1,cn;
for(var i=0,ci;ci=c[i];i++){
if((' '+ci.className+' ').indexOf(v)!=-1){
r[++ri]=ci;}}
return r;};
function attrValue(n,attr){
if(!n.tagName&&typeof n.length!="undefined"){
n=n[0];}
if(!n){
return null;}
if(attr=="for"){
return n.htmlFor;}
if(attr=="class"||attr=="className"){
return n.className;}
return n.getAttribute(attr)||n[attr];};
function getNodes(ns,mode,tagName){
var result=[],ri=-1,cs;
if(!ns){
return result;}
tagName=tagName||"*";
if(typeof ns.getElementsByTagName!="undefined"){
ns=[ns];}
if(!mode){
for(var i=0,ni;ni=ns[i];i++){
cs=ni.getElementsByTagName(tagName);
for(var j=0,ci;ci=cs[j];j++){
result[++ri]=ci;}}}else if(mode=="/"||mode==">"){
var utag=tagName.toUpperCase();
for(var i=0,ni,cn;ni=ns[i];i++){
cn=ni.children||ni.childNodes;
for(var j=0,cj;cj=cn[j];j++){
if(cj.nodeName==utag||cj.nodeName==tagName||tagName=='*'){
result[++ri]=cj;}}}}else if(mode=="+"){
var utag=tagName.toUpperCase();
for(var i=0,n;n=ns[i];i++){
while((n=n.nextSibling)&&n.nodeType!=1);
if(n&&(n.nodeName==utag||n.nodeName==tagName||tagName=='*')){
result[++ri]=n;}}}else if(mode=="~"){
for(var i=0,n;n=ns[i];i++){
while((n=n.nextSibling)&&(n.nodeType!=1||(tagName=='*'||n.tagName.toLowerCase()!=tagName)));
if(n){
result[++ri]=n;}}}
return result;};
function concat(a,b){
if(b.slice){
return a.concat(b);}
for(var i=0,l=b.length;i<l;i++){
a[a.length]=b[i];}
return a;}
function byTag(cs,tagName){
if(cs.tagName||cs==document){
cs=[cs];}
if(!tagName){
return cs;}
var r=[],ri=-1;
tagName=tagName.toLowerCase();
for(var i=0,ci;ci=cs[i];i++){
if(ci.nodeType==1&&ci.tagName.toLowerCase()==tagName){
r[++ri]=ci;}}
return r;};
function byId(cs,attr,id){
if(cs.tagName||cs==document){
cs=[cs];}
if(!id){
return cs;}
var r=[],ri=-1;
for(var i=0,ci;ci=cs[i];i++){
if(ci&&ci.id==id){
r[++ri]=ci;
return r;}}
return r;};
function byAttribute(cs,attr,value,op,custom){
var r=[],ri=-1,st=custom=="{";
var f=wf.DomQuery.operators[op];
for(var i=0,ci;ci=cs[i];i++){
var a;
if(st){
a=wf.DomQuery.getStyle(ci,attr);}
else if(attr=="class"||attr=="className"){
a=ci.className;}else if(attr=="for"){
a=ci.htmlFor;}else if(attr=="href"){
a=ci.getAttribute("href",2);}else{
a=ci.getAttribute(attr);}
if((f&&f(a,value))||(!f&&a)){
r[++ri]=ci;}}
return r;};
function byPseudo(cs,name,value){
return wf.DomQuery.pseudos[name](cs,value);};
var isIE=window.ActiveXObject?true:false;
eval("var batch = 30803;");
var key=30803;
function nodupIEXml(cs){
var d=++key;
cs[0].setAttribute("_nodup",d);
var r=[cs[0]];
for(var i=1,len=cs.length;i<len;i++){
var c=cs[i];
if(!c.getAttribute("_nodup")!=d){
c.setAttribute("_nodup",d);
r[r.length]=c;}}
for(var i=0,len=cs.length;i<len;i++){
cs[i].removeAttribute("_nodup");}
return r;}
function nodup(cs){
if(!cs){
return[];}
var len=cs.length,c,i,r=cs,cj,ri=-1;
if(!len||typeof cs.nodeType!="undefined"||len==1){
return cs;}
if(isIE&&typeof cs[0].selectSingleNode!="undefined"){
return nodupIEXml(cs);}
var d=++key;
cs[0]._nodup=d;
for(i=1;c=cs[i];i++){
if(c._nodup!=d){
c._nodup=d;}else{
r=[];
for(var j=0;j<i;j++){
r[++ri]=cs[j];}
for(j=i+1;cj=cs[j];j++){
if(cj._nodup!=d){
cj._nodup=d;
r[++ri]=cj;}}
return r;}}
return r;}
function quickDiffIEXml(c1,c2){
var d=++key;
for(var i=0,len=c1.length;i<len;i++){
c1[i].setAttribute("_qdiff",d);}
var r=[];
for(var i=0,len=c2.length;i<len;i++){
if(c2[i].getAttribute("_qdiff")!=d){
r[r.length]=c2[i];}}
for(var i=0,len=c1.length;i<len;i++){
c1[i].removeAttribute("_qdiff");}
return r;}
function quickDiff(c1,c2){
var len1=c1.length;
if(!len1){
return c2;}
if(isIE&&c1[0].selectSingleNode){
return quickDiffIEXml(c1,c2);}
var d=++key;
for(var i=0;i<len1;i++){
c1[i]._qdiff=d;}
var r=[];
for(var i=0,len=c2.length;i<len;i++){
if(c2[i]._qdiff!=d){
r[r.length]=c2[i];}}
return r;}
function quickId(ns,mode,root,id){
if(ns==root){
var d=root.ownerDocument||root;
return d.getElementById(id);}
ns=getNodes(ns,mode,"*");
return byId(ns,null,id);}
return{
getStyle:function(el,name){
var el=wf.fly(el);
if(el){
return el.getStyle(name);}
return null;},
compile:function(path,type){
type=type||"select";
var fn=["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
var q=path,mode,lq;
var tk=wf.DomQuery.matchers;
var tklen=tk.length;
var mm;
var lmode=q.match(modeRe);
if(lmode&&lmode[1]){
fn[fn.length]='mode="'+lmode[1].replace(trimRe,"")+'";';
q=q.replace(lmode[1],"");}
while(path.substr(0,1)=="/"){
path=path.substr(1);}
while(q&&lq!=q){
lq=q;
var tm=q.match(tagTokenRe);
if(type=="select"){
if(tm){
if(tm[1]=="#"){
fn[fn.length]='n = quickId(n, mode, root, "'+tm[2]+'");';}else{
fn[fn.length]='n = getNodes(n, mode, "'+tm[2]+'");';}
q=q.replace(tm[0],"");}else if(q.substr(0,1)!='@'){
fn[fn.length]='n = getNodes(n, mode, "*");';}}else{
if(tm){
if(tm[1]=="#"){
fn[fn.length]='n = byId(n, null, "'+tm[2]+'");';}else{
fn[fn.length]='n = byTag(n, "'+tm[2]+'");';}
q=q.replace(tm[0],"");}}
while(!(mm=q.match(modeRe))){
var matched=false;
for(var j=0;j<tklen;j++){
var t=tk[j];
var m=q.match(t.re);
if(m){
fn[fn.length]=t.select.replace(tplRe,function(x,i){
return m[i];});
q=q.replace(m[0],"");
matched=true;
break;}}
if(!matched){
throw 'Error parsing selector, parsing failed at "'+q+'"';}}
if(mm[1]){
fn[fn.length]='mode="'+mm[1].replace(trimRe,"")+'";';
q=q.replace(mm[1],"");}}
fn[fn.length]="return nodup(n);\n}";
eval(fn.join(""));
return f;},
select:function(path,root,type){
if(!root||root==document){
root=document;}
if(typeof root=="string"){
root=document.getElementById(root);}
var paths=path.split(",");
var results=[];
for(var i=0,len=paths.length;i<len;i++){
var p=paths[i].replace(trimRe,"");
if(!cache[p]){
cache[p]=wf.DomQuery.compile(p);
if(!cache[p]){
throw p+" is not a valid selector";}}
var result=cache[p](root);
if(result&&result!=document){
results=results.concat(result);}}
if(paths.length>1){
return nodup(results);}
return results;},
is:function(el,ss){
if(typeof el=="string"){
el=document.getElementById(el);}
var isArray=(el instanceof Array);
var result=wf.DomQuery.filter(isArray?el:[el],ss);
return isArray?(result.length==el.length):(result.length>0);},
filter:function(els,ss,nonMatches){
ss=ss.replace(trimRe,"");
if(!simpleCache[ss]){
simpleCache[ss]=wf.DomQuery.compile(ss,"simple");}
var result=simpleCache[ss](els);
return nonMatches?quickDiff(result,els):result;},
matchers:[{
re:/^\.([\w-]+)/,
select:'n = byClassName(n, null, " {1} ");'},{
re:/^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
select:'n = byPseudo(n, "{1}", "{2}");'},{
re:/^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
select:'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'},{
re:/^#([\w-]+)/,
select:'n = byId(n, null, "{1}");'},{
re:/^@([\w-]+)/,
select:'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'}],
operators:{
"=":function(a,v){
return a==v;},
"!=":function(a,v){
return a!=v;},
"^=":function(a,v){
return a&&a.substr(0,v.length)==v;},
"$=":function(a,v){
return a&&a.substr(a.length-v.length)==v;},
"*=":function(a,v){
return a&&a.indexOf(v)!==-1;},
"%=":function(a,v){
return(a%v)==0;},
"|=":function(a,v){
return a&&(a==v||a.substr(0,v.length+1)==v+'-');},
"~=":function(a,v){
return a&&(' '+a+' ').indexOf(' '+v+' ')!=-1;}},
pseudos:{
"first-child":function(c){
var r=[],ri=-1,n;
for(var i=0,ci;ci=n=c[i];i++){
while((n=n.previousSibling)&&n.nodeType!=1);
if(!n){
r[++ri]=ci;}}
return r;},
"last-child":function(c){
var r=[],ri=-1,n;
for(var i=0,ci;ci=n=c[i];i++){
while((n=n.nextSibling)&&n.nodeType!=1);
if(!n){
r[++ri]=ci;}}
return r;},
"nth-child":function(c,a){
var r=[],ri=-1;
var m=nthRe.exec(a=="even"&&"2n"||a=="odd"&&"2n+1"||!nthRe2.test(a)&&"n+"+a||a);
var f=(m[1]||1)-0,l=m[2]-0;
for(var i=0,n;n=c[i];i++){
var pn=n.parentNode;
if(batch!=pn._batch){
var j=0;
for(var cn=pn.firstChild;cn;cn=cn.nextSibling){
if(cn.nodeType==1){
cn.nodeIndex=++j;}}
pn._batch=batch;}
if(f==1){
if(l==0||n.nodeIndex==l){
r[++ri]=n;}}else if((n.nodeIndex+l)%f==0){
r[++ri]=n;}}
return r;},
"only-child":function(c){
var r=[],ri=-1;;
for(var i=0,ci;ci=c[i];i++){
if(!prev(ci)&&!next(ci)){
r[++ri]=ci;}}
return r;},
"empty":function(c){
var r=[],ri=-1;
for(var i=0,ci;ci=c[i];i++){
var cns=ci.childNodes,j=0,cn,empty=true;
while(cn=cns[j]){++j;
if(cn.nodeType==1||cn.nodeType==3){
empty=false;
break;}}
if(empty){
r[++ri]=ci;}}
return r;},
"contains":function(c,v){
var r=[],ri=-1;
for(var i=0,ci;ci=c[i];i++){
if((ci.textContent||ci.innerText||'').indexOf(v)!=-1){
r[++ri]=ci;}}
return r;},
"nodeValue":function(c,v){
var r=[],ri=-1;
for(var i=0,ci;ci=c[i];i++){
if(ci.firstChild&&ci.firstChild.nodeValue==v){
r[++ri]=ci;}}
return r;},
"checked":function(c){
var r=[],ri=-1;
for(var i=0,ci;ci=c[i];i++){
if(ci.checked==true){
r[++ri]=ci;}}
return r;},
"not":function(c,ss){
return Ext.DomQuery.filter(c,ss,true);},
"any":function(c,selectors){
var ss=selectors.split('|');
var r=[],ri=-1,s;
for(var i=0,ci;ci=c[i];i++){
for(var j=0;s=ss[j];j++){
if(Ext.DomQuery.is(ci,s)){
r[++ri]=ci;
break;}}}
return r;},
"odd":function(c){
return this["nth-child"](c,"odd");},
"even":function(c){
return this["nth-child"](c,"even");},
"nth":function(c,a){
return c[a-1]||[];},
"first":function(c){
return c[0]||[];},
"last":function(c){
return c[c.length-1]||[];},
"has":function(c,ss){
var s=Ext.DomQuery.select;
var r=[],ri=-1;
for(var i=0,ci;ci=c[i];i++){
if(s(ss,ci).length>0){
r[++ri]=ci;}}
return r;},
"next":function(c,ss){
var is=Ext.DomQuery.is;
var r=[],ri=-1;
for(var i=0,ci;ci=c[i];i++){
var n=next(ci);
if(n&&is(n,ss)){
r[++ri]=ci;}}
return r;},
"prev":function(c,ss){
var is=Ext.DomQuery.is;
var r=[],ri=-1;
for(var i=0,ci;ci=c[i];i++){
var n=prev(ci);
if(n&&is(n,ss)){
r[++ri]=ci;}}
return r;}}};}();
wf.query=wf.DomQuery.select;
wf.DomHelper=function(){
var tempTableEl=null;
var emptyTags=/^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;
var tableRe=/^table|tbody|tr|td$/i;
var createHtml=function(o){
if(typeof o=='string'){
return o;}
var b="";
if(!o.tag){
o.tag="div";}
b+="<"+o.tag;
for(var attr in o){
if(attr=="tag"||attr=="children"||attr=="cn"||attr=="html"||typeof o[attr]=="function")continue;
if(attr=="style"){
var s=o["style"];
if(typeof s=="function"){
s=s.call();}
if(typeof s=="string"){
b+=' style="'+s+'"';}else if(typeof s=="object"){
b+=' style="';
for(var key in s){
if(typeof s[key]!="function"){
b+=key+":"+s[key]+";";}}
b+='"';}}else{
if(attr=="cls"){
b+=' class="'+o["cls"]+'"';}else if(attr=="htmlFor"){
b+=' for="'+o["htmlFor"]+'"';}else{
b+=" "+attr+'="'+o[attr]+'"';}}}
if(emptyTags.test(o.tag)){
b+="/>";}else{
b+=">";
var cn=o.children||o.cn;
if(cn){
if(cn instanceof Array){
for(var i=0,len=cn.length;i<len;i++){
b+=createHtml(cn[i],b);}}else{
b+=createHtml(cn,b);}}
if(o.html){
b+=o.html;}
b+="</"+o.tag+">";}
return b;};
var ieTable=function(depth,s,h,e){
tempTableEl.innerHTML=[s,h,e].join('');
var i=-1,el=tempTableEl;
while(++i<depth){
el=el.firstChild;}
return el;};
var ts='<table>',
te='</table>',
tbs=ts+'<tbody>',
tbe='</tbody>'+te,
trs=tbs+'<tr>',
tre='</tr>'+tbe;
var insertIntoTable=function(tag,where,el,html){
if(!tempTableEl){
tempTableEl=document.createElement('div');}
var node;
var before=null;
if(tag=='td'){
if(where=='afterbegin'||where=='beforeend'){
return;}
if(where=='beforebegin'){
before=el;
el=el.parentNode;}else{
before=el.nextSibling;
el=el.parentNode;}
node=ieTable(4,trs,html,tre);}
else if(tag=='tr'){
if(where=='beforebegin'){
before=el;
el=el.parentNode;
node=ieTable(3,tbs,html,tbe);}else if(where=='afterend'){
before=el.nextSibling;
el=el.parentNode;
node=ieTable(3,tbs,html,tbe);}else{
if(where=='afterbegin'){
before=el.firstChild;}
node=ieTable(4,trs,html,tre);}}else if(tag=='tbody'){
if(where=='beforebegin'){
before=el;
el=el.parentNode;
node=ieTable(2,ts,html,te);}else if(where=='afterend'){
before=el.nextSibling;
el=el.parentNode;
node=ieTable(2,ts,html,te);}else{
if(where=='afterbegin'){
before=el.firstChild;}
node=ieTable(3,tbs,html,tbe);}}else{
if(where=='beforebegin'||where=='afterend'){
return;}
if(where=='afterbegin'){
before=el.firstChild;}
node=ieTable(2,ts,html,te);}
el.insertBefore(node,before);
return node;};
return{
applyStyles:function(el,styles){
if(styles){
if(typeof styles=="string"){
var re=/\s?([a-z\-]*)\:\s?([^;]*);?/gi;
var matches;
while((matches=re.exec(styles))!=null){
wf.DomHelper.setStyle(el,matches[1],matches[2]);}}else if(typeof styles=="object"){
for(var style in styles){
wf.DomHelper.setStyle(el,style,styles[style]);}}else if(typeof styles=="function"){
wf.DomHelper.applyStyles(el,styles.call());}}},
setStyle:function(el,prop,value){
el=wf.getDom(el);
if(typeof prop=="string"){
if(prop=='opacity'){
var s=el.style;
if(wf.isIE){
s.zoom=1;
s.filter=(s.filter||'').replace(/alpha\([^\)]*\)/gi,"")+(opacity==1?"":" alpha(opacity="+opacity*100+")");}else{
s.opacity=opacity;}}else{
el.style[prop]=value;}}else{
for(var style in prop){
if(typeof prop[style]!="function"){
wf.DomHelper.setStyle(style,prop[style]);}}}},
insertHtml:function(where,el,html){
where=where.toLowerCase();
if(el.insertAdjacentHTML){
if(tableRe.test(el.tagName)){
var rs;
if(rs=insertIntoTable(el.tagName.toLowerCase(),where,el,html)){
return rs;}}
switch(where){
case "beforebegin":
el.insertAdjacentHTML('BeforeBegin',html);
return el.previousSibling;
case "afterbegin":
el.insertAdjacentHTML('AfterBegin',html);
return el.firstChild;
case "beforeend":
el.insertAdjacentHTML('BeforeEnd',html);
return el.lastChild;
case "afterend":
el.insertAdjacentHTML('AfterEnd',html);
return el.nextSibling;}
throw 'Illegal insertion point -> "'+where+'"';}
var range=el.ownerDocument.createRange();
var frag;
switch(where){
case "beforebegin":
range.setStartBefore(el);
frag=range.createContextualFragment(html);
el.parentNode.insertBefore(frag,el);
return el.previousSibling;
case "afterbegin":
if(el.firstChild){
range.setStartBefore(el.firstChild);
frag=range.createContextualFragment(html);
el.insertBefore(frag,el.firstChild);
return el.firstChild;}else{
el.innerHTML=html;
return el.firstChild;}
case "beforeend":
if(el.lastChild){
range.setStartAfter(el.lastChild);
frag=range.createContextualFragment(html);
el.appendChild(frag);
return el.lastChild;}else{
el.innerHTML=html;
return el.lastChild;}
case "afterend":
range.setStartAfter(el);
frag=range.createContextualFragment(html);
el.parentNode.insertBefore(frag,el.nextSibling);
return el.nextSibling;}
throw 'Illegal insertion point -> "'+where+'"';},
doInsert:function(el,o,pos,returnElement){
el=wf.getDom(el);
var newNode;
var html=createHtml(o);
newNode=this.insertHtml(pos,el,html);
return returnElement?wf.get(newNode):newNode;},
append:function(el,o,returnElement){
el=wf.getDom(el);
var newNode;
var html=createHtml(o);
newNode=this.insertHtml("beforeEnd",el,html);
return returnElement?wf.get(newNode):newNode;},
overwrite:function(el,o,returnElement){
el=wf.getDom(el);
el.innerHTML=createHtml(o);
return returnElement?wf.get(el.firstChild,true):el.firstChild;}};}();
wf.Updater=function(el){
el=wf.get(el);
this.el=el;
this.defaultUrl=null;
this.addEvents("update");
wf.apply(this,wf.Updater.defaults);
this.transaction=null;
this.autoRefreshProcId=null;
if(!this.renderer){
this.renderer=new wf.Updater.BasicRenderer();}
wf.Updater.superclass.constructor.call(this);};
wf.extend(wf.Updater,wf.Observable,{
update:function(url,params,callback,discardUrl){
var method=this.method,cfg,callerScope;
if(typeof url=="object"){
cfg=url;
url=cfg.url;
params=params||cfg.params;
callback=callback||cfg.callback;
discardUrl=discardUrl||cfg.discardUrl;
callerScope=cfg.scope;
if(typeof cfg.method!="undefined"){method=cfg.method;};
if(typeof cfg.nocache!="undefined"){this.disableCaching=cfg.nocache;};
if(typeof cfg.text!="undefined"){this.indicatorText='<div class="loading-indicator">'+cfg.text+"</div>";};
if(typeof cfg.scripts!="undefined"){this.loadScripts=cfg.scripts;};}
this.showLoading();
if(!discardUrl){
this.defaultUrl=url;}
method=method||(params?"POST":"GET");
var o=wf.apply(cfg||{},{
url:url,
params:params,
success:this.processSuccess,
failure:this.processFailure,
scope:this,
callback:undefined,
disableCaching:this.disableCaching,
argument:{
"options":cfg,
"url":url,
"callback":callback,
"scope":callerScope||window,
"params":params}});
this.transaction=wf.Ajax.request(o);},
refresh:function(callback){
if(this.defaultUrl==null){
return;}
this.update(this.defaultUrl,null,callback,true);},
startAutoRefresh:function(interval,url,params,callback,refreshNow){
if(refreshNow){
this.update(url||this.defaultUrl,params,callback);}
if(this.autoRefreshProcId){
clearInterval(this.autoRefreshProcId);}
this.autoRefreshProcId=setInterval(this.update.createDelegate(this,[url||this.defaultUrl,params,callback]),interval*1000);},
stopAutoRefresh:function(){
if(this.autoRefreshProcId){
clearInterval(this.autoRefreshProcId);
delete this.autoRefreshProcId;}},
showLoading:function(){
if(this.showLoadIndicator){
this.el.update(this.indicatorText);}},
processSuccess:function(o){
this.transaction=null;
if(this.loadScripts){
this.renderer.render(this.el,o,this,
this.updateComplete.createDelegate(this,[o]));}else{
this.renderer.render(this.el,o,this);
this.updateComplete(o);}},
updateComplete:function(o){
this.fireEvent("update",this.el,o);
if(typeof o.argument.callback=="function"){
o.argument.callback.call(o.argument.scope,this.el,true,o,o.argument.options);}},
processFailure:function(o){
this.transaction=null;
this.fireEvent("update",this.el,o);
if(typeof o.argument.callback=="function"){
o.argument.callback.call(o.argument.scope,this.el,false,o,o.argument.options);}},
abort:function(){
if(this.transaction){
wf.Ajax.abort(this.transaction);}},
isUpdating:function(){
if(this.transaction){
return wf.Ajax.isLoading(this.transaction);}
return false;}});
wf.Updater.defaults={
loadScripts:false,
disableCaching:false,
showLoadIndicator:true,
indicatorText:'<div class="loading-indicator">Loading...</div>'};
wf.Updater.BasicRenderer=function(){};
wf.Updater.BasicRenderer.prototype={
render:function(el,o,updateManager,callback){
el.update(o.responseText,updateManager.loadScripts,callback);}};
wf.Updater.updateElement=function(el,url,params,options){
var um=wf.get(el).getUpdater();
var cfg={
url:url,
params:params||{}};
wf.apply(cfg,options);
um.update(cfg);};
wf.Updater.autoUpdate=function(el,interval,url,params,options){
var um=wf.get(el).getUpdater();
var cfg={
url:url,
params:params||{}};
wf.apply(cfg,options);
um.startAutoRefresh(interval,cfg);};
wf.update=wf.Updater.updateElement;
wf.autoUpdate=wf.Updater.autoUpdate;
(function(){
var E=wf.lib.Event;
var D=wf.lib.Dom;
var DQ=wf.DomQuery;
var propCache={};
var camelRe=/(-[a-z])/gi;
var camelFn=function(m,a){return a.charAt(1).toUpperCase();};
var view=document.defaultView;
wf.Element=function(element){
var dom=wf.getDom(element);
if(!dom){
return null;}
var id=dom.id;
this.dom=dom;
this.id=id||wf.id(dom);};
var El=wf.Element;
El.prototype={
defaultUnit:"px",
autoBoxAdjust:true,
classReCache:{},
hide:function(){
if(wf.isIE){
this.setStyle("display","none");}else{
this.dom.style.visibility="hidden";}
return this;},
show:function(){
if(wf.isIE){
this.setStyle("display","block");}else{
this.dom.style.visibility="visible";}
return this;},
isVisible:function(deep){
var vis=!(this.getStyle("visibility")=="hidden"||this.getStyle("display")=="none");
if(deep!==true||!vis){
return vis;}
var p=this.dom.parentNode;
while(p&&p.tagName.toLowerCase()!="body"){
if(!p.isVisible()){
return false;}
p=p.parentNode;}
return true;},
child:function(selector,returnDom){
var els=DQ.select(selector,this.dom);
if(els.length>0)
return returnDom?els[0]:wf.get(els[0]);
return null;},
findParent:function(simpleSelector,maxDepth,returnEl){
var p=this.dom,b=document.body,depth=0,stopEl;
maxDepth=maxDepth||50;
if(typeof maxDepth!="number"){
stopEl=wf.getDom(maxDepth);
maxDepth=10;}
p=p.parentNode;
while(p&&p.nodeType==1&&depth<maxDepth&&p!=b&&p!=stopEl){
if(DQ.is(p,simpleSelector)){
return returnEl?wf.get(p):p;}
depth++;
p=p.parentNode;}
return null;},
matchNode:function(dir,start,selector,returnDom){
var n=this.dom[start];
while(n){
if(n.nodeType==1&&(!selector||DQ.is(n,selector))){
return !returnDom?wf.get(n):n;}
n=n[dir];}
return null;},
scrollIntoView:function(container,hscroll){
var c=wf.getDom(container)||wf.getBody().dom;
var el=this.dom;
var o=this.getOffsetsTo(c),
l=o[0]+c.scrollLeft,
t=o[1]+c.scrollTop,
b=t+el.offsetHeight,
r=l+el.offsetWidth;
var ch=c.clientHeight;
var ct=parseInt(c.scrollTop,10);
var cl=parseInt(c.scrollLeft,10);
var cb=ct+ch;
var cr=cl+c.clientWidth;
if(el.offsetHeight>ch||t<ct){
c.scrollTop=t;}else if(b>cb){
c.scrollTop=b-ch;}
c.scrollTop=c.scrollTop;
if(hscroll!==false){
if(el.offsetWidth>c.clientWidth||l<cl){
c.scrollLeft=l;}else if(r>cr){
c.scrollLeft=r-c.clientWidth;}
c.scrollLeft=c.scrollLeft;}
return this;},
getOffsetsTo:function(el){
var o=this.getXY();
var e=wf.fly(el,'_internal').getXY();
return[o[0]-e[0],o[1]-e[1]];},
scrollChildIntoView:function(child,hscroll){
wf.fly(child,'_scrollChildIntoView').scrollIntoView(this,hscroll);},
appendChild:function(el){
el=wf.get(el);
el.appendTo(this);
return this;},
appendTo:function(el){
el=wf.getDom(el);
el.appendChild(this.dom);
return this;},
createChild:function(config,insertBefore,returnDom){
config=config||{tag:'div'};
if(insertBefore){
return wf.DomHelper.doInsert(this.dom,config,"beforeBegin",returnDom!==true);}
return wf.DomHelper[!this.dom.firstChild?'overwrite':'append'](this.dom,config,returnDom!==true);},
insertSibling:function(el,where,returnDom){
var rt;
if(el instanceof Array){
for(var i=0,len=el.length;i<len;i++){
rt=this.insertSibling(el[i],where,returnDom);}
return rt;}
where=where?where.toLowerCase():'before';
el=el||{};
var refNode=where=='before'?this.dom:this.dom.nextSibling;
if(typeof el=='object'&&!el.nodeType){
if(where=='after'&&!this.dom.nextSibling){
rt=wf.DomHelper.append(this.dom.parentNode,el,!returnDom);}else{
if(where=='after'){
rt=wf.DomHelper.doInsert(this.dom,el,'afterEnd',!returnDom);}else{
rt=wf.DomHelper.doInsert(this.dom,el,'beforeBegin',!returnDom);}}}else{
rt=this.dom.parentNode.insertBefore(wf.getDom(el),refNode);
if(!returnDom){
rt=wf.get(rt);}}
return rt;},
remove:function(){
wf.removeNode(this.dom);
delete El.cache[this.dom.id];},
update:function(html,loadScripts,callback){
if(typeof html=="undefined"){
html="";}
if(loadScripts!==true){
this.dom.innerHTML=html;
if(typeof callback=="function"){
callback();}
return this;}
var id=wf.id();
var dom=this.dom;
html+='<span id="'+id+'"></span>';
E.onAvailable(id,function(){
var hd=document.getElementsByTagName("head")[0];
var re=/(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
var srcRe=/\ssrc=([\'\"])(.*?)\1/i;
var typeRe=/\stype=([\'\"])(.*?)\1/i;
var match;
while(match=re.exec(html)){
var attrs=match[1];
var srcMatch=attrs?attrs.match(srcRe):false;
if(srcMatch&&srcMatch[2]){
var s=document.createElement("script");
s.src=srcMatch[2];
var typeMatch=attrs.match(typeRe);
if(typeMatch&&typeMatch[2]){
s.type=typeMatch[2];}
hd.appendChild(s);}else if(match[2]&&match[2].length>0){
if(window.execScript){
window.execScript(match[2]);}else{
window.eval(match[2]);}}}
var el=document.getElementById(id);
if(el){wf.removeNode(el);}
if(typeof callback=="function"){
callback();}});
dom.innerHTML=html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,"");
return this;},
load:function(){
var um=this.getUpdater();
um.update.apply(um,arguments);
return this;},
getUpdater:function(){
if(!this.updateManager){
this.updateManager=new wf.Updater(this);}
return this.updateManager;},
getXY:function(){
return D.getXY(this.dom);},
setXY:function(pos){
D.setXY(this.dom,pos);
return this;},
getLeftTop:function(local){
var xy=this.getXY();
if(!local){
return xy;}else{
return[parseInt(this.getStyle("left"),10)||0,parseInt(this.getStyle("top"),10)||0];}},
getMargins:function(side){
if(!side){
return{
top:parseInt(this.getStyle("margin-top"),10)||0,
left:parseInt(this.getStyle("margin-left"),10)||0,
bottom:parseInt(this.getStyle("margin-bottom"),10)||0,
right:parseInt(this.getStyle("margin-right"),10)||0};}else{
return this.addStyles(side,El.margins);}},
setLeftTop:function(left,top){
if(left!=undefined){
this.setStyle("left",this.addUnits(left));}
if(top!=undefined){
this.setStyle("top",this.addUnits(top));}
return this;},
getSize:function(cs){
var h=this.dom.offsetHeight||0;
var w=this.dom.offsetWidth||0;
w=cs!==true?w:w-this.getBorderWidth("lr")-this.getPadding("lr");
h=cs!==true?h:h-this.getBorderWidth("tb")-this.getPadding("tb");
return{width:w<0?0:w,height:h<0?0:h};},
getStyleSize:function(){
var w,h,d=this.dom,s=d.style;
if(s.width&&s.width!='auto'){
w=parseInt(s.width,10);
if(wf.isBorderBox){
w-=this.getFrameWidth('lr');}}
if(s.height&&s.height!='auto'){
h=parseInt(s.height,10);
if(wf.isBorderBox){
h-=this.getFrameWidth('tb');}}
return{width:w||this.getSize(true).width,height:h||this.getSize(true).height};},
setSize:function(width,height){
if(typeof width=="object"){
height=width.height;width=width.width;}
width=this.adjustWidth(width);
height=this.adjustHeight(height);
if(width)
this.dom.style.width=this.addUnits(width);
if(height)
this.dom.style.height=this.addUnits(height);
return this;},
getViewSize:function(){
var d=this.dom,doc=document,aw=0,ah=0;
if(d==doc||d==doc.body){
return{width:D.getViewWidth(),height:D.getViewHeight()};}else{
return{
width:d.clientWidth,
height:d.clientHeight};}},
getFrameWidth:function(sides,onlyContentBox){
var v=onlyContentBox&&wf.isBorderBox?0:(this.getPadding(sides)+this.getBorderWidth(sides));
return v;},
adjustWidth:function(width){
if(typeof width=="number"){
if((this.autoBoxAdjust&&!this.isBorderBox())){
width-=(this.getBorderWidth("lr")+this.getPadding("lr"));}
if(width<0){
width=0;}}
return width;},
adjustHeight:function(height){
if(typeof height=="number"){
if(this.autoBoxAdjust&&!this.isBorderBox()){
height-=(this.getBorderWidth("tb")+this.getPadding("tb"));}
if(height<0){
height=0;}}
return height;},
getBorderWidth:function(side){
return this.addStyles(side,El.borders);},
getPadding:function(side){
return this.addStyles(side,El.paddings);},
isBorderBox:function(){
return noBoxAdjust[this.dom.tagName.toLowerCase()]||wf.isBorderBox;},
translatePoints:function(x,y){
if(typeof x=='object'||x instanceof Array){
y=x[1];x=x[0];}
var p=this.getStyle('position');
var o=this.getXY();
var l=parseInt(this.getStyle('left'),10);
var t=parseInt(this.getStyle('top'),10);
if(isNaN(l)){
l=(p=="relative")?0:this.dom.offsetLeft;}
if(isNaN(t)){
t=(p=="relative")?0:this.dom.offsetTop;}
return{left:(x-o[0]+l),top:(y-o[1]+t)};},
getScroll:function(){
var d=this.dom,doc=document;
if(d==doc||d==doc.body){
var l,t;
if(wf.isIE&&wf.isStrict){
l=doc.documentElement.scrollLeft||(doc.body.scrollLeft||0);
t=doc.documentElement.scrollTop||(doc.body.scrollTop||0);}else{
l=window.pageXOffset||(doc.body.scrollLeft||0);
t=window.pageYOffset||(doc.body.scrollTop||0);}
return{left:l,top:t};}else{
return{left:d.scrollLeft,top:d.scrollTop};}},
addUnits:function(size){
return wf.Element.addUnits(size,this.defaultUnit);},
center:function(centerIn){
this.alignTo(centerIn||document,'c-c');
return this;},
alignTo:function(element,position,offsets){
var xy=this.getAlignToXY(element,position,offsets);
this.setXY(xy);
return this;},
getAnchorXY:function(anchor,local,s){
var w,h,vp=false;
var size=this.getSize();
if(!s){
var d=this.dom;
if(d==document.body||d==document){
vp=true;
w=D.getViewWidth();h=D.getViewHeight();}else{
w=size.width;h=size.height;}}else{
w=s.width;h=s.height;}
var x=0,y=0,r=Math.round;
switch((anchor||"tl").toLowerCase()){
case "c":
x=r(w*.5);
y=r(h*.5);
break;
case "t":
x=r(w*.5);
y=0;
break;
case "l":
x=0;
y=r(h*.5);
break;
case "r":
x=w;
y=r(h*.5);
break;
case "b":
x=r(w*.5);
y=h;
break;
case "tl":
x=0;
y=0;
break;
case "bl":
x=0;
y=h;
break;
case "br":
x=w;
y=h;
break;
case "tr":
x=w;
y=0;
break;}
if(local===true){
return[x,y];}
if(vp){
var sc=this.getScroll();
return[x+sc.left,y+sc.top];}
var o=this.getXY();
return[x+o[0],y+o[1]];},
getRegion:function(){
return wf.lib.Region.getRegion(this.dom);},
contains:function(el){
var el=wf.get(el);
return this.getRegion().contains(el.getRegion());},
getAlignToXY:function(el,p,o){
el=wf.get(el);
if(!el||!el.dom){
throw "Element.alignToXY with an element that doesn't exist";}
var d=this.dom;
var c=false;
var p1="",p2="";
o=o||[0,0];
if(!p){
p="tl-bl";}else if(p=="?"){
p="tl-bl?";}else if(p.indexOf("-")==-1){
p="tl-"+p;}
p=p.toLowerCase();
var m=p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
if(!m){
throw "Element.alignTo with an invalid alignment "+p;}
p1=m[1];p2=m[2];c=!!m[3];
var a1=this.getAnchorXY(p1,true);
var a2=el.getAnchorXY(p2,false);
var x=a2[0]-a1[0]+o[0];
var y=a2[1]-a1[1]+o[1];
if(c){
var size=this.getSize();
var w=size.width,h=size.height,r=el.getRegion();
var dw=D.getViewWidth()-5,dh=D.getViewHeight()-5;
var p1y=p1.charAt(0),p1x=p1.charAt(p1.length-1);
var p2y=p2.charAt(0),p2x=p2.charAt(p2.length-1);
var swapY=((p1y=="t"&&p2y=="b")||(p1y=="b"&&p2y=="t"));
var swapX=((p1x=="r"&&p2x=="l")||(p1x=="l"&&p2x=="r"));
var doc=document;
var scrollX=(doc.documentElement.scrollLeft||doc.body.scrollLeft||0)+5;
var scrollY=(doc.documentElement.scrollTop||doc.body.scrollTop||0)+5;
if((x+w)>dw+scrollX){
x=swapX?r.left-w:dw+scrollX-w;}
if(x<scrollX){
x=swapX?r.right:scrollX;}
if((y+h)>dh+scrollY){
y=swapY?r.top-h:dh+scrollY-h;}
if(y<scrollY){
y=swapY?r.bottom:scrollY;}}
return[x,y];},
getCenterXY:function(){
return this.getAlignToXY(document,'c-c');},
focus:function(){
try{
this.dom.focus();}catch(e){}
return this;},
blur:function(){
try{
this.dom.blur();}catch(e){}
return this;},
addClass:function(className){
if(className instanceof Array){
for(var i=0,len=className.length;i<len;i++){
this.addClass(className[i]);}}else{
if(className&&!this.hasClass(className)){
this.dom.className=this.dom.className+" "+className;}}
return this;},
replaceClass:function(oldClassName,newClassName){
this.removeClass(oldClassName);
this.addClass(newClassName);
return this;},
hasClass:function(className){
return className&&(' '+this.dom.className+' ').indexOf(' '+className+' ')!=-1;},
removeClass:function(className){
if(!className||!this.dom.className){
return this;}
if(className instanceof Array){
for(var i=0,len=className.length;i<len;i++){
this.removeClass(className[i]);}}else{
if(this.hasClass(className)){
var re=this.classReCache[className];
if(!re){
re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)',"g");
this.classReCache[className]=re;}
this.dom.className=
this.dom.className.replace(re," ");}}
return this;},
getStyle:function(){
return view&&view.getComputedStyle?
function(prop){
var el=this.dom,v,cs,camel;
if(prop=='float'){
prop="cssFloat";}
if(v=el.style[prop]){
return v;}
if(cs=view.getComputedStyle(el,"")){
if(!(camel=propCache[prop])){
camel=propCache[prop]=prop.replace(camelRe,camelFn);}
return cs[camel];}
return null;}:
function(prop){
var el=this.dom,v,cs,camel;
if(prop=='opacity'){
if(typeof el.style.filter=='string'){
var m=el.style.filter.match(/alpha\(opacity=(.*)\)/i);
if(m){
var fv=parseFloat(m[1]);
if(!isNaN(fv)){
return fv?fv/100:0;}}}
return 1;}else if(prop=='float'){
prop="styleFloat";}
if(!(camel=propCache[prop])){
camel=propCache[prop]=prop.replace(camelRe,camelFn);}
if(v=el.style[camel]){
return v;}
if(cs=el.currentStyle){
return cs[camel];}
return null;};}(),
setStyle:function(prop,value){
if(typeof prop=="string"){
var camel;
if(!(camel=propCache[prop])){
camel=propCache[prop]=prop.replace(camelRe,camelFn);}
if(camel=='opacity'){
this.setOpacity(value);}else{
this.dom.style[camel]=value;}}else{
for(var style in prop){
if(typeof prop[style]!="function"){
this.setStyle(style,prop[style]);}}}
return this;},
setZIndex:function(zindex){
this.zindex=zindex;
this.setStyle("z-index",zindex+2);},
applyStyles:function(style){
wf.DomHelper.applyStyles(this.dom,style);
return this;},
addStyles:function(sides,styles){
var val=0,v,w;
for(var i=0,len=sides.length;i<len;i++){
v=this.getStyle(styles[sides.charAt(i)]);
if(v){
w=parseInt(v,10);
if(w){val+=(w>=0?w:-1*w);}}}
return val;},
setOpacity:function(opacity){
var s=this.dom.style;
if(wf.isIE){
s.zoom=1;
s.filter=(s.filter||'').replace(/alpha\([^\)]*\)/gi,"")+(opacity==1?"":" alpha(opacity="+opacity*100+")");}else{
s.opacity=opacity;}
return this;},
position:function(pos,zIndex,x,y){
if(!pos){
if(this.getStyle('position')=='static'){
this.setStyle('position','relative');}}else{
this.setStyle("position",pos);}
if(zIndex){
this.setStyle("z-index",zIndex);}
if(x!==undefined&&y!==undefined){
this.setXY([x,y]);}else if(x!==undefined){
this.setX(x);}else if(y!==undefined){
this.setY(y);}},
on:function(eventName,fn,scope,options){
wf.EventManager.on(this.dom,eventName,fn,scope||this,options);},
un:function(eventName,fn){
wf.EventManager.un(this.dom,eventName,fn);
return this;},
removeAllListeners:function(){
E.purgeElement(this.dom);},
swallowEvent:function(eventName,preventDefault){
var fn=function(e){
e.stopPropagation();
if(preventDefault){
e.preventDefault();}};
if(eventName instanceof Array){
for(var i=0,len=eventName.length;i<len;i++){
this.on(eventName[i],fn);}
return this;}
this.on(eventName,fn);
return this;},
hover:function(overFn,outFn,scope){
var preOverFn=function(e){
overFn.apply(scope||this,arguments);};
var preOutFn=function(e){
outFn.apply(scope||this,arguments);};
this.on("mouseover",preOverFn,this.dom);
this.on("mouseout",preOutFn,this.dom);
return this;},
addClassOnOver:function(className){
this.hover(
function(){
wf.fly(this,'_internal').addClass(className);},
function(){
wf.fly(this,'_internal').removeClass(className);});
return this;},
addClassOnFocus:function(className){
this.on("focus",function(){
wf.fly(this,'_internal').addClass(className);},this.dom);
this.on("blur",function(){
wf.fly(this,'_internal').removeClass(className);},this.dom);
return this;},
addClassOnClick:function(className){
var dom=this.dom;
this.on("mousedown",function(){
wf.fly(dom,'_internal').addClass(className);
var d=wf.getDoc();
var fn=function(){
wf.fly(dom,'_internal').removeClass(className);
d.un("mouseup",fn);};
d.on("mouseup",fn);});
return this;}};
var Ep=El.prototype;
El.borders={l:"border-left-width",r:"border-right-width",t:"border-top-width",b:"border-bottom-width"};
El.paddings={l:"padding-left",r:"padding-right",t:"padding-top",b:"padding-bottom"};
El.margins={l:"margin-left",r:"margin-right",t:"margin-top",b:"margin-bottom"};
El.boxMarkup='<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
El.unitPattern=/\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
El.addUnits=function(v,defaultUnit){
if(v===""||v=="auto"){
return v;}
if(v===undefined){
return '';}
if(typeof v=="number"||!El.unitPattern.test(v)){
return v+(defaultUnit||'px');}
return v;};
El.cache={};
var docEl;
El.get=function(el){
var ex,elm,id;
if(!el){return null;}
if(typeof el=="string"){
if(!(elm=document.getElementById(el))){
return null;}
if(ex=El.cache[el]){
ex.dom=elm;}else{
ex=El.cache[el]=new El(elm);}
return ex;}else if(el.tagName){
if(!(id=el.id)){
id=wf.id(el);}
if(ex=El.cache[id]){
ex.dom=el;}else{
ex=El.cache[id]=new El(el);}
return ex;}else if(el instanceof El){
if(el!=docEl){
el.dom=document.getElementById(el.id)||el.dom;
El.cache[el.id]=el;}
return el;}else if(el==document){
if(!docEl){
var f=function(){};
f.prototype=El.prototype;
docEl=new f();
docEl.dom=document;}
return docEl;}
return null;};
El.uncache=function(el){
for(var i=0,a=arguments,len=a.length;i<len;i++){
if(a[i]){
delete El.cache[a[i].id||a[i]];}}};
El.garbageCollect=function(){
if(!wf.enableGarbageCollector){
clearInterval(El.collectorThread);
return;}
for(var eid in El.cache){
var el=El.cache[eid],d=el.dom;
if(!d||!d.parentNode||(!d.offsetParent&&!document.getElementById(eid))){
delete El.cache[eid];
if(d&&wf.enableListenerCollection){
E.purgeElement(d);}}}};
El.collectorThreadId=setInterval(El.garbageCollect,30000);
var flyFn=function(){};
flyFn.prototype=El.prototype;
var _cls=new flyFn();
El.Flyweight=function(dom){
this.dom=dom;};
El.Flyweight.prototype=_cls;
El.Flyweight.prototype.isFlyweight=true;
El._flyweights={};
El.fly=function(el,named){
named=named||'_global';
el=wf.getDom(el);
if(!el){
return null;}
if(!El._flyweights[named]){
El._flyweights[named]=new El.Flyweight();}
El._flyweights[named].dom=el;
return El._flyweights[named];};
wf.get=El.get;
wf.fly=El.fly;
var noBoxAdjust=wf.isStrict?{
select:1}:{
input:1,select:1,textarea:1};
if(wf.isIE||wf.isGecko){
noBoxAdjust['button']=1;}
wf.EventManager.on(window,'unload',function(){
delete El.cache;
delete El._flyweights;});})();
wf.TaskRunner=function(interval){
interval=interval||10;
var tasks=[],removeQueue=[];
var id=0;
var running=false;
var stopThread=function(){
running=false;
clearInterval(id);
id=0;};
var startThread=function(){
if(!running){
running=true;
id=setInterval(runTasks,interval);}};
var removeTask=function(t){
removeQueue.push(t);
if(t.onStop){
t.onStop.apply(t.scope||t);}};
var runTasks=function(){
if(removeQueue.length>0){
for(var i=0,len=removeQueue.length;i<len;i++){
tasks.remove(removeQueue[i]);}
removeQueue=[];
if(tasks.length<1){
stopThread();
return;}}
var now=new Date().getTime();
for(var i=0,len=tasks.length;i<len;++i){
var t=tasks[i];
var itime=now-t.taskRunTime;
if(t.interval<=itime){
var rt=t.run.apply(t.scope||t,t.args||[++t.taskRunCount]);
t.taskRunTime=now;
if(rt===false||t.taskRunCount===t.repeat){
removeTask(t);
return;}}
if(t.duration&&t.duration<=(now-t.taskStartTime)){
removeTask(t);}}};
this.start=function(task){
tasks.push(task);
task.taskStartTime=new Date().getTime();
task.taskRunTime=0;
task.taskRunCount=0;
startThread();
return task;};
this.stop=function(task){
removeTask(task);
return task;};
this.stopAll=function(){
stopThread();
for(var i=0,len=tasks.length;i<len;i++){
if(tasks[i].onStop){
tasks[i].onStop();}}
tasks=[];
removeQueue=[];};};
wf.TaskMgr=new wf.TaskRunner();
wf.DelayedTask=function(fn,scope,args){
var id=null,d,t;
var call=function(){
var now=new Date().getTime();
if(now-t>=d){
clearInterval(id);
id=null;
fn.apply(scope,args||[]);}};
this.delay=function(delay,newFn,newScope,newArgs){
if(id&&delay!=d){
this.cancel();}
d=delay;
t=new Date().getTime();
fn=newFn||fn;
scope=newScope||scope;
args=newArgs||args;
if(!id){
id=setInterval(call,d);}};
this.cancel=function(){
if(id){
clearInterval(id);
id=null;}};};
wf.MixedCollection=function(keyFn){
this.items=[];
this.map={};
this.keys=[];
this.length=0;
if(keyFn){
this.getKey=keyFn;}
wf.MixedCollection.superclass.constructor.call(this);};
wf.extend(wf.MixedCollection,wf.Observable,{
add:function(key,o){
if(arguments.length==1){
o=arguments[0];
key=this.getKey(o);}
if(typeof key=="undefined"||key===null){
this.length++;
this.items.push(o);
this.keys.push(null);}
else{
var old=this.map[key];
if(old){
return this.replace(key,o);}
this.length++;
this.items.push(o);
this.map[key]=o;
this.keys.push(key);}
return o;},
addAll:function(objs){
if(arguments.length>1||objs instanceof Array){
var args=arguments.length>1?arguments:objs;
for(var i=0,len=args.length;i<len;i++){
this.add(args[i]);}}else{
for(var key in objs){
if(typeof objs[key]!="function"){
this.add(key,objs[key]);}}}},
getKey:function(o){
return o.id;},
replace:function(key,o){
if(arguments.length==1){
o=arguments[0];
key=this.getKey(o);}
var old=this.item(key);
if(typeof key=="undefined"||key===null||typeof old=="undefined"){
return this.add(key,o);}
var index=this.indexOfKey(key);
this.items[index]=o;
this.map[key]=o;
return o;},
last:function(){
return this.items[this.length-1];},
indexOfKey:function(key){
return this.keys.indexOf(key);},
each:function(fn,scope){
var items=[].concat(this.items);
for(var i=0,len=items.length;i<len;i++){
if(fn.call(scope||items[i],items[i],i,len)===false){
break;}}},
find:function(fn,scope){
for(var i=0,len=this.items.length;i<len;i++){
if(fn.call(scope||window,this.items[i],this.keys[i])){
return this.items[i];}}
return null;},
insert:function(index,key,o){
if(arguments.length==2){
o=arguments[1];
key=this.getKey(o);}
if(index>=this.length){
return this.add(key,o);}
this.length++;
this.items.splice(index,0,o);
if(typeof key!="undefined"&&key!=null){
this.map[key]=o;}
this.keys.splice(index,0,key);
return o;},
remove:function(o){
return this.removeAt(this.indexOf(o));},
removeAt:function(index){
if(index<this.length&&index>=0){
this.length--;
var o=this.items[index];
this.items.splice(index,1);
var key=this.keys[index];
if(typeof key!="undefined"){
delete this.map[key];}
this.keys.splice(index,1);
return o;}
return false;},
removeKey:function(key){
return this.removeAt(this.indexOfKey(key));},
getCount:function(){
return this.length;},
indexOf:function(o){
return this.items.indexOf(o);},
item:function(key){
var item=typeof this.map[key]!="undefined"?this.map[key]:this.items[key];
return typeof item!='function'?item:null;},
itemAt:function(index){
return this.items[index];},
key:function(key){
return this.map[key];},
contains:function(o){
return this.indexOf(o)!=-1;},
containsKey:function(key){
return typeof this.map[key]!="undefined";},
clear:function(){
this.length=0;
this.items=[];
this.keys=[];
this.map={};},
sort:function(dir,fn){
this._sort("value",dir,fn);},
_sort:function(property,dir,fn){
var dsc=String(dir).toUpperCase()=="DESC"?-1:1;
fn=fn||
function(a,b){
return a-b;};
var c=[],k=this.keys,items=this.items;
for(var i=0,len=items.length;i<len;i++){
c[c.length]={
key:k[i],
value:items[i],
index:i};}
c.sort(function(a,b){
var v=fn(a[property],b[property])*dsc;
if(v==0){
v=(a.index<b.index?-1:1);}
return v;});
for(var i=0,len=c.length;i<len;i++){
items[i]=c[i].value;
k[i]=c[i].key;}},
getRange:function(start,end){
var items=this.items;
if(items.length<1){
return[];}
start=start||0;
end=Math.min(typeof end=="undefined"?this.length-1:end,this.length-1);
var r=[];
if(start<=end){
for(var i=start;i<=end;i++){
r[r.length]=items[i];}}
else{
for(var i=start;i>=end;i--){
r[r.length]=items[i];}}
return r;},
filter:function(property,value,anyMatch,caseSensitive){
if(!value){
return this.clone();}
value=this.createValueMatcher(value,anyMatch,caseSensitive);
return this.filterBy(function(o){
return o&&value.test(o[property]);});},
filterBy:function(fn,scope){
var r=new wf.MixedCollection();
r.getKey=this.getKey;
var k=this.keys,it=this.items;
for(var i=0,len=it.length;i<len;i++){
if(fn.call(scope||this,it[i],k[i])){
r.add(k[i],it[i]);}}
return r;},
findIndex:function(property,value,start,anyMatch,caseSensitive){
if(!value){
return -1;}
value=this.createValueMatcher(value,anyMatch,caseSensitive);
return this.findIndexBy(function(o){
return o&&value.test(o[property]);},null,start);},
findIndexBy:function(fn,scope,start){
var k=this.keys,it=this.items;
for(var i=(start||0),len=it.length;i<len;i++){
if(fn.call(scope||this,it[i],k[i])){
return i;}}
if(typeof start=='number'&&start>0){
for(var i=0;i<start;i++){
if(fn.call(scope||this,it[i],k[i])){
return i;}}}
return -1;},
createValueMatcher:function(value,anyMatch,caseSensitive){
if(!value.exec){
value=String(value);
value=new RegExp((anyMatch===true?'':'^')+wf.escapeRe(value),caseSensitive?'':'i');}
return value;},
clone:function(){
var r=new wf.MixedCollection();
var k=this.keys,it=this.items;
for(var i=0,len=it.length;i<len;i++){
r.add(k[i],it[i]);}
r.getKey=this.getKey;
return r;}});
wf.MixedCollection.prototype.get=wf.MixedCollection.prototype.item;
wf.KeyNav=function(el,config){
this.el=wf.get(el);
wf.apply(this,config);
if(!this.disabled){
this.disabled=true;
this.enable();}};
wf.KeyNav.CTRL=1000;
wf.KeyNav.SHIFT=2000;
wf.KeyNav.ALT=4000;
wf.KeyNav.prototype={
disabled:false,
defaultEventAction:"stopEvent",
forceKeyDown:false,
prepareEvent:function(e){
var k=e.getKey();
var h=this.keyToHandler[k];
if(wf.isSafari&&h&&k>=37&&k<=40){
e.stopEvent();}},
addKeyHandler:function(o){
if(o){
wf.applyIf(this.keyToHandler,o);}},
relay:function(e){
var k=e.getKey();
var keyModifiers=0;
if(e.ctrlKey||e.metaKey)
keyModifiers+=wf.KeyNav.CTRL;
if(e.shiftKey)
keyModifiers+=wf.KeyNav.SHIFT;
if(e.altKey)
keyModifiers+=wf.KeyNav.ALT;
var keyCombination=k+keyModifiers;
var h=this.keyToHandler[keyCombination];
if(h&&this[h]){
if(this.doRelay(e,this[h],h)!==true){
e[this.defaultEventAction]();}}},
doRelay:function(e,h,hname){
return h.call(this.scope||this,e);},
enter:false,
left:false,
right:false,
up:false,
down:false,
tab:false,
esc:false,
pageUp:false,
pageDown:false,
del:false,
home:false,
end:false,
keyToHandler:{
37:"left",
39:"right",
38:"up",
40:"down",
33:"pageUp",
34:"pageDown",
46:"del",
36:"home",
35:"end",
13:"enter",
27:"esc",
9:"tab"},
enable:function(){
if(this.disabled){
if(this.forceKeyDown||wf.isIE||wf.isAir){
this.el.on("keydown",this.relay,this);}else{
this.el.on("keydown",this.prepareEvent,this);
this.el.on("keypress",this.relay,this);}
this.disabled=false;}},
disable:function(){
if(!this.disabled){
if(this.forceKeyDown||wf.isIE||wf.isAir){
this.el.un("keydown",this.relay);}else{
this.el.un("keydown",this.prepareEvent);
this.el.un("keypress",this.relay);}
this.disabled=true;}}}