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

