
Function.prototype.bind=function(obj){var method=this,temp=function(){return method.apply(obj,arguments);};return temp;};String.prototype.trim=function(){return(this||"").replace(/^\s+|\s+$/g,"");};(function($){var _readyQueue=[],_behaviors=[],_class={list:{},create:function(){return function(){this.initialize.apply(this,arguments);};}},_System=function(){};var _msiebuttonexp=/^[\s\S]*<!--\[msiebutton\](.*)-->$/g;Object.extend=function(tgt,src){for(property in src)tgt[property]=src[property];return tgt;};_class.Inherit=function(base,args){var o=_class.create();o.prototype=Object.extend(base,args);return o;};_System.prototype._Behavior=_class.create();_System.prototype._Behavior.prototype={initialize:function(){},create:function(interface,base){return _class.Inherit(base||new BehaviorBase(),interface);},ready:function(fn){_readyQueue.push(function(){return fn.call(this);})},add:function(cls,interface,base){eval('_class.list.'+cls+'=this.create(interface, base)');_behaviors[cls]=eval('new _class.list.'+cls+"(cls)");_behaviors[cls].name=cls;if(interface.autoAttach)
this.attach(interface.autoAttach,cls);},get:function(name){return _behaviors[name]},attach:function(sel,name,settings){if(!name){name=sel;sel="."+name;}
this.ready(function(){$(sel).scf_behavior(name,settings)});},start:function(){for(var i=0;i<_readyQueue.length;i++)_readyQueue[i].call()}};var _sys=new _System();_sys.Class=_class;function BehaviorBase(){};BehaviorBase.prototype={state:{},initialize:function(){},autoAttach:null,attach:function(el,settings,jq,instance){},detach:function(el){}};_System.prototype.StringBuilder=_class.create();_System.prototype.StringBuilder.prototype={initialize:function(text){this.length=0;this._index=0;this._ar=[];this._cache=null;if(text!=null)
this.append(text);},add:function(text){this.length+=(this._ar[this._index++]=String(text)).length;this._cache=null;return this;},addLine:function(s){this.add(s);this.add("\n");},toString:function(){if(this._cache!=null)
return this._cache;return this._cache=this._ar.join("");}};_System.prototype.JSONFilter=_class.create();_System.prototype.JSONFilter.prototype={state:{},initialize:function(p){state=this;state.prop=p;},filter:function(n,v){if(n.substring(0,1)=='_')
return null;else if(state.prop[n]){if($.scf.smartlet._getA(state.prop[n],true)<2&&$.scf.smartlet._getA(state.prop[n],false)==2){v["v"]=null;}}
return v;}};_System.prototype._Smartlet=_class.create();_System.prototype._Smartlet.prototype={initialize:function(sys){_this=this;_sys=sys;},ERR_BASE:1899000,_err:function(obj,n,msg){throw new Error(this.ERR_BASE+n,msg+"\r\rSmarlet: "+obj.sml);},_check:function(obj,name){if(typeof(obj.prop[name])=='undefined')
_this._err(obj,5,"Property '"+name+"' not defined.");},_getA:function(prop,client){var a=prop.a,ix=client?0:1;if(a&&a.indexOf('.')!=-1)
return parseInt(a.split('.')[ix]);return 0;},_enrich:function(obj){obj=Object.extend(obj||{},{prop:obj.prop||[],id:function(s){return this.nm+((s)?"_"+s:"");},_priv:{reuseAjax:true},abort:function(){if(obj._priv.x)
obj._priv.x.abort();if(obj._priv.busy){$(obj._priv.busy).scf_busy(0);}},ajax:function(cb){return $.scf.smartlet._ajax(obj,cb);},get:function(name){$.scf.smartlet._check(obj,name);var v=obj.prop[name].v;var p=obj.prop[name];if(p.t==64&&typeof(v)=='string'){var match=v.match(/^([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})T(?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9])Z?)?$/);if(match)
v=new Date(RegExp.$1,parseInt(RegExp.$2)-1,RegExp.$3,RegExp.$4,RegExp.$5,RegExp.$6);else
_this._err(obj,14,"Invalid Date string: "+v);}
if(p.e)
v=$.scf.convert.base64.decode(v.toString());return v;},set:function(name,value){if(typeof(obj.prop[name])=='undefined')
_this._err(obj,9,"Property '"+name+"' is not defined.");var p=obj.prop[name];if($.scf.smartlet._getA(p,true)<2)
_this._err(obj,8,"Property '"+name+"' is not writable on the client.");if(p.e)
value=$.scf.convert.base64.encode(value.toString());$.scf.smartlet._check(obj,name);obj.prop[name].v=value;}});return obj;},_update:function(obj){var sml=window.smartlet[obj.nm];for(e in obj.prop){if(typeof(obj.prop[e].v)!='undefined')
if(sml.prop[e]){sml.prop[e].v=obj.prop[e].v;}}},add:function(id,settings){if(!window.smartlet)window.smartlet=[];var sml=this._enrich(settings);window.smartlet[id]=sml;},behavior:{create:function(){return $.scf.behavior.create({test:function(){}},new BehaviorBase());}},get:function(id){if(id&&id.id)
id=id.id;if(!window.smartlet)
window.smartlet=[];return window.smartlet[id];},debug:function(writer){window.debugWriter=writer;},_ajax:function(smartlet,c,options){options=(!options&&typeof(c)=='function')?{ready:c}:c||{};if(typeof(options.start)=='function')
options.start();var u=smartlet.url;if(options.query)
u+=((u.indexOf('?')!=-1)?'&':'?')+options.query;if(typeof(options.busy)!='undefined'){if(typeof(options.busy)=='function'){options.busy();smartlet._priv.busy=c.busy;}
else if(options.busy==true||typeof(options.busy)=='string'||typeof(options.busy)=='object'){smartlet._priv.busy='#'+smartlet.id();if(typeof(options.busy)=='string'||typeof(options.busy)=='object')
smartlet._priv.busy=$(options.busy);el=smartlet._priv.busy;if(smartlet._priv.reuseAjax)
smartlet.abort();$(el).scf_busy(true);}}
options.ready=options.ready||function(x){};var ajOpts={url:u,data:$.scf.json.toString(smartlet,null,new _System.prototype.JSONFilter(smartlet.prop).filter),callback:function(j){var q=$('#'+smartlet.id()),e=q.get(0);if(e){if(smartlet._priv.busy){if(typeof(smartlet._priv.busy)=='function')
smartlet._priv.busy(false);else
$(smartlet._priv.busy).scf_busy(false);smartlet._priv.busy=null}};options.ready(j)},isSmartlet:true};var x=$.scf.json.post(Object.extend(ajOpts,options||{}));if(smartlet._priv.reuseAjax)
smartlet._priv.x=x;return x;}};_sys.JSON=function(){function f(n){return n<10?'0'+n:n;}
Date.prototype.toJSON=function(){var s=this.getUTCFullYear()+'-'+
f(this.getUTCMonth()+1)+'-'+
f(this.getUTCDate())+'T'+
f(this.getUTCHours())+':'+
f(this.getUTCMinutes())+':'+
f(this.getUTCSeconds())+'Z';return s;};var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','/':'\\/','"':'\\"','\\':'\\\\'};function stringify(value,whitelist,callback){var a,i,k,l,v,r=/["\\\x00-\x1f\x7f-\x9f]/g;switch(typeof value){case'string':return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c)return c;c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+
(c%16).toString(16);})+'"':'"'+value+'"';case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value)return'null';if(typeof value.toJSON==='function')
return stringify(value.toJSON(),null,callback);a=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))){l=value.length;for(i=0;i<l;i+=1){a.push(stringify(value[i],whitelist,callback)||'null');};return'['+a.join(',')+']';}
if(whitelist){l=whitelist.length;for(i=0;i<l;i+=1){k=whitelist[i];if(typeof k==='string')
v=stringify(value[k],whitelist,callback);if(v)
a.push(stringify(k,null,callback)+':'+v);}}
else{for(k in value){v=null;if(typeof k==='string'){if(callback){v=callback(k,value[k]);if(v!=null)
v=stringify(v,whitelist,callback);}else{v=stringify(value[k],whitelist,callback);}
if(v!=null)
a.push(stringify(k,null,callback)+':'+v);}}}
return'{'+a.join(',')+'}';}}
return{stringify:stringify,parse:function(text,filter){var j;function walk(k,v){var i,n;if(v&&typeof v==='object'){for(i in v){if(Object.prototype.hasOwnProperty.apply(v,[i])){n=walk(i,v[i]);if(n!==undefined)
v[i]=n;}}}
return filter(k,v);}
if(/^[\],:{}\s]*$/.test(text.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof filter==='function'?walk('',j):j;}
throw new Error('JSON parse error.');}};}();$.extend({scf:{behavior:new _sys._Behavior(),smartlet:new _sys._Smartlet(_sys),convert:{base64:{charmap:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(str){var ret=new $.scf.string.build();var c,i,acc=0;var div=1;for(i=0,c=0;i<str.length;i++,c++){acc=acc*256+str.charCodeAt(i);div=div*4;ret.add(this.charmap.charAt(parseInt(acc/div)));acc=acc%div;if(div==64){ret.add(this.charmap.charAt(parseInt(acc)));acc=0;div=1;c++;}
if(c>=75){c=-1;ret.add("\n");}}if(i%3){ret.add(this.charmap.charAt(parseInt(acc*((i%3==1)?16:4))));ret.add(((i%3)==1?"==":"="));}return ret.toString();},decode:function(str){var ret=new $.scf.string.build();var i,acc=0;var div=1;for(i=0;i<str.length;i++){if(str.charAt(i)=="="||str.charAt(i)=='\n')break;acc=acc*64+this.charmap.indexOf(str.charAt(i));div=(div==1?64:div/4);if(div!=64){ret.add(String.fromCharCode(parseInt(acc/div)));acc=acc%div;}}
return ret.toString();}}},string:{build:_sys.StringBuilder},json:{toString:function(a,b,c){return _sys.JSON.stringify(a,b,c)},post:function(options){var ajOpts={type:"POST",url:options.url,data:options.data,contentType:"application/json",success:function(x){try{obj=eval('('+x+')');if(window.smartlet&&options.isSmartlet)
obj=$.scf.smartlet._enrich(obj);}
catch(ex){var exdata='';for(e in ex)
exdata+='\r\n'+e+' = '+ex[e];throw new Error($.scf.smartlet.ERR_BASE+1,"Invalid response JSON: \r\n"+exdata);}
if(obj.lastError){var ab=function(){if(typeof(options.busy)=='object'||typeof(options.busy)=='string')
$(options.busy).scf_busy(0);else if(obj.abort)
obj.abort();};var er=new Error($.scf.smartlet.ERR_BASE+2,obj.lastError);er.errorType=obj.lastErrorType;if(window.smartlet&&options.isSmartlet){if(obj.errorCaught==true)
$.scf.smartlet._update(obj);};if(typeof(options.error)=='function'){options.error(obj);ab();}
else if(obj.errorCaught==true){alert(obj.lastErrorMessage||obj.lastError);ab();}
else{ab();throw er;}}
else{if(window.smartlet&&options.isSmartlet)
$.scf.smartlet._update(obj);options.callback(obj);}}};return $.ajax(Object.extend(ajOpts,options||{}));}},ready:function(fn){this.behavior.ready(fn)},start:function(){document.cookie='_sce=1';this.behavior.start();}}});$.extend({_ns:{cur:null,init:$.fn.init,obj:{},extend:function(ns){if(eval(ns)!=undefined){$.extend(eval(ns),{});}else{eval(ns+" = {};");}}},namespace:function(namespaces,objects){if(typeof objects=="function"){if(namespaces.match(".")){var a=namespaces.split("."),d="";for(var i=0;i<a.length;i++){d+="['"+a[i]+"']";$._ns.extend("$._ns.obj"+d);$._ns.extend("$.fn"+d);}
eval("$._ns.obj"+d+" = objects;");eval("$.fn"+d+" = "+"function(){ return eval(\"$._ns.obj"+d+".apply($._ns.cur, arguments)\"); }");}else{$.extend({namespaces:function(){return objects($.fn._ns.cur);}});}}else{for(var space in objects){$.namespace(namespaces+"."+space,objects[space]);};}}});$.fn.extend({init:function(selector,context){$._ns.cur=new $._ns.init(selector,context);return $._ns.cur;}});$.fn.scf_behavior=function(name,options){if(typeof name=='function'){$.scf.behavior.guid=$.scf.behavior.guid||0;$.scf.behavior.guid++;var guid="anonymousBehavior_"+$.scf.behavior.guid;$.scf.behavior.add(guid,{attach:name});name=guid;}
return this.each(function(){var el=$(this);var o=$.scf.behavior.get(name);if(!o)
throw new Error("Behavior not defined: "+name);var e=el.get(0);e.behavior=o;o.attach(e,options||{},el);});};$.fn.scf_busy=function(ok,text){return this.each(function(){var el=$(this),e=el.get(0);if(typeof(ok)=='undefined')ok=true;if(ok){e.busyDiv=$("<div></div>");e.busyDiv.text(text||"Please wait...").addClass("ScfAjaxBusySmall").css({left:el.offset().left+el.width()/2-50,top:el.offset().top+el.height()/2-15}).hide();$(document.body).append(e.busyDiv);e.busyDiv.fadeIn(100);}
else{if(e.busyDiv){if(ok==0)
$(e.busyDiv).remove();else
$(e.busyDiv).fadeOut(100,function(){$(e.busyDiv).remove()});e.busyDiv=null;}}});};$.fn.scf_form={toJSON:function(){var f=this[0];if(!f||f.tagName!='FORM'||typeof f.getData!='function')
throw new Error("Not a valid Scf form");var data=f.getData();return $.scf.json.toString(data);},val:function(){var el=this[0];var v=$(el).val();if(typeof v=="string")
v=v.replace(_msiebuttonexp,"$1");return v;}};$.fn.scf_popup=function(options){if(options==false){$(".ScfPopup").fadeOut(300,function(){$(this).remove()});}
else{options=options||{};options.inEffectTime=options.inEffectTime||300;options.outEffectTime=options.outEffectTime||300;options.css=options.css||{};function viewport(){return{x:$(window).scrollLeft(),y:$(window).scrollTop(),cx:$(window).width(),cy:$(window).height()};};var toolbar="<img title='Close' alt='Close dialog' class='CmdClosePopup' src='/scf/gfx/close.png'/>";return this.each(function(){var j=$(this),e=j.get(0);e.scfPop=$("<table class='ScfPopup'><thead><tr><th class='Title'>"+
(options.title||"Popup")+"</th><th class='ToolBar'>"+toolbar+"</th><thead></tr><tbody><tr><td colspan='2' class='ScfPopupBody ScfAjaxBusy'>"+
(options.loadingText||"Loading...")+"</td></tr></tbody></table>");var o=j.offset(),pj=$(e.scfPop);pj.css({left:o.left+20,top:o.top+20}).css(options.css).hide();j.addClass("PopupShown");$(document.body).append(e.scfPop);pj.fadeIn(options.inEffectTime,function(){options.html=options.html||"No data";var popBody=$('tbody td:first-child',e.scfPop);var v=viewport(),os=pj.offset();if(v.x+v.cx<os.left+pj.width())
pj.animate({left:(v.x+v.cx-pj.width()-20)+'px'},200);if(v.y+v.cy<os.top+pj.height())
pj.animate({top:(v.y+v.cy-pj.height()-20)+'px'},200);var ready=function(data){if(data)options.html=data;popBody.removeClass("ScfAjaxBusy").html(options.html);};if(typeof(options.load)=='function')options.load(ready);else ready();$(".CmdClosePopup",e.scfPop).hover(function(){$(this).animate({width:"20px"},100)},function(){$(this).animate({width:"16px"},50)}).click(function(){$(e.scfPop).fadeOut(options.outEffectTime,function(){$(e.scfPop).remove();})});});return false;});}};$.namespace("scf",{behavior:$.fn.scf_behavior,popup:$.fn.scf_popup,busy:$.fn.scf_busy});$.namespace("scf.form",{val:$.fn.scf_form.val,toJSON:$.fn.scf_form.toJSON});})(jQuery);var $j=jQuery.noConflict();
