
if(window.jQuery&&!window.jQuery.createTemplate){(function(){var Template=function(s,includes,settings){this._tree=[];this._param={};this._includes=null;this._templates={};this._templates_code={};this.settings=jQuery.extend({disallow_functions:false,filter_data:true,filter_params:false,runnable_functions:false,clone_data:true,clone_params:true},settings);this.f_cloneData=(this.settings.f_cloneData!==undefined)?(this.settings.f_cloneData):(TemplateUtils.cloneData);this.f_escapeString=(this.settings.f_escapeString!==undefined)?(this.settings.f_escapeString):(TemplateUtils.escapeHTML);this.splitTemplates(s,includes);if(s){this.setTemplate(this._templates_code['MAIN'],includes,this.settings);}
this._templates_code=null;};Template.prototype.version='0.7.5';Template.DEBUG_MODE=true;Template.prototype.splitTemplates=function(s,includes){var reg=/\{#template *(\w*?)( .*)*\}/g;var iter,tname,se;var lastIndex=null;var _template_settings=[];while((iter=reg.exec(s))!=null){lastIndex=reg.lastIndex;tname=iter[1];se=s.indexOf('{#/template '+tname+'}',lastIndex);if(se==-1){throw new Error('jTemplates: Template "'+tname+'" is not closed.');}
this._templates_code[tname]=s.substring(lastIndex,se);_template_settings[tname]=TemplateUtils.optionToObject(iter[2]);}
if(lastIndex===null){this._templates_code['MAIN']=s;return;}
for(var i in this._templates_code){if(i!='MAIN'){this._templates[i]=new Template();}}
for(var i in this._templates_code){if(i!='MAIN'){this._templates[i].setTemplate(this._templates_code[i],jQuery.extend({},includes||{},this._templates||{}),jQuery.extend({},this.settings,_template_settings[i]));this._templates_code[i]=null;}}};Template.prototype.setTemplate=function(s,includes,settings){if(s==undefined){this._tree.push(new TextNode('',1));return;}
s=s.replace(/[\n\r]/g,'');s=s.replace(/\{\*.*?\*\}/g,'');this._includes=jQuery.extend({},this._templates||{},includes||{});this.settings=new Object(settings);var node=this._tree;var op=s.match(/\{#.*?\}/g);var ss=0,se=0;var e;var literalMode=0;var elseif_level=0;for(var i=0,l=(op)?(op.length):(0);i<l;++i){if(literalMode){se=s.indexOf('{#/literal}');if(se==-1){throw new Error("jTemplates: No end of literal.");}
if(se>ss){node.push(new TextNode(s.substring(ss,se),1));}
ss=se+11;literalMode=0;i=jQuery.inArray('{#/literal}',op);continue;}
se=s.indexOf(op[i],ss);if(se>ss){node.push(new TextNode(s.substring(ss,se),literalMode));}
var ppp=op[i].match(/\{#([\w\/]+).*?\}/);var op_=RegExp.$1;switch(op_){case'elseif':++elseif_level;node.switchToElse();case'if':e=new opIF(op[i],node);node.push(e);node=e;break;case'else':node.switchToElse();break;case'/if':while(elseif_level){node=node.getParent();--elseif_level;}
case'/for':case'/foreach':node=node.getParent();break;case'foreach':e=new opFOREACH(op[i],node,this);node.push(e);node=e;break;case'for':e=opFORFactory(op[i],node,this);node.push(e);node=e;break;case'include':node.push(new Include(op[i],this._includes));break;case'param':node.push(new UserParam(op[i]));break;case'cycle':node.push(new Cycle(op[i]));break;case'ldelim':node.push(new TextNode('{',1));break;case'rdelim':node.push(new TextNode('}',1));break;case'literal':literalMode=1;break;case'/literal':if(Template.DEBUG_MODE){throw new Error("jTemplates: No begin of literal.");}
break;default:if(Template.DEBUG_MODE){throw new Error('jTemplates: unknown tag '+op_+'.');}}
ss=se+op[i].length;}
if(s.length>ss){node.push(new TextNode(s.substr(ss),literalMode));}};Template.prototype.get=function(d,param,element,deep){++deep;var $T=d,_param1,_param2;if(this.settings.clone_data){$T=this.f_cloneData(d,{escapeData:(this.settings.filter_data&&deep==1),noFunc:this.settings.disallow_functions},this.f_escapeString);}
if(!this.settings.clone_params){_param1=this._param;_param2=param;}else{_param1=this.f_cloneData(this._param,{escapeData:(this.settings.filter_params),noFunc:false},this.f_escapeString);_param2=this.f_cloneData(param,{escapeData:(this.settings.filter_params&&deep==1),noFunc:false},this.f_escapeString);}
var $P=jQuery.extend({},_param1,_param2);var $Q=element;$Q.version=this.version;var ret='';for(var i=0,l=this._tree.length;i<l;++i){ret+=this._tree[i].get($T,$P,$Q,deep);}
--deep;return ret;};Template.prototype.setParam=function(name,value){this._param[name]=value;};TemplateUtils=function(){};TemplateUtils.escapeHTML=function(txt){return txt.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;');};TemplateUtils.cloneData=function(d,filter,f_escapeString){if(d==null){return d;}
switch(d.constructor){case Object:var o={};for(var i in d){o[i]=TemplateUtils.cloneData(d[i],filter,f_escapeString);}
if(!filter.noFunc){if(d.hasOwnProperty("toString"))
o.toString=d.toString;}
return o;case Array:var o=[];for(var i=0,l=d.length;i<l;++i){o[i]=TemplateUtils.cloneData(d[i],filter,f_escapeString);}
return o;case String:return(filter.escapeData)?(f_escapeString(d)):(d);case Function:if(filter.noFunc){if(Template.DEBUG_MODE)
throw new Error("jTemplates: Functions are not allowed.");else
return undefined;}
default:return d;}};TemplateUtils.optionToObject=function(optionText){if(optionText===null||optionText===undefined){return{};}
var o=optionText.split(/[= ]/);if(o[0]===''){o.shift();}
var obj={};for(var i=0,l=o.length;i<l;i+=2){obj[o[i]]=o[i+1];}
return obj;};var TextNode=function(val,literalMode){this._value=val;this._literalMode=literalMode;};TextNode.prototype.get=function(d,param,element,deep){var t=this._value;if(!this._literalMode){var $T=d;var $P=param;var $Q=element;t=t.replace(/\{(.*?)\}/g,function(__a0,__a1){try{var tmp=eval(__a1);if(typeof tmp=='function'){var settings=jQuery.data(element,'jTemplate').settings;if(settings.disallow_functions||!settings.runnable_functions){return'';}else{tmp=tmp($T,$P,$Q);}}
return(tmp===undefined)?(""):(String(tmp));}catch(e){if(Template.DEBUG_MODE)
throw e;return"";}});}
return t;};var opIF=function(oper,par){this._parent=par;oper.match(/\{#(?:else)*if (.*?)\}/);this._cond=RegExp.$1;this._onTrue=[];this._onFalse=[];this._currentState=this._onTrue;};opIF.prototype.push=function(e){this._currentState.push(e);};opIF.prototype.getParent=function(){return this._parent;};opIF.prototype.switchToElse=function(){this._currentState=this._onFalse;};opIF.prototype.get=function(d,param,element,deep){var $T=d;var $P=param;var $Q=element;var ret='';try{var tab=(eval(this._cond))?(this._onTrue):(this._onFalse);for(var i=0,l=tab.length;i<l;++i){ret+=tab[i].get(d,param,element,deep);}}catch(e){if(Template.DEBUG_MODE)
throw e;}
return ret;};opFORFactory=function(oper,par,template){if(oper.match(/\{#for (\w+?) *= *(\S+?) +to +(\S+?) *(?:step=(\S+?))*\}/)){oper='{#foreach opFORFactory.funcIterator as '+RegExp.$1+' begin='+(RegExp.$2||0)+' end='+(RegExp.$3||-1)+' step='+(RegExp.$4||1)+' extData=$T}';return new opFOREACH(oper,par,template);}else{throw new Error('jTemplates: Operator failed "find": '+oper);}};opFORFactory.funcIterator=function(i){return i;};var opFOREACH=function(oper,par,template){this._parent=par;this._template=template;oper.match(/\{#foreach (.+?) as (\w+?)( .+)*\}/);this._arg=RegExp.$1;this._name=RegExp.$2;this._option=RegExp.$3||null;this._option=TemplateUtils.optionToObject(this._option);this._onTrue=[];this._onFalse=[];this._currentState=this._onTrue;};opFOREACH.prototype.push=function(e){this._currentState.push(e);};opFOREACH.prototype.getParent=function(){return this._parent;};opFOREACH.prototype.switchToElse=function(){this._currentState=this._onFalse;};opFOREACH.prototype.get=function(d,param,element,deep){try{var $T=d;var $P=param;var $Q=element;var fcount=eval(this._arg);var key=[];var mode=typeof fcount;if(mode=='object'){var arr=[];jQuery.each(fcount,function(k,v){key.push(k);arr.push(v);});fcount=arr;}
var extData=(this._option.extData!==undefined)?(eval(this._option.extData)):{};var s=Number(eval(this._option.begin)||0),e;var step=Number(eval(this._option.step)||1);if(mode!='function'){e=fcount.length;}else{if(this._option.end===undefined||this._option.end===null){e=Number.MAX_VALUE;}else{e=Number(eval(this._option.end))+((step>0)?(1):(-1));}}
var ret='';var i,l;if(this._option.count){var tmp=s+Number(eval(this._option.count));e=(tmp>e)?(e):(tmp);}
if((e>s&&step>0)||(e<s&&step<0)){var iteration=0;var _total=(mode!='function')?(Math.ceil((e-s)/step)):undefined;var ckey,cval;for(;((step>0)?(s<e):(s>e));s+=step,++iteration){ckey=key[s];if(mode!='function'){cval=fcount[s];}else{cval=fcount(s);if(cval===undefined||cval===null){break;}}
if((typeof cval=='function')&&(this._template.settings.disallow_functions||!this._template.settings.runnable_functions)){continue;}
if((mode=='object')&&(ckey in Object)){continue;}
$T=extData;var p=$T[this._name]=cval;$T[this._name+'$index']=s;$T[this._name+'$iteration']=iteration;$T[this._name+'$first']=(iteration==0);$T[this._name+'$last']=(s+step>=e);$T[this._name+'$total']=_total;$T[this._name+'$key']=(ckey!==undefined&&ckey.constructor==String)?(this._template.f_escapeString(ckey)):(ckey);$T[this._name+'$typeof']=typeof cval;for(i=0,l=this._onTrue.length;i<l;++i){ret+=this._onTrue[i].get($T,param,element,deep);}
delete $T[this._name+'$index'];delete $T[this._name+'$iteration'];delete $T[this._name+'$first'];delete $T[this._name+'$last'];delete $T[this._name+'$total'];delete $T[this._name+'$key'];delete $T[this._name+'$typeof'];delete $T[this._name];}}else{for(i=0,l=this._onFalse.length;i<l;++i){ret+=this._onFalse[i].get($T,param,element,deep);}}
return ret;}catch(e){if(Template.DEBUG_MODE)
throw e;return"";}};var Include=function(oper,includes){oper.match(/\{#include (.*?)(?: root=(.*?))?\}/);this._template=includes[RegExp.$1];if(this._template==undefined){if(Template.DEBUG_MODE)
throw new Error('jTemplates: Cannot find include: '+RegExp.$1);}
this._root=RegExp.$2;};Include.prototype.get=function(d,param,element,deep){var $T=d;try{return this._template.get(eval(this._root),param,element,deep);}catch(e){if(Template.DEBUG_MODE)
throw e;}};var UserParam=function(oper){oper.match(/\{#param name=(\w*?) value=(.*?)\}/);this._name=RegExp.$1;this._value=RegExp.$2;};UserParam.prototype.get=function(d,param,element,deep){var $T=d;var $P=param;var $Q=element;try{param[this._name]=eval(this._value);}catch(e){if(Template.DEBUG_MODE)
throw e;param[this._name]=undefined;}
return'';};var Cycle=function(oper){oper.match(/\{#cycle values=(.*?)\}/);this._values=eval(RegExp.$1);this._length=this._values.length;if(this._length<=0){throw new Error('jTemplates: cycle has no elements');}
this._index=0;this._lastSessionID=-1;};Cycle.prototype.get=function(d,param,element,deep){var sid=jQuery.data(element,'jTemplateSID');if(sid!=this._lastSessionID){this._lastSessionID=sid;this._index=0;}
var i=this._index++%this._length;return this._values[i];};jQuery.fn.setTemplate=function(s,includes,settings){if(s.constructor===Template){return jQuery(this).each(function(){jQuery.data(this,'jTemplate',s);jQuery.data(this,'jTemplateSID',0);});}else{return jQuery(this).each(function(){jQuery.data(this,'jTemplate',new Template(s,includes,settings));jQuery.data(this,'jTemplateSID',0);});}};jQuery.fn.setTemplateURL=function(url_,includes,settings){var s=jQuery.ajax({url:url_,async:false}).responseText;return jQuery(this).setTemplate(s,includes,settings);};jQuery.fn.setTemplateElement=function(elementName,includes,settings){var s=$('#'+elementName).val();if(s==null){s=$('#'+elementName).html();s=s.replace(/&lt;/g,"<").replace(/&gt;/g,">");}
s=jQuery.trim(s);s=s.replace(/^<\!\[CDATA\[([\s\S]*)\]\]>$/im,'$1');s=s.replace(/^<\!--([\s\S]*)-->$/im,'$1');return jQuery(this).setTemplate(s,includes,settings);};jQuery.fn.hasTemplate=function(){var count=0;jQuery(this).each(function(){if(jQuery.data(this,'jTemplate')){++count;}});return count;};jQuery.fn.removeTemplate=function(){jQuery(this).processTemplateStop();return jQuery(this).each(function(){jQuery.removeData(this,'jTemplate');});};jQuery.fn.setParam=function(name,value){return jQuery(this).each(function(){var t=jQuery.data(this,'jTemplate');if(t===undefined){if(Template.DEBUG_MODE)
throw new Error('jTemplates: Template is not defined.');else
return;}
t.setParam(name,value);});};jQuery.fn.processTemplate=function(d,param){return jQuery(this).each(function(){var t=jQuery.data(this,'jTemplate');if(t===undefined){if(Template.DEBUG_MODE)
throw new Error('jTemplates: Template is not defined.');else
return;}
jQuery.data(this,'jTemplateSID',jQuery.data(this,'jTemplateSID')+1);jQuery(this).html(t.get(d,param,this,0));});};jQuery.fn.processTemplateURL=function(url_,param,options){var that=this;options=jQuery.extend({type:'GET',async:true,cache:false},options);jQuery.ajax({url:url_,type:options.type,data:options.data,dataFilter:options.dataFilter,async:options.async,cache:options.cache,timeout:options.timeout,dataType:'json',success:function(d){var r=jQuery(that).processTemplate(d,param);if(options.on_success){options.on_success(r);}},error:options.on_error,complete:options.on_complete});return this;};var Updater=function(url,param,interval,args,objs,options){this._url=url;this._param=param;this._interval=interval;this._args=args;this.objs=objs;this.timer=null;this._options=options||{};var that=this;jQuery(objs).each(function(){jQuery.data(this,'jTemplateUpdater',that);});this.run();};Updater.prototype.run=function(){this.detectDeletedNodes();if(this.objs.length==0){return;}
var that=this;jQuery.getJSON(this._url,this._args,function(d){var r=jQuery(that.objs).processTemplate(d,that._param);if(that._options.on_success){that._options.on_success(r);}});this.timer=setTimeout(function(){that.run();},this._interval);};Updater.prototype.detectDeletedNodes=function(){this.objs=jQuery.grep(this.objs,function(o){if(jQuery.browser.msie){var n=o.parentNode;while(n&&n!=document){n=n.parentNode;}
return n!=null;}else{return o.parentNode!=null;}});};jQuery.fn.processTemplateStart=function(url,param,interval,args,options){return new Updater(url,param,interval,args,this,options);};jQuery.fn.processTemplateStop=function(){return jQuery(this).each(function(){var updater=jQuery.data(this,'jTemplateUpdater');if(updater==null){return;}
var that=this;updater.objs=jQuery.grep(updater.objs,function(o){return o!=that;});jQuery.removeData(this,'jTemplateUpdater');});};jQuery.extend({createTemplate:function(s,includes,settings){return new Template(s,includes,settings);},createTemplateURL:function(url_,includes,settings){var s=jQuery.ajax({url:url_,async:false}).responseText;return new Template(s,includes,settings);},jTemplatesDebugMode:function(value){Template.DEBUG_MODE=value;}});})(jQuery);}
(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.substring(0,q)||"*";var o=s.substring(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).substring(2,10)}var h=function(t,r,s){var q=this;var p={};var u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.substring(0,v.length-1);var w="onBefore"+v.substring(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(v=="onStart"||v=="onUpdate"||v=="onResume"){i(A,y);if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var s={};var o=this;var u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var y=q._api().fp_getPlugin(p);if(!y){return}i(o,y);delete o.methods;if(!u){m(y.methods,function(){var A=""+this;o[A]=function(){var B=[].slice.call(arguments);var C=q._api().fp_invoke(p,A,B);return C=="undefined"?o:C}});u=true}}var z=s[w];if(z){z.apply(o,v);if(w.substring(0,1)=="_"){delete s[w]}}}})};function b(o,t,z){var E=this,y=null,x,u,p=[],s={},B={},r,v,w,D,A,q;i(E,{id:function(){return r},isLoaded:function(){return(y!==null)},getParent:function(){return o},hide:function(F){if(F){o.style.height="0px"}if(y){y.style.height="0px"}return E},show:function(){o.style.height=q+"px";if(y){y.style.height=A+"px"}return E},isHidden:function(){return y&&parseInt(y.style.height,10)===0},load:function(F){if(!y&&E._fireEvent("onBeforeLoad")!==false){m(a,function(){this.unload()});x=o.innerHTML;if(x&&!flashembed.isSupported(t.version)){o.innerHTML=""}flashembed(o,t,{config:z});if(F){F.cached=true;j(B,"onLoad",F)}}return E},unload:function(){try{if(!y||y.fp_isFullscreen()){return E}}catch(F){return E}if(x.replace(/\s/g,"")!==""){if(E._fireEvent("onBeforeUnload")===false){return E}y.fp_close();y=null;o.innerHTML=x;E._fireEvent("onUnload")}return E},getClip:function(F){if(F===undefined){F=D}return p[F]},getCommonClip:function(){return u},getPlaylist:function(){return p},getPlugin:function(F){var H=s[F];if(!H&&E.isLoaded()){var G=E._api().fp_getPlugin(F);if(G){H=new l(F,G,E);s[F]=H}}return H},getScreen:function(){return E.getPlugin("screen")},getControls:function(){return E.getPlugin("controls")},getConfig:function(F){return F?k(z):z},getFlashParams:function(){return t},loadPlugin:function(I,H,K,J){if(typeof K=="function"){J=K;K={}}var G=J?e():"_";E._api().fp_loadPlugin(I,H,K,G);var F={};F[G]=J;var L=new l(I,null,E,F);s[I]=L;return L},getState:function(){return y?y.fp_getState():-1},play:function(G,F){function H(){if(G!==undefined){E._api().fp_play(G,F)}else{E._api().fp_play()}}if(y){H()}else{E.load(function(){H()})}return E},getVersion:function(){var G="flowplayer.js 3.1.1";if(y){var F=y.fp_getVersion();F.push(G);return F}return G},_api:function(){if(!y){throw"Flowplayer "+E.id()+" not loaded when calling an API method"}return y},setClip:function(F){E.setPlaylist([F]);return E},getIndex:function(){return w}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error").split(","),function(){var F="on"+this;if(F.indexOf("*")!=-1){F=F.substring(0,F.length-1);var G="onBefore"+F.substring(2);E[G]=function(H){j(B,G,H);return E}}E[F]=function(H){j(B,F,H);return E}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip").split(","),function(){var F=this;E[F]=function(H,G){if(!y){return E}var I=null;if(H!==undefined&&G!==undefined){I=y["fp_"+F](H,G)}else{I=(H===undefined)?y["fp_"+F]():y["fp_"+F](H)}return I=="undefined"?E:I}});E._fireEvent=function(O){if(typeof O=="string"){O=[O]}var P=O[0],M=O[1],K=O[2],J=O[3],I=0;if(z.debug){g(O)}if(!y&&P=="onLoad"&&M=="player"){y=y||c(v);A=y.clientHeight;m(p,function(){this._fireEvent("onLoad")});m(s,function(Q,R){R._fireEvent("onUpdate")});u._fireEvent("onLoad")}if(P=="onLoad"&&M!="player"){return}if(P=="onError"){if(typeof M=="string"||(typeof M=="number"&&typeof K=="number")){M=K;K=J}}if(P=="onContextMenu"){m(z.contextMenu[M],function(Q,R){R.call(E)});return}if(P=="onPluginEvent"){var F=M.name||M;var G=s[F];if(G){G._fireEvent("onUpdate",M);G._fireEvent(K,O.slice(3))}return}if(P=="onPlaylistReplace"){p=[];var L=0;m(M,function(){p.push(new h(this,L++,E))})}if(P=="onClipAdd"){if(M.isInStream){return}M=new h(M,K,E);p.splice(K,0,M);for(I=K+1;I<p.length;I++){p[I].index++}}var N=true;if(typeof M=="number"&&M<p.length){D=M;var H=p[M];if(H){N=H._fireEvent(P,K,J)}if(!H||N!==false){N=u._fireEvent(P,K,J,H)}}m(B[P],function(){N=this.call(E,M,K);if(this.cached){B[P].splice(I,1)}if(N===false){return false}I++});return N};function C(){if($f(o)){$f(o).getParent().innerHTML="";w=$f(o).getIndex();a[w]=E}else{a.push(E);w=a.length-1}q=parseInt(o.style.height,10)||o.clientHeight;if(typeof t=="string"){t={src:t}}r=o.id||"fp"+e();v=t.id||r+"_api";t.id=v;z.playerId=r;if(typeof z=="string"){z={clip:{url:z}}}if(typeof z.clip=="string"){z.clip={url:z.clip}}z.clip=z.clip||{};if(o.getAttribute("href",2)&&!z.clip.url){z.clip.url=o.getAttribute("href",2)}u=new h(z.clip,-1,E);z.playlist=z.playlist||[z.clip];var F=0;m(z.playlist,function(){var H=this;if(typeof H=="object"&&H.length){H={url:""+H}}m(z.clip,function(I,J){if(J!==undefined&&H[I]===undefined&&typeof J!="function"){H[I]=J}});z.playlist[F]=H;H=new h(H,F,E);p.push(H);F++});m(z,function(H,I){if(typeof I=="function"){j(B,H,I);delete z[H]}});m(z.plugins,function(H,I){if(I){s[H]=new l(H,I,E)}});if(!z.plugins||z.plugins.controls===undefined){s.controls=new l("controls",null,E)}s.canvas=new l("canvas",null,E);t.bgcolor=t.bgcolor||"#000000";t.version=t.version||[9,0];t.expressInstall="http://www.flowplayer.org/swf/expressinstall.swf";function G(H){if(!E.isLoaded()&&E._fireEvent("onBeforeClick")!==false){E.load()}return f(H)}x=o.innerHTML;if(x.replace(/\s/g,"")!==""){if(o.addEventListener){o.addEventListener("click",G,false)}else{if(o.attachEvent){o.attachEvent("onclick",G)}}}else{if(o.addEventListener){o.addEventListener("click",f,false)}E.load()}}if(typeof o=="string"){flashembed.domReady(function(){var F=c(o);if(!F){throw"Flowplayer cannot access element: "+o}else{o=F;C()}})}else{C()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var r=arguments[1];var q=(arguments.length==3)?arguments[2]:{};if(typeof o=="string"){if(o.indexOf(".")!=-1){var t=[];m(n(o),function(){t.push(new b(this,k(r),k(q)))});return new d(t)}else{var s=c(o);return new b(s!==null?s:o,r,q)}}else{if(o){return new b(o,r,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.prototype.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var e=typeof jQuery=="function";function i(){if(c.done){return false}var k=document;if(k&&k.getElementsByTagName&&k.getElementById&&k.body){clearInterval(c.timer);c.timer=null;for(var j=0;j<c.ready.length;j++){c.ready[j].call()}c.ready=null;c.done=true}}var c=e?jQuery:function(j){if(c.done){return j()}if(c.timer){c.ready.push(j)}else{c.ready=[j];c.timer=setInterval(i,13)}};function f(k,j){if(j){for(key in j){if(j.hasOwnProperty(key)){k[key]=j[key]}}}return k}function g(j){switch(h(j)){case"string":j=j.replace(new RegExp('(["\\\\])',"g"),"\\$1");j=j.replace(/^\s?(\d+)%/,"$1pct");return'"'+j+'"';case"array":return"["+b(j,function(m){return g(m)}).join(",")+"]";case"function":return'"function()"';case"object":var k=[];for(var l in j){if(j.hasOwnProperty(l)){k.push('"'+l+'":'+g(j[l]))}}return"{"+k.join(",")+"}"}return String(j).replace(/\s/g," ").replace(/\'/g,'"')}function h(k){if(k===null||k===undefined){return false}var j=typeof k;return(j=="object"&&k.push)?"array":j}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function b(j,m){var l=[];for(var k in j){if(j.hasOwnProperty(k)){l[k]=m(j[k])}}return l}function a(q,s){var o=f({},q);var r=document.all;var m='<object width="'+o.width+'" height="'+o.height+'"';if(r&&!o.id){o.id="_"+(""+Math.random()).substring(9)}if(o.id){m+=' id="'+o.id+'"'}o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random());if(o.w3c||!r){m+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{m+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}m+=">";if(o.w3c||r){m+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;for(var j in o){if(o[j]!==null){m+='<param name="'+j+'" value="'+o[j]+'" />'}}var n="";if(s){for(var l in s){if(s[l]!==null){n+=l+"="+(typeof s[l]=="object"?g(s[l]):s[l])+"&"}}n=n.substring(0,n.length-1);m+='<param name="flashvars" value=\''+n+"' />"}m+="</object>";return m}function d(l,o,k){var j=flashembed.getVersion();f(this,{getContainer:function(){return l},getConf:function(){return o},getVersion:function(){return j},getFlashvars:function(){return k},getApi:function(){return l.firstChild},getHTML:function(){return a(o,k)}});var p=o.version;var q=o.expressInstall;var n=!p||flashembed.isSupported(p);if(n){o.onFail=o.version=o.expressInstall=null;l.innerHTML=a(o,k)}else{if(p&&q&&flashembed.isSupported([6,65])){f(o,{src:q});k={MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title};l.innerHTML=a(o,k)}else{if(l.innerHTML.replace(/\s/g,"")!==""){}else{l.innerHTML="<h2>Flash version "+p+" or greater is required</h2><h3>"+(j[0]>0?"Your version is "+j:"You have no flash plugin installed")+"</h3>"+(l.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>");if(l.tagName=="A"){l.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!n&&o.onFail){var m=o.onFail.call(this);if(typeof m=="string"){l.innerHTML=m}}if(document.all){window[o.id]=document.getElementById(o.id)}}window.flashembed=function(k,l,j){if(typeof k=="string"){var m=document.getElementById(k);if(m){k=m}else{c(function(){flashembed(k,l,j)});return}}if(!k){return}var n={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onFail:null,expressInstall:null,w3c:false};if(typeof l=="string"){l={src:l}}f(n,l);return new d(k,n,j)};f(window.flashembed,{getVersion:function(){var l=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var k=navigator.plugins["Shockwave Flash"].description;if(typeof k!="undefined"){k=k.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var m=parseInt(k.replace(/^(.*)\..*$/,"$1"),10);var q=/r/.test(k)?parseInt(k.replace(/^.*r(.*)$/,"$1"),10):0;l=[m,q]}}else{if(window.ActiveXObject){try{var o=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(p){try{o=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");l=[6,0];o.AllowScriptAccess="always"}catch(j){if(l[0]==6){return}}try{o=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(n){}}if(typeof o=="object"){k=o.GetVariable("$version");if(typeof k!="undefined"){k=k.replace(/^\S+\s+(.*)$/,"$1").split(",");l=[parseInt(k[0],10),parseInt(k[2],10)]}}}}return l},isSupported:function(j){var l=flashembed.getVersion();var k=(l[0]>j[0])||(l[0]==j[0]&&l[1]>=j[1]);return k},domReady:c,asString:g,getHTML:a});if(e){jQuery.tools=jQuery.tools||{version:{}};jQuery.tools.version.flashembed="1.0.2";jQuery.fn.flashembed=function(k,j){var l=null;this.each(function(){l=flashembed(this,k,j)});return k.api===false?this:l}}})();(function($){$.fn.markItUp=function(settings,extraSettings){var options,ctrlKey,shiftKey,altKey;ctrlKey=shiftKey=altKey=false;options={id:'',nameSpace:'',root:'',previewInWindow:'',previewAutoRefresh:true,previewPosition:'after',previewTemplatePath:'~/templates/preview.html',previewParserPath:'',previewParserVar:'data',resizeHandle:true,beforeInsert:'',afterInsert:'',onEnter:{},onShiftEnter:{},onCtrlEnter:{},onTab:{},markupSet:[{}]};$.extend(options,settings,extraSettings);if(!options.root){$('script').each(function(a,tag){miuScript=$(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);if(miuScript!==null){options.root=miuScript[1];}});}
return this.each(function(){var $$,textarea,levels,scrollPosition,caretPosition,caretOffset,clicked,hash,header,footer,previewWindow,template,iFrame,abort;$$=$(this);textarea=this;levels=[];abort=false;scrollPosition=caretPosition=0;caretOffset=-1;options.previewParserPath=localize(options.previewParserPath);options.previewTemplatePath=localize(options.previewTemplatePath);function localize(data,inText){if(inText){return data.replace(/("|')~\//g,"$1"+options.root);}
return data.replace(/^~\//,options.root);}
function init(){id='';nameSpace='';if(options.id){id='id="'+options.id+'"';}else if($$.attr("id")){id='id="markItUp'+($$.attr("id").substr(0,1).toUpperCase())+($$.attr("id").substr(1))+'"';}
if(options.nameSpace){nameSpace='class="'+options.nameSpace+'"';}
$$.wrap('<div '+nameSpace+'></div>');$$.wrap('<div '+id+' class="markItUp"></div>');$$.wrap('<div class="markItUpContainer"></div>');$$.addClass("markItUpEditor");header=$('<div class="markItUpHeader"></div>').insertBefore($$);$(dropMenus(options.markupSet)).appendTo(header);footer=$('<div class="markItUpFooter"></div>').insertAfter($$);if(options.resizeHandle===true&&$.browser.safari!==true){resizeHandle=$('<div class="markItUpResizeHandle"></div>').insertAfter($$).bind("mousedown",function(e){var h=$$.height(),y=e.clientY,mouseMove,mouseUp;mouseMove=function(e){$$.css("height",Math.max(20,e.clientY+h-y)+"px");return false;};mouseUp=function(e){$("html").unbind("mousemove",mouseMove).unbind("mouseup",mouseUp);return false;};$("html").bind("mousemove",mouseMove).bind("mouseup",mouseUp);});footer.append(resizeHandle);}
$$.keydown(keyPressed).keyup(keyPressed);$$.bind("insertion",function(e,settings){if(settings.target!==false){get();}
if(textarea===$.markItUp.focused){markup(settings);}});$$.focus(function(){$.markItUp.focused=this;});}
function dropMenus(markupSet){var ul=$('<ul></ul>'),i=0;$('li:hover > ul',ul).css('display','block');$.each(markupSet,function(){var button=this,t='',title,li,j;title=(button.key)?(button.name||'')+' [Ctrl+'+button.key+']':(button.name||'');key=(button.key)?'accesskey="'+button.key+'"':'';if(button.separator){li=$('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul);}else{i++;for(j=levels.length-1;j>=0;j--){t+=levels[j]+"-";}
li=$('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>').bind("contextmenu",function(){return false;}).click(function(){$('ul ul',header).hide();return false;}).mouseup(function(){if(button.call){eval(button.call)();}
markup(button);return false;}).hover(function(){$('> ul',this).show();$(document).one('click',function(){$('ul ul',header).hide();});},function(){$('> ul',this).hide();}).appendTo(ul);if(button.dropMenu){levels.push(i);$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));}}});levels.pop();return ul;}
function magicMarkups(string){if(string){string=string.toString();string=string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,function(x,a){var b=a.split('|!|');if(altKey===true){return(b[1]!==undefined)?b[1]:b[0];}else{return(b[1]===undefined)?"":b[0];}});string=string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,function(x,a){var b=a.split(':!:');if(abort===true){return false;}
value=prompt(b[0],(b[1])?b[1]:'');if(value===null){abort=true;}
return value;});return string;}
return"";}
function prepare(action){if($.isFunction(action)){action=action(hash);}
return magicMarkups(action);}
function build(string){openWith=prepare(clicked.openWith);placeHolder=prepare(clicked.placeHolder);replaceWith=prepare(clicked.replaceWith);closeWith=prepare(clicked.closeWith);if(replaceWith!==""){block=openWith+replaceWith+closeWith;}else if(selection===''&&placeHolder!==''){block=openWith+placeHolder+closeWith;}else{block=openWith+(string||selection)+closeWith;}
return{block:block,openWith:openWith,replaceWith:replaceWith,placeHolder:placeHolder,closeWith:closeWith};}
function markup(button){var len,j,n,i;hash=clicked=button;get();$.extend(hash,{line:"",root:options.root,textarea:textarea,selection:(selection||''),caretPosition:caretPosition,ctrlKey:ctrlKey,shiftKey:shiftKey,altKey:altKey});prepare(options.beforeInsert);prepare(clicked.beforeInsert);if(ctrlKey===true&&shiftKey===true){prepare(clicked.beforeMultiInsert);}
$.extend(hash,{line:1});if(ctrlKey===true&&shiftKey===true){lines=selection.split(/\r?\n/);for(j=0,n=lines.length,i=0;i<n;i++){if($.trim(lines[i])!==''){$.extend(hash,{line:++j,selection:lines[i]});lines[i]=build(lines[i]).block;}else{lines[i]="";}}
string={block:lines.join('\n')};start=caretPosition;len=string.block.length+(($.browser.opera)?n:0);}else if(ctrlKey===true){string=build(selection);start=caretPosition+string.openWith.length;len=string.block.length-string.openWith.length-string.closeWith.length;len-=fixIeBug(string.block);}else if(shiftKey===true){string=build(selection);start=caretPosition;len=string.block.length;len-=fixIeBug(string.block);}else{string=build(selection);start=caretPosition+string.block.length;len=0;start-=fixIeBug(string.block);}
if((selection===''&&string.replaceWith==='')){caretOffset+=fixOperaBug(string.block);start=caretPosition+string.openWith.length;len=string.block.length-string.openWith.length-string.closeWith.length;caretOffset=$$.val().substring(caretPosition,$$.val().length).length;caretOffset-=fixOperaBug($$.val().substring(0,caretPosition));}
$.extend(hash,{caretPosition:caretPosition,scrollPosition:scrollPosition});if(string.block!==selection&&abort===false){insert(string.block);set(start,len);}else{caretOffset=-1;}
get();$.extend(hash,{line:'',selection:selection});if(ctrlKey===true&&shiftKey===true){prepare(clicked.afterMultiInsert);}
prepare(clicked.afterInsert);prepare(options.afterInsert);if(previewWindow&&options.previewAutoRefresh){refreshPreview();}
shiftKey=altKey=ctrlKey=abort=false;}
function fixOperaBug(string){if($.browser.opera){return string.length-string.replace(/\n*/g,'').length;}
return 0;}
function fixIeBug(string){if($.browser.msie){return string.length-string.replace(/\r*/g,'').length;}
return 0;}
function insert(block){if(document.selection){var newSelection=document.selection.createRange();newSelection.text=block;}else{$$.val($$.val().substring(0,caretPosition)+block+$$.val().substring(caretPosition+selection.length,$$.val().length));}}
function set(start,len){if(textarea.createTextRange){if($.browser.opera&&$.browser.version>=9.5&&len==0){return false;}
range=textarea.createTextRange();range.collapse(true);range.moveStart('character',start);range.moveEnd('character',len);range.select();}else if(textarea.setSelectionRange){textarea.setSelectionRange(start,start+len);}
textarea.scrollTop=scrollPosition;textarea.focus();}
function get(){textarea.focus();scrollPosition=textarea.scrollTop;if(document.selection){selection=document.selection.createRange().text;if($.browser.msie){var range=document.selection.createRange(),rangeCopy=range.duplicate();rangeCopy.moveToElementText(textarea);caretPosition=-1;while(rangeCopy.inRange(range)){rangeCopy.moveStart('character');caretPosition++;}}else{caretPosition=textarea.selectionStart;}}else{caretPosition=textarea.selectionStart;selection=$$.val().substring(caretPosition,textarea.selectionEnd);}
return selection;}
function preview(){if(!previewWindow||previewWindow.closed){if(options.previewInWindow){previewWindow=window.open('','preview',options.previewInWindow);}else{iFrame=$('<iframe class="markItUpPreviewFrame"></iframe>');if(options.previewPosition=='after'){iFrame.insertAfter(footer);}else{iFrame.insertBefore(header);}
previewWindow=iFrame[iFrame.length-1].contentWindow||frame[iFrame.length-1];}}else if(altKey===true){if(iFrame){iFrame.remove();}
previewWindow.close();previewWindow=iFrame=false;}
if(!options.previewAutoRefresh){refreshPreview();}}
function refreshPreview(){if(previewWindow.document){try{sp=previewWindow.document.documentElement.scrollTop}catch(e){sp=0;}
previewWindow.document.open();previewWindow.document.write(renderPreview());previewWindow.document.close();previewWindow.document.documentElement.scrollTop=sp;}
if(options.previewInWindow){previewWindow.focus();}}
function renderPreview(){if(options.previewParserPath!==''){$.ajax({type:'POST',async:false,url:options.previewParserPath,data:options.previewParserVar+'='+encodeURIComponent($$.val()),success:function(data){phtml=localize(data,1);}});}else{if(!template){$.ajax({async:false,url:options.previewTemplatePath,success:function(data){template=localize(data,1);}});}
phtml=template.replace(/<!-- content -->/g,$$.val());}
return phtml;}
function keyPressed(e){shiftKey=e.shiftKey;altKey=e.altKey;ctrlKey=(!(e.altKey&&e.ctrlKey))?e.ctrlKey:false;if(e.type==='keydown'){if(ctrlKey===true&&e.keyCode!=39){li=$("a[accesskey="+String.fromCharCode(e.keyCode)+"]",header).parent('li');if(li.length!==0){ctrlKey=false;li.triggerHandler('mouseup');return false;}}
if(e.keyCode===13||e.keyCode===10){if(ctrlKey===true){ctrlKey=false;markup(options.onCtrlEnter);return options.onCtrlEnter.keepDefault;}else if(shiftKey===true){shiftKey=false;markup(options.onShiftEnter);return options.onShiftEnter.keepDefault;}else{markup(options.onEnter);return options.onEnter.keepDefault;}}
if(e.keyCode===9){if(shiftKey==true||ctrlKey==true||altKey==true){return false;}
if(caretOffset!==-1){get();caretOffset=$$.val().length-caretOffset;set(caretOffset,0);caretOffset=-1;return false;}else{markup(options.onTab);return options.onTab.keepDefault;}}}}
init();});};$.fn.markItUpRemove=function(){return this.each(function(){$$=$(this).unbind().removeClass('markItUpEditor');$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);});};$.markItUp=function(settings){var options={target:false};$.extend(options,settings);if(options.target){return $(options.target).each(function(){$(this).focus();$(this).trigger('insertion',[options]);});}else{$('textarea').trigger('insertion',[options]);}};})(jQuery);﻿
Date.prototype.addMinutes=function(m){this.setMinutes(this.getMinutes()+m);return this;};(function($){$.xw=$.xw||{};$.xw.scriptUrls=[];$.xw.options={trace:0};$.xw.viewer={width:0,height:0};$(window).load(function(){if($.xw.options.trace){$(document.body).bind('trace',function(){var last=[];return function(e,v){var m=$.xw.typeOf(v.message)=='[object String]'?v.message:$.xw.toJson(v.message).replace(/\</g,'&lt;').replace(/\>/g,'&gt;'),c=v.color||'silver';if(last[v.type]!=m){last[v.type]=m;$(document.body).append('<p style="color:'+c+'" class="trace '+v.type+'">'+v.type+': '+m+'</p>');}else{$('.'+v.type+':last',document.body).append('.');}};}());}});$.fn.klick=function(h){this.each(function(){$(this).click(function(e){e.preventDefault();return h.apply(this,arguments);});});return this;};$.xw.typeOf=function(v){return v==undefined?'undefined':Object.prototype.toString.call(v);};$.xw.isArray=function(v){return Object.prototype.toString.call(v)=='[object Array]';};$.xw.toJson=function(o){var v=null;if($.xw.typeOf(o)=='[object Array]')
return $.xw.toJsonArg(o);var buffer=[];for(var p in o){v=$.xw.toJsonArg(o[p]);if(v!=null){buffer[buffer.length]='"'+p+'":'+v;}}
return"{"+buffer.join(',')+"}";};$.xw.toJsonArg=function(v){if(v===null){return'null';}
switch($.xw.typeOf(v)){case'[object Date]':return(v.getTime)?'"\\\/Date('+v.getTime()+')\\\/"':null;case'[object String]':return'"'+v.replace(/\\/g,'\\\\').replace(/\"/g,'\\"')+'"';case'[object Number]':case'[object Boolean]':return v;case'[object Array]':var s$=this,buf=[];$.each(v,function(i,value){buf[i]=$.xw.toJsonArg(value);});return'['+buf.join(',')+']';case'[object Object]':return $.xw.toJson(v);default:return null;}};$.xw.auth={id:null,user:null,userId:null,_cache:[],refresh:function(){var self=this,cache=this._cache,items=$('.xw-auth');items.each(function(i,el){var $e=$(el),index=$.inArray(el,cache);if(index<0){var hasEvents=$e.data('events');if(hasEvents&&hasEvents['click']){alert($.xw.replace('WARNING: Attempt to intercept an element (id={0}) with existing JQuery click event.\n\nThis is not possible.',$e.attr('id')));return;}
cache[cache.length]=el;if(el.onclick){var inline=el.onclick;el.onclick=function(){if(self.loggedIn(function(){$e.trigger('click');},null)){return inline.call(el);}else{return false;}};}else{$e.bind('click',function(e){if('a'===this.nodeName.toLowerCase()&&typeof e.originalEvent==='undefined'){var href=$(this).attr('href');if(href.substr(0,11).toLowerCase()==='javascript:'){eval(href.substr(11));}else{location.href=href;}}
if(!self.loggedIn(function(){$e.trigger('click');},null)){e.preventDefault();e.stopPropagation();}});}}});var delList=[];$.each(cache,function(i,el){if(items.index(el)<0){delList[delList.length]=i;}});for(var i=delList.length-1;i>=0;i--){cache.splice(delList[i],1);}},isLoggedIn:function(){return $('.xw-loginProxy').loginProxy('isLoggedIn');},loggedIn:function(onLogin,onCancel){return $('.xw-loginProxy').loginProxy('loggedIn',onLogin,onCancel);},logIn:function(onSuccess,onFail,deferCallback){$('.xw-loginProxy').loginProxy('logIn',onSuccess,onFail,deferCallback);}};$.xw.image={getUrl:function(args,session){var o=$.extend({'upload':'','id':'','key':'','missingKey':''},args);return $.xw.replace(session?this.surlTemplate:this.urlTemplate,o);}};$.xw.message={'id':null,'open':function(options){$.extend(options,{'mode':$.xw.MessageMode.New});$('#'+this.id).actionBox('open',options);}};$.xw.friends={'add':function(friendName){$('.xw-friendRequestProxy').friendRequestProxy('add',friendName);}};$.xw.status={add:function(target,context,msg){var id=(target===this.INFO)?this.infoId:this.errorId;(id&&$('#'+id).statusMessages('add',context,msg));},remove:function(target,context){var id=(target===this.INFO)?this.infoId:this.errorId;(id&&$('#'+id).statusMessages('remove',context));},clear:function(target){var id=(target===this.INFO)?this.infoId:this.errorId;(id&&$('#'+id).statusMessages('clear'));},infoId:'',errorId:'',INFO:0,ERROR:1};$.xw.tip={id:null,add:function(){var $tip=$('#'+this.id);$tip.toolTipManager.apply($tip,['add'].concat($.makeArray(arguments)));},remove:function(trigger){var $tip=$('#'+this.id);$tip.toolTipManager.call($tip,'remove',trigger);}};$.xw.track={on:function(){return typeof pageTracker!=='undefined';},custom:{_s:[null,null,null,null,null],page:function(slot,name,value){if(this._s[slot-1]===null){this._s[slot-1]={name:name,value:value,level:3};}},session:function(slot,name,value){if(this._s[slot-1]===null){this._s[slot-1]={name:name,value:value,level:2};}},visitor:function(slot,name,value){if(this._s[slot-1]===null){this._s[slot-1]={name:name,value:value,level:1};}},send:function(){if($.xw.track.on()){for(var i=0;i<5;i++){var sl=this._s[i];if(sl!==null){pageTracker._setCustomVar(i+1,sl.name,sl.value,sl.level);}}}}},event:function(){if($.xw.track.on()){pageTracker._trackEvent.apply(pageTracker,arguments);}},page:function(data){if($.xw.track.on()){pageTracker._trackPageview(data);}}};$.xw.inArray=function(arr,fn){for(var i=0;i<arr.length;i++){if(fn(arr[i]))return i;}
return-1;};$.xw.delegate=function(ctx,method){var p=Array.prototype.slice.call(arguments,2);return function(){return method.apply(ctx,p.concat($.makeArray(arguments)));};};$.xw.groupCall=function(method,args,group){var results={'method':method,'args':args,'value':new Array()};$('div').trigger('call.'+(group||'default'),[results]);return results;};$.xw.groupCall.result={element:null,context:null,value:null};$.xw.link={_add:function(url,p,v){url=url.replace(new RegExp('([?&]'+p+'[^&#]*)'),'');return url+((url.indexOf('?')<0?'?':'&')+p+'='+v);},go:function(url,e,options){var e=e||window.event,o=$.extend(this.defaults,options),shift=o.shiftKey?o.shiftKey:e.shiftKey;if(o.query!==null)
url=this._add(url,'rq',o.query);if(o.history!==''){var h=o.historyQuery?this._add(o.history,'rq',o.query):o.history;url=this._add(url,'h',escape(h));}
if(shift){$.xw.openWindow(url,{'contentOnly':true,'width':$.xw.viewer.width,'height':$.xw.viewer.height});}else{location.href=url;}
if(typeof e.preventDefault!=='undefined')
e.preventDefault();else if(typeof e.returnValue!=='undefined')
e.returnValue=false;},defaults:{contentOnly:false,query:null,shiftKey:false,history:'',historyQuery:false}};$.xw.openWindow=function(url,options){var o=$.extend($.xw.openDefaults,options);if(o.contentOnly){var ofs=url.indexOf('?');if(ofs<0||url.indexOf('&co',ofs)<0){url+=(ofs<0?'?':'&')+'co'}}
if(o.mode=='offset'){o.left=(window.screenX||window.screenLeft)+((o.left>=0)?o.left:10);o.top=(window.screenY||window.screenTop)+((o.top>=0)?o.top:10);}
var winArgs=$.xw.replace('location={location},menubar={menubar},resizable={resizable},scrollbars={scrollbars},status={status},titlebar={titlebar},toolbar={toolbar},directories={directories}',o);if(o.top>=0){winArgs+=',top='+o.top;}
if(o.left>=0){winArgs+=',left='+o.left;}
if(o.width>0){winArgs+=',width='+o.width;}
if(o.height>0){winArgs+=',height='+o.height;}
var handle=window.open(url,'_blank',winArgs);if(handle){handle.focus();}};$.xw.openDefaults={'mode':'offset','left':-1,'top':-1,'width':0,'height':0,'location':0,'menubar':0,'resizable':1,'scrollbars':1,'status':0,'titlebar':0,'toolbar':0,'directories':0,'contentOnly':false};$.xw.proxy=function(w,m){var e$=$('.xw-'+w);return e$[w].apply(e$,Array.prototype.slice.call(arguments,1));};$.xw.refresh=function(types,selector){if(!(types===null||(types&&types.length))){throw'invalid call to refresh. first argument must be null or an array of strings.';}
var $divs=(selector)?$(selector):$('div');if($divs.length>0){$divs.each(function(i,el){$(el).triggerHandler('refresh',[types]);});}};$.xw.replace=function(text){if(arguments.length>1){if(arguments.length===2&&typeof arguments[1]==='object'){var args=arguments[1];for(var p in args){text=text.replace(new RegExp("\\{"+p+"\\}","g"),args[p]);}}else{for(var i=1;i<arguments.length;i++){text=text.replace(new RegExp("\\{"+(i-1)+"\\}","g"),arguments[i]);}}}
return text;};$.xw.show=function($set,value){(value)?$set.show():$set.hide();return value;};$.xw.set=function(){var result={};for(var i=0;i<arguments.length;i++)
result[arguments[i]]=true;return result;};$.xw.valid=function(group){var a=new $.xw.valid.args();$('div').trigger('validate.'+(group||'default'),[a]);return a.isValid();};$.xw.valid.args=function(){var _valid=true;this.fail=function(msg){_valid=false;if(this.onFail){this.onFail(msg);this.onFail=null;}};this.isValid=function(){return _valid;};this.onFail=null;};$.fn.appendButton=function(label,css,click){return this.each(function(){var b=$('<button type="button"><span></span></button>');if(css){b.addClass(css);}
if($.isFunction(click)){b.click(click);}
if(label){b.children().eq(0).append(label);}
$(this).append(b);return this;});};$.fn.sort=function(){return this.pushStack([].sort.apply(this,arguments),[]);};$.fn.ph=function(){var total=0;this.each(function(){total+=parseInt($(this).css('padding-top'))+parseInt($(this).css('padding-bottom'));});return total;};$.fn.pw=function(){var total=0;this.each(function(){total+=parseInt($(this).css('padding-left'))+parseInt($(this).css('padding-right'));});return total;};$.fn.busy=function(options){var o=(typeof options==='boolean')?{'visible':options}:options;return this.each(function(){var e$=$(this);if(typeof this._busy==='undefined'||this._busy===null){this._busy=$('<div id="toggleBusy" class="x_busy" />').hide().appendTo(document.body);}
var adjust=$.extend({'visible':true,'left':0,'top':0,'width':0,'height':0,'backgroundPosition':'center center'},o);if(adjust.visible){var position=e$.offset();if(typeof adjust.backgroundColor!=='undefined')
this._busy.css('background-color',adjust.backgroundColor);this._busy.css({'top':position.top+adjust.top,'left':position.left+adjust.left,'width':e$.width()+adjust.width,'height':e$.height()+adjust.height,'background-position':adjust.backgroundPosition}).show();}else{this._busy.remove();this._busy=null;}
return this;});};$.fn.swapClass=function(oldClass,newClass){return this.each(function(){$(this).removeClass(oldClass).addClass(newClass);});};$.fn.elastic=function(){var mimics=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight'];return this.each(function(){if(this.type!='textarea'){return false;}
var $textarea=jQuery(this),$twin=jQuery('<div />').css({'position':'absolute','display':'none','word-wrap':'break-word'}),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0,i=0;if(maxheight<0){maxheight=Number.MAX_VALUE;}
$twin.appendTo($textarea.parent());var i=mimics.length;while(i--){$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));}
function setHeightAndOverflow(height,overflow){curratedHeight=Math.floor(parseInt(height,10));if($textarea.height()!=curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':overflow});}}
function update(){var textareaContent=$textarea.val().replace(/&/g,'&amp;').replace(/  /g,'&nbsp;').replace(/<|>/g,'&gt;').replace(/\n/g,'<br />');var twinContent=$twin.html();if(textareaContent+'&nbsp;'!=twinContent){$twin.html(textareaContent+'&nbsp;');if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){var goalheight=$twin.height()+lineHeight;if(goalheight>=maxheight){setHeightAndOverflow(maxheight,'auto');}else if(goalheight<=minheight){setHeightAndOverflow(minheight,'hidden');}else{setHeightAndOverflow(goalheight,'hidden');}}}}
$textarea.css({'overflow':'hidden'});$textarea.keyup(function(){update();});$textarea.live('input paste',function(e){setTimeout(update,250);});update();});};$.fn.ellipses=function(target){return this.each(function(){var $self=$(this),$text=$self.contents('[nodeType=3]');if(target<=0||$text.length!==1||$self.width()<=target){return;}
$self.attr('title',$text[0].nodeValue).css({'cursor':'pointer','white-space':'nowrap'});var $alt=$self.clone(true);$alt.css({'width':'auto','display':'inline'});$self.replaceWith($alt);var el=$alt.contents('[nodeType=3]')[0],text=el.nodeValue,orig_w=$alt.width();if(orig_w<target){$alt.replaceWith($self);return;}
el.nodeValue+='...';var ellipse_w=$alt.width()-orig_w,newTgt=target-ellipse_w,charsToRemove=Math.floor(text.length*(orig_w-newTgt)/orig_w);el.nodeValue=text.substr(0,text.length-charsToRemove);var w=$alt.width();while(w>newTgt&&el.nodeValue.length>4&&function(){el.nodeValue=el.nodeValue.substr(0,el.nodeValue.length-1);if(w==$alt.width()){return false;}
w=$alt.width();return true;}());$self.contents('[nodeType=3]')[0].nodeValue=el.nodeValue+'...';$alt.replaceWith($self);});};$.fn.selectOnFocus=function(options){$(this).each(function(){if(typeof(this.value)==='undefined'){return;}
var o=$.extend({'from':0,'to':'end'},options);$(this).bind('focus.selectOnFocus',function(e){if(!$.isFunction($(this).cursorSelect)){$(this).textCursor();}
$(this).textCursor('cursorSelect',o);});});return this;};$.fn.shadowText=function(text,options){if(typeof(text)=='undefined'||text===null||text.length===0){return this;}
return $(this).each(function(){var $for=$(this);if(!($for.is('[type="text"]')||$for.is('[type="password"]')||$for.is('textarea'))||$for.next().is('.ShadowText')){return;}
var $text=$('<span class="ShadowText" />').click(function(e){$for.focus();}).text(text);$for.bind('focus',function(e){$text.hide();}).bind('keypress',function(e){$text.hide();}).bind('blur',function(e){(($for.val().length===0)&&$text.show());}).after($text);function position(){var p=$for.position();$text.css({'top':p.top,'left':p.left});}
if($text.visible()){position();($for.val().length===0)?$text.show():$text.hide();}else{$text.one('show.shadowText',position);}});};$.fn.autoComplete=function(remote,options){return $(this).each(function(){var $input=$(this);if(!($input.is('[type="text"]')||$input.next().is('.AutoComplete'))){return;}
var $c=$('<span class="AutoComplete" />'),lists=[],overPanel=false;$c.bind('click',function(e){var el=e.target;while(el!==null&&el.tagName.toLowerCase()!=='li'){el=el.parentNode;}
if(el!==null){$input.val($(el).text());$c.hide();}}).hover(function(){overPanel=true;},function(){overPanel=false;}).appendTo(document.body).hide();var show=function($ul){var offset=$input.offset();$ul&&$c.empty().append($ul).css({'top':offset.top+$input.outerHeight(),'left':offset.left,'width':$input.outerWidth()}).show();};$input.focus(function(){var text=$.trim($input.val());text.length&&lists[text]&&show(lists[text].ul);}).blur(function(){!overPanel&&$c.hide();}).keyup(function(e){var text=$.trim($input.val());if(text.length>0){if(!(text in lists)){remote(text,function(list){if(list.length){var $ul=$('<ul />');$.each(list,function(i,v){$ul.append('<li>'+v.replace(new RegExp(text,'gi'),'<b>'+text+'</b>')+'</li>');});show($ul);lists[text]={'ul':$ul};}else{$c.hide();lists[text]={'ul':null};}});}else{if(lists[text].ul){show(lists[text].ul);}else{$c.hide();}}}else{$c.hide();}});});};$.fn.showSwitch=function(value){return $(this).each(function(){(value)?$(this).show():$(this).hide();});};$.fn.detach=function(){return this.each(function(){if(!this.parentNode)return;this.parentNode.removeChild(this);});}
$.fn.visible=function(){return!this.is(':hidden');};$.xw.history={_curHash:null,_callback:null,_historyLength:0,_backStack:[],_forwardStack:[],_stopCheck:false,_first:false,_needIframe:$.browser.msie&&($.browser.version<8||document.documentMode<8),init:function(callback){var s$=this;s$._callback=callback;var current_hash=location.hash.replace(/\?.*$/,'');s$._curHash=current_hash;if(s$._needIframe){if(s$._curHash==''){s$._curHash='#';}
$("body").prepend('<iframe id="jQuery_history" style="display: none;"'+' src="javascript:false;"></iframe>');var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentWindow.document;iframe.open();iframe.close();iframe.location.hash=current_hash;}
else if($.browser.safari){s$._backStack.length=history.length;s$._historyLength=history.length;s$._first=true;}
if(current_hash)
s$._callback(current_hash.replace(/^#/,''),'init');setInterval($.xw.delegate(s$,s$._check),100);},_add:function(hash){this._backStack.push(hash);this._forwardStack.length=0;this._first=true;},_check:function(){var s$=this;if(s$._needIframe){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentDocument||ihistory.contentWindow.document;var current_hash=iframe.location.hash.replace(/\?.*$/,'');if(current_hash!=s$._curHash){location.hash=current_hash;s$._curHash=current_hash;s$._callback(current_hash.replace(/^#/,''),'ext');}}else if($.browser.safari){if(s$._historyLength==history.length&&s$._backStack.length>s$._historyLength){s$._backStack.shift();}
if(!s$._stopCheck){var historyDelta=history.length-s$._backStack.length;s$._historyLength=history.length;if(historyDelta){s$._first=false;if(historyDelta<0){for(var i=0;i<Math.abs(historyDelta);i++)s$._forwardStack.unshift(s$._backStack.pop());}else{for(var i=0;i<historyDelta;i++)s$._backStack.push(s$._forwardStack.shift());}
var cachedHash=s$._backStack[s$._backStack.length-1];if(cachedHash!=undefined){s$._curHash=location.hash.replace(/\?.*$/,'');s$._callback(cachedHash,'ext');}}else if(s$._backStack[s$._backStack.length-1]==undefined&&!s$._first){if(location.hash){var current_hash=location.hash;s$._callback(location.hash.replace(/^#/,''),'ext');}else{var current_hash='';s$._callback('','ext');}
s$._first=true;}}}else{var current_hash=location.hash.replace(/\?.*$/,'');if(current_hash!=s$._curHash){s$._curHash=current_hash;s$._callback(current_hash.replace(/^#/,''),'ext');}}},load:function(hash){var newhash,s$=this;hash=decodeURIComponent(hash.replace(/\?.*$/,''));if($.browser.safari){newhash=hash;}
else{newhash='#'+hash;location.hash=newhash;}
s$._curHash=newhash;if(s$._needIframe){var ihistory=$("#jQuery_history")[0];var iframe=ihistory.contentWindow.document;iframe.open();iframe.close();iframe.location.hash=newhash;s$._historyLength=history.length;s$._callback(hash,'int');}
else if($.browser.safari){s$._stopCheck=true;s$._add(hash);var fn=function(){s$._stopCheck=false;};window.setTimeout(fn,200);s$._callback(hash,'int');location.hash=newhash;}
else{s$._callback(hash,'int');}}};$.xw.aspNetBase={aspNetBaseInit:function(args){args=$.extend({'addClass':true},args);(args.addClass&&this.element.addClass(this.widgetBaseClass));var o=this.options;o.id=$(this.element).attr('id');var idx=o.id.lastIndexOf('_');o.idParent=(idx>0)?o.id.substr(0,idx):null;(o.disabled&&this.element.addClass(this.widgetBaseClass+'-disabled'));},$get:function(id){return $('#'+this.options.id+'_'+id);},$getInParent:function(id){return $('#'+(this.options.idParent||this.options.id)+'_'+id);},$fnd:function(id){return(id)?$find(this.options.id+'_'+id):$find(this.options.id);},$ref:function(id,plugInName){var o=$('#'+this.options.id+'_'+id);return(o===null)?null:o[plugInName];},$gr:function(key,cb,err){this.$remote('GetTextResource',{'key':key},function(text){cb(text);},err);return this;},$uc:function(id,path,theme,args){var w$=this,o=w$.options;args=$.extend({'ucArgs':null},args);w$.element.unbind('ucLoading').unbind('ucLoaded');if(args.loading)
w$.element.bind('ucLoading',args.loading);if(args.loaded)
w$.element.bind('ucLoaded',args.loaded);if(o.uc==undefined){o.uc=[];}
if(o.uc[id]==undefined){o.uc[id]={'id':id,'path':path,'loaded':false,'data':$('body > e')};this.$remote('GetUserControl',{'path':path,'id':id,'theme':theme,'data':args.ucArgs},function(data){var delay=0;o.uc[id].data=$('input[name!="__VIEWSTATE"]',data.hidden).add(data.html);var x=o.uc[id].data;debugger
if(data.scriptUrls!==null){$.each(data.scriptUrls,function(){var nv=this;if($.xw.inArray($.xw.scriptUrls,function(v){return v==nv;})<0){$.xw.scriptUrls[$.xw.scriptUrls.length]=nv;$.getScript(nv);delay=1000;}});}
function loadAndOpen(){w$.element.triggerHandler('ucLoading',o.uc[id]);eval(data.loadScripts);o.uc[id].loaded=true;w$.element.triggerHandler('ucLoaded',o.uc[id]);};if(delay>0){window.setTimeout(loadAndOpen,delay);}else{loadAndOpen();}},function(err){alert(err.responseText);});}
return w$;},$remote:function(method,args,success,error,sync){var w$=this,o=w$.options,async=sync?false:true,m=(o.servicePath)?o.servicePath+'/'+method:method,a=typeof(args)==='object'?this.toArgs(args):args;$(document.body).trigger('trace',{'type':'remoteRequest','message':m+'('+a+')','color':'green'});$.ajax({async:async,type:"POST",contentType:"application/json; charset=utf-8",url:m,data:a,dataType:"json",success:function(data){$(document.body).trigger('trace',{'type':'remoteResponse','message':data,'color':'blue'});w$._decode(data.d);success&&success.apply(w$,[data.d]);},error:function(err){if($.isFunction(error)){error.call(w$,err);}
if(w$.options.log){w$._ajaxError.call(w$,err);}}});},_ajaxError:function(err){$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:(this.options.logPath)?this.options.logPath+'/LogScriptError':'LogScriptError',data:"{'pluginName': '"+this.widgetName+"', 'type': 'AJAX', 'message': '"+err.responseText+"'}",dataType:"json",success:null,error:null});},toArgs:function(obj){return $.xw.toJson(obj);},_decode:function(obj){if(typeof obj!=='object'){return;}
for(var p in obj){if(this._isDate(obj[p])){obj[p]=this._toDate(obj[p]);}else if(typeof obj[p]==='object'){this._decode(obj[p]);}}},_isDate:function(value){return(typeof value==='string'&&value.indexOf('Date(')>0);},_toDate:function(value){var tics=parseInt(value.substring(value.indexOf('(')+1,value.indexOf(')')));return new Date(tics);}};})(jQuery);﻿
(function($){$.widget("xw.actionBox",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit({'addClass':false});var o=this.options,$e=this.element,$form=this.element.parents('form'),widget=this,$content=$('<div class="xw-actionBox-container" />').append('<div class="xw-actionBox-content" />').children().append(this.element.contents()).end().appendTo(this.element);this.element.dialog({autoOpen:false,height:o.height||'auto',modal:true,overlay:{opacity:0.5,background:"black"},resizable:false,position:'center',title:o.title,width:o.width||'auto'}).show();this.element.addClass('xw-actionBox');var $outer=this.element.parents('.ui-dialog');if(o.postsBack&&$outer.parents('form').length===0)
$outer.appendTo($form[0]);if(o.cssClass)
$outer.addClass(o.cssClass);function setShadow(){if(o.postsBack){if($outer.parents('form').length===0)
$outer.appendTo($form[0]);$e.data('dialog').overlay.$el.appendTo($form[0]);};if(!o.$shadow){o.$shadow=$('<div />').css({'position':'absolute','z-index':0,'background-color':'black'}).insertAfter($outer);};var ofs=$outer.offset();o.$shadow.css({'top':ofs.top+3,'left':ofs.left+3,'width':$outer.width(),'height':$outer.height()}).show();$content.height($outer.height()-$outer.find('.ui-dialog-titlebar').outerHeight()-10);};$e.dialog('option','open',setShadow);$e.dialog('option','close',function(){(o.close&&o.close());o.$shadow.hide();widget.busy(false);});$e.dialog('option','drag',setShadow);$e.dialog('option','dragStop',setShadow);(o.openers&&$.each(o.openers,function(){$('#'+this).bind('click',function(){widget.open();})}));$outer.find('.ui-resizable-handle').hide();$outer.find('.ui-dialog-titlebar-close').html(o.closeLabel);this.options.dialog=$outer;o.okId&&$('#'+o.okId).each(function(i,el){if(el.onclick){var inline=el.onclick;el.onclick=function(e){if(o.onOk){var value=o.onOk.call(widget,e);if(typeof value==='undefined'||value!==false)
inline.call(el);};};}else{$(el).click(function(e){widget.close();if(o.onOk){var value=o.onOk.call(widget,e);if(value===false)
e.preventDefault();};});}});o.cancelId&&$('#'+o.cancelId).click(function(e){widget.close();if(o.onCancel){var value=o.onCancel.call(widget,e);if(value===false)
e.preventDefault();};});if(o.proxy){$(document.body).append($('<div />').attr('id',$e.attr('id')+'Proxy')[o.proxy]({'actionId':$e.attr('id'),'servicePath':o.servicePath}));}},load:function(){var widget=this,o=this.options;if(o.onLoad)
o.onLoad.call(this);o.onOpen&&this.element.bind('opening',$.xw.delegate(this,o.onOpen));if(o.cssTriggers)
$.each(o.cssTriggers.split(','),function(i,v){$('.'+v).click(function(){widget.open();});});},busy:function(options){var o=$.extend({'height':4},(typeof options==='boolean')?{'visible':options}:options);this.element.find('div:eq(0)').busy(o);},onOk:function(handler){this.options.onOk=handler;},opening:function(method){this.element.bind('opening',method);},open:function(options){var widget=this;(this.options.auth)?$.xw.auth.logIn(function(){widget._preOpen.apply(widget,[options]);},null):this._preOpen(options);},_preOpen:function(options){var o=this.options,widget=this,isLoaded=this.options.loaded;if(o.ucPath&&!isLoaded){widget.$remote('GetUserControl',{'path':o.ucPath,'id':o.ucId,'theme':o.theme,'data':null},function(data){var $content=widget.element.find('.xw-actionBox-content'),delay=0;$(data.hidden).find('input[name!="__VIEWSTATE"]').appendTo($content);$(data.html).appendTo($content);if(data.scriptUrls!==null){$.each(data.scriptUrls,function(){var nv=this;if($.xw.inArray($.xw.scriptUrls,function(v){return v==nv;})<0){$.xw.scriptUrls[$.xw.scriptUrls.length]=nv;$.getScript(nv);delay=1000;}});}
function loadAndOpen(){eval(data.loadScripts);widget.options.loaded=true;widget._open(options);};if(delay>0){window.setTimeout(loadAndOpen,delay);}else{loadAndOpen();}},function(err){alert(err.responseText);});}else{this._open(options);}},_open:function(options){var widget=this,$e=widget.element;$e.triggerHandler('opening',{'context':widget,'options':options});$e.dialog('open').find('.ShadowText').each(function(){$(this).triggerHandler('show');});$e.triggerHandler('opened',{'context':widget,'options':options});},opened:function(method){this.element.bind('opened',method);},close:function(){$(this.element).dialog('close');},title:function(){if(arguments.length>0){this.element.dialog('option','title',arguments[0]);this.options.width&&$('.ui-dialog-title',this.element.parents('.ui-dialog')).ellipses(this.options.width*0.7);}else
return $('.ui-dialog-title',this.element.parents('.ui-dialog')).text();}}));$.xw.actionBox.getter='title';$.xw.actionBox.defaults={'ucId':null};$.widget("xw.breadCrumb",$.extend({},{_init:function(){this.element.addClass(this.widgetBaseClass);function shrink(node){var linkText=$(node).text();if(linkText.length<5)return false;var length=linkText.length-((linkText.substr(linkText.length-3,3)==='...')?4:3);$(node).text(linkText.substr(0,length)+'...');return true;}
var target=this.options.width;if(target>0){var width=0,longest=null,shrunk=true,count=0;while(shrunk&&this.element.width()>target&&count++<100){$('a',this.element).each(function(index){if(index===0)
width=0;var w=$(this).width();if(w>width){width=w;longest=this;}});shrunk=shrink(longest);};};this.element.css('visibility','visible');}}));$.widget("xw.countryList",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options,$e=this.element,hiddenId=this.element[0].id.replace(/_/g,'$'),ui={label:this.element.find('a').css({'background-position':'-'+this.options.left+'px -'+this.options.top+'px','width':this.options.width,'height':this.options.height}),hidden:$(document.getElementById(hiddenId)),ul:null};widget.options.ui=ui;if(o.containerUrl)
$e.css({'background-image':'url('+o.containerUrl+')'});$(document).bind('click.countryList',function(e){var ui=widget.options.ui;if(ui.ul!=null&&!$(e.target).parents().hasClass(widget.widgetBaseClass))
ui.ul.hide();});$e.one('click',function(e,options){widget.$remote("GetCountries",{'theme':widget.options.theme},function(data){var ui=widget.options.ui,offset=$e.offset();widget.options.data=data;ui.ul=$('<ul></ul>').addClass(widget.widgetBaseClass).css({'top':offset.top+$e.outerHeight(),'left':offset.left}).bind('click',function(e){var ui=widget.options.ui,el=e.target;while(el!=null&&el.tagName.toLowerCase()!=='li')
el=el.parentNode;if(el!=null){widget.selectedValue($(el).attr('data'));ui.ul.hide();widget.element.triggerHandler('change',$(el).attr('data'));}}).appendTo(document.body).hide();$.each(data,function(){var flagCss={'background-image':'url('+widget.options.imageUrl+')','background-position':'-'+this.left+'px -'+this.top+'px','height':widget.options.height,'width':widget.options.width};ui.ul.append($(String.format('<li><label>{0}</label><a href="javascript:void(0)" title="{0}" /><span>+{1}</span></li>',this.name,this.prefix)).attr('data',this.code).addClass((this.code===widget.options.value)?'selected':null).find('a').css(flagCss).end());});widget.options.ui=ui;$e.bind('click.countryList',function(e){e.stopPropagation();var ui=widget.options.ui;if(ui.ul.visible()){$(document).triggerHandler('click.countryList');}else{var listHeight=$(window).height()-$e.offset().top+$(window).scrollTop()-$e.height();ui.ul.css('max-height',Math.max(listHeight,100)).fadeIn('fast');}});if(!options||(options&&!options.hide))
$e.triggerHandler('click.countryList');if(options&&$.isFunction(options.callback))
options.callback.call(widget);});});},change:function(handler){this.element.bind('change',handler);},selectedValue:function(value){function _selectedValue(){var ui=this.options.ui;ui.ul.find('li').removeClass('selected');var a=ui.ul.find('li[data="'+value+'"]').addClass('selected').find('a');ui.label.css('backgroundPosition',a.css('backgroundPosition')).attr('title',a.attr('title'));ui.hidden.val(value);};var ui=this.options.ui;if(ui.ul===null)
this.element.triggerHandler('click',{hide:true,callback:_selectedValue});else
_selectedValue.call(this);},destroy:function(){$(document).unbind('click.countryLink');var ui=this.options.ui;if(ui.ul!==null)
ui.ul.remove();this.element.unbind('.countryLink').removeData('ui').removeData('data').removeData('countryList');}}));$.xw.countryList.getter='selectedValue';$.widget("xw.flowPlayer3",$.extend({},$.xw.aspNetBase,{_init:function(){var widget=this,o=this.options;this.aspNetBaseInit();o.cueSet=false;$(window).unload(function(){widget.element.flowplayer(0).stopBuffering();});this.element.flowplayer({src:o.swfPath,wmode:'transparent'},{playlist:o.flvPath?[o.flvPath]:null,clip:{autoBuffering:o.autoBuffering,autoPlay:o.autoPlay,scaling:o.scaling,onStart:function(clip){if(!o.cueSet){this.onCuepoint([5000],function(clip,cuepoint){if(o.assetId&&o.track){widget.$remote('LogView',{'assetId':o.assetId,'type':'Movie'});}});o.cueSet=true;}}},canvas:{backgroundColor:'#000000',backgroundGradient:'none'}});},unload:function(){var player=this.element.flowplayer(0);player.stop();player.stopBuffering();player.unload();},setClip:function(url,assetId,track){var player=this.element.flowplayer(0);this.options.track=(arguments.length>2&&track);player.stop();player.stopBuffering();player.unload();this.options.assetId=assetId;player.getClip(0).update({url:url});player.load();}}));$.widget("xw.googleMap",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options,geo=new GClientGeocoder();o.message=(o.messageId)?$('#'+o.messageId).html():'<b>This is my <i>approximate</i> Location</b>';if(GBrowserIsCompatible()&&o.lat&&o.lng){var map=new GMap2(widget.element[0]);function showLocation(point){var m=(o.prv)?$.xw.replace('<b>{0}{1}</b><br />',o.prv,(o.cty)?' / '+o.cty:'')+o.message:o.message;map.openInfoWindowHtml(point,m);};var myPlace=new GLatLng(o.lat,o.lng);map.setCenter(myPlace,13);map.setUIToDefault();showLocation(myPlace);o.clickHandle=GEvent.addListener(map,"click",function(overlay,latlng){widget.element.busy();geo.getLocations(latlng,function(r){var country=null;if(r.Status.code==200&&r.Placemark&&r.Placemark[0].AddressDetails){var d=r.Placemark[0].AddressDetails;country=d.Country.CountryNameCode;o.prv=null;o.cty=null;if(d.Accuracy>=4&&d.Country.AdministrativeArea){o.prv=d.Country.AdministrativeArea.AdministrativeAreaName;if(d.Country.AdministrativeArea.Locality)
o.cty=d.Country.AdministrativeArea.Locality.LocalityName;}}
showLocation(latlng);widget.$remote('SetLocation',{'lat':latlng.y,'lng':latlng.x,'country':country,'region':o.prv,'locality':o.cty},function(){widget.element.busy(false);},function(err){widget.element.busy(false);});});});}},destroy:function(){this.options.clickHandle&&GEvent.removeListener(this.options.clickHandle);GUnload();}}));$.widget("xw.statusMessages",$.extend({},{_init:function(){this.buffer=[];},add:function(c,m){if(0<$.grep(this.buffer,function(value){return(m==value.message);}).length)
return;this.buffer[this.buffer.length]={message:m,context:c,li:$(this.element).find('.x_body').append('<li>'+m+'</li>').find(':last')};this.element.show();},remove:function(c){var self=this;var items=$.grep(this.buffer,function(value){return(c==value.context);})
$.each(items,function(){var index=$.inArray(this,self.buffer);if(index>=0){this.li.remove();self.buffer.splice(index,1);}});if(this.buffer.length===0)
this.element.hide();},clear:function(){this.element.find('li').remove().end().hide();this.buffer=[];}}));$.widget("xw.toolTipManager",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options,$e=this.element,ui={content:$('<div class="x_middle"></div>'),tpoint:$('<div></div>'),point:$('<div></div>'),top:$('<div class="x_top"><span /></div>'),bottom:$('<div class="x_bottom"><span /></div>'),shadow:{self:$('<div class="x_shadow"></div>'),top:$('<div class="x_stop"><span /></div>'),middle:$('<div class="x_smiddle"></div>'),bottom:$('<div class="x_sbottom"><span /></div>')}};this.options.ui=ui;this.element.css({'width':'100%'});;$e.appendTo(document.body).append(ui.top).append(ui.content).append(ui.bottom).hover(function(){o.deferHide.clear();},function(){o.deferHide.call(this,1000);});if(o.hasPoint){ui.top.append(ui.tpoint);ui.bottom.append(ui.point);}
o.hasShadow&&$e.append(ui.shadow.self.append(ui.shadow.top).append(ui.shadow.middle).append(ui.shadow.bottom));o.dx.offset=function(el){return(this.IsEmpty)?0:(this.Type===7)?el.width()*this.Value/100:this.Value;};o.dy.offset=function(el){return(this.IsEmpty)?0:(this.Type===7)?el.height()*this.Value/100:this.Value;};o.hasShadow&&(o.padding=ui.shadow.top.height()+ui.shadow.bottom.height());function deferCall(context,method){this.handle=0;this.call=function(el,delay){if(delay==0){$.xw.delegate(context,method,el);}else
this._handle=window.setTimeout($.xw.delegate(context,method,el),delay);};this.clear=function(){(this._handle&&window.clearTimeout(this._handle));this._handle=0;};};o.deferShow=new deferCall(this,function(el){var $el=$(el),$e=this.element,o=this.options,ui=this.options.ui,ctx=o.cache.find($el);if(ctx===null){return;}
$e.css({'visibility':'hidden','left':0,'width':'95%'});function show(content){if(content===null){return;}
if($.xw.typeOf(content)=='[object String]')
ui.content.html($('<span />').html(content));else{if(!(ui.content.length>0&&content[0]==ui.content.children()[0]))
ui.content.empty().append(content);}
ui.content.click(function(){widget.element.css({'visibility':'hidden'});});$e.css({'width':Math.min(ui.content.children().width()+20,$(window).width()*0.45)});ctx.cssClass&&$e.addClass(ctx.cssClass);var pos=new function($trigger,$tip,ox,oy){var tw=$trigger.width(),th=$trigger.height(),tO=$trigger.offset(),tx=tO.left,ty=tO.top,ttw=$tip.width(),tth=$tip.height(),ww=$(window).width(),st=window.pageYOffset||document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop;this.tp=(ty-st-th-tth<0);this.rx=(tx+tw+ttw>$(window).width());this.x=this.rx?(tx+tw-ttw-ox):(tx+ox);this.y=this.tp?ty+th-oy:ty-tth+oy;this.tth=tth;this.ttw=ttw;}($el,$e,o.dx.offset($el),o.dy.offset($el));if(o.hasPoint){ui.point.removeAttr('class');ui.tpoint.removeAttr('class');if(pos.tp)
ui.tpoint.addClass(pos.rx?'x_rtpoint':'x_tpoint');else
ui.point.addClass(pos.rx?'x_rpoint':'x_point');}
$e.css({'top':pos.y,'left':pos.x,'visibility':'visible'});if(o.hasShadow){ui.shadow.self.css('width',pos.ttw);ui.shadow.middle.css('height',pos.tth-o.padding);};if(ctx.remoteOnce){ctx.content=content;ctx.remote=null;}}
if(ctx.remote){ctx.remote(function(content){show(content);});}else{show($('<span />').html((ctx.contentId)?$('#'+ctx.contentId).html():ctx.content));}});o.deferHide=new deferCall(this,function(el){this.element.css({'visibility':'hidden'});});o.cache=[];o.cache.index=function(trigger){for(var i=0;i<this.length;i++)
if(this[i].trigger[0]===trigger[0])
return i;return-1;};o.cache.find=function(trigger){var i=this.index(trigger);return(i<0)?null:this[i];};for(var id in o.triggers){var t=o.triggers[id];this.add(id,t.contentId,t.cssClass,t.delay);};},add:function(){var args=(arguments.length===1&&typeof arguments[0]==='object')?arguments[0]:{'triggerId':arguments[0],'contentId':(arguments.length>1)?arguments[1]:null,'cssClass':(arguments.length>2)?arguments[2]:null,'delay':(arguments.length>3)?arguments[3]:null,'content':null,'trigger':null},widget=this,o=this.options,delay=args.delay||o.delay,$t=(args.triggerId)?$('#'+args.triggerId):args.trigger;if($t.length>0&&o.cache.index($t)<0){o.cache[o.cache.length]={'trigger':$t,'contentId':args.contentId,'cssClass':args.cssClass,'delay':delay,'content':args.content,'remote':args.remote,'remoteOnce':args.remoteOnce};$t.bind('mouseover',function(e){o.deferHide.clear();o.deferShow.call(this,delay);}).bind('mouseout',function(){o.deferShow.clear();o.deferHide.call(this,Math.max(1000,delay));}).css('cursor','pointer');};},remove:function(trigger){var $t=(typeof trigger==='string')?$('#'+trigger):trigger;$t.unbind();var i=this.options.cache.index($t);if(i>=0)
this.options.cache.splice(i,1);}}));$.xw.toolTipManager.defaults={triggers:{},dx:0,dy:0};})(jQuery);﻿
(function($){$.widget("xw.repeater",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options,$e=this.element,ui=o.ui={pageLabel:$('<div class="x_pageLabel"/>'),pageLinks:$('<div class="x_links" />'),page:$('<div class="'+o.pageCss+'" />'),layout:$('.xw-repeater-layout',this.element),empty:$('.xw-repeater-empty',this.element).hide(),items:$(o.itemsSelector,this.element)};ui.items.empty();ui.page.append(ui.pageLabel).append(ui.pageLinks).hide();$e.prepend(ui.page);ui.pageLinks.append('<span class="x_first">'+(o.swapLabels?o.lastLabel:o.firstLabel)+'</span>').append('<span class="x_fs">'+o.firstSeperator+'</span>').append('<span class="x_prev" />').append('<span class="x_nos" />').append('<span class="x_next" />').append('<span class="x_ls">'+o.lastSeperator+'</span>').append('<span class="x_last">'+(o.swapLabels?o.firstLabel:o.lastLabel)+'</span>');if(o.cv){$e.show();}
$.extend(this.pagination,{element:ui.page,label:ui.pageLabel,links:ui.pageLinks,size:o.pageSize});},load:function(){var widget=this,o=this.options,s=$('#'+o.dataSourceId)
ui=o.ui;o.dataSource=$.xw.delegate(s,s[o.dataSourceName]);o.dataSource('initSource',widget,ui.layout);if(o.auto)
this.loadPage(o.pageIndex);this.element.bind('refresh.repeater',function(e,types){((types==null||$.inArray('messages',types)>=0)&&widget.loadPage());});},loadPage:function(pageIndex,e){var widget=this,o=this.options,$e=this.element,ui=o.ui;function link($e,text,index){if(text=='')
(index&&$e.click($.xw.delegate(widget,widget.loadPage,index)));else
(index)?$e.append($('<a href="javascript:void(0)" />').html(text).click(o.auth?function(){$.xw.auth.logIn($.xw.delegate(widget,widget.loadPage,index));}:$.xw.delegate(widget,widget.loadPage,index))):$e.append(text);};o.pageIndex=pageIndex||o.pageIndex;ui.layout.busy();o.dataSource('data',{'pageIndex':o.pageIndex,'pageSize':o.pageSize},function(data){data=$.extend({totalCount:0,rows:[]},data);if(data.totalCount===0){ui.page.hide();if(ui.empty.length){ui.layout.hide();ui.empty.show();}else{o.dataSource('databind',widget,ui.layout,data);ui.items.setTemplate(o.template).processTemplate(data);o.dataSource('databound',widget,ui.layout,data);}
ui.layout.busy(false);return;};ui.page.show();ui.layout.show();ui.empty.hide();var pageCount=o.pageCount=parseInt((data.totalCount-1)/o.pageSize+1);ui.pageLabel.text($.xw.replace('Page {page} of {total}',{'page':o.pageIndex,'total':pageCount}));ui.page.showSwitch(widget.paginationVisible());link(ui.pageLinks.find('.x_first').empty(),o.swapLabels?o.lastLabel:o.firstLabel,pageIndex<=1?null:1);link(ui.pageLinks.find('.x_prev').empty(),'',pageIndex<=1?null:pageIndex-1);var x=ui.pageLinks.find('.x_nos').find('a').unbind('click').end().empty();var min=Math.max(1,o.pageIndex-o.delta-((o.pageIndex>pageCount-o.delta)?o.pageIndex-pageCount+o.delta:0));var max=Math.min(pageCount,o.pageIndex+o.delta+((o.delta+1>o.pageIndex)?o.delta+1-o.pageIndex:0));for(var i=min;i<=max;i++){link(x,i,(o.pageIndex===i)?null:i);((i<pageCount)&&x.append('<span class="x_s" />'));}
link(ui.pageLinks.find('.x_next').empty(),'',pageIndex>=pageCount?null:pageIndex+1);link(ui.pageLinks.find('.x_last').empty(),o.swapLabels?o.firstLabel:o.lastLabel,pageIndex>=pageCount?null:pageCount);o.dataSource('databind',widget,ui.layout,data);ui.items.setTemplate(o.template,null,{filter_data:o.encodeHtml}).processTemplate(data);ui.layout.busy(false);o.dataSource('databound',widget,ui.layout,data);o.onDataBound&&o.onDataBound.apply(widget,[null,{'content':ui.layout,'data':data}]);},function(err){ui.layout.busy(false);},ui.layout);},swapLabels:function(value){var o=this.options;o.swapLabels=value;$('.x_first',ui.pageLinks).html(value?o.lastLabel:o.firstLabel);$('.x_last',ui.pageLinks).html(value?o.firstLabel:o.lastLabel);},toggle:function(visible){this.element.toggle(visible);},paginationVisible:function(){return this.options.singleVisible||(this.options.pageCount>1&&false===this.options.singleVisible);}}));$.xw.repeater.defaults={'pageIndex':1,'pageSize':10,'onDataBound':null};$.widget("xw.commentsSource",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},initSource:function(repeater,content){var w$=this,o=this.options,r$=repeater.element,sort=$('<a href="#" class="x_dir"></a>').css({'background-color':r$.css('border-top-color'),'color':content.children('h2').css('color')}),children=content.children(),ui={buttons:content.find('.clientComments-cmd button'),title:content.children('h2').find('span'),titleLink:content.children('a').eq(0),addRow:content.find('.xw-textField'),items:content.children('.xw-repeater-items'),status:content.children('.clientComments-status'),closed:content.children('.clientComments-closed'),optPanel:$('<div class="clientComments_options" />').hide().append(sort).appendTo(r$),sort:sort};o.ui=ui;o.rw=ui.addRow.width();ui.addRow.find('textarea').width(o.rw*0.8);w$.element.bind('resize',function(){ui.optPanel.css('bottom',r$.outerHeight());});content.find('.clientComments-cmd').css('padding-right',(o.rw*0.2)-ui.buttons.outerWidth());r$.hover(function(){if(w$._canReSort()){ui.optPanel.stop(true,true).slideDown(500);}},function(){ui.optPanel.stop(true,true).slideUp(500);});ui.sort.klick(function(){o.sortBy=o.sortBy==0?1:0;w$._setSort();repeater.swapLabels(o.sortBy==0?true:false);w$.$remote('SetSettingById',{'id':7,'value':o.sortBy});o.repeater.loadPage(1);});w$._setSort();o.repeater=repeater;o.collapsable=o.lastVisible;if(!o.canAdd){ui.addRow.hide();ui.buttons.hide();ui.closed.show();}
if(o.collapsable){ui.titleLink.click(function(){if(o.collapsed){o.collapsed=false;ui.titleLink.html(o.messages['-TitleLink']).swapClass('x_down','x_up');ui.title.html(o.messages['-Title']);if(!o.addVisible){ui.addRow.toggle(o.canAdd);ui.buttons.toggle(o.canAdd);}
ui.addRow.find('.ShadowText').each(function(){$(this).triggerHandler('show')});w$.itemsVisible();repeater.paginationVisible()&&repeater.options.ui.page.show();r$.triggerHandler('mouseover');}else{o.collapsed=true;ui.titleLink.html((o.totalCount>1)?$.xw.replace(o.messages['+TitleLink'],{'count':o.totalCount}):o.messages['+TitleLink01']).swapClass('x_up','x_down');ui.title.html(o.messages['+Title']);if(!o.addVisible){ui.addRow.hide();ui.buttons.hide();}
w$.itemsVisible();repeater.paginationVisible()&&repeater.options.ui.page.hide();r$.triggerHandler('mouseout');}
w$.element.trigger('resize');ui.status.html('').hide();});}
ui.buttons.click(function(){ui.status.html('').hide();content.busy();$.xw.auth.logIn(function(){if($.xw.valid(w$.element[0].id)){w$.$remote('AddComment',{'assetId':o.assetId,'comment':ui.addRow.textField('text'),'type':o.assetType},function(result){if(result.Success){ui.status.removeClass('clientComments-error').html(o.messages['Added']).show();ui.addRow.textField('text','');repeater.loadPage(1);}else{ui.status.addClass('clientComments-error').html(o.messages[(result.Reason=='AddLimit')?'AddLimit':'AddFail']).show();content.busy(false);};},w$.remoteError);};},function(){content.busy(false);});});},itemsVisible:function(){var o=this.options,ui=o.ui;ui.items.children().each(function(i){var isLast=$(this).hasClass('x_last');$(this).showSwitch((o.collapsed&&isLast)||(!o.collapsed&&!isLast));});},remoteError:function(err){var serverError=null;try{eval('serverError = '+err.responseText);}catch(e){}
if(serverError!=null&&serverError.ExceptionType==="System.Security.SecurityException")
this.options.ui.status.addClass('clientComments-error').html(this.options.messages['Activate']).show();else
this.options.ui.status.addClass('clientComments-error').html(this.options.messages['Unexpected']).show();},open:function(options){var o=$.extend(this.options,options),ui=o.ui;this.options=o;if(!o.addVisible){ui.addRow.toggle(o.canAdd);ui.buttons.toggle(o.canAdd);ui.closed.toggle(!o.canAdd);}
ui.status.html('').hide();ui.addRow.textField('text','');o.repeater.loadPage(1);},data:function(options,callback,errorBack){var o=this.options,options=$.extend({'pageIndex':1,'pageSize':10},options);$.xw.status.remove($.xw.status.INFO,this);$.xw.status.remove($.xw.status.ERROR,this);this.$remote('GetComments',{'assetId':o.assetId,'pageIndex':options.pageIndex,'pageSize':options.pageSize,'direction':o.sortBy},function(data){o.source=data;callback((data.rows.length==0)?null:data);},errorBack);},_canReSort:function(){var o=this.options;return o.totalCount>1&&(!o.collapsable||(o.collapsable&&!o.collapsed));},_setSort:function(){var o=this.options;o.ui.sort.html(o.sortBy==0?o.messages['OldToNew']:o.messages['NewToOld']);},databind:function(repeater,content,data){this.options.ui.items.find('.x_desc a').each(function(){$.xw.tip.remove($(this));});},databound:function(repeater,content,data){var w$=this,o=this.options,ui=o.ui;o.totalCount=data.totalCount;if(o.collapsable&&ui.titleLink.contents().length===0){if(data.totalCount>1){ui.titleLink.html($.xw.replace(o.messages['+TitleLink'],{'count':data.totalCount}));}else if(o.addVisible){ui.titleLink.hide();}else{ui.titleLink.html(o.messages['+TitleLink01']);}
ui.title.html(o.collapsed?o.messages['+Title']:o.messages['-Title']);o.collapsed=!o.collapsed;ui.titleLink.triggerHandler('click');}else{this.itemsVisible();}
$('div',ui.items).each(function(i,el){var c=data.last?(i==0?data.last:data.rows[i-1]):data.rows[i],url=$.xw.replace(o.profileUrl,{'name':c.userName});$('.x_label a',this).attr('href',url);$('.x_roField',this).width(o.rw*0.8);$('.x_roField label',this).append($.xw.replace(o.leadIn,{'name':c.userName,'created':c.created})).find('a').attr({'href':url,'target':'_blank'}).ellipses(120);var canRemove=(c.userName===$.xw.auth.user||$.xw.auth.user===o.assetOwner);$('.x_desc a',this).click(function(){content.busy();$.xw.auth.logIn(function(){w$.$remote('RemoveCommentRequest',{'commentId':c.id,'assetOwner':o.assetOwner},function(removed){if(removed){ui.status.css('color','green').removeClass('clientComments-error').html(o.messages['Removed']).show();}else{ui.status.css('color','green').removeClass('clientComments-error').html(o.messages['Requested']).show();};repeater.loadPage();},function(err){content.busy(false);w$.remoteError(err);});});}).children().eq(0).attr('src',canRemove?o.trashGif:o.flagGif);$.xw.tip.add({'trigger':$('.x_desc a',this),'content':canRemove?o.messages['TipRemove']:o.messages['TipRequest'],'cssClass':'','delay':300});});w$.element.trigger('resize');}}));$.widget("xw.friendRequestSource",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},initSource:function(repeater,content){var widget=this,o=this.options,ui={items:content.children('.xw-repeater-items')};this.options.ui=ui;},data:function(options,callback,errorBack){var o=this.options,options=$.extend({'pageIndex':1,'pageSize':10},options);$.xw.status.remove($.xw.status.INFO,this);$.xw.status.remove($.xw.status.ERROR,this);this.$remote('GetFriendRequests',{'pageIndex':options.pageIndex,'pageSize':options.pageSize},function(data){o.source=data;callback((data.rows.length==0)?null:data);},errorBack);},databind:function(repeater,content,data){},databound:function(repeater,content,data){var widget=this,o=this.options,ui=this.options.ui;o.totalCount=data.totalCount;content.find('.xw-repeater-items').children().each(function(i,el){var links=$(el).find('a'),value=data.rows[i];$(el).find('img').attr('src',$.xw.replace(o.portraitUrl,value.portraitId));links.eq(1).click(function(){$.xw.auth.logIn(function(){widget.$remote('AcceptFriend',{'userId':value.id},function(){repeater.loadPage();$.xw.refresh(['auth']);},function(err){});});});links.eq(2).click(function(){$.xw.auth.logIn(function(){widget.$remote('RejectFriend',{'userId':value.id},function(){repeater.loadPage();$.xw.refresh(['auth']);},function(err){});});});});}}));$.widget("xw.friendsSource",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},initSource:function(repeater,content){var widget=this,o=this.options,children=content.children(),ui={items:content.children('.xw-repeater-items'),sortBy:$('.xw-friendsView-sort')};ui.sortBy.bind('change',function(){var el=$(this);$.xw.auth.logIn(function(){var value=el.val().split(' ');o.orderBy=value[0];o.orderByAsc=(value[1].toLowerCase()==='asc')?true:false;repeater.loadPage(1);});});this.options.ui=ui;},data:function(options,callback,errorBack){var o=this.options,options=$.extend({'pageIndex':1,'pageSize':10},options);$.xw.status.remove($.xw.status.INFO,this);$.xw.status.remove($.xw.status.ERROR,this);this.$remote('GetFriendsPage',{'orderBy':o.orderBy,'orderByAsc':o.orderByAsc,'pageIndex':options.pageIndex,'pageSize':options.pageSize},function(data){o.source=data;callback((data.rows.length==0)?null:data);},errorBack);},databind:function(repeater,content,data){if(data&&data.rows&&data.rows.length>0){var len=data.rows.length;var pad=(len%4==0)?0:4-(len%4);for(var i=len;i<len+pad;i++)
data.rows[i]=null;}},databound:function(repeater,content,data){var widget=this,o=this.options,t=o.templates,ui=this.options.ui;o.totalCount=data.totalCount;content.find('.xw-friendsView-list').each(function(i,el){var value=data.rows[i];function li(ul,label,labelArg,link,linkArg,click){var a=(link)?$('<a href="'+$.xw.replace(link,linkArg)+'">'+$.xw.replace(label,labelArg)+'</a>'):null;ul.append($('<li></li>').append(a||$.xw.replace(label,labelArg)));click&&a.bind('click',click);}
li($(el),t.profile,'',t.profileUrl,value.name);li($(el),t.photos,value.pc,(value.pc>0)?t.photosUrl:null,value.name);li($(el),t.movies,value.mc,(value.mc>0)?t.moviesUrl:null,value.name);li($(el),t.blog,value.bc,(value.bc>0)?t.blogUrl:null,value.name);li($(el),t.pm,'','javascript:void(0)','',function(){$.xw.message.open({'toEnable':false,'to':value.name});});li($(el),value.wl?t.removeWl:t.addWl,'','javascript:void(0)','',function(){if(value.wl)
widget.$remote('RemoveFromWatchlist',{'friendId':value.id},function(){repeater.loadPage();},function(err){});else
widget.$remote('AddToWatchlist',{'friendId':value.id},function(){repeater.loadPage();},function(err){});});li($(el),t.remove,'','javascript:void(0)','',function(){if(confirm(t.removeFriend)){widget.$remote('RemoveFriend',{'friendId':value.id},function(){repeater.loadPage();},function(err){});}});});}}));$.xw.friendsSource.defaults={'orderBy':'FriendName','orderByAsc':true};$.widget("xw.messagesSource",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();this.options.orders=new Array();},initSource:function(repeater,content){var widget=this,o=this.options,showFrom=(o.folder!=='SentItems'),showTo=(o.folder==='Trash'||o.folder==='SentItems'),ui={buttons:content.find('.x_commands button'),th:{allInput:content.find('tr > th:nth-child(1) input'),orderByAs:content.find('tr > th a'),fromTd:content.find('tr > th:nth-child(3)'),toTd:content.find('tr > th:nth-child(4)'),attachImg:content.find('tr > th:nth-child(6) img')}};content.find('.x_commands a').click(function(){$('.xw-messageProxy').messageProxy('newMessage');});$.xw.tip.add({'trigger':ui.buttons.eq(0),'content':o.tipDelete,'cssClass':'','delay':300});var src=ui.th.attachImg.attr('src');o.imgFolder=src.substr(0,src.lastIndexOf('/')+1);ui.buttons.eq(0).click(function(){var ids=new Array(),data=o.source;content.find('tr > td:nth-child(1) input').each(function(i,el){(el.checked&&(ids[ids.length]=data.rows[i].id));});if(ids.length===0){$.xw.status.add($.xw.status.ERROR,widget,o.messageNotSelected);return;};widget.$remote('DeleteMessages',{'ids':ids.join(',')},function(){$.xw.refresh(['messages']);var msg=(o.folder==='Trash')?o[(ids.length>1)?'messagesTrashed':'messageTrashed']:o[(ids.length>1)?'messagesDeleted':'messageDeleted'];$.xw.status.add($.xw.status.INFO,widget,msg);});});switch(o.folder){case'Inbox':ui.buttons.eq(1).click(function(){var ids=new Array(),data=o.source;content.find('tr > td:nth-child(1) input').each(function(i,el){(el.checked&&(ids[ids.length]=data.rows[i].id));});if(ids.length===0){$.xw.status.add($.xw.status.ERROR,widget,o.messageNotSelected);return;};widget.$remote('MoveMessages',{'ids':ids.join(',')},function(){$.xw.refresh(['messages']);$.xw.status.add($.xw.status.INFO,widget,o[(ids.length>1)?'messagesMoved':'messageMoved']);});});ui.buttons.eq(2).hide();break;case'SentItems':ui.buttons.eq(1).hide();ui.buttons.eq(2).hide();break;case'SavedItems':ui.buttons.eq(1).hide();ui.buttons.eq(2).hide();break;case'Trash':ui.buttons.eq(1).hide();ui.buttons.eq(2).click(function(){var ids=new Array(),data=o.source;if(ids.length===0){$.xw.status.add($.xw.status.ERROR,widget,o.messageNotSelected);return;};content.find('tr > td:nth-child(1) input').each(function(i,el){(el.checked&&(ids[ids.length]=data.rows[i].id));});widget.$remote('RestoreMessages',{'ids':ids.join(',')},function(){$.xw.refresh(['messages']);$.xw.status.add($.xw.status.INFO,widget,o[(ids.length>1)?'messagesRestored':'messageRestored']);});});break;};ui.th.allInput.click(function(){var state=this.checked;content.find('tr > td:nth-child(1) input').each(function(i,el){el.checked=state;});});ui.th.fromTd[showFrom?'show':'hide']();ui.th.toTd[showTo?'show':'hide']();ui.th.orderByAs.each(function(i,el){$(el).click(function(){var orderBy=$(this).attr('data');o.orders[orderBy]=(o.orders[orderBy]&&o.orders[orderBy]==='Asc')?'Desc':'Asc';o.orderBy=orderBy;o.orderByDirection=o.orders[orderBy];repeater.loadPage();});});},data:function(options,callback,errorBack){var o=this.options,options=$.extend({'pageIndex':1,'pageSize':10},options);$.xw.status.remove($.xw.status.INFO,this);$.xw.status.remove($.xw.status.ERROR,this);this.$remote('GetMessages',{'folder':o.folder,'orderBy':o.orderBy,'orderByDirection':o.orderByDirection,'pageIndex':options.pageIndex,'pageSize':options.pageSize},function(data){o.source=data;callback((data.rows.length==0)?null:data);},errorBack);},databound:function(repeater,content,data){var widget=this,o=this.options,showFrom=(o.folder!=='SentItems'),showTo=(o.folder==='Trash'||o.folder==='SentItems'),tdMethods=[function(td,data){td.find('input').change(function(){$.xw.status.remove($.xw.status.ERROR,widget);});},function(td,data){td.find('a').click(function(){$('.xw-messageProxy').messageProxy('readMessage',{'messageId':data.id});var tr=td.parent();(tr.hasClass('x_unread')&&tr.removeClass('x_unread').addClass('x_read'));});},function(td,data){td.find('img').attr('src',(data.isOnline)?o.onlineUrl:o.offlineUrl);},function(td,data){if(showFrom){if(data.fromVersionId){var src=$.xw.image.getUrl({'upload':'3','id':data.fromVersionId,'key':'Tiny','missingKey':''});td.prepend($('<img />').attr('src',src).css({'vertical-align':'middle','padding-right':5}));};td.click(function(){$('.xw-messageProxy').messageProxy('readMessage',{'messageId':data.id});var tr=td.parent();(tr.hasClass('x_unread')&&tr.removeClass('x_unread').addClass('x_read'));}).show();}
else
td.hide();},function(td,data){if(showTo){if(data.toVersionId){var src=$.xw.image.getUrl({'upload':'3','id':data.toVersionId,'key':'Tiny','missingKey':''});td.prepend($('<img />').attr('src',src).css({'vertical-align':'middle','padding-right':5}));};td.click(function(){$('.xw-messageProxy').messageProxy('readMessage',{'messageId':data.id});var tr=td.parent();(tr.hasClass('x_unread')&&tr.removeClass('x_unread').addClass('x_read'));}).show();}else
td.hide();},null,function(td,data){data.attachment&&td.append($('<img />').attr('src',o.imgFolder+'iconAttachment.gif'));},function(td,data){td.css('cursor','pointer');td.click(function(){$('.xw-messageProxy').messageProxy('readMessage',{'messageId':data.id});var tr=td.parent();(tr.hasClass('x_unread')&&tr.removeClass('x_unread').addClass('x_read'));});}];content.find('tbody tr').each(function(i,tr){var row=data.rows[i],$tr=$(tr);$tr.find('td').each(function(i,td){(tdMethods[i]&&tdMethods[i]($(td),row));});});}}));$.widget("xw.referralsSource",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},initSource:function(repeater,content){var widget=this,o=this.options,children=content.children(),tfoot=content.find('tfoot'),thead=content.find('thead'),ui={items:content.children('.xw-repeater-items'),titleLinks:thead.find('tr th a'),titles:{url:thead.find('tr > th:nth-child(1) a'),sid:thead.find('tr > th:nth-child(2) a'),clicks:thead.find('tr > th:nth-child(3) a'),joined:thead.find('tr > th:nth-child(4) a'),ratio:thead.find('tr > th:nth-child(5) a'),points:thead.find('tr > th:nth-child(6) a')},totals:{clicks:tfoot.find('tr > td:nth-child(3)'),joined:tfoot.find('tr > td:nth-child(4)'),ratio:tfoot.find('tr > td:nth-child(5)'),points:tfoot.find('tr > td:nth-child(6)')}};this.options.ui=ui;ui.titleLinks.click(function(){var column=$(this).attr('data');if(o.orderBy==column)
o.orderByAsc=!o.orderByAsc;else{o.orderBy=column;o.orderByAsc=true;}
repeater.loadPage();});},data:function(options,callback,errorBack){var o=this.options,options=$.extend({'pageIndex':1,'pageSize':10},options);$.xw.status.remove($.xw.status.INFO,this);$.xw.status.remove($.xw.status.ERROR,this);this.$remote('GetReferralSummaryPage',{'orderBy':o.orderBy,'orderByAsc':o.orderByAsc,'thenBy':o.thenBy,'thenByAsc':o.thenByAsc,'pageIndex':options.pageIndex,'pageSize':options.pageSize},function(data){o.source=data;callback((data.rows.length==0)?null:data);},errorBack);},databind:function(repeater,content,data){},databound:function(repeater,content,data){var widget=this,o=this.options,ui=this.options.ui;o.totalCount=data.totalCount;ui.totals.clicks.html(data.clicks);ui.totals.joined.html(data.joined);ui.totals.ratio.html('1:'+data.ratio);ui.totals.points.html(data.points);}}));$.xw.referralsSource.defaults={'orderBy':'SourceHost','orderByAsc':true,'thenBy':'SourceId','thenByAsc':true};$.widget("xw.wlSource",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},initSource:function(repeater,content){var widget=this,o=this.options,children=content.children(),thead=content.find('thead'),ui={items:content.children('.xw-repeater-items'),titleLinks:thead.find('tr th a'),titles:{name:thead.find('tr > th:nth-child(1) a'),joined:thead.find('tr > th:nth-child(2) a'),login:thead.find('tr > th:nth-child(3) a'),pc:thead.find('tr > th:nth-child(4) a'),mc:thead.find('tr > th:nth-child(5) a'),bc:thead.find('tr > th:nth-child(6) a'),fc:thead.find('tr > th:nth-child(6) a')},viewBy:$('.xw-watchlist-view')};ui.viewBy.bind('change',function(){$.xw.auth.logIn(function(){repeater.loadPage(1);});});this.options.ui=ui;ui.titleLinks.click(function(){var el=$(this);$.xw.auth.logIn(function(){var column=el.attr('data');if(o.orderBy==column)
o.orderByAsc=!o.orderByAsc;else{o.orderBy=column;o.orderByAsc=true;}
repeater.loadPage();});});},data:function(options,callback,errorBack){var widget=this,o=this.options,ui=this.options.ui,options=$.extend({'pageIndex':1,'pageSize':10},options);$.xw.status.remove($.xw.status.ERROR,widget);this.$remote('GetWatchlistPage',{'period':ui.viewBy.val(),'orderBy':o.orderBy,'orderByAsc':o.orderByAsc,'pageIndex':options.pageIndex,'pageSize':options.pageSize},function(data){o.source=data;callback((data.rows.length==0)?null:data);},function(err){$.xw.status.add($.xw.status.ERROR,widget,o.messageError);errorBack.apply(widget,[err]);});},databind:function(repeater,content,data){},databound:function(repeater,content,data){var widget=this,o=this.options,t=o.templates,ui=this.options.ui;o.totalCount=data.totalCount;content.find('.xw-repeater-items').children().each(function(i,el){var tds=$(el).children(),value=data.rows[i];tds.eq(0).find('span').ellipses(120);function anchor(td,label,labelArg,link,linkArg,click){var a=(link)?$('<a href="'+$.xw.replace(link,linkArg)+'">'+$.xw.replace(label,labelArg)+'</a>'):null;td.append(a||$.xw.replace(label,labelArg));click&&a.bind('click',click);};anchor(tds.eq(3),(value.pc>0)?t.photos:t.none,value.pc,(value.pc>0)?t.photosUrl:null,value.name);anchor(tds.eq(4),(value.mc>0)?t.movies:t.none,value.mc,(value.mc>0)?t.moviesUrl:null,value.name);anchor(tds.eq(5),(value.bc>0)?t.blog:t.none,value.bc,(value.bc>0)?t.blogUrl:null,value.name);anchor(tds.eq(6),(value.fc>0)?t.forum:t.none,value.fc,(value.fc>0)?t.forumUrl:null,value.forumReq);anchor(tds.eq(7),t.remove,'','javascript:void(0)','',function(){widget.$remote('RemoveFromWatchlist',{'friendId':value.id},function(){repeater.loadPage();},function(err){});});});}}));$.xw.wlSource.defaults={'orderBy':'FriendName','orderByAsc':true};})(jQuery);﻿
(function($){$.widget("xw.blogSummary",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var boxes=$('.BoxB',this.element),b1=boxes.eq(0),b2=boxes.eq(1),b3=boxes.eq(2),width=this.element.width(),widths=$.map(boxes,function(n,i){return $(n).width();}),moreLink=b3.find('.xw-blogSummary-more'),backLink=b3.find('.xw-blogSummary-back');moreLink.click(function(){b1.animate({width:'0'},{'complete':function(){$(this).hide();}});b2.animate({width:'0'},{'step':function(){b3.css('width',width-b3.position().left-10);},'complete':function(){$(this).hide();b3.css('width',width);}});$(this).hide();backLink.show();});backLink.click(function(){var shown=false;b3.animate({width:widths[2]},{'step':function(){var w=Math.max(0,parseInt((width-b3.width())/2));if(w>20&&!shown){b1.show();b2.show();shown=true;}
b1.css('width',w-10);b2.css('width',w-10);},'complete':function(){b1.width(widths[0]);b2.width(widths[1]);}});$(this).hide();moreLink.show();});}}));$.widget("xw.friendRequest",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options,$box=this.element.parents('.xw-actionBox'),ui={actionBox:this.element.parents('.xw-actionBox'),name:this.$get('idMemberName'),submit:this.$get('idGo')};this.options.ui=ui;ui.submit.click(function(){$.xw.auth.logIn(function(){if($.xw.valid('FriendRequest')){var name=ui.name.textField('text');ui.actionBox.length&&ui.actionBox.actionBox('busy');widget.$remote('MakeFriendRequest',{'name':name},function(status){var msgLabel;switch(status){case 3:msgLabel='friendsalready';break;case 4:msgLabel='nowfriends';break;default:msgLabel='success';break;}
$('#'+o.infoId).statusMessages('add',widget,$.xw.replace(o.messages[msgLabel],name));ui.name.textField('text','');ui.actionBox.length&&ui.actionBox.actionBox('busy',false);ui.actionBox.length&&$('.xw-friendRequest-input').hide();},function(err){var serverError=null,vLabel='VerifyEmail:';try{eval('serverError = '+err.responseText);}catch(e){}
if(serverError!=null&&serverError.ExceptionType==="System.ArgumentException")
$('#'+o.errorId).statusMessages('add',widget,o.messages['notfound']);else if(serverError!=null&&serverError.Message.substr(0,vLabel.length)==vLabel)
$('#'+o.errorId).statusMessages('add',widget,o.messages['notverified']);else
$('#'+o.errorId).statusMessages('add',widget,o.messages['failed']);ui.actionBox.length&&ui.actionBox.actionBox('busy',false);ui.actionBox.length&&$('.xw-friendRequest-input').hide();});};});});ui.actionBox.length&&ui.actionBox.actionBox('opening',function(e,openArgs){$('#'+o.errorId).statusMessages('remove',widget);$('#'+o.infoId).statusMessages('remove',widget);$('.xw-friendRequest-input').show();ui.name.textField('text',openArgs.options.name);});},load:function(){var widget=this,o=this.options,ui=this.options.ui;ui.name.textField('changed',function(){$('#'+o.errorId).statusMessages('remove',widget);$('#'+o.infoId).statusMessages('remove',widget);});}}));$.xw.friendRequest.defaults={};$.widget("xw.friendRequestProxy",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},add:function(name){$('#'+this.options.actionId).actionBox('open',{'name':name});}}));$.widget("xw.loginProxy",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},loggedIn:function(onLogin,onCancel){if(this.isLoggedIn())
return true;$('#'+this.options.actionId).actionBox('open',{'onSuccess':onLogin,'onFail':onCancel});return false;},logIn:function(onSuccess,onFail,deferCallback){if(this.isLoggedIn())
onSuccess();else{deferCallback&&deferCallback();$('#'+this.options.actionId).actionBox('open',{'onSuccess':onSuccess,'onFail':onFail});}},isLoggedIn:function(){var loggedIn=false;this.$remote('IsLoggedIn',null,function(value){loggedIn=value!==null;$.xw.auth.userId=loggedIn?value.id:null;$.xw.auth.user=loggedIn?value.nm:'';},null,true)
return loggedIn;}}));$.xw.loginProxy.getter='loggedIn isLoggedIn';$.widget("xw.loginBox",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options,$e=this.element,ui={$err:this.$get('idErrors'),$user:this.$get('idUsername'),$pwd:this.$get('idPassword'),$actionBox:this.element.parents('.xw-actionBox'),$login:this.$get('idLogin')};this.options.ui=ui;$e.bind('keyup',function(e){(e.keyCode===13&&ui.$login.triggerHandler('click'));});ui.$login.click(function(){if($.xw.valid('LoginBox')){var user=ui.$user.textField('text'),password=ui.$pwd.textField('text');ui.$actionBox.actionBox('busy');widget.$remote('EnhancedLogin',{'userName':user,'password':password,'createPersistentCookie':false},function(result){ui.$actionBox.actionBox('busy',false);switch(result.Status){case 0:$.xw.auth.user=result.Name;$.xw.auth.userId=result.Id;ui.$actionBox.actionBox('close');o.passed=true;(o.success&&o.success());o.success=null;$.xw.refresh(['auth']);break;case 1:ui.$err.statusMessages('add',this,o.badInactive);break;case 2:ui.$err.statusMessages('add',this,o.badLocked);break;case 3:ui.$err.statusMessages('add',this,o.badNotFound);break;case 4:ui.$err.statusMessages('add',this,o.badSuspend);break;default:ui.$err.statusMessages('add',this,o.badPassword);break;}},function(err){ui.$actionBox.actionBox('busy',false);});};});this.$get('idCancel').click(function(){ui.$actionBox.actionBox('close');(o.fail&&o.fail());});},load:function(){var widget=this,o=this.options,ui=this.options.ui;ui.$user.textField('option','onValidate',function(e,args){if($.trim(this.text()).indexOf(',')>0){args.fail(o.badSyntax);}});ui.$actionBox.actionBox('opening',function(e,openArgs){o.passed=false;o.success=openArgs.options.onSuccess;o.fail=openArgs.options.onFail;ui.$err.statusMessages('remove',widget);ui.$user.textField('text','')
ui.$pwd.textField('text','');});ui.$actionBox.actionBox('option','close',function(){(!o.passed&&o.fail&&o.fail());o.fail=null;});}}));$.widget("xw.inlineLogin",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options,ui={anon:{panel:$('.xw-inlineLogin-anon',this.element),user:$('input[type="text"]',this.element),pwd:$('input[type="password"]',this.element),login:this.$get('idLoginButton'),forgot:$('.xw-inlineLogin-forgot',this.element)},member:{panel:$('.xw-inlineLogin-member',this.element),welcome:$('.xw-inlineLogin-member > div:eq(0)',this.element),messages:$('.xw-inlineLogin-member > div:eq(1)',this.element),logout:this.$get('logout')},error:this.$get('idError')};o.welcome=ui.member.welcome.html();ui.anon.panel.length&&ui.error.visible()&&ui.anon.forgot.hide();ui.anon.user.bind('keypress',pressHandler);ui.anon.pwd.bind('keydown',loginHandler).bind('keypress',pressHandler);ui.anon.login.bind('click',loginHandler);ui.member.logout.attr('href',o.logoutPb);this.options.ui=ui;function pressHandler(e){ui.error.hide();ui.anon.forgot.show();};function loginHandler(e){var goodKey=typeof(e.keyCode)==='undefined'||e.keyCode===0||e.keyCode===13;if(goodKey&&supplied(ui.anon.user,o.errorUserMissing)&&userValid()&&supplied(ui.anon.pwd,o.errorPasswordMissing)){eval(o.loginPb);e.preventDefault();return false;}};function supplied($el,msg){if($.trim($el.val())===''){ui.error.html(msg).show();ui.anon.forgot.hide();return false;}
return true;};function userValid(){if(ui.anon.user.val().indexOf(',')>=0){ui.error.html(o.badSyntax).show();ui.anon.forgot.hide();return false;}
return true;}
this.element.bind('refresh.inlineLogin',function(e,types){((types==null||$.inArray('auth',types)>=0)&&widget._poll());});ui.anon.user.selectOnFocus();ui.anon.pwd.selectOnFocus();},_poll:function(){var w$=this,o=this.options,ui=o.ui;$.xw.poll.polling('register',$.xw.polling.LOGIN,function(status){var o=w$.options,ui=o.ui,poll;if(w$._changed(o.lastStatus,status)){if(status.l){var msg;switch(status.ur){case 0:msg=$.xw.replace(o.messages,{"messageLabel":o.noMessages});break;case 1:msg=$.xw.replace(o.messages,{"messageLabel":o.newMessage});break;default:msg=$.xw.replace(o.messages,{"messageLabel":$.xw.replace(o.newMessages,{'count':status.ur})});break;};if(status.r&&status.r>0){msg+=(status.r==1)?o.friendRequest:$.xw.replace(o.friendRequests,{'count':status.r});};ui.member.messages.html(msg);ui.member.messages.find('a').eq(0).attr('href',o.inboxUrl);ui.member.messages.find('.x_mail').click(function(){location.href=o.inboxUrl;});ui.member.messages.find('a').eq(1).attr('href',o.friendUrl);var user=$('<span />').append($('<span class="x_user" />').text(status.u)).html();ui.member.welcome.html($.xw.replace(o.welcome,{'username':user})).show().find('.x_user').ellipses(o.userWidth);w$.element.removeClass('xw-inlineLogin-out').addClass('xw-inlineLogin-in');ui.anon.panel.hide();ui.member.panel.show();}else{$.xw.auth.user=null;$.xw.auth.userId=null;w$.element.removeClass('xw-inlineLogin-in').addClass('xw-inlineLogin-out');ui.anon.panel.show();ui.member.panel.hide();ui.anon.panel.find('.ShadowText').each(function(){$(this).triggerHandler('show')});};if(o.pollWindow>0&&o.fastPoll>0){var now=new Date();o.fastPollUntil=now.setSeconds(now.getSeconds()+o.pollWindow);}
poll=1000*((status.l)?((o.fastPoll>0)?o.fastPoll:o.slowPoll):o.anonPoll);}else{poll=1000*((status.l)?(((new Date()).valueOf()>o.fastPollUntil)?o.slowPoll:o.fastPoll):o.anonPoll);}
if(status.t&&status.t.length>0){w$.$remote('GetNotice',{'triggerId':status.t[0]},function(data){$.xw.proxy('noticeProxy','open',{'html':data.html,'event':'OnLogin','label':data.label});});}
o.lastStatus=status;return poll;},100);},load:function(){var o=this.options,ui=this.options.ui;this._poll();window.setTimeout(function(){ui.anon.user.shadowText(o.userShadow);ui.anon.pwd.shadowText(o.pwdShadow);},500);},_changed:function(s1,s2){if(typeof s1=='undefined'&&typeof s2!='undefined')return true;if(typeof s2=='undefined'&&typeof s1!='undefined')return true;if(s1.l!=s2.l)return true;if(s1.l){if(s1.ur!=s2.ur)return true;if(s1.r!=s2.r)return true;}
return false;}}));$.widget("xw.memberBasic",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},load:function(){var $e=this.element;$('#'+this.options.countryListId).selectField('changed',function(e,args){$e.triggerHandler('countryChanged',args);});},valid:function(){return $.xw.valid(this.options.validationGroup);},countryChanged:function(handler){this.element.bind('countryChanged',handler);},countryValue:function(){return $('#'+this.options.countryListId).selectField('selectedValue');}}));$.xw.memberBasic.getter='countryValue valid';$.widget("xw.memberSettings",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this;this.options.getProvincesOptions={'list':this.$get('idProvince'),'method':'GetProvinces','args':{'country':null},'defaultValue':this.options.province,'results':function(){if(arguments.length>0)widget.options.pData=arguments[0];else return widget.options.pData;}};this.options.getCitiesOptions={'list':this.$get('idCity'),'method':'GetCities','args':{'provinceItemId':null},'defaultValue':this.options.city,'results':function(){if(arguments.length>0)widget.options.cData=arguments[0];else return widget.options.cData;}};},load:function(){var widget=this,plugin=$('#'+this.options.detailsId),pOptions=widget.options.getProvincesOptions;pOptions.list.clientSelectField('changed',function(e,args){var pOptions=widget.options.getProvincesOptions;var cOptions=$.extend(widget.options.getCitiesOptions,{args:(args.index>0)?{'provinceItemId':pOptions.results()[args.index-1].ItemId}:null});widget._loadList(cOptions);});plugin.memberBasic('countryChanged',function(e,args){pOptions.args.country=args.value;widget._loadList.call(widget,pOptions);});pOptions.args.country=plugin.memberBasic('countryValue');widget._loadList(pOptions);},valid:function(){return $.xw.valid(this.options.validationGroup);},_loadList:function(options){var widget=this;options.list.clientSelectField('disable');options.list.clientSelectField('clear');if(options.args===null){options.list.clientSelectField('add',widget.options.resources.MemberSettings_List_NA,'');return;}
options.list.clientSelectField('add',widget.options.resources.MemberSettings_List_Loading,'');this.$remote(options.method,options.args,function(data){var resources=widget.options.resources;options.results(data);options.list.clientSelectField('clear');options.list.remoteData=data;if(data.length===0)
options.list.clientSelectField('add',resources.MemberSettings_List_NA,'');else{options.list.clientSelectField('add',resources.MemberSettings_List_PleaseChoose,'');var index=0;for(var i=0;i<data.length;i++){if(data[i].Value===options.defaultValue)
index=i+1;options.list.clientSelectField('add',data[i].Text,data[i].Value);}
options.list.clientSelectField('selectedIndex',index);options.list.clientSelectField('enable');}
options.list.triggerHandler('changed');});}}));$.xw.memberSettings.getter='valid';$.widget("xw.messageBox",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var panels=$('div.xw-messageBox > div',this.element.parent()).hide(),widget=this,o=this.options,$box=this.element.parents('.xw-actionBox'),ui={$actionBox:$box,$content:$box.find('div:eq(0)'),$err:panels.eq(0),attach:this.$get('attach'),compose:{panel:panels.eq(1),intro:panels.eq(1).find('.xw-messageBox-intro'),to:this.$get('idNewTo'),subject:this.$get('idNewSubject'),upload:this.$get('idUpload'),body:this.$get('idNewMessage'),reply:this.$get('reply'),button:{send:this.$get('idNewSend')}},read:{panel:panels.eq(2),intro:panels.eq(2).find('.xw-messageBox-intro'),from:this.$get('idFrom').find('span:eq(0)'),date:this.$get('idDate').find('span:eq(0)'),subject:this.$get('idSubject').find('span:eq(0)'),body:this.$get('idBody').find('span:eq(0)'),button:{cancel:this.$get('idCancel'),move:this.$get('idMove'),del:this.$get('idDelete'),reply:this.$get('idReply')},report:panels.eq(2).find('.xw-messageBox-scam')},done:{panel:panels.eq(3),intro:panels.eq(3).find('.xw-messageBox-intro'),close:this.$get('idDone')},show:function(arg){var out;if($.xw.show(this.compose.panel,arg===this.compose.panel))
out=this.compose;if($.xw.show(this.read.panel,arg===this.read.panel))
out=this.read.panel;if($.xw.show(this.done.panel,arg===this.done.panel))
out=this.done.panel;return out;}};o.ui=ui;ui.read.report.click(function(){$('.xw-reportMemberProxy').reportMemberProxy('open',o.readMessage.From);});o.newTitle=ui.$actionBox.actionBox('title');if(!o.isPremium){ui.attach.find('img').bind('load',function(){ui.attach.find('div').css({'height':$(this).height(),'width':$(this).width()});});}
ui.$actionBox.actionBox('opening',function(e,openArgs){var openWith=$.extend(false,o.openWith,(openArgs&&openArgs.options)?openArgs.options:null);$.xw.status.remove($.xw.status.INFO,widget);ui.$err.statusMessages('clear');if(openWith.mode===$.xw.MessageMode.New){widget.newMessage(openWith);}else{widget.readMessage(openWith);}});function remoteError(err){var ui=this.options.ui;ui.$err.statusMessages('add',this,o.messages['unexpectedError']);ui.$actionBox.actionBox('busy',false);};ui.compose.button.send.click(function(){var ui=widget.options.ui,t=ui.compose.to.textField('text'),s=ui.compose.subject.textField('text'),b=ui.compose.body.textField('text'),fid=(ui.compose.upload.uploadField('isUploaded'))?ui.compose.upload.uploadField('fileId'):null;if($.xw.valid('Message')){ui.$actionBox.actionBox('busy');widget.$remote('SendMessage',{'to':t,'subject':s,'body':b,'attachmentFileId':fid,'replyingToMessageId':null},function(data){if(data.Success)
ui.show(ui.done.panel);else{ui.$err.statusMessages('add',widget,widget.options.messages[data.Message]);ui.show(ui.compose.panel);}
ui.$actionBox.actionBox('busy',false);},remoteError);}});ui.read.button.reply.click(function(){var m=o.readMessage;widget.newMessage({to:m.From,subject:m.Subject,title:m.Subject,replyTo:m});});ui.read.button.del.click(function(){var ui=widget.options.ui,m=o.readMessage;ui.$actionBox.actionBox('busy');widget.$remote('DeleteMessage',{'id':m.MessageId},function(){$.xw.status.add($.xw.status.INFO,widget,o.messages['deleteMessage']);((o.messageChanged)&&o.messageChanged.call(widget));ui.$actionBox.actionBox('close');$.xw.refresh(['messages']);},remoteError);});ui.read.button.move.click(function(){var m=o.readMessage;ui.$actionBox.actionBox('busy');widget.$remote('MoveMessage',{'id':m.MessageId},function(){$.xw.status.add($.xw.status.INFO,widget,o.messages['movedMessage']);((o.messageChanged)&&o.messageChanged.call(widget));ui.$actionBox.actionBox('close');$.xw.refresh(['messages']);},remoteError);});ui.read.button.cancel.click(function(){ui.$actionBox.actionBox('close');});ui.done.close.click(function(){ui.$actionBox.actionBox('close');});},newMessage:function(openWith){var o=this.options,ui=o.ui,view=ui.compose,openWith=$.extend(false,this.options.openWith,openWith);ui.$actionBox.actionBox('title',openWith.title||this.options.newTitle);view.to.textField('text',openWith.to);view.subject.textField('text',openWith.subject);view.body.textField('text',openWith.body);if(openWith.attachId)
view.upload.hide();else{view.upload.uploadField('reset');view.upload.show();}
this._initAttach(openWith.attachId,view.subject);view.intro.html(openWith.intro);view.to.textField(openWith.toEnable?'enable':'disable');view.subject.textField(openWith.subjectEnable?'enable':'disable');view.body.textField(openWith.bodyEnable?'enable':'disable');view.upload.uploadField(openWith.uploadEnable?'enable':'disable');if(openWith.replyTo){ui.compose.reply.find('span:eq(0)').html($.xw.replace(o.replyTitle,openWith.replyTo.From,openWith.replyTo.DateDeliveredString,openWith.replyTo.Subject));ui.compose.reply.find('.bodyField').html(openWith.replyTo.Body);ui.compose.reply.show();}
else
ui.compose.reply.hide();ui.show(view.panel);},readMessage:function(openWith){if(openWith&&openWith.messageId){this.$remote('GetMessage',{'id':openWith.messageId},function(m){var o=this.options,ui=o.ui,b=ui.read.button,view=ui.read;ui.$actionBox.actionBox('title',m.Subject);o.readMessage=m;view.intro.html(openWith.intro);view.from.html(m.From);view.date.html(m.DateDeliveredString);view.subject.html(m.Subject);view.body.html(m.Body);if(m.Suspended){ui.$err.statusMessages('add',this,o.messages['suspended']);}else if(m.Closed){ui.$err.statusMessages('add',this,o.messages['closed']);}
b.move.toggle(!m.DateDeleted&&!m.Suspended&&m.Folder=='Inbox');b.reply.toggle(!m.DateDeleted&&!m.Closed&&(m.Folder=='Inbox'||m.Folder=='SavedItems'));b.del.toggle(m.Folder!='SentItems');this._initAttach(m.VersionIds.length>0?m.VersionIds[0]:null,this.$get('idSubject'));ui.show(view.panel);},function(err){var ui=this.options.ui;ui.$err.statusMessages('add',this,err.responseText);ui.show(ui.read.panel);});}else{alert('readMessage needs a messageId property to be supplied.');}},_initAttach:function(id,$after){var ui=this.options.ui,o=this.options;if(id){ui.attach.find('img').attr('src',o.thumbUriFormat.replace(/\{0\}/g,id));(o.isPremium&&ui.attach.find('a').attr('href',o.origUriFormat.replace(/\{0\}/g,id)));ui.attach.insertAfter($after).show();}else{ui.attach.hide();}}}));$.xw.MessageMode={New:0,Read:1};$.xw.messageBox.defaults={openWith:{attachId:null,body:'',bodyEnable:true,messageId:null,mode:$.xw.MessageMode.New,subject:'',subjectEnable:true,to:'',toEnable:true,uploadEnable:true}};$.widget("xw.messageProxy",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},newMessage:function(options){$.extend(options,{'mode':$.xw.MessageMode.New})
$('#'+this.options.actionId).actionBox('open',options);},readMessage:function(options){$.extend(options,{'mode':$.xw.MessageMode.Read})
$('#'+this.options.actionId).actionBox('open',options);}}));$.widget("xw.moderateItem",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var w$=this,o=this.options,ui={'opened':{'title':this.$get('idTitleRequired').toggle(o.required),'choice':this.$get('idOptions').toggle(o.required)},'closed':{'title':this.$get('idTitleOptions').toggle(!o.required),'deleteBox':this.$get('idDeleteBox').toggle(!o.required)},'reason':this.$get('idReason'),'submit':this.$get('idSubmit'),'forumKeepPlaceholder':this.$get('idPlaceholder')};ui.forumKeepPlaceholder.hide();if(o.clientOnly){ui.submit.attr('href','javascript:void(0)').click(function(){if(o.required&&ui.opened.choice.radioListField('selectedValue')=='Yes'){w$.$remote('ModApprove',{'id':o.assetId,'assetType':o.type},function(changed){if(changed)w$.element.triggerHandler('refresh');},function(err){});}else{w$.$remote('ModDelete',{'id':o.assetId,'assetType':o.type,'reason':ui.reason.selectField('selectedValue')},function(changed){if(changed)w$.element.triggerHandler('refresh');},function(err){});}});}
ui.closed.title.insertBefore(this.element);o.ui=ui;},load:function(){var $e=this.element,o=this.options,ui=o.ui,warning=this.$get('idFirstPostWarning'),firstPost=(warning.length===1);function setDisplay(){var reasonIndex=ui.reason.selectField('selectedIndex')
if(o.required){var selected=ui.opened.choice.radioListField('selected'),value=ui.opened.choice.radioListField('selectedValue'),selectedNo=(selected&&value==='No');ui.reason.toggle(selectedNo);ui.submit.toggle(selected&&((selectedNo&&reasonIndex>0)||!selectedNo));ui.forumKeepPlaceholder.toggle(selectedNo&&reasonIndex>0&&!firstPost);}else{var checked=ui.closed.deleteBox.checkField('selected');ui.reason.toggle(checked);ui.forumKeepPlaceholder.toggle(checked&&reasonIndex>0&&!firstPost);ui.submit.toggle(checked&&reasonIndex>0);}};ui.opened.choice.click(function(){setDisplay();});ui.closed.title.click(function(){$e.slideToggle(300);setDisplay();});ui.closed.deleteBox.click(function(){setDisplay();});if(o.required){ui.opened.choice.triggerHandler('click');}else{this.element.hide();ui.closed.deleteBox.triggerHandler('click');}
ui.reason.selectField('changed',function(e){setDisplay();});ui.submit.bind('click',function(e){if(o.type==='ForumPost'&&firstPost&&!confirm(warning.text())){e.preventDefault();return;};});},change:function(id,required){var o=this.options;o.required=required;o.assetId=id;o.ui.opened.title.toggle(o.required);o.ui.opened.choice.toggle(o.required).find('input').attr('checked',false);o.ui.closed.title.toggle(!o.required);o.ui.closed.deleteBox.toggle(!o.required).find('input').attr('checked',false);o.ui.reason.selectField('selectedIndex',0);this.element.toggle(o.required);if(o.required){o.ui.opened.choice.triggerHandler('click');}else{o.ui.closed.deleteBox.triggerHandler('click');}}}));$.widget("xw.newForumPost",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var self=this,o=this.options,panels=$('.NewForumPost-panel',this.element),ui={error:this.$get('idErrorStatus'),topic:this.$get('idNewTopic'),content:this.$get('idBody'),roTitle:panels.eq(1).find('.x_roField'),roContent:panels.find('.x_body').eq(0)};this.$get('idNewNext').click(function(){ui.error.statusMessages('remove',self);if($.xw.valid('ForumPost')){self.$remote("ForumPostTryParse",{'rawTitle':(o.categoryId>0)?ui.topic.textField('text'):'','rawContent':ui.content.textField('text')},_forumPostTryParse);};});this.$get('idPrevBack').click(function(){panels.eq(0).show();panels.eq(1).hide();});this.$get('idPrevNext').click(function(){var notifyMe=(1===self.$get('idAdvise:checked').length);if(o.categoryId<=0)
self.$remote("SaveForumPost",{'threadId':o.threadId,'rawContent':ui.content.textField('text'),'notifyMe':notifyMe},_saveForumThread);else
self.$remote("SaveForumThread",{'categoryId':o.categoryId,'rawTitle':ui.topic.textField('text'),'rawContent':ui.content.textField('text'),'notifyMe':notifyMe},_saveForumThread);});ui.topic.textField('option','onChanged',function(){ui.error.statusMessages('remove',self);});ui.content.textField('option','onChanged',function(){ui.error.statusMessages('remove',self);});function _forumPostTryParse(data){if(data.Success){ui.roTitle.html((o.topic==null)?data.Title:o.topic);ui.roContent.html(data.Content);panels.eq(0).hide();panels.eq(1).show();}else{ui.error.statusMessages('add',self,data.ContentError.Description);}};function _saveForumThread(data){if(data.Success){panels.eq(1).hide();panels.eq(2).show();}else{ui.error.statusMessages('add',self,data.ContentError.Description);}};}}));$.widget("xw.notice",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var w$=this,o=this.options,e$=this.element,$box=this.element.parents('.xw-actionBox'),ui={actionBox:e$.parents('.xw-actionBox')};o.ui=ui;o.title=ui.actionBox.actionBox('title');ui.actionBox.length&&ui.actionBox.actionBox('opening',function(e,openArgs){var c$=$(openArgs.options.html);var title=c$.find('h1').remove().html();ui.actionBox.actionBox('title',title||o.title);w$.element.html(c$);$.xw.track.event('Notices',openArgs.options.event,openArgs.options.label);});}}));$.widget("xw.noticeProxy",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},open:function(args){$('#'+this.options.actionId).actionBox('open',args);}}));$.widget("xw.polling",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var widget=this,o=this.options;$.xw.poll=this.element;o.timestamp=0;o.pollHandle=null;o.events=[];o.events.getEvents=function(){for(var i=0,b={};i<this.length;i++){if(this[i].interval>0){b[this[i].id]=($.isFunction(this[i].args))?this[i].args():null;}}
return b;};o.events.getInterval=function(){var interval=this[0].interval;for(var i=1;i<this.length;i++){if(this[i].interval>0&&this[i].interval<interval){interval=this[i].interval;}};return interval;};o.events.getById=function(id){for(var i=0;i<this.length;i++)
if(this[i].id==id)
return this[i];return null;};window.setInterval(function(){var ms=o.events.getInterval();if(ms<=0){return;}
var overdue=widget._nowAddMs(-10000);if(o.nextPoll>overdue){return;}
debugger
widget._setupCall();},30000);},register:function(eventId,handler,interval,argsCallBack){var o=this.options,evts=this.options.events;var event=evts.getById(eventId);if(event){event.handler=handler;event.interval=interval;event.args=argsCallBack;}else{event=evts[evts.length]={'id':eventId,'handler':handler,'interval':interval,'args':argsCallBack};}
if(o.pollHandle==null){this._setupCall();}else{var myPoll_ms=this._nowAddMs(interval).getTime(),nextPoll_ms=o.nextPoll.getTime();if(myPoll_ms<(nextPoll_ms-1000)){window.clearTimeout(o.pollHandle);this._setupCall();}}},unregister:function(eventId){var evts=this.options.events;for(var i=0;i<evts.length;i++){if(evts[i].id==eventId){evts.splice(i,1);break;}}},interval:function(eventId,interval){var event=this.events.getById(eventId);if(arguments.length==1)
return event;if(event&&interval!=null)event.interval=interval;},_setupCall:function(){var interval=this.options.events.getInterval();this.options.nextPoll=this._nowAddMs(interval);this.options.pollHandle=window.setTimeout($.xw.delegate(this,this._poll),interval);},_nowAddMs:function(v){return new Date((new Date()).valueOf()+v);},_handler:function(status){var widget=this,o=this.options,evts=o.events,request=evts.getEvents();try{$.each(evts,function(i,value){if(value&&typeof request[value.id]!='undefined'){var newInt=value.handler(status[value.id]);if(typeof(newInt)!='undefined'){value.interval=newInt;}}});}catch(e){}
for(var i=evts.length-1;i>=0;i--){if(evts[i].interval<=0){evts.splice(i,1);}};var interval=evts.getInterval();if(o.pollVisible){$('#xw-polling-label').length==0&&$('#footerContent div.sub').append(' | <label id="xw-polling-label"></label>');$('#xw-polling-label').html((new Date()).toLocaleTimeString()+': '+interval/1000+'s');}
widget._setupCall();},_poll:function(){var widget=this,o=this.options,evts=o.events;if(o.pollHandle){window.clearTimeout(o.pollHandle);o.pollHandle=null;}
o.timestamp++;var stamp=o.timestamp;var request=evts.getEvents();this.$remote('Poll',{'events':request},function(status){if(stamp!=o.timestamp){return;}
widget._handler(status);},function(err){var serverError=null;try{eval('serverError = '+err.responseText);}catch(e){}
widget._setupCall();});}}));$.xw.polling.NONE='None';$.xw.polling.LOGIN='Login';$.xw.polling.EMAIL='Bounce';$.xw.polling.CHAT='Chat';$.widget("xw.profileTip",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},load:function(userFn){var widget=this,el=this.element,o=this.options,user=el.text(),template=$('<table cellpadding="0" cellspacing="0" class="profileTip"><tr><th><img class="portrait" width="33" height="33" /><div class="age"></div><img class="online" width="24" height="23" /><div class="x_medals clearfix"></div></th><td><label>username</label><ul class="iconList"></ul></td></tr></table>'),ui={div:template,portrait:template.find('img').eq(0),online:template.find('img').eq(1),age:template.find('div.age'),label:template.find('label'),items:template.find('ul'),medals:template.find('div.x_medals')};if(user.lastIndexOf('...')>0||el.find('img').length>0)user=el.attr('title');$.xw.tip.add({'trigger':el,'remote':function(callBack){widget.$remote('GetProfileTip',{'user':userFn?userFn():user,'linkNewWindow':o.linkNewWindow},function(data){if(data.valid){ui.items.empty();ui.age.html(data.age);ui.portrait.attr('src',data.pUrl);ui.online.attr({'src':data.online?o.onlineUrl:o.offlineUrl,'title':data.onlineText});ui.medals.empty();data.isM&&ui.medals.append('<img class="x_medal x_moderator" title="Moderator" />');data.isP&&ui.medals.append('<img class="x_medal x_premium" title="Premium Member" />');data.isV&&ui.medals.append('<img class="x_medal x_verified" title="Verified Member" />');$.each(data.items,function(i,item){if(item.url)
ui.items.append('<li class="'+item.css+'"><a href="'+item.url+'">'+item.text+'</a></li>');else{var $a=$('<a href="javascript:void(0)">'+item.text+'</a>').click(function(){eval(item.script);});ui.items.append($('<li class="'+item.css+'"></li>').append($a));}});ui.label.html((userFn?userFn():user)+':');}
var args={'context':widget,'data':data,'ui':data.valid?ui.div:null,'user':userFn?userFn():user};el.triggerHandler('profileTip',args);callBack(args.ui);},function(err){debugger;});}});},destroy:function(){$.xw.tip.remove(this.element);}}));$.xw.profileTip.defaults={'linkNewWindow':false};$.widget("xw.reportMember",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();var w$=this,o=this.options,e$=this.element,$box=this.element.parents('.xw-actionBox'),ui={ctn:this.element.parents('.xw-actionBox-container'),inPanel:$('.xw-reportMember-in',e$),donePanel:$('.xw-reportMember-done',e$),actionBox:e$.parents('.xw-actionBox'),reasons:$('input[type="checkbox"]',e$),details:$('textarea',e$),errors:$('#'+o.errorId),go:this.$get('idGo'),cancel:this.$get('idCancel')};o.ui=ui;o.allReasons=0;ui.cancel.click(function(){ui.actionBox.actionBox('close');});ui.reasons.each(function(){o.allReasons+=parseInt(this.value);});ui.reasons.change(function(){w$._clear();});ui.details.keypress(function(){w$._clear();});ui.go.click(function(){var selection=w$._selection();if(selection!==null){$.xw.auth.logIn(function(){ui.actionBox.length&&ui.actionBox.actionBox('busy');w$.$remote('ReportMember',{'name':selection.name,'reasons':selection.reasons,'details':selection.details},function(status){ui.inPanel.hide();ui.donePanel.show();ui.actionBox.length&&ui.actionBox.actionBox('busy',false);},function(err){ui.actionBox.length&&ui.actionBox.actionBox('busy',false);var serverError=null;try{eval('serverError = '+err.responseText);}catch(e){}
w$._error(o.errSubmit);});});};});ui.actionBox.length&&ui.actionBox.actionBox('opening',function(e,openArgs){o.userName=openArgs.options.name;ui.actionBox.actionBox('title',$.xw.replace(o.title,o.userName));ui.reasons.each(function(){this.checked=false;});ui.details.val('');w$._clear();ui.donePanel.hide();ui.inPanel.show();});},load:function(){},_selection:function(){var w$=this,o=this.options,ui=o.ui;var reasons=0;ui.reasons.each(function(){if(this.checked){reasons+=parseInt(this.value);}});if(reasons==0){w$._error(o.errNoRsns);return null;}
if(reasons==o.allReasons){w$._error(o.errAllRsns);return null;}
var details=$.trim(o.ui.details.val());if(details===''&&((reasons&w$.ABS)==w$.ABS||(reasons&w$.ILL)==w$.ILL||(reasons&w$.UND)==w$.UND||(reasons&w$.OTH)==w$.OTH)){w$._error(o.errDetails);return null;}
return{'name':o.userName,'reasons':reasons,'details':details};},_error:function(m){var o=this.options;o.ui.errors.statusMessages('add',this,m);o.ui.ctn[0].scrollTop=o.ui.ctn[0].scrollHeight;},_clear:function(){this.options.ui.errors.statusMessages('remove',this);},SPAM:1,SCAM:2,ABS:4,ILL:8,UPL:16,UND:32,OTH:16384}));$.xw.reportMember.defaults={};$.widget("xw.reportMemberProxy",$.extend({},$.xw.aspNetBase,{_init:function(){this.aspNetBaseInit();},open:function(name){$('#'+this.options.actionId).actionBox('open',{'name':name});}}));$.widget("xw.textCursor",$.extend({},{_init:function(){var self=this;if(document.selection){function saveCursor(){self.options.ieCursor=document.selection.createRange();};$(this.element).bind('click.textCursor',saveCursor).bind('select.textCursor',saveCursor).bind('keyup.textCursor',saveCursor);}},cursorReplace:function(options){var o=$.extend({text:'',pattern:null,highlight:false},(typeof(options)==='string')?{'text':options}:options),field=this.element[0],fromTo=this.cursorRange();if(o.pattern!==null){var selection=field.value.substring(fromTo.from,fromTo.to)||'';o.text=o.text.replace(o.pattern,selection);}
if(field.selectionStart||field.selectionStart===0){field.value=field.value.substring(0,fromTo.from)+o.text+field.value.substring(fromTo.to,field.value.length);}else if(document.selection){(this.options.ieCursor||document.selection.createRange()).text=o.text;}else{field.value+=o.text;}
if(o.highlight)
this.cursorSelect({from:fromTo.from,to:fromTo.from+o.text.length});},cursorRange:function(){var ta=this.element[0];ta.focus();if(ta.selectionStart||ta.selectionStart===0){return{from:ta.selectionStart,to:ta.selectionEnd};}else if(document.selection){var middle=(this.options.ieCursor||document.selection.createRange()).duplicate();var left=document.body.createTextRange();left.moveToElementText(ta);left.setEndPoint('EndToStart',middle);var right=document.body.createTextRange();right.moveToElementText(ta);right.setEndPoint('StartToEnd',middle);var selectionStart=this.getRangeLength(left);var selectionEnd=selectionStart+this.getRangeLength(middle);return{from:selectionStart,to:selectionEnd};}else{return{from:0,to:0};}},getRangeLength:function(range){var original=buffer=range.text;while(true){if(range.compareEndPoints('StartToEnd',range)===0)
break;range.moveEnd('character',-1)
if(range.text!=original)
break;buffer+='\r\n';}
return buffer.length;},cursorSelect:function(options){var field=this.element[0];if(typeof(field.value)==='undefined')
return this;var self=this,o=$.extend({'from':0,'to':0},options),from=(o.from.toLowerCase&&o.from.toLowerCase()==='end')?field.value.length:o.from,to=(o.to.toLowerCase&&o.to.toLowerCase()==='end')?field.value.length:o.to;if(field.setSelectionRange)
setTimeout(function(){field.setSelectionRange(from,to);},2);else if(field.createTextRange){var r=field.createTextRange();r.moveStart('character',from);r.moveEnd('character',to-field.value.length);r.select();}
return this;}}));})(jQuery);﻿
(function($){$.xw=$.xw||{};$.xw.fieldBase={fieldBaseInit:function(f){var self=this,o=this.options,$c=$('.field-f',this.element).eq(0),ui={'container':$c,'label':$('.field-l',this.element),'field':(f)?$(f,$c):$c,'desc':$('.field-d',this.element),'error':$('.field-e',this.element),'pageErrors':(o.errorId)?$('#'+o.errorId):null};this.options.ui=ui;if(o.disabled)
this.disable();$(this.element).bind('validate.'+o.validationGroup,function(e,args){if(o.disabled)return;args.onFail=$.xw.delegate(self,self.showError);if(o.onValidate)
o.onValidate.apply(self,[e,args]);}).bind('load',function(e,args){if(o.onLoad)
o.onLoad.apply(self,[e,args]);}).bind('call.'+o.validationGroup,function(e,args){var fn=self[args.method];if($.isFunction(fn))
args.value[args.value.length]={'context':self,'element':self.element,'value':(args.args)?fn.apply(self,args.args):fn.apply(self)};}).bind('changed',function(e,args){if(o.onChanged)
o.onChanged.apply(self,[e,args]);});},showError:function(msg){var o=$.extend({'message':'','pageErrors':true},(typeof msg==='object')?msg:{'message':msg||this.options.defaultError});var ui=this.options.ui;this.element.addClass(this.options.errorRowClass);ui.error.html(o.message);if(o.pageErrors&&ui.pageErrors)
ui.pageErrors.statusMessages('add',this,o.message);ui.error.show();},hideError:function(){if(!this.element.hasClass(this.options.errorRowClass))
return;var ui=this.options.ui;this.element.removeClass(this.options.errorRowClass);if(ui.pageErrors)
ui.pageErrors.statusMessages('remove',this);ui.error.hide();},validate:function(handler){var widget=this,o=this.options,fullEvent='validate.'+this.options.validationGroup;return $(this.element).unbind(fullEvent).bind(fullEvent,function(e,args){if(o.disabled)return;args.onFail=$.xw.delegate(widget,widget.showError);handler.apply(widget,[e,args]);if(args.isValid()&&o.onValidate){o.onValidate.apply(widget,[e,args]);}});},disable:function(){this.options.ui.field.attr('disabled',true);this.options.disabled=true;},enable:function(){this.options.ui.field.removeAttr('disabled');this.options.disabled=false;},focus:function(){var ui=this.options.ui;(ui.field[0].focus&&ui.field[0].focus());}};$.widget("xw.textField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit();var self=this,o=this.options,ui=this.options.ui;ui.field.shadowText(o.shadowText).bind('keypress',function(e){self.hideError();if(o.lengthCheck&&o.maxLength>0){var l=o.maxLength-$.trim($(this).val()).length;l<0&&self.showError({'message':$.xw.replace(o.maxLengthMsg,o.maxLength),'pageErrors':false});}
self.element.triggerHandler('changed');}).after('<div />');this.validate(function(e,args){if(o.required&&ui.field.val()=='')
args.fail();if(o.maxLength>0){var limit=new RegExp('^[\\s\\S]{0,'+o.maxLength+'}$');if(!limit.test(ui.field.val()))
args.fail(String.format(o.maxLengthMsg,o.maxLength));}});$(this.element).trigger('load');},text:function(value){return(arguments.length===0)?this.options.ui.field.val():(this.options.ui.field.val(value),value);},changed:function(handler){this.options.onChanged=handler;},selected:function(){return $.trim(this.options.ui.field.val()).length>0;}}));$.xw.textField.getter='text selected';$.widget("xw.telephoneField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input');var self=this,o=this.options,ui=this.options.ui;this.validate(function(e,args){if(o.required&&ui.field.val()=='')
args.fail();if(o.maxLength>0){var limit=new RegExp('^[\\s\\S]{0,'+o.maxLength+'}$');if(!limit.test(ui.field.val()))
args.fail(String.format(o.maxLengthMsg,o.maxLength));}
var format=new RegExp('^[+]?[0-9]*$');if(!format.test(ui.field.val()))
args.fail(o.formatMsg);});$(this.element).trigger('load');},load:function(){var widget=this,o=this.options,ui=this.options.ui,$cl=ui.container.find('.xw-countryList');ui.countryList=$.xw.delegate($cl,$cl.countryList)
ui.countryList('change',function(e,code){ui.field.attr('disabled',true);widget.$remote('ChangeTelephonePrefix',{'code':code,'userInput':ui.field.val()},function(value){ui.field.val(value);ui.field.attr('disabled',false);},function(){ui.field.attr('disabled',false);});});ui.field.shadowText(o.shadowText).bind('keyup',function(e){widget.hideError();var value=$.trim($(this).val());if(o.lengthCheck&&o.maxLength>0){var l=o.maxLength-$.trim(value).length;l<0&&widget.showError({'message':$.xw.replace(o.maxLengthMsg,o.maxLength),'pageErrors':false});var format=new RegExp('^[+]?[0-9]*$');if(!format.test(value))
widget.showError({'message':o.formatMsg,'pageErrors':false});}
if(value.substr(0,1)==='+'&&value.length>1){widget.$remote("FindCountryCodeByPrefix",{'number':value},function(code){ui.countryList('selectedValue',code);});}
widget.element.triggerHandler('changed');}).after('<div />');o.countryCode&&ui.countryList('selectedValue',o.countryCode);},text:function(value){return(arguments.length===0)?this.options.ui.field.val():(ui.field.val(value),value);},selected:function(){return $.trim(this.options.ui.field.val()).length>0;}}));$.xw.telephoneField.getter='text selected';$.widget("xw.timeDurationField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input');var self=this,o=this.options,ui=this.options.ui;ui.field.eq(0).bind('keydown',function(e){(e.KeyCode<48||e.keyCode>57)&&e.preventDefault();});ui.field.eq(1).bind('keydown',function(e){(e.KeyCode<48||e.keyCode>57)&&e.keyCode!=190&&e.preventDefault();});ui.field.bind('keypress',function(e){self.hideError();});this.validate(function(e,args){if(o.required&&false===self.selected()){args.fail();return;}
var minValue=$.trim(ui.field[0].value);if(minValue!==''){var x=new RegExp("^[0-9]+$","gi");if(!x.test(minValue)){args.fail(o.errorNotNumeric);return;}}
var secValue=$.trim(ui.field[1].value);if(secValue!==''){var y=new RegExp("^[0-9]+(\.[0-9]*)?$","gi");if(!y.test(secValue)){args.fail(o.errorNotNumeric);return;}}});$(this.element).trigger('load');},selected:function(){var ui=this.options.ui;return($.trim(ui.field[0].value)!==''||$.trim(ui.field[1].value)!=='');}}));$.xw.timeDurationField.getter='selected';$.widget("xw.heightField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input');var self=this,o=this.options,ui=this.options.ui;ui.field.bind('keydown',function(e){if(e.keyCode in $.xw.set(8,9,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,110,190))
self.hideError();else
e.preventDefault();});var impToCm=function(){var feet=new Number(ui.field[0].value),inches=new Number(ui.field[1].value);ui.field[2].value=(feet==0&&inches==0)?'':Math.round((feet*12+inches)/o.cmToInFactor);};ui.field.eq(0).bind('blur',impToCm);ui.field.eq(1).bind('blur',impToCm);ui.field.eq(2).bind('blur',function(e){var value=new Number(this.value);ui.field[0].value=(value==0)?'':parseInt((value*o.cmToInFactor)/12);ui.field[1].value=(value==0)?'':Math.round((value*o.cmToInFactor)%12);});this.validate(function(e,args){if(o.required&&false===self.selected()){args.fail();return;}
if(self.selected()){var value=ui.field[2].value;re=new RegExp("^[0-9]+$","gi");if(!re.test(value)){args.fail(o.errorNotNumeric);return;}
var height=parseInt(value);if(height<o.minValue||height>o.maxValue){args.fail(o.errorRange);return;}}});$(this.element).trigger('load');},selected:function(){return($.trim(this.options.ui.field[2].value)!=='');}}));$.xw.heightField.getter='selected';$.widget("xw.weightField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input');var self=this,o=this.options,ui=this.options.ui;ui.field.bind('keydown',function(e){if(e.keyCode in $.xw.set(8,9,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,110,190))
self.hideError();else
e.preventDefault();});ui.field.eq(0).bind('blur',function(e){var value=new Number(this.value);if(!(new RegExp("^[0-9]+$")).test(this.value))
ui.field[1].value=this.value='';else
ui.field[1].value=(value==0)?'':Math.round(value*o.kgToLbFactor);});ui.field.eq(1).bind('blur',function(e){var value=new Number(this.value);if(!(new RegExp("^[0-9]+$")).test(this.value))
ui.field[0].value=this.value='';else
ui.field[0].value=(value==0)?'':Math.round(value/o.kgToLbFactor);});this.validate(function(e,args){if(o.required&&false===self.selected()){args.fail();return;}
if(self.selected()){var value=ui.field[1].value;re=new RegExp("^[0-9]+$","gi");if(!re.test(value)){args.fail(o.errorNotNumeric);return;}
var weight=new Number(value);if(weight<o.minValue||weight>o.maxValue){args.fail(o.errorRange);return;}}});$(this.element).trigger('load');},selected:function(){return($.trim(this.options.ui.field[1].value)!=='');}}));$.xw.weightField.getter='selected';$.widget("xw.selectField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit();var self=this,o=this.options,ui=this.options.ui;ui.field.bind('change',function(e){self.hideError();self.element.triggerHandler('changed',{'index':this.selectedIndex,'value':this.options[this.selectedIndex].value});}).bind('keyup',function(e){ui.field.triggerHandler('change');});this.validate(function(e,args){if(o.required&&ui.field.val()=='')
args.fail();});$(this.element).trigger('load');},selectedIndex:function(newIndex){if(arguments.length>0){this.options.ui.field[0].selectedIndex=newIndex;}
return this.options.ui.field[0].selectedIndex;},selectedValue:function(){var list=this.options.ui.field[0];return(list.selectedIndex<0)?null:list.options[list.selectedIndex].value;},textByValue:function(value){var list=this.options.ui.field[0];for(var i=0;i<list.options.length;i++){if(list.options[i].value==value){return list.options[i].text;}}
return null;},selected:function(){var index=this.options.ui.field[0].selectedIndex,o=this.options;return(index>=(o.chooseVisible?1:0))&&index!=o.unselectedIndex;},changed:function(handler){this.element.bind('changed.selectField',handler);}}));$.xw.selectField.getter='selectedIndex textByValue selectedValue selected';$.widget("xw.multiSelectField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input');var self=this,o=this.options,ui=this.options.ui;ui.field.bind('change',function(e){self.hideError();});this.validate(function(e,args){if(o.required&&!self.selected()){args.fail();return;}});$(this.element).trigger('load');},selected:function(){var ui=this.options.ui,selected=ui.container.find(':checked');return(selected.length&&ui.field.index(selected[0])!=this.options.unselectedIndex)?true:false;}}));$.xw.multiSelectField.getter='selected';$.widget("xw.clientSelectField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit();var self=this,o=this.options,ui=this.options.ui;ui.field.bind('change',function(e){self.hideError();self.element.triggerHandler('changed');});this.validate(function(e,args){var index=parseInt(ui.field.val().split('|')[2]);if(!o.disabled&&o.required&&index<=0){args.fail();}});$(this.element).trigger('load');},clear:function(){this.options.ui.field.empty();},add:function(text,value){var ui=this.options.ui;$('<option />').attr('value',value+'|'+text+'|'+ui.field[0].length).html(text).appendTo(ui.field);},selected:function(){return this.options.ui.field[0].selectedIndex>=0;},selectedIndex:function(){if(arguments.length===0)
return this.options.ui.field[0].selectedIndex;else
this.options.ui.field[0].selectedIndex=arguments[0];},selectedValue:function(){var list=this.options.ui.field[0];return(list.selectedIndex<0)?null:list.options[list.selectedIndex].value;},changed:function(handler){var self=this;this.element.bind('changed.clientSelectField',function(e){handler.apply(this,[e,{'index':self.selectedIndex(),'value':self.selectedValue()}]);});}}));$.xw.clientSelectField.getter='selected selectedIndex selectedValue';$.widget("xw.radioListField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('li > input');var self=this,o=this.options,ui=this.options.ui;ui.field.bind('click',function(e){self.hideError();self.element.triggerHandler('changed');});this.validate(function(e,args){if(o.required&&false===self.selected())
args.fail();});$(this.element).trigger('load');},selectedValue:function(value){var o=this.options;if(arguments.length>0){this.options.ui.field.each(function(){if(this.value==value)this.checked=true;});}else{return $(':checked',this.options.ui.container).val();}},selected:function(){var ui=this.options.ui,selected=ui.container.find(':checked');return(selected.length&&ui.field.index(selected[0])!=this.options.unselectedIndex)?true:false;}}));$.xw.radioListField.getter='selectedValue selected';$.widget("xw.dateField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('select');var self=this,o=this.options,ui=this.options.ui;ui.field.bind('change',function(e){self.hideError();self.element.triggerHandler('changed');});this.validate(function(e,args){var valid=true;if(o.required&&o.chooseVisible&&self.selectedValue()===null){args.fail();valid=false;}
if(valid&&self.selected()){var value=self.selectedValue();if(($(ui.field[1]).val()-1)!=value.getMonth()||$(ui.field[0]).val()!=value.getDate())
args.fail();}});$(this.element).trigger('load');},selectedValue:function(){var ui=this.options.ui;return(!this.options.chooseVisible||ui.field.filter(function(){return this.selectedIndex>0;}).length==3)?new Date($(ui.field[2]).val(),$(ui.field[1]).val()-1,$(ui.field[0]).val()):null;},selected:function(){return(this.selectedValue()!==null);}}));$.xw.dateField.getter='selected selectedValue';$.widget("xw.changeStateCheckField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input');var self=this,o=this.options,ui=this.options.ui;$(ui.field).bind('change',function(e){self.hideError();self.element.triggerHandler('changed');});this.validate(function(e,args){if(o.required&&false===ui.field[0].checked)
args.fail();});$(this.element).trigger('load');},selected:function(){return(this.options.ui.field[0].checked);}}));$.xw.changeStateCheckField.getter='selected';$.widget("xw.checkField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input');var self=this,o=this.options,ui=this.options.ui;$(ui.field).bind('click',function(e){self.hideError();self.element.triggerHandler('changed');});this.validate(function(e,args){if(o.required&&false===ui.field[0].checked)
args.fail();});$(this.element).trigger('load');},selected:function(){return this.options.ui.field[0].checked;}}));$.xw.checkField.getter='selected';$.widget("xw.templateField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit();},load:function(){$(this.element).trigger('load');},selected:function(){return this.options.selected?this.options.selected():false;}}));$.xw.templateField.getter='selected';$.widget("xw.uploadField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit();this.element[0].xw_upload=this;var widget=this,ui=this.options.ui;ui.$browse=$('div:eq(0)',ui.container);ui.$frame=$('iframe',ui.container);ui.$uploadId=this.$get('uploadId');ui.$pct=$('<div />').append('<div class="x_bar" />').append('<div class="x_label" />').addClass('x_pct').appendTo(ui.container).hide()
ui.$cancel=$('<input type="button" />').css({'float':'left'}).attr('value',this.options.cancel).click(function(){widget.options.ui.view.show(ui.view.$uploaded);}).appendTo(ui.container).hide();ui.$thumb=$('<img />').css({'width':this.options.thumbWidth||'auto','height':this.options.thumbHeight||'auto'}).appendTo(ui.container).hide();ui.$change=$('<input type="button" />').attr('value',this.options.change).click(function(){widget.reset();}).appendTo(ui.container).hide();if(this.options.disabled){$('<div class="attachmentCover"><div class="x_top"><span /></div><div class="x_middle"/><div class="x_bottom"><span /></div></div>').appendTo(this.element);this.element.css({'margin-top':20,'margin-bottom':20});}
var height=ui.$pct.height();ui.$pctLabel=ui.$pct.find('div:eq(1)').text("0%").css({'height':height});ui.$pctBar=ui.$pct.find('div:eq(0)').css('height',height);ui.view={$uploaded:$([ui.$change[0],ui.$thumb[0]]),$select:(ui.$uploadId.val().length>0)?$([ui.$browse[0],ui.$cancel[0]]):ui.$browse,$progress:ui.$pct,show:function(view){this.$progress.showSwitch(view===this.$progress);this.$select.showSwitch(view===this.$select);this.$uploaded.showSwitch(view===this.$uploaded);}};this.options.ui=ui;ui.$browse.css('width',(ui.view.$select.length===1)?'100%':ui.container.width()-ui.$cancel.width()-15);if(this.options.onUploading)
this.bind('uploading',this.options.onUploading)
if(this.options.onUploaded)
this.bind('uploaded',this.options.onUploaded)
this.validate(function(e,args){if(widget.options.required&&!widget.isUploaded())
args.fail();});if(this.isUploaded()){widget._setThumb();ui.view.show(ui.view.$uploaded);}},_setThumb:function(){var url=$.xw.replace($.trim(this.options.thumbUrl),this.options.fileId);url+=(url.indexOf('?')<0)?'?':'&';this.options.ui.$thumb.attr('src',url+Date.parse(new Date()));},_progress:function(pct){var ui=this.options.ui;ui.$pctBar.css('width',pct+'%');ui.$pctLabel.text(pct+'%');},start:function(fileName){var ui=this.options.ui,widget=this,o=this.options,exts=this.options.extensions,ext=fileName.substring(fileName.lastIndexOf('.')+1).toLowerCase(),valid=false;this.hideError();for(var i=0;i<exts.length;i++)
if(exts[i].toLowerCase()===ext){valid=true;break;}
if(!valid){alert(this.options.errorExt);return false;}
this.isUploading(true);this._progress(0);this.element.triggerHandler('uploading',{'context':widget});var nullCount=10;var showProgress=false;function getStatus(){if(!this.isUploading())
return;if(!showProgress){ui.view.show(ui.view.$progress);showProgress=true;}
this.$remote('GetUploadStatus',{'fileId':this.options.fileId},function(status){if(status==null){nullCount--;if(nullCount>0)
window.setTimeout($.xw.delegate(widget,getStatus),1000);else
alert('Status not returned.');}else{if(status.ex){this.isUploading(false);widget.newIdToIframe(true);ui.view.show(ui.view.$select);if(status.ex.type=='System.Web.HttpException'&&status.ex.message.indexOf('request length exceeded')>0)
widget.showError(o.tooLargeMessage||'The file you are uploading is too large.');else
widget.showError(o.failedMessage||'Upload failed due to an unexpected error.');}else{widget._progress(status.percent);widget.fileName(status.fileName);if(status.percent<100)
window.setTimeout($.xw.delegate(widget,getStatus),1000);else
nullCount=10;}}},function(err){});}
window.setTimeout($.xw.delegate(this,getStatus),300);return true;},finish:function(err){var widget=this;if(this.isUploading()){this.isUploading(false);var ui=this.options.ui,o=this.options;if(err!=null){this.showError(o.failedMessage||'Upload failed due to an unexpected error.');ui.view.show(ui.view.$select);}else{ui.$uploadId.val(this.options.fileId);if(ui.view.$select.length===1){ui.view.$select=$([ui.$browse[0],ui.$cancel[0]]);ui.$browse.css('width',ui.container.width()-ui.$cancel.width()-15);this.options.ui=ui;}
widget._setThumb();if(o.upType==3)
this.$remote('SaveFileToProfile',{'name':o.srcName,'uploadId':o.fileId},function(){});ui.view.show(ui.view.$uploaded);this.element.triggerHandler('uploaded',{'context':widget});this.hideError();widget.element.triggerHandler('changed');this.$remote('NewGuid',null,function(newId){this.options.nextId=newId;});}}},newIdToIframe:function(getNewId){var ui=this.options.ui,o=this.options;o.lastId=o.fileId;o.fileId=o.nextId;ui.$frame.attr('src',o.frameUrl.replace(/\{0\}/,o.fileId));ui.$uploadId.val('');if(getNewId)
this.$remote('NewGuid',null,function(newId){this.options.nextId=newId;});},reset:function(){var ui=this.options.ui,o=this.options;if(ui.$uploadId.val().length>0){this.newIdToIframe();if(ui.view.$select.length===2){ui.view.$select=ui.$browse;ui.$browse.css('width','100%');this.options.ui=ui;}
ui.view.show(ui.view.$select);}},isUploading:function(){if(arguments.length===0)
return this.options.ul;else
this.options.ul=arguments[0];},uploaded:function(method){this.element.bind('uploaded',method);},uploading:function(method){this.element.bind('uploading',method);},isUploaded:function(){return(this.options.ui.$uploadId.val().length>0);},fileName:function(){if(arguments.length===0)
return this.options.ofn;else
this.options.ofn=arguments[0];},fileId:function(){return this.options.fileId;}}));$.xw.uploadField.getter='start isUploading isUploaded fileName fileId';$.widget("xw.tagsField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('select');var w$=this,o=this.options,ui=this.options.ui;this._rebuild();ui.field.bind('change',function(e){w$.hideError();var value=$(e.target).val();o.selectedValue[ui.field.index(e.target)]=value===o.firstItemLabel?'':value;w$._rebuild();w$.element.triggerHandler('changed');});this.validate(function(e,args){if(o.required&&!w$.selected()){args.fail();}});this.element.bind('refresh.tagsField',function(){w$.$remote('GetTags',null,function(list){o.list=list;w$._rebuild();});});$(this.element).trigger('load');},_rebuild:function(){var o=this.options;o.ui.field.each(function(i,s){var $s=$(s),id=o.selectedValue[i];$s.empty();o.firstItemVisible&&$s.append($('<option />').addClass(o.chooseCssClass).text(o.firstItemLabel));$.each(o.list,function(j,item){if($.inArray(item.id,o.selectedValue)<0||(id&&item.id===id)){$s.append($('<option />').attr('value',item.id).text(item.name).attr('selected',item.id===id));};});});},selectedValue:function(value){var o=this.options;if(arguments.length>0){o.selectedValue=value;this._rebuild();}else{return o.selectedValue;}},selected:function(){var count=0;$.each(this.options.selectedValue,function(i,value){typeof value!=='undefined'&&value.length>0&&count++;});return(count>=this.options.minRequired);}}));$.xw.tagsField.getter='selected selectedValue';$.widget("xw.selectTextField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('input,select');var self=this,o=this.options,ui=this.options.ui;ui.text=ui.field.eq(0).is('input')?ui.field.eq(0):ui.field.eq(1);ui.select=ui.field.eq(0).is('input')?ui.field.eq(1):ui.field.eq(0);ui.field.bind('change',function(e){self.hideError();self.element.triggerHandler('changed',{'index':ui.select[0].selectedIndex,'value':ui.select.val(),'textValue':ui.text.val()});});this.validate(function(e,args){if(o.required){var unselected=(o.unselectedIndex&&o.unselectedIndex>=0)?o.unselectedIndex:-1;if(unselected==ui.select[0].selectedIndex){args.fail();}}});$(this.element).trigger('load');},selectedIndex:function(){return this.options.ui.select[0].selectedIndex;},selectedValue:function(){var list=this.options.ui.select[0];return(list.selectedIndex<0)?null:list.options[list.selectedIndex].value;},selected:function(){return this.options.selected?this.options.selected():false;},textValue:function(){return this.options.ui.text[0].value;},changed:function(handler){this.element.bind('changed.selectTextField',handler);}}));$.xw.selectTextField.getter='selectedIndex selectedValue selected textValue';$.widget("xw.selectSelectField",$.extend({},$.xw.aspNetBase,$.xw.fieldBase,{_init:function(){this.aspNetBaseInit();this.fieldBaseInit('select');var self=this,o=this.options,ui=this.options.ui;ui.field.bind('change',function(e){self.hideError();self.element.triggerHandler('changed',{'index':ui.field[0].selectedIndex,'value':ui.field.eq(0).val()});});this.validate(function(e,args){});$(this.element).trigger('load');},selectedIndex:function(){return this.options.ui.field[0].selectedIndex;},selectedValue:function(){var list=this.options.ui.field[0];return(list.selectedIndex<0)?null:list.options[list.selectedIndex].value;},selected:function(){return this.options.selected?this.options.selected():false;},selectedIndex2:function(){return this.options.ui.field[1].selectedIndex;},selectedValue2:function(){var list=this.options.ui.field[1];return(list.selectedIndex<0)?null:list.options[list.selectedIndex].value;},changed:function(handler){this.element.bind('changed.selectSelectField',handler);}}));$.xw.selectTextField.getter='selectedIndex selectedValue selected selectedIndex2 selectedValue2';})(jQuery);