//===================================================
// PageScripts.js
//===================================================

NN4 = ((parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<5)&&(navigator.appName.indexOf("Netscape")!=-1))? 1:0;
NN6 = ((parseInt(navigator.appVersion)>=5)&&(navigator.appName.indexOf("Netscape")!=-1))? 1:0;
MS4 = ((parseInt(navigator.appVersion)>=4)&&(navigator.appName.indexOf("Microsoft")!=-1))? 1:0;

// Called only programaticly by page developer as needed
function showCurrentPage()
{
    if( (typeof isPageValid == "function") && (!isPageValid("show")) )
    {
        return;
    }
    document.forms[0].nextState.value="show";
    document.forms[0].submit();
}

function syncTabUsingPageId(pageid)
{
   syncTabUsingPageIdTries=0;
   syncTabUsingPageIdImpl(pageid);
}

function syncTabUsingPageIdImpl(pageid)
{
   syncTabUsingPageIdTries++;
   if(parent.bookHeader.isLoaded==true)
   {
      syncTab(parent.bookHeader.pageIndiciesByPageId[pageid]);
   }
   else if(syncTabUsingPageIdTries<15)
   {
      setTimeout("syncTabUsingPageIdImpl("+pageid+");", 200);
   }
}


// Called by page in BookVars.inc
function syncTab(pageid)
{
   syncTabTries=0;
   syncTabImpl(pageid);
}

function syncTabImpl(pageid)
{
   syncTabTries++;
   if(parent.bookHeader.isLoaded==true)
   {
      parent.bookHeader.syncTab(pageid);
      parent.bookHeader.showHelpButton(document.forms[0].helpfile);
   }
   else if(syncTabTries<15)
   {
      setTimeout("syncTabImpl("+pageid+");", 200);
   }
}

// Convience methods for developers using EDAS
function getValueFromXml(str)
{
   s = str.indexOf("<value>");
   e = str.indexOf("</value>");
   if((s!=-1) && (e!=-1))
   {
      return xmlDecode(str.substring(s+7, e));
   }

   return "";
}

function toXmlString(value, mode)
{
   var modeStr = (mode? " mode='" + mode + "' " : "");
   var valStr  = (value && value.length>0 ? "<value>" + xmlEncode(value) + "</value>" : "");
   return "<attribute"+modeStr+">"+valStr+"</attribute>";
}

// exactly simulates user pressing apply button
function applyPressed()
{
   parent.bookHeader.apply();
}

// exactly simulates user pressing ok button
function okPressed()
{
   parent.bookHeader.ok();
}

function getCache()
{
   return parent.sharedPageData;
}