
/* Mootools Class Occlude */
//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.
MooTools.More={version:"1.2.3.1"};Class.refactor=function(b,a){$each(a,function(e,d){var c=b.prototype[d];if(c&&(c=c._origin)&&typeof e=="function"){b.implement(d,function(){var f=this.previous;
this.previous=c;var g=e.apply(this,arguments);this.previous=f;return g;});}else{b.implement(d,e);}});return b;};Class.Mutators.Binds=function(a){return a;
};Class.Mutators.initialize=function(a){return function(){$splat(this.Binds).each(function(b){var c=this[b];if(c){this[b]=c.bind(this);}},this);return a.apply(this,arguments);
};};Class.Occlude=new Class({occlude:function(c,b){b=document.id(b||this.element);var a=b.retrieve(c||this.property);if(a&&!$defined(this.occluded)){this.occluded=a;
}else{this.occluded=false;b.store(c||this.property,this);}return this.occluded;}});Element.implement({tidy:function(){this.set("value",this.get("value").tidy());
},getTextInRange:function(b,a){return this.get("value").substring(b,a);},getSelectedText:function(){if(this.setSelectionRange){return this.getTextInRange(this.getSelectionStart(),this.getSelectionEnd());
}return document.selection.createRange().text;},getSelectedRange:function(){if($defined(this.selectionStart)){return{start:this.selectionStart,end:this.selectionEnd};
}var e={start:0,end:0};var a=this.getDocument().selection.createRange();if(!a||a.parentElement()!=this){return e;}var c=a.duplicate();if(this.type=="text"){e.start=0-c.moveStart("character",-100000);
e.end=e.start+a.text.length;}else{var b=this.get("value");var d=b.length-b.match(/[\n\r]*$/)[0].length;c.moveToElementText(this);c.setEndPoint("StartToEnd",a);
e.end=d-c.text.length;c.setEndPoint("StartToStart",a);e.start=d-c.text.length;}return e;},getSelectionStart:function(){return this.getSelectedRange().start;
},getSelectionEnd:function(){return this.getSelectedRange().end;},setCaretPosition:function(a){if(a=="end"){a=this.get("value").length;}this.selectRange(a,a);
return this;},getCaretPosition:function(){return this.getSelectedRange().start;},selectRange:function(e,a){if(this.setSelectionRange){this.focus();this.setSelectionRange(e,a);
}else{var c=this.get("value");var d=c.substr(e,a-e).replace(/\r/g,"").length;e=c.substr(0,e).replace(/\r/g,"").length;var b=this.createTextRange();b.collapse(true);
b.moveEnd("character",e+d);b.moveStart("character",e);b.select();}return this;},insertAtCursor:function(b,a){var d=this.getSelectedRange();var c=this.get("value");
this.set("value",c.substring(0,d.start)+b+c.substring(d.end,c.length));if($pick(a,true)){this.selectRange(d.start,d.start+b.length);}else{this.setCaretPosition(d.start+b.length);
}return this;},insertAroundCursor:function(b,a){b=$extend({before:"",defaultMiddle:"",after:""},b);var c=this.getSelectedText()||b.defaultMiddle;var g=this.getSelectedRange();
var f=this.get("value");if(g.start==g.end){this.set("value",f.substring(0,g.start)+b.before+c+b.after+f.substring(g.end,f.length));this.selectRange(g.start+b.before.length,g.end+b.before.length+c.length);
}else{var d=f.substring(g.start,g.end);this.set("value",f.substring(0,g.start)+b.before+d+b.after+f.substring(g.end,f.length));var e=g.start+b.before.length;
if($pick(a,true)){this.selectRange(e,e+d.length);}else{this.setCaretPosition(e+f.length);}}return this;}});Element.implement({measure:function(e){var g=function(h){return !!(!h||h.offsetHeight||h.offsetWidth);
};if(g(this)){return e.apply(this);}var d=this.getParent(),b=[],f=[];while(!g(d)&&d!=document.body){b.push(d.expose());d=d.getParent();}var c=this.expose();
var a=e.apply(this);c();b.each(function(h){h();});return a;},expose:function(){if(this.getStyle("display")!="none"){return $empty;}var a=this.style.cssText;
this.setStyles({display:"block",position:"absolute",visibility:"hidden"});return function(){this.style.cssText=a;}.bind(this);},getDimensions:function(a){a=$merge({computeSize:false},a);
var d={};var c=function(f,e){return(e.computeSize)?f.getComputedSize(e):f.getSize();};if(this.getStyle("display")=="none"){d=this.measure(function(){return c(this,a);
});}else{try{d=c(this,a);}catch(b){}}return $chk(d.x)?$extend(d,{width:d.x,height:d.y}):$extend(d,{x:d.width,y:d.height});},getComputedSize:function(a){a=$merge({styles:["padding","border"],plains:{height:["top","bottom"],width:["left","right"]},mode:"both"},a);
var c={width:0,height:0};switch(a.mode){case"vertical":delete c.width;delete a.plains.width;break;case"horizontal":delete c.height;delete a.plains.height;
break;}var b=[];$each(a.plains,function(g,f){g.each(function(h){a.styles.each(function(i){b.push((i=="border")?i+"-"+h+"-width":i+"-"+h);});});});var e={};
b.each(function(f){e[f]=this.getComputedStyle(f);},this);var d=[];$each(a.plains,function(g,f){var h=f.capitalize();c["total"+h]=0;c["computed"+h]=0;g.each(function(i){c["computed"+i.capitalize()]=0;
b.each(function(k,j){if(k.test(i)){e[k]=e[k].toInt()||0;c["total"+h]=c["total"+h]+e[k];c["computed"+i.capitalize()]=c["computed"+i.capitalize()]+e[k];}if(k.test(i)&&f!=k&&(k.test("border")||k.test("padding"))&&!d.contains(k)){d.push(k);
c["computed"+h]=c["computed"+h]-e[k];}});});});["Width","Height"].each(function(g){var f=g.toLowerCase();if(!$chk(c[f])){return;}c[f]=c[f]+this["offset"+g]+c["computed"+g];
c["total"+g]=c[f]+c["total"+g];delete c["computed"+g];},this);return $extend(e,c);}});(function(){var a=Element.prototype.position;Element.implement({position:function(r){if(r&&($defined(r.x)||$defined(r.y))){return a?a.apply(this,arguments):this;
}$each(r||{},function(t,s){if(!$defined(t)){delete r[s];}});r=$merge({relativeTo:document.body,position:{x:"center",y:"center"},edge:false,offset:{x:0,y:0},returnPos:false,relFixedPosition:false,ignoreMargins:false,allowNegative:false},r);
var b={x:0,y:0};var h=false;var c=this.measure(function(){return document.id(this.getOffsetParent());});if(c&&c!=this.getDocument().body){b=c.measure(function(){return this.getPosition();
});h=true;r.offset.x=r.offset.x-b.x;r.offset.y=r.offset.y-b.y;}var q=function(s){if($type(s)!="string"){return s;}s=s.toLowerCase();var t={};if(s.test("left")){t.x="left";
}else{if(s.test("right")){t.x="right";}else{t.x="center";}}if(s.test("upper")||s.test("top")){t.y="top";}else{if(s.test("bottom")){t.y="bottom";}else{t.y="center";
}}return t;};r.edge=q(r.edge);r.position=q(r.position);if(!r.edge){if(r.position.x=="center"&&r.position.y=="center"){r.edge={x:"center",y:"center"};}else{r.edge={x:"left",y:"top"};
}}this.setStyle("position","absolute");var p=document.id(r.relativeTo)||document.body;var i=p==document.body?window.getScroll():p.getPosition();var o=i.y;
var g=i.x;if(Browser.Engine.trident){var l=p.getScrolls();o+=l.y;g+=l.x;}var j=this.getDimensions({computeSize:true,styles:["padding","border","margin"]});
if(r.ignoreMargins){r.offset.x=r.offset.x-j["margin-left"];r.offset.y=r.offset.y-j["margin-top"];}var n={};var d=r.offset.y;var e=r.offset.x;var k=window.getSize();
switch(r.position.x){case"left":n.x=g+e;break;case"right":n.x=g+e+p.offsetWidth;break;default:n.x=g+((p==document.body?k.x:p.offsetWidth)/2)+e;break;}switch(r.position.y){case"top":n.y=o+d;
break;case"bottom":n.y=o+d+p.offsetHeight;break;default:n.y=o+((p==document.body?k.y:p.offsetHeight)/2)+d;break;}if(r.edge){var m={};switch(r.edge.x){case"left":m.x=0;
break;case"right":m.x=-j.x-j.computedRight-j.computedLeft;break;default:m.x=-(j.x/2);break;}switch(r.edge.y){case"top":m.y=0;break;case"bottom":m.y=-j.y-j.computedTop-j.computedBottom;
break;default:m.y=-(j.y/2);break;}n.x=n.x+m.x;n.y=n.y+m.y;}n={left:((n.x>=0||h||r.allowNegative)?n.x:0).toInt(),top:((n.y>=0||h||r.allowNegative)?n.y:0).toInt()};
if(p.getStyle("position")=="fixed"||r.relFixedPosition){var f=window.getScroll();n.top=n.top.toInt()+f.y;n.left=n.left.toInt()+f.x;}if(r.returnPos){return n;
}else{this.setStyles(n);}return this;}});})();Element.implement({isDisplayed:function(){return this.getStyle("display")!="none";},toggle:function(){return this[this.isDisplayed()?"hide":"show"]();
},hide:function(){var b;try{if("none"!=this.getStyle("display")){b=this.getStyle("display");}}catch(a){}return this.store("originalDisplay",b||"block").setStyle("display","none");
},show:function(a){return this.setStyle("display",a||this.retrieve("originalDisplay")||"block");},swapClass:function(a,b){return this.removeClass(a).addClass(b);
}});
var DataInput=new Class({Implements:[Options,Events,Class.Occlude],Binds:['focused','changed','blured','keydowned','datareset'],options:{'onClass':'input-select','offClass':'gray','message':''},element:null,property:'MavInputHint',version:'1.0.0',initialize:function(_elem,_opts){if($type(_elem)=='object'&&!$defined(_opts)){_opts=_elem;_elem=_elem['elem'];delete _opts['elem'];}this.element=$(_elem);if(this.occlude()){return this.occlude;}this.setOptions((_opts||{'message':this.element.defaultValue}));this.element.addEvents({'focus':this.focused,'change':this.changed,'blur':this.blured,'keydown':this.keydowned,'datareset':this.datareset});this.element.addClass(this.options.offClass);},focused:function(){if(this.element.get('tag')=='input'){var elValue=this.element.get('value');var elDValue=this.element.defaultValue;this.element.addClass(this.options.onClass);if(elValue!=elDValue||(elValue==''&&elDValue=='')){this.element.select();this.element.removeClass(this.options.offClass);}else{this.element.selectRange(0,0);}}},changed:function(){if(this.element.get('tag')=='select'){if(this.element.get('value')==''||this.options.selectedIndex==0){if(this.element.get('tag')=='select'){this.element.options[0].selected=true;}this.element.swapClass(this.options.onClass,this.options.offClass);}else{this.element.removeClass(this.options.offClass);}}},blured:function(){if(this.element.get('value')==''){this.element.set('value',this.element.defaultValue);this.element.swapClass(this.options.onClass,this.options.offClass);}else{this.element.removeClass(this.options.onClass);}},keydowned:function(){if(this.element.get('value')==this.element.defaultValue){this.element.swapClass(this.options.offClass,this.options.onClass);this.element.set('value','');}},datareset:function(){this.element.set('value',this.element.defaultValue);this.element.swapClass(this.options.onClass,this.options.offClass);this.element.focus();}});var create_data_inputs=function(){for(var i=0;i<arguments.length;i++){new DataInput(($type(arguments[i])=='element'?arguments[i]:($type(arguments[i])=='object'?$(arguments[i]['elem']):$(arguments[i]))));}};
var MavDialog=new Class({Implements:[Options,Events],Binds:['clickClose','show'],options:{'autoShow':true,'buttons':null,'cancel':null,'cancelAutoClose':true,'cancelClass':'cancel-button','cancelImageClass':'dialog-image-button','cancelText':'Cancel','cancelDestroy':true,'callback':null,'center':true,'clickCloses':false,'defaultButtons':true,'dialogClass':'mav-dialog','draggable':false,'fxOptions':{},'footer':null,'footerClass':'mav-dialog-footer','force':false,'height':'auto','loadingMessage':'loading...','message':null,'messageAreaClass':'mav-dialog-message','messageBoxClass':'mid-float-box','noTitleClass':'mav-no-title','noFooterClass':'mav-no-footer','ok':null,'okAutoClose':true,'okClass':'ok-button','okImageClass':'dialog-image-button','okText':'OK','okDestroy':true,'parent':null,'requestQuery':'','shadeClass':'mavdialog-shade','styles':{},'title':null,'titleBarClass':'mav-dialog-title','titleClose':true,'titleCloseClass':'mav-icon-button md-closer','titleCloseTitle':'Close Dialog','titleTextClass':'md-title-text','url':null,'useFx':true,'width':'400'},initialize:function(_opts){this.setOptions(_opts);var dialogNum=Math.ceil(Math.random()*10000);this.dialogId='mavd'+dialogNum+'_dialog';if($(this.dialogId+'_dialog')){return null;}this.request=new Request({'url':'','onSuccess':this.urlRequest.bind(this),'onFailure':this.errorMessage.bind(this)});this.tabidx=dialogNum;this.parent=$((this.options.parent||document.body));this.generate();},destruct:function(){},generate:function(){var dialog_styles=$merge({'display':'none','width':this.options.width.toInt()+'px'},this.options.styles);this.dialog=new Element('div',{'id':this.dialogId,'class':this.options.dialogClass,'opacity':(this.options.useFx?0:1),'styles':dialog_styles}).inject(this.parent);this.fx=this.options.useFx?new Fx.Tween(this.dialog,$merge({'duration':'300'},this.options.fxOptions)):null;var db_message=new Element('div',{'class':this.options.messageBoxClass}).inject(this.dialog);if(this.options.title!==false){this.titlebar=new Element('div',{'id':this.dialogId+'_title','class':this.options.titleBarClass}).inject(db_message);new Element('span',{'class':this.options.titleTextClass,'html':this.options.title}).inject(this.titlebar);if(this.options.titleClose!=false){new Element('span',{'id':this.dialogId+'_closer','class':this.options.titleCloseClass,'title':this.options.titleCloseTitle}).inject(this.titlebar).addEvent('click',this.close.bind(this));}}this.message=new Element('div',{'id':this.dialogId+'_message','class':this.options.messageAreaClass+(this.options.title===false?' '+this.options.noTitleClass:'')+(this.options.footer===false?' '+this.options.noFooterClass:'')}).inject(db_message).setStyle('height',(this.options.height=='auto'?'auto':this.options.height.toInt()+'px'));if($defined(this.options.url)){this.request.options.url=this.options.url;this.request.send((this.options.requestQuery||''));this.setMessage(this.options.loadingMessage);if(this.options.autoShow){this.delayedShow=true;}}else if($defined(this.options.message)){this.setMessage(this.options.message);}if(this.options.footer!==false){this.footer=new Element('div',{'id':this.dialogId+'_footer','class':this.options.footerClass}).inject(db_message);new Element('div',{'class':'foot-wrap'}).inject(this.footer);new Element('div',{'class':'clear'}).inject(this.footer);if($type(this.options.buttons)=='array'){for(var i=0;i<this.options.buttons.length;i++){(this.injectButton(this.options.buttons[i])).inject(this.footer.firstChild,'top');}}if(this.options.ok!==false&&this.options.defaultButtons!==false){(this.injectButton({'text':this.options.okText,'class':this.options.okClass,'imageClass':this.options.okImageClass,'action':($type(this.options.ok)=='function'?this.options.ok:null),'autoClose':this.options.okAutoClose})).inject(this.footer.firstChild,'top');}if(this.options.cancel!==false&&this.options.defaultButtons!==false){(this.injectButton({'text':this.options.cancelText,'class':this.options.cancelClass,'imageClass':this.options.cancelImageClass,'action':($type(this.options.cancel)=='function'?this.options.cancel:null),'autoClose':this.options.cancelAutoClose})).inject(this.footer.firstChild,'top');}}if(this.options.draggable&&this.titlebar){this.drag=new Drag.Move(this.dialog,{handle:this.titlebar});}if(this.options.clickCloses||((this.options.title==false||this.options.titleClose==false)&&(this.options.footer==false))){$(document.body).addEvent('mousedown',this.clickClose);}this.setTabindex();this.fireEvent('complete');if(this.options.autoShow&&!this.request.running){this.show();}},buttonOptions:{'text':'','position':'right','imageClass':'image-button','class':'','action':$empty(),'autoClose':true,'tabindex':null},injectButton:function(_opts){var opts=$merge(this.buttonOptions,_opts);var bid=this.dialogId+'_btn_'+(opts.text||Math.ceil(Math.random()*10000)).replace(/\W/g,'').toLowerCase();var button=new Element('div',{'class':'go'+opts['position']+' '+opts['imageClass']+' '+opts['class']});var b_link=new Element('a',{'id':bid,'href':'javascript:void(0)','html':opts.text}).inject(button);if($defined(opts.tabindex)){b_link.set('tabindex',opts.tabindex);}if($type(opts.action)=='function'){button.addEvent('click',opts.action.bind(this));}if(opts.autoClose){button.addEvent('click',this.close.bind(this));}return button;},setMessage:function(_message){var message=($type(_message)=='function'?_message():_message);if($type(message)=='element'){this.grabbed=message.getParent();if(this.grabbed!=null){this.grabbedHide=(message.hasClass('none')?{'class':'none'}:(message.getStyle('display')=='none'?{'style':'display:none'}:{}));if($defined(this.grabbedHide['class'])){message.removeClass('none');}else if($defined(this.grabbedHide['style'])){message.setStyle('display','');}this.message.grab(message);}else{message.inject(this.message);}}else{this.message.set('html',message);}if(this.delayedShow){this.delayedShow=false;this.show();}},errorMessage:function(_error){},setTabindex:function(){var tabbed=['a','select','input','textarea','button','label'];this.tabidx=this.tabidx.toInt();$(this.dialogId+'_message').getElements('*').each(function(_elem,_idx){if(tabbed.contains(_elem.get('tag'))&&_elem.get('tabindex')!=-1){_elem.set('tabindex',(++this.tabidx));}},this);if($(this.dialogId+'_footer')){var footer_links=$(this.dialogId+'_footer').getElements('*');(footer_links.reverse()).each(function(_elem,_idx){if(tabbed.contains(_elem.get('tag'))&&_elem.get('tabindex')!=-1){_elem.set('tabindex',(++this.tabidx));}},this);}},urlRequest:function(_response){this.setMessage(_response);this.fireEvent('request');},toggleShade:function(_show){if(!$('mavdialog_shade')){new Element('div',{'id':'mavdialog_shade','class':this.options.shadeClass,'opacity':'0.5'}).inject(document.body);}$('mavdialog_shade').setStyle('display',(_show===true?'block':'none'));},show:function(){if(this.options.force){var shade_requests=($(document.body).retrieve('shade_requets')||0).toInt();$(document.body).store('shade_requests',(++shade_requests));this.toggleShade(this.options.force);}this.dialog.setStyle('display','');if(this.options.center!==false){this.screen_center();}this.fireEvent('show');if(this.options.useFx){this.fx.start('opacity',0,1);}},hide:function(){this.dialog.setStyle('display','none');this.fireEvent('hide');},clickClose:function(e){var is_dialog=false;$(e.target).getParents('div').each(function(_elem){if(!is_dialog&&$(_elem).get('id')==this.dialogId){is_dialog=true;}},this);if(!is_dialog){this.close();}},close:function(){if(this.options.useFx){this.fx.start('opacity',1,0).chain(this.finishClose.bind(this));}else{this.finishClose();}},finishClose:function(){if($(this.dialog)){if(this.options.force){var shade_requests=($(document.body).retrieve('shade_requests')).toInt();$(document.body).store('shade_requests',(--shade_requests));}if($defined(this.grabbed)){if($defined(this.grabbedHide['class'])){this.message.firstChild.addClass('none');}else if($defined(this.grabbedHide['style'])){this.message.firstChild.setStyle('display','none');}this.grabbed.grab(this.message.firstChild);}this.dialog.dispose();if(this.options.force&&shade_requests==0){this.toggleShade();}this.fireEvent('close');this.destruct();$(document.body).removeEvent('mousedown',this.clickClose);}},screen_center:function(){this.dialog.position('center',(this.parent||null));}});MavDialog.Confirm=new Class({Extends:MavDialog,initialize:function(_opts){var opts=$merge(_opts,{'cancel':false,'titleClose':false,'message':this.buildMessage.bind(this,_opts.message),'ok':this.closeAction.bind(this,true),'cancel':this.closeAction.bind(this,false)});this.parent(opts);},buildMessage:function(_msg){var message_box=new Element('div');new Element('div',{'class':'mav-icon-button confirm-icon goleft'}).inject(message_box);new Element('div',{'class':'mav-alert-msg goleft','html':_msg}).inject(message_box);new Element('div',{'class':'clear'}).inject(message_box);return message_box;},closeAction:function(_confirmed){this.close();if(this.options.useFx&&$defined(this.options.callback)){this.fx.start('opacity',1,0).chain(this.finishClose.bind(this)).chain(this.options.callback(_confirmed));}else{this.finishClose();if($defined(this.options.callback)&&$type(this.options.callback)=='function'){this.options.callback(_confirmed);}}}});MavDialog.Prompt=new Class({Extends:MavDialog,initialize:function(_opts){var opts=$merge(_opts,{'cancel':false,'titleClose':false,'message':this.buildMessage.bind(this,_opts.message),'ok':this.closeAction.bind(this),'cancel':this.closeAction.bind(this,false),'onComplete':function(){var text_elem=this.dialogId+'_prompted';window.setTimeout(function(){$(text_elem).focus();},310);}});this.parent(opts);},buildMessage:function(_msg){var message_box=new Element('div');new Element('div',{'class':'mav-icon-button prompt-icon goleft'}).inject(message_box);var msg_display=new Element('div',{'class':'mav-alert-msg goleft'}).inject(message_box);new Element('div',{'html':_msg}).inject(msg_display);new Element('input',{'id':this.dialogId+'_prompted','type':'text','class':'mav-prompt-input'}).inject(msg_display);new Element('div',{'class':'clear'}).inject(message_box);return message_box;},closeAction:function(_canceled){this.close();var prompt_value=(_canceled===false?null:$(this.dialogId+'_prompted').get('value'));if(this.options.useFx&&$defined(this.options.callback)){this.fx.start('opacity',1,0).chain(this.finishClose.bind(this)).chain(this.options.callback(prompt_value));}else{this.finishClose();if($defined(this.options.callback)&&$type(this.options.callback)=='function'){this.options.callback(prompt_value);}}}});MavDialog.Alert=new Class({Extends:MavDialog,initialize:function(_opts){var opts=$merge(_opts,{'cancel':false,'titleClose':false,'message':this.buildMessage.bind(this,_opts.message)});this.parent(opts);},buildMessage:function(_msg){var message_box=new Element('div');new Element('div',{'class':'mav-icon-button alert-icon goleft'}).inject(message_box);new Element('div',{'class':'mav-alert-msg goleft','html':_msg}).inject(message_box);new Element('div',{'class':'clear'}).inject(message_box);return message_box;}});MavDialog.MediaBox=new Class({Extends:MavDialog,mOptions:{'autoShow':true,'footerClass':'media-footer','defaultButtons':false,'title':false,'force':true,'messageBoxClass':'','dialogClass':'mav-dialog-media','noTitleClass':'','noFooterClass':'','titleClose':false,'clickCloses':true,'media':'','buttons':[{'text':'Close','class':'media-close-button close-icon'}]},mediaFormats:[/\.jpe?g$/i,/\.gif$/i,/\.png$/i],initialize:function(_opts){this.mOptions=$merge(this.mOptions,_opts);this.mOptions['message']=new Element('img').inject(document.body);if($defined(this.mOptions.media)){this.mOptions['message'].set('src',this.mOptions.media).addEvent('load',this.finishInit.bind(this));}},finishInit:function(){var iSize=this.mOptions['message'].getSize();this.mOptions['width']=(iSize.x+38)+'px';this.mOptions['height']=(iSize.y)+'px';this.mOptions['message'].addClass('none');this.setOptions(this.mOptions);var dialogNum=Math.ceil(Math.random()*10000);this.dialogId='mavd'+dialogNum+'_dialog';this.request={'running':false};if($(this.dialogId+'_dialog')){return null;}this.tabidx=dialogNum;this.parent=$((this.options.parent||document.body));this.generate();}});
var MavMediaBox = function(_media) { new MavDialog.MediaBox({'media': _media}); };
String.implement({strip_tags: function() { return (this.stripScripts()).replace(/<\/?[^>]+>/gi, ''); },reverse: function() { return ((this.split('')).reverse()).join(''); },lcfirst: function() { return this.replace(/\b([A-Z])/, function(_s) { return _s.toLowerCase(); }); },ucfirst: function() { return this.replace(/\b([a-z])/, function(_s) { return _s.toUpperCase(); }); },ltrim: function() { return this.replace(/^\s*/, ''); },rtrim: function() { return this.replace(/\s*$/, ''); },nl2br: function() { return (this.replace(/\r/g, '')).replace(/\n/g, '<br />'); },br2nl: function() { return (this.replace(/\r/g, '')).replace(/<br \/>/g, "\n"); }, number_format: function(_decs, _dpt, _thsep) {var str = String((this.toFloat()).toFixed(_decs || 2));str = (str.reverse()).replace(/((?:\d(?!\d+?\.)(?=\d)){3})/g, "$1" + (_thsep || ','));return (str.replace(/\./, (_dpt || '.'))).reverse();}});
Element.implement({swapClass:function(_remove,_add){this.removeClass(_remove).addClass(_add);},toDataQueryString:function(_blacklist,_json,_noencoding){var queryString=(_json===true?{}:[]),bl=(_blacklist||[]);var formElements=this.elements,valids=['input','select','textarea'];for(var i=0;i<formElements.length;i++){el=formElements[i];if(!valids.contains(el.tagName.toLowerCase())){continue;}if(!el.name||el.disabled||el.type=='submit'||el.type=='reset'||el.type=='file'||bl.contains(el.name)){continue;}var value=((el.type=='radio'||el.type=='checkbox')?(el.checked?(el.value!=''?el.value:1):0):el.value);$splat(value).each(function(_val){if(typeof _val!='undefined'){_val=(_val.toString()).replace(/\&/g,'&amp;');if(_json===true){queryString[el.name]=(_noencoding?_val:encodeURIComponent(_val));}else{queryString.push(el.name+'='+(_noencoding?_val:encodeURIComponent(_val)));}}});}return(_json===true?queryString:queryString.join('&'));}});
