function sendSearch3(txt2Find)
{
var docQ = window.parent.frames['navigation'].document; // the 'navigation' frame (contains accordion items [iframes] TOC, Index, Search, etc)
var searchAccord = docQ.getElementById('searchAccordion'); // the div that holds the Search accordion item 
var frmSrch = window.parent.frames['navigation'].frames["search"]; // the iframe that is the Search accordion item
window.parent.frames["navigation"].AccordionItemClick(searchAccord); // click the Search accordion item
frmSrch.document.forms["search"].searchField.value = txt2Find;       // copy the value of our search box to the Search box in accordion
frmSrch.document.getElementById("SearchButton").click();			 // click Search button within Search accordion
}


function submitFormWithEnter(frm, e)
{
var keycode;
if (window.event) 
{
  keycode = window.event.keyCode;
}
else if (e) 
{
  keycode = e.which;
}
else 
{
  return true;
}

if (keycode == 13)
{
frm.form.submit();
var docE = window.parent.frames[0].document;
var tmpE = docE.getElementById("quickSearchField");
sendSearch3(tmpE.value);
return false;
}
else
{
 return true;
}
}


function focusToSearch()
{
if (window.parent.frames.length > 0)
  {
    var docG = window.parent.frames[0].document;

    var tmpG = docG.getElementById("quickSearchField");
    if (tmpG !== null)
      {
         tmpG.focus();
      }
  }
}

var submitURL="";
var tabs;
var j=0;

function hideTabs()  {
  var htHref = document.location.href;
  var htRe = /_\w.htm/;
  var htFrag = "_p.htm";
//  var htHref2 = htHref.replace(htRe, htFrag);
//var htHref2 = "variogramTest1_p.htm";

  tabs = document.getElementById('menu').getElementsByTagName('li');

  hideTabIndividual("_o.htm",0);
  hideTabIndividual("_p.htm",1);
  hideTabIndividual("_e.htm",2);
}

function switch3tab(sTabnum)
{
  var fullHref = document.location.href;
  var myRe = /_\w.htm/;
  var myFrag = "";

  if (sTabnum == 1)
  {
     myFrag = "_o.htm";
  }
  else if (sTabnum == 2)
  {
     myFrag = "_p.htm";
  }
  else
  {
     myFrag = "_e.htm";
  }
  fullHref = fullHref.replace(myRe, myFrag);
  window.open(fullHref, '_self');
}

function SelectIconClickCustom()
{
        var navFrameG = MCGlobals.NavigationFrame;
        navFrameG.frames["search"].open;
}

function submitOnlyIfUrlActive()
{
  if ( window.XMLHttpRequest )
  {
    // oHttp = new window.XMLHttpRequest();
    oHttp = new ajaxRequest();
  }
  else
  {
    if ( window.ActiveXObject )
    {
      oHttp = new ActiveXObject('Msxml2.XMLHTTP');
      // oHttp = new ActiveXObject('Microsoft.XMLHTTP');
      // oHttp = new window.ActiveXObject("Microsoft.XMLHTTP" );
    }
    else
    {
      setStatus("Unsupported Platform");
    }
  }
  if ( !oHttp )
  {
    setStatus("Error");
  }
  oHttp.onreadystatechange = submitOnlyIfUrlActiveCallback;

  try
  {
  oHttp.open("HEAD", submitURL, false ); // true = async, false = sync
  // setStatus( "Checking existence of report processor " + submitURL + "....");
  oHttp.send( null );
  }
  catch (e)
  {
  }
}

function submitOnlyIfUrlActiveCallback()
{
  if ( oHttp.readyState == 4 )
  {

    if ( oHttp.status == 200 || window.location.href.indexOf("http")==-1)
    {
            //alert('oHttp.readyState is '+oHttp.readyState);
    }
    else
    {
      if (oHttp.status == 404)
      {
        setStatus( submitURL + " Not Found");
      }
      else
      {
        setStatus("Error: " + oHttp.status );
      }
    }
  }
}

function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i]);
   }
   catch(e){
    //suppress error
    alert('error');
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
 {
  return new XMLHttpRequest();
 }
 else
 {
  return false;
 }
}


function FileExists(strURL)
{
//** Following 1 line HyperWrite ***********
    var fe = false;
    oHttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); 
    oHttp.open("HEAD", strURL, false);
    try {
        oHttp.send( null );
    }
    catch (e)
    {
    }
// HyperWrite: ALL OF THIS
    if(oHttp.responseText.length == 0)  {
        if(oHttp.status!=200 || window.location.href.indexOf("http")==-1)   {
            fe=false;
        }
        else {
            fe=true;
        }
    }
    else {
        fe=true;
    }
    return fe;
// OR
//    return oHttp.responseText.length == 0 ? false : true;
}

function hideTabIndividual(htFrag,j) {
  var htHref = document.location.href;
  var htRe = /_\w.htm/;
  var htHref2 = htHref.replace(htRe, htFrag);
  // if the URL goes to an anchor, (i.e. has a # in it) then strip out everything after the #. Thus u will avoid making a hash of the 3 tab system.
  var patt1=new RegExp("#.+");
  var htHref2 = htHref2.replace(patt1, "");
  if (window.ActiveXObject)   { //IE
      submitURL=htHref2;
      submitOnlyIfUrlActive();
         //alert('oHttp.readyState is '+oHttp.readyState);
      if (oHttp.readyState !== 4)
      {
        // if htHref2 does not exist as a file then hide the tab


	// HyperWrite : following line no longer required


        //tabs[j].className ='hidden';
      }
      else
      {
        if (oHttp.status==200 || window.location.href.indexOf("http")==-1)  {
            if(document.location.href.indexOf(htFrag)!=-1)    {
                tabs[j].className='activeselected';
            }
            else    {
                tabs[j].className='deselected';
            }
        }
      }
    }
  else  {
      if(FileExists(htHref2)) {
        if(document.location.href.indexOf(htFrag)!=-1)    {
            tabs[j].className='activeselected';
        }
        else    {
            tabs[j].className='deselected';
        }
        }  
        else{
            tabs[j].className='hidden';
        }
  }
}


function stripChar(str)
{
charToRemove = '"';

regExp = new RegExp("["+charToRemove+"]","g");

return str.replace(regExp,"");

}