/* Determine browser. */

var isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
var isMinIE4 = (document.all) ? 1 : 0;
var isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("MSIE 5.") >= 0 || isMinIE4 && navigator.appVersion.indexOf("MSIE 6.") >= 0 ) ? 1 : 0;
var isMinIE6 = (isMinIE5&&navigator.appVersion.indexOf("MSIE 5.5") >= 0 || isMinIE5&&navigator.appVersion.indexOf("MSIE 6.") >= 0 ) ? 1 : 0;

/* page and window properties  */
function getWindowWidth() {
   
   if (isMinNS4)
      return window.innerWidth;
   if (isMinIE4)
      return document.body.clientWidth;
   return -1;
}

function getWindowHeight() {
   
   if (isMinNS4)
      return window.innerHeight;
   if (isMinIE4)
      return document.body.clientHeight;
   return -1;
}

function getPageWidth() {
   
   if (isMinNS4)
      return document.width;
   if (isMinIE4)
      return document.body.scrollWidth;
   return -1;
}

function getPageHeight() {
   
   if (isMinNS4)
      return document.height;
   if (isMinIE4)
      return document.body.scrollHeight;
   return -1;
}

function moveLayerTo(layer, x, y) {
   
   if (isMinNS4)
      layer.moveTo(x, y);
   if (isMinIE4) {
      layer.style.left = x;
      layer.style.top  = y;
   }
}


/* Macromedia image & window resize handlers */
function MM_preloadImages() { //v3.0
   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
      var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
   }

function MM_swapImgRestore() { //v3.0
   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
   }

function MM_findObj(n, d) { //v4.0
   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
   d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
   if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
   if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
   document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
   else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

/* window opener */
function defaultWindowFeatures( width, height, left, top ) {
   return "screenX=" + left + ",left=" + left + ",screenY=" + top + ",top=" + top
   + ",innerWidth=" + width + ",width=" + width + ",innerHeight=" + height + ",height=" + height
   + ",menubar=no,directories=no,location=no,resizable=yes, status=no,titlebar=yes,toolbar=no";
}

function OpenWin( formname ) {
   var url =  formname;
   var newwindow;
   newwindow = window.open(url, "newPage", defaultWindowFeatures(660,330,165,65) + ",scrollbars=yes");
   //newwindow.location=url;
   newwindow.focus();
}


function writeMyMenu()  {
   var myTitle = new Array();
   var myPage = new Array();
   
   myTitle[0]='About&nbsp;Sierra';
   myPage[0]= 'About_Sierra.htm';
   
   myTitle[1]='AS\/400';
   myPage[1]= 'AS400_Core_Competency.htm';
   
   myTitle[2]='EAI';
   myPage[2]= 'EAI_Competency_Center.htm';
   
   myTitle[3]='Methodology';
   myPage[3]= 'Methodology.htm';
   
   if (isMinIE4)  {
      document.write('<div style=\"style="position: relative; top: 0; left:0 z-index: 10\">');
      document.write ('<table border=\"0\" cellpadding=1 cellspacing=3 width=\"100%\" height=\"30\" style=\"background-color: #000000\;\"><tr>');
      document.write ('<td class=cohead><a href="index.htm"><img src=\"images/sierraMenuLogo.gif\" border=0 alt=\"Sierra Computer Group\"></a><\/td>');
      
      for (i=0; i<myTitle.length; i++)  {
         document.write ('<td class=mbOff width=\"60\" onmouseover="this.className=\'mbOn\'\;\"  onmouseout=\"this.className=\'mbOff\';\" ');
         document.write ('onclick =\"window.location=\''+myPage[i]+'\'\;\">'+myTitle[i]+'</td>');
      }
      document.write('<\/tr><\/table>');
      document.write('<\/div>');
      
   }
   else {
      document.write('<table border="0" cellpadding="0" width="100%" cellspacing="0" bgcolor="#000000" height="32"><tr><td width=105>');
      document.write('<a href="index.htm"><img border="0" src="images/sierraMenuLogo.gif" width="101" height="24"><\/a><\/td><td><p align="right">');
      document.write('<a href="'+myPage[0]+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'menu00\',\'\',\'images/btnAbout_over.gif\',1)">');
      document.write('<img name=menu00 border="0" src="images/btnAbout_out.gif" width="69" height="26"><\/a>');
      document.write('<a href="'+myPage[1]+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'menu01\',\'\',\'images/btnAS400_over.gif\',1)">');
      document.write('<img  name=menu01 border="0" src="images/btnAS400_out.gif" width="66" height="26"><\/a>');
      document.write('<a href="'+myPage[2]+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'menu02\',\'\',\'images/btnEAI_over.gif\',1)">');
      document.write('<img name=menu02  border="0" src="images/btnEAI_out.gif" width="66" height="26"><\/a>');
      document.write('<a href="'+myPage[3]+'" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'menu03\',\'\',\'images/btnMethod_over.gif\',1)">');
      document.write('<img  name=menu03 border="0" src="images/btnMethod_out.gif" width="71" height="26"><\/a>');
      document.write('&nbsp\;<\/p><\/td><\/tr><\/table>');
      
   }
}


function placeIcon(t, l) {
   var spotTop = (t==null) ? 220 : t ;
   var spotLft = (l==null) ? 450 : l;
   if (isMinIE4){
      document.write('<img id="sierraIcon" src=\"images/sierraIconTrans.gif\" width=200 height=210 align=center style=\"position:absolute;top:'+spotTop+'; left:'+spotLft+';z-index:3\">');
      //		document.write('<hr align="left" width=100%  noshade size="3" color="#C1E2B1">')
      return;
   }
   
   //	if (isMinNS4)
   //	{
      //	document.write('<layer id="sierraIconLayer" position=absolute top='+spotTop+'  left='+spotLft+' z-index=3><Img src=\"images/sierraIconTrans.gif\" width=200 height=210\"></layer>');
      //	return;
   //	}
   else return;
}

/* display the inner-page (or document) title as  background */

function setBackground(bkgdText,t,l) {
   if (isMinIE4){
      var spotTop = (t==null) ? 250 : t ;
      var spotLft = (l==null) ? 160 : l;
      if (bkgdText==null) bkgdText=document.title;
      //		var showText= new String(bkgdText);
      if (document.all['bkgdtitle']) 	document.all['bkgdtitle'].innerHTML = bkgdText;
      else document.write('<p id=bkgdtitle class=bkgdtitle style=\"position:absolute;  left:'+spotLft+'; top:'+spotTop+';  z-index:5;display:\">'+bkgdText+'<\/p>');
      return;
   }
}



function beginBodyTable() {
   
   if (isMinIE4)  {
      document.write('<table  border=0 cellpadding=0 width=100% cellspacing=0 style=\"position:relative; z-index: 10\"><tr><td>');
      return;
   }
   
   //	if (isMinNS4) {
      //		document.write('<layer id="bodyTableLayer" position=absolute left=10 top=65  z-index=10>');
      //		return;
   //		}
   //	else return;
}

function endBodyTable() {
   if (isMinIE4) {
      document.write('</td></tr></table>');
      return;
   }
   
   //	if (isMinNS4) {
      //		document.write('</layer>');
      //		return;
   //		}
   else return;
}

function nsAddTitle(altTitle, ieToo) {
   if (isMinIE4 && ieToo==null)  return false;
   else{
      if (altTitle==null) altTitle=document.title;
      if (isMinIE4) document.write('<h1>'+altTitle+'<\/h1>');
      else document.write('<h1 class=nsAddTitle>'+altTitle+'<\/h1>');
   }
   return true;
   
}

function sidebarHead(h,l) {
   var headLabel = (h != null) ? h : 'Sierra';
   var linkBegin = (l !=null) ? '<a class=\"seclink\" href=\"'+l+'\">' : '';
   var linkEnd =  (l !=null) ? '</a>' : '';
   
   document.write('<table border=\"0\" height=\"18\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">');
   document.write('<tr><td class=\"sidebarhead\">'+linkBegin+headLabel+linkEnd);
   document.write('</td></tr></table>');
}


function colBreak(w,h) {
   var curFile = new String(document.URL);
   var colWidth = (w!=null) ? 'width=\"' + w +'\"' : 'width=\"300\"';
   var colHeight = (h!=null) ? 'height=\"'+ h + '\"' : '';
   
   if (curFile.indexOf('_content')==-1) document.write('<\/td><td rowspan="2" '+colWidth+' '+colHeight+'\" valign=\"top\" align="left">');
   
}


/* remove underscores for display */
function showText(anyString){
   var fixString = new String(anyString);
   while (fixString.indexOf('_',0)>0) fixString=fixString.replace('_',' ');
   return fixString;
}



function aBlk(){
   document.write('xx');
}






/* SuperPage development */

/* write the "sibling" menu from  inner-page titles */
function writeMenu() {
   document.write('<\/div>');
   document.write('<span id=pagemenu style=\"position:absolute; left:10; top:100; width:90px;  z-index:10;\" >');
   document.write('<p id=pagemenuhead class=sidebarhead>'+document.title+'<\/p>');
   var allDivs = document.all.tags("div");
   for (i=0; i<allDivs.length; i++) {
      if (allDivs[i].id!="") {
         var dispLink = showText(allDivs[i].id);
         document.write('<p class=sidebarmenu><a href=\"javascript:showMePage(\''+allDivs[i].id+'\')\">'+dispLink+'</a></p>');
         
      }
   }
   document.write('<\/span>');
   
}

/* alternate verison of writeMenu to show current selection  (development) */
function writeMenuTwo() {
   if (document.all['pagemenu']) document.all['pagemenu'].innerHTML="";
   else writeMenu();return false;
   
   //	else {document.write('<span id=pagemenu style=\"position:absolute; left:10; top:100; width:90px; background-color:#ffffff z-index:10;\" >');
   //	        var endTag=1;}
   
   document.write('<p id=pagemenuhead class=sidebarhead>'+document.title+'<\/p>');
   var allDivs = document.all.tags("div");
   for (i=0; i<allDivs.length; i++) {
      if (allDivs[i].id!="") {
         var myID = allDivs[i].id;
         document.write('<p class=sidebarmenu><a href=\"javascript:showMePage(\''+myID+'\')\">'+myID+'</a></p>');
         
      }
   }
   if (endTag==1) document.write('<\/span>');
   
   
}



/* display the first inner-page*/
function showFirstPage() {
   var allPages=document.all.tags("div");
   allPages[0].style.visibility = 'visible';	//show first page
   
   return;
}

/*display inner-page page from internal lnk*/
function showMePage(myPage) {
   clearSlate();
   pageStyle=document.all[myPage].style;
   pageStyle.visibility='visible';
   pageStyleID=document.all[myPage].id
   setBackground(pageStyleID);
   //writeMenu();
}

/*display inner-page page from external lnk*/
function getPageCalled() {
   whichPage = new String(window.location.hash).replace('#','');
   if (whichPage !=""){
      clearSlate();
      pageStyle=document.all[whichPage].style;
      pageStyle.visibility='visible';
      
      //writeMenu();
   }
   
}

/* convert standard text link into call to showMePage() */
/* used in "onclick" event handler; reads link ID       */
/* attribute to jump to another super-page              */
function ieLink() {
   if (document.all) {
      
      var innerPage= new String(document.activeElement.href); // read link to convert
      if (innerPage.substr(0,4)=='java') return false; // if already converted, quit
         numChars = innerPage.length;
      var slash = '\/';
      if (innerPage.indexOf('\/',7) == -1)  var slash='\\'; // check if on disk or server
         var startPos = parseFloat(innerPage.lastIndexOf(slash,numChars))+1;
      var endPos = parseFloat(innerPage.lastIndexOf(".",numChars));
      var myService = innerPage.substring(0,startPos); // parse server name
      innerPage = innerPage.substring(startPos,endPos); // parse path
      if (document.activeElement.id=="")  {             // if is an inner-page in this super-page, show it
         document.activeElement.href='javascript:showMePage(\''+innerPage+'\');';
         return true;
      }
      
      else sectionPage=document.activeElement.id+'.htm';  // otherwise, a different super-page...
         
      //    window.alert(myService+sectionPage+'#'+innerPage+'.htm'); //debug
      document.activeElement.href=myService+sectionPage+'#'+innerPage; // jump to the new super-page
      
      return true;
   }
   else return false;
}


/* first inner-page delimiter; displays 1st page if no inner-page specified*/
function beginPages(myName){
   document.write('<div id=\"'+myName+'\" style=\"position:absolute; left:150; top:100; width:450px;  z-index:7; visibility:visible\" >');
   
}
/* delimiters for other pages */
function createPages(myName) {
   document.write('<\/div>');
   document.write('<div id=\"'+myName+'\" style=\"position:absolute; left:150; top:100; width:450px;  z-index:7; visibility: hidden\" >');
}

/* hide all inner-pages */
function clearSlate() {
   var allDivs =document.all.tags("div");
   for (i=0; i<allDivs.length; i++)  allDivs[i].style.visibility = "hidden";
   return
}


