//form
;(function($){$.fn.ajaxSubmit=function(options){if(!this.length){log('ajaxSubmit: skipping submit process - no element selected');return this;}
if(typeof options=='function')
options={success:options};options=$.extend({url:this.attr('action')||window.location.toString(),type:this.attr('method')||'GET'},options||{});var veto={};this.trigger('form-pre-serialize',[this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');return this;}
if(options.beforeSerialize&&options.beforeSerialize(this,options)===false){log('ajaxSubmit: submit aborted via beforeSerialize callback');return this;}
var a=this.formToArray(options.semantic);if(options.data){options.extraData=options.data;for(var n in options.data){if(options.data[n]instanceof Array){for(var k in options.data[n])
a.push({name:n,value:options.data[n][k]})}
else
a.push({name:n,value:options.data[n]});}}
if(options.beforeSubmit&&options.beforeSubmit(a,this,options)===false){log('ajaxSubmit: submit aborted via beforeSubmit callback');return this;}
this.trigger('form-submit-validate',[a,this,options,veto]);if(veto.veto){log('ajaxSubmit: submit vetoed via form-submit-validate trigger');return this;}
var q=$.param(a);if(options.type.toUpperCase()=='GET'){options.url+=(options.url.indexOf('?')>=0?'&':'?')+q;options.data=null;}
else
options.data=q;var $form=this,callbacks=[];if(options.resetForm)callbacks.push(function(){$form.resetForm();});if(options.clearForm)callbacks.push(function(){$form.clearForm();});if(!options.dataType&&options.target){var oldSuccess=options.success||function(){};callbacks.push(function(data){$(options.target).html(data).each(oldSuccess,arguments);});}
else if(options.success)
callbacks.push(options.success);options.success=function(data,status){for(var i=0,max=callbacks.length;i<max;i++)
callbacks[i].apply(options,[data,status,$form]);};var files=$('input:file',this).fieldValue();var found=false;for(var j=0;j<files.length;j++)
if(files[j])
found=true;if(options.iframe||found){if($.browser.safari&&options.closeKeepAlive)
$.get(options.closeKeepAlive,fileUpload);else
fileUpload();}
else
$.ajax(options);this.trigger('form-submit-notify',[this,options]);return this;function fileUpload(){var form=$form[0];if($(':input[@name=submit]',form).length){alert('Error: Form elements must not be named "submit".');return;}
var opts=$.extend({},$.ajaxSettings,options);var s=jQuery.extend(true,{},$.extend(true,{},$.ajaxSettings),opts);var id='jqFormIO'+(new Date().getTime());var $io=$('<iframe id="'+id+'" name="'+id+'" />');var io=$io[0];if($.browser.msie||$.browser.opera)
io.src='javascript:false;document.write("");';$io.css({position:'absolute',top:'-1000px',left:'-1000px'});var xhr={aborted:0,responseText:null,responseXML:null,status:0,statusText:'n/a',getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;$io.attr('src','about:blank');}};var g=opts.global;if(g&&!$.active++)$.event.trigger("ajaxStart");if(g)$.event.trigger("ajaxSend",[xhr,opts]);if(s.beforeSend&&s.beforeSend(xhr,s)===false){s.global&&jQuery.active--;return;}
if(xhr.aborted)
return;var cbInvoked=0;var timedOut=0;var sub=form.clk;if(sub){var n=sub.name;if(n&&!sub.disabled){options.extraData=options.extraData||{};options.extraData[n]=sub.value;if(sub.type=="image"){options.extraData[name+'.x']=form.clk_x;options.extraData[name+'.y']=form.clk_y;}}}
setTimeout(function(){var t=$form.attr('target'),a=$form.attr('action');$form.attr({target:id,method:'POST',action:opts.url});if(!options.skipEncodingOverride){$form.attr({encoding:'multipart/form-data',enctype:'multipart/form-data'});}
if(opts.timeout)
setTimeout(function(){timedOut=true;cb();},opts.timeout);var extraInputs=[];try{if(options.extraData)
for(var n in options.extraData)
extraInputs.push($('<input type="hidden" name="'+n+'" value="'+options.extraData[n]+'" />').appendTo(form)[0]);$io.appendTo('body');io.attachEvent?io.attachEvent('onload',cb):io.addEventListener('load',cb,false);form.submit();}
finally{$form.attr('action',a);t?$form.attr('target',t):$form.removeAttr('target');$(extraInputs).remove();}},10);function cb(){if(cbInvoked++)return;io.detachEvent?io.detachEvent('onload',cb):io.removeEventListener('load',cb,false);var operaHack=0;var ok=true;try{if(timedOut)throw'timeout';var data,doc;doc=io.contentWindow?io.contentWindow.document:io.contentDocument?io.contentDocument:io.document;if(doc.body==null&&!operaHack&&$.browser.opera){operaHack=1;cbInvoked--;setTimeout(cb,100);return;}
xhr.responseText=doc.body?doc.body.innerHTML:null;xhr.responseXML=doc.XMLDocument?doc.XMLDocument:doc;xhr.getResponseHeader=function(header){var headers={'content-type':opts.dataType};return headers[header];};if(opts.dataType=='json'||opts.dataType=='script'){var ta=doc.getElementsByTagName('textarea')[0];xhr.responseText=ta?ta.value:xhr.responseText;}
else if(opts.dataType=='xml'&&!xhr.responseXML&&xhr.responseText!=null){xhr.responseXML=toXml(xhr.responseText);}
data=$.httpData(xhr,opts.dataType);}
catch(e){ok=false;$.handleError(opts,xhr,'error',e);}
if(ok){opts.success(data,'success');if(g)$.event.trigger("ajaxSuccess",[xhr,opts]);}
if(g)$.event.trigger("ajaxComplete",[xhr,opts]);if(g&&!--$.active)$.event.trigger("ajaxStop");if(opts.complete)opts.complete(xhr,ok?'success':'error');setTimeout(function(){$io.remove();xhr.responseXML=null;},100);};function toXml(s,doc){if(window.ActiveXObject){doc=new ActiveXObject('Microsoft.XMLDOM');doc.async='false';doc.loadXML(s);}
else
doc=(new DOMParser()).parseFromString(s,'text/xml');return(doc&&doc.documentElement&&doc.documentElement.tagName!='parsererror')?doc:null;};};};$.fn.ajaxForm=function(options){return this.ajaxFormUnbind().bind('submit.form-plugin',function(){$(this).ajaxSubmit(options);return false;}).each(function(){$(":submit,input:image",this).bind('click.form-plugin',function(e){var form=this.form;form.clk=this;if(this.type=='image'){if(e.offsetX!=undefined){form.clk_x=e.offsetX;form.clk_y=e.offsetY;}else if(typeof $.fn.offset=='function'){var offset=$(this).offset();form.clk_x=e.pageX-offset.left;form.clk_y=e.pageY-offset.top;}else{form.clk_x=e.pageX-this.offsetLeft;form.clk_y=e.pageY-this.offsetTop;}}
setTimeout(function(){form.clk=form.clk_x=form.clk_y=null;},10);});});};$.fn.ajaxFormUnbind=function(){this.unbind('submit.form-plugin');return this.each(function(){$(":submit,input:image",this).unbind('click.form-plugin');});};$.fn.formToArray=function(semantic){var a=[];if(this.length==0)return a;var form=this[0];var els=semantic?form.getElementsByTagName('*'):form.elements;if(!els)return a;for(var i=0,max=els.length;i<max;i++){var el=els[i];var n=el.name;if(!n)continue;if(semantic&&form.clk&&el.type=="image"){if(!el.disabled&&form.clk==el)
a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y});continue;}
var v=$.fieldValue(el,true);if(v&&v.constructor==Array){for(var j=0,jmax=v.length;j<jmax;j++)
a.push({name:n,value:v[j]});}
else if(v!==null&&typeof v!='undefined')
a.push({name:n,value:v});}
if(!semantic&&form.clk){var inputs=form.getElementsByTagName("input");for(var i=0,max=inputs.length;i<max;i++){var input=inputs[i];var n=input.name;if(n&&!input.disabled&&input.type=="image"&&form.clk==input)
a.push({name:n+'.x',value:form.clk_x},{name:n+'.y',value:form.clk_y});}}
return a;};$.fn.formSerialize=function(semantic){return $.param(this.formToArray(semantic));};$.fn.fieldSerialize=function(successful){var a=[];this.each(function(){var n=this.name;if(!n)return;var v=$.fieldValue(this,successful);if(v&&v.constructor==Array){for(var i=0,max=v.length;i<max;i++)
a.push({name:n,value:v[i]});}
else if(v!==null&&typeof v!='undefined')
a.push({name:this.name,value:v});});return $.param(a);};$.fn.fieldValue=function(successful){for(var val=[],i=0,max=this.length;i<max;i++){var el=this[i];var v=$.fieldValue(el,successful);if(v===null||typeof v=='undefined'||(v.constructor==Array&&!v.length))
continue;v.constructor==Array?$.merge(val,v):val.push(v);}
return val;};$.fieldValue=function(el,successful){var n=el.name,t=el.type,tag=el.tagName.toLowerCase();if(typeof successful=='undefined')successful=true;if(successful&&(!n||el.disabled||t=='reset'||t=='button'||(t=='checkbox'||t=='radio')&&!el.checked||(t=='submit'||t=='image')&&el.form&&el.form.clk!=el||tag=='select'&&el.selectedIndex==-1))
return null;if(tag=='select'){var index=el.selectedIndex;if(index<0)return null;var a=[],ops=el.options;var one=(t=='select-one');var max=(one?index+1:ops.length);for(var i=(one?index:0);i<max;i++){var op=ops[i];if(op.selected){var v=$.browser.msie&&!(op.attributes['value'].specified)?op.text:op.value;if(one)return v;a.push(v);}}
return a;}
return el.value;};$.fn.clearForm=function(){return this.each(function(){$('input,select,textarea',this).clearFields();});};$.fn.clearFields=$.fn.clearInputs=function(){return this.each(function(){var t=this.type,tag=this.tagName.toLowerCase();if(t=='text'||t=='password'||tag=='textarea')
this.value='';else if(t=='checkbox'||t=='radio')
this.checked=false;else if(tag=='select')
this.selectedIndex=-1;});};$.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=='function'||(typeof this.reset=='object'&&!this.reset.nodeType))
this.reset();});};$.fn.enable=function(b){if(b==undefined)b=true;return this.each(function(){this.disabled=!b});};$.fn.selected=function(select){if(select==undefined)select=true;return this.each(function(){var t=this.type;if(t=='checkbox'||t=='radio')
this.checked=select;else if(this.tagName.toLowerCase()=='option'){var $sel=$(this).parent('select');if(select&&$sel[0]&&$sel[0].type=='select-one'){$sel.find('option').selected(false);}
this.selected=select;}});};function log(){if($.fn.ajaxSubmit.debug&&window.console&&window.console.log)
window.console.log('[jquery.form] '+Array.prototype.join.call(arguments,''));};})(jQuery);
//chain

(function($){$.Chain={version:'0.2',tag:['{','}'],services:{},service:function(name,proto)
{this.services[name]=proto;$.fn[name]=function(options)
{if(!this.length)
{return this;}
var instance=this.data('chain-'+name);var args=Array.prototype.slice.call(arguments,1);if(!instance)
{if(options=='destroy')
{return this;}
instance=$.extend({element:this},$.Chain.services[name]);this.data('chain-'+name,instance);if(instance.init)
{instance.init();}}
var result;if(typeof options=='string'&&instance['$'+options])
{result=instance['$'+options].apply(instance,args);}
else if(instance['handler'])
{result=instance['handler'].apply(instance,[options].concat(args));}
else
{result=this;}
if(options=='destroy')
{this.removeData('chain-'+name);}
return result;};},extend:function(name,proto)
{if(this.services[name])
{this.services[name]=$.extend(this.services[name],proto);}},jobject:function(obj)
{return obj&&obj.init==$.fn.init;},jidentic:function(j1,j2)
{if(!j1||!j2||j1.length!=j2.length)
{return false;}
var a1=j1.get();var a2=j2.get();for(var i=0;i<a1.length;i++)
{if(a1[i]!=a2[i])
{return false;}}
return true;},parse:function()
{var $this={};$this.closure=['function($data, $el){'
+'var $text = [];\n'
+'$text.print = function(text)'
+'{this.push((typeof text == "number") ? text : ((typeof text != "undefined") ? text : ""));};\n'
+'with($data){\n','}\n'
+'return $text.join("");'
+'}'];$this.textPrint=function(text)
{return'$text.print("'
+text.split('\\').join('\\\\').split("'").join("\\'").split('"').join('\\"')
+'");';};$this.scriptPrint=function(text)
{return'$text.print('+text+');';};$this.parser=function(text){var tag=$.Chain.tag;var opener,closer,closer2=null,result=[];while(text){opener=text.indexOf(tag[0]);closer=opener+text.substring(opener).indexOf(tag[1]);if(opener!=-1)
{if(text[opener-1]=='\\')
{closer2=opener+tag[0].length+text.substring(opener+tag[0].length).indexOf(tag[0]);if(closer2!=opener+tag[0].length-1&&text[closer2-1]=='\\')
{closer2=closer2-1;}
else if(closer2==opener+tag[0].length-1)
{closer2=text.length;}
result.push($this.textPrint(text.substring(0,opener-1)));result.push($this.textPrint(text.substring(opener,closer2)));}
else
{closer2=null;if(closer==opener-1)
{closer=text.length;}
result.push($this.textPrint(text.substring(0,opener)));result.push($this.scriptPrint(text.substring(opener+tag[0].length,closer)));}
text=text.substring((closer2===null)?closer+tag[1].length:closer2);}
else if(text)
{result.push($this.textPrint(text));text='';}}
return result.join('\n');};return function($text)
{var $fn=function(){};try
{eval('$fn = '+$this.closure[0]+$this.parser($text)+$this.closure[1]);}
catch(e)
{throw"Parsing Error";}
return $fn;};}()};})(jQuery);(function($){$.Chain.service('update',{handler:function(opt)
{if(typeof opt=='function')
{return this.bind(opt);}
else
{return this.trigger(opt);}},bind:function(fn)
{return this.element.bind('update',fn);},trigger:function(opt)
{this.element.items('update');this.element.item('update');this.element.triggerHandler('preupdate',this.element.item());if(opt=='hard')
{this.element.items(true).each(function(){$(this).update();});}
this.element.triggerHandler('update',this.element.item());return this.element;}});})(jQuery);(function($){$.Chain.service('chain',{init:function()
{this.anchor=this.element;this.template=this.anchor.html();this.tplNumber=0;this.builder=this.createBuilder();this.plugins={};this.isActive=false;this.destroyers=[];this.element.addClass('chain-element');},handler:function(obj)
{this.element.items('backup');this.element.item('backup');if(typeof obj=='object')
{this.handleUpdater(obj);}
else if(typeof obj=='function')
{this.handleBuilder(obj);}
this.anchor.empty();this.isActive=true;this.element.update();return this.element;},handleUpdater:function(rules)
{var builder=rules.builder;delete rules.builder;if(rules.anchor)
{this.setAnchor(rules.anchor);}
delete rules.anchor;var override=rules.override;delete rules.override;for(var i in rules)
{if(typeof rules[i]=='string')
{rules[i]=$.Chain.parse(rules[i]);}
else if(typeof rules[i]=='object')
{for(var j in rules[i])
{if(typeof rules[i][j]=='string')
{rules[i][j]=$.Chain.parse(rules[i][j]);}}}}
var fn=function(event,data)
{var el,val;var self=$(this);for(var i in rules)
{if(i=='self')
{el=self;}
else
{el=$(i,self);}
if(typeof rules[i]=='function')
{val=rules[i].apply(self,[data,el]);if(typeof val=='string')
{el.not(':input').html(val).end().filter(':input').val(val);}}
else if(typeof rules[i]=='object')
{for(var j in rules[i])
{if(typeof rules[i][j]=='function')
{val=rules[i][j].apply(self,[data,el]);if(typeof val=='string')
{if(j=='content')
{el.html(val);}
else if(j=='text')
{el.text(val);}
else if(j=='value')
{el.val(val);}
else if(j=='class'||j=='className')
{el.addClass(val);}
else
{el.attr(j,val);}}}}}}};var defBuilder=this.defaultBuilder;this.builder=function(root)
{if(builder)
{builder.apply(this,[root]);}
if(!override)
{defBuilder.apply(this);}
this.update(fn);return false;};},handleBuilder:function(fn)
{this.builder=this.createBuilder(fn);},defaultBuilder:function(builder,root)
{var res=builder?(builder.apply(this,[root])!==false):true;if(res)
{this.bind('update',function(event,data){var self=$(this);for(var i in data)
{if(typeof data[i]!='object'&&typeof data[i]!='function')
{self.find('> .'+i+', *:not(.chain-element) .'+i).each(function(){var match=$(this);if(match.filter(':input').length)
{match.val(data[i]);}
else if(match.filter('img').length)
{match.attr('src',data[i]);}
else
{match.html(data[i]);}});}}});}},createBuilder:function(builder)
{var defBuilder=this.defaultBuilder;return function(root){defBuilder.apply(this,[builder,root]);return false;};},setAnchor:function(anchor)
{this.anchor.html(this.template);this.anchor=anchor==this.element?anchor:this.element.find(anchor).eq(0);this.template=this.anchor.html();this.anchor.empty();},$anchor:function(anchor)
{if(anchor)
{this.element.items('backup');this.element.item('backup');this.setAnchor(anchor);this.element.update();return this.element;}
else
{return this.anchor;}},$template:function(arg)
{if(!arguments.length)
{return $('<div>').html(this.template).children().eq(this.tplNumber);}
if(arg=='raw')
{return this.template;}
if(typeof arg=='number')
{this.tplNumber=arg;}
else
{var tpl=$('<div>').html(this.template).children();var node=tpl.filter(arg).eq(0);if(node.length)
{this.tplNumber=tpl.index(node);}
else
{return this.element;}}
this.element.items('backup');this.element.item('backup');this.element.update();return this.element;},$builder:function(builder)
{if(builder)
{return this.handler(builder);}
else
{return this.builder;}},$active:function()
{return this.isActive;},$plugin:function(name,fn)
{if(fn===null)
{delete this.plugins[name];}
else if(typeof fn=='function')
{this.plugins[name]=fn;}
else if(name&&!fn)
{return this.plugins[name];}
else
{return this.plugins;}
if(typeof fn=='function')
{this.element.items(true).each(function(){var self=$(this);fn.call(self,self.item('root'));});}
this.element.update();return this.element;},$clone:function()
{var id=this.element.attr('id');this.element.attr('id','');var clone=this.element.clone().empty().html(this.template);this.element.attr('id',id);return clone;},$destroy:function(nofollow)
{this.element.removeClass('chain-element');if(!nofollow)
{this.element.items('backup');this.element.item('backup');this.element.find('.chain-element').each(function(){$(this).chain('destroy',true);});}
this.element.triggerHandler('destroy');this.isActive=false;this.anchor.html(this.template);return this.element;}});})(jQuery);(function($){$.Chain.service('item',{init:function()
{this.isActive=false;this.isBuilt=false;this.root=this.element;this.data=false;this.datafn=this.dataHandler;},handler:function(obj)
{if(typeof obj=='object')
{return this.handleObject(obj);}
else if(typeof obj=='function')
{return this.handleFunction(obj);}
else
{return this.handleDefault();}},handleObject:function(obj)
{this.setData(obj);this.isActive=true;this.update();return this.element;},handleFunction:function(fn)
{this.datafn=fn;return this.element;},handleDefault:function()
{if(this.isActive)
{return this.getData();}
else
{return false;}},getData:function()
{this.data=this.datafn.call(this.element,this.data);return this.data;},setData:function(obj)
{var data;if($.Chain.jobject(obj)&&obj.item())
{data=$.extend({},obj.item());}
else if($.Chain.jobject(obj))
{data={};}
else
{data=obj;}
this.data=this.datafn.call(this.element,this.data||data,data);if(this.linkElement&&this.linkElement[0]!=obj[0])
{var el=this.linkFunction();if($.Chain.jobject(el)&&el.length&&el.item())
{el.item(this.data);}}},dataHandler:function(oldval,newval)
{if(arguments.length==2)
{return $.extend(oldval,newval);}
else
{return oldval;}},update:function()
{return this.element.update();},build:function()
{var fix=this.element.chain('template','raw').replace(/jQuery\d+\=\"null\"/gi,"");this.element.chain('anchor').html(fix);if(!$.Chain.jidentic(this.root,this.element))
{var plugins=this.root.chain('plugin');for(var i in plugins)
{plugins[i].apply(this.element,[this.root]);}}
this.element.chain('builder').apply(this.element,[this.root]);this.isBuilt=true;},$update:function()
{if(this.element.chain('active')&&this.isActive&&!this.isBuilt&&this.getData())
{this.build();}
return this.element;},$replace:function(obj)
{this.data={};this.setData(obj);this.isActive=true;this.update();return this.element;},$remove:function(noupdate)
{this.element.chain('destroy');this.element.remove();this.element.item('link',null);this.element.item('destroy');if(!$.Chain.jidentic(this.root,this.element)&&!noupdate)
{this.root.update();}},$active:function()
{return this.isActive;},$root:function(root)
{if(arguments.length)
{this.root=root;this.update();return this.element;}
else
{return this.root;}},$backup:function()
{this.isBuilt=false;return this.element;},$link:function(element,collection)
{if(this.linkElement)
{this.linkElement.unbind('update',this.linkUpdater);this.linkElement=null;}
element=$(element);if(element.length)
{var self=this;this.isActive=true;this.linkElement=element;this.linkFunction=function()
{if(typeof collection=='function')
{try{return collection.call(self.element,self.linkElement);}catch(e){return $().eq(-1);}}
else if(typeof collection=='string')
{return self.linkElement.items('collection',collection);}
else
{return $().eq(-1);}};this.linkUpdater=function()
{var res=self.linkFunction();if(res&&res.length)
{self.element.item(res);}};this.linkElement.bind('update',this.linkUpdater);this.linkUpdater();}
return this.element;},$destroy:function()
{return this.element;}});})(jQuery);(function($){$.Chain.service('items',{collections:{all:function()
{return this.element.chain('anchor').children('.chain-item');},visible:function()
{return this.element.chain('anchor').children('.chain-item:visible');},hidden:function()
{return this.element.chain('anchor').children('.chain-item:hidden');},self:function()
{return this.element;}},init:function()
{this.isActive=false;this.pushBuffer=[];this.shiftBuffer=[];this.collections=$.extend({},this.collections);},handler:function(obj)
{if(obj instanceof Array)
{return this.handleArray(obj);}
else if(!this.isActive)
{return $().eq(-1);}
else if($.Chain.jobject(obj))
{return this.handleElement(obj);}
else if(typeof obj=='object')
{return this.handleObject(obj);}
else if(typeof obj=='number')
{return this.handleNumber(obj);}
else if(obj===true)
{return this.handleTrue();}
else
{return this.handleDefault();}},handleObject:function(obj)
{return this.collection('all').filter(function(){return $(this).item()==obj;});},handleElement:function(obj)
{if(!$.Chain.jidentic(obj,obj.item('root'))&&$.Chain.jidentic(this.element,obj.item('root')))
{return obj;}
else
{return $().eq(-1);}},handleArray:function(array)
{return this.$merge(array);},handleNumber:function(number)
{if(number==-1)
{return this.collection('visible').filter(':last');}
else
{return this.collection('visible').eq(number);}},handleTrue:function()
{return this.collection('all');},handleDefault:function()
{return this.collection('visible');},update:function()
{this.element.update();},empty:function()
{var all=this.collection('all');setTimeout(function(){all.each(function(){$(this).item('remove',true);});},1);this.element.chain('anchor').empty();},collection:function(col,fn)
{if(arguments.length>1)
{if(typeof fn=='function')
{this.collections[col]=fn;}
return this.element;}
else
{if(this.collections[col])
{return this.collections[col].apply(this);}
else
{return $().eq(-1);}}},$update:function()
{if(!this.element.chain('active')||!this.isActive)
{return this.element;}
var self=this;var builder=this.element.chain('builder');var template=this.element.chain('template');var push;var iterator=function(){var clone=template.clone()[push?'appendTo':'prependTo'](self.element.chain('anchor')).addClass('chain-item').item('root',self.element);if(self.linkElement&&$.Chain.jobject(this)&&this.item())
{clone.item('link',this,'self');}
else
{clone.item(this);}
clone.chain(builder);};push=false;$.each(this.shiftBuffer,iterator);push=true;$.each(this.pushBuffer,iterator);this.shiftBuffer=[];this.pushBuffer=[];return this.element;},$add:function()
{if(this.linkElement)
{return this.element;}
var cmd;var args=Array.prototype.slice.call(arguments);if(typeof args[0]=='string')
{cmd=args.shift();}
var buffer=(cmd=='shift')?'shiftBuffer':'pushBuffer';this.isActive=true;this[buffer]=this[buffer].concat(args);this.update();return this.element;},$merge:function(cmd,items)
{if(this.linkElement)
{return this.element;}
if(typeof cmd!='string')
{items=cmd;}
var buffer=(cmd=='shift')?'shiftBuffer':'pushBuffer';this.isActive=true;if($.Chain.jobject(items))
{this[buffer]=this[buffer].concat(items.map(function(){return $(this);}).get());}
else if(items instanceof Array)
{this[buffer]=this[buffer].concat(items);}
this.update();return this.element;},$replace:function(cmd,items)
{if(this.linkElement&&arguments.callee.caller!=this.linkUpdater)
{return this.element;}
if(typeof cmd!='string')
{items=cmd;}
var buffer=(cmd=='shift')?'shiftBuffer':'pushBuffer';this.isActive=true;this.empty();if($.Chain.jobject(items))
{this[buffer]=items.map(function(){return $(this);}).get();}
else if(items instanceof Array)
{this[buffer]=items;}
this.update();return this.element;},$remove:function()
{if(this.linkElement)
{return this.element;}
for(var i=0;i<arguments.length;i++)
{this.handler(arguments[i]).item('remove',true);}
this.update();return this.element;},$reorder:function(item1,item2)
{if(item2)
{this.handler(item1).before(this.handler(item2));}
else
{this.handler(item1).appendTo(this.element.chain('anchor'));}
this.update();return this.element;},$empty:function()
{if(this.linkElement)
{return this.element;}
this.empty();this.shiftBuffer=[];this.pushBuffer=[];this.update();return this.element;},$data:function(x)
{return this.handler(x).map(function(){return $(this).item();}).get();},$link:function(element,collection)
{if(this.linkElement)
{this.linkElement.unbind('update',this.linkUpdater);this.linkElement=null;}
element=$(element);if(element.length)
{var self=this;this.linkElement=element;this.linkFunction=function()
{if(typeof collection=='function')
{try{return collection.call(self.element,self.linkElement);}catch(e){return $().eq(-1);}}
else if(typeof collection=='string')
{return self.linkElement.items('collection',collection);}
else
{return $().eq(-1);}};this.linkUpdater=function()
{self.$replace(self.linkFunction());};this.linkElement.bind('update',this.linkUpdater);this.linkUpdater();}
return this.element;},$index:function(item)
{return this.collection('all').index(this.handler(item));},$collection:function()
{return this.collection.apply(this,Array.prototype.slice.call(arguments));},$active:function()
{return this.isActive;},$backup:function()
{if(!this.element.chain('active')||!this.isActive)
{return this.element;}
var buffer=[];this.collection('all').each(function(){var item=$(this).item();if(item)
{buffer.push(item);}});this.pushBuffer=buffer.concat(this.pushBuffer);this.empty();return this.element;},$destroy:function()
{this.empty();return this.element;}});$.Chain.extend('items',{doFilter:function()
{var props=this.searchProperties;var text=this.searchText;if(text)
{if(typeof text=='string')
{text=text.toLowerCase();}
var items=this.element.items(true).filter(function(){var data=$(this).item();if(props)
{for(var i=0;i<props.length;i++)
{if(typeof data[props[i]]=='string'&&!!(typeof text=='string'?data[props[i]].toLowerCase():data[props[i]]).match(text))
{return true;}}}
else
{for(var prop in data)
{if(typeof data[prop]=='string'&&!!(typeof text=='string'?data[prop].toLowerCase():data[prop]).match(text))
{return true;}}}});this.element.items(true).not(items).hide();items.show();}
else
{this.element.items(true).show();this.element.unbind('preupdate',this.searchBinding);this.searchBinding=null;}},$filter:function(text,properties)
{if(!arguments.length)
{return this.update();}
this.searchText=text;if(typeof properties=='string')
{this.searchProperties=[properties];}
else if(properties instanceof Array)
{this.searchProperties=properties;}
else
{this.searchProperties=null;}
if(!this.searchBinding)
{var self=this;this.searchBinding=function(event,item){self.doFilter();};this.element.bind('preupdate',this.searchBinding);}
return this.update();}});$.Chain.extend('items',{doSort:function()
{var name=this.sortName;var opt=this.sortOpt;var sorter={'number':function(a,b){return parseFloat(($(a).item()[name]+'').match(/\d+/gi)[0])>parseFloat(($(b).item()[name]+'').match(/\d+/gi)[0]);},'default':function(a,b){return $(a).item()[name]>$(b).item()[name];}};if(name)
{var sortfn=opt.fn||sorter[opt.type]||sorter['default'];var array=this.element.items(true).get().sort(sortfn);array=opt.desc?array.reverse():array;for(var i=0;i<array.length;i++)
{this.element.chain('anchor').append(array[i]);}
opt.desc=opt.toggle?!opt.desc:opt.desc;}
else
{this.element.unbind('preupdate',this.sortBinding);this.sortBinding=null;}},$sort:function(name,opt)
{if(!name&&name!==null&&name!==false)
{return this.update();}
if(this.sortName!=name)
{this.sortOpt=$.extend({desc:false,type:'default',toggle:false},opt);}
else
{$.extend(this.sortOpt,opt);}
this.sortName=name;if(!this.sortBinding)
{var self=this;this.sortBinding=function(event,item){self.doSort();};this.element.bind('preupdate',this.sortBinding);}
return this.update();}});})(jQuery);

//hotkeys
(function(B){B.fn.__bind__=B.fn.bind;B.fn.__unbind__=B.fn.unbind;B.fn.__find__=B.fn.find;var A={version:"0.7.8",override:/keydown|keypress|keyup/g,triggersMap:{},specialKeys:{27:"esc",9:"tab",32:"space",13:"return",8:"backspace",145:"scroll",20:"capslock",144:"numlock",19:"pause",45:"insert",36:"home",46:"del",35:"end",33:"pageup",34:"pagedown",37:"left",38:"up",39:"right",40:"down",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|"},newTrigger:function(E,D,F){var C={};C[E]={};C[E][D]={cb:F,disableInInput:false};return C}};if(B.browser.mozilla){A.specialKeys=B.extend(A.specialKeys,{96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"})}B.fn.find=function(C){this.query=C;return B.fn.__find__.apply(this,arguments)};B.fn.unbind=function(H,E,G){if(B.isFunction(E)){G=E;E=null}if(E&&typeof E==="string"){var F=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();var D=H.split(" ");for(var C=0;C<D.length;C++){delete A.triggersMap[F][D[C]][E]}}return this.__unbind__(H,G)};B.fn.bind=function(J,F,K){var H=J.match(A.override);if(B.isFunction(F)||!H){return this.__bind__(J,F,K)}else{var N=null,I=B.trim(J.replace(A.override,""));if(I){N=this.__bind__(I,F,K)}if(typeof F==="string"){F={combi:F}}if(F.combi){for(var M=0;M<H.length;M++){var D=H[M];var G=F.combi.toLowerCase(),E=A.newTrigger(D,G,K),L=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();E[D][G].disableInInput=F.disableInInput;if(!A.triggersMap[L]){A.triggersMap[L]=E}else{if(!A.triggersMap[L][D]){A.triggersMap[L][D]=E[D]}}var C=A.triggersMap[L][D][G];if(!C){A.triggersMap[L][D][G]=[E[D][G]]}else{if(C.constructor!==Array){A.triggersMap[L][D][G]=[C]}else{A.triggersMap[L][D][G][C.length]=E[D][G]}}this.each(function(){var O=B(this);if(O.attr("hkId")&&O.attr("hkId")!==L){L=O.attr("hkId")+";"+L}O.attr("hkId",L)});N=this.__bind__(H.join(" "),F,A.handler)}}return N}};A.findElement=function(C){if(!B(C).attr("hkId")){if(B.browser.opera||B.browser.safari){while(!B(C).attr("hkId")&&C.parentNode){C=C.parentNode}}}return C};A.handler=function(E){var O=A.findElement(E.currentTarget),I=B(O),D=I.attr("hkId");if(D){D=D.split(";");var G=E.which,Q=E.type,P=A.specialKeys[G],N=!P&&String.fromCharCode(G).toLowerCase(),H=E.shiftKey,C=E.ctrlKey,M=E.altKey||E.originalEvent.altKey,F=null;for(var R=0;R<D.length;R++){if(A.triggersMap[D[R]][Q]){F=A.triggersMap[D[R]][Q];break}}if(F){var J;if(!H&&!C&&!M){J=F[P]||(N&&F[N])}else{var L="";if(M){L+="alt+"}if(C){L+="ctrl+"}if(H){L+="shift+"}J=F[L+P];if(!J){if(N){J=F[L+N]||F[L+A.shiftNums[N]]||(L==="shift+"&&F[A.shiftNums[N]])}}}if(J){var S=false;for(var R=0;R<J.length;R++){if(J[R].disableInInput){var K=B(E.target);if(I.is("input")||I.is("textarea")||K.is("input")||K.is("textarea")){return true}}S=S||J[R].cb.apply(this,[E])}return S}}}};window.hotkeys=A;return B})(jQuery);

//interaction
(function($){$.Interaction={services:{},add:function(name,proto)
{var services=$.Interaction.services;services[name]=$.extend({},this.base,proto);$.fn[name]=function(options)
{var service=this.data('interaction-'+name);if(typeof options!='string')
{if(service)
service.$destroy();this.data('interaction-'+name,$.extend({element:this,name:name},services[name]));service=this.data('interaction-'+name);service.init(options);return this;}
else
{var command=options;options=Array.prototype.slice.call(arguments,1);if(command=='?')
return!!service;else if(service&&typeof service['$'+command]=='function')
return service['$'+command].apply(service,options);else
return services[name]['$'+command].apply({isEnabled:false,dummy:true},options);}}},extend:function(name,proto)
{if(this.services[name])
this.services[name]=$.extend(this.services[name],proto);},listeners:{},listen:function(service,name,fn)
{if(!this.listeners[service])
this.listeners[service]={};var obj={};if(typeof name=='string')
obj[name]=fn;else if(typeof name=='object')
obj=name;for(var n in obj)
{if(!this.listeners[service][n])
this.listeners[service][n]=[];this.listeners[service][n].push(obj[n]);}},defaults:function(service,defaults)
{if(this.services[service])
$.extend(this.services[service].defaults,defaults);}};$.Interaction.base={init:function()
{this.base();},base:function()
{this.setting=$.extend({},(typeof this.defaults=='function')?this.defaults():this.defaults||{});this.functionWrappers=[];this.temp={};this.isEnabled=true;this.listeners={};var listeners=$.Interaction.listeners[this.name]||{};for(var i in listeners)
this.listeners[i]=[].concat(listeners[i]);this.element.addClass('interaction-'+this.name);var self=this;this.element.chain('plugin',this.name,function(){self.builder($(this));});this.element.bind('destroy',function(){self.$destroy();});},wrap:function(fn)
{var self=this;var args=Array.prototype.slice.call(arguments,1);var array=this.functionWrappers;var wrap;if(typeof fn=='string')
fn=self[fn];for(var i=0;i<array.length;i++)
{if(array[i].src==fn)
{wrap=array[i];break;}}
if(!wrap)
{wrap={src:fn,fn:function(){return fn.apply(self,Array.prototype.slice.call(arguments).concat(args));}};array.push(wrap);}
return wrap.fn;},builder:function(item)
{},addListener:function(name,fn)
{if(!this.listeners[name])
this.listeners[name]=[];this.listeners[name].push(fn);},removeListener:function(name,fn)
{if(!this.listeners[name])
this.listeners[name]=[];if(fn)
{var res=[];for(var i=0;i<this.listeners[name].length;i++)
if(this.listeners[name][i]!=fn)
res.push(this.listeners[name][i]);this.listeners[name]=res;}
else
{this.listeners[name]=[];}},extractListener:function()
{for(var i=0;i<arguments.length;i++)
{if(this.setting[arguments[i]])
this.addListener('$'+arguments[i],this.setting[arguments[i]]);}},callListener:function(name)
{if(!this.listeners[name])
this.listeners[name]=[];if(!this.listeners['$'+name])
this.listeners['$'+name]=[];var args=Array.prototype.slice.call(arguments,1);for(var i=0;i<this.listeners[name].length;i++)
this.listeners[name][i].apply(this,args);for(var i=0;i<this.listeners['$'+name].length;i++)
this.listeners['$'+name][i].apply(this.element,[this].concat(args));},destroy:function()
{this.element.unbind('.'+this.name);this.element.removeData('interaction-'+this.name);this.element.removeClass('interaction-'+this.name);this.element.chain('plugin',this.name,null);this.element.items().each(function(){$(this).unbind('.'+this.name+'-item');});this.callListener('destroy');},$listen:function(name,fn)
{if(this.dummy)return this.element;var obj={};if(typeof name=='string')
obj[name]=fn;else if(typeof name=='object')
obj=name;for(var n in obj)
this.addListener('$'+n,obj[n]);return this.element;},$unlisten:function(name,fn)
{if(this.dummy)return this.element;this.removeListener('$'+name,fn);return this.element;},$service:function()
{return this.dummy?null:this;},$destroy:function()
{if(!this.dummy)
this.destroy();return this.element;},$enable:function()
{if(this.dummy)return this.element;this.isEnabled=true;this.callListener('enable');return this.element;},$disable:function()
{if(this.dummy)return this.element;if(this.mouseUp)
this.mouseUp(this.mouseDownEvent);this.isEnabled=false;this.callListener('disable');return this.element;}};$.Interaction.mouse={mouseDown:function(event)
{var self=this;if(this.isMouseStarted)
this.mouseUp(event);this.mouseDownEvent=event;var cancel=(typeof this.setting.cancel=='string'&&$(event.target).parents().add(event.target).filter(this.setting.cancel).length);if(event.which!=1||this.mouseCapture(event)||cancel)
return false;this.isMouseDelayMet=false;setTimeout(function(){self.isMouseDelayMet=true;},this.setting.delay);if(event.preventDefault)
event.preventDefault();if($.browser.msie)
document.onselectstart=function(){return false};$(document).bind('mousemove.'+this.name,this.wrap('mouseMove')).bind('mouseup.'+this.name,this.wrap('mouseUp'));return true;},mouseMove:function(event)
{if($.browser.msie&&!event.button)
{this.mouseUp(event);return false;}
this.mouseMoveEvent=event;if(this.isMouseStarted)
{this.mouseDrag(event);}
else if(this.mouseDistanceMet(event)&&this.mouseDelayMet(event))
{this.isMouseStarted=this.mouseStart(event);if(this.isMouseStarted)
this.mouseDrag(event);else
this.mouseUp(event);}
return this.isMouseStarted;},mouseUp:function(event)
{$(document).unbind('mousemove.'+this.name,this.wrap('mouseMove')).unbind('mouseup.'+this.name,this.wrap('mouseUp'));if($.browser.msie)
document.onselectstart=function(){return true;};if(this.isMouseStarted)
{this.isMouseStarted=false;this.mouseStop(event);}},mouseDistanceMet:function(e){return(Math.max(Math.abs(this.mouseDownEvent.pageX-e.pageX),Math.abs(this.mouseDownEvent.pageY-e.pageY))>=this.setting.distance);},mouseDelayMet:function(e){return this.isMouseDelayMet;},mouseStart:function(){return false;},mouseDrag:function(){return false;},mouseStop:function(){return false;},mouseCapture:function(){return false;}};})(jQuery);(function($){$.Interaction.add('draggable',$.extend({},$.Interaction.mouse,{defaults:{helper:function(e){return $(e).clone();},handle:null,classPrefix:'drag-',container:null,cancel:':input',cursorAt:null,axis:'xy',delay:0,distance:0},init:function(setting)
{this.base();$.extend(this.setting,setting);if(!$('#interaction-draggable-container').length)
$('<div>').attr('id','interaction-draggable-container').css('position','absolute').hide().appendTo(document.body);this.container=$(this.setting.container||'#interaction-draggable-container');this.cursor=null;this.position={x:0,y:0};this.extractListener('start','drag','stop');this.callListener('init');},builder:function(item)
{var self=this;this.getHandle(item).bind('mousedown.draggable-item',function(event){if(self.isEnabled)
{self.item=item;self.mouseDown(event);}});this.callListener('build',item);},mouseStart:function(event)
{if(!this.item||!this.item.length)
return this.mouseUp(event);var offset=this.item.eq(0).offset();if(!this.cursor)
{this.cursor={};if(this.setting.cursorAt)
{this.cursor.left=this.setting.cursorAt.left;this.cursor.top=this.setting.cursorAt.top;}
else
{this.cursor.left=event.pageX-offset.left;this.cursor.top=event.pageY-offset.top;}}
if(this.setting.axis=='y')
this.container[0].style.left=offset.left+'px';else if(this.setting.axis=='x')
this.container[0].style.top=offset.top+'px';this.mouseDrag(event);this.container.empty().append(this.setting.helper(this.item)).show();this.callListener('start');return true;},mouseDrag:function(event)
{this.position.x=event.pageX;this.position.y=event.pageY;if(this.setting.axis!='y')
this.container[0].style.left=(this.position.x-this.cursor.left)+'px';if(this.setting.axis!='x')
this.container[0].style.top=(this.position.y-this.cursor.top)+'px';this.callListener('drag');return true;},mouseStop:function(event)
{this.container.empty().hide();this.callListener('stop');this.cursor=null;return true;},getHandle:function(item)
{return this.setting.handle?item.find(this.setting.handle):item;}}));$.Interaction.listen('draggable',{start:function()
{if(!this.setting.cursor)
return;var body=$('body');this.temp.bodyCursor=body.css('cursor');body.css('cursor',this.setting.cursor);this.container.css('cursor',this.setting.cursor).children().css('cursor',this.setting.cursor);},stop:function()
{if(!this.setting.cursor)
return;$('body').css('cursor',this.temp.bodyCursor);}});$.Interaction.listen('draggable',{init:function()
{if(this.setting.opacity)
this.container.css('opacity',this.setting.opacity);}})
$.Interaction.defaults('draggable',{scroll:true,scrollArea:20,scrollSpeed:20});$.Interaction.listen('draggable',{start:function()
{if(!this.setting.scroll)
return;var self=this;var el=this.setting.scrollElement?$(this.setting.scrollElement)[0]:this.element.chain('anchor')[0];var offset=$(el).offset();$.extend(offset,{scrollHeight:0,scrollWidth:0,height:el.offsetHeight,width:el.offsetWidth});$(el).children().each(function(){offset.scrollHeight+=this.offsetHeight;offset.scrollWidth+=this.offsetWidth;});this.temp.scrollInt=setInterval(function(){var s=self.setting;var pos=self.position;var doc=$(document);if(offset.scrollHeight>offset.height&&Math.abs(pos.y-offset.top)<s.scrollArea)
el.scrollTop-=s.scrollSpeed;if(offset.scrollHeight>offset.height&&Math.abs(offset.top+offset.height-pos.y)<s.scrollArea)
el.scrollTop+=s.scrollSpeed;if(offset.scrollWidth>offset.width&&Math.abs(pos.x-offset.left)<s.scrollArea)
el.scrollLeft-=s.scrollSpeed;if(offset.scrollWidth>offset.width&&Math.abs(offset.left+offset.width-pos.x)<s.scrollArea)
el.scrollLeft+=s.scrollSpeed;if(pos.y-doc.scrollTop()<s.scrollArea)
doc.scrollTop(doc.scrollTop()-s.scrollSpeed);if(window.innerHeight-(pos.y-doc.scrollTop())<s.scrollArea)
doc.scrollTop(doc.scrollTop()+s.scrollSpeed);if(pos.x-doc.scrollLeft()<s.scrollArea)
doc.scrollLeft(doc.scrollLeft()-s.scrollSpeed);if(window.innerWidth-(pos.x-doc.scrollLeft())<s.scrollArea)
doc.scrollLeft(doc.scrollLeft()+s.scrollSpeed);},200);},stop:function()
{if(!this.setting.scroll)
return;clearInterval(this.temp.scrollInt);}});})(jQuery);(function($){$.Interaction.ddmanager=ddmanager={droppables:[],draggable:null,status:'',getAllDroppables:function()
{return $('.interaction-droppable').map(function(){return this.data('interaction-droppable')}).get();}};$.Interaction.add('droppable',{defaults:{accept:function(){return true;},classPrefix:'drop-',activeClass:'active',hoverClass:'hover',dynamic:true,nested:false},init:function(setting)
{this.base();this.setting=$.extend(this.setting,setting);this.droppables=[];this.isOver=false;this.childOver=false;if(typeof this.setting.accept=='string')
{var className=this.setting.accept;this.setting.accept=function(element){return element.hasClass(className)};}
this.extractListener('over','out','active','deactive','drop');this.updateParent();this.refreshOffset();this.callListener('init');},refreshOffset:function()
{var element=this.element.get(0);var offset=this.element.offset();this.offset={width:element.offsetWidth,height:element.offsetHeight,top:offset.top,left:offset.left};},intersect:function(draggable)
{if(this.setting.dynamic)
this.refreshOffset();return draggable.position.x>=this.offset.left&&draggable.position.y>=this.offset.top&&draggable.position.x<=this.offset.left+this.offset.width&&draggable.position.y<=this.offset.top+this.offset.height;},updateParent:function()
{var oldparent=this.parent||ddmanager;var parent=this.element.parents('.interaction-droppable').eq(0);this.parent=parent.length?parent.data('interaction-droppable'):false;if(this.parent!=oldparent)
{var droppables=[];for(var i=0;i<oldparent.droppables.length;i++)
if(oldparent.droppables[i]!=this)
droppables.push(oldparent.droppables[i]);oldparent.droppables=droppables;(this.parent||ddmanager).droppables.push(this);}},setStatus:function(stat)
{ddmanager.status=stat;},mouseStart:function()
{$.each(this.droppables,function(){this.mouseStart();});if(!this.isEnabled)return;this.updateParent();if(this.setting.accept(ddmanager.draggable.element,ddmanager.draggable.item))
{this.isActive=true;this.dragActive();}},mouseDrag:function()
{$.each(this.droppables,function(){if(!this.setting.nested)
this.mouseDrag();});var intersect=false;if(this.isEnabled&&this.isActive)
{intersect=this.intersect(ddmanager.draggable);if(intersect)
$.each(this.droppables,function(){if(this.setting.nested)
this.mouseDrag();});if((!intersect||(intersect&&this.childOver))&&this.isOver)
{this.dragOut();this.isOver=false;if(this.parent&&this.setting.nested&&!this.childOver)
this.parent.childOver=false;}
else if(!this.isOver&&intersect&&!this.childOver)
{this.dragOver();this.isOver=true;if(this.parent&&this.setting.nested)
this.parent.childOver=true;}
else if(this.childOver&&this.parent&&this.setting.nested)
this.parent.childOver=true;}},mouseStop:function()
{$.each(this.droppables,function(){this.mouseStop();});var intersect=this.intersect(ddmanager.draggable);if(this.isActive&&intersect&&!this.childOver)
this.dragDrop();this.dragDeactive();this.isActive=false;this.isOver=false;this.childOver=false;},dragActive:function()
{this.callListener('active',ddmanager.draggable.item);},dragDeactive:function()
{this.callListener('deactive',ddmanager.draggable.item);},dragOver:function()
{this.callListener('over',ddmanager.draggable.item);},dragOut:function()
{this.callListener('out',ddmanager.draggable.item);},dragDrop:function()
{this.callListener('drop',ddmanager.draggable.item);},$destroy:function()
{if(!this.dummy)
{var droppables=[];var parent=this.parent||ddmanager;for(var i=0;i<parent.droppables.length;i++)
if(parent.droppables[i]!=this)
droppables.push(parent.droppables[i]);parent.droppables=droppables;this.destroy();}
return this.element;}});$.Interaction.listen('draggable',{start:function()
{ddmanager.draggable=this;$.each(ddmanager.droppables,function(){this.mouseStart();})},drag:function()
{if(ddmanager.status!=this.lastDragStatus)
{if(this.lastDragStatus)
this.container.removeClass(this.setting.classPrefix+this.lastDragStatus);if(ddmanager.status)
this.container.addClass(this.setting.classPrefix+ddmanager.status);this.lastDragStatus=ddmanager.status;}
$.each(ddmanager.droppables,function(){this.mouseDrag();})},stop:function()
{$.each(ddmanager.droppables,function()
{this.mouseStop();});ddmanager.draggable=null;ddmanager.status='';}});$.Interaction.listen('droppable',{active:function()
{this.element.addClass(this.setting.classPrefix+this.setting.activeClass);},deactive:function()
{this.element.removeClass(this.setting.classPrefix+this.setting.activeClass);this.element.removeClass(this.setting.classPrefix+this.setting.hoverClass);},over:function()
{this.element.addClass(this.setting.classPrefix+this.setting.hoverClass);},out:function()
{this.element.removeClass(this.setting.classPrefix+this.setting.hoverClass);}});})(jQuery);(function($){$.Interaction.add('sortable',{defaults:{marker:'transparent',boundary:6,align:'vertical',accept:function(){return false},method:'move'},init:function(setting)
{this.base();$.extend(this.setting,setting);this.parseMarker();if(!this.element.data('interaction-draggable'))
this.element.draggable({start:this.wrap('mouseStart'),drag:this.wrap('mouseDrag'),stop:this.wrap('mouseStop')});else
this.element.draggable('listen',{start:this.wrap('mouseStart'),drag:this.wrap('mouseDrag'),stop:this.wrap('mouseStop')});if(this.setting.accept)
{if(typeof this.setting.accept=='string')
{var className=this.setting.accept;this.setting.accept=function(element){return element.hasClass(className)};}
if(!this.element.data('interaction-droppable'))
this.element.droppable({over:this.wrap('dragOver')});else
this.element.droppable('listen',{over:this.wrap('dragOver')});this.element.data('interaction-droppable').setting.dynamic=true;}
this.draggable=this.element.data('interaction-draggable');this.extractListener('reorder','transfer');this.currentIndex=-1;this.lastIndex=-1;this.isActive=false;this.callListener('init');},parseMarker:function()
{if(typeof this.setting.marker=='function')
return;var marker=this.setting.marker;if(marker=='transparent')
marker=function(item){return item.eq(0).clone().css('visibility','hidden');};else if(marker=='separator')
marker=function(item,align){return $('<div></div>').css('overflow','hidden').addClass('interaction-sortable-separator')[(align=='vertical'?'height':'width')](0);};else
marker=function(item){return item.clone();}
this.setting.marker=marker;},mouseStart:function()
{this.isActive=true;this.item=this.draggable.item;this.marker=this.setting.marker(this.item,this.setting.align);this.marker.removeClass('chain-item').addClass('interaction-sortable-marker');this.item.eq(0).before(this.marker);this.item.hide();this.currentIndex=this.marker.parent().children(':visible').index(this.marker);this.lastIndex=this.currentIndex;},mouseDrag:function()
{if(this.item)
{var pos=this.draggable.position;var setting=this.setting;var item=this.item;var marker=this.marker;var self=this;var offset=this.element.offset();offset.height=this.element[0].offsetHeight;offset.width=this.element[0].offsetWidth;if(pos.y<offset.top||pos.y>(offset.top+offset.height)||pos.x<offset.left||pos.x>(offset.left+offset.width))
{item.eq(0).before(marker);return;}
var items=this.element.items();var markerIndex=marker.parent().children(':visible').index(marker);for(var i=0;i<items.length;i++)
{var hover=$(items[i]);var offset=hover.offset();offset.height=hover[0].offsetHeight;offset.width=hover[0].offsetWidth;if(setting.align=='vertical')
{var xy='y';var tl='top';var hw='height';}
else
{var xy='x';var tl='left';var hw='width';}
self.currentIndex=markerIndex;var moved=self.currentIndex!=self.lastIndex;if(hover.prev()[0]!=marker[marker.length-1]&&pos[xy]-offset[tl]>0&&pos[xy]-offset[tl]<setting.boundary)
hover.before(marker);else if(hover.next()[0]!=marker[0]&&offset[tl]+offset[hw]-pos[xy]>0&&offset[tl]+offset[hw]-pos[xy]<setting.boundary)
hover.after(marker);if(moved)
{self.callListener('reorder',item);self.lastIndex=self.currentIndex;break;}}
this.element.items().each(function(){});}},mouseStop:function()
{if(this.item&&$.Chain.jidentic(this.item.item('root'),this.element))
{this.marker.before(this.item);this.item.show();}
this.marker.remove();this.isActive=false;this.item=null;this.marker=null;this.element.update();},dragOver:function(droppable,item,bypass)
{if(bypass||item.item('root')[0]==this.element[0])
return;var sortable=item.item('root').data('interaction-sortable');if(this.setting.accept(sortable.element,item))
{var cursor=sortable.draggable.cursor;var newItem=$().eq(-1);var data=item.map(function(){return $(this).item();}).get();this.element.items('merge',data);for(var i=0;i<data.length;i++)
newItem=newItem.add(this.element.items(data[i]));this.callListener('transfer',item,newItem);if(sortable.setting.method=='move')
{item.each(function(){$(this).item('remove',true);});}
item.item('root').update();this.draggable.item=newItem;this.draggable.cursor=cursor;sortable.draggable.mouseUp(sortable.draggable.mouseDownEvent);var event=sortable.draggable.mouseMoveEvent||sortable.draggable.mouseDownEvent;this.draggable.mouseDown(event);this.draggable.isMouseStarted=this.draggable.mouseStart(event);droppable.callListener('over',item,true);}},$destroy:function()
{this.element.draggable('unlisten','start',this.wrap('mouseStart'));this.element.draggable('unlisten','drag',this.wrap('mouseDrag'));this.element.draggable('unlisten','stop',this.wrap('mouseStop'));}});})(jQuery);(function($){$.Interaction.add('selectable',{defaults:{multiple:false,required:false,selected:null,handle:null,selectClass:'selected',nested:false,drag:false},init:function(setting)
{this.base();$.extend(this.setting,setting);this.selected=this.setting.selected?$(this.setting.selected):$().eq(-1);var self=this;this.element.items('collection','selected',function(){return self.getSelected().filter(':visible');});this.element.items('collection','selected-all',function(){return self.getSelected();});this.extractListener('select','unselect','change');this.callListener('init');},builder:function(item)
{var handle,self=this;if(this.setting.handle)
handle=item.find('> '+this.setting.handle+', *:not(.chain-element) '+this.setting.handle).eq(0);if(!handle)
handle=item;item.bind('mousedown.selectable-item',function(event){if(self.isEnabled&&$(event.target).parents().add(event.target).filter(function(){return handle[0]==this;}).length)
return self.mouseDown(event,item);}).bind('click.selectable-item',function(event){if(self.isEnabled&&$(event.target).parents().add(event.target).filter(function(){return handle[0]==this;}).length)
return self.mouseClick(event,item);});if(this.setting.required&&!this.selected.length&&item.parent().children(':visible').index(item)==0)
this.select(item);else if(this.selected.index(item)>-1)
this.select(item);},mouseDown:function(event,item)
{this.mouseDownEvent=event;var draggable=this.element.draggable('service');if(draggable&&this.$selected(item)&&this.setting.drag)
{draggable.mouseUp(draggable.mouseDownEvent);draggable.item=this.selected.filter(':visible');draggable.mouseDown(event);}},mouseClick:function(event,item)
{if($.browser.msie&&this.mouseDownEvent);event=this.mouseDownEvent;if(event.which!=1)
alert(event.which);if(event.metaKey)
{if(this.$selected(item)&&(!this.setting.required||this.selected.length>1))
this.$unselect(item);else
this.$select(item);}
else if(event.shiftKey)
{var selected=this.selected.eq(0);if(selected.length&&!$.Chain.jidentic(item,selected))
{var items=selected.parent().children(':visible');var dir=items.index(selected)<items.index(item)?'next':'prev';var next=selected[dir]();while(next.length)
{selected=selected.add(next);if($.Chain.jidentic(next,item))
break;next=next[dir]();}}
this.clear();this.$select(selected.length?selected:item);}
else
{this.clear();this.$select(item);}},getParent:function()
{return this.setting.nested?this.element.parents('.interaction-selectable').eq(0):$().eq(-1);},getAncestor:function()
{var parent=this.getParent();if(parent.length)
return parent.data('interaction-selectable').getAncestor();else
return this.element;},getNested:function(recursive)
{var selectable=this.element.find('.interaction-selectable').not(this.element.find('.interaction-selectable .interaction-selectable')).filter(function(){var sel=$(this).data('interaction-selectable');return sel?sel.setting.nested:false;});if(!recursive)
return selectable;var res=[];selectable.each(function(){res.push(this);$(this).data('interaction-selectable').getNested(true).each(function(){res.push(this)});});return $(res);},getSelected:function()
{var anchor=this.element.chain('anchor')
var selected=this.selected.filter(function(){return($(this).parent()[0]==anchor[0]);});this.getNested().each(function(){var selectable=$(this).data('interaction-selectable');selected=selected.add(selectable.getSelected());});return selected;},select:function()
{var args=Array.prototype.slice.call(arguments);var self=this;var selected=this.selected;this.getAncestor().data('interaction-selectable').clear();$.each(args,function(){if(this&&typeof this!='boolean')
selected=selected.add(self.element.items(this));});if(!this.setting.multiple)
selected=selected.eq(selected.length-1);selected.addClass(this.setting.selectClass);this.selected=selected;},unselect:function()
{var args=Array.prototype.slice.call(arguments);var self=this;this.selected.removeClass(this.setting.selectClass);$.each(args,function(){if(this&&typeof this!='boolean')
self.selected=self.selected.not(self.element.items(this));});this.selected.addClass(this.setting.selectClass);},clear:function()
{this.selected.removeClass(this.setting.selectClass);this.selected=$().eq(1);this.getNested().each(function(){$(this).data('interaction-selectable').clear();});},$select:function()
{if(!this.isEnabled)return this.element;this.select.apply(this,Array.prototype.slice.call(arguments));this.callListener('select');this.callListener('change');return this.element;},$unselect:function()
{if(!this.isEnabled)return this.element;this.unselect.apply(this,Array.prototype.slice.call(arguments));this.callListener('unselect');this.callListener('change');return this.element;},$clear:function()
{if(!this.isEnabled)return this.element;this.clear();this.callListener('unselect');this.callListener('change');return this.element;},$selected:function(item)
{if(!this.isEnabled)return $().eq(-1);if(item===true)
return this.getSelected();else if(arguments.length&&typeof item!='boolean'&&item!==null)
return this.selected.index(this.element.items(item))>-1;else
return this.getSelected().filter(':visible');}});$.Interaction.listen('selectable',{change:function()
{this.element.update();}});})(jQuery);

// LiveValidation 1.3 (standalone version)
// Copyright (c) 2007-2008 Alec Hill (www.livevalidation.com)
// LiveValidation is licensed under the terms of the MIT License
var LiveValidation=function(B,A){this.initialize(B,A);};LiveValidation.VERSION="1.3 standalone";LiveValidation.TEXTAREA=1;LiveValidation.TEXT=2;LiveValidation.PASSWORD=3;LiveValidation.CHECKBOX=4;LiveValidation.SELECT=5;LiveValidation.FILE=6;LiveValidation.massValidate=function(C){var D=true;for(var B=0,A=C.length;B<A;++B){var E=C[B].validate();if(D){D=E;}}return D;};LiveValidation.prototype={validClass:"LV_valid",invalidClass:"LV_invalid",messageClass:"LV_validation_message",validFieldClass:"LV_valid_field",invalidFieldClass:"LV_invalid_field",initialize:function(D,C){var A=this;if(!D){throw new Error("LiveValidation::initialize - No element reference or element id has been provided!");}this.element=D.nodeName?D:document.getElementById(D);if(!this.element){throw new Error("LiveValidation::initialize - No element with reference or id of '"+D+"' exists!");}this.validations=[];this.elementType=this.getElementType();this.form=this.element.form;var B=C||{};this.validMessage=B.validMessage||"Thankyou!";var E=B.insertAfterWhatNode||this.element;this.insertAfterWhatNode=E.nodeType?E:document.getElementById(E);this.onValid=B.onValid||function(){this.insertMessage(this.createMessageSpan());this.addFieldClass();};this.onInvalid=B.onInvalid||function(){this.insertMessage(this.createMessageSpan());this.addFieldClass();};this.onlyOnBlur=B.onlyOnBlur||false;this.wait=B.wait||0;this.onlyOnSubmit=B.onlyOnSubmit||false;if(this.form){this.formObj=LiveValidationForm.getInstance(this.form);this.formObj.addField(this);}this.oldOnFocus=this.element.onfocus||function(){};this.oldOnBlur=this.element.onblur||function(){};this.oldOnClick=this.element.onclick||function(){};this.oldOnChange=this.element.onchange||function(){};this.oldOnKeyup=this.element.onkeyup||function(){};this.element.onfocus=function(F){A.doOnFocus(F);return A.oldOnFocus.call(this,F);};if(!this.onlyOnSubmit){switch(this.elementType){case LiveValidation.CHECKBOX:this.element.onclick=function(F){A.validate();return A.oldOnClick.call(this,F);};case LiveValidation.SELECT:case LiveValidation.FILE:this.element.onchange=function(F){A.validate();return A.oldOnChange.call(this,F);};break;default:if(!this.onlyOnBlur){this.element.onkeyup=function(F){A.deferValidation();return A.oldOnKeyup.call(this,F);};}this.element.onblur=function(F){A.doOnBlur(F);return A.oldOnBlur.call(this,F);};}}},destroy:function(){if(this.formObj){this.formObj.removeField(this);this.formObj.destroy();}this.element.onfocus=this.oldOnFocus;if(!this.onlyOnSubmit){switch(this.elementType){case LiveValidation.CHECKBOX:this.element.onclick=this.oldOnClick;case LiveValidation.SELECT:case LiveValidation.FILE:this.element.onchange=this.oldOnChange;break;default:if(!this.onlyOnBlur){this.element.onkeyup=this.oldOnKeyup;}this.element.onblur=this.oldOnBlur;}}this.validations=[];this.removeMessageAndFieldClass();},add:function(A,B){this.validations.push({type:A,params:B||{}});return this;},remove:function(B,D){var E=false;for(var C=0,A=this.validations.length;C<A;C++){if(this.validations[C].type==B){if(this.validations[C].params==D){E=true;break;}}}if(E){this.validations.splice(C,1);}return this;},deferValidation:function(B){if(this.wait>=300){this.removeMessageAndFieldClass();}var A=this;if(this.timeout){clearTimeout(A.timeout);}this.timeout=setTimeout(function(){A.validate();},A.wait);},doOnBlur:function(A){this.focused=false;this.validate(A);},doOnFocus:function(A){this.focused=true;this.removeMessageAndFieldClass();},getElementType:function(){switch(true){case (this.element.nodeName.toUpperCase()=="TEXTAREA"):return LiveValidation.TEXTAREA;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="TEXT"):return LiveValidation.TEXT;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="PASSWORD"):return LiveValidation.PASSWORD;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="CHECKBOX"):return LiveValidation.CHECKBOX;case (this.element.nodeName.toUpperCase()=="INPUT"&&this.element.type.toUpperCase()=="FILE"):return LiveValidation.FILE;case (this.element.nodeName.toUpperCase()=="SELECT"):return LiveValidation.SELECT;case (this.element.nodeName.toUpperCase()=="INPUT"):throw new Error("LiveValidation::getElementType - Cannot use LiveValidation on an "+this.element.type+" input!");default:throw new Error("LiveValidation::getElementType - Element must be an input, select, or textarea!");}},doValidations:function(){this.validationFailed=false;for(var C=0,A=this.validations.length;C<A;++C){var B=this.validations[C];switch(B.type){case Validate.Presence:case Validate.Confirmation:case Validate.Acceptance:this.displayMessageWhenEmpty=true;this.validationFailed=!this.validateElement(B.type,B.params);break;default:this.validationFailed=!this.validateElement(B.type,B.params);break;}if(this.validationFailed){return false;}}this.message=this.validMessage;return true;},validateElement:function(A,C){var D=(this.elementType==LiveValidation.SELECT)?this.element.options[this.element.selectedIndex].value:this.element.value;if(A==Validate.Acceptance){if(this.elementType!=LiveValidation.CHECKBOX){throw new Error("LiveValidation::validateElement - Element to validate acceptance must be a checkbox!");}D=this.element.checked;}var E=true;try{A(D,C);}catch(B){if(B instanceof Validate.Error){if(D!==""||(D===""&&this.displayMessageWhenEmpty)){this.validationFailed=true;this.message=B.message;E=false;}}else{throw B;}}finally{return E;}},validate:function(){if(!this.element.disabled){var A=this.doValidations();if(A){this.onValid();return true;}else{this.onInvalid();return false;}}else{return true;}},enable:function(){this.element.disabled=false;return this;},disable:function(){this.element.disabled=true;this.removeMessageAndFieldClass();return this;},createMessageSpan:function(){var A=document.createElement("span");var B=document.createTextNode(this.message);A.appendChild(B);return A;},insertMessage:function(B){this.removeMessage();if((this.displayMessageWhenEmpty&&(this.elementType==LiveValidation.CHECKBOX||this.element.value==""))||this.element.value!=""){var A=this.validationFailed?this.invalidClass:this.validClass;B.className+=" "+this.messageClass+" "+A;if(this.insertAfterWhatNode.nextSibling){this.insertAfterWhatNode.parentNode.insertBefore(B,this.insertAfterWhatNode.nextSibling);}else{this.insertAfterWhatNode.parentNode.appendChild(B);}}},addFieldClass:function(){this.removeFieldClass();if(!this.validationFailed){if(this.displayMessageWhenEmpty||this.element.value!=""){if(this.element.className.indexOf(this.validFieldClass)==-1){this.element.className+=" "+this.validFieldClass;}}}else{if(this.element.className.indexOf(this.invalidFieldClass)==-1){this.element.className+=" "+this.invalidFieldClass;}}},removeMessage:function(){var A;var B=this.insertAfterWhatNode;while(B.nextSibling){if(B.nextSibling.nodeType===1){A=B.nextSibling;break;}B=B.nextSibling;}if(A&&A.className.indexOf(this.messageClass)!=-1){this.insertAfterWhatNode.parentNode.removeChild(A);}},removeFieldClass:function(){if(this.element.className.indexOf(this.invalidFieldClass)!=-1){this.element.className=this.element.className.split(this.invalidFieldClass).join("");}if(this.element.className.indexOf(this.validFieldClass)!=-1){this.element.className=this.element.className.split(this.validFieldClass).join(" ");}},removeMessageAndFieldClass:function(){this.removeMessage();this.removeFieldClass();}};var LiveValidationForm=function(A){this.initialize(A);};LiveValidationForm.instances={};LiveValidationForm.getInstance=function(A){var B=Math.random()*Math.random();if(!A.id){A.id="formId_"+B.toString().replace(/\./,"")+new Date().valueOf();}if(!LiveValidationForm.instances[A.id]){LiveValidationForm.instances[A.id]=new LiveValidationForm(A);}return LiveValidationForm.instances[A.id];};LiveValidationForm.prototype={initialize:function(B){this.name=B.id;this.element=B;this.fields=[];this.oldOnSubmit=this.element.onsubmit||function(){};var A=this;this.element.onsubmit=function(C){return(LiveValidation.massValidate(A.fields))?A.oldOnSubmit.call(this,C||window.event)!==false:false;};},addField:function(A){this.fields.push(A);},removeField:function(C){var D=[];for(var B=0,A=this.fields.length;B<A;B++){if(this.fields[B]!==C){D.push(this.fields[B]);}}this.fields=D;},destroy:function(A){if(this.fields.length!=0&&!A){return false;}this.element.onsubmit=this.oldOnSubmit;LiveValidationForm.instances[this.name]=null;return true;}};var Validate={Presence:function(B,C){var C=C||{};var A=C.failureMessage||"Can't be empty!";if(B===""||B===null||B===undefined){Validate.fail(A);}return true;},Numericality:function(J,E){var A=J;var J=Number(J);var E=E||{};var F=((E.minimum)||(E.minimum==0))?E.minimum:null;var C=((E.maximum)||(E.maximum==0))?E.maximum:null;var D=((E.is)||(E.is==0))?E.is:null;var G=E.notANumberMessage||"Must be a number!";var H=E.notAnIntegerMessage||"Must be an integer!";var I=E.wrongNumberMessage||"Must be "+D+"!";var B=E.tooLowMessage||"Must not be less than "+F+"!";var K=E.tooHighMessage||"Must not be more than "+C+"!";if(!isFinite(J)){Validate.fail(G);}if(E.onlyInteger&&(/\.0+$|\.$/.test(String(A))||J!=parseInt(J))){Validate.fail(H);}switch(true){case (D!==null):if(J!=Number(D)){Validate.fail(I);}break;case (F!==null&&C!==null):Validate.Numericality(J,{tooLowMessage:B,minimum:F});Validate.Numericality(J,{tooHighMessage:K,maximum:C});break;case (F!==null):if(J<Number(F)){Validate.fail(B);}break;case (C!==null):if(J>Number(C)){Validate.fail(K);}break;}return true;},Format:function(C,E){var C=String(C);var E=E||{};var A=E.failureMessage||"Not valid!";var B=E.pattern||/./;var D=E.negate||false;if(!D&&!B.test(C)){Validate.fail(A);}if(D&&B.test(C)){Validate.fail(A);}return true;},Email:function(B,C){var C=C||{};var A=C.failureMessage||"Must be a valid email address!";Validate.Format(B,{failureMessage:A,pattern:/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i});return true;},Length:function(F,G){var F=String(F);var G=G||{};var E=((G.minimum)||(G.minimum==0))?G.minimum:null;var H=((G.maximum)||(G.maximum==0))?G.maximum:null;var C=((G.is)||(G.is==0))?G.is:null;var A=G.wrongLengthMessage||"Must be "+C+" characters long!";var B=G.tooShortMessage||"Must not be less than "+E+" characters long!";var D=G.tooLongMessage||"Must not be more than "+H+" characters long!";switch(true){case (C!==null):if(F.length!=Number(C)){Validate.fail(A);}break;case (E!==null&&H!==null):Validate.Length(F,{tooShortMessage:B,minimum:E});Validate.Length(F,{tooLongMessage:D,maximum:H});break;case (E!==null):if(F.length<Number(E)){Validate.fail(B);}break;case (H!==null):if(F.length>Number(H)){Validate.fail(D);}break;default:throw new Error("Validate::Length - Length(s) to validate against must be provided!");}return true;},Inclusion:function(H,F){var F=F||{};var K=F.failureMessage||"Must be included in the list!";var G=(F.caseSensitive===false)?false:true;if(F.allowNull&&H==null){return true;}if(!F.allowNull&&H==null){Validate.fail(K);}var D=F.within||[];if(!G){var A=[];for(var C=0,B=D.length;C<B;++C){var I=D[C];if(typeof I=="string"){I=I.toLowerCase();}A.push(I);}D=A;if(typeof H=="string"){H=H.toLowerCase();}}var J=false;for(var E=0,B=D.length;E<B;++E){if(D[E]==H){J=true;}if(F.partialMatch){if(H.indexOf(D[E])!=-1){J=true;}}}if((!F.negate&&!J)||(F.negate&&J)){Validate.fail(K);}return true;},Exclusion:function(A,B){var B=B||{};B.failureMessage=B.failureMessage||"Must not be included in the list!";B.negate=true;Validate.Inclusion(A,B);return true;},Confirmation:function(C,D){if(!D.match){throw new Error("Validate::Confirmation - Error validating confirmation: Id of element to match must be provided!");}var D=D||{};var B=D.failureMessage||"Does not match!";var A=D.match.nodeName?D.match:document.getElementById(D.match);if(!A){throw new Error("Validate::Confirmation - There is no reference with name of, or element with id of '"+D.match+"'!");}if(C!=A.value){Validate.fail(B);}return true;},Acceptance:function(B,C){var C=C||{};var A=C.failureMessage||"Must be accepted!";if(!B){Validate.fail(A);}return true;},Custom:function(D,E){var E=E||{};var B=E.against||function(){return true;};var A=E.args||{};var C=E.failureMessage||"Not valid!";if(!B(D,A)){Validate.fail(C);}return true;},now:function(A,D,C){if(!A){throw new Error("Validate::now - Validation function must be provided!");}var E=true;try{A(D,C||{});}catch(B){if(B instanceof Validate.Error){E=false;}else{throw B;}}finally{return E;}},fail:function(A){throw new Validate.Error(A);},Error:function(A){this.message=A;this.name="ValidationError";}};

//maskedinput

(function($){var pasteEventName=($.browser.msie?'paste':'input')+".mask";$.mask={definitions:{'9':"[0-9]",'a':"[A-Za-z]",'*':"[A-Za-z0-9]"},addPlaceholder:function(c,r){$.mask.definitions[c]=r;}};$.fn.extend({caret:function(begin,end){if(this.length==0)return;if(typeof begin=='number'){end=(typeof end=='number')?end:begin;return this.each(function(){if(this.setSelectionRange){this.focus();this.setSelectionRange(begin,end);}else if(this.createTextRange){var range=this.createTextRange();range.collapse(true);range.moveEnd('character',end);range.moveStart('character',begin);range.select();}});}else{if(this[0].setSelectionRange){begin=this[0].selectionStart;end=this[0].selectionEnd;}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();begin=0-range.duplicate().moveStart('character',-100000);end=begin+range.text.length;}
return{begin:begin,end:end};}},unmask:function(){return this.trigger("unmask");},mask:function(mask,settings){if(!mask&&this.length>0){var input=$(this[0]);var locked=input.data("locked");return $.map(input.data("buffer"),function(c,i){return locked[i]?null:c;}).join('');}
settings=$.extend({placeholder:"_",allowPartial:false,completed:null},settings);var re=new RegExp("^"+
$.map(mask.split(""),function(c,i){return $.mask.definitions[c]||((/[A-Za-z0-9]/.test(c)?"":"\\")+c);}).join('')+"$");return this.each(function(){var input=$(this);var buffer=new Array(mask.length);var locked=new Array(mask.length);var ignore=false;var firstNonMaskPos=null;$.each(mask.split(""),function(i,c){locked[i]=($.mask.definitions[c]==null);buffer[i]=locked[i]?c:settings.placeholder;if(!locked[i]&&firstNonMaskPos==null)
firstNonMaskPos=i;});input.data("buffer",buffer).data("locked",locked);function focusEvent(){var pos=checkVal();writeBuffer();setTimeout(function(){input.caret(pos);},0);};function keydownEvent(e){var pos=$(this).caret();var k=e.keyCode;ignore=(k<16||(k>16&&k<32)||(k>32&&k<41));if((pos.begin-pos.end)!=0&&(!ignore||k==8||k==46)){clearBuffer(pos.begin,pos.end);}
if(k==8){while(pos.begin-->=0){if(!locked[pos.begin]){buffer[pos.begin]=settings.placeholder;writeBuffer();$(this).caret(Math.max(firstNonMaskPos,pos.begin));return false;}}}else if(k==46){clearBuffer(pos.begin,pos.begin+1);writeBuffer();$(this).caret(Math.max(firstNonMaskPos,pos.begin));return false;}else if(k==27){clearBuffer(0,mask.length);writeBuffer();$(this).caret(firstNonMaskPos);return false;}};function keypressEvent(e){if(ignore){ignore=false;return(e.keyCode==8)?false:null;}
e=e||window.event;var k=e.charCode||e.keyCode||e.which;var pos=$(this).caret();if(e.ctrlKey||e.altKey){return true;}else if((k>=41&&k<=122)||k==32||k>186){var p=seekNext(pos.begin-1);if(p<mask.length){var c=String.fromCharCode(k);if(new RegExp($.mask.definitions[mask.charAt(p)]).test(c)){buffer[p]=c;writeBuffer();var next=seekNext(p);$(this).caret(next);if(settings.completed&&next==mask.length)
settings.completed.call(input);}}}
return false;};function clearBuffer(start,end){for(var i=start;i<end&&i<mask.length;i++){if(!locked[i])
buffer[i]=settings.placeholder;}};function writeBuffer(){return input.val(buffer.join('')).val();};function checkVal(){var test=input.val();var pos=firstNonMaskPos;for(var i=0;i<mask.length;i++){if(!locked[i]){buffer[i]=settings.placeholder;while(pos++<test.length){var reChar=new RegExp($.mask.definitions[mask.charAt(i)]);if(test.charAt(pos-1).match(reChar)){buffer[i]=test.charAt(pos-1);break;}}
if(pos>test.length)
break;}}
valid=writeBuffer().match(re);if(!valid&&!settings.allowPartial){input.val("");clearBuffer(0,mask.length);}
return valid?mask.length:(settings.allowPartial?i:firstNonMaskPos);};function seekNext(pos){while(++pos<mask.length){if(!locked[pos])
return pos;}
return mask.length;};input.one("unmask",function(){input.unbind(".mask").removeData("buffer").removeData("locked");}).bind("focus.mask",focusEvent).bind("blur.mask",checkVal).bind("keydown.mask",keydownEvent).bind("keypress.mask",keypressEvent).bind(pasteEventName,function(){setTimeout(checkVal,0);});checkVal();});}});})(jQuery);


