if(typeof FLQ=='undefined')var FLQ=new Object()
FLQ.event=new Object()
FLQ.event.f={}
FLQ.event.addListener=function(ele,event,fRef,cap){if(typeof ele=='string'){ele=document.getElementById(ele)}
if(typeof ele.addEventListener!='undefined'){ele.addEventListener(event,fRef,cap)}else if(typeof ele.attachEvent!='undefined'){ele.attachEvent('on'+event,FLQ.event.getFunc(ele,event,fRef))}}
FLQ.event.add=FLQ.event.addListener
FLQ.event.getXY=function(e){if(typeof e=='undefined'){e=window.event}
var xy=[e.screenX,e.screenY]
return xy}
FLQ.event.removeListener=function(ele,event,fRef,capture){if(typeof ele=='string'){ele=document.getElementById(ele)}
if(typeof ele.removeEventListener!='undefined'){ele.removeEventListener(event,fRef,capture)}else if(typeof ele.detachEvent!='undefinded'){var f=FLQ.event.getFunc(ele,event,fRef)
ele.detachEvent('on'+event,f)
delete f}}
FLQ.event.getFunc=function(ele,event,fRef){if(typeof FLQ.event.f[event]=='undefined')FLQ.event.f[event]={}
if(typeof FLQ.event.f[event][ele]=='undefined')FLQ.event.f[event][ele]={}
if(typeof FLQ.event.f[event][ele][fRef]=='undefined')FLQ.event.f[event][ele][fRef]={}
FLQ.event.f[event][ele][fRef]=function(e){if(!e)e=window.event;fRef.apply(ele,[e])}
return FLQ.event.f[event][ele][fRef];}
FLQ.event.getTarget=function(e){if(typeof e.target!='undefined'){return e.target}else if(typeof e.srcElement!='undefined'){return e.srcElement}}
FLQ.event.stopProp=function(e){if(typeof e.stopPropagation!='undefined'){e.stopPropagation()}else if(typeof e.cancelBubble!='undefined'){e.cancelBubble=true}}
FLQ.event.prevDef=function(e){if(typeof e.preventDefault!='undefined'){e.preventDefault()}else{e.returnValue=false}}
FLQ.event.stopEvent=function(e){FLQ.event.stopProp(e)
FLQ.event.prevDef(e)}
if(typeof FLQ=='undefined')var FLQ=new Object()
if(typeof FLQ._=='undefined')FLQ._=new Object()
FLQ.isSet=function(v){return(v!='undefined'?true:false)}
FLQ.isNull=function(v){return(v===null?true:false)}
FLQ.isFunc=function(v){if(typeof v=='function'||(FLQ.isObj(v)&&String(v.constructor)==String(Function))){return true}else if(FLQ.isObj(v)){try{return(String(v).search(/^\s*function [a-zA-Z]+\(\) \{\s+\[native code\]\s+\}\s*$/)!=-1?true:false)}catch(z){}}
return false}
FLQ.isObj=function(v){return(!FLQ.isNull(v)&&typeof v=='object'?true:false)}
FLQ.isArr=function(v){return(FLQ.isObj(v)&&String(v.constructor)==String(Array)?true:false)}
FLQ.isStr=function(v){return(typeof v=='string'?true:false)}
FLQ.isInt=function(v){return(typeof v=='number'&&Math.floor(v)==v?true:false)}
FLQ.isBool=function(v){return(typeof v=='boolean'||v===true||v===false?true:false)}
FLQ.isScalar=function(v){return(FLQ.isStr(v)||FLQ.isInt(v)||FLQ.isFloat(v)||FLQ.isBool(v)?true:false)}
FLQ.isRegex=function(v){return(v&&FLQ.isFunc(v.test))||(FLQ.isObj(v)&&String(v.constructor)==String(RegExp))}
FLQ.ifNull=function(v){var a=arguments
for(i=0;FLQ.isSet(typeof a[i]);i++){if(!FLQ.isNull(a[i]))return a[i]}
return null}
FLQ.ifNaN=function(v){var a=arguments
for(i=0;FLQ.isSet(a[i]);i++){if(!isNaN(a[i]))return a[i]}
return NaN;}
if(!FLQ.isFunc(Array.prototype.search)){if(FLQ.isFunc(Array.prototype.indexOf)){Array.prototype.search=Array.prototype.indexOf}else{Array.prototype.search=function(v){for(var i=0;this[i];i++){if(this[i]===v)return i}
return-1}}}
FLQ.toHex=function(s){var r='',h,i
for(i=0;i<s.length;i++){h=s.charCodeAt(i).toString(16).toUpperCase()
r+=(h.length==1?'0':'')+h}
return r}
FLQ.fromHex=function(s){var r='',i
for(i=0;i<s.length;i+=2){r+=String.fromCharCode(parseInt(s.substr(i,2),16))}
return r}
FLQ.addClass=function(n,c){var m=n.className.split(/ +/),f=false,s=''
for(i in m){if(!FLQ.isFunc(m[i])){s+=(s.length>0?' ':'')+m[i]
if(m[i]==c)f=true}}
if(!f){s+=(s.length>0?' ':'')+c}
n.className=s}
FLQ.removeClass=function(n,c){var m=n.className.split(/ +/),s=''
for(i in m){if(m[i]!=c&&!FLQ.isFunc(m[i])){s+=(s.length>0?' ':'')+m[i]}}
n.className=s}
FLQ.hasClass=function(n,c){var m=n.className.split(/ +/)
for(i in m){if(m[i]==c)return true}
return false}
FLQ.getAvailHeight=function(n){var u=0,t=n.lastChild,s
while(t){s=FLQ.getStyle(t)
if(s.position!='absolute'){u=FLQ.ifNaN(parseInt(t.offsetTop),0)+FLQ.ifNaN(parseInt(s.marginTop),0)+FLQ.ifNaN(parseInt(s.marginBottom),0)
break}
t=t.previousSibling}
s=FLQ.getStyle(n)
u+=FLQ.ifNaN(parseInt(s.paddingBottom),0)+FLQ.ifNaN(parseInt(s.paddingTop),0)+FLQ.ifNaN(parseInt(s.borderTopWidth),0)+FLQ.ifNaN(parseInt(s.borderBottomWidth),0)
return n.offsetHeight-u}
FLQ.getStyle=function(n){var s={}
if(window.getComputedStyle){s=window.getComputedStyle(n,'')}else if(n.currentStyle){s=n.currentStyle}
return s}
FLQ.setNodeWidth=function(n,px){var s,i,k
if(px>0&&(s=FLQ.getStyle(n))){k=['paddingLeft','paddingRight','borderLeftWidth','borderRightWidth']
for(i=0;k[i];i++){px-=FLQ.ifNaN(parseInt(s[k[i]]),0)}
if(px>=0)n.style.width=px+'px'}}
FLQ.setNodeHeight=function(n,px){var s,i,k
if(px>0&&(s=FLQ.getStyle(n))){k=['paddingTop','paddingBottom','borderBottomWidth','borderTopWidth']
for(i=0;k[i];i++){px-=FLQ.ifNaN(parseInt(s[k[i]]),0)}
if(px>=0)n.style.height=px+'px'}};FLQ.popup=function(url,props){if(arguments.length<2)props={}
props['scrollbars']='1';var s='',n=''
if(FLQ.isSet(typeof props['name']))n=props['name']
for(i in props){s+=(s!=''?',':'')+i+'='+props[i]}
window.open(url,n,s)}
FLQ.lbox=function(){return FLQ.lbox.open.apply(FLQ.popup,arguments)}
FLQ.lbox.minWidth=200
FLQ.lbox.minHeight=100
FLQ.lbox.open=function(href){if(FLQ.isObj(FLQ._['lbox']))FLQ.lbox.close()
var a=arguments
var o=(a.length>1&&FLQ.isObj(a[a.length-1])?a[a.length-1]:{})
if(!FLQ.isSet(typeof o['width'])&&a.length>2)o['width']=a[1]
if(!FLQ.isSet(typeof o['height'])&&a.length>3)o['height']=a[2]
var d={'width':600,'height':400,'toolbars':'no','scrollbars':'yes','resizable':true}
for(var i in d){if(!FLQ.isSet(typeof o[i]))o[i]=d[i]}
if(FLQ.isSet(typeof o['name'])){var n=o['name']
delete o['name']}else{var n=href.replace(/[^a-zA-Z0-9_]/g,'')}
var d=document.createElement('div')
FLQ.addClass(d,'lboxwindow')
d.appendChild(b=document.createElement('div'))
FLQ.addClass(b,'background')
d.appendChild(i=document.createElement('div'))
FLQ.addClass(i,'lboxwindow-inner')
i.style.width=o['width']+'px'
i.style.height=o['height']+'px'
FLQ.lbox.setCenterPos(i)
i.innerHTML='<iframe frameborder="0" name="'+n+'" src="'+href+'"></iframe>'
FLQ.event.add(window,'resize',function(){FLQ.lbox.setCenterPos(i)})
i.appendChild(c=document.createElement('div'))
FLQ.addClass(c,'close')
FLQ.event.add(c,'click',FLQ.lbox.close)
FLQ.shortcut.add('Esc',FLQ.lbox.close)
if(o['resizable']){i.appendChild(r=document.createElement('div'))
FLQ.addClass(r,'resize')
FLQ.event.add(r,'mousedown',FLQ.lbox.startResize)}
if(FLQ.isSet(typeof o['args'])){if(!FLQ.isObj(FLQ._['lboxargs']))FLQ._['lboxargs']={}
FLQ._['lboxargs']=o['args']
delete o['args']}
i.appendChild(m=document.createElement('div'))
FLQ.addClass(m,'move')
FLQ.event.add(m,'mousedown',FLQ.lbox.startMove)
document.body.appendChild(d)
FLQ._['lbox']=d
return i.firstChild}
FLQ.lbox.close=function(reload){if(!FLQ.isBool(reload))reload=false
if(FLQ.isObj(FLQ._['lbox'])){if(reload)window.location.reload()
FLQ._['lbox'].parentNode.removeChild(FLQ._['lbox'])
FLQ._['lbox']=null
FLQ._['lboxargs']=null}
FLQ.shortcut.remove('Esc')}
FLQ.lbox.setCenterPos=function(n){var wWidth=(FLQ.isSet(typeof window.innerWidth)?window.innerWidth:document.documentElement.clientWidth)
var wHeight=(FLQ.isSet(typeof window.innerHeight)?window.innerHeight:document.documentElement.clientHeight)
n.style.left=Math.max((wWidth-parseInt(n.style.width))/2,0)+'px'
n.style.top=Math.max(((wHeight-parseInt(n.style.height))/2)-20,0)+'px'}
FLQ.lbox.getLauncher=function(){return window.top}
FLQ.lbox.getArgs=function(){if(window.parent){var o=window.parent
if(FLQ.isSet(typeof o.FLQ)&&FLQ.isSet(typeof o.FLQ._)&&FLQ.isSet(typeof o.FLQ._['lboxargs'])){return o.FLQ._['lboxargs']}}
return null}
FLQ.lbox.autoHeight=function(){if(FLQ._['lbox']){var i=FLQ._['lbox'].childNodes[1]
var d=i.getElementsByTagName('iframe')[0].contentWindow.document
if(d.body){if(d.height){i.style.height=Math.min(Math.max(d.height,d.body.offsetHeight,d.body.clientHeight)+6,window.top.innerHeight-60)+'px'}else{i.style.height=Math.min(Math.max(d.body.scrollHeight,d.body.offsetHeight,d.body.clientHeight)+6,window.top.document.documentElement.clientHeight-60)+'px'}}
FLQ.lbox.setCenterPos(i)}}
FLQ.lbox.startResize=function(e){if(FLQ._['lbox']){if(FLQ.lbox.moving)FLQ.lbox.endMove()
var iframe=FLQ._['lbox'].getElementsByTagName('iframe')[0]
FLQ.event.add(document.body,'mouseup',FLQ.lbox.endResize)
FLQ.event.add(document.body,'mousemove',FLQ.lbox.resize)
FLQ.event.add(iframe.contentWindow.document.body,'mouseup',FLQ.lbox.endResize)
FLQ.event.add(iframe.contentWindow.document.body,'mousemove',FLQ.lbox.resize)
FLQ.lbox.X=e.screenX
FLQ.lbox.Y=e.screenY
FLQ.lbox.resizing=true
FLQ.event.stopPropagation(e)}}
FLQ.lbox.endResize=function(){var iframe=FLQ._['lbox'].getElementsByTagName('iframe')[0]
FLQ.event.removeListener(document.body,'mousemove',FLQ.lbox.resize)
FLQ.event.removeListener(document.body,'mouseup',FLQ.lbox.endResize)
FLQ.event.removeListener(iframe.contentWindow.document.body,'mouseup',FLQ.lbox.endResize)
FLQ.event.removeListener(iframe.contentWindow.document.body,'mousemove',FLQ.lbox.resize)
FLQ.lbox.resizing=false}
FLQ.lbox.resize=function(e){if(FLQ._['lbox']){var m=FLQ._['lbox'].getElementsByTagName('iframe')[0].parentNode
var end=false
if(m){var w=e.screenX-FLQ.lbox.X
var h=e.screenY-FLQ.lbox.Y
if(w>3||w<3){var mw=parseInt(m.style.width)
var neww=(mw!=NaN?mw:m.offsetWidth)+w
if(neww>=FLQ.lbox.minWidth){m.style.width=neww+'px'
FLQ.lbox.X=e.screenX}else{end=true}}
if(h>3||h<3){var mh=parseInt(m.style.height)
var newh=(mh!=NaN?mh:m.offsteHeight)+h
if(newh>=FLQ.lbox.minHeight){m.style.height=newh+'px'
FLQ.lbox.Y=e.screenY}else{end=true}}}
if(end)FLQ.lbox.endResize()}}
FLQ.lbox.startMove=function(e){if(FLQ._['lbox']){if(FLQ.lbox.resizing)FLQ.lbox.endResize()
var iframe=FLQ._['lbox'].getElementsByTagName('iframe')[0]
FLQ.event.add(document.body,'mouseup',FLQ.lbox.endMove)
FLQ.event.add(document.body,'mousemove',FLQ.lbox.move)
FLQ.event.add(iframe.contentWindow.document.body,'mouseup',FLQ.lbox.endMove)
FLQ.event.add(iframe.contentWindow.document.body,'mousemove',FLQ.lbox.move)
FLQ.lbox.X=e.screenX
FLQ.lbox.Y=e.screenY
FLQ.lbox.moving=true
var m=iframe.parentNode
if(m){FLQ.addClass(m,'moving')}}}
FLQ.lbox.endMove=function(){var iframe=FLQ._['lbox'].getElementsByTagName('iframe')[0]
FLQ.event.removeListener(document.body,'mousemove',FLQ.lbox.move)
FLQ.event.removeListener(document.body,'mouseup',FLQ.lbox.endMove)
FLQ.event.removeListener(iframe.contentWindow.document.body,'mouseup',FLQ.lbox.endMove)
FLQ.event.removeListener(iframe.contentWindow.document.body,'mousemove',FLQ.lbox.move)
FLQ.lbox.moving=false
var m=FLQ._['lbox'].getElementsByTagName('iframe')[0].parentNode
if(m){FLQ.removeClass(m,'moving')}}
FLQ.lbox.move=function(e){if(FLQ._['lbox']){var m=FLQ._['lbox'].getElementsByTagName('iframe')[0].parentNode
if(m){var l=e.screenX-FLQ.lbox.X
var t=e.screenY-FLQ.lbox.Y
if(l>3||l<3){m.style.left=(parseInt(m.style.left)+l)+'px'
FLQ.lbox.X=e.screenX}
if(t>3||t<3){m.style.top=(parseInt(m.style.top)+t)+'px'
FLQ.lbox.Y=e.screenY}}}}
Number.prototype.pad=function(n,p){var s=''+this
p=p||'0'
while(s.length<n)s=p+s
return s}
Date.prototype.mths=['January','February','March','April','May','June','July','August','September','October','November','December'];Date.prototype.wd=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];Date.prototype.dim=[31,28,31,30,31,30,31,31,30,31,30,31];Date.prototype.strftime_f={A:function(d){return d.wd[d.getDay()]},a:function(d){return d.wd[d.getDay()].substring(0,3)},B:function(d){return d.mths[d.getMonth()]},b:function(d){return d.mths[d.getMonth()].substring(0,3)},C:function(d){return Math.floor(d.getFullYear()/100)},c:function(d){return d.toString()},D:function(d){return d.strftime_f.m(d)+'/'+d.strftime_f.d(d)+'/'+d.strftime_f.y(d)},d:function(d){return d.getDate().pad(2,'0')},e:function(d){return d.getDate().pad(2,' ')},F:function(d){return d.strftime_f.Y(d)+'-'+d.strftime_f.m(d)+'-'+d.strftime_f.d(d)},H:function(d){return d.getHours().pad(2,'0')},I:function(d){return((d.getHours()%12||12).pad(2))},j:function(d){var t=d.getDate()
var m=d.getMonth()-1
if(m>1){var y=d.getYear()
if(((y%100)==0)&&((y%400)==0)){++t}else if((y%4)==0){++t}}
while(m>-1)t+=d.dim[m--]
return t.pad(3,'0')},k:function(d){return d.getHours().pad(2,' ')},l:function(d){return((d.getHours()%12||12).pad(2,' '))},M:function(d){return d.getMinutes().pad(2,'0')},m:function(d){return(d.getMonth()+1).pad(2,'0')},n:function(d){return"\n"},p:function(d){return(d.getHours()>11)?'PM':'AM'},R:function(d){return d.strftime_f.H(d)+':'+d.strftime_f.M(d)},r:function(d){return d.strftime_f.I(d)+':'+d.strftime_f.M(d)+':'+d.strftime_f.S(d)+' '+d.strftime_f.p(d)},S:function(d){return d.getSeconds().pad(2,'0')},s:function(d){return Math.floor(d.getTime()/1000)},T:function(d){return d.strftime_f.H(d)+':'+d.strftime_f.M(d)+':'+d.strftime_f.S(d)},t:function(d){return"\t"},u:function(d){return(d.getDay()||7)},v:function(d){return d.strftime_f.e(d)+'-'+d.strftime_f.b(d)+'-'+d.strftime_f.Y(d)},w:function(d){return d.getDay()},X:function(d){return d.toTimeString()},x:function(d){return d.toDateString()},Y:function(d){return d.getFullYear()},y:function(d){return(d.getYear()%100).pad(2)},'%':function(d){return'%'}}
Date.prototype.strftime_f['+']=Date.prototype.strftime_f.c
Date.prototype.strftime_f.h=Date.prototype.strftime_f.b
Date.prototype.strftime=function(f){var r='',n=0,c
while(n<f.length){c=f.substring(n,n+1)
if(c=='%'){c=f.substring(++n,n+1)
r+=(this.strftime_f[c])?this.strftime_f[c](this):c}else{r+=c}
++n}
return r};Date.prototype.strptime_f={'Y':new RegExp('^-?[0-9]+'),'d':new RegExp('^[0-9]{1,2}'),'m':new RegExp('^[0-9]{1,2}'),'H':new RegExp('^[0-9]{1,2}'),'M':new RegExp('^[0-9]{1,2}'),'a':new RegExp('(Sun|Mon|Tue|Wed|Thu|Fri|Sat|Sun)'),'A':new RegExp('(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)'),'b':new RegExp('(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'),'B':new RegExp('(January|February|March|April|May|June|July|August|September|October|November|December)')}
Date.prototype._strptime=function(s,f){var p={},d,v,k,n
for(var i=0,o=0;i<f.length;i++,o++){var k=f.substr(i,1)
var n=s.substr(o,1)
if(k=='%'){k=f.substr(++i,1)
d=this.strptime_f[k].exec(s.substring(o))
if(d.length==0){return null}
d=d[0]
o+=d.length-1
v=d
if(k=='B'){p['m']=this.mths.search(v)+1}else{p[k]=v}
continue}else if(k!=n){return null}}
return p}
Date.prototype.strptime=function(s,f){var p,y
if(p=this._strptime(s,f)){this.setFullYear(p['Y']?p['Y']:0)
this.setMonth(p['m']?p['m']-1:0)
this.setDate(p['d']?p['d']:1)
if(p['H'])this.setHours(p['H'])
if(p['M'])this.setMinutes(p['M'])
return true}
return false}
FLQ.shortcut={}
FLQ.shortcut.enabled=false
FLQ.shortcut.events={}
FLQ.shortcut.add=function(s,f){if(!FLQ.shortcut.enabled)FLQ.shortcut.enable()
s=FLQ.shortcut.parse(s)
if(!FLQ.isFunc(FLQ.shortcut.events[s])){FLQ.shortcut.events[s]=f}else{throw('A function is already registered to the shortcut '+s)}}
FLQ.shortcut.remove=function(s){s=FLQ.shortcut.parse(s)
if(FLQ.shortcut.events[s])delete FLQ.shortcut.events[s]}
FLQ.shortcut.parse=function(s){s=s.toLowerCase()
var p=s.split('+')
var ctrl=false,alt=false,shift=false,esc=false,char=''
if(p&&p.length>0){for(var i=0;i<p.length;i++){switch(p[i]){case'ctrl':ctrl=true;break
case'alt':alt=true;break
case'shift':shift=true;break
case'esc':default:char+=(char.length>0?'+':'')+p[i]
break}}
var ns=''
if(ctrl)ns+='ctrl'
if(alt)ns+=(ns.length>0?'+':'')+'alt'
if(shift)ns+=(ns.length>0?'+':'')+'shift'
if(esc)ns+=(ns.length>0?'+':'')+'esc'
ns+=(ns.length>0?'+':'')+char
return ns}
return s}
FLQ.shortcut.handle=function(e){var t=FLQ.event.getTarget(e)
if(t.nodeName!='INPUT'||t.nodeName!='SELECT'){var s='';if(e.ctrlKey)s+='ctrl';if(e.altKey)s+=(s.length>0?'+':'')+'alt'
if(e.shiftKey)s+=(s.length>0?'+':'')+'shift'
if(e.keyCode==27){s+=(s.length>0?'+':'')+'esc'}else{var c=FLQ.event.getCharCode(e)
if(c>0)s+=(s.length>0?'+':'')+String.fromCharCode(c).toLowerCase()}
if(FLQ.isFunc(FLQ.shortcut.events[s])){FLQ.shortcut.events[s](e)
FLQ.event.stopEvent(e)}}}
FLQ.shortcut.catchKeys=function(e){var t=FLQ.event.getTarget(e)
if(t.nodeName!='INPUT'||t.nodeName!='SELECT'){var s=''
if(e.ctrlKey)s+='ctrl'
if(e.altKey)s+=(s.length>0?'+':'')+'alt'
if(e.shiftKey)s+=(s.length>0?'+':'')+'shift'
if(e.keyCode==27){s+=(s.length>0?'+':'')+'esc'}else{var c=FLQ.event.getCharCode(e)
if(c>0)s+=(s.length>0?'+':'')+String.fromCharCode(c).toLowerCase()}
if(FLQ.isFunc(FLQ.shortcut.events[s])){FLQ.event.stopEvent(e)}}}
FLQ.shortcut.enable=function(){FLQ.event.add(document,'keydown',FLQ.shortcut.handle)
FLQ.event.add(document,'keypress',FLQ.shortcut.catchKeys)
FLQ.shortcut.enabled=true}
FLQ.ajax=function(url,callback){this.url=url
this.handlers={}
this.headers={}
this.method='GET'
this.asynchronous=true
this.svr=null
if(arguments.length>1)this.addHandler(callback)}
FLQ.ajax.prototype.addHandler=function(func,status,state){if(arguments.length<2)status=200
if(arguments.length<3)state=4
if(FLQ.isFunc(func)){if(!FLQ.isObj(this.handlers[state]))this.handlers[state]={}
this.handlers[state][status]=func}}
FLQ.ajax.prototype.addHeader=function(key,val){this.headers[key]=val}
FLQ.ajax.prototype.send=function(data){if(arguments.length<1)data=''
if(this.url==null)throw('FLQ.ajax.send() - url must be specified')
var svr=false
if(FLQ.isSet(typeof ActiveXObject)){try{svr=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{svr=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){svr=false}}}else if(window.XMLHttpRequest){try{svr=new XMLHttpRequest()}catch(e){svr=false}}
if(svr){var a=this
svr.onreadystatechange=function(){try{var state=svr.readyState}catch(e){return false}
try{var status=svr.status}catch(e){return false}
a.state=state
if(FLQ.isSet(typeof a.handlers[state])&&FLQ.isFunc(a.handlers[state][status])){a.handlers[state][status](svr)}else if(FLQ.isSet(typeof a.handlers[state])&&FLQ.isFunc(a.handlers[state][''])){a.handlers[state][''](svr)}}
svr.open(this.method,this.url,this.asynchronous)
for(var i in this.headers){svr.setRequestHeader(i,this.headers[i])}
svr.send(data)}}
if(typeof FLQ=='undefined')var FLQ=function(){}
FLQ.URL=function(url){this.scheme=null;this.host=null;this.port=null;this.path=null;this.args={};this.anchor=null;if(arguments.length>0)this.set(url);}
FLQ.URL.thisURL=function(){return new FLQ.URL(window.location.href);}
FLQ.URL.prototype=new Object();FLQ.URL.prototype.set=function(url){var p;if(p=this.parseURL(url)){this.scheme=p['scheme'];this.host=p['host'];this.port=p['port'];this.path=p['path'];this.args=this.parseArgs(p['args']);this.anchor=p['anchor'];}}
FLQ.URL.prototype.removeArg=function(k){if(k&&String(k.constructor)==String(Array)){var t=this.args;for(var i=0;i<k.length-1;i++){if(typeof t[k[i]]!='undefined'){t=t[k[i]];}else{return false;}}
delete t[k[k.length-1]];return true;}else if(typeof this.args[k]!='undefined'){delete this.args[k];return true;}
return false;}
FLQ.URL.prototype.addArg=function(k,v,o){if(k&&String(k.constructor)==String(Array)){var t=this.args;for(var i=0;i<k.length-1;i++){if(typeof t[k[i]]=='undefined')t[k[i]]={};t=t[k[i]];}
if(o||typeof t[k[k.length-1]]=='undefined')t[k[k.length-1]]=v;}else if(o||typeof this.args[k]=='undefined'){this.args[k]=v;return true;}
return false;}
FLQ.URL.prototype.parseURL=function(url){var p={},m;if(m=url.match(/((s?ftp|https?):\/\/)?([^\/:]+)?(:([0-9]+))?([^\?#]+)?(\?([^#]+))?(#(.+))?/)){p['scheme']=(m[2]?m[2]:'http');p['host']=(m[3]?m[3]:window.location.host);p['port']=(m[5]?m[5]:null);p['path']=(m[6]?m[6]:null);p['args']=(m[8]?m[8]:null);p['anchor']=(m[10]?m[10]:null);return p;}
return false;}
FLQ.URL.parseArgs=function(s){var a={};if(s&&s.length){var kp,kv;var p;if((kp=s.split('&'))&&kp.length){for(var i=0;i<kp.length;i++){if((kv=kp[i].split('='))&&kv.length==2){kv[0]=FLQ.URL.decode(kv[0])
kv[1]=FLQ.URL.decode(kv[1])
if(p=kv[0].split(/(\[|\]\[|\])/)){if(p[p.length-1]=='')p.splice(p.length-1,1);for(var z=0;z<p.length;z++){if(p[z]==']'||p[z]=='['||p[z]==']['){p.splice(z,1);}}
var t=a;for(var o=0;o<p.length-1;o++){if(typeof t[p[o]]=='undefined')t[p[o]]={};t=t[p[o]];}
t[p[p.length-1]]=kv[1];}else{a[kv[0]]=kv[1];}}}}}
return a;}
FLQ.URL.prototype.parseArgs=function(s){return FLQ.URL.parseArgs(s)}
FLQ.URL.prototype.toArgs=function(a,p){if(arguments.length<2)p='';if(a&&typeof a=='object'){var s='';for(i in a){if(typeof a[i]!='function'){if(s.length)s+='&';if(typeof a[i]=='object'){var k=(p.length?p+'['+i+']':i);s+=this.toArgs(a[i],k);}else{s+=p+(p.length&&i!=''?'[':'')+i+(p.length&&i!=''?']':'')+'='+a[i];}}}
return s;}
return'';}
FLQ.URL.prototype.toAbsolute=function(){var s='';if(this.scheme!=null)s+=this.scheme+'://';if(this.host!=null)s+=this.host;if(this.port!=null)s+=':'+this.port;s+=this.toRelative();return s;}
FLQ.URL.prototype.toRelative=function(){var s='';if(this.path!=null)s+=this.path;var a=this.toArgs(this.args);if(a.length)s+='?'+a;if(this.anchor!=null)s+='#'+this.anchor;return s;}
FLQ.URL.prototype.isHost=function(){var u=FLQ.URL.thisURL();return(this.host==null||this.host==u.host?true:false);}
FLQ.URL.prototype.toString=function(){return(this.isHost()?this.toRelative():this.toAbsolute());}
FLQ.URL.encode=function(s){var r='',c,i,cs='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$-_.!*\'(),'
for(i=0;i<s.length;i++){c=s.substr(i,1)
if(c==' '){c='+'}else if(FLQ.URL.cs.indexOf(c)==-1){c='%'+FLQ.toHex(c)}
r+=c}
return r}
FLQ.URL.decode=function(s){var r='',c,i
for(i=0;i<s.length;i++){c=s.substr(i,1)
if(c=='+'){c=' '}else if(c=='%'&&s.substr(i+1,1)!='%'){c=FLQ.fromHex(s.substr(i+1,2))
i+=2}
r+=c}
return r}
var $=function(i){return document.getElementById('mlk-'+i)}
var Milk={SLOT_SAMEWIN:'_self',SLOT_NEWWIN:'_blank',SLOT_CHILDWIN:'_child',SLOT_LIGHTWIN:'_light',SLOT_AJAX:'_ajax',SLOT_LAUNCHER:'_launcher',errors:[],history:[],c:{},NOTIFY_ERROR:'error',NOTIFY_WARNING:'warning',NOTIFY_MESSAGE:'message'}
Milk.add=function(ctrl,id,props){var c=new Milk.Ctrl[ctrl](id)
c.setProps(props)
Milk.c[id]=c
return c}
Milk.get=function(id){if(Milk.c[id])return Milk.c[id]}
Milk.Ctrl={}
Milk.getArg=function(args,arg){if(FLQ.isObj(args)&&FLQ.isSet(typeof args[arg])){return args[arg]}
return null}
Milk.mergeArgs=function(){var args={},i,j
for(i=0;arguments[i];i++){if(FLQ.isObj(arguments[i])){for(j in arguments[i]){if(!FLQ.isFunc(arguments[i][j]))args[j]=arguments[i][j]}}}
return args}
Milk.getLauncher=function(){var a
if(window.parent&&window.parent.FLQ&&window.parent.FLQ._&&window.parent.FLQ._['lbox']){a=window.parent.FLQ.lbox.getArgs()
if(FLQ.isObj(a)&&FLQ.isSet(typeof a['launcher'])&&window.parent.Milk){return window.parent.Milk.get(a['launcher'])}}else{a=FLQ.popup.getArgs(),o=FLQ.popup.getLauncher()
if(FLQ.isObj(a)&&FLQ.isSet(typeof a['launcher'])&&o!==null&&FLQ.isSet(typeof o.Milk)){return o.Milk.get(a['launcher'])}}
return null}
Milk.editHistory=function(k,v){if(Milk.history.length>0){var u=new FLQ.URL(Milk.history[Milk.history.length-1])
if(v===null){u.removeArg(k)}else{u.addArg(k,v,true)}
Milk.history[Milk.history.length-1]=u.toString()}}
Milk.notify=function(t,err){var s=''
for(var i=0;err[i];i++){s+='- '+err[i]+'\n'}
alert(s)}
Milk.Conn=function(src,signal,destId,slot,args){this.src=src
this.signal=signal
this.destId=destId
this.slot=slot
this.args=args
if((this.slot=='back'||this.slot=='reload'||this.slot=='refresh')&&Milk.getArg(args,'validate')!=true){if(!FLQ.isObj(this.args))this.args=[]
this.args['validate']=false}
if(this.destId==Milk.SLOT_SAMEWIN||this.destId==Milk.SLOT_NEWWIN||this.destId==Milk.SLOT_CHILDWIN||this.destId==Milk.SLOT_LIGHTWIN||this.destId==Milk.SLOT_AJAX){this.dest=this.destId
this.exec=Milk.Conn.serverExec}else{this.dest=(this.destId==Milk.SLOT_LAUNCHER?Milk.getLauncher():Milk.get(this.destId))
this.exec=Milk.Conn.clientExec}}
Milk.Conn.clientExec=function(args,e){args=Milk.mergeArgs(this.args,args)
if(!FLQ.isSet(typeof args['send'])||args.send===true){for(var i in Milk.c){if((!FLQ.isSet(typeof args.send)&&Milk.c[i].defaultSend)||args.send){if(Milk.c[i].getData)args=Milk.mergeArgs(args,Milk.c[i].getData())
if(!FLQ.isSet(typeof args.validate)||args.validate){if(Milk.c[i].validate){Milk.c[i].validate()}}}}
if(Milk.errors[0]){Milk.notify(Milk.NOTIFY_ERROR,Milk.errors)
return false}}
if(FLQ.isSet(typeof args.send))delete args.send
if(FLQ.isSet(typeof args.validate))delete args.validate
if(FLQ.isSet(typeof args.confirm)){if(!confirm(args.confirm))return
delete args.confirm}
this.dest.execSlot(this.slot,args,e)}
Milk.Conn.serverExec=function(args){args=Milk.mergeArgs(args,this.args)
if(this.dest==Milk.SLOT_SAMEWIN||this.dest==Milk.SLOT_NEWWIN||this.dest==Milk.SLOT_CHILDWIN||this.dest==Milk.SLOT_LIGHTWIN||this.dest==Milk.SLOT_AJAX){var frm=document.createElement('form')
frm.setAttribute('method','get')
if(Milk.getArg(args,'modurl')){frm.setAttribute('action',args.modurl)
delete args.modurl}else{frm.setAttribute('action',window.location.pathname)}
function add_field(frm,key,val){if(FLQ.isObj(key)){for(var i in key){if(!FLQ.isFunc(key[i])){add_field(frm,i,key[i])}}}else if(FLQ.isObj(val)){for(var i in val){if(!FLQ.isFunc(val[i])){add_field(frm,key+'['+i+']',val[i])}}}else{if(FLQ.isBool(val)){val=(val?'1':'0')}
var s=document.createElement('span')
s.innerHTML='<input type="hidden" />'
s.firstChild.setAttribute('name',key)
s.firstChild.setAttribute('value',FLQ.ifNull(val,''))
frm.appendChild(s.firstChild)}}
if(Milk.getArg(args,'confirm')){if(!confirm(args.confirm))return
delete args.confirm}
if(!FLQ.isSet(typeof args.send)||args.send===true){frm.setAttribute('method','post')
for(var i in Milk.c){if((!FLQ.isSet(typeof args.send)&&Milk.c[i].defaultSend)||args.send){if(Milk.c[i].addData)Milk.c[i].addData(frm)
if(Milk.c[i].getData)add_field(frm,Milk.c[i].getData())
if(!FLQ.isSet(typeof args.validate)||args.validate){if(Milk.c[i].validate)Milk.c[i].validate()}}}
if(Milk.errors[0]){Milk.notify(Milk.NOTIFY_ERROR,Milk.errors)
return false}}
if(FLQ.isSet(typeof args.send))delete args.send
if(FLQ.isSet(typeof args.validate))delete args.validate
if(this.dest==Milk.SLOT_SAMEWIN){frm.setAttribute('target','_self')
if(!FLQ.isSet(typeof args.nohistory)){for(var i=0;Milk.history[i];i++){add_field(frm,'history['+i+']',Milk.history[i])}}else{delete args.nohistory}}else if(this.dest==Milk.SLOT_NEWWIN){if(FLQ.isSet(typeof args.target)){frm.setAttribute('target',args.target)
delete args.target}else{frm.setAttribute('target','_blank')}}else if(this.dest==Milk.SLOT_CHILDWIN){if(FLQ.isSet(typeof args.target)){var t=args.target}else{var t='newwin_'+(this.src?this.src.id:'unknown')}
var props={'width':(FLQ.isSet(typeof args.width)?args.width:600),'height':(FLQ.isSet(typeof args.height)?args.height:600),'name':t,'dependant':true,'args':{'launcher':(this.src?this.src.id:null)},'status':'yes'}
var w=FLQ.popup('/milk/blank.php',props)
frm.setAttribute('target',t)
delete args.width
delete args.height
delete args.target}else if(this.dest==Milk.SLOT_LIGHTWIN){if(FLQ.isSet(typeof args.target)){var t=args.target}else{var t='newwin_'+(this.src?this.src.id:'unknown')}
var props={'width':(FLQ.isSet(typeof args.width)?args.width:600),'height':(FLQ.isSet(typeof args.height)?args.height:400),'name':t,'args':{'launcher':(this.src?this.src.id:null)}}
var w=FLQ.lbox('/milk/blank.php',props)
if(!FLQ.isSet(typeof args.height)&&w){FLQ.event.add(w,'load',function(){setTimeout(FLQ.lbox.autoHeight,300)})}
frm.setAttribute('target',t)
delete args.width
delete args.height
delete args.target}
var ajaxResponse={}
if(this.dest===Milk.SLOT_AJAX&&FLQ.isSet(typeof args.response)){ajaxResponse=args.response
delete args.response}
if(!FLQ.isSet(typeof args.nohistory)){add_field(frm,'act',this.slot)}
delete args.nohistory
add_field(frm,args)
if(this.dest==Milk.SLOT_AJAX){var ajax=new FLQ.ajax(frm.getAttribute('action'))
ajax.method='POST'
var data=''
for(var n,i=0;frm.childNodes[i];i++){n=frm.childNodes[i]
if(n.nodeType==1&&n.nodeName=='INPUT'&&n.getAttribute('type')=='hidden'&&!(/^response\[/.exec(n.name))){if(data[0])data+='&'
data+=escape(n.name)+'='+escape(n.value)}}
for(var i in ajaxResponse){if(!FLQ.isFunc(ajaxResponse[i])){ajax.addHandler(Milk.Conn.ajaxResponse(ajaxResponse[i].dest,ajaxResponse[i].slot,ajaxResponse[i].args),i)}}
ajax.addHandler(Milk.Conn.ajaxShowErrors,'')
ajax.addHandler(Milk.Conn.ajaxUnauthorised,401)
ajax.addHeader('Content-Type','application/x-www-form-urlencoded')
ajax.send(data)}else{document.body.appendChild(frm)
frm.submit()}}}
Milk.Conn.ajaxResponse=function(dest,slot,args){var c=new Milk.Conn(null,null,dest,slot,args)
var f=function(svr){c.exec({'svr':svr,'validate':false})
Milk.Conn.ajaxShowErrors(svr)}
return f}
Milk.Conn.ajaxShowErrors=function(svr){if(svr.responseXML){var e=svr.responseXML.getElementsByTagName('error')
var s=[]
for(var i=0;e[i];i++){if(e[i].firstChild.nodeType==3){s.push(e[i].firstChild.nodeValue)}}
if(s[0]){alert('- '+s.join('\n- '))}}}
Milk.Conn.ajaxUnauthorised=function(){new Milk.Conn(null,null,Milk.SLOT_SAMEWIN,'refresh').exec({'send':false,'validate':false})}
var MilkCtrl=function(){this.id=null
this.signals=null
this.saveGroup=null
this.groupCtrls={}}
MilkCtrl.prototype={}
MilkCtrl.prototype.init=function(){}
MilkCtrl.prototype.setProps=function(props){for(var i in props){this[i]=props[i]}}
MilkCtrl.prototype.connect=function(signal,destId,slot,args){if(this.signals===null)this.signals={}
if(!FLQ.isSet(typeof this.signals[signal]))this.signals[signal]=[]
if(!FLQ.isObj(args))args={}
this.signals[signal].push(new Milk.Conn(this,signal,destId,slot,args))}
MilkCtrl.prototype.sendSignal=function(signal,args,e){if(this.hasSignal(signal)){if(!FLQ.isObj(args))args={}
var newargs=this.mergeSignalArgs(signal,args)
if(FLQ.isObj(newargs)){for(var i=0;this.signals[signal][i];i++){this.signals[signal][i].exec(newargs,e)}}}}
MilkCtrl.prototype.hasSignal=function(signal){return(FLQ.isObj(this.signals)&&FLQ.isSet(typeof this.signals[signal])&&FLQ.isArr(this.signals[signal])?true:false)}
MilkCtrl.prototype.hasSlot=function(slot){return((FLQ.isSet(typeof this[slot])&&FLQ.isFunc(this[slot]))?true:false)}
MilkCtrl.prototype.hasValue=function(v){if(v===null){return false}else if((FLQ.isStr(v)||FLQ.isArr(v))&&v.length==0){return false}else if(FLQ.isObj(v)){for(var i in v){if(!FLQ.isFunc(v[i])){return true}}
return false}
return true}
MilkCtrl.prototype.mergeSignalArgs=function(signal,args){if(this.hasSignal(signal)){var send=false
var require=false
for(var i=0;this.signals[signal][i];i++){if((this.signals[signal][i].args&&this.signals[signal][i].args['send'])||this.defaultSend)send=true
if((this.signals[signal][i].args&&this.signals[signal][i].args['require'])||this.defaultRequire)require=true}
if(FLQ.isSet(typeof args['send']))send=args['send']
if(FLQ.isSet(typeof args['require']))require=args['require']
var v=null
if(FLQ.isFunc(this.getValue))v=this.getValue()
if(require&&!this.hasValue(v)){alert('An item must be selected')
var args=null}else if(this.hasValue(v)){var args=Milk.mergeArgs(args,v)}}
return args}
MilkCtrl.prototype.execSlot=function(slot,args,e){if(this.hasSlot(slot)){this[slot](args,e)}else if(!this.strictConns){this.sendSignal(slot,args,e)}else{throw('Unable to execute slot '+slot)}}
MilkCtrl.prototype.refresh=function(){new Milk.Conn(null,null,Milk.SLOT_SAMEWIN,'refresh').exec({'send':true,'validate':false})}
MilkCtrl.prototype.fillHeight=function(n){var h=FLQ.getAvailHeight(n.parentNode)
if(h>n.offsetHeight)FLQ.setNodeHeight(n,h)}
MilkCtrl.prototype.setSaveGroup=function(group){this.saveGroup=group
this._hasChanged=this.hasChanged
this.hasChanged=this.haveChanged
if(!FLQ.isSet(typeof this.groupCtrls[this.saveGroup]))this.groupCtrls[this.saveGroup]=[]
this.groupCtrls[this.saveGroup].push(this)}
MilkCtrl.prototype.haveChanged=function(){if(this.saveGroup&&FLQ.isSet(typeof this.groupCtrls[this.saveGroup])){for(var i=0;this.groupCtrls[this.saveGroup][i];i++){if(this.groupCtrls[this.saveGroup][i]._hasChanged())return true}}
return false}
Milk.Ctrl.Text=function(id){this.id=id
this.n=null}
Milk.Ctrl.Text.prototype=new MilkCtrl()
Milk.Ctrl.Text.prototype.init=function(){this.n=$(this.id)
var c=this
FLQ.event.add(this.n,'click',function(e){c.sendSignal('click');FLQ.event.stopEvent(e)})}
Milk.Ctrl.Label=function(id){this.id=id
this.n=null}
Milk.Ctrl.Label.prototype=new MilkCtrl()
Milk.Ctrl.Label.prototype.init=function(){this.n=$(this.id)
var c=this
FLQ.event.add(this.n,'click',function(e){c.sendSignal('click');FLQ.event.stopEvent(e)})}
Milk.Ctrl.Heading=function(id){this.id=id
this.n=null}
Milk.Ctrl.Heading.prototype=new MilkCtrl()
Milk.Ctrl.Heading.prototype.init=function(){this.n=$(this.id)
var c=this
FLQ.event.add(this.n,'click',function(e){c.sendSignal('click');FLQ.event.stopEvent(e)})}
Milk.Ctrl.Image=function(id){this.id=id
this.n=null}
Milk.Ctrl.Image.prototype=new MilkCtrl()
Milk.Ctrl.Image.prototype.init=function(){this.n=$(this.id)
var c=this
FLQ.event.add(this.n,'click',function(){c.sendSignal('click')})}
Milk.Ctrl.Terminator=function(id){this.id=id
this.reload=true
this.url=null
this.doclose=true}
Milk.Ctrl.Terminator.prototype=new MilkCtrl()
Milk.Ctrl.Terminator.prototype.init=function(){if(this.reload){if(FLQ.isStr(this.url)&&this.url.length>0){if(window.parent&&window.parent.FLQ&&window.parent.FLQ._&&window.parent.FLQ._['lbox']){window.parent.location=this.url}else if(window.opener){window.opener.location=this.url}}else{var l=Milk.getLauncher()
if(l!==null&&l.hasSlot('refresh'))l.refresh()}}
if(this.doclose)this.close()}
Milk.Ctrl.Terminator.prototype.close=function(){if(window.parent&&window.parent.FLQ&&window.parent.FLQ._&&window.parent.FLQ._['lbox']){window.parent.FLQ.lbox.close()}else if(window.opener){window.close()}else{window.location='/'}}
Milk.Ctrl.VerticalBox=function(id){this.id=id
this.fitHeight=false}
Milk.Ctrl.VerticalBox.prototype=new MilkCtrl()
Milk.Ctrl.VerticalBox.prototype.init=function(){this.n=$(this.id)
var c=this
if(this.fitHeight)setTimeout(function(){c.fillHeight(c.n);c.fillHeight(c.n.lastChild)},100)}
Milk.Ctrl.VertBox=Milk.Ctrl.VerticalBox
Milk.Ctrl.VBox=Milk.Ctrl.VerticalBox
Milk.Ctrl.VertContainer=Milk.Ctrl.VerticalBox
Milk.Ctrl.VertCont=Milk.Ctrl.VerticalBox
Milk.Ctrl.VCont=Milk.Ctrl.VerticalBox
Milk.Ctrl.HideBox=function(id){this.id=id
this.n=null
this.currentShow=false
this.defaultSend=false}
Milk.Ctrl.HideBox.prototype=new MilkCtrl()
Milk.Ctrl.HideBox.prototype.init=function(){this.n=$(this.id)}
Milk.Ctrl.HideBox.prototype.show=function(){FLQ.removeClass(this.n,'hidebox-hide')
FLQ.addClass(this.n,'hidebox-show')
this.currentShow=true
Milk.editHistory([this.id,'show'],1)
this.sendSignal('show')}
Milk.Ctrl.HideBox.prototype.hide=function(){FLQ.removeClass(this.n,'hidebox-show')
FLQ.addClass(this.n,'hidebox-hide')
this.currentShow=false
Milk.editHistory([this.id,'show'],0)
this.sendSignal('hide')}
Milk.Ctrl.HideBox.prototype.toggle=function(){if(this.currentShow){this.hide()}else{this.show()}}
Milk.Ctrl.Template=function(id){this.id=id}
Milk.Ctrl.Template.prototype=new MilkCtrl()
Milk.Ctrl.Template.prototype.init=function(){setTimeout('Milk.get(\''+this.id+'\').load()',0);}
Milk.Ctrl.Template.prototype.load=function(){this.sendSignal('load',{'send':false})}
Milk.Ctrl.Tabs=function(id){this.id=id
this.n=null
this.tab=null}
Milk.Ctrl.Tabs.prototype=new MilkCtrl()
Milk.Ctrl.Tabs.prototype.init=function(){this.n=$(this.id)
if(this.n.firstChild&&this.n.firstChild.childNodes){var i,c=this,l=this.n.firstChild.childNodes
for(i=0;l[i];i++){if(l[i]&&FLQ.hasClass(l[i],'tablabel')){FLQ.event.add(l[i],'click',Function('','Milk.get(\''+this.id+'\').showTab('+i+')'))}}}
this.showTab(this.tab)
this.resize()}
Milk.Ctrl.Tabs.prototype.showTab=function(i){var p=this.id+'-'+i+'-',s=this.id+'-'+this.tab+'-'
if(i!=this.tab&&!FLQ.hasClass($(p+'label'),'tablabel-disabled')){FLQ.removeClass($(s+'label'),'tablabel-selected')
FLQ.removeClass($(s+'tab'),'tab-selected')
FLQ.addClass($(p+'label'),'tablabel-selected')
FLQ.addClass($(p+'tab'),'tab-selected')
Milk.editHistory([this.id,'tab'],i)
this.tab=i}}
Milk.Ctrl.Tabs.prototype.resize=function(){if(this.n.childNodes&&this.n.childNodes[1]&&this.n.childNodes[1].childNodes){var i,mh=0,t=this.n.childNodes[1].childNodes
for(i=0;t[i];i++){FLQ.removeClass(t[i],'tab-off')
if(t[i].offsetHeight>mh)mh=t[i].offsetHeight
FLQ.addClass(t[i],'tab-off')}
if(mh>0)this.n.childNodes[1].style.height=mh+'px'}}
Milk.Ctrl.DataGrid=function(id){this.id=id
this.defaultRequire=true
this.n=null
this.b=null
this.f=[]
this.perpage=null
this.offset=null
this.totalrows=null
this.connected=false}
Milk.Ctrl.DataGrid.prototype=new MilkCtrl()
Milk.Ctrl.DataGrid.prototype.init=function(){this.n=$(this.id)
this.b=this.n.tBodies[0]
var i,c=this,tr=this.n.getElementsByTagName('TR'),th=this.n.getElementsByTagName('TH')
if(this.connected){for(i=1;tr[i];i++){FLQ.event.add(tr[i],'mouseover',function(){FLQ.addClass(this,'datagrid-hover');c.sendSignal('hover')})
FLQ.event.add(tr[i],'mouseout',function(){FLQ.removeClass(this,'datagrid-hover')})
FLQ.event.add(tr[i],'click',function(e){c.focus(this.rowIndex,e)})
FLQ.event.add(tr[i],'dblclick',function(e){c.select(this.rowIndex,e)})}}
for(i=0;th[i];i++){FLQ.event.add(th[i],'click',Function('','Milk.get(\''+this.id+'\').sort('+i+')'))}}
Milk.Ctrl.DataGrid.prototype.getValue=function(){var vs=[],r,v,a,i
if(FLQ.isArr(this.f)){for(i=0;this.f[i];i++){r=this.f[i]
v={}
if(r!==null&&(a=this.b.rows[r].getAttribute('actarg'))){v=FLQ.URL.parseArgs(a)}
vs.push(v)}}
if(vs.length==1){return vs[0]}else{v={}
if(vs.length)v['value']=vs
for(i=0;vs[i];i++)v[i]=vs[i]
return v}}
Milk.Ctrl.DataGrid.prototype.focus=function(r,e){if(r<0)return false
if(e.ctrlKey){var i
if((i=this.f.search(r))!=-1){FLQ.removeClass(this.b.rows[r],'datagrid-focus')
this.f.splice(i,1)}else{FLQ.addClass(this.b.rows[r],'datagrid-focus')
this.f.push(r)
this.sendSignal('focus')}}else if(this.f.search(r)==-1||this.f.length>1){if(this.b&&this.b.rows&&this.b.rows[r]){if(this.f.length>0){for(var i=0;this.f[i];i++){FLQ.removeClass(this.b.rows[this.f[i]],'datagrid-focus')}}
FLQ.addClass(this.b.rows[r],'datagrid-focus')
this.f=[r]
this.sendSignal('focus')}}}
Milk.Ctrl.DataGrid.prototype.select=function(r,e){if(this.f.search(r)==-1)this.focus(r,e)
this.sendSignal('select')}
Milk.Ctrl.DataGrid.prototype.first=function(){Milk.editHistory([this.id,'offset'],0)
new Milk.Conn(this,'first',Milk.SLOT_SAMEWIN,'refresh').exec({'send':true})
this.offset=0}
Milk.Ctrl.DataGrid.prototype.prev=function(){var os=Math.max(0,(this.offset-this.perpage))
Milk.editHistory([this.id,'offset'],os)
new Milk.Conn(this,'previous',Milk.SLOT_SAMEWIN,'refresh').exec({'send':true})
this.offset=os}
Milk.Ctrl.DataGrid.prototype.next=function(){var os=Math.min(this.totalrows-1,(this.offset+this.perpage))
Milk.editHistory([this.id,'offset'],os)
new Milk.Conn(this,'next',Milk.SLOT_SAMEWIN,'refresh').exec({'send':true})
this.offset=os}
Milk.Ctrl.DataGrid.prototype.last=function(){var os=this.totalrows-1
Milk.editHistory([this.id,'offset'],os)
new Milk.Conn(this,'last',Milk.SLOT_SAMEWIN,'refresh').exec({'send':true})
this.offset=os}
Milk.Ctrl.DataGrid.prototype.sort=function(c){var d=(c==this.sortCol&&!this.sortDesc?1:0)
Milk.editHistory([this.id,'sortCol'],c)
Milk.editHistory([this.id,'sortDesc'],d)
new Milk.Conn(this,'sort',Milk.SLOT_SAMEWIN,'refresh').exec({'send':true})}
Milk.Ctrl.DataGrid.prototype.csv=function(){Milk.editHistory([this.id,'csv'],1)
new Milk.Conn(this,'sort',Milk.SLOT_SAMEWIN,'refresh').exec({'send':true})}
Milk.Ctrl.Button=function(id){this.id=id
this.n=null}
Milk.Ctrl.Button.prototype=new MilkCtrl()
Milk.Ctrl.Button.prototype.init=function(){this.n=$(this.id)
var c=this
FLQ.event.add(this.n,'click',function(e){c.sendSignal('click');FLQ.event.stopEvent(e)})}
Milk.Ctrl.Button.prototype.disable=function(args){var d=(FLQ.isSet(typeof args['disable'])?args['disable']:true);if(d){this.disabled=true;FLQ.addClass(this.n,'button-disabled');}else{this.disabled=false;FLQ.removeClass(this.n,'button-disabled');}}
Milk.Ctrl.Form=function(id){this.id=id
this.n=null
this.defaultSend=true
this.value=null
this.reqValue=null}
Milk.Ctrl.Form.prototype=new MilkCtrl()
Milk.Ctrl.Form.prototype.getValue=function(){return this.n.value}
Milk.Ctrl.Form.prototype.hasChanged=function(){return(this.getValue()!=this.value?true:false)}
Milk.Ctrl.Form.prototype.getData=function(){if(this.hasChanged()){var d={}
d[this.n.name]=this.getValue()
return d}
return null}
Milk.Ctrl.Form.prototype.setvalue=function(args){var v
if(v=Milk.getArg(args,'value')){this.n.value=v}}
Milk.Ctrl.Form.prototype.focus=function(){this.n.focus()}
Milk.Ctrl.TextBox=function(id){this.id=id
this.n=null}
Milk.Ctrl.TextBox.prototype=new Milk.Ctrl.Form()
Milk.Ctrl.TextBox.prototype.init=function(){this.n=$(this.id).firstChild
var c=this
FLQ.event.add(this.n,'keypress',function(e){c.keypress(e)})}
Milk.Ctrl.TextBox.prototype.keypress=function(e){if(e.keyCode&&e.keyCode==13){if(this.n.nodeName.toLowerCase()!='textarea'){this.sendSignal('enter')
FLQ.event.stopEvent(e)}}}
Milk.Ctrl.PasswordBox=function(id){this.id=id}
Milk.Ctrl.PasswordBox.prototype=new Milk.Ctrl.TextBox()
Milk.Ctrl.PasswordBox.prototype.init=function(){this.n=$(this.id).firstChild
var c=this
FLQ.event.add(this.n,'keypress',function(e){c.keypress(e)})}
Milk.Ctrl.ListBox=function(id){this.id=id
this.min=null
this.max=1}
Milk.Ctrl.ListBox.prototype=new Milk.Ctrl.Form()
Milk.Ctrl.ListBox.prototype.init=function(){this.n=$(this.id).firstChild}
Milk.Ctrl.ListBox.prototype.getValue=function(){var v,i
if(this.max>1||this.max==null){v=[]
for(i=0;this.n.options[i];i++){if(this.n.options[i].selected){v.push(this.n.options[i].value)}}
return v}else{if(this.n.selectedIndex!=-1&&this.n.options[this.n.selectedIndex]){v=this.n.options[this.n.selectedIndex].value
return(v.length==0?null:v)}else{alert(this.id+' null')
return null}}}
Milk.Ctrl.BoolBox=function(id){this.id=id
this.n=null}
Milk.Ctrl.BoolBox.prototype=new Milk.Ctrl.Form()
Milk.Ctrl.BoolBox.prototype.init=function(){this.n=$(this.id).firstChild
var c=this
FLQ.event.add(this.n,'change',function(){c.sendSignal('change',{'value':c.getValue()})})}
Milk.Ctrl.BoolBox.prototype.getValue=function(){return(this.n.checked?1:0)}
Milk.Ctrl.BoolBox.prototype.setvalue=function(args){var v=(Milk.getArg(args,'value')?true:false)
this.n.checked=v
this.value=v}
Milk.Ctrl.BoolBox.prototype.toggle=function(){this.setvalue({'value':(this.getValue()?false:true)})}
Milk.Ctrl.ChooseBox=function(id){this.id=id
this.n=null}
Milk.Ctrl.ChooseBox.prototype=new Milk.Ctrl.Form()
Milk.Ctrl.ChooseBox.prototype.init=function(){this.n=$(this.id).firstChild
var c=this
if(this.n.nextSibling)FLQ.event.add(this.n.nextSibling,'click',function(){c.sendSignal('choose',{'send':false})})}
Milk.Ctrl.ChooseBox.prototype.setvalue=function(args){var v
if(v=Milk.getArg(args,'value')){this.reqValue=v
this.n.value=v[1]}}
Milk.Ctrl.ChooseBox.prototype.getValue=function(){return this.reqValue}
Milk.Ctrl.DateBox=function(id){this.id=id
this.p=null
this.c=null
this.fmt='%d/%m/%Y'
this.showtime=false}
Milk.Ctrl.DateBox.prototype=new Milk.Ctrl.Form()
Milk.Ctrl.DateBox.prototype.init=function(){this.p=$(this.id)
this.n=this.p.firstChild
var c=this
FLQ.event.add(this.n,'focus',function(){c.show()})
FLQ.event.add(this.n,'click',function(e){FLQ.event.stopEvent(e)})
FLQ.event.add(this.n,'change',function(){c.hide()})
FLQ.event.add(this.n,'keypress',function(e){c.keypress(e)})}
Milk.Ctrl.DateBox.prototype.keypress=function(e){if(e&&e.keyCode){if(e.keyCode==9)this.hide()}}
Milk.Ctrl.DateBox.prototype.show=function(sm,sy){this.hide()
var t,b,d=0,dow=1,dam=1,dim,dbm,m,y,sd,dt,a=true,v=new Date()
if(arguments.length>=2){v.setDate(1)
v.setMonth(sm)
v.setYear(sy)
a=false}else if(tmp=this.getValue()){v.strptime(tmp,this.fmt)}
sd=this.getFDIM(v)
y=v.getFullYear()
m=v.getMonth()
dim=v.dim[m]
dbm=v.dim[(m==0?11:m-1)]-(sd-2)
this.c=document.createElement('div')
FLQ.addClass(this.c,'datebox-cal')
this.c.appendChild(t=document.createElement('table'))
t.appendChild(b=document.createElement('tbody'))
var c=this
FLQ.event.add(document.body,'click',function(){setTimeout('Milk.get(\''+c.id+'\').hide()',100)})
b.appendChild(tr=document.createElement('tr'))
tr.appendChild(td=document.createElement('td'))
FLQ.addClass(tr,'datebox-title');td.appendChild(document.createTextNode('«'))
FLQ.addClass(td,'datebox-prev');FLQ.event.add(td,'click',function(e){c.show((m==0?11:m-1),(m==0?y-1:y));FLQ.event.stopEvent(e)})
tr.appendChild(td=document.createElement('td'))
td.appendChild(document.createTextNode(v.mths[m]+' '+y))
td.colSpan=5;tr.appendChild(td=document.createElement('td'))
td.appendChild(document.createTextNode('»'))
FLQ.addClass(td,'datebox-next');FLQ.event.add(td,'click',function(e){c.show((m==11?0:m+1),(m==11?y+1:y));FLQ.event.stopEvent(e)})
b.appendChild(tr=document.createElement('tr'))
FLQ.addClass(tr,'datebox-dow')
for(var i=1;i<7;i++){tr.appendChild(td=document.createElement('td'))
td.appendChild(document.createTextNode(v.wd[i].substr(0,1)))
if(i==6){i=-1}else if(i==0){break}}
b.appendChild(tr=document.createElement('tr'))
dt=new Date(y,m,1,v.getHours(),v.getMinutes(),v.getSeconds())
for(var i=1;i<=42;i++){cl=''
if(dow>7){if(d>=dim)break;b.appendChild(tr=document.createElement('tr'))
dow=1;}
dow++;if(i>=sd&&d<dim){++d
dt.setDate(d)
if(v.getDate()==d&&m==v.getMonth())cl+=' datebox-today'
cl+=' datebox-day';tr.appendChild(td=document.createElement('td'))
td.appendChild(document.createTextNode(d));FLQ.addClass(td,cl);FLQ.event.add(td,'click',new Function('','with (ctr = Milk.get(\''+c.id+'\')) { setvalue({\'value\': getCalValue(\''+dt.strftime(c.fmt)+'\')}) }'))}else{tr.appendChild(td=document.createElement('td'))
FLQ.addClass(td,'datebox-nonday')
td.appendChild(document.createTextNode(d>=dim?(dam++):(dbm++)))}}
if(this.showtime){this.c.appendChild(t=document.createElement('div'))
FLQ.addClass(t,'datebox-time')
t.appendChild(s=document.createElement('strong'))
s.appendChild(document.createTextNode('Time: '))
t.appendChild(h=document.createElement('select'))
o=0
for(var i=0;i<=23;i++){h.options[o++]=new Option((i<10?'0':'')+i,i,(v.getHours()==i?true:false))}
FLQ.event.add(h,'click',function(e){FLQ.event.stopEvent(e);})
t.appendChild(mi=document.createElement('select'))
o=0
for(var i=0;i<60;i++){mi.options[o++]=new Option((i<10?'0':'')+i,i,(v.getMinutes()==i?true:false))}
FLQ.event.add(mi,'click',function(e){FLQ.event.stopEvent(e);})}
if(a)this.c.style.height='0px'
this.p.appendChild(this.c)
if(a)this.iId=setInterval('Milk.get(\''+c.id+'\').showAnim()',1)}
Milk.Ctrl.DateBox.prototype.getCalValue=function(d){if(this.showtime){v=new Date()
v.strptime(d,this.fmt)
if(s=this.c.getElementsByTagName('select')){v.setHours(s[0].options[s[0].selectedIndex].value,s[1].options[s[1].selectedIndex].value)}
return v.strftime(this.fmt)}
return d}
Milk.Ctrl.DateBox.prototype.showAnim=function(){if(this.c&&this.c.offsetHeight<200){this.c.style.height=(this.c.offsetHeight+5)+'px'}else{clearInterval(this.iId)}}
Milk.Ctrl.DateBox.prototype.isLeapYear=function(y){y=parseInt(year)
if(y%4==0){if(y%100!=0){return true}else if(y%400==0){return true}}
return false}
Milk.Ctrl.DateBox.prototype.getFDIM=function(v){d=new Date(v)
d.setDate(1)
var sd=d.getDay()
return(sd==0?7:sd)}
Milk.Ctrl.DateBox.prototype.hide=function(){if(this.c&&this.c.parentNode){this.c.parentNode.removeChild(this.c)}
var c=this
FLQ.event.removeListener(document.body,'click',function(){setTimeout('Milk.get(\''+c.id+'\').hide()',100)})}
Milk.Ctrl.DateTimeBox=function(id){this.id=id
this.p=null
this.fmt='%d/%m/%Y %H:%M'
this.showtime=true}
Milk.Ctrl.DateTimeBox.prototype=new Milk.Ctrl.DateBox()
Milk.Ctrl.DateTimeBox.prototype.init=function(){this.p=$(this.id)
this.n=this.p.firstChild
var c=this
FLQ.event.add(this.n,'focus',function(){c.show()})
FLQ.event.add(this.n,'click',function(e){FLQ.event.stopEvent(e)})
FLQ.event.add(this.n,'change',function(){c.hide()})
FLQ.event.add(this.n,'keypress',function(e){c.keypress(e)})}
Milk.Ctrl.FileBox=function(id){this.id=id
this.n=null
this.changed=false}
Milk.Ctrl.FileBox.prototype=new Milk.Ctrl.Form()
Milk.Ctrl.FileBox.prototype.init=function(){this.n=$(this.id).firstChild
var c=this
FLQ.event.add(this.n,'change',function(){c.changed=true})}
Milk.Ctrl.FileBox.prototype.hasChanged=function(){return this.changed}
Milk.Ctrl.FileBox.prototype.addData=function(f){if(this.hasChanged()){f.encoding='multipart/form-data'
this.n.style.display='none'
f.appendChild(this.n)}}
Milk.Ctrl.SMTemplate=function(id){this.id=id}
Milk.Ctrl.SMTemplate.prototype=new Milk.Ctrl.Template()
Milk.Ctrl.SMBox=function(id){this.id=id
this.n=null}
Milk.Ctrl.SMBox.prototype=new MilkCtrl()
Milk.Ctrl.SMBox.prototype.init=function(){this.n=$(this.id)
var c=this
FLQ.event.add(this.n,'click',function(){c.sendSignal('click')})}
Milk.Ctrl.SMDataGrid=Milk.Ctrl.DataGrid;Milk.Ctrl.MultiBox=function(id){this.id=id
this.n=null
this.options=null
this.minsel=0
this.maxsel=null
this.wrap=false}
Milk.Ctrl.MultiBox.prototype=new Milk.Ctrl.Form()
Milk.Ctrl.MultiBox.prototype.init=function(){this.n=$(this.id)
this.initoptions(this.options)}
Milk.Ctrl.MultiBox.prototype.initoptions=function(options){var c=this
while(this.n.firstChild)this.n.removeChild(this.n.firstChild)
if(FLQ.isObj(options)){for(var i in options){var d=document.createElement('div')
d.setAttribute('milkval',i)
FLQ.addClass(d,'multibox-option')
if(this.wrap)FLQ.addClass(d,'multibox-wrap')
if(FLQ.isArr(this.value)&&this.value.search(i)!=-1){FLQ.addClass(d,'multibox-selected')}
d.appendChild(document.createTextNode(options[i]))
FLQ.event.add(d,'click',function(){c.toggle(this)})
this.n.appendChild(d)}}}
Milk.Ctrl.MultiBox.prototype.toggle=function(d){if(FLQ.hasClass(d,'multibox-selected')){FLQ.removeClass(d,'multibox-selected')}else{FLQ.addClass(d,'multibox-selected')}
this.sendSignal('change',{'value':this.getValue()})}
Milk.Ctrl.MultiBox.prototype.getValue=function(){var v=[],o;for(var i=0;this.n.childNodes[i];i++){o=this.n.childNodes[i]
if(FLQ.hasClass(o,'multibox-selected')){v.push(o.getAttribute('milkval'))}}
return v}
Milk.Ctrl.MultiBox.prototype.getData=function(){if(this.hasChanged()){var o={},v=this.getValue()
o[this.id]=(FLQ.isArr(v)&&v.length==0?null:v)
return o}
return null};
