Index: ../trunk-jpl/src/m/plot/writejsfile.py
===================================================================
--- ../trunk-jpl/src/m/plot/writejsfile.py	(revision 19055)
+++ ../trunk-jpl/src/m/plot/writejsfile.py	(revision 19056)
@@ -19,7 +19,7 @@
 	#write index:
 	fid.write('<!-- model["index"]{{{-->\n')
 	fid.write('model["index"]=[')
-	for i in xrange(1, nel-1):
+	for i in xrange(0, nel-1):
 		fid.write('[{0}, {1}, {2}],'.format(model.index[i][0],model.index[i][1],model.index[i][2]))
 	fid.write('[{0}, {1}, {2}]];\n'.format(model.index[-1][0],model.index[-1][1],model.index[-1][2]))
 	fid.write('<!--}}}-->\n')
@@ -39,7 +39,7 @@
 	results=model.results
 	fid.write('results={};\n')
 
-	for i in xrange(1,len(results)):
+	for i in xrange(0,len(results)):
 		fid.write('result={};\n')
 		writejsfield(fid,'result["data"]',results[i].data,nods)
 		fid.write('<!--{{{-->\n')
Index: ../trunk-jpl/src/m/plot/writejsfield.py
===================================================================
--- ../trunk-jpl/src/m/plot/writejsfield.py	(revision 19055)
+++ ../trunk-jpl/src/m/plot/writejsfield.py	(revision 19056)
@@ -10,7 +10,7 @@
 	if type(variable[0])==numpy.float64:
 		fid.write('<!-- {0}{{{{{{-->\n'.format(name))
 		fid.write('{0}=['.format(name))
-		for i in xrange(1, nods-1):
+		for i in xrange(0, nods-1):
 			fid.write('{0},'.format(variable[i]))
 		fid.write('{0}];\n'.format(variable[-1]))
 		fid.write('<!--}}}}}}-->\n')
@@ -18,7 +18,7 @@
 		#multi-sized array: 
 		fid.write('<!-- {0}{{{{{{-->\n'.format(name))
 		fid.write('{0}=[]\n'.format(name))
-		for i in xrange(1, len(variable[2])):
+		for i in xrange(0, len(variable[2])):
 			fid.write('{0}["{1}"]=['.format(name,i))
 			for j in xrange(1, nods-1):
 				fid.write('{0},'.format(variable[j][i]))
Index: ../trunk-jpl/src/m/plot/export_gl.py
===================================================================
--- ../trunk-jpl/src/m/plot/export_gl.py	(revision 19055)
+++ ../trunk-jpl/src/m/plot/export_gl.py	(revision 19056)
@@ -15,20 +15,22 @@
 	optionslist=templist.list;
 	options=optionslist[1];
 	options=checkplotoptions(md,options);
+	#print (templist,options)
+	#templist contains options 0-3. Use in the future to rework.
 	
 	#Setup unique directory in present dir: 
 	print ('setting directory')
-	directory=options.getfieldvalue('directory','./');
-	databasename=options.getfieldvalue('database','Pig');
+	directory=optionslist[0].getfieldvalue('directory');
+	databasename=optionslist[0].getfieldvalue('database');
 	
 	#scaling factor: 
 	print ('setting scaling factor')
-	scaling_factor=options.getfieldvalue('scaling_factor',50);
+	scaling_factor=optionslist[0].getfieldvalue('scaling_factor');
 
 	#Deal with title: 
 	print ('setting title')
-	if options.exist('title'):
-		title=options.getfieldvalue('title');
+	if optionslist[0].exist('title'):
+		title=optionslist[0].getfieldvalue('title');
 	else:
 		title='';
 
@@ -39,12 +41,16 @@
 
 	#Deal with contour {{{
 	print ('getting contour')
-	contour_lat1=md.mesh.lat.take(md.mesh.segments[:,0])
-	contour_lat2=md.mesh.lat.take(md.mesh.segments[:,1]);
-	contour_long1=md.mesh.long.take(md.mesh.segments[:,0]);
-	contour_long2=md.mesh.long.take(md.mesh.segments[:,1]);
-	contour_surface1=md.geometry.surface.take(md.mesh.segments[:,0]);
-	contour_surface2=md.geometry.surface.take(md.mesh.segments[:,1]);
+	print (md.mesh.segments)
+	segmenets0 = map(lambda s: s - 1, md.mesh.segments[:,0]);
+	segmenets1 = map(lambda s: s - 1, md.mesh.segments[:,1]);
+	
+	contour_lat1=md.mesh.lat.take(segmenets0)
+	contour_lat2=md.mesh.lat.take(segmenets1);
+	contour_long1=md.mesh.long.take(segmenets0);
+	contour_long2=md.mesh.long.take(segmenets1);
+	contour_surface1=md.geometry.surface.take(segmenets0);
+	contour_surface2=md.geometry.surface.take(segmenets1);
 
 	R1=6371000*np.ones(len(contour_surface1))+scaling_factor*contour_surface1;
 	R2=6371000*np.ones(len(contour_surface2))+scaling_factor*contour_surface2;
@@ -77,11 +83,11 @@
 	model.z=z;
 	model.surface=surface;
 	
-	results = [""]
-	
+	results = []
+	print(optionslist)	
 	#Deal with data: 
 	print('getting data')
-	for i in xrange(1,len(optionslist)):
+	for i in xrange(0,len(optionslist)):
 		options=optionslist[i]; 
 		options=checkplotoptions(md,options);
 		data=options.getfieldvalue('data').flatten();
