Index: /issm/trunk-jpl/src/m/plot/plot_manager.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plot_manager.js	(revision 19863)
+++ /issm/trunk-jpl/src/m/plot/plot_manager.js	(revision 19864)
@@ -29,5 +29,6 @@
 	
 	//Initialize the buffer structure: 
-	var node = Node(gl,options);
+	var nodes = {};
+	nodes["main"] = Node(gl,options);
 	
 	//figure out if this is a special plot
@@ -95,5 +96,5 @@
 			case 'mesh':
 				//plot_mesh(md,options,nlines,ncols,i);
-				plot_mesh(md,options,canvas,gl,node);
+				plot_mesh(md,options,canvas,gl,nodes["main"]);
 				break;
 			case 'none':
@@ -187,7 +188,7 @@
 
 	//Figure out if this is a semi-transparent plot.
-	if (options.exist('overlay')){
-		plot_overlay(md,data,options,nlines,ncols,i);
-		return;
+	if (options.getfieldvalue('overlay','off')=='on'){
+		nodes["overlay"] = Node(gl,options);
+		plot_overlay(md,data,options,canvas,gl,nodes["overlay"]);
 	}
 
@@ -218,11 +219,11 @@
 	if (typeof data !== 'string'){
 		//plot unit
-		plot_unit(md,data,options,canvas,gl,node);
+		plot_unit(md,data,options,canvas,gl,nodes["main"]);
 	}
 
 	//applyoptions(md,data2,options); 
-	applyoptions(md,data,options,canvas,gl,node);
+	applyoptions(md,data,options,canvas,gl,nodes["main"]);
 	
 	/*Draw into the canvas:*/
-	draw(gl,options,canvas,node);
+	draw(gl,options,canvas,nodes);
 }
Index: /issm/trunk-jpl/src/m/plot/plot_overlay.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plot_overlay.js	(revision 19864)
+++ /issm/trunk-jpl/src/m/plot/plot_overlay.js	(revision 19864)
@@ -0,0 +1,69 @@
+function plot_overlay(md,data,options,canvas,gl,node){
+	//PLOT_OVERLAY - Function for plotting a georeferenced image.  
+	//This function is called from within the plotmodel code.
+	//
+	//   Usage:
+	//      plot_overlay(md,data,options,canvas,gl,node);
+	//
+	//   See also: PLOTMODEL, PLOT_MANAGER
+
+	//declare variables:  {{{
+	var vertices = [];
+	var indices = [];
+	var texcoords = [];
+	var xmin,xmax;
+	var ymin,ymax;
+	var zmin,zmax;
+	
+	//Process data and model
+	var x = md.mesh.x;
+	var y = md.mesh.y;
+	var z = [0.0];
+	var elements = md.mesh.elements;
+	//}}}
+
+	//Compute coordinates and data range:
+	xlim=options.getfieldvalue('xlim',[ArrayMin(x),ArrayMax(x)]);
+	ylim=options.getfieldvalue('ylim',[ArrayMin(y),ArrayMax(y)]);
+	xmin = xlim[0];
+	xmax = xlim[1];
+	ymin = ylim[0];
+	ymax = ylim[1];
+	zmin = ArrayMin(z);
+	zmax = ArrayMax(z);
+	
+	//Compute scaling: 
+	var scale = 1 / (xmax - xmin);
+	node["scale"] = [scale, scale, scale];
+	node["rotation"] = options.getfieldvalue('view',[0,0,0]);
+	node["translation"] = [(xmin + xmax) / (-2 / scale), (ymin + ymax) / (-2 / scale), (zmin + zmax) / (-2 / scale)];
+	node["modelMatrix"] = recalculateModelMatrix(node);
+	node["texture"] = initTexture(gl,options.getfieldvalue('image','images/checker.gif'));
+	node["alpha"] = options.getfieldvalue('alpha',1.0);
+	node["overlay"] = true;
+				
+	//some defaults:
+	texcoords.itemSize = 2;
+	vertices.itemSize = 3;
+	
+	var xrange = xmax - xmin;
+	var yrange = ymax - ymin;
+	
+	//generate mesh:
+	for(var i = 0; i < x.length; i++){
+		vertices[vertices.length] = x[i];
+		vertices[vertices.length] = y[i];
+		vertices[vertices.length] = 0.0;
+
+		texcoords[texcoords.length] = (x[i] - xmin) / xrange;
+		texcoords[texcoords.length] = (y[i] - ymin) / yrange;
+	}
+	
+	//linearize the elements array: 
+	indices = indices.concat.apply(indices, elements); 
+	indices.itemSize = 1;
+	for(var i=0;i<indices.length;i++)indices[i]--; //matlab indices from 1, so decrement.
+	
+	/*Initalize buffers: */
+	node["buffers"] = initBuffers(gl,[vertices, texcoords, indices]);
+}
Index: /issm/trunk-jpl/src/m/plot/plot_unit.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/plot_unit.js	(revision 19863)
+++ /issm/trunk-jpl/src/m/plot/plot_unit.js	(revision 19864)
@@ -140,3 +140,4 @@
 	/*Initalize buffers: */
 	node["buffers"] = initBuffers(gl,[vertices, texcoords, indices]);
+	node["overlay"] = false;
 }
Index: /issm/trunk-jpl/src/m/plot/webgl.js
===================================================================
--- /issm/trunk-jpl/src/m/plot/webgl.js	(revision 19863)
+++ /issm/trunk-jpl/src/m/plot/webgl.js	(revision 19864)
@@ -22,4 +22,6 @@
 	// Clear the color as well as the depth buffer.
 	gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+	// Enable color blending/overlay
+	gl.enable(gl.BLEND);
 
 	// Allocate arrays equal to maximium number of attributes used by any one shader
@@ -99,8 +101,6 @@
 } //}}}
 function Node(gl,options) { //{{{
-	
-	var node;
-
-	node= {buffers:[],
+	//Returns a Node object that contains default display states for webgl object
+	return {buffers:[],
 		shader:gl.shaders["unlit_textured"]["program"],
 		draw:null,
@@ -109,5 +109,5 @@
 		useIndexBuffer:true,
 		useOrthographic:false,
-		transparency:1.0,
+		alpha:1.0,
 		disableDepthTest:false, 
 		enableCullFace:false,
@@ -120,8 +120,6 @@
 		modelMatrix:mat4.create(),
 		shaderName:"unlit_textured",
+		overlay:false,
 	};
-	
-	return node;
-
 } //}}}
 function recalculateModelMatrix(node) { //{{{
@@ -210,7 +208,8 @@
 		'',
 		'uniform sampler2D uColorSampler;',
+		'uniform float uAlpha;',
 		'',
 		'void main(void) {',
-		'	gl_FragColor = texture2D(uColorSampler, vec2(vTextureCoord.s, vTextureCoord.t));',
+		'	gl_FragColor = vec4(texture2D(uColorSampler, vec2(vTextureCoord.s, vTextureCoord.t)).rgb, uAlpha);',
 		'}'].join('\n');
 	shaderNames.forEach(function(shaderName){
@@ -323,5 +322,5 @@
 	}
 	gl.uniformMatrix4fv(node["shader"]["uMVPMatrix"], false, mvpMatrix);
-	gl.uniform1f(node["shader"]["uAlpha"], node["transparency"]);
+	gl.uniform1f(node["shader"]["uAlpha"], node["alpha"]);
 	if (node["texture"]) {
 		gl.activeTexture(gl.TEXTURE0);
@@ -329,5 +328,11 @@
 		gl.uniform1i(node["shader"]["uColorSampler"], 0);	
 	}
-	if  (node["useIndexBuffer"]) {
+	if (node["overlay"] == true) {
+		gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
+	}
+	else {
+		gl.blendFunc (gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
+	}
+	if  (node["useIndexBuffer"] == true) {
 		gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, node["buffers"][node["buffers"].length - 1]);
 		gl.drawElements(node["drawMode"], node["buffers"][node["buffers"].length - 1].numItems, gl.UNSIGNED_SHORT, 0);
@@ -350,5 +355,5 @@
 	}
 } //}}}
-function draw(gl,options,canvas,node) { //{{{
+function draw(gl,options,canvas,nodes) { //{{{
 
 	// Set clear color to black, fully opaque
@@ -358,12 +363,13 @@
 	}
 	else throw Error(sprintf("s%s%s\n","initWebGL error message: cound not find out background color for curent canvas ",canvas));
-	
+		
 	// Clear the color as well as the depth buffer.
 	gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
 
-	window.requestAnimationFrame(function(time) {draw(gl,options,canvas,node)});
+	window.requestAnimationFrame(function(time) {draw(gl,options,canvas,nodes)});
 	updateCameraMatrix(canvas);
-
-	drawSceneGraphNode(gl, canvas, node);
+	for (var node in nodes) {
+		drawSceneGraphNode(gl, canvas, nodes[node]);
+	}
 } //}}}
 //}}}
