
function setOverlay() {
   var obj = $('all');
   var id = 'gmipam_0_canvas';
   var bd = '0,0,255';
   var co = '0,0,0';
   var op = '0.33';
   var nb = 0;
   var f = 1;
   var z = 0;
   var a, i, j, d, c, o, b, n, l, r, v, u, x, y, p, k = 0, t = '', r = obj.getAttribute('rel'), context, canvas = document.getElementById(id);
   if(r != null) {
      d = r.split(",");
      v = d.unshift(obj.id);
      }
   else {
      d = new Array(obj.id);
      }
   function setAttr() {
      if(l.indexOf('forcegroup') !=- 1) {
         k = getClassAttribute(u, "forcegroup");
         }
      else {
         k = 0;
         }
      if(l.indexOf('iopacity') !=- 1) {
         o = getClassValue(u, "iopacity") / 100;
         }
      else {
         o = op;
         }
      if(l.indexOf('iborder') !=- 1) {
         b = getClassRGBColor(u, "iborder", bd);
         }
      else {
         b = bd;
         }
      if(l.indexOf('icolor') !=- 1) {
         c = getClassRGBColor(u, "icolor", co);
         }
      else {
         c = co;
         }
      if(l.indexOf('noborder') !=- 1) {
         n = getClassAttribute(u, "noborder");
         }
      else {
         n = nb;
         }
      }
   if(isVM) {
      for(a = 0; a < d.length; a++) {
         obj = document.getElementById(d[a]);
         p = '', l = obj.className, u = l.split(" "), v = obj.coords.split(",");
         if(k == 0) {
            setAttr();
            }
         if(obj.shape.toLowerCase() == 'rect') {
            t += '<v:rect strokeweight="1" filled="t" stroked="' + (n < 1 ? "t" : "f") + '" strokecolor="#' + b + '" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + parseInt(v[0]) + 'px;top:' + parseInt(v[1]) + 'px;width:' + parseInt(v[2] - v[0]) + 'px;height:' + parseInt(v[3] - v[1]) + 'px;"><v:fill color="#' + c + '" opacity="' + o + '" /></v:rect>';
            }
         else if(obj.shape.toLowerCase() == 'circle') {
            t += '<v:oval strokeweight="1" filled="t" stroked="' + (n < 1 ? "t" : "f") + '" strokecolor="#' + b + '" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + parseInt(v[0] - v[2]) + 'px;top:' + parseInt(v[1] - v[2]) + 'px;width:' + (parseInt(v[2]) * 2) + 'px;height:' + (parseInt(v[2]) * 2) + 'px;"><v:fill color="#' + c + '" opacity="' + o + '" /></v:oval>';
            }
         else {
            for(j = 2; j < v.length; j += 2) {
               p += parseInt(v[j]) + ',' + parseInt(v[j + 1]) + ',';
               }
            t += '<v:shape strokeweight="1" filled="t" stroked="' + (n < 1 ? "t" : "f") + '" strokecolor="#' + b + '" coordorigin="0,0" coordsize="' + canvas.width + ',' + canvas.height + '" path="m ' + parseInt(v[0]) + ',' + parseInt(v[1]) + ' l ' + p + ' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' + canvas.width + 'px;height:' + canvas.height + 'px;"><v:fill color="#' + c + '" opacity="' + o + '" /></v:shape>';
            }
         }
      canvas.innerHTML = t;
      }
   else if(isCV) {
      if(f < 1) {
         canvas.fading = 0;
         canvas.style.opacity = 0;
         }
      context = canvas.getContext("2d");
      for(a = 0; a < d.length; a++) {
         obj = document.getElementById(d[a]);
         l = obj.className, u = l.split(" "), v = obj.coords.split(",");
         if(k == 0) {
            setAttr();
            }
         context.beginPath();
         if(obj.shape.toLowerCase() == 'rect') {
            context.rect(0.5 + parseInt(v[0]), 0.5 + parseInt(v[1]), parseInt(v[2] - v[0]), parseInt(v[3] - v[1]));
            context.closePath();
            }
         else if(obj.shape.toLowerCase() == 'circle') {
            context.arc(0.5 + parseInt(v[0]), 0.5 + parseInt(v[1]), parseInt(v[2]), 0, (Math.PI / 180) * 360, false);
            }
         else {
            context.moveTo(parseInt(v[0]), parseInt(v[1]));
            for(j = 2; j < v.length; j += 2) {
               context.lineTo(parseInt(v[j]), parseInt(v[j + 1]));
               }
            context.closePath();
            }
         context.fillStyle = 'rgba(' + c + ',' + o + ')';
         context.strokeStyle = 'rgba(' + b + ',1)';
         context.fill();
         if(n < 1) {
            context.stroke();
            }
         }
      if(f < 1) {
         canvas.fading = 1;
         fadeCanvas(id, 0);
         }
      }
   else {
      o = op;
      l = obj.className;
      u = l.split(" ");
      if(l.indexOf('forcegroup') !=- 1) {
         k = getClassAttribute(u, "forcegroup");
         if(k != 0) {
            if(l.indexOf('iopacity') !=- 1) {
               o = getClassValue(u, "iopacity") / 100;
               k = 0;
               }
            }
         }
      if(isIE) {
         canvas.style.filter = "Alpha(opacity=" + (o * 100) + ")";
         }
      else {
         canvas.style.opacity = o;
         canvas.style.MozOpacity = o;
         canvas.style.KhtmlOpacity = o;
         }
      for(a = 0; a < d.length; a++) {
         obj = document.getElementById(d[a]);
         l = obj.className, u = l.split(" "), v = obj.coords.split(",");
         if(k == 0) {
            if(l.indexOf('forcegroup') !=- 1) {
               k = getClassAttribute(u, "forcegroup");
               }
            else {
               k = 0;
               }
            if(l.indexOf('icolor') !=- 1) {
               c = getClassRGBColor(u, "icolor", co);
               }
            else {
               c = co;
               }
            }
         jg[z].setColor("#" + c);
         if(obj.shape.toLowerCase() == 'rect') {
            jg[z].fillRect(parseInt(v[0]), parseInt(v[1]), parseInt(v[2] - v[0]) + 1, parseInt(v[3] - v[1]) + 1);
            }
         else if(obj.shape.toLowerCase() == 'circle') {
            jg[z].fillEllipse(parseInt(v[0] - v[2]), parseInt(v[1] - v[2]), parseInt(v[2]) * 2 + 1, parseInt(v[2]) * 2 + 1);
            }
         else {
            x = new Array();
            y = new Array();
            i = 0;
            for(j = 0; j < v.length; j += 2) {
               x[i] = parseInt(v[j]);
               y[i] = parseInt(v[j + 1]);
               i++;
               }
            jg[z].fillPolygon(x, y);
            }
         jg[z].paint();
         }
      }
   }




function setSelect(selectedID) {
   var obj = $(selectedID);
   var id = 'gmipam_0_canvas';
   var bd = '0,0,255';
   var co = '0,0,0';
   var op = '0.33';
   var nb = 0;
   var f = 1;
   var z = 0;
   var a, i, j, d, c, o, b, n, l, r, v, u, x, y, p, k = 0, t = '', r = obj.getAttribute('rel'), context, canvas = $(id);
   if(r != null) {
      d = r.split(",");
      v = d.unshift(obj.id);
      }
   else {
      d = new Array(obj.id);
      }
   function setAttr() {
      if(l.indexOf('forcegroup') !=- 1) {
         k = getClassAttribute(u, "forcegroup");
         }
      else {
         k = 0;
         }
      if(l.indexOf('iopacity') !=- 1) {
         o = getClassValue(u, "iopacity") / 100;
         }
      else {
         o = op;
         }
      if(l.indexOf('iborder') !=- 1) {
         b = getClassRGBColor(u, "iborder", bd);
         }
      else {
         b = bd;
         }
      if(l.indexOf('icolor') !=- 1) {
         c = getClassRGBColor(u, "icolor", co);
         }
      else {
         c = co;
         }
      if(l.indexOf('noborder') !=- 1) {
         n = getClassAttribute(u, "noborder");
         }
      else {
         n = nb;
         }
      }
   if(isVM) {
      for(a = 0; a < d.length; a++) {
         obj = document.getElementById(d[a]);
         p = '', l = obj.className, u = l.split(" "), v = obj.coords.split(",");
         if(k == 0) {
            setAttr();
            }
         if(obj.shape.toLowerCase() == 'rect') {
            t += '<v:rect strokeweight="1" filled="t" stroked="' + (n < 1 ? "t" : "f") + '" strokecolor="#' + b + '" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + parseInt(v[0]) + 'px;top:' + parseInt(v[1]) + 'px;width:' + parseInt(v[2] - v[0]) + 'px;height:' + parseInt(v[3] - v[1]) + 'px;"><v:fill color="#' + c + '" opacity="' + o + '" /></v:rect>';
            }
         else if(obj.shape.toLowerCase() == 'circle') {
            t += '<v:oval strokeweight="1" filled="t" stroked="' + (n < 1 ? "t" : "f") + '" strokecolor="#' + b + '" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + parseInt(v[0] - v[2]) + 'px;top:' + parseInt(v[1] - v[2]) + 'px;width:' + (parseInt(v[2]) * 2) + 'px;height:' + (parseInt(v[2]) * 2) + 'px;"><v:fill color="#' + c + '" opacity="' + o + '" /></v:oval>';
            }
         else {
            for(j = 2; j < v.length; j += 2) {
               p += parseInt(v[j]) + ',' + parseInt(v[j + 1]) + ',';
               }
            t += '<v:shape strokeweight="1" filled="t" stroked="' + (n < 1 ? "t" : "f") + '" strokecolor="#' + b + '" coordorigin="0,0" coordsize="' + canvas.width + ',' + canvas.height + '" path="m ' + parseInt(v[0]) + ',' + parseInt(v[1]) + ' l ' + p + ' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' + canvas.width + 'px;height:' + canvas.height + 'px;"><v:fill color="#' + c + '" opacity="' + o + '" /></v:shape>';
            }
         }
      canvas.innerHTML = t;
      }
   else if(isCV) {
      if(f < 1) {
         canvas.fading = 0;
         canvas.style.opacity = 0;
         }
      context = canvas.getContext("2d");
      for(a = 0; a < d.length; a++) {
         obj = document.getElementById(d[a]);
         l = obj.className, u = l.split(" "), v = obj.coords.split(",");
         if(k == 0) {
            setAttr();
            }
         context.beginPath();
         if(obj.shape.toLowerCase() == 'rect') {
            context.rect(0.5 + parseInt(v[0]), 0.5 + parseInt(v[1]), parseInt(v[2] - v[0]), parseInt(v[3] - v[1]));
            context.closePath();
            }
         else if(obj.shape.toLowerCase() == 'circle') {
            context.arc(0.5 + parseInt(v[0]), 0.5 + parseInt(v[1]), parseInt(v[2]), 0, (Math.PI / 180) * 360, false);
            }
         else {
            context.moveTo(parseInt(v[0]), parseInt(v[1]));
            for(j = 2; j < v.length; j += 2) {
               context.lineTo(parseInt(v[j]), parseInt(v[j + 1]));
               }
            context.closePath();
            }
         context.fillStyle = 'rgba(' + c + ',' + o + ')';
         context.strokeStyle = 'rgba(' + b + ',1)';
         context.fill();
         if(n < 1) {
            context.stroke();
            }
         }
      if(f < 1) {
         canvas.fading = 1;
         fadeCanvas(id, 0);
         }
      }
   else {
      o = op;
      l = obj.className;
      u = l.split(" ");
      if(l.indexOf('forcegroup') !=- 1) {
         k = getClassAttribute(u, "forcegroup");
         if(k != 0) {
            if(l.indexOf('iopacity') !=- 1) {
               o = getClassValue(u, "iopacity") / 100;
               k = 0;
               }
            }
         }
      if(isIE) {
         canvas.style.filter = "Alpha(opacity=" + (o * 100) + ")";
         }
      else {
         canvas.style.opacity = o;
         canvas.style.MozOpacity = o;
         canvas.style.KhtmlOpacity = o;
         }
      for(a = 0; a < d.length; a++) {
         obj = document.getElementById(d[a]);
         l = obj.className, u = l.split(" "), v = obj.coords.split(",");
         if(k == 0) {
            if(l.indexOf('forcegroup') !=- 1) {
               k = getClassAttribute(u, "forcegroup");
               }
            else {
               k = 0;
               }
            if(l.indexOf('icolor') !=- 1) {
               c = getClassRGBColor(u, "icolor", co);
               }
            else {
               c = co;
               }
            }
         jg[z].setColor("#" + c);
         if(obj.shape.toLowerCase() == 'rect') {
            jg[z].fillRect(parseInt(v[0]), parseInt(v[1]), parseInt(v[2] - v[0]) + 1, parseInt(v[3] - v[1]) + 1);
            }
         else if(obj.shape.toLowerCase() == 'circle') {
            jg[z].fillEllipse(parseInt(v[0] - v[2]), parseInt(v[1] - v[2]), parseInt(v[2]) * 2 + 1, parseInt(v[2]) * 2 + 1);
            }
         else {
            x = new Array();
            y = new Array();
            i = 0;
            for(j = 0; j < v.length; j += 2) {
               x[i] = parseInt(v[j]);
               y[i] = parseInt(v[j + 1]);
               i++;
               }
            jg[z].fillPolygon(x, y);
            }
         jg[z].paint();
         }
      }
   }
		
function releaseSelect(selectedID) {
	var obj = $('map').getElement(selectedID);
		var id = 'gmipam_0_canvas';
		var f = 0;
		var z = 0;
	var canvas = $(id);
	if(isVM) {canvas.innerHTML = '';}else 
	if(isJG) {jg[z].clear();}else if(isCV) {
		var context = canvas.getContext("2d");
		context.clearRect(0,0,canvas.width,canvas.height);
	}
	setOverlay();
}



