/**
 * Reads Templates and updates the container div accordingly
 * 
 * 
 * Version 1.0
 * Created 08/03/2010
 *
 * Author: henworx-ASA 
 *
 */

TemplateReader= new function(){
	this.removeOldItems=true;
	_this=this;
	this.read=function(file,container){
			jQuery.ajax({
  			url: file,
  			cache: false,
			async: false,
  			success: function(html){				
    				jQuery(container).html(html);
  					}
			});
	};
	
	this.append=function(file,container){
		jQuery.ajax({
			url: file,
			cache: false,
			async: false,
			success: function(html){
					jQuery(container).append(html);
					}
		});
	};
	
	this.update=function(obj,container,chainParams){
			if(typeof(chainParams)=='object'){
				if(typeof(chainParams.container)!='undefined'){
					container=container+" "+chainParams.container;
				}
			}
			if(this.removeOldItems){jQuery(container).items('destroy');}
			jQuery(container).items(obj).chain(chainParams);
  					
	};
		
};

