//Set of functions to support opening windows for EBSD.COM
//Steve Vale March 2004
//15 June 04 - make opened window resizable.
//18 July 04 - "," before "toolbars" - didn't work without this in Mozilla!
//23 July 2004
// Change "title=" to "title=" so works with Mozilla.
//--------------------------------------------------------

infowin = null;
appwin = null;
figwin = null;
var str = new String("");

function closewin(){
	return;
}
function newwindow(name){
	infowin = newwin(name,"Information",520,460,true);
}
function appletwindow(name){
	appwin = newwin(name,"Applet",600,550,false);
}
function figsetwindow(name){
	figwin = newwin(name,"Figures",580,500,false);
}
function winclose(hwin){
	if (hwin != null)
		if(!hwin.closed)
			hwin.close();
}

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);
}

function viewfig(s,c){
	//View a figure in a new window. s is figure file name and c is figure caption.
	figwin = newwin("","Figures",580,500,false);
	figwin.document.open("text/html");
	figwin.document.write("<link rel='stylesheet' type='text/css' href='includes/oicss.css'>")
	figwin.document.write("<div align='center'>");
	if (c!=null){
		figwin.document.write("<IMG SRC = " + s + " title='" + c + "'>");
		figwin.document.write("<p class='tinyblacktext' style='margin: 0 0'>"+c+"</p>");
	}
	else{
		figwin.document.write("<IMG SRC = '" + s + "'><p></p>");
	}	
	figwin.document.write("<BUTTON TYPE='button' id = 'close' ONCLICK='window.close()'>Close</button>")
	figwin.document.write("</div>");
	figwin.document.close();
	figwin.document.title="Figure";
      figwin.focus();
}

//This displays the navigator bar.  The bar to be displayed is given by the query string in the URL

function ShowNavigator(){
	str = location.search;

	//fudge to show a navigator (possibly wrong one) if called from search page.
	if (str == "")
		str="?an";

	switch (str) {
	   case "?an":
        	document.write("<map name='FPMap0'>")
	    	document.write("<area coords='83, 32, 131, 68' shape='rect' href='project.htm?an'>")
	    	document.write("<area coords='82, 103, 131, 139' shape='rect' href='sample.htm?an'>")
	      document.write("<area href='phaseedit.htm?an' shape='rect' coords='151, 103, 201, 140'>")
	      document.write("<area href='siteofinterest.htm?an' shape='rect' coords='82, 174, 130, 212'>")
	      document.write("<area href='siteofinterest.htm?an' shape='rect' coords='151, 177, 200, 212'>")
	      document.write("<area href='patternoptimisation.htm?an' shape='rect' coords='83, 249, 132, 284'>")
	      document.write("<area href='solversetup.htm?an' shape='rect' coords='151, 248, 199, 283'>")
	      document.write("<area href='solutions.htm?an' shape='rect' coords='82, 313, 132, 350'>")
	      document.write("<area href='solutions.htm?an' shape='rect' coords='151, 314, 201, 349'>")
	      document.write("<area href='report.htm?an' shape='rect' coords='82, 379, 132, 416'>")
	    	document.write("</map>")
	    	document.write("<img border='0' src='images/inca/analysenavigator.jpg' usemap='#FPMap0' width='210' height='502' title='Click on the buttons to find out more about the software feature' >")
		break
	   case "?ma":
		document.write("<map name='FPMap0'>")
		document.write("<area href='project.htm?ma' shape='rect' coords='82, 32, 131, 69'>")
		document.write("<area href='sample.htm?ma' shape='rect' coords='82, 90, 131, 124'>")
		document.write("<area href='phaseedit.htm?ma' shape='rect' coords='152, 90, 200, 125'>")
		document.write("<area href='siteofinterest.htm?ma' shape='rect' coords='82, 145, 131, 181'>")
		document.write("<area href='siteofinterest.htm?ma' shape='rect' coords='150, 147, 200, 181'>")
		document.write("<area href='patternoptimisation.htm?ma' shape='rect' coords='83, 202, 130, 238'>")
		document.write("<area href='solversetup.htm?ma' shape='rect' coords='151, 201, 201, 236'>")
		document.write("<area href='acquiremap.htm?ma' shape='rect' coords='81, 260, 132, 293'>")
		document.write("<area href='acquiremap.htm?ma' shape='rect' coords='152, 259, 201, 293'>")
		document.write("<area href='boundaryanalysis.htm?ma' shape='rect' coords='14, 316, 61, 351'>")
		document.write("<area href='orientationanalysis.htm?ma' shape='rect' coords='83, 314, 130, 350'>")
		document.write("<area href='enhancemaps.htm?ma' shape='rect' coords='151, 317, 200, 351'>")
		document.write("<area href='report.htm?ma' shape='rect' coords='82, 373, 130, 406'>")
		document.write("</map> ")
		document.write("<img border='0' src='images/inca/mappingnavigator.jpg' usemap='#FPMap0' width='209' height='503'title='Click on the buttons to find out more about the software feature' >")
		break
	   case "?pr":
		document.write("<map name='FPMap0'>")
		document.write("<area href='project.htm?pr' shape='rect' coords='84, 32, 132, 68'>")
		document.write("<area href='sample.htm?pr' shape='rect' coords='83, 88, 131, 124'>")
		document.write("<area href='sitereview.htm?pr' shape='rect' coords='82, 145, 133, 181'>")
		document.write("<area href='enhancemaps.htm?pr' shape='rect' coords='152, 143, 201, 177'>")
		document.write("<area href='orientationanalysis.htm?pr' shape='rect' coords='83, 200, 131, 236'>")
		document.write("<area href='prboundaryanalysis.htm?pr' shape='rect' coords='50, 256, 97, 293'>")
		document.write("<area href='textureanalysis.htm?pr' shape='rect' coords='120, 257, 167, 294'>")
		document.write("<area href='areaanalysis.htm?pr' shape='rect' coords='83, 315, 131, 351'>")
		document.write("<area href='report.htm?pr' shape='rect' coords='83, 370, 133, 407'>")
		document.write("</map>")
		document.write("<img border='0' src='images/inca/processingnavigator.jpg' usemap='#FPMap0' width='210' height='501'title='Click on the buttons to find out more about the software feature' >")		
		break
	   default :
		alert("No switch passed in ShowNavigator")
	}

}
