/* 	Copyright 2008 Maximum Processing Inc
	
	ABOUT THIS SCRIPT

	
	Change Log
 	Created 12/16/2008 Nathan Townsend
*/


function ERROR(){

  this.inheritFrom = BaseComponent;

	this.inheritFrom();

	var _xmlNode = null;
	
  this.Src = "../../images/RuleERROR.png";

  this.Title = "ERROR Component";
	
	this.ToolTip = "Displays an html message to the user when an error occurs";
	
	
	

  this.Create = function()
  {
	  try{

		  var uo = new UndoObject();
			
			uo.AddUndo(RulesMaker.Load, RuleXML.GetVRM().xml);

      this.BaseCreate();
			
			this.SetType("ERROR");	

			_xmlNode = this.GetNode();

      var values = $(_xmlNode.find('>values')[0]);
      
      values.append(RuleXML.GetNewElement('v'));
			
      uo.AddRedo(RulesMaker.Load, RuleXML.GetVRM().xml);
      
      Undo.Add(uo);								
			

		} catch(err){Log.Add("ERROR.Create", err, LogType.Error);}    
  }
  
	this.Load = function(xmlNode)
  {
	  try{
		
		  _xmlNode = $(xmlNode);
		
		  this.BaseLoad(_xmlNode);
			
		} catch(err){Log.Add("ERROR.Load", err, LogType.Error);}	  	
  }
  
  
	this.GetProperties = function(){
    try{
	
  	  var properties = this.GetBaseProperties();

      properties[properties.length] = new PropertiesEditor.Property(PropertyFields.GetProperty("ErrorMessage"), this.GetErrorMessage, this.SetErrorMessage);

  		return properties;

		} catch(err){Log.Add("ERROR.GetProperties", err, LogType.Error);}		

	}
	
  this.GetErrorMessage = function(){
	  try{
		
      return $(_xmlNode.find(">values>v")[0]).text();

		} catch(err){Log.Add("ERROR.GetErrorMessage", err, LogType.Error);}			
  }
	

 
  this.SetErrorMessage = function(newErrorMessage)
  {
	 	try{

      RuleXML.ReplaceCDATA(_xmlNode.find(">values>v")[0], newErrorMessage);
			
		} catch(err){Log.Add("ERROR.SetErrorMessage", err, LogType.Error);}    
  }
	
	
	this.SetJ1 = null;

 

 
}







