//-------------------------------------------------------
// A set of functions to support x-raymicroanalysis.com
// Steve Vale October 2004
// Rev 1
// (C) SH Vale 2004
//--------------------------------------------------------


// A function to open a new window.
// name : url of document to load
// winname : Name of window to load document in (will open a new window if one with this name does not exist)
// width : width of window
// height : height of window
// showtoolbar : boolean, true if toolbar to be shown in new window

function newwin(name,winname,width,height,showtoolbar){
	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); 
	if(win!=null)
	  win.focus() ;
}

//-----------------------------------------------------------------
// Open a new window called "Information" 520x460 pixels in size with a toolbar
// name : url of document to load

function newwindow(name){
	infowin = newwin(name,"Information",520,460,true);
}

//-----------------------------------------------------------------
// Open a new window called "LargeInformation" 650x460 pixels in size with a toolbar
// name : url of document to load

function largewindow(name){
	infowin = newwin(name,"LargeInformation",650,460,true);
}


//------------------------------------------------------------------
// A function to display the INCA navigator bar.  Used in pages describing INCA software
// The navigator to display is specified by the query string in the URL
// Query string expected is of the form ?nav=xxx where xxx =:
// ptid : for the Point and ID navigator
// map : for the Mapping navigator
// an : for the Analyser navigator

function ShowNavigator(){

	titletext="Click on the buttons to find out more about the software feature";

	document.write('<p style="margin-top: 0; margin-bottom: 0" class="medbluetitle" align="center">')
	strinfo = '<p style="margin-top: 0; margin-bottom: 0" class="paragraph">Browse the INCA software by clicking on the Navigator buttons.  <a href="javascript:newwindow(\'../main/navinfo.htm\')">More...</a></p><p></p>';

	switch (navType()) {
	   case "ptid":
         document.write('<b>Point & ID</b>'+strinfo);
         document.write('<div style="position:relative"><map name="FPMap0">')
         document.write('<area href="../common/project.htm?nav=ptid" shape="rect" coords="84, 32, 133, 69">')
         document.write('<area href="../common/micsetup.htm?nav=ptid" shape="rect" coords="16, 88, 64, 124">')
         document.write('<area href="../common/sample.htm?nav=ptid" shape="rect" coords="85, 89, 131, 123">')
         document.write('<area href="../ancommon/quantopt.htm?nav=ptid" shape="rect" coords="17, 146, 62, 181">')
         document.write('<area href="../ptid/siteofinterest.htm?nav=ptid" shape="rect" coords="85, 146, 132, 180">')
         document.write('<area href="../ptid/imagesetup.htm?nav=ptid" shape="rect" coords="153, 145, 200, 182">')
         document.write('<area href="../ancommon/compare.htm?nav=ptid" shape="rect" coords="16, 201, 64, 237">')
         document.write('<area href="../ptid/acquirespectra.htm?nav=ptid" shape="rect" coords="85, 201, 133, 232">')
         document.write('<area href="../ancommon/acqsetup.htm?nav=ptid" shape="rect" coords="154, 203, 201, 239">')
         document.write('<area href="../ancommon/confirm.htm?nav=ptid" shape="rect" coords="84, 258, 132, 292">')
         document.write('<area href="../ancommon/quantanalysis.htm?nav=ptid" shape="rect" coords="85, 315, 132, 351">')
         document.write('<area href="../ancommon/quantsetup.htm?nav=ptid" shape="rect" coords="154, 316, 200, 350">')
         document.write('<area href="../common/report.htm?nav=ptid" shape="rect" coords="85, 371, 133, 403">')
         document.write('</map>')
         document.write('<img border="0" src="../../images/navigator/ptid.jpg" usemap="#FPMap0" width="213" height="504" title="'+titletext+'">')
         break

	   case "temptid":
         document.write('<b>TEM Point & ID</b>'+strinfo);
         document.write('<div style="position:relative"><map name="FPMap0">')
         document.write('<area href="../common/project.htm?nav=temptid" shape="rect" coords="84, 32, 133, 69">')
         document.write('<area href="../common/micsetup.htm?nav=temptid" shape="rect" coords="16, 88, 64, 124">')
         document.write('<area href="../common/sample.htm?nav=temptid" shape="rect" coords="85, 89, 131, 123">')
         document.write('<area href="../ancommon/quantopt.htm?nav=temptid" shape="rect" coords="17, 146, 62, 181">')
         document.write('<area href="../ptid/siteofinterest.htm?nav=temptid" shape="rect" coords="85, 146, 132, 180">')
         document.write('<area href="../ptid/imagesetup.htm?nav=temptid" shape="rect" coords="153, 145, 200, 182">')
         document.write('<area href="../ancommon/compare.htm?nav=temptid" shape="rect" coords="16, 201, 64, 237">')
         document.write('<area href="../temptid/acquirespectra.htm?nav=temptid" shape="rect" coords="85, 201, 133, 232">')
         document.write('<area href="../ancommon/acqsetup.htm?nav=temptid" shape="rect" coords="154, 203, 201, 239">')
         document.write('<area href="../temancommon/confirm.htm?nav=temptid" shape="rect" coords="84, 258, 132, 292">')
         document.write('<area href="../ancommon/quantanalysis.htm?nav=temptid" shape="rect" coords="85, 315, 132, 351">')
         document.write('<area href="../ancommon/quantsetup.htm?nav=temptid" shape="rect" coords="154, 316, 200, 350">')
         document.write('<area href="../common/report.htm?nav=temptid" shape="rect" coords="85, 371, 133, 403">')
         document.write('</map>')
         document.write('<img border="0" src="../../images/navigator/temptid.jpg" usemap="#FPMap0" width="213" height="504" title="'+titletext+'">')
         break;

	   case "map":
         document.write('<b>Mapping</b>'+strinfo);
         document.write('<div style="position:relative"><map name="FPMap0">')
         document.write('<area href="../common/project.htm?nav=map"  shape="rect" coords="84, 32, 133, 69">')
         document.write('<area href="../common/micsetup.htm?nav=map"  shape="rect" coords="16, 88, 64, 124">')
         document.write('<area href="../common/sample.htm?nav=map" shape="rect" coords="85, 89, 131, 123">')
         document.write('<area href="../ptid/siteofinterest.htm?nav=map" shape="rect" coords="85, 147, 132, 181">')
         document.write('<area href="../ptid/imagesetup.htm?nav=map" shape="rect" coords="153, 147, 201, 184">')
         document.write('<area href="../map/cameo.htm?nav=map" shape="rect" coords="15 202, 64 236">')
         document.write('<area href="../map/smartmap.htm?nav=map" shape="rect" coords="85, 201, 133, 232">')
         document.write('<area href="../map/mapsetup.htm?nav=map" shape="rect" coords="154, 204, 202, 242">')
         document.write('<area href="../map/linescan.htm?nav=map" shape="rect" coords="15, 258, 63, 295">')
         document.write('<area href="../map/maps.htm?nav=map" shape="rect" coords="83, 259, 131, 293">')
         document.write('<area href="../map/elemsetup.htm?nav=map" shape="rect" coords="154, 259, 201, 294">')
         document.write('<area href="../map/phasemap.htm?nav=map" shape="rect" coords="85, 315, 132, 351">')
         document.write('<area href="../common/report.htm?nav=map" shape="rect" coords="85, 371, 133, 403">')
         document.write('</map>')
         document.write('<img border="0" src="../../images/navigator/mapping.jpg" usemap="#FPMap0" width="213" height="504" title="'+titletext+'">')
	   break;

	   case "temmap":
         document.write('<b>TEM Mapping</b>'+strinfo);
         document.write('<div style="position:relative"><map name="FPMap0">')
         document.write('<area href="../common/project.htm?nav=temmap"  shape="rect" coords="84, 32, 133, 69">')
         document.write('<area href="../common/micsetup.htm?nav=temmap"  shape="rect" coords="16, 88, 64, 124">')
         document.write('<area href="../common/sample.htm?nav=temmap" shape="rect" coords="85, 89, 132, 126">')
         document.write('<area href="../ptid/siteofinterest.htm?nav=temmap" shape="rect" coords="85, 147, 132, 181">')
         document.write('<area href="../ptid/imagesetup.htm?nav=temmap" shape="rect" coords="153, 147, 201, 184">')
         document.write('<area href="../map/cameo.htm?nav=temmap" shape="rect" coords="15 202, 64 236">')
         document.write('<area href="../temmap/smartmap.htm?nav=temmap" shape="rect" coords="85, 201, 133, 232">')
         document.write('<area href="../map/mapsetup.htm?nav=temmap" shape="rect" coords="154, 204, 202, 242">')
         //document.write('<area href="../map/linescan.htm?nav=temmap" shape="rect" coords="15, 258, 63, 295">')
         document.write('<area href="../temmap/maps.htm?nav=temmap" shape="rect" coords="83, 259, 131, 293">')
         document.write('<area href="../map/elemsetup.htm?nav=temmap" shape="rect" coords="154, 259, 201, 294">')
         //document.write('<area href="../map/phasemap.htm?nav=temmap" shape="rect" coords="85, 315, 132, 351">')
         document.write('<area href="../common/report.htm?nav=temmap" shape="rect" coords="85, 371, 133, 403">')
         document.write('</map>')
         document.write('<img border="0" src="../../images/navigator/temmapping.jpg" usemap="#FPMap0" width="213" height="504" title="'+titletext+'">')
	   break;

	   case "an":
         document.write('<b>Analyzer</b>'+strinfo);
         document.write('<div style="position:relative"><map name="FPMap0">')
         document.write('<area href="../common/project.htm?nav=an" shape="rect" coords="84, 32, 132, 69">')
         document.write('<area href="../analyser/synthesis.htm?nav=an" shape="rect" coords="154, 33, 201, 68">')
         document.write('<area href="../common/sample.htm?nav=an" shape="rect" coords="84, 89, 132, 126">')
         document.write('<area href="../common/micsetup.htm?nav=an" shape="rect" coords="86, 147, 134, 185">')
         document.write('<area href="../ancommon/quantopt.htm?nav=an" shape="rect" coords="14, 147, 64, 184">')
         document.write('<area href="../analyser/acquirespectra.htm?nav=an" shape="rect" coords="84, 203, 132, 241">')
         document.write('<area href="../ancommon/acqsetup.htm?nav=an" shape="rect" coords="154, 203, 200, 237">')
         document.write('<area href="../ancommon/compare.htm?nav=an" shape="rect" coords="14, 203, 64, 237">')
         document.write('<area href="../ancommon/confirm.htm?nav=an" shape="rect" coords="84, 260, 131, 293">')
         document.write('<area href="../analyser/match.htm?nav=an" shape="rect" coords="14, 259, 63, 293">')
         document.write('<area href="../analyser/standardize.htm?nav=an" shape="rect" coords="14, 315, 63, 351">')
         document.write('<area href="../ancommon/quantanalysis.htm?nav=an" shape="rect" coords="85, 315, 133, 351">')
         document.write('<area href="../ancommon/quantsetup.htm?nav=an" shape="rect" coords="153, 316, 203, 352">')
         document.write('<area href="../common/report.htm?nav=an" shape="rect" coords="84, 372, 132, 408">')
         document.write('</map>')
         document.write('<img border="0" src="../../images/navigator/analyser.jpg" usemap="#FPMap0" width="213" height="504" title="'+titletext+'">')
	   break;

	   case "teman":
         document.write('<b>TEM Analyzer</b>'+strinfo);
         document.write('<div style="position:relative"><map name="FPMap0">')
         document.write('<area href="../common/project.htm?nav=teman" shape="rect" coords="84, 32, 132, 69">')
         document.write('<area href="../common/sample.htm?nav=teman" shape="rect" coords="84, 89, 132, 126">')
         document.write('<area href="../common/micsetup.htm?nav=teman" shape="rect" coords="86, 147, 134, 185">')
         document.write('<area href="../ancommon/quantopt.htm?nav=teman" shape="rect" coords="14, 147, 64, 184">')
         document.write('<area href="../analyser/acquirespectra.htm?nav=teman" shape="rect" coords="84, 203, 132, 241">')
         document.write('<area href="../ancommon/compare.htm?nav=teman" shape="rect" coords="14, 203, 64, 237">')
         document.write('<area href="../temancommon/confirm.htm?nav=teman" shape="rect" coords="84, 260, 131, 293">')
         document.write('<area href="../analyser/match.htm?nav=teman" shape="rect" coords="14, 259, 63, 293">')
         document.write('<area href="../ancommon/quantanalysis.htm?nav=teman" shape="rect" coords="85, 315, 133, 351">')
         document.write('<area href="../ancommon/quantsetup.htm?nav=teman" shape="rect" coords="153, 316, 203, 352">')
         document.write('<area href="../common/report.htm?nav=teman" shape="rect" coords="84, 372, 132, 408">')
         document.write('</map>')
         document.write('<img border="0" src="../../images/navigator/temanalyzer.jpg" usemap="#FPMap0" width="213" height="504" title="'+titletext+'">')
	   break;

	   case "wdsan":
         document.write('<b>Wave-Analyze</b>'+strinfo);
         document.write('<div style="position:relative"><map name="FPMap0">')
         document.write('<area href="../common/project.htm?nav=wdsan" shape="rect" coords="85, 32, 133, 67">')
         document.write('<area shape="rect" coords="11, 102, 60, 139">')
         document.write('<area href="../common/sample.htm?nav=wdsan" shape="rect" coords="85, 102, 133, 136">')
         document.write('<area href="../wave/spectralscan.htm?nav=wdsan" shape="rect" coords="12, 171, 62, 205">')
         document.write('<area href="../wave/scanelements.htm?nav=wdsan" shape="rect" coords="85, 171, 133, 208">')
         document.write('<area href="../wave/scansetup.htm?nav=wdsan" shape="rect" coords="154, 171, 203, 208">')
         document.write('<area href="../wave/measureelements.htm?nav=wdsan" shape="rect" coords="85, 239, 133, 275">')
         document.write('<area href="../wave/measuresetup.htm?nav=wdsan" shape="rect" coords="156, 241, 200, 278">')
         document.write('<area href="../wave/quantanalysis.htm?nav=wdsan" shape="rect" coords="85, 309, 130, 343">')
         document.write('<area shape="rect" coords="153, 310, 204, 347">')
         document.write('<area href="../common/report.htm?nav=wdsan" shape="rect" coords="85, 378, 133, 415">')
         document.write('</map>')
         document.write('<img border="0" src="../../images/navigator/waveanalyse.jpg" usemap="#FPMap0" width="213" height="504" title="'+titletext+'">')
	   break;

	   case "auto":
         document.write('<b>Automate</b><p></p>');
         document.write('<img border="0" src="../../images/navigator/automate.jpg" width="213" height="504">')
	   break;

	   case "feat":
         document.write('<b>Feature</b><p></p>');
         document.write('<img border="0" src="../../images/navigator/feature.jpg" width="213" height="504">')
	   break;

	   default :
		alert("No switch passed in ShowNavigator")
	}

      showHighlight();
}

//------------------------------------------------------------------
//Show the highlight over the relevant Navigator button

function showHighlight(){

  //image is right size to cover button
  document.write('<img name="hlight" id="hlight" SRC="../../images/navigator/yellowpixel.gif" STYLE="position:absolute; visibility:hidden; opacity:0.3; -moz-opacity: 0.3; filter:alpha(opacity=30)" width="46" height="35"></div>');
  var strhref = new String("");
  var oarea = document.getElementsByTagName("area");
  for(var i=0;i<oarea.length;i++){
    strhref=oarea[i].href;
    if(strhref=="")
      continue;
    strhref=strhref.substring(strhref.lastIndexOf("/")+1,strhref.indexOf(".htm"));
    if(location.href.indexOf(strhref)!==-1){
      strcoords = new Array();
      strcoords = oarea[i].coords.split(",");
      var ohlight = document.getElementById("hlight");
      ohlight.style.left=parseInt(strcoords[0]);
      //Netscape puts higlight in slightly different place.
      if (navigator.appName!="Microsoft Internet Explorer")
        ohlight.style.left=parseInt(strcoords[0])+6;
      ohlight.style.top=parseInt(strcoords[1]);
      ohlight.style.visibility="visible";
      break;
    }
  }
}


//------------------------------------------------------------------
// Function to return the string representing the navigator type as given by by the "nav=" part of the query string

function navType(){
	strloc = location.search;
      strnav = "nav=";
      indnav = strloc.indexOf(strnav);
      if(indnav == -1){
        return("ptid");
      }else{
        return(strloc.substring(indnav+strnav.length));
      }
}

//-------------------------------------------------------------------
// Function returns true if query string shows this page is to contain TEM information

function isTEM(){
	strtype=navType();
	return((strtype.indexOf("tem")==-1)?false:true);
}
//-------------------------------------------------------------------
// Function returns true if query string shows this page is to contain map information

function isMAP(){
	strtype=navType();
	return((strtype.indexOf("map")==-1)?false:true);
}

//-------------------------------------------------------------------
// Function returns true if query string shows this page is for the wave analyse navigator

function isWAVE(){
	strtype=navType();
	return(strtype=="wdsan")
}

//--------------------------------------------------------------------
// Function inserts hyperlink in HTML to the correct description of quantitiatve analysis for SEM or TEM

function quantLink(){
	if(!isTEM()){
        document.write('<a href="javascript:showGlossaryPage(45,1)"> quantitative </a>')
      }else{
	  document.write('<a href="../tutorial3/quantitativeanalysis.htm"> quantitative </a>')
      }
}



