diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
index cde52ec..1b20c90 100644
--- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
+++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
@@ -4186,14 +4186,18 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$('#btnIdentity').addClass('btn-primary');
// clear canvas before drawing transparency box
- $('#canvas').removeLayers();
- var paintCanvasObj = document.getElementById("canvasPaint");
- var ctx = paintCanvasObj.getContext("2d");
- ctx.clearRect(0, 0, 2277, 3248);
- var sktch = $('#canvasPaint').sketch();
- $('#canvasPaint').sketch().actions = [];
- $("#annotationpaintbrushsize").removeClass("activebtncolor");
- $("#annotationpainteraser").removeClass("activebtncolor");
+ if ($rootScope.isAnnotationWindowOpen == true){
+ $('#canvas').removeLayers();
+ var paintCanvasObj = document.getElementById("canvasPaint");
+ if (paintCanvasObj != null) {
+ var ctx = paintCanvasObj.getContext("2d");
+ ctx.clearRect(0, 0, 2277, 3248);
+ }
+ var sktch = $('#canvasPaint').sketch();
+ $('#canvasPaint').sketch().actions = [];
+ $("#annotationpaintbrushsize").removeClass("activebtncolor");
+ $("#annotationpainteraser").removeClass("activebtncolor");
+ }
//hide the speechbubble
@@ -5665,12 +5669,17 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
$("#bord").remove();
// clear canvas on closing of transparency box
- $('#canvas').removeLayers();
- var paintCanvasObj = document.getElementById("canvasPaint");
- var ctx = paintCanvasObj.getContext("2d");
- ctx.clearRect(0, 0, 2277, 3248);
- var sktch = $('#canvasPaint').sketch();
- $('#canvasPaint').sketch().actions = [];
+ if ($rootScope.isAnnotationWindowOpen == true) {
+ $('#canvas').removeLayers();
+ var paintCanvasObj = document.getElementById("canvasPaint");
+ if (paintCanvasObj != null) {
+ var ctx = paintCanvasObj.getContext("2d");
+ ctx.clearRect(0, 0, 2277, 3248);
+
+ var sktch = $('#canvasPaint').sketch();
+ $('#canvasPaint').sketch().actions = [];
+ }
+ }
// $("#annotationpaintbrushsize").removeClass("activebtncolor");
// $("#annotationpainteraser").removeClass("activebtncolor");