function viewfig(s){

  //View a figure in a new window. 
  //s is figure file name 

  figwin = newwin("","Figures",850,650,false);
  figwin.document.open("text/html");
  figwin.document.write("<div align='center'>");
  figwin.document.write("<BUTTON TYPE='button' id = 'Close' ONCLICK='window.close()'>Close this window</button>")
  figwin.document.write("<p></p><IMG SRC = '" + s + "'>");	
  figwin.document.write("</div>");
  figwin.document.close();
  figwin.document.title="Figure";
  figwin.focus();

}

function newwin(name,winname,width,height,showtoolbar){
	//Open a new window.
	//name is html document to load, winname is name of window to use, width, height are width and height of window,
	//showtoolbar is set if toolbar is to be shown.
	window_width = width ;
	window_height = height ;
	str = 'left=' + (screen.width - window_width)/2 ;
	str = str + ',top=' + (screen.height - window_height)/2 ;
	str = str + ',width=' + window_width + ',height=' + window_height + ',scrollbars=yes' ;
      str = str + ',resizable=yes';
	if (showtoolbar)
		str=str+' ,toolbar=yes';
	win = window.open(name, winname, str); 
	win.focus() ;
	return (win);
}
