if(typeof Jemplate=='undefined'){var Jemplate=function(){this.init.apply(this,arguments);};}Jemplate.VERSION='0.22';Jemplate.process=function(){var jemplate=new Jemplate();return jemplate.process.apply(jemplate,arguments);};(function(){if(!Jemplate.templateMap)Jemplate.templateMap={};var proto=Jemplate.prototype={};proto.init=function(config){this.config=config||{AUTO_RESET:true,BLOCKS:{},CONTEXT:null,DEBUG_UNDEF:false,DEFAULT:null,ERROR:null,EVAL_JAVASCRIPT:false,FILTERS:{},INCLUDE_PATH:[''],INTERPOLATE:false,OUTPUT:null,PLUGINS:{},POST_PROCESS:[],PRE_PROCESS:[],PROCESS:null,RECURSION:false,STASH:null,TOLERANT:null,VARIABLES:{},WRAPPER:[]};};proto.process=function(template,data,output){var context=this.config.CONTEXT||new Jemplate.Context();context.config=this.config;context.stash=this.config.STASH||new Jemplate.Stash();context.stash.__config__=this.config;context.__filter__=new Jemplate.Filter();context.__filter__.config=this.config;context.__plugin__=new Jemplate.Plugin();context.__plugin__.config=this.config;var result;var proc=function(input){try{result=context.process(template,input);}catch(e){if(!String(e).match(/Jemplate\.STOP\n/))throw(e);result=e.toString().replace(/Jemplate\.STOP\n/,'');}if(typeof output=='undefined')return result;if(typeof output=='function'){output(result);return null;}if(typeof(output)=='string'||output instanceof String){if(output.match(/^#[\w\-]+$/)){var id=output.replace(/^#/,'');var element=document.getElementById(id);if(typeof element=='undefined')throw('No element found with id="'+id+'"');element.innerHTML=result;return null;}}else{output.innerHTML=result;return null;}throw("Invalid arguments in call to Jemplate.process");return 1;};if(typeof data=='function')data=data();else if(typeof data=='string'){var url=data;Jemplate.Ajax.processGet(url,function(data){proc(data)});return null;}return proc(data);};if(typeof Jemplate.Context=='undefined')Jemplate.Context=function(){};proto=Jemplate.Context.prototype;proto.include=function(template,args){return this.process(template,args,true);};proto.process=function(template,args,localise){if(localise)this.stash.clone(args);else this.stash.update(args);var func=Jemplate.templateMap[template];if(typeof func=='undefined')throw('No Jemplate template named "'+template+'" available');var output=func(this);if(localise)this.stash.declone();return output;};proto.set_error=function(error,output){this._error=[error,output];return error;};proto.plugin=function(name,args){if(typeof name=='undefined')throw "Unknown plugin name ':"+name+"'";return new window[name](this,args);};proto.filter=function(text,name,args){if(name=='null')name="null_filter";if(typeof this.__filter__.filters[name]=="function")return this.__filter__.filters[name](text,args,this);else throw "Unknown filter name ':"+name+"'";};if(typeof Jemplate.Plugin=='undefined'){Jemplate.Plugin=function(){};}proto=Jemplate.Plugin.prototype;proto.plugins={};if(typeof Jemplate.Filter=='undefined'){Jemplate.Filter=function(){};}proto=Jemplate.Filter.prototype;proto.filters={};proto.filters.collapse=function(text){return text.replace(/^\s+/g,"").replace(/\s+$/g,"").replace(/\s+/," ");};proto.filters.uri=function(text){return encodeURIComponent(text);};proto.filters.url=function(text){return encodeURI(text);};proto.filters.truncate=function(text,args){var len=args[0];if(!text)return null;if(!len)len=32;if(text.length<len)return text;var newlen=len-3;return text.substr(0,newlen)+'...';};proto.filters.replace=function(text,args){if(!text)return null;var re_search=args[0];var text_replace=args[1];if(!re_search)re_search='';if(!text_replace)text_replace='';var re=new RegExp(re_search,'g');return text.replace(re,text_replace);};if(typeof Jemplate.Stash=='undefined'){Jemplate.Stash=function(){this.data={};};}proto=Jemplate.Stash.prototype;proto.clone=function(args){var data=this.data;this.data={};this.update(data);this.update(args);this.data._PARENT=data;};proto.declone=function(args){this.data=this.data._PARENT||this.data;};proto.update=function(args){if(typeof args=='undefined')return;for(var key in args){var value=args[key];this.set(key,value);}};proto.get=function(key){var root=this.data;if(key instanceof Array){for(var i=0;i<key.length;i+=2){var args=key.slice(i,i+2);args.unshift(root);value=this._dotop.apply(this,args);if(typeof value=='undefined')break;root=value;}}else{value=this._dotop(root,key);}if(typeof value=='undefined'){if(this.__config__.DEBUG_UNDEF)throw("undefined value found while using DEGUG_UNDEF");value='';}return value;};proto.set=function(key,value,set_default){if(key instanceof Array){var data=this.get(key[0])||{};key=key[2];}else{data=this.data;}if(!(set_default&&(typeof data[key]!='undefined')))data[key]=value;};proto._dotop=function(root,item,args){if(typeof item=='undefined'||typeof item=='string'&&item.match(/^[\._]/)){return undefined;}if((!args)&&(typeof root=='object')&&(!(root instanceof Array)||(typeof item=='number'))&&(typeof root[item]!='undefined')){var value=root[item];if(typeof value=='function')value=value.apply(root);return value;}if(typeof root=='string'&&this.string_functions[item])return this.string_functions[item](root,args);if(root instanceof Array&&this.list_functions[item])return this.list_functions[item](root,args);if(typeof root=='object'&&this.hash_functions[item])return this.hash_functions[item](root,args);if(typeof root[item]=='function')return root[item].apply(root,args);return undefined;};proto.string_functions={};proto.string_functions.defined=function(string){return 1;};proto.string_functions.hash=function(string){return{'value':string};};proto.string_functions.length=function(string){return string.length;};proto.string_functions.list=function(string){return[string];};proto.string_functions.match=function(string,args){var regexp=new RegExp(args[0],'gm');var list=string.match(regexp);return list;};proto.string_functions.replace=function(string,args){var regexp=new RegExp(args[0],'gm');var sub=args[1];if(!sub)sub='';var output=string.replace(regexp,sub);return output;};proto.string_functions.search=function(string,args){var regexp=new RegExp(args[0]);return(string.search(regexp)>=0)?1:0;};proto.string_functions.size=function(string){return 1;};proto.string_functions.split=function(string,args){var regexp=new RegExp(args[0]);var list=string.split(regexp);return list;};proto.list_functions={};proto.list_functions.push=function(list,args){list.push(args[0]);return list;};proto.list_functions.pop=function(list){return list.pop();};proto.list_functions.unshift=function(list,args){list.unshift(args[0]);return list;};proto.list_functions.shift=function(list){return list.shift();};proto.list_functions.first=function(list){return list[0];};proto.list_functions.size=function(list){return list.length;};proto.list_functions.max=function(list){return list.length-1;};proto.list_functions.last=function(list){return list.slice(-1);};proto.hash_functions={};proto.hash_functions.exists=function(hash,args){return(typeof(hash[args[0]])=="undefined")?0:1;};proto.hash_functions.size=function(hash){var size=0;for(var key in hash)size++;return size;};if(typeof Jemplate.Iterator=='undefined'){Jemplate.Iterator=function(object){if(object instanceof Array){this.object=object;this.size=object.length;this.max=this.size-1;}else if(object instanceof Object){this.object=object;var object_keys=new Array;for(var key in object){object_keys[object_keys.length]=key;}this.object_keys=object_keys.sort();this.size=object_keys.length;this.max=this.size-1;}}}proto=Jemplate.Iterator.prototype;proto.get_first=function(){this.index=0;this.first=1;this.last=0;this.count=1;return this.get_next(1);};proto.get_next=function(should_init){var object=this.object;var index;if(typeof(should_init)!='undefined'&&should_init){index=this.index;}else{index= ++this.index;this.first=0;this.count=this.index+1;if(this.index==this.size-1){this.last=1;}}if(typeof object=='undefined')throw('No object to iterate');if(this.object_keys){if(index<this.object_keys.length){this.prev=index>0?this.object_keys[index-1]:"";this.next=index<this.max?this.object_keys[index+1]:"";return[this.object_keys[index],false];}}else{if(index<object.length){this.prev=index>0?object[index-1]:"";this.next=index<this.max?object[index+1]:"";return[object[index],false];}}return[null,true];}}()); 