/* 	Copyright 2008 Maximum Processing Inc
	
	ABOUT THIS SCRIPT

	
	Change Log
 	Created 12/03/2008 Nathan Townsend
*/


function TEMPLATE(){

  this.inheritFrom = BaseComponent;

	this.inheritFrom();

	this.Src  = "../../images/RuleTEMPLATE.png";

  this.Title = "Template Component";
	
	this.ToolTip = "Delivers a template to the specified screen target WITHOUT executing the pre-process function";
	
	var _xmlNode = null;
	

  this.Create = function()
  {
	  try{
		  var uo = new UndoObject();
			
			uo.AddUndo(RulesMaker.Load, RuleXML.GetVRM().xml);

      this.BaseCreate();
			
			this.SetType("TEMPLATE");			

			_xmlNode = this.GetNode();

      var values = $(_xmlNode.find('>values')[0]);
      
      values.append(RuleXML.GetNewElement('n'));
			
      values.append(RuleXML.GetNewElement('t'));
			
      uo.AddRedo(RulesMaker.Load, RuleXML.GetVRM().xml);
      
      Undo.Add(uo);		
						

		} catch(err){Log.Add("TEMPLATE.Create", err, LogType.Error);}    
  }
  
	this.Load = function(xmlNode)
  {
	  try{
		
		  _xmlNode = $(xmlNode);
		
		  this.BaseLoad(_xmlNode);
			
		} catch(err){Log.Add("TEMPLATE.Load", err, LogType.Error);}	  	
  }
  
  
	this.GetProperties = function(){
    try{
	
  	  var properties = this.GetBaseProperties();

      properties[properties.length] = new PropertiesEditor.Property(PropertyFields.GetProperty("Name"), this.GetName, this.SetName);
			properties[properties.length] = new PropertiesEditor.Property(PropertyFields.GetProperty("Target"), this.GetTarget, this.SetTarget);
  		return properties;		

		} catch(err){Log.Add("TEMPLATE.GetProperties", err, LogType.Error);}		

	}
	
  this.GetName = function(){
	  try{
		
      return $(_xmlNode.find(">values>n")[0]).text();

		} catch(err){Log.Add("TEMPLATE.GetName", err, LogType.Error);}			
  }
	
  this.GetTarget = function(){
	  try{
		
      return $(_xmlNode.find(">values>t")[0]).text();

		} catch(err){Log.Add("TEMPLATE.GetTarget", err, LogType.Error);}			
  }
 
 
  this.SetName = function(newName)
  {
	 	try{
		
				$(_xmlNode.find(">values>n")[0]).text(newName);
			
		} catch(err){Log.Add("TEMPLATE.SetName", err, LogType.Error);}    
  }
   
  this.SetTarget = function(newTarget)
  {
	 	try{
		
				$(_xmlNode.find(">values>t")[0]).text(newTarget);
			
		} catch(err){Log.Add("TEMPLATE.SetTarget", err, LogType.Error);}    
  }

 
}







