// Templating.js
// Copyright (c) Nikhil Kothari, 2008
// http://www.nikhilk.net
//
// This product's copyrights are licensed under the Creative
// Commons Attribution-ShareAlike (version 2.5).B
// http://creativecommons.org/licenses/by-sa/2.5/
//	http://www.nikhilk.net/Ajax-Templates.aspx
// You are free to:
// - copy, distribute, display, and perform the work 
// - make derivative works 
// - make commercial use of the work 
// as long as the work is itself not a server control offering of
// any sort, under the following conditions:
// Attribution. You must attribute the original work in your
//              product or release.
// Share Alike. If you alter, transform, or build upon this work,
//              you may distribute the resulting work only under
//              a license identical to this one.
//

Type.registerNamespace('Templating');Templating.Template=function(templateContainer){this.$1=templateContainer;if(!Templating.Template.$0){Templating.Template.$0=new RegExp('([^\\{]*)\\{([^\\}]+)\\}','g');}var $0=[];var $1=this.$1.innerHTML.replace('\n','').replace('%7B','{').replace('%7D','}');this.$2=$1.replace(Templating.Template.$0,Function.createDelegate(this,function($p1_0){
var $1_0=arguments[1];var $1_1=arguments[2];if($1_1.substr(0,1)==='{'){return $1_0+'{'+$1_1+'}';}var $1_2=$1_1.split(':');Array.add($0,$1_2[0]);$1_2[0]=($0.length-1).toString();return $1_0+'{'+$1_2.join(':')+'}';}));var $2=new Sys.StringBuilder();$2.append('var container = document.createElement(\'div\');');$2.append('container.innerHTML = String.format(format');for(var $4=0;$4<$0.length;$4++){$2.append(', data.');$2.append($0[$4]);}$2.appendLine(');');$2.appendLine('var element = null;');$2.appendLine('var itemContainer = $get(\'itemContainer\', container);');$2.appendLine('var children = itemContainer.childNodes;');$2.appendLine('for (var i = 0; children.length; i++) {');$2.appendLine('    if (children[i].nodeType == 1) { element = children[i]; break; }');$2.appendLine('}');$2.appendLine('if (element && callback) { callback(element, data, context); }');$2.appendLine('return element;');var $3=$2.toString();this.$3=new Function('format','data','callback','context',$3);}
Templating.Template.prototype={$1:null,$2:null,$3:null,get_templateContainer:function(){return this.$1;},createInstance:function(data,callback,context){return this.$3(this.$2,data,callback,context);}}
Templating.Repeater=function(e){Templating.Repeater.initializeBase(this,[e]);this.$2_0=Sys.UI.DomElement.getElementById('itemContainer',e);}
Templating.Repeater.prototype={$2_0:null,$2_1:null,$2_2:null,get_data:function(){return this.$2_1;},set_data:function(value){if(!this.$2_1){this.$2_1=value;return;}this.$2_3(value);return value;},get_template:function(){if(this.$2_2){return this.$2_2.get_templateContainer();}return null;},set_template:function(value){this.$2_2=new Templating.Template(value);return value;},addDataItem:function(dataItem){if(this.$2_2){var $0=this.$2_2.createInstance(dataItem,null,null);if($0){Array.add(this.$2_1,dataItem);this.$2_0.appendChild($0);}}},$2_3:function($p0){if((!$p0)||(!$p0.length)){this.$2_0.innerHTML='';}else{if(!this.$2_2){this.$2_1=Array.clone($p0);return;}this.$2_1=[];var $0=this.$2_0.tagName;if((window.navigator.userAgent.indexOf('MSIE')<0)||(($0!=='TABLE')&&($0!=='TBODY')&&($0!=='TR'))){this.$2_0.innerHTML='';}else{for(var $1=this.$2_0.childNodes.length-1;$1>=0;$1--){this.$2_0.removeChild(this.$2_0.childNodes[$1]);}}for(var $2=0;$2<$p0.length;$2++){this.addDataItem($p0[$2]);}}}}
Templating.Template.registerClass('Templating.Template');Templating.Repeater.registerClass('Templating.Repeater',Sys.UI.Control);Templating.Template.$0=null;
// ---- Do not remove this footer ----
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
// -----------------------------------
