var ____=(function(){var __={};var _trace=null;var i=0;function $_(value,expression){if(!_trace){_trace=new Array(10000)}if(arguments.length==0||typeof value=="undefined"||value==null){throw new Error('null expression: expression="'+expression+'", value='+value+", trace="+_trace)}_trace[i++]=expression;return value}if(typeof LINGO=="undefined"){LINGO={detect:{},timestamps:{},deconcept:{}}}function noop(){return null}function ass(x,msg){if(!x){if(typeof msg=="undefined"||msg==null){msg="assertion error"}throw new Error(msg+", trace="+_trace)}}function now(){return(new Date()).getTime()}if(typeof LINGO=="object"&&typeof LINGO.timestamps=="object"){LINGO.timestamps.js_start=now()}function doa(d,key,item){d[key]?d[key].push(item):d[key]=[item]}var time={};time.now=now;time.units="second minute hour day week month year decade".split(" ");time.second=1000;time.minute=60*time.second;time.hour=60*time.minute;time.day=24*time.hour;time.week=7*time.day;time.month=4*time.week;time.year=12*time.month;time.decade=10*time.year;function now_utc(){return(new Date()).getTime()}time.format_ts=function(ts){var d=new Date(ts);if(typeof d=="string"){d=parseFloat(d)}else{if(typeof date=="object"){d=d.getTime()}}var month=(d.getMonth()+1)+"";if(month.length==1){month="0"+month}var day=d.getDate();var year=d.getFullYear();var hour=d.getHours()+0;var half="pm";if(hour>12){hour-=12}else{if(hour<12){half="am"}}var min=d.getMinutes()+"";if(min.length==1){min="0"+min}var stamp=month+"-"+day+"-"+year+" "+hour+":"+min+" "+half;return stamp};time.ago=function(date){if(typeof date=="string"){date=parseFloat(date)}else{if(typeof date=="object"){date=date.getTime()}}var diff=now_utc()-date;var units=time.units,unit=null,num=null;for(var i=1,n=units.length;i<n;i++){var max=time[units[i]];if(diff<max){unit=units[i-1];num=Math.round(diff/time[unit]);break}else{}}if(!unit){unit=units[units.length-1];num=Math.round(diff/time[unit])}if(num<=0){return"A few minutes ago"}if(num!=1){unit+="s"}return num+" "+unit+" ago"};function comma_num(num){if(num==0){return"0"}var num=num+"";var len=num.length;var r=num.charAt(0);var i=3-(len%3);for(var j=1;j<len;j++){if(++i%3==0){r+=","}r+=num.charAt(j)}return r}var str_reverse=function(s){return s.split("").reverse().join("")};function yield(f){setTimeout(f,1)}function is_null(x){return typeof x=="undefined"||x==null}function not_null(x){return typeof x!="undefined"&&x!=null}function not(f,s){for(var i=1,n=s.length;i<n;i++){if(f(s[i])){return false}}return true}var none=not;function and(f,s){for(var i=1,n=s.length;i<n;i++){if(!f(s[i])){return false}}return true}var all=and;function or(f,s){for(var i=1,n=s.length;i<n;i++){if(f(s[i])){return true}}return false}var any=or;function update(self,obj){if(self===null){self={}}for(var i=1,n=arguments.length;i<n;i++){var o=arguments[i];if(not_null(o)){for(var k in o){self[k]=o[k]}}}return self}function _(x){return function(){return x}}function null_(){return null}function true_(){return true}function false_(){return false}function dict_(){return{}}function array_(){return[]}function apply(obj,meth_name,args){var f=obj[meth_name];if(!f){throw new Error(meth_name)}return args?f.apply(obj,args):f.apply(obj)}function identity(x){return x}function random_int(min,max){return Math.round(Math.random()*(max-min))+min}function random_int_str(n){return new String(Math.random()).substring(2,n+2)}var random_str,gen_id;(function(){_0=48;_9=57;_A=65;_Z=90;_a=97;_z=122;random_str=function(length){var str="";while(str.length<length){var i=random_int(_0,_z);if((i>=_0&&i<=_9)||(i>=_A&&i<=_Z)||(i>=_a&&i<=_z)){str+=String.fromCharCode(i)}}return str};var id_prefix="lingo_"+random_str(4)+"_";var id_count=0;gen_id=function(){return id_prefix+id_count++}})();function is_dict(obj){return typeof obj=="object"&&obj&&typeof obj.length!="number"}function is_array(o){return o&&typeof o.length=="number"}function _is_function(obj){return typeof obj=="function"}function _is_object(obj){return obj&&(typeof obj=="object"||_is_function(obj))}function _is_array(obj){if(obj&&obj.constructor&&obj.constructor.toString().indexOf("Array")>-1){return true}else{return _is_object(obj)&&obj.constructor==Array}}var is_array_like=is_array;var slice=function(list,start,stop){var _slice=Array.prototype.slice;return arguments.length>=3?_slice.call(list,start,stop):_slice.call(list,start)};function extend(self,obj,skip){if(!skip){skip=0}if(obj){if(!self){self=[]}for(var i=skip,n=obj.length;i<n;i++){self.push(obj[i])}}return self}function concat(){var rval=[];for(var i=0,n=arguments.length;i<n;i++){extend(rval,arguments[i])}return rval}function sum(list){var r=0;for(var i=0,n=list.length;i<n;i++){r+=list[i]}return r}function has_key(obj,name){return typeof obj[name]!="undefined"&&obj[name]!=null}function getset(d,key,value){return d[key]?d[key]:d[key]=value()}function contains(obj,x){if(is_array(obj)){for(var i=0,n=obj.length;i<n;i++){if(obj[i]==x){return true}}return false}else{return has_attr(obj,x)}}function keys(dict){var r=[];for(var key in dict){r.push(key)}return r}function values(dict){var r=[];for(var key in dict){r.push(dict[key])}return r}function items(){throw new Error("items() not implemented")}function dict(pairs){var d={};forall(pairs,function(p){d[p[0]]=p[1]});return d}function dict_join(innerDelim,outerDelim,dict){var my_keys=keys(dict);my_keys.sort();return map(my_keys,function(key){return key+innerDelim+dict[key]}).join(outerDelim)}function dict_split(innerDelim,outerDelim,str){if(str.length==0){return{}}return dict(map(str.split(outerDelim),function(pair){return pair.split(innerDelim)}))}function _wrapDumbFunction(f){return function(){var a=arguments;switch(a.length){case 0:return f();case 1:return f(a[0]);case 2:return f(a[0],a[1]);case 3:return f(a[0],a[1],a[2]);case 4:return f(a[0],a[1],a[2],a[3]);case 5:return f(a[0],a[1],a[2],a[3],a[4]);case 6:return f(a[0],a[1],a[2],a[3],a[4],a[5])}throw new Error("wrapDumb not implemented")}}function bind(func,self){if(typeof (func)=="string"){func=self[func]}var im_func=func.im_func;var im_preargs=func.im_preargs;var im_self=func.im_self;if(typeof (func)=="function"&&typeof (func.apply)=="undefined"){func=_wrapDumbFunction(func)}if(typeof (im_func)!="function"){im_func=func}if(typeof (self)!="undefined"){im_self=self}if(typeof (im_preargs)=="undefined"){im_preargs=[]}else{im_preargs=im_preargs.slice()}extend(im_preargs,arguments,2);var newfunc=function(){var args=arguments;var me=arguments.callee;if(me.im_preargs.length>0){args=concat(me.im_preargs,args)}var self=me.im_self;if(!self){self=this}return me.im_func.apply(self,args)};newfunc.im_self=im_self;newfunc.im_func=im_func;newfunc.im_preargs=im_preargs;return newfunc}function getmeth(obj,name){return bind(obj[name],obj)}function partial(func){return bind.apply(this,extend([func,undefined],arguments,1))}function method_caller(){var name=arguments[0];var n=arguments.length;var args=new Array(n-1);for(var i=1;i<n;i++){args[i-1]=arguments[i]}return function(object){return object[name].apply(object,args)}}var _TEXTFIELD_OK="lingo_textfield_ok";function check_textfield(elt){if(!elt){elt=document.body}else{elt=elt.obj()}var o=LINGO.detect;if((o.browser=="Firefox")||(o.browser=="Explorer"&&o.version>=5.5)||(o.browser=="Opera")){if(elt.className.length>0){elt.className=elt.className+" "+_TEXTFIELD_OK}else{elt.className=_TEXTFIELD_OK}}}var query_join=partial(dict_join,"=","&");var query_split=partial(dict_split,"=","&");var cookie_join=partial(dict_join,":","|");var cookie_split=partial(dict_split,":","|");var _cookie_list_split=partial(dict_split,"=","; ");var re1=/^"+/;var re2=/"+$/;function strip(s){s=s.replace(re1,"");s=s.replace(re2,"");return s}function cookie_list_split(s){var d=_cookie_list_split(s);var d2={};for(var key in d){var val=d[key];d2[strip(key)]=strip(val)}return d2}function get_cookie(key){var allCookies=document.cookie;var i=allCookies.indexOf(key+"=");if(i==-1){return null}var start=i+key.length+1;var end=allCookies.indexOf(";",start);if(end==-1){end=allCookies.length}var escapedValue=allCookies.substring(start,end);return unescape(escapedValue)}function set_cookie(key,value){var expires=new Date();expires.setFullYear(expires.getFullYear()+20);var escapedValue=escape(value);document.cookie=key+"="+escapedValue+";path=/; expires="+expires.toGMTString()}function prop(){var names=arguments;if(names.length==0){names=[random_str(8)]}var n=names.length-1;return function(){var source=this;for(var i=0;i<n;i++){source=source[names[i]]}if(arguments.length==0){return source[names[i]]}source[names[i]]=arguments[0]}}var property=prop;function getter(name){return function(){ass(arguments.length==0);return this[name]}}function setter(name){return function(value){ass(arguments.length==1);this[name]=value}}function cached_prop(getter){var rand=random_str(8);var name="__cached_prop_"+rand;var set_name="__cached_prop_set_"+rand;return function(){if(!this[set_name]){this[set_name]=true;this[name]=getter.apply(this,arguments)}return this[name]}}function node_prop(src_name,class_name,is_many){return cached_prop(function(){var src_node=this[src_name].call(this);var nodes=src_node.get_by_class(class_name);return is_many?nodes:nodes[0]})}function query_arg(key){var loc=location+"";var q=loc.indexOf("?");if(q<0){return null}key+="=";var i=q;while(i<loc.length){var k=loc.indexOf(key,i);if(k<0){return null}var pre_char=loc.charAt(k-1);if(pre_char!="?"&&pre_char!="&"){i+=key.length;continue}else{break}}v=k+key.length;var amp=loc.indexOf("&",v);var val=amp<0?loc.substring(v):loc.substring(v,amp);return val}function has_query_arg(key){return typeof query_arg(key)=="string"}var map,forall,pair_map,pair_forall,keep,drop;(function(){var filter_error=new Error();function _pipe_fun(pairs,args){var arg_index,arg_len=args.length;if(pairs){return function(key,obj){for(arg_index=1;arg_index<arg_len;arg_index++){obj=args[arg_index](key,obj)}return obj}}else{return function(key,obj){for(arg_index=1;arg_index<arg_len;arg_index++){obj=args[arg_index](obj)}return obj}}}function _pipe(aggregate,pairs,args){var pipe_fun=_pipe_fun(pairs,args);var apply_fun,results,result_index=0,stream=args[0];var stream_is_array=is_array(stream);if(!aggregate){results=null;apply_fun=pipe_fun}else{results=new Array(stream_is_array?stream.length:0);apply_fun=function(){results[result_index]=pipe_fun.apply(null,arguments);result_index++}}if(stream_is_array){var index=0,stream_len=stream.length;while(index<stream_len){try{for(;index<stream_len;index++){apply_fun(index,stream[index])}}catch(e){if(e!=filter_error){throw e}index++}}}else{for(var key in stream){try{apply_fun(key,stream[key])}catch(e){if(e!=filter_error){throw e}}}}if(results&&result_index<results.length){results.splice(result_index,results.length-result_index)}return results}map=function(){return _pipe(true,false,arguments)};forall=function(){return _pipe(false,false,arguments)};pair_map=function(){return _pipe(true,true,arguments)};pair_forall=function(){return _pipe(true,true,arguments)};keep=function(f){return function(){if(f.apply(null,arguments)){return arguments.length>=2?arguments[1]:arguments[0]}throw filter_error}};drop=function(f){return function(){if(!f.apply(null,arguments)){return arguments.length>=2?arguments[1]:arguments[0]}throw filter_error}}})();var _oid=1;function gen_oid(){return"__oid__"+_oid++}function oid_method(){if(!this._oid){this._oid=gen_oid()}return this._oid}function basic_wrap(parent,child){return function(){var ref=this.base;this.base=parent.inner||parent;var result=child.apply(this,arguments);ref?this.base=ref:delete this.base;return result}}function wrap(parent,child){var inner=basic_wrap(parent,child);var fire=parent.fire||child.fire||null;if(!fire){return inner}function outer(){var result=inner.apply(this,arguments);var ref=this.base;if(this.base){delete this.base}fire.apply(this,arguments);if(ref){this.base=ref}return result}outer.fire=fire;outer.inner=inner;return outer}function base(obj,args){return apply(obj,"base",args)}function _find_ancestors(parents){var ancestors=[];forall(parents,function(parent){ancestors.push(parent);forall(parent.ancestors,function(a){ancestors.push(a)})});ancestors.reverse();var i=0;while(i<ancestors.length){var current=ancestors[i];var j=i+1;while(j<ancestors.length){if(ancestors[j]==current){ancestors.splice(j,1)}else{j++}}i++}ancestors.reverse();return ancestors}function bases(obj,name){var args=slice(arguments,2);return map(obj.Class.parents,function(parent){return parent.prototype[name]},keep(function(attr){return typeof attr=="function"}),function(method){return method.apply(obj,args)})}function _inherit_ancestors(self,attr_name,defined_name){var ancestors=self.ancestors;var self_attr=self[attr_name];for(var i=0,n=ancestors.length;i<n;i++){var a=ancestors[i];var attr_dict=a[attr_name];var defined_dict=a[defined_name];for(var name in attr_dict){if(defined_dict[name]==true&&!self_attr[name]){self_attr[name]=attr_dict[name]}}}}function _inherit_self(self_def,self,attr_name,defined_name){var defined=self[defined_name]={};var self_attr=self[attr_name];for(var name in self_def){defined[name]=true;var attr=self_def[name];var old_attr=self_attr[name];if(typeof attr=="function"&&!attr.is_class){if(old_attr){attr=wrap(old_attr,attr)}}else{if(attr&&attr.is_iclass){attr=old_attr?_override_class(attr,old_attr):Class.apply(null,attr.args)}}self_attr[name]=attr}}function _inherit(self_def,self,attr_name,defined_name){_inherit_ancestors(self,attr_name,defined_name);_inherit_self(self_def,self,attr_name,defined_name)}var iclass=function(){return{is_iclass:true,args:arguments}};function _override_class(iclass,parent){ass(parent.is_class,"parent not class");var args=extend([parent],iclass.args);return Class.apply(null,args)}function _Class(args,root){var num_parents=args.length-1;var instance_def=args[num_parents];var shared_def=null;if(instance_def.shared){shared_def=instance_def.shared;delete instance_def.shared}else{shared_def={}}var parents=new Array(num_parents);for(var i=0;i<num_parents;i++){parents[i]=args[i]}if(root){parents.push(root)}var ancestors=_find_ancestors(parents);var self=function(){var o=this;if(typeof o.pre_init=="function"){o.pre_init.apply(o,arguments)}if(typeof o.init=="function"){o.init.apply(o,arguments)}};var self_attr=self.prototype;self.is_class=true;self.parents=parents;self.ancestors=ancestors;self.shared={};self_attr.Class=self;self_attr.shared=self.shared;_inherit(instance_def,self,"prototype","prototype_defined");_inherit(shared_def,self,"shared","shared_defined");self.oid=oid_method;return self}var Obj=_Class([{init:noop,oid:oid_method,destroy:function(){if(Class.unsubscribe_all){Class.unsubscribe_all(this)}for(var name in this){delete this[name]}}}]);var Class=function(){return _Class(arguments,Obj)};function singleton(){var klass=Class.apply(null,arguments);return new klass()}function isinstance(obj,klass){if(!obj.Class||typeof obj.Class!="function"){return false}if(obj.Class==klass){return true}var ancestors=obj.Class.ancestors;for(var i=0,n=ancestors.length;i<n;i++){if(ancestors[i]==klass){return true}}return false}function base_update(dict){return function(){return update(this.base(),dict)}}function mouse_xy(e){var posx=0;var posy=0;if(!e){var e=window.event}if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY}else{if(e.clientX||e.clientY){posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop}}return[posx,posy]}function gen_is_click_type(which,button){return function(e){if(!e){e=window.e}if(e.which){return e.which==which}if(e.button){return e.button==button}return false}}var is_left_click=gen_is_click_type(1,1);var is_right_click=gen_is_click_type(3,2);var Event=Class({init:function(dom_event){this.dom_event=dom_event;if(arguments.length==0||is_null(dom_event)){this._mouse_xy=null}else{this._mouse_xy=mouse_xy(dom_event);this._is_mouse_event=not_null(this._mouse_xy);this._is_left_click=is_left_click(dom_event);this._is_right_click=is_right_click(dom_event);this._set_key_down(dom_event,"shiftKey","_shift_key_down");this._set_key_down(dom_event,"altKey","_alt_key_down");this._set_key_down(dom_event,"ctrlKey","_ctrl_key_down")}},_set_key_down:function(dom_event,dom_name,new_name){try{this[new_name]=dom_event[dom_name]}catch(e){this[new_name]=false}},prevent_default:function(){var dom=this.dom_event;try{dom.preventDefault()}catch(e){dom.returnValue=false}},suppress:function(){this.prevent_default()},stop_propagation:function(){var dom=this.dom_event;try{dom.stopPropagation()}catch(e){dom.cancelBubble=true}},mouse_xy:function(){return this._mouse_xy},is_mouse_event:function(){return this._is_mouse_event==true},is_left_click:function(){return this._is_left_click==true},is_right_click:function(){return this._is_right_click==true},shift_key_down:function(){return this._shift_key_down==true},alt_key_down:function(){return this._alt_key_down==true},control_key_down:function(){return this._control_key_down==true}});var add_listener,remove_listener,remove_all_listeners;(function(){var subscribe=(function(){if(window.addEventListener){return function(dom,name,f){dom.addEventListener(name,f,false)}}else{if(window.attachEvent){return function(dom,name,f){dom.attachEvent("on"+name,f)}}}return noop})();var unsubscribe=(function(){if(window.removeEventListener){return function(dom,name,f){dom.removeEventListener(name,f,false)}}else{if(window.detachEvent){return function(dom,name,f){dom.detachEvent("on"+name,f)}}}return noop})();var listeners={};add_listener=function(dom,name,f,node){if(!node){node=null}function wrapped(e){var ev=new Event(e||window.event);f.call(node,ev)}subscribe(dom,name,wrapped);doa(listeners,name,[dom,f,wrapped])};remove_listener=function(dom,name,f){var l=listeners[name];if(!l){return }for(var i=l.length-1;i>=0;i--){var a=l[i];if(dom==a[0]&&f==a[1]){unsubscribe(dom,name,a[2])}}};remove_all_listeners=function(){pair_forall(listeners,function(name,keys){forall(keys,function(a){unsubscribe(a[0],name,a[2])})})}})();var graph=singleton({init:function(){this._arcs={};this._src_events_arcs={};this._dst_arcs={};this._unloader=getmeth(this,"destroy");add_listener(window,"unload",this._unloader)},destroy:function(){if(LINGO.detect.browser=="Explorer"){this._unload_arcs()}remove_listener(document.body,"unload",this._unloader);this.base()},_unload_arcs:function(){remove_all_listeners()},insert_arc:function(src,src_name,dst,dst_name){var arc=new Arc(src,src_name,dst,dst_name);this._arc_insert(arc);this._src_insert(arc);this._dst_insert(arc);return arc.oid()},_arc_insert:function(arc){this._arcs[arc.oid()]=arc},_src_insert:function(arc){var events_arcs=getset(this._src_events_arcs,arc.src_id(),dict_);var arcs=getset(events_arcs,arc.event_id(),dict_);arcs[arc.oid()]=arc},_dst_insert:function(arc){var arcs=getset(this._dst_arcs,arc.dst_id(),dict_);arcs[arc.oid()]=arc},remove_arc:function(arc_id){var arc=this._arcs[arc_id];if(!arc){return }this._remove_arc(arc)},_remove_arc:function(arc){var id=arc.oid();delete this._arcs[id];delete this._dst_arcs[arc.dst_id()][id];delete this._src_events_arcs[arc.src_id()][arc.event_id()][id];arc.destroy()},_obj_arc_ids:function(obj){var id=obj.oid();var arc_ids=[];var dst_arcs=this._dst_arcs[id];if(dst_arcs){arc_ids=concat(arc_ids,keys(dst_arcs))}var events_arcs=this._src_events_arcs[id];if(events_arcs){for(var event_id in events_arcs){arc_ids=concat(arc_ids,keys(events_arcs[event_id]))}}return arc_ids},remove_obj:function(obj){var arc_ids=this._obj_arc_ids(obj);forall(arc_ids,getmeth(this,"remove_arc"));var id=obj.oid();if(this._dst_arcs[id]){delete this._dst_arcs[id]}if(this._src_events_arcs[id]){delete this._src_events_arcs[id]}},_fire:function(src,event_id,obj,args){var event_to_arcs=this._src_events_arcs[src.oid()];if(!event_to_arcs){return }var arcs=event_to_arcs[event_id];if(!arcs){return }for(var arc_id in arcs){arcs[arc_id].fire(obj,args)}},fire:function(event_id,obj,args){this._fire(obj,event_id,obj,args);this._fire(obj.Class,event_id,obj,args);var ancestors=obj.Class.ancestors;for(var j=0,m=ancestors.length;j<m;j++){this._fire(ancestors[j],event_id,obj,args)}}});var Arc=Class({init:function(src,src_name,dst,dst_name){this.src=src;this.src_name=src_name;this.dst=dst;this.dst_name=dst_name;if(!src.is_class&&!src[src_name]){this.on();this._event_id=src_name;this.is_native=true}else{var event=src.is_class?src.prototype[src_name]:src[src_name];this._event_id=event.fire.oid();this.is_native=false}},on:function(){ass(this.src.is_node,"src must be a node");this.src.on(this.src_name,this.callback())},src_id:function(){return this.src.oid()},dst_id:function(){return this.dst.oid()},event_id:function(){return this._event_id},fire:function(obj,args){this.callback().apply(obj,args)},callback:function(){if(!this._callback){var dst=this.dst;var method=dst[this.dst_name];var self=this;this._callback=function(){var args=concat([this],arguments);return method.apply(dst,args)}}return this._callback},destroy:function(){if(this.is_native){this.src.unsubscribe(this.src_name,this.callback())}}});var after=getmeth(graph,"insert_arc");Class.unsubscribe_all=getmeth(graph,"remove_obj");function gen_fire(){function fire(){graph.fire(fire.oid(),this,arguments)}fire.oid=oid_method;return fire}function event(inner){if(!inner){inner=noop}function outer(){var result=inner.apply(this,arguments);outer.fire.apply(this,arguments);return result}outer.inner=inner;outer.fire=gen_fire();return outer}var KEY_REPEAT_DELAY=25;var Key_watcher=Class({init:function(key_data){this.key=key_data.key;this.shift=key_data.shift||false;this.alt=key_data.alt||false;this.ctrl=key_data.ctrl||false},key_down:function(node,my_event){var e=my_event.dom_event;var e_key=e.charCode||e.keyCode;if(e.shiftKey==this.shift&&e.altKey==this.alt&&e.ctrlKey==this.ctrl&&e_key==this.key){this.fire.apply(this,arguments)}},fire:event()});function after_key(src,key_data,dst,dst_name){var watcher=new Key_watcher(key_data);after(src,"keydown",watcher,"key_down");after(watcher,"fire",dst,dst_name)}function identity_field(parent,child){return child}function gen_field(){if(arguments.length==0){return identity_field}var model=arguments[0];var is_collection=_is_array(model);if(is_collection){if(model.length==0){return identity_field}model=model[0]}var copies=arguments.length>=2?arguments[1]:null;if(copies){copies=map(copies.split(", "),function(copy){return copy.split("=")})}function create(parent,child_data){if(copies){forall(copies,function(copy){var src=copy[0];var dst=copy.length>=2?copy[1]:src;ass(typeof parent[src]=="function","no copy attr");child_data[dst]=parent[src]()})}return new model(child_data)}return !is_collection?create:function(parent,child_data_array){return map(child_data_array,partial(create,parent))}}var required=gen_field;var optional=gen_field;var MODEL_ATTR="_model_data";function Model(schema){var body=arguments[arguments.length-1];var old_init=body.init;body.init=function(data){ass(typeof data=="object","in model: typeof data != object");var attr=this[MODEL_ATTR]={};var self=this;pair_forall(schema,function(name,field){attr[name]=field(self,data[name])});if(old_init){old_init.apply(this,arguments)}};for(var name in schema){ass(!body[name],"should not have attr");body[name]=prop(MODEL_ATTR,name)}return Class.apply(null,slice(arguments,1))}__[16]=(function(){function noop(){return null}var STATUS={OK:200,RETRY:202,BAD_REQUEST:400,SERVER_ERROR:500};function gen_connect(append_js,respond_path){var connect={requests:{}};connect.request=gen_request(connect,append_js,respond_path);connect.request_embed=gen_request_embed(connect);connect.respond=gen_respond(connect);return connect}function gen_request(connect,append_js,respond_path){return function(request){var try_count=request.try_count?++request.try_count:request.try_count=1;var key=request.key;var url=request.url_root;if(try_count==1){connect.requests[key]=request}else{if(typeof request.add_retry!="boolean"||request.add_retry){url+="_retry"}}if(request.url_suffix){url+="/"+request.url_suffix}url+="/?request_id="+key+"&respond_path="+respond_path+"&try="+try_count+"&"+request.url_args;append_js(url)}}function gen_respond(connect){return function(response){var key=response.key;var request=connect.requests[key];switch(response.status){case STATUS.OK:case"ok":request.response=response;(request.callback||noop)(request);break;case STATUS.RETRY:case"retry":var delay=(request.retry_delay||noop)();var retry=function(){connect.request(request)};if(delay==0){retry()}else{if(delay){setTimeout(retry,delay)}else{if(request.timeout_callback){request.timeout_callback(request)}}}break;case STATUS.BAD_REQUEST:case STATUS.SERVER_ERROR:case"error":if(request.error_callback){request.response=response;request.error_callback(request)}break;default:break}}}function gen_request_embed(connect){return function(){var request=create_embed_request.apply(null,arguments);connect.request(request)}}function create_embed_request(key,parent_id,url_root,url_args,on_dom,callback,timeout_callback){return{url_root:url_root,url_args:url_args,add_retry:false,retry_delay:gen_retry_delay(),callback:gen_embed_callback(parent_id,on_dom,callback),timeout_callback:timeout_callback,key:key}}function gen_embed_callback(parent_id,on_dom,callback){return function(request){var response=request.response;if(typeof parent_id=="function"){parent_id=parent_id()}var response=request.response;var content=response.content;var dom_callback=function(){var parent=document.getElementById(parent_id);callback(parent,response,embed_content)};on_dom(dom_callback)}}function gen_retry_delay(){var max_count=6;var count=0;return function(){if(count++>max_count){return null}return 1000}}function embed_content(parent,content){var markup=content.doc;var js=content.js;var css=content.css;if(css&&parent.id){css=css.replace(/#LINGO/g,"#"+parent.id)}if(css){create_css(css)}if(js){eval(js)}parent.innerHTML=markup;setTimeout(function(){parent.style.display="block"},250)}function create_css(bundleStyle){var newSS=document.createElement("style");newSS.setAttribute("type","text/css");if(newSS.styleSheet){newSS.styleSheet.cssText=bundleStyle}else{var cssText=document.createTextNode(bundleStyle);newSS.appendChild(cssText)}document.getElementsByTagName("head")[0].appendChild(newSS)}return[STATUS,gen_connect]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[19]=(function(){var detect={init:function(){this.browser=this._searchString(this._dataBrowser)||"An unknown browser";this.version=this._searchVersion(navigator.userAgent)||this._searchVersion(navigator.appVersion)||"an unknown version";this.OS=this._searchString(this.dataOS)||"an unknown OS"},_searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i]._string;var dataProp=data[i].prop;this.version_searchString=data[i]._versionSearch||data[i]._identity;if(dataString){if(dataString.indexOf(data[i]._subString)!=-1){return data[i]._identity}}else{if(dataProp){return data[i]._identity}}}},_searchVersion:function(dataString){var index=dataString.indexOf(this.version_searchString);if(index==-1){return }return parseFloat(dataString.substring(index+this.version_searchString.length+1))},_dataBrowser:[{_string:navigator.userAgent,_subString:"Chrome",_identity:"Chrome"},{_string:navigator.userAgent,_subString:"OmniWeb",_versionSearch:"OmniWeb/",_identity:"OmniWeb"},{_string:navigator.vendor,_subString:"Apple",_identity:"Safari"},{prop:window.opera,_identity:"Opera"},{_string:navigator.vendor,_subString:"iCab",_identity:"iCab"},{_string:navigator.vendor,_subString:"KDE",_identity:"Konqueror"},{_string:navigator.userAgent,_subString:"Firefox",_identity:"Firefox"},{_string:navigator.vendor,_subString:"Camino",_identity:"Camino"},{_string:navigator.userAgent,_subString:"Netscape",_identity:"Netscape"},{_string:navigator.userAgent,_subString:"MSIE",_identity:"Explorer",_versionSearch:"MSIE"},{_string:navigator.userAgent,_subString:"Gecko",_identity:"Mozilla",_versionSearch:"rv"},{_string:navigator.userAgent,_subString:"Mozilla",_identity:"Netscape",_versionSearch:"Mozilla"}],dataOS:[{_string:navigator.platform,_subString:"Win",_identity:"Windows"},{_string:navigator.platform,_subString:"Mac",_identity:"Mac"},{_string:navigator.userAgent,_subString:"iPhone",_identity:"iPhone/iPod"},{_string:navigator.platform,_subString:"Linux",_identity:"Linux"}]};detect.init();var b=detect.browser;var browser={ie:b=="Explorer",firefox:b=="Firefox",safari:b=="Safari",opera:b=="Opera"};return[detect,browser]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[18]=(function(){function noop(){}function now(){return(new Date()).getTime()}function get_cookie(key){var allCookies=document.cookie;var i=allCookies.indexOf(key+"=");if(i==-1){return null}var start=i+key.length+1;var end=allCookies.indexOf(";",start);if(end==-1){end=allCookies.length}var escapedValue=allCookies.substring(start,end);return unescape(escapedValue)}function on_load(callback){if(window.addEventListener){window.addEventListener("load",callback,false)}else{if(window.attachEvent){window.attachEvent("onload",callback)}}}function append_js(url){var script=document.createElement("script");script.setAttribute("type","text/javascript");script.setAttribute("language","javascript");script.setAttribute("src",url);var head=document.getElementsByTagName("head")[0];head.appendChild(script)}function get_by_class_prefix(class_prefix){var root=document;var nodes=root.getElementsByTagName("*");if(!nodes.length&&root.all){nodes=root.all}var re=new RegExp("(?:^|\\s+)"+class_prefix);function pred(node){return re.test(node.className)}var found_nodes=[];for(var i=0,n=nodes.length;i<n;i++){if(pred(nodes[i])){found_nodes.push(nodes[i])}}return found_nodes}function query_split(query){var args={};var pairs=query.split("&");for(var i=0;i<pairs.length;i++){var pair=pairs[i].split("=");args[pair[0]]=pair[1]}return args}function query_join(args){var keys=[];for(key in args){keys.push(key)}keys.sort();var q="",key;for(var i=0,n=keys.length;i<n;i++){key=keys[i];q+=key+"="+args[key]+"&"}return q.substring(0,q.length-1)}function encode(str){return typeof encodeURIComponent=="function"?encodeURIComponent(str):escape(str)}return[get_cookie,query_split,on_load,get_by_class_prefix,query_join,noop,append_js,encode,now]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[13]=(function(){var L=LINGO;var timestamps=L.timestamps;var epoch=timestamps.epoch;function elapsed(){return now()-epoch}var State=Class({init:function(){this._init_args=arguments},enter:event(function(){this._enter_time=elapsed()}),exit:event(),enter_time:function(){return this._enter_time},elapsed:function(){return elapsed()-this._enter_time},kill:noop});var Clean_state=Class(State,{kill:function(){this.destroy()}});var Machine=Class({init:function(start){this._states=[{exit:noop,kill:noop}];this._state_insert("init",start,0)},_state_insert:function(arc_name,state,i){var states=this._states;while(states.length>i){var doomed=states.pop();doomed.exit(arc_name);doomed.kill()}while(state){if(states.length>0){state.parent=states[states.length-1]}states.push(state);state.enter(arc_name);state=state.start?state.start.apply(state,state._init_args):null}},_state_lookup:function(name){var states=this._states;for(var i=0,n=states.length;i<n;i++){if(states[i][name]){return i}}throw new Error("invalid state method: "+name)},delegate:function(name,args){var states=this._states;var i=this._state_lookup(name);var old=this.$;this.$=states[i];var method=this.$[name];var result=args?method.apply(this,args):method.apply(this);old?this.$=old:delete this.$;if(this._arc){this._state_insert(name,this._arc,i);delete this._arc}else{if(this._sharc){this._state_insert(name,this._sharc,i+1);delete this._sharc}}return result},in_state:function(State){var states=this._states;for(var i=0,n=states.length;i<n;i++){if(isinstance(states[i],State)){return true}}return false},arc:function(next){this._arc=next},sharc:function(next){this._sharc=next}});function arc(name){return function(){return this.delegate(name,arguments)}}return[Machine,State,arc,Clean_state,timestamps,elapsed]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[17]=(function(){var YAHOO={};YAHOO.namespace=function(){var a=arguments,o=null,i,j,d;for(i=0;i<a.length;i=i+1){d=a[i].split(".");o=YAHOO;for(j=(d[0]=="YAHOO")?1:0;j<d.length;j=j+1){o[d[j]]=o[d[j]]||{};o=o[d[j]]}}return o};YAHOO.log=function(msg,cat,src){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(msg,cat,src)}else{return false}};YAHOO.init=function(){this.namespace("util","widget","example");if(typeof YAHOO_config!="undefined"){var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;if(l){for(i=0;i<ls.length;i=i+1){if(ls[i]==l){unique=false;break}}if(unique){ls.push(l)}}}};YAHOO.register=function(name,mainClass,data){var mods=YAHOO.env.modules;if(!mods[name]){mods[name]={versions:[],builds:[]}}var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners;m.name=name;m.version=v;m.build=b;m.versions.push(v);m.builds.push(b);m.mainClass=mainClass;for(var i=0;i<ls.length;i=i+1){ls[i](m)}if(mainClass){mainClass.VERSION=v;mainClass.BUILD=b}else{YAHOO.log("mainClass is undefined for module "+name,"warn")}};YAHOO.env=YAHOO.env||{modules:[],listeners:[],getVersion:function(name){return YAHOO.env.modules[name]||null}};YAHOO.lang={isArray:function(obj){if(obj&&obj.constructor){try{if(obj.constructor.toString().indexOf("Array")>-1){return true}}catch(e){}}return YAHOO.lang.isObject(obj)&&obj.constructor==Array},isBoolean:function(obj){return typeof obj=="boolean"},isFunction:function(obj){return typeof obj=="function"},isNull:function(obj){return obj===null},isNumber:function(obj){return typeof obj=="number"&&isFinite(obj)},isObject:function(obj){return obj&&(typeof obj=="object"||YAHOO.lang.isFunction(obj))},isString:function(obj){return typeof obj=="string"},isUndefined:function(obj){return typeof obj=="undefined"},hasOwnProperty:function(obj,prop){if(Object.prototype.hasOwnProperty){return obj.hasOwnProperty(prop)}return !YAHOO.lang.isUndefined(obj[prop])&&obj.constructor.prototype[prop]!==obj[prop]},extend:function(subc,superc,overrides){if(!superc||!subc){throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.")}var F=function(){};F.prototype=superc.prototype;subc.prototype=new F();subc.prototype.constructor=subc;subc.superclass=superc.prototype;if(superc.prototype.constructor==Object.prototype.constructor){superc.prototype.constructor=superc}if(overrides){for(var i in overrides){subc.prototype[i]=overrides[i]}}},augment:function(r,s){if(!s||!r){throw new Error("YAHOO.lang.augment failed, please check that all dependencies are included.")}var rp=r.prototype,sp=s.prototype,a=arguments,i,p;if(a[2]){for(i=2;i<a.length;i=i+1){rp[a[i]]=sp[a[i]]}}else{for(p in sp){if(!rp[p]){rp[p]=sp[p]}}}}};YAHOO.init();YAHOO.util.Lang=YAHOO.lang;YAHOO.augment=YAHOO.lang.augment;YAHOO.extend=YAHOO.lang.extend;YAHOO.register("yahoo",YAHOO,{version:"2.2.1",build:"193"});return[YAHOO]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[8]=(function(){function field(name,klass,group_dimensions){return function(){var serial=this.serial()[name];if(serial==null){return serial}if(group_dimensions==null){return atom_from_serial(serial,klass)}else{return group_from_serial(serial,klass,group_dimensions)}}}function atom_from_serial(serial_atom,klass){return klass?new klass(serial_atom):serial_atom}function group_from_serial(serial_group,klass,dimensions){if(dimensions==1){return map(serial_group,function(serial_atom){return atom_from_serial(serial_atom,klass)})}else{return map(serial_group,function(sub_group){return group_from_serial(sub_group,klass,dimensions-1)})}}var Solid=Class({init:function(serial){this._serial=serial},serial:function(){return this._serial}});function escaped_query_join(args){var escaped={};for(var key in args){escaped[key]=escape(args[key])}return query_join(escaped)}var Url=Class(Solid,{host:field("host"),path:field("path"),args:field("args"),url:function(){return this.abs_path()+this._query_str()},abs_path:function(){return this.host()+this._path_str()},query:function(){return escaped_query_join(this.args())},_path_str:function(){return this.path()&&this.path().length>0?"/"+this.path():""},_query_str:function(){return this.query().length>0?"?"+this.query():""},with_new_args:function(args){var new_args=update(null,this.args(),args);return new Url({host:this.host(),path:this.path(),args:new_args})},toString:_("Url")});var App=Class(Solid,{key:field("key"),class_key:field("class_key"),run:function(response){}});var Request=Class(Solid,{term:field("term"),prio:field("prio"),hash:field("hash"),retry_url:field("retry_url",Url),app:function(){if(!this._app){this._app=App.get(this.serial().app)}return this._app}});var Response=Class(Solid,{status:field("status"),_quality:field("quality"),request:field("request",Request),content:field("content"),quality:function(){return this._quality()||"good"},is_retry:function(){return this.status()==202},is_good:function(){return this.quality()=="good"},app:function(){return this.request().app()},clone:function(serial){var new_serial=update(null,this.serial(),serial);return new Response(new_serial)},run:function(){this.app().run(this)}});Request.prototype.referrer_response=field("referrer_response",Response);Request.prototype.child_responses=field("child_responses",Response,1);Request.prototype.cols=field("cols",App,2);var registry={};App.register=function(class_key,klass){ass(!registry[class_key],"App class key already registered, key = "+class_key);registry[class_key]=klass};App.get=function(serial){var class_key=serial.class_key;ass(registry[class_key],"App class key not registered, key = "+class_key);klass=registry[class_key];return new klass(serial)};LINGO.respond=function(serial_response){var response=new Response(serial_response);response.run()};LINGO.run=function(){var responses=LINGO.responses||[];delete LINGO.responses;forall(responses,LINGO.respond)};return[App]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[15]=(function(){var on_load=__[18][2],browser=__[19][1];function gen_on_dom(){var _is_ready=false;function is_ready(){return _is_ready}var q=[];function on_dom(callback){_is_ready?callback():q.push(callback)}function ready(){if(_is_ready){return }_is_ready=true;for(var i=0,n=q.length;i<n;i++){q[i]()}}run(ready,is_ready);return on_dom}function run(ready,is_ready){if(!browser.opera){best(ready)}if(browser.opera){opera(ready)}if(browser.ie){ie(ready,is_ready)}if(browser.safari){safari(ready,is_ready)}fallback(ready,is_ready)}function best(ready){if(document.addEventListener){document.addEventListener("DOMContentLoaded",ready,false)}}function opera(ready){document.addEventListener("DOMContentLoaded",function(){for(var i=0;i<document.styleSheets.length;i++){if(document.styleSheets[i].disabled){setTimeout(arguments.callee,0);return }}ready()},false)}function ie(ready,is_ready){if(window!=top){return }(function(){if(is_ready()){return }try{document.documentElement.doScroll("left")}catch(error){setTimeout(arguments.callee,0);return }ready()})()}function safari(ready,is_ready){var num_styles;(function(){if(is_ready()){return }if(document.readyState!="loaded"&&document.readyState!="complete"){setTimeout(arguments.callee,0);return }if(num_styles===undefined){num_styles=0;var styles=document.getElementsByTagName("style");if(styles){num_styles+=styles.length}var links=document.getElementsByTagName("link");if(links){for(var i=0,n=links.length;i<n;i++){if(links[i].getAttribute("rel")=="stylesheet"){num_styles++}}}}if(document.styleSheets.length!=num_styles){setTimeout(arguments.callee,0);return }ready()})()}function fallback(ready){on_load(ready)}return[gen_on_dom]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[14]=(function(){var YAHOO=__[17][0];(function(){var Y=YAHOO.util,getStyle,setStyle,propertyCache={};var ua=navigator.userAgent.toLowerCase(),isOpera=(ua.indexOf("opera")>-1),isSafari=(ua.indexOf("safari")>-1),isGecko=(!isOpera&&!isSafari&&ua.indexOf("gecko")>-1),isIE=(!isOpera&&ua.indexOf("msie")>-1);var patterns={HYPHEN:/(-[a-z])/i,ROOT_TAG:/body|html/i};var toCamel=function(property){if(!patterns.HYPHEN.test(property)){return property}if(propertyCache[property]){return propertyCache[property]}var converted=property;while(patterns.HYPHEN.exec(converted)){converted=converted.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase())}propertyCache[property]=converted;return converted};if(document.defaultView&&document.defaultView.getComputedStyle){getStyle=function(el,property){var value=null;if(property=="float"){property="cssFloat"}var computed=document.defaultView.getComputedStyle(el,"");if(computed){value=computed[toCamel(property)]}try{return el.style[property]||value}catch(e){}}}else{if(document.documentElement.currentStyle&&isIE){getStyle=function(el,property){switch(toCamel(property)){case"opacity":var val=100;try{val=el.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(e){try{val=el.filters("alpha").opacity}catch(e){}}return val/100;break;case"float":property="styleFloat";default:var value=el.currentStyle?el.currentStyle[property]:null;return(el.style[property]||value)}}}else{getStyle=function(el,property){return el.style[property]}}}if(isIE){setStyle=function(el,property,val){switch(property){case"opacity":if(YAHOO.lang.isString(el.style.filter)){el.style.filter="alpha(opacity="+val*100+")";if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1}}break;case"float":property="styleFloat";default:try{el.style[property]=val}catch(e){throw new Error("invalid ie css property: "+property+", value: "+val+", el: "+el)}}}}else{setStyle=function(el,property,val){if(property=="float"){property="cssFloat"}try{el.style[property]=val}catch(e){throw new Error("invalid ie css property: "+property+", value: "+val+", el: "+el)}}}YAHOO.util.Dom={get:function(el){if(YAHOO.lang.isString(el)){return document.getElementById(el)}if(YAHOO.lang.isArray(el)){var c=[];for(var i=0,len=el.length;i<len;++i){c[c.length]=Y.Dom.get(el[i])}return c}if(el){return el}return null},getStyle:function(el,property){property=toCamel(property);var f=function(element){return getStyle(element,property)};return Y.Dom.batch(el,f,Y.Dom,true)},setStyle:function(el,property,val){property=toCamel(property);var f=function(element){setStyle(element,property,val)};Y.Dom.batch(el,f,Y.Dom,true)},getXY:function(el){var f=function(el){if((el.parentNode===null||el.offsetParent===null||this.getStyle(el,"display")=="none")&&el!=document.body){return false}var parentNode=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var doc=document;if(!this.inDocument(el)&&parent.document!=document){doc=parent.document;if(!this.isAncestor(doc.documentElement,el)){return false}}var scrollTop=Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);var scrollLeft=Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);return[box.left+scrollLeft,box.top+scrollTop]}else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;var hasAbs=this.getStyle(el,"position")=="absolute";if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;if(isSafari&&!hasAbs&&this.getStyle(parentNode,"position")=="absolute"){hasAbs=true}parentNode=parentNode.offsetParent}}if(isSafari&&hasAbs){pos[0]-=document.body.offsetLeft;pos[1]-=document.body.offsetTop}}parentNode=el.parentNode;while(parentNode.tagName&&!patterns.ROOT_TAG.test(parentNode.tagName)){if(isOpera&&Y.Dom.getStyle(parentNode,"display")!="inline"){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop}parentNode=parentNode.parentNode}return pos};return Y.Dom.batch(el,f,Y.Dom,true)},getX:function(el){var f=function(el){return Y.Dom.getXY(el)[0]};return Y.Dom.batch(el,f,Y.Dom,true)},getY:function(el){var f=function(el){return Y.Dom.getXY(el)[1]};return Y.Dom.batch(el,f,Y.Dom,true)},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=this.getStyle(el,"position");if(style_pos=="static"){this.setStyle(el,"position","relative");style_pos="relative"}var pageXY=this.getXY(el);if(pageXY===false){return false}var delta=[parseInt(this.getStyle(el,"left"),10),parseInt(this.getStyle(el,"top"),10)];if(isNaN(delta[0])){delta[0]=(style_pos=="relative")?0:el.offsetLeft}if(isNaN(delta[1])){delta[1]=(style_pos=="relative")?0:el.offsetTop}if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+"px"}if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+"px"}if(!noRetry){var newXY=this.getXY(el);if((pos[0]!==null&&newXY[0]!=pos[0])||(pos[1]!==null&&newXY[1]!=pos[1])){this.setXY(el,pos,true)}}};Y.Dom.batch(el,f,Y.Dom,true)},setX:function(el,x){Y.Dom.setXY(el,[x,null])},setY:function(el,y){Y.Dom.setXY(el,[null,y])},getElementsByClassName:function(className,tag,root){var method=function(el){return Y.Dom.hasClass(el,className)};return Y.Dom.getElementsBy(method,tag,root)},hasClass:function(el,className){var re=new RegExp("(?:^|\\s+)"+className+"(?:\\s+|$)");var f=function(el){return re.test(el.className)};return Y.Dom.batch(el,f,Y.Dom,true)},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return }el.className=[el.className,className].join(" ")};Y.Dom.batch(el,f,Y.Dom,true)},removeClass:function(el,className){var re=new RegExp("(?:^|\\s+)"+className+"(?:\\s+|$)","g");var f=function(el){if(!this.hasClass(el,className)){return }var c=el.className;el.className=c.replace(re," ");if(this.hasClass(el,className)){this.removeClass(el,className)}};Y.Dom.batch(el,f,Y.Dom,true)},replaceClass:function(el,oldClassName,newClassName){if(oldClassName===newClassName){return false}var re=new RegExp("(?:^|\\s+)"+oldClassName+"(?:\\s+|$)","g");var f=function(el){if(!this.hasClass(el,oldClassName)){this.addClass(el,newClassName);return }el.className=el.className.replace(re," "+newClassName+" ");if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName)}};Y.Dom.batch(el,f,Y.Dom,true)},isAncestor:function(haystack,needle){haystack=Y.Dom.get(haystack);if(!haystack||!needle){return false}var f=function(needle){if(haystack.contains&&!isSafari){return haystack.contains(needle)}else{if(haystack.compareDocumentPosition){return !!(haystack.compareDocumentPosition(needle)&16)}else{var parent=needle.parentNode;while(parent){if(parent==haystack){return true}else{if(!parent.tagName||parent.tagName.toUpperCase()=="HTML"){return false}}parent=parent.parentNode}return false}}};return Y.Dom.batch(needle,f,Y.Dom,true)},inDocument:function(el){var f=function(el){return this.isAncestor(document.documentElement,el)};return Y.Dom.batch(el,f,Y.Dom,true)},getElementsBy:function(method,tag,root){tag=tag||"*";var nodes=[];if(root){root=Y.Dom.get(root);if(!root){return nodes}}else{root=document}var elements=root.getElementsByTagName(tag);if(!elements.length&&(tag=="*"&&root.all)){elements=root.all}for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i]}}return nodes},batch:function(el,method,o,override){var id=el;el=Y.Dom.get(el);var scope=(override)?o:window;if(!el||el.tagName||!el.length){if(!el){return false}return method.call(scope,el,o)}var collection=[];for(var i=0,len=el.length;i<len;++i){if(!el[i]){id=el[i]}collection[collection.length]=method.call(scope,el[i],o)}return collection},getDocumentHeight:function(){var scrollHeight=(document.compatMode!="CSS1Compat")?document.body.scrollHeight:document.documentElement.scrollHeight;var h=Math.max(scrollHeight,Y.Dom.getViewportHeight());return h},getDocumentWidth:function(){var scrollWidth=(document.compatMode!="CSS1Compat")?document.body.scrollWidth:document.documentElement.scrollWidth;var w=Math.max(scrollWidth,Y.Dom.getViewportWidth());return w},getViewportHeight:function(){var height=self.innerHeight;var mode=document.compatMode;if((mode||isIE)&&!isOpera){height=(mode=="CSS1Compat")?document.documentElement.clientHeight:document.body.clientHeight}return height},getViewportWidth:function(){var width=self.innerWidth;var mode=document.compatMode;if(mode||isIE){width=(mode=="CSS1Compat")?document.documentElement.clientWidth:document.body.clientWidth}return width}}})();YAHOO.register("dom",YAHOO.util.Dom,{version:"2.2.1",build:"193"});var Dom=YAHOO.util.Dom;return[YAHOO,Dom]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[9]=(function(){var D=__[14][1];var get=D.get;var get_by=D.getElementsBy;var get_by_class=D.getElementsByClassName;var get_viewport_width=D.getViewportWidth;var get_viewport_height=D.getViewportHeight;var get_doc_width=D.getDocumentWidth;var get_doc_height=D.getDocumentHeight;var get_xy=D.getXY;var set_xy=D.setXY;var get_style=D.getStyle;var set_style=D.setStyle;var has_class=D.hasClass;var add_class=D.addClass;var remove_class=D.removeClass;function get_by_tag(tag){return concat(document.getElementsByTagName(tag))}function get_selected_text(){try{if(not_null(window.getSelection)){var query=window.getSelection()+""}else{if(not_null(document.selection)){var range=document.selection.createRange();var query=not_null(range)?range.text:""}else{var query=""}}return query}catch(e){return""}}function count_reg_exp(str,re){var i=0;var base=0;var count=0;var i=str.search(re);while(i!=-1&&base<str.length){count++;base=base+i+1;i=str.substring(base).search(re)}return count}function close_tags(text){var opens=count_reg_exp(text,/<b>/i);var closes=count_reg_exp(text,/<\/b>/i);while(opens>closes){opens--;text=text+"</b>"}return text}function trim_text(node,suffix,delim,delta){var node=node.obj();if(is_null(suffix)){suffix="..."}if(is_null(delim)){delim=/(. |[^<]\/)/g}if(is_null(delta)){delta=5}var parentNode=node.parentNode;var parentWidth=parentNode.offsetWidth;if(typeof parentWidth!="number"){return }if(node.offsetWidth<=parentWidth){return false}var fullText=node.innerHTML;var bestText=null;var currentText=null;var matchIndex=fullText.search(delim);if(matchIndex>=0){matchIndex++}var baseIndex=0;while(matchIndex>=0){currentText=fullText.substring(0,baseIndex+matchIndex)+suffix;node.innerHTML=currentText;if(node.offsetWidth>=parentWidth){break}bestText=currentText;baseIndex=baseIndex+matchIndex+1;matchIndex=fullText.substr(baseIndex).search(delim);if(matchIndex>=0){matchIndex++}}if(bestText!=null){node.innerHTML=close_tags(bestText);if(node.tagName=="A"){var t=fullText.replace("<b>","");t=t.replace("<B>","");t=t.replace("</b>","");t=t.replace("</B>","");node.setAttribute("title",t)}return true}for(var i=1;i<fullText.length;i+=delta){currentText=fullText.substr(0,i)+suffix;node.innerHTML=currentText;if(node.offsetWidth>parentWidth){break}bestText=currentText}if(not_null(bestText)){node.innerHTML=close_tags(bestText);if(node.tagName=="A"){var t=fullText.replace("<b>","");t=t.replace("<B>","");t=t.replace("</b>","");t=t.replace("</B>","");node.setAttribute("title",t)}return true}throw new Error("trim text failed")}return[get_style,set_style,get_viewport_width,get,get_by_class,get_by_tag,get_by,add_class,set_xy,trim_text,has_class,remove_class,get_viewport_height,get_selected_text,get_xy,get_doc_height,get_doc_width]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[12]=(function(){var dom=__[14],get_viewport_width=__[9][2],get_viewport_height=__[9][12];var Point=Class({init:function(x,y){this.x(x);this.y(y)},x:property("_x"),y:property("_y"),toString:_("Point")});var Region=Class({init:function(t,r,b,l){this.top(t);this.right(r);this.bottom(b);this.left(l)},copy:function(){return new (this.Class)(this.top(),this.right(),this.bottom(),this.left())},top:property("_t"),right:property("_r"),bottom:property("_b"),left:property("_l"),xy:function(xy){if(arguments.length==0){return[this.left(),this.top()]}this.left(xy[0]);this.top(xy[1])},height:function(){return this.bottom()-this.top()},width:function(){return this.right()-this.left()},area:function(){return this.height()*this.width()},crosses_x:function(x){return this.right()>=x&&this.left()<=x},crosses_y:function(y){return this.bottom()>=y&&this.top()<=y},intersect:function(region){var t=Math.max(this.top(),region.top());var r=Math.min(this.right(),region.right());var b=Math.min(this.bottom(),region.bottom());var l=Math.max(this.left(),region.left());return(b>=t&&r>=l)?new (this.Class)(t,r,b,l):null},toString2:function(){return"l:"+this.left()+", r:"+this.right()+", t:"+this.top()+", b:"+this.bottom()}});function screen(){var view_width=get_viewport_width();var view_height=get_viewport_height();var top=document.body.scrollTop+document.documentElement.scrollTop;var bottom=top+view_height;var left=document.body.scrollLeft+document.documentElement.scrollLeft;var right=left+view_width;return new Region(top,right,bottom,left)}return[Region,screen]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[10]=(function(){var get_by=__[9][6],get_by_class=__[9][4],get_xy=__[9][14],set_xy=__[9][8],get_style=__[9][0],set_style=__[9][1],has_class=__[9][10],add_class=__[9][7],remove_class=__[9][11],Region=__[12][0],State=__[13][1],Machine=__[13][0],arc=__[13][2];var Local_mixin=Class(State,{hide:function(){if(this.is_visible()){var node=this.obj();if(!node[_SAVED_DISPLAY_STYLE]){node[_SAVED_DISPLAY_STYLE]=this.style("display")}this.style("display","none")}return this},show:function(value){if(this._fetch_on_show&&this.in_state(this.shared.LOCAL_REMOTE)){this.fetch()}if(!this.is_visible()){var node=this.obj();this.style("display",value||node[_SAVED_DISPLAY_STYLE]||"block");node[_SAVED_DISPLAY_STYLE]=null}return this},style:function(arg,value){if(typeof arg=="string"){var name=arg;if(arguments.length==1){return get_style(this.obj(),name)}set_style(this.obj(),name,value)}else{ass(typeof arg=="object"&&arguments.length==1,"invalid args");pair_forall(arg,getmeth(this,"style"))}return this},classes:function(){var dom=this.obj();if(arguments.length==0){return dom.className}dom.className="";apply(this,"add_classes",arguments);return this},has_class:function(class_name){return has_class(this.obj(),class_name)},add_classes:function(){forall(arguments,partial(add_class,this.obj()));return this},remove_classes:function(){forall(arguments,partial(remove_class,this.obj()));return this},mark:function(){return this},id:function(value){if(arguments.length==0){return this.attr("id")}this.attr("id",value);return this},attr:function(arg,value){if(typeof arg=="string"){var name=arg;ass(name!="name","breaks ie");var dom=this.obj();if(arguments.length==1){return dom.getAttribute(name)||null}dom.setAttribute(name,value)}else{ass(arguments.length==1&&typeof arg=="object","invalid args");pair_forall(arg,getmeth(this,"attr"))}return this},len:function(){return this.obj().childNodes.length},insert:function(){var self=this;var dom=this.obj();forall(arguments,function(new_child){var old_child=new_child;new_child=self.coerce(new_child);dom.appendChild(new_child.obj())})},insert_before:function(before_me){var parent=this.parent().obj();var me=this.obj();before_me=this.coerce(before_me).obj();parent.insertBefore(before_me,me)},insert_after:function(after_me){var parent=this.parent().obj();var me=this.obj();after_me=this.coerce(after_me).obj();if(me.nextSibling){parent.insertBefore(after_me,me.nextSibling)}else{parent.appendChild(after_me)}},_get_children:function(){try{var r=[];var c=this.obj().childNodes;for(var i=0,n=c.length;i<n;i++){r.push(this.coerce(c[i]))}return r}catch(e){throw e}},append:function(){throw new Error();var self=this;var dom=this.obj();forall(arguments,function(new_child){var old_child=new_child;new_child=self.coerce(new_child);dom.appendChild(new_child.obj())})},_remove_child:function(child){child=this.coerce(child);if(child.has_parent()&&child.parent().obj()==this.obj()){this.obj().removeChild(child.obj())}},replace_child:function(old_child,new_child){old_child=this.coerce(old_child);new_child=this.coerce(new_child);this.obj().replaceChild(new_child.obj(),old_child.obj())},get_by:function(tag,class_name,method){var dom=this.obj();var results=null;if(arguments.length==1){results=dom.getElementsByTagName(tag)}else{if(arguments.length==2){results=get_by_class(class_name,tag,dom)}else{if(arguments.length==3){var f=method;if(typeof class_name!="undefined"&&class_name!=null){f=function(node){return this.coerce(node).has_class(class_name)&&method(node)}}results=get_by(f,tag,dom)}else{throw new Error("1-3 args required")}}}return map(results,getmeth(this,"coerce"))},get_by_tag:function(tag_name){return this.get_by(tag_name)},get_by_class:function(class_name){return this.get_by(null,class_name)},toString:_("Local_mixin")});var LOCAL=singleton(Local_mixin,{fetch:function(callback){if(typeof callback=="function"){callback(this)}},destroy:noop,tag:function(){var dom=this.obj();return dom.frames?"":dom.tagName},xy:function(new_xy){var dom=this.obj();if(arguments.length==0){return get_xy(dom)}return set_xy(dom,new_xy)},region:function(){var dom=this.obj();var width=dom.offsetWidth;var height=dom.offsetHeight;var xy=this.xy();var left=xy[0];var top=xy[1];return new Region(top,left+width,top+height,left)}});var REMOTE=singleton(State,{attr:function(arg,value){if(!this._attr){this._attr={}}var attr=this._attr;if(typeof arg=="string"){if(arguments.length==1){return attr[arg]}attr[arg]=value}else{update(attr,arg)}return this},has_class:function(name){return this._classes?this._classes[name]&&true:false},classes:function(){var classes=this._classes={};forall(arguments,function(name){classes[name]=true});return this},add_classes:function(){if(!this._classes){this._classes={}}for(var i=0,n=arguments.length;i<n;i++){this._classes[arguments[i]]=true}return this},remove_classes:function(){var classes=this._classes;if(!classes){return }for(var i=0,n=arguments.length;i<n;i++){var name=arguments[i];if(classes[name]){classes[name]=false}}return this},style:function(arg,value){if(!this._styles){this._styles={}}if(typeof arg=="string"){this._styles[arg]=value}else{update(this._styles,arg)}return this},hide:function(){this.style("display","none");return this},show:function(){this.style("display","block");return this}});var LOCAL_REMOTE=singleton(LOCAL.Class,{fetch:function(callback){if(typeof callback=="function"){this._callbacks.push(callback)}if(this._started_fetching){return }this._started_fetching=true;yield(partial(this._fetcher,getmeth(this,"_receive")))},receive:function(obj){this._has_fetched_obj=true;this.obj(obj);this._notify();this.arc(this.shared.LOCAL)},destroy:noop});function styler(key,value){return arguments.length>=2?function(){return this.style(key,value)}:function(value){return this.style(key,value)}}var _SAVED_DISPLAY_STYLE="__saved_display_style";var _SAVED_HEIGHT_STYLE="__saved_height_style";var _SAVED_WIDTH_STYLE="__saved_width_style";var Dom_node=Class(Machine,{shared:{LOCAL:LOCAL,REMOTE:REMOTE,LOCAL_REMOTE:LOCAL_REMOTE},init:function(local,fetcher,fetch_on_show){this._local=local;this._fetcher=arguments.length>=2?fetcher:null;this._fetch_on_show=arguments.length>=3?fetch_on_show:false;this._has_fetched_obj=false;this._callbacks=[];this._loading_node=local;var state=null;if(local&&fetcher){state=this.shared.LOCAL_REMOTE}else{if(local){state=this.shared.LOCAL}else{if(fetcher){state=this.shared.REMOTE}else{throw new Error("local or fetcher is required")}}}this.base(state);this._wrapped_obj=null;if(local){this.obj(local)}},has_fetched_obj:function(){return this._has_fetched_obj},fetch:arc("fetch"),_receive:arc("receive"),_notify:function(){var self=this;forall(this._callbacks,function(callback){callback(self)});this._callbacks=[]},has_obj:function(){return not_null(this._wrapped_obj)},_wrapped:function(new_obj){if(arguments.length==0){ass(this.has_obj(),"no wrapped object: typeof obj= "+typeof this._wrapped_obj);return this._wrapped_obj}else{ass(typeof new_obj!="undefined"&&new_obj!=null,"new_obj is null");this._wrapped_obj=new_obj}},is_node:true,obj:function(new_obj){if(arguments.length==0){if(!this.has_obj()){}return this._wrapped()}ass(not_null(new_obj),"new_obj is null");ass(typeof new_obj!="string","new_obj is string");ass(typeof new_obj!="number","new_obj is number");if(isinstance(new_obj,Dom_node)){new_obj=new_obj.obj()}var parent=null;if(this.has_obj()&&this.has_parent()){var parent=this.parent();var is_visible=this.is_visible();this.remove()}this._wrapped(new_obj);if(parent){this.parent(parent);is_visible?this.show():this.hide()}},tag:arc("tag"),xy:arc("xy"),region:arc("region"),style:arc("style"),hide:arc("hide"),show:arc("show"),classes:arc("classes"),has_class:arc("has_class"),add_classes:arc("add_classes"),remove_classes:arc("remove_classes"),attr:arc("attr"),mark:arc("mark"),has_parent:function(potential_parent){var dom=this.obj();if(arguments.length==0){return not_null(dom.parentNode)&&(!dom._fake_parent||dom._fake_parent!=dom.parentNode)}return this.has_parent()&&this.coerce(potential_parent).obj()==this.parent().obj()},parent:function(new_parent){var dom=this.obj();if(arguments.length==0){if(!this.has_parent()){throw new Error("node does not have a parent")}return this.coerce(dom.parentNode)}this.coerce(new_parent).insert(dom);return this},len:arc("len"),_get_children:arc("_get_children"),insert:arc("insert"),insert_before:arc("insert_before"),insert_after:arc("insert_after"),_remove_child:arc("_remove_child"),replace_child:arc("replace_child"),get_by:arc("get_by"),get_by_tag:arc("get_by_tag"),get_by_class:arc("get_by_class"),inner_html:function(new_inner_html){var tag=this.tag();ass(tag!="TABLE"&&tag!="TBODY"&&tag!="THEAD"&&tag!="TR","innerHTML error");var dom=this.obj();try{if(arguments.length==0){return dom.innerHTML}else{var old_parent=dom.parentNode;dom.innerHTML=new_inner_html;if(old_parent!=dom.parentNode){dom._fake_parent=dom.parentNode}}}catch(e){throw new Error("innerHTML error")}},id:function(value){if(arguments.length==0){if(!this.attr("id")){this.attr("id",gen_id())}return this.attr("id")}this.attr("id",value);return this},height:styler("height"),width:styler("width"),full_width:styler("width","100%"),full_height:styler("height","100%"),color:styler("color"),bg_color:styler("background-color"),border:styler("border"),display:styler("display"),center:styler("text-align","center"),left:styler("text-align","left"),right:styler("text-align","right"),top:styler("vertical-align","top"),middle:styler("vertical-align","middle"),bottom:styler("vertical-align","bottom"),margin_right_auto:styler("margin-right","auto"),margin_left_auto:styler("margin-left","auto"),margin_auto:function(){return this.margin_left_auto().margin_right_auto()},bold:styler("font-weight","bold"),underline:styler("text-decoration","underline"),italic:styler("font-style","italic"),on:function(name,listener){add_listener(this.obj(),name,listener,this);return this},unsubscribe:function(name,listener){remove_listener(this.obj(),name,listener);return this},is_visible:function(){return this.style("display")!="none"},replace_class:function(old_class,new_class){ass(this.has_class(old_class),"does not have old class");this.modify_classes([old_class],[new_class]);return this},modify_classes:function(removes,adds){var self=this;forall(removes,function(class_name){self.remove_classes(class_name)});forall(adds,function(class_name){self.add_classes(class_name)});return this},destroy:function(){this.remove();this.base()},remove:function(){if(this.has_parent()){this.parent().remove_children(this)}},replace:function(new_node){ass(this.has_parent(),"replace: node does not have a parent");this.parent().replace_child(this,new_node)},render:function(){return this},has_content:function(){return this.len()>0},content:function(new_children){if(arguments.length==0){return this._get_children()}this._set_children.apply(this,new_children)},_set_children:function(){this.remove_children();forall(arguments,getmeth(this,"insert"))},remove_children:function(){forall(arguments.length==0?this.content():arguments,getmeth(this,"_remove_child"))}});return[Dom_node]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[11]=(function(){var Dom_node=__[10][0],Machine=__[13][0],arc=__[13][2];function dfs(root,visit){var last=0;var nodes=[root];var node=null;var i=null;var children=null;while(last>=0){children=visit(nodes[last--]);if(children){for(i=children.length-1;i>=0;i--){nodes[++last]=children[i]}}}}var DONE={};function _iter(){return this.i<this.n?this.a[this.i++]:DONE}function iter(a){return{a:a,i:0,n:a.length,next:_iter}}iter.DONE=DONE;var PARENT=0;var CHILD_ITER=1;var RESULTS=2;function dfs2(root,open,close){var children=open(root);if(!children){return close(root,[])}var state=[root,children,[]];var path=[state];var i=0;var result=null;while(true){state=path[i];node=state[CHILD_ITER].next();if(node==DONE){result=close(state[PARENT],state[RESULTS]);if(--i<0){return result}path[i][RESULTS].push(result)}else{children=open(node);if(children){path[++i]=[node,children,[]]}else{result=close(node,[]);path[i][RESULTS].push(result)}}}}var REMOTE=singleton(Dom_node.shared.REMOTE.Class,{tag:function(){return this._tag},mark:function(){this.id();this._do_mark_callback=true;return this},len:function(){return this._children?this._children.length:0},_get_children:function(){return this._children?map(this._children,identity):[]},insert:function(child){this._children?this._children.push(child):this._children=[child]},append:function(child){throw new Error("ghost append");this._children?this._children.push(child):this._children=[child]},_remove_child:function(child){if(!this.has_content()){return }for(var i=0,n=this.len();i<n;i++){if(this._children[i]==child){this._children.splice(i,1);return }}},replace_child:function(old_child,new_child){if(this.has_content()){for(var i=0,n=this.len();i<n;i++){if(this._children[i]==old_child){this._children[i]=new_child;return }}}throw new Error("child not found")},_ghost_children:function(){if(!this.has_content()){return null}var c=this._children;var ghosts=[];var child=null;for(var i=0,n=c.length;i<n;i++){child=c[i];if(child.IS_GHOST&&!child.is_complete()){ghosts.push(child)}}return ghosts},_setup_callbacks:function(){function visit(node){node._setup_dom_callbacks();node._setup_listener_callbacks();node._setup_mark_callback();return node._ghost_children()}dfs(this,visit)},_setup_mark_callback:function(){if(!this._do_mark_callback){return }var self=this;function callback(node){self.obj(node.obj())}var id=this.id();this._add_callback(id,callback)},_setup_dom_callbacks:function(){var children=this._children;if(!children){return }var self=this;pair_forall(children,function(i,child){if(typeof child=="string"||(child.IS_GHOST&&!child.is_complete())){return }var swap_child=new Ghost("span");children[i]=swap_child;function callback(swap_child){swap_child.replace(child)}var id=swap_child.id();self._add_callback(id,callback)})},_setup_listener_callbacks:function(){var listeners=this.__lazy_listeners;if(!listeners){return }function callback(node){for(name in listeners){forall(listeners[name],function(f){node.on(name,f)})}}var id=this.id();this._add_callback(id,callback)},_setup_children_callbacks:function(){if(!this.has_content()){return }forall(this._children,function(child){if(child.IS_GHOST&&!child.is_complete()){child._setup_callbacks()}})},_add_callback:function(id,callback){if(!this._callbacks){this._callbacks=[]}this._callbacks.push([id,callback])},_call_callbacks:function(){function visit(node){if(node._callbacks){forall(node._callbacks,function(pair){var id=pair[0];var callback=pair[1];callback(node.coerce(id))})}return node._ghost_children()}dfs(this,visit)},_create:function(){var root=_template_parent(this.coerce);var parent_dom=document.createElement("div");root.insert(parent_dom);var markup=this._markup();parent_dom.innerHTML=markup;return this.coerce(parent_dom.childNodes[0])},_inner_markup:function(){if(!this.has_content()){return""}return this.has_content()?map(this._children,function(template){if(typeof template=="string"){return template}if(template.is_complete()){return template}return template._markup()}).join(""):""},_markup:function(){if(this._rendered){throw new Error("template already rendered")}this._rendered=true;try{return this.__markup()}catch(e){throw e}},__markup:function(){function open(node){if(typeof node=="string"){return null}return node.has_content()?iter(node._children):null}function close(node,children){if(typeof node=="string"){return node}var m="<"+node._tag;var classes=node._classes;if(classes){m+=' class="';var first=true;for(var name in classes){if(classes[name]){if(!first){m+=" "}else{first=false}m+=name}}m+='"'}var styles=node._styles;if(styles){m+=' style="';for(var name in styles){m+=name+": "+styles[name]+";"}m+='"'}var attr=node._attr;for(var name in attr){m+=" "+name+'="'+attr[name]+'"'}m+=">";m+=children.join("");m+="</"+node._tag+">";return m}return dfs2(this,open,close)},has_rendered:function(){return this._has_rendered?true:false},render:function(){this._setup_callbacks();var node=this._create();this._call_callbacks();this._set_complete();this.obj(node);this._has_rendered=true;return this},__set_complete:function(){this.arc(this.shared.LOCAL);this._complete=true},_set_complete:function(){function visit(node){var ghosts=node._ghost_children();node.__set_complete();return ghosts}dfs(this,visit)},is_complete:false_});var LOCAL=singleton(Dom_node.shared.LOCAL.Class,{render:function(){return this},is_complete:true_});var _template_parent=(function(){var node=null;return function(coerce){if(!node){node=document.createElement("div");node.style.display="none";document.body.appendChild(node);node=coerce(node)}return node}})();function wrap(f){return function(){if(this.is_complete()){return base(this,arguments)}return f.apply(this,arguments)}}var Ghost=Class(Dom_node,{shared:{LOCAL:LOCAL,REMOTE:REMOTE},on:wrap(function(name,f){if(!this.__lazy_listeners){this.__lazy_listeners={}}var listeners=this.__lazy_listeners;if(listeners[name]){listeners[name].push(f)}else{listeners[name]=[f]}}),unsubscribe:wrap(function(name,f){if(!this.__lazy_listeners||!this.__lazy_listeners[name]){return }var event_listeners=this.__lazy_listeners[name];for(var i=0,n=event_listeners.length;i<n;i++){if(event_listeners[i]==f){event_listeners.splice(i,1);break}}}),is_complete:function(){return this._complete},_set_complete:arc("_set_complete"),__set_complete:arc("__set_complete"),IS_GHOST:true,pre_init:function(){Machine.prototype.init.call(this,REMOTE)},init:function(tag,children){this._tag=tag;this._children=children?map(children,identity):null},obj:function(){if(arguments.length>0){return base(this,arguments)}if(!this.is_complete()){throw new Error("obj() calling render not implemented")}if(this.has_obj()){return this.base()}if(!this._attr||!this._attr["id"]){throw new Error("cannot get obj, complete template id is null")}var dom=this.coerce(this._attr["id"]).obj();this.obj(dom);return dom},render:arc("render"),_create:arc("_create"),_ghost_children:arc("_ghost_children"),_setup_callbacks:arc("_setup_callbacks"),_setup_mark_callback:arc("_setup_mark_callback"),_setup_dom_callbacks:arc("_setup_dom_callbacks"),_setup_listener_callbacks:arc("_setup_listener_callbacks"),_setup_children_callbacks:arc("_setup_children_callbacks"),_add_callback:arc("_add_callback"),_call_callbacks:arc("_call_callbacks"),_inner_markup:arc("_inner_markup"),__markup:arc("__markup"),_markup:arc("_markup")});return[Ghost]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[7]=(function(){var get=__[9][3],get_doc_width=__[9][16],get_doc_height=__[9][15],get_selected_text=__[9][13],Dom_node=__[10][0],Ghost=__[11][0];function $(arg){ass(typeof arg!="undefined"&&arg!=null,"$ arg is null");ass(typeof arg!="number","$ arg is number");if(isinstance(arg,$.Node)){return arg}if(arg.IS_GHOST){return arg.render()}if(typeof arg=="string"){var x=get(arg);if(!x){throw new Error("could not find id")}arg=x}return new $.Node(arg)}$.Node=Class(Dom_node,{coerce:$});$.Ghost=Class(Ghost,{coerce:$});forall("A SPAN DIV UL OL LI IMG TABLE TBODY THEAD TFOOT TR TD FORM INPUT SELECT OPTION BR HR".split(" "),function(tag){$[tag]=function(){return new $.Ghost(tag,arguments)}});$.LINK=function(inner,href){return $.A(inner).attr("href",href)};$.image=function(src,height,width){var img=$.IMG().attr("src",src);if(not_null(height)){img.attr("height",height)}if(not_null(width)){img.attr("width",width)}return img};var _Doc=Class($.Node,{width:function(){return get_doc_width()},height:function(){return get_doc_height()},width_height:function(){return[this.width(),this.height()]}});$.doc=function(){var dom=document;return new _Doc(dom)};function _gen_singleton_getter(tag){return function(){var d=$.doc();if(d.obj()[tag]){return $(d.obj()[tag])}var nodes=d.get_by(tag);ass(nodes.length>0,"no "+tag+" found");return $(nodes[0])}}$.body=_gen_singleton_getter("body");$.head=_gen_singleton_getter("head");$.html=function(){return $.body().parent()};$.coerce=function(arg){ass(not_null(arg),"coerce arg is undef or null");var node=null;if(typeof arg=="string"||typeof arg=="number"){node=document.createTextNode(arg)}else{if(arg.IS_GHOST){node=arg.render()}else{if(typeof arg=="function"){node=arg()}else{if(typeof arg=="object"){node=arg}else{throw new Error("arg has an invalid type")}}}}return $(node)};$.create=function(tag,inner){var node=$(document.createElement(tag));if(arguments.length>=2&&inner){if(inner.length==1&&(typeof inner[0]=="string"||typeof inner[0]=="number")){node.inner_html(inner[0])}else{forall(inner,function(arg){map(is_array(arg)?map(arg,$.coerce):[$.coerce(arg)],function(child){node.insert(child)})})}}return node};function template(f){f.render=f;return f}forall("a span div table tbody thead tr td ul ol li img".split(" "),function(tag){$[tag]=template(function(){return $.create(tag,arguments)})});var _copy_styles="font-family, font-size, font-weight, font-style".split(", ");var _n=_copy_styles.length;function copy_text_styles(source,target){var parent=$(source);target=$(target);if(parent.has_class("lingo")&&parent.has_parent()){parent=parent.parent()}var i=0;while(i<_n){try{for(;i<_n;i++){var style_name=_copy_styles[i];var value=parent.style(style_name);if(!value){continue}if(style_name=="font-size"&&(!/[^\d-]/.test(value)||value.indexOf("%")>=0)){continue}target.style(style_name,parent.style(style_name))}}catch(e){i++}}}var highlight=singleton({init:function(){after($.doc(),"mouseup",this,"_mouseup")},_mouseup:function(doc,event){var query=get_selected_text();if(query.length<3||query.length>50){return }if(!event.alt_key_down()||!event.is_left_click()){return }this.click(event.mouse_xy(),query)},click:event()});return[copy_text_styles,highlight,$]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[3]=(function(){var $=__[7][2];function add_signup(key){try{var box=$("signup_box");var link=$("signup_link");var form=$("signup_form")}catch(e){return }var toggler=gen_toggler(key,form);after(link,"click",toggler,"toggle");box.show()}function gen_toggler(key,form){return singleton({toggle:function(link,e){e.suppress();if(!this._signup_shown){this._signup_shown=true;this._signup_hidden=false;var server=ENV.CONSOLE_SERVER;var path="/console/portals/"+key+"/signup/";var url=server+path;var markup="<iframe id='signup_frame' src='"+url+"' frameborder='0'></iframe>";form.inner_html(markup);form.show()}else{this._signup_hidden?$("signup_frame").show():$("signup_frame").hide();this._signup_hidden=!this._signup_hidden}}})}return[add_signup]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[5]=(function(){var $=__[7][2];function add_menus(root){root=$(root);forall(root.get_by_class("lingo_preview"),render_menu)}function render_menu(root){var previews=root.get_by_class("lingo_item_preview");var items=root.get_by_class("lingo_item");var current_preview=previews[0];var current_index=0;var o=singleton({over:function(item){item.add_classes("lingo_item_hover")},out:function(item){item.remove_classes("lingo_item_hover")},click:function(item){var i=item.attr("index")-1;if(current_index==i){return }previews[current_index].hide();items[current_index].remove_classes("lingo_item_selected");previews[i].show();items[i].add_classes("lingo_item_selected");current_index=i}});forall(items,function(item){after(item,"mouseover",o,"over");after(item,"mouseout",o,"out");after(item,"click",o,"click")})}return[add_menus]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[2]=(function(){var $=__[7][2];function append_image(url){if($.doc().obj().images){(new Image()).src=url}return true}function append_js(url){var script=document.createElement("script");script.setAttribute("language","javascript");script.setAttribute("src",url);var parentNode=null;if(typeof document!="undefined"&&document!=null){var d=document;if(typeof d.lastChild!="undefined"&&d.lastChild!=null){var lc=d.lastChild;if(typeof lc.firstChild!="undefined"&&typeof lc.firstChild!=null){parentNode=lc.firstChild}}else{if(typeof d.body!="undefined"&&d.body!=null){parentNode=d.body}else{if(typeof d.head!="undefined"&&d.head!=null){parentNode=d.body}}}}if(typeof parentNode=="undefined"||parentNode==null){return }try{parentNode.appendChild(script)}catch(e){}return script}function append_css(url){var css=document.createElement("link");css.type="text/css";css.rel="stylesheet";css.media="all";css.href=url;document.lastChild.firstChild.appendChild(css)}function create_stylesheet(bundleStyle){var newSS=document.createElement("style");newSS.setAttribute("type","text/css");if(newSS.styleSheet){newSS.styleSheet.cssText=bundleStyle}else{var cssText=document.createTextNode(bundleStyle);newSS.appendChild(cssText)}document.getElementsByTagName("head")[0].appendChild(newSS)}return[append_image,append_css,create_stylesheet,append_js]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[6]=(function(){var $=__[7][2];var Portal_events=Class({init:function(key,term,referrer){this.key=key;this.term=term;this.referrer=referrer;this.load()},load:function(){var input_args={dst_apps:this.arc_apps(),dst_term:this.term,label:"done"};if(this.ref_apps()){input_args.src_apps=this.ref_apps()}lingo_event_load(input_args)},wrap_tree:function(root){root=$(root);var links=root.get_by_tag("a");forall(links,getmeth(this,"wrap"))},wrap:function(link){after(link,"mousedown",this,"mousedown")},mousedown:function(link){var args={src_apps:this.arc_apps(),src_term:this.term};if(this.ref_apps()){args.ref_apps=this.ref_apps()}var extra_args=this.extra_args(link);var dom=link.obj();lingo_event_wrap(dom,args,extra_args)},ref_apps:function(){if(this.referrer){return[this.referrer]}},arc_apps:function(){return[this.key]},extra_args:function(link){var old_url=link.obj().href;var extra_args={};if(typeof LINGO_WRAP_ARGS=="object"){for(var domain in LINGO_WRAP_ARGS){var key_to_val=LINGO_WRAP_ARGS[domain];var url_domain=old_url;var i=url_domain.indexOf("://");if(i>=0){url_domain=url_domain.substring(i+"://".length)}var i=url_domain.indexOf("/");if(i>=0){url_domain=url_domain.substring(0,i)}if(url_domain.indexOf("topics.sacbee.com")>=0){continue}if(url_domain.indexOf(domain)>=0){for(var key in key_to_val){var val=key_to_val[key];extra_args[key]=val}}}}return extra_args},toString:_("Portal_events")});return[Portal_events]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[4]=(function(){var $=__[7][2],append_js=__[2][3],gen_on_dom=__[15][0],gen_connect=__[16][1],STATUS=__[16][0];function escaped_query_join(args){var escaped={};for(var key in args){escaped[key]=escape(args[key])}return query_join(escaped)}if(typeof LINGO!="object"){window.LINGO={}}var L=window.LINGO;L.on_dom=gen_on_dom();var server=L.portal_server=gen_connect(append_js,"LINGO.portal_server");var retry_count=0;var good_responses=0;function no_results(){if(retry_count==0&&good_responses==0){$("lingo_portal_no_results").show()}}function do_retries(portal_response,run_widget,referrer){var child_responses=portal_response.request().child_responses();child_responses.sort(function(x,y){return x.request().prio()-y.request().prio()});var retries=forall(child_responses,function(r){if(r.is_retry()){retry(r,portal_response,run_widget,referrer)}else{if(r.is_good()){good_responses++}}});var referrer_response=portal_response.request().referrer_response();if(referrer&&referrer_response){retry_referrer(referrer_response,portal_response,run_widget,referrer)}no_results()}function is_affiliate_response(response){return response.app().class_key()=="affiliate"}var parent_id_index=1;function next_parent_id(){return"lingo_get_test_"+parent_id_index++}function retry(widget_response,portal_response,run_widget){var parent_id=next_parent_id();_retry(widget_response,portal_response,run_widget,parent_id)}function retry_referrer(widget_response,portal_response,run_widget,referrer){var parent_id="affiliate_parent";var new_args={referrer:referrer};_retry(widget_response,portal_response,run_widget,parent_id,new_args)}function _retry(widget_response,portal_response,run_widget,parent_id,new_args){var request=widget_response.request();var hash=request.hash();var url=request.retry_url();if(!url){return }var widget=widget_response.app();if(!new_args){new_args={}}new_args.format="embed";var get_parent_id=gen_get_parent_id(portal_response,widget,parent_id);var url=url.with_new_args(new_args);var url_root=url.abs_path();var url_args=url.query();var on_dom=L.on_dom;function callback(parent,response,embed_content){retry_count--;var content=response.content;var r=widget_response.clone({status:response.status,quality:response.quality,content:content});if(r.quality()=="bad"){no_results();return }good_responses++;embed_content(parent,content);run_widget(parent)}function timeout_callback(request){retry_count--;no_results()}retry_count++;server.request_embed(hash,get_parent_id,url_root,url_args,on_dom,callback,timeout_callback)}function gen_get_parent_id(portal_response,widget,parent_id){return function(){var parent=document.createElement("div");parent.id=parent_id;var col=col_from_widget(portal_response,widget);col.appendChild(parent);return parent_id}}function col_from_widget(portal_response,widget){var index=col_index_from_widget(portal_response,widget);return get_col(index)}function get_col(i){var col_class="lingo_col_"+(i+1);var col=$.body().get_by_class(col_class)[0].obj();return col}function col_index_from_widget(portal_response,widget){var cols=portal_response.request().cols();for(var index=0;index<cols.length;index++){var col=cols[index];for(var i=0;i<col.length;i++){var app=col[i];if(app.key()==widget.key()){return index}}}throw new Error("couldnt find col index for widget, key = "+widget.key())}return[do_retries]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[1]=(function(){var append_image=__[2][0],append_js=__[2][3],add_signup=__[3][0],do_retries=__[4][0],add_menus=__[5][0],Portal_events=__[6][0],$=__[7][2],Root=__[8][0];function fragment(){var hash=location.hash||"#";if(hash.charAt(0)=="#"){hash=hash.substring(1)}var frag=query_split(hash);return frag}var App=Class(Root,{run:function(response){var request=response.request();var key=this.key();var term=request.term();var referrer=fragment().referrer||null;this.events=new Portal_events(key,term,referrer);add_signup(key);var root=$("boxes");this.run_widget(root);do_retries(response,getmeth(this,"run_widget"),referrer)},run_widget:function(root){this.events.wrap_tree(root);add_menus(root)},toString:_("Portal")});var Widget=Class(Root,{});Root.register("portal",App);Root.register("widget",Widget);Root.register("affiliate",Widget);return[App]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }__[0]=(function(){var App=__[1][0];LINGO.run();return[]})();if(typeof LINGO=="object"&&LINGO.do_abort_js&&LINGO.do_abort_js()){LINGO.abort_js();return }})()
