var applicationClass=function()
{this.context={module:null,action:null};var _loadedJavaScript={};this.execute=function()
{this.init();this.processAction(this.context.module,this.context.action);}
this.addContext=function(variables)
{for(var name in variables)
{this.context[name]=variables[name];}}
this.init=function()
{}
this.processAction=function(module,action)
{action=action.substring(0,1).toUpperCase()+action.substring(1,action.length);eval("if ( typeof "+module+action+" == 'function' ) { "+module+action+"() }; ");}
this.url=function(module,action,params)
{var url_params='';if(typeof params=='object')
{for(var param_name in params)
{url_params=url_params+'/'+param_name+'/'+params[param_name];}}
if(typeof action=='undefined')
{return'/'+module+url_params;}
return'/'+module+'/'+action+url_params;}
this.redirect=function(module,action)
{document.location=this.url(module,action);}
this.addJavaScript=function(js,callback)
{if(_loadedJavaScript[js])
{return;}
_loadedJavaScript[js]=true;$.getScript(js,callback);}};var application=new applicationClass();;var slicer=function(options)
{var instance=this;var defaults={name:'default',urlVarname:'page',urlEqual:'/',urlSeparator:'/',page:1,maxPage:1,possiblePage:1,baseUrl:location.href,enableKeys:true};this.options=$.extend(defaults,options);instance.options.possiblePage=instance.options.page;this.init=function()
{if(!instance.options.page)
{return false;}
if(instance.options.enableKeys)
{$(document).keydown(function(e)
{if(e.ctrlKey)
{if(e.which==37)
{instance.next();}
if(e.which==39)
{instance.prev();}}});$(document).keyup(function(e)
{if(e.which==17&&instance.options.possiblePage!=instance.options.page)
{instance.go();}});}}
this.go=function()
{var findStr=instance.options.urlSeparator+instance.options.urlVarname+instance.options.urlEqual+instance.options.page;var replaceStr=instance.options.urlSeparator+instance.options.urlVarname+instance.options.urlEqual+instance.options.possiblePage;if(instance.options.baseUrl.search(findStr)!=-1)
{location.href=instance.options.baseUrl.replace(findStr,replaceStr);}
else
{location.href=instance.options.baseUrl+replaceStr;}};this.next=function()
{instance.options.possiblePage++;if(instance.options.possiblePage>instance.options.maxPage)
{instance.options.possiblePage=instance.options.maxPage;}
$('.page').html(instance.options.possiblePage);};this.prev=function()
{instance.options.possiblePage--;if(instance.options.possiblePage<1)
{instance.options.possiblePage=1;}
$('.page').html(instance.options.possiblePage);};};var slicers=false;;var errorRenderer=function()
{this.ER_SUPPRESED=0;this.ER_CONTAINER=1;this.ER_FIELDS=2;};var Form=function(f)
{this.f=f;this.multipart=$(':file',this.f).length>0;this.method=$(this.f).attr('method');this.id=$(this.f).attr('id');if(this.method=='')
{this.method='post';}
this.lastResponseData=null;this.onSuccess=$(this.f).attr('onsuccess');this.onError=$(this.f).attr('onerror');this.onBeforeSubmit=null;var errRenderer=new errorRenderer();this.errorRendererType=errRenderer.ER_FIELDS;this.errorRendererContainer='error_container';this.setErrorRenderer=function(rendererType,container)
{this.errorRendererType=rendererType;this.errorRendererContainer=typeof(container=='undefined')?this.errorRendererContainer:container;}
this.init=function()
{var thisForm=this;$(':input,:file,',this.f).not('[type=submit],[type=hidden]').each(function(){$('<div class="error"></div>').attr('id',thisForm.f.attr('id')+'_'+thisForm.exractFieldName($(this).attr('name'))+'_error').insertAfter(this);});this.f.ajaxForm({url:$(thisForm).attr('action'),dataType:'json',type:thisForm.method,iframe:false,beforeSubmit:function(data,jobj,opt)
{if(typeof thisForm.onBeforeSubmit=='function')
{if(!thisForm.onBeforeSubmit())
{return false;}}
for(var l in data)
{var obj=$('input[type=text][name="'+data[l].name+'"]');if(obj.length>0)
{if($(obj).attr('title')!=''&&$(obj).attr('title')==obj.val())
{data[l].value='';}}}
if($(thisForm).method=='get')
{var url='';for(l in data)
{url=url+'/'+data[l].name+'/'+data[l].value;}
this.url=opt.url+url;location.href=this.url;return false;}
thisForm.disableSubmit();},success:function(response)
{thisForm.hideErrors();if(typeof response!='object')
{ajax.errorHandler(response.toString());thisForm.enableSubmit();return;}
if(response.status=='error')
{if(typeof thisForm.onError=='function')
{eval(thisForm.onError+'( response )');}
thisForm.showErrors(response);}
if(response.status=='success'&&typeof thisForm.onSuccess=='string')
{eval(thisForm.onSuccess+'( response )');}
if(response.status=='exception')
{console.log('Exception',response.errors);}
thisForm.enableSubmit();if(typeof response.notice!='undefined')
{notification.success(response.notice);}}});}
this.disableSubmit=function()
{$('input:submit',this.f).attr('disabled',true);$('button:submit',this.f).attr('disabled',true);};this.enableSubmit=function()
{$('input:submit',this.f).attr('disabled',false);$('button:submit',this.f).attr('disabled',false);};this.showErrors=function(response)
{this.lastResponseData=response;var errors='';var eRenderer=new errorRenderer();if(typeof response.errors!='undefined')
{for(var fieldName in response.errors)
{$('#'+this.id+'_'+fieldName+'_error').html(response.errors[fieldName]);$('#'+this.id+'_'+fieldName+'_error').show(200);}
return;}};this.hideErrors=function()
{if(this.lastResponseData==null)return;var eRenderer=new errorRenderer();if(typeof this.lastResponseData.errors!='undefined')
{for(var fieldName in this.lastResponseData.errors)
{$('#'+this.id+'_'+fieldName+'_error').hide();}}};this.exractFieldName=function(n)
{var r=new RegExp(/\[(.*)\]/g).exec(n);if(r==null)
{return n;}
return r[1];};this.init();};function autobindForms()
{$('form').each(function(){new Form($(this));});};(function($){Class={create:function(){var s=(arguments.length>0&&arguments[arguments.length-1].constructor==Boolean)?arguments[arguments.length-1]:false;var c=s?{}:function(){this.init.apply(this,arguments);}
var methods={ns:[],supers:{},init:function(){},namespace:function(ns){if(!ns)return null;var _this=this;if(ns.constructor==Array){$.each(ns,function(){_this.namespace.apply(_this,[this]);});return;}else if(ns.constructor==Object){for(var key in ns){if([Object,Function].indexOf(ns[key].constructor)>-1){if(!this.ns)this.ns=[];this.ns[key]=ns[key];this.namespace.apply(this,[key]);}}
return;}
var levels=ns.split(".");var nsobj=this.prototype?this.prototype:this;$.each(levels,function(){nsobj[this]=_this.ns[this]||nsobj[this]||window[this]||Class.create(true);delete _this.ns[this];nsobj=nsobj[this];});return nsobj;},create:function(){var args=Array.prototype.slice.call(arguments);var name=args.shift();var temp=Class.create.apply(Class,args);var ns={};ns[name]=temp;this.namespace(ns);},sup:function(){try{var caller=this.sup.caller.name;this.supers[caller].apply(this,arguments);}catch(noSuper){return false;}}}
s?delete methods.init:null;$.extend(c,methods);if(!s)$.extend(c.prototype,methods);var extendee=s?c:c.prototype;$.each(arguments,function(){if(this.constructor==Object||typeof this.init!=undefined){for(i in this){if(extendee[i]&&extendee[i].constructor==Function&&['namespace','create','sup'].indexOf(i)==-1){this[i].name=extendee[i].name=i;extendee.supers[i]=extendee[i];}
extendee[i]=this[i];}}});return c;}};})(jQuery);;var dialogClass=function()
{var contentContainer='dialog';this.close=function()
{$('#dialog').dialog('close');}
this.load=function(module,action,params)
{ajax.get(module,action,params,function(response)
{dialog.show(response.title,response.body);application.processAction(module,action);})}
this.url=function(url,params)
{ajax.url(url,params,function(response)
{dialog.show(response.title,response.body);application.processAction(response.context.module,response.context.action);})}
this.show=function(title,content)
{$('#'+contentContainer).html(content);$('#ui-dialog-title-dialog').html(title);$('#dialog').dialog('open');}};var dialog=new dialogClass;;var notificationClass=function()
{this.success=function(message,params)
{this.centered('#notification',message,2500);}
this.error=function(message,params)
{this.centered('#error',message,0);}
this.centered=function(selector,message,delay)
{var top=95;var left=parseInt(($('body').width()-$('#notification').width())/2);if($.browser.msie)
{top=document.documentElement.scrollTop+top;$(selector).css('position','absolute');}else
{$(selector).css('position','fixed');}
var top=0;$(selector).css('left',left+'px');$(selector).css('top',top+'px');$(selector).hide();$(selector).html(message);$(selector).fadeIn(100);if(delay)
{nameTimer=setTimeout("$('"+selector+"').fadeOut(500)",delay);}}};var notification=new notificationClass;;var ajaxClass=function()
{this.init=function()
{$('body').ajaxStart(function(){$('#ajax_wrapper').fadeIn(200);$('#ajax_loading').show();});$("body").ajaxComplete(function(e,XMLHttpRequest,ajaxOptions){$('#ajax_loading').hide();$('#ajax_wrapper').hide(100);var data=$.httpData(XMLHttpRequest,ajaxOptions.dataType);if(typeof data.redirect!='undefined')
{$.address.value(data.redirect);}});$("body").ajaxError(function(event,request,settings){ajax.errorHandler(request.responseText);});};this.errorHandler=function(data)
{console.log('Ajax Transport Error',data);};this.url=function(url,params,callback,datatype)
{if(typeof datatype=='undefined')
{datatype='json';}
$.get(url,params,function(response){if(typeof callback=='function')
{callback(response);}
if(datatype=='json'&&response.status=='exception')
{console.log('Exception',response.errors);}},datatype);}
this.get=function(module,action,params,callback,datatype)
{if(typeof datatype=='undefined')
{datatype='json';}
$.get(application.url(module,action),params,function(response){if(typeof callback=='function')
{callback(response);}
if(datatype=='json'&&response.status=='exception')
{console.log('Exception',response.errors);}},datatype);}
this.put=function(module,action,params,callback,datatype)
{if(typeof datatype=='undefined')
{datatype='json';}
$.post(application.url(module,action),params,function(response){if(typeof callback=='function')
{callback(response);}
if(datatype=='json')
{if(response.status=='success'&&typeof callback!='function'&&response.message)
{notification.success(response.message);}
if(response.status=='exception')
{console.log('Exception',response.errors);}
if(response.status=='error')
{console.log('Error',response.errors);}}},datatype);}};var ajax=new ajaxClass();;function boot()
{application.execute();ajax.init();for(l in slicers)
{slicers[l].obj=new slicer(slicers[l]);slicers[l].obj.init();}
$('input[title!=""]').hint();};function debug(applicationTime)
{$('#application_time').html(applicationTime+'s');};