﻿//************************
//  CONSTRUCTOR
//***********************
function History() {

    //***********************
    //  PROPERTIES
    //***********************
    
    var _oTarget = new Object();
    var _oTargetHistory = new Object();
    var _oScope = this;
    
    //***********************
    //  GETTER / SETTERS
    //***********************
    this.addTarget = function(oTarget) { _oTarget = oTarget; getHistory()};
    this.target = function() {return  _oTarget;};
    
    this.history = function() {return _oTargetHistory};
    
    
    //***********************
    //  PRIVATE
    //***********************
    
    function getHistory() {
        var oHistory = new Object();
        var oTarget = _oScope.target();
     
        oHistory.nTopCanvas = oTarget["Canvas.Top"];
        oHistory.nLeftCanvas = oTarget["Canvas.Left"];
        oHistory.nWidth = oTarget.Width;
        oHistory.nHeight = oTarget.Height;
        
        _oTargetHistory = oHistory;
    }
    
    //******************************
    //  RESET IT NOW
    //******************************
    function resetHistory() {
         var oHistory = _oScope.history();
         var oTarget = _oScope.target(); 
         
         oTarget["Canvas.Left"] = _oTargetHistory.nLeftCanvas;
         oTarget["Canvas.Top"] = _oTargetHistory.nTopCanvas;
         oTarget.Width = _oTargetHistory.nWidth;
         oTarget.Height = _oTargetHistory.nHeight;
    }
    
    
    
    //***********************
    //  PUBLIC
    //***********************
    
    this.reset = function() {
       resetHistory();
    }

}