var iniFlag=false;
var prgFlag=false;
var imgFlag=false;
var winFlag=false;
var datFlag=false;
var msgFlag=false;
var selFlag=true;
var dlyFlag=false;
var visited=false;
var idxFlag=false;
var regSet=false;
var scrnFit=true;
var capTog=true;
var navTog=true;
var c=Math.pow(2,8);
var mag=0;
var vuMode=-1;
var udMode=0;
var lumLev=10;
var opaci=1;
var rotat=0;
var mirro=0;
var grays=0;
var inver=0;
var negat=0;
var oldMs=0;
var begMs=0;
var kbpMs=0;
var slideNow=0;
var imgCount=0;
var srcIdx=0;
var pad1=0;
var pad2=0;
var lastChances=3;
var remSec=0;
var maxSec=10;
var citSec=15;
var fontMaxSize=20;
var crtW=792;
var thmW=132;
var imageWidth=0;
var imageHeight=0;
var capWidth=0;
var capPadding=10;
var capSize=14;
var imgBorderW=6;
var imgBorderH=10;
var borderW=12;
var borderH=12;
var butW=20;
var progWinW=240; 
var progWinH=175;
var idxW=200;
var navH=24;
var oldBGC="#000000"
var oldFGC="#FFFFFF"
var oldObj=null;
var URLwin=null;
var prgWin=null;
var str$='';
var df$='unSpecified Error';
var image$='';
var label$='';
var style$='';
var mode$="default mode$";
var winParm=''
var winName='Sophisto';
var docTitle='Default Document Title';
var idxTitle='Default Index Title';
var sel='image size';
var hideIdx$='<div onclick=\"togIdx();\" style=\"position:relative;float:right;font:8pt;cursor:hand;\">idx</div>';
var showIdx$='<div id=\"showIdx\" style=\"position:relative;float:center;font:8pt;display:none;\">idx</div>';
var pageHead='<font class=pt12>Default</font><br>Page Head';
var pageTitle='<div>'+pageHead+'</div>';
var pageImg='<img src=\"image/default.jpg\">';
var pageSig='by <br>Default Signature';
var progMsg$='default progress message';
var statMsg='default status message';
var nowStat='default nowStat message';
var advise$='default advise message';
var rev$='Sophisto 20';
var cpyr$='<div class=\"cpyrt\"><hr>'+rev$+' Copyright &#169; 2001-2004 Philip Margush. All rights reserved<br>';
cpyr$+='<a class=\"nonImgI\" href=\"javascript:winURL(\'abtsopis.htm\',\'About '+rev$+' \')\">About '+rev$+'</a><hr></div>';
var bordeSpec$='frameborder=\"no\" border=\"0\"';
var frameSpec$='src=\"about:blank\" '+bordeSpec$; 

str$= '<select disabled id=\"imgProcSel\" name=\"imgProcSel\" onChange=\"doImgProc(parent.oSlideImg,this.options[this.selectedIndex].value)\">';
str$+='<option value=\"7\">rot 270';
str$+='<option value=\"6\">rot 180';
str$+='<option value=\"5\"> rot 90';
str$+='<option value=\"4\"> mirror';
str$+='<option value=\"3\">negative';
str$+='<option value=\"2\"> invert';
str$+='<option value=\"1\">   gray';
str$+='<option value=\"0\" selected>desktop';
str$+='<option value=\"-1\">normal';
str$+='<option value=\"-2\">magnify';
str$+='<option value=\"10\">reset';
str$+='</select>';

str$+='<select disabled id=\"imgModeSel\" name=\"imgModeSel\" onChange=\"selMode(this.options[this.selectedIndex].value)\">';
str$+='<option value=\"3\">luminan';
str$+='<option value=\"2\">timer';
str$+='<option value=\"1\">m zoom';
str$+='<option value=\"0\" selected>fwd/rev';
str$+='<option value=\"-1\">reset';
str$+='</select>';

var msg$="unexpected error";
var up$='<input disabled class=\"dir\" id=\"upBut\" title=\"up\" type=\"button\" value=\"up\" onclick=\"doUpDn(oSlideImg,\'up\');\">';
var dn$='<input disabled class=\"dir\" id=\"dnBut\" title=\"down\" type=\"button\" value=\"dn\" onclick=\"doUpDn(oSlideImg,\'dn\');\">';
var thm$='<input disabled class=\"tog\" id=\"tgBut\" title=\"thumb nail images\" type=\"button\" value=\"*\" onclick=\"togThm();\">';
var selBox=str$+dn$+up$+thm$;

var navBar='<div class=nav><a href=\"javascript:getURL(1, \'indexMAN.htm#DOCTOP\')\">Main Index</a><a href=\"http://www.margush.com\" >National</a><a href=\"javascript:getURL(5, \'smdr\')\">Guestbook</a><a HREF=\"mailto:pmargush@voicenet.com\">Write</a></div><div class=cpyrgt>Copyright &#169; 2002 Philip Margush. All Rights Reserved</div>';
var pageMeta='<meta name="author" content="Philip Margush"><meta name="resource-type" content="document">';
var but$='<a class=but href=javascript:dispImg(\'up\');>next</a><br><a class=but href=javascript:dispImg(\'dn\');>prev</a>';

var filePath='image/';
var version="7/27/03 12:19:07 PM";
document.loaded=new Object; 
document.loaded.flag=false;

function getSrc(idx){
var i, j, n, s;
with (document) {
  i=hiByte(idxIdxA[idx]);
  j=loByte(idxIdxA[idx]);
  n=aCapt(mapZoneA[i][j]);if (n=='unfound'||n==null){n=0}
  s=baseURLA[n]+aFile(mapZoneA[i][j]);
}
return s;
}

function togIdx() {
if (idxFlag) {
  showIdx.style.display='block'
  aWinNum.style.cursor='hand';
  aWinNum.style.borderColor='blue';
  aWinNum.onclick=togIdx;
  rDiv.style.left="0px";  
  rDiv.style.width=mDiv.style.width;
  tgBut.title="thumb nail images";
  navTog=false;
  nDiv.style.zIndex=1;
  }
  //alert(rDiv.style.width+' '+mDiv.style.width+' '+rDiv.style.paddingTop)
else {
  if (document.all.showIdx!=null){
  showIdx.style.display='none';
  aWinNum.style.cursor="default";
  aWinNum.onclick=null;
  aWinNum.style.borderColor='pink';
  }
  rDiv.style.width=mDiv.style.pixelWidth-lDiv.style.pixelWidth;
  rDiv.style.left=lDiv.style.width;
  navTog=true;
  }
idxFlag=!idxFlag;
setNav();
if (document.all.iViewFrm!=null) {document.all.iViewFrm.width=rDiv.style.width;}
if (document.all.oSlideImg!=null) {doResize()}
}

function getKey() {
//capArea.innerHTML=event.keyCode.toString().fontcolor('red')+' = '+String.fromCharCode(event.keyCode);
//alert(event.keyCode.toString().fontcolor('red')+' = '+String.fromCharCode(event.keyCode));
//alert(event.keyCode)
switch (event.keyCode) {
  case 85: displaySlide('up');break;
  case 68: displaySlide('dn');break;
  //default:alert(naviFrame.event.keyCode);break;
}
}

function makeNoLoad(inA) {
var s='<br><table style=\"font-size:8pt;background:#cccccc;\">';
  for (i=0;i<inA.length;i++) {      
      s+='<tr><td align=right>' +String(i)+ '.</td>';
      s+='<td align=left>' +getSrc(inA[i])+ '</td></tr>'; }
  s+='</table>';
return s
}

function progress(iName,totImg,nowImg,remain,speed,graph) {
  this.iName=iName
  this.totImg=totImg
  this.nowImg=nowImg
  this.remain=remain
  this.speed=speed
  this.graph=graph   
}

function doReport(status){
 if (imgFlag&&(document.readyState=='complete')){window.status=status}
}

function doProgWin(obj,inStr) {
winParm=makeWinParm(progWinW,progWinH,'no','no','no','no','yes')
//alert('clientHeight='+document.body.clientHeight+' top='+x+ ' clientWidth='+document.body.clientWidth+ ' left='+y+ ' s=' +winParm )
str$='<div class=\"label\">images<br><font id=\"totRpt\">' +document.imgArray.length+ '</font><br>total</div>';
str$+='<div class=\"label\">images<br><font id=\"cntRpt\">' +imgCount+ '</font><br>loaded</div>';
str$+='<div class=\"label\">retrys<br><font id=\"labRpt\">' +remSec+ '</font><br>remain</div>';
str$+='<div class=\"label\">average<br><font id=\"spdRpt\">' +kbpMs+ '</font><br>speed</div>';
str$+='<br clear=all>';
str$+='<div id=\"bar\"><div id=\"plot\"></div></div><br clear=all>';
str$+='<div id=\"advise\">' +advise$+ '</div>';

  prgWin=window.open("","TheProgressWin",winParm);
  //alert(typeof(prgWin));
  //alert(prgWin.document.body.clientWidth)
  prgWin.document.open();//open text stream 
  prgWin.title='Progress';
  prgWin.window.status='Loading Images';
  prgWin.document.write('<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">');
  prgWin.document.write('<html><head>'+getScpt(1, styleGlobe)+'</head><body id=\"progWin\">');
  prgWin.document.write('<div id=\"reptMsg\"><img id=\"progImg\" src=\"image/downloa3.gif\">' +str$+ '</div>');
  prgWin.document.write('<span id=\"progMsg\">' +inStr+ '</span>');  
  prgWin.document.write('</body></html>');    
return true
}

function layout$(x){
if (x) {return ' portrait';}
return ' landscape';
}

function aCapt(s) {
if (s==null) {s='';}
var i=s.indexOf(" ")+1;
if (!i) {s='unfound!'}
return s.substring(i);
}

function exitProc(winName) {
//alert(winName+ ' '+prgFlag)
if (URLwin!=null){URLwin.close()};
if ((msgFlag)&&(!msgWin.closed)){msgWin.close()};
if ((prgFlag)&&(!prgWin.closed)){prgWin.close()};
}

function selMode(d){
  udMode=parseInt(d);
  if (udMode==2){
    togSCT()}
  else if (udMode<0) {
   mag=0;
   lumLev=10;
   clearInterval(cgImgT);cgImgT=0;}
}

function doUpDn(o,dir) {
//alert(udMode +' '+dir)
switch (udMode) {
  case 1: if (dir=='dn'&&mag>-9) {mag--;} else if (dir=='up'&&mag<19){mag++;};doResize();break;
  case 2: clearInterval(cgImgT);cgImgT=0;
          window.status='Timer: '+citSec;
          if (dir=='dn'&&citSec>1) {citSec--;} else if (dir=='up'&&citSec<120){citSec++;};togSCT();break;
  case 3: if (dir=='dn'&&lumLev>0) {lumLev--;} else if (dir=='up'&&lumLev<10){lumLev++;};
          window.status='Luminance: '+lumLev;
          doImgProc(o,'8');break;
  default:    
    //window.status=document.title + ': ' +o.src+ ' resize: ' +o.width+ 'x' +o.height;
    displaySlide(dir);
    break;}
rDiv.focus();
}

function doImgProc(o,m) {
vuMode=m;
//alert(vuMode)
switch (vuMode) {
  case '-2': scrnFit=false;mag=10;break;
  case '-1': scrnFit=false;mag=0;break;
  case '0': scrnFit=true;mag=0;break;
  case '1': grays=1;break;
  case '2': inver=1;xrays=0;break;
  case '3': negat=1;inver=0;break;
  case '4': mirro=1;break
  case '5': rotat=1;break;
  case '6': rotat=2;break;
  case '7': rotat=3;break;
  case '8': opaci=(lumLev*.1);break;
  default:grays=0;inver=0;negat=0;mirro=0;rotat=0;opaci=1;lumLev=10;break;
}
if (o!=null&&vuMode>0) {
  str$='progid:DXImageTransform.Microsoft.BasicImage(Rotation='+rotat+',Mirror='+mirro+',Invert='+inver+',XRay='+negat+',Grayscale='+grays+',opacity='+opaci+')';
  o.style.filter=str$; }
else if (o!=null&&vuMode<1) {doResize()}
else {vuMode=-1;}
return vuMode;
}

var step=0;
var limit=0;
paci=0;
var fadeFlag=true;
function fadeImg(dir,pace){
if (fadeFlag) {
  step=(lumLev/10);
  limit=lumLev;
  paci=0;
  if (dir=='dn'){opaci=lumLev;limit=0};
  fadeFlag=false;
}
if (dir=='dn') {
  paci-=step; }
else{
  paci+=step;
}
//alert(step+' '+paci+' '+dir+' '+pace)
oSlideImg.style.filter='progid:DXImageTransform.Microsoft.BasicImage(opacity='+(paci*.1)+')';
if (paci!=limit) {setFadeTimer(dir,pace)}else{fadeFlag=true};
}

var cgImgT=0;
function cgImgTimer(pace) {
var mSec=(pace*1000);  
if (cgImgT){
    clearInterval(cgImgT);cgImgT=0;}
  else{
    cgImgT=setInterval("displaySlide('up');",mSec);
  }
}

function togSCT() {
cgImgTimer(citSec);
mDiv.focus();
}

function togVis(obj) {
var now = obj.style.display;
if (now=="inline") {now="\'none\'";}else{now="\'inline\'";}
obj.style.setExpression('display',now,'javascript');
window.status='Selected';
}

function doGlass(o,s){
 o.style.cursor='wait';
  window.status=s;
 return true;
}

function togThm() {
if (idxFlag) {
  with (document) for (i = 0 ; i < all.tags("div").length ; i++) {
    elem=all.tags("div").item(i);
    if (elem.className=="thmCell") {togVis(elem)} 
    }
  lDiv.focus()
}
else{
  alert(nDiv.currentStyle.visibility);
  doHide(nDiv);
}
}

function setIdx(obj,inClr){
 obj.style.listStyleType="disc";
 obj.style.color=inClr;
}

function setCap(){
if (capTog){doVisi(oCapDiv)}else{doHide(oCapDiv)};
}

function setNav(){
if (navTog){doVisi(nDiv)}else{doHide(nDiv)};
}

function doUL(obj){
   obj.style.textDecoration="underline";
}

function doHTML(o,s) {
  o.innerHTML=s;
}

function doVisited(obj){
   obj.style.color=visitClr;
   obj.style.listStyleType="disc";
}

function doHilight(obj){
  oldFGC=obj.style.color;
  oldBGC=obj.style.background; 
  if (oldObj!=null) {
     oldObj.style.color=oldFGC; 
     oldObj.style.background=oldBGC}; 
  obj.style.color=activFGC;
  obj.style.background=activBGC;
  oldObj=obj;
}

var oReVisit=/\d/gi;
function doVisit(i) {
visited=false;
//alert(obj.style.color)
//obj.style.background="salmon";
//alert(obj.style.color)
//obj.style.background="transparent";
//slideNow=obj.id.substr(obj.id.search(oReVisit))
visited=displaySlide(i);
}

function nowMsec() {
d = new Date();    
return d.getTime();
}

function getMsec(inMs) {
return nowMsec()-inMs;
}

function elapSec(inMs) {
//alert((nowMsec()-inMs)/1000+' '+inMs )
return Math.round((nowMsec()-inMs)/1000);
}      

function doTimeout(inSec) {
d = new Date()    
var nowMsec=d.getTime();
var endMsec=nowMsec+(inSec*1000);
var remainder=endMsec-nowMsec;
while (remainder>0) {  
  d = new Date()    
  nowMsec=d.getTime()
  remainder=endMsec-nowMsec;
  //window.status='nowMsec: ' + nowMsec + ' endMsec: ' + endMsec + ' remainder: ' + remainder;  
}
return true;
}

var ckImgT;
function checkImgTimer(pace) {
var mSec=(pace*1000);  
  ckImgT=setInterval("checkImage();",mSec);
}

function getChronos() {
	var time = new Date();   
      var daySec=time.getTime();
	var month = time.getMonth();
	var day = time.getDate();
	var year = time.getYear();
	var hour = time.getHours();   
	var minute = time.getMinutes();   
	var second = time.getSeconds();
	return daySec+' '+month.toString()+day.toString()+year.toString()+hour.toString()+minute.toString()+second.toString();
}
var timeStamp=0;
var checkObject;
var checkSec=0;
var complT=0;

function chkCompl(o,pace){
clearTimeout(complT); 
checkSec=pace;
var nowStat=o.readyState;
//alert(checkObject.id+' '+nowStat)
if (!timeStamp){timeStamp=nowMsec()}
var nowSec=elapSec(timeStamp);
if (nowStat=='complete'||nowSec>maxSec) { 
  //doHide(statDiv);
  doVisi(o);  
  timeStamp=0;
  if (o.id=='iViewFrm') {statMsg+=' '+nowStat+ ' loadTime: '+nowSec+ ' seconds';}  
  window.status=statMsg; }
else  {    
  checkObject=o;
  if (timeStamp&&nowSec) {
  }
  complT=setTimeout("chkCompl(checkObject,checkSec)",pace*1000);
  }
return nowStat;
}

function setFadeTimer(o,dir,pace) {
var mSec=(pace*1000);  
//str$='\"fadeImg('+dir+','+pace+')\"';
  var x=setTimeout("fadeImg(\'up\',.1)",.1);
}

function loadImages() {
  var idx=0;
  var n=0; //inclusive cardinal; 
  var i=0; //image cardinal;
  var j=0; //already in imgArray at y;
  var x=0; //coordinate x;
  var y=0; //coordinate y;
  document.imgArray=new Array(); //preLoad img Array
  document.img2LdA=new Array(); //images to Load Array -- no dupes, deplete on complete;
  document.srcIdxA=new Array(); //index: list Items to preLoad img Array and html reference;
  document.idxIdxA=new Array(); //sequential index to idx sourceFile (2 8-bit bytes);
  document.datIdxA=new Array(); //sequential index to dat sourceFile (decimal);
  progMsg$='Preloading Media: '+mapZoneA.length+ ' zones!';
  with (document) {
    prgFlag=doProgWin(self,progMsg$);      
    for (x=0; x<mapZoneA.length; x++) {
      for (y=1; y<mapZoneA[x].length; y++) {
        df$=aFile(mapZoneA[x][y])
        datIdxA[n]=atIdx(imgList,df$); //looks-up caption and indexes it
        idxIdxA[n]=enCode(x,y); //stores coordinates in 2 8-bit bytes         
        var medType='image: ';
        if (isImage(df$)) {            
          var found=false;
          j=0;
          df$=getSrc(n);
          var fnRExp = new RegExp(df$, "i");          
          while (!found&&j<img2LdA.length){
            found=fnRExp.test(img2LdA[j++].src)
            //alert(img2LdA[j-1].src+' '+getSrc(n)+' '+(j-1)+' '+found)
          }
          j--; 
          //srcIdxA[n]=atIdx(img2LdA,n); //see if value of n is on already on list 
          if (!found){
            j=i;
            img2LdA[i]=n;// if not then store n at index x (x is less than n by dupes and htm)
            i++;  
          } else{alert('found:'+df$)}
          srcIdxA[n]=j;// also store x at index n or y if found already on list
        }else{
          srcIdxA[n]=n+1000;
          medType='nonImage: ';
        };
        doAdvise(medType,dec2hex(idxIdxA[n]),0);  
        n++;
        //alert((n-1)+df$+srcIdxA[n-1])        
      }
    }
  prgRpt=new progress('',img2LdA.length,'',remSec,kbpMs,'')
  }
//alert('img2LdA: ' +document.img2LdA+ ' idxIdxA: ' +document.idxIdxA); //line 620
//alert('imgArray: '+document.imgArray+' | img2LdA: '+document.img2LdA+' | srcIdxA: '+document.srcIdxA+' | idxIdxA: '+ document.idxIdxA+' | datIdxA: '+document.datIdxA);
if (document.img2LdA.length) {return true}else{return false}
}

function reCheckImage(){
offset=0;
while (offset<document.img2LdA.length){
  progMsg$='recovering: '+offset+'/'+document.img2LdA.length;
  window.status=progMsg$;
  checkImage();}
}

var checked=false;
var offset=0;
var curImg=0;
function checkImage() {
  with (document) {    
    curImg=srcIdxA[img2LdA[offset]]
    //alert(offset+' '+curImg+' '+img2LdA)
    if (imgArray[curImg]==null) {
      imgArray[curImg]=new Image;             
      imgArray[curImg].src=getSrc(img2LdA[offset]);      
      begMs=nowMsec();
      }
    remSec=maxSec-elapSec(begMs); 
    notify(curImg);     
    imgFlag=imgComplete(curImg)
    if(imgFlag||remSec<1){
      if (imgFlag) { 
        doAdvise('Complete:',prgRpt.iName+' ('+(maxSec-remSec)+')',0);          
        for (i=offset;i<img2LdA.length-1;i++){img2LdA[i]=img2LdA[i+1]};
        img2LdA.length=i; }
      else {doAdvise('Delayed:',prgRpt.iName,1);offset++;}
    } 
    //alert('img2LdA.length:' +img2LdA.length+' offset: '+offset)    
    if (offset>=img2LdA.length&&!checked){
      clearInterval(ckImgT); 
      checked=true;
      if (img2LdA.length){
        imgFlag=false;    
        reCheckImage();  
        for (i=0;i<img2LdA.length;i++){
          //alert(i+' '+img2LdA[i]+' '+img2LdA+' '+imgArray.length+' '+srcIdxA[img2LdA[i]]);          
          imgArray[srcIdxA[img2LdA[i]]].onreadystatechange=reCheckImage; 
        }    
        var fail$='Image Notification: '+i+' tagged for stateChange';        
        nowStat='time out'
        DispErr(fail$,this.url,makeNoLoad(img2LdA));
      }
      prgWin.close();
      prgFlag=false;
      doReport('images ready: '+imgFlag)
    }
  }
} 

function imgComplete(idx) {
  with (document) {
    nowStat=imgArray[idx].readyState;
    if (nowStat!='complete'){return false};
    var zone=all.item('zone'+hiByte(idxIdxA[idx]));    
    for (var i=0; i<srcIdxA.length; i++){
      if (srcIdxA[i]==idx){
        tSlide$='<img class=\"tImg\" src=\"' +imgArray[idx].src+ '\" width=\"' +thmW+ '\" ><br clear=\"all\">';
        setIdx(all.tags("li").item("item"+i),readyClr);
        doUL(all.tags("a").item("thm"+i));
        doHTML(all.tags("div").item("tSlide"+i),tSlide$)
        doHand(all.tags("a").item("thm"+i),'');
        }
    }    
    str$=prgRpt.iName;
    doAdvise('Complete:',str$,0);          
    return true; 
  } 
}

function htmComplete(idx) {
  with (document) {
    nowStat=imgArray[idx].readyState;
    if (nowStat!='complete'){return false};
    var zone=all.item('zone'+hiByte(idxIdxA[idx]));    
    for (var i=0; i<srcIdxA.length; i++){
      if (srcIdxA[i]==idx){
        tSlide$='<img class=\"tImg\" src=\"' +imgArray[idx].src+ '\" width=\"' +thmW+ '\" ><br clear=\"all\">';
        setIdx(all.tags("li").item("item"+i),readyClr);
        doUL(all.tags("a").item("thm"+i));
        doHTML(all.tags("div").item("tSlide"+i),tSlide$)
        doHand(all.tags("a").item("thm"+i),'');
        }
    }    
    str$=prgRpt.iName;
    doAdvise('Complete:',str$,0);          
    return true; 
  } 
}




function doAdvise(d,s,preEmt) {
window.status=d+' '+s; 
if (!prgFlag||prgWin.closed) return;
var adviseT;
if (preEmt>0) {
  var mSec=preEmt*1000;
  clearTimeout(adviseT)
  adviseT=setTimeout("dlyFlag=false",mSec);
  dlyFlag=true;
  //prgWin.focus();
}
if (preEmt>0||!dlyFlag){prgWin.advise.innerHTML='<div id=\"dAdvise\">'+d+'</div>'+s.substr(0,18)}

//.document.write('<div class=\"rptStat\">image '+i+' is still loading!</div>');

}

function notify(imgNum) {
  with (document) {
    var fileBytes=imgArray[imgNum].width*imgArray[imgNum].height;
    kbpMs+=(fileBytes/(getMsec(begMs)+1))/1000;
    prgRpt.speed=Math.round(kbpMs/(imgNum+1));    
    prgRpt.nowImg=prgRpt.totImg-img2LdA.length;
    prgRpt.remain=remSec;
    prgRpt.iName=justFS(imgArray[imgNum].src);   
    }

  with (document) if (prgFlag&&!prgWin.closed) {  
    prgWin.totRpt.innerText=prgRpt.totImg;
    prgWin.cntRpt.innerText=prgRpt.nowImg;
    prgWin.labRpt.innerText=prgRpt.remain;
    prgWin.spdRpt.innerText=prgRpt.speed; 
    prgWin.bar.style.width='100%';
    prgWin.plot.style.width=giraffe(prgRpt.nowImg,prgRpt.totImg,prgWin.bar.clientWidth);
//alert(prgWin.bar.style.pixelWidth+' '+prgWin.plot.style.width);   
doAdvise('Seeking:',prgRpt.iName,0); 
  }   
}

function init(){
doHide(lDiv,nDiv,rDiv);
document.title=docTitle; 
document.name=winName;

with (document.body) {
  scroll='no';
}
with (mDiv.style) {
  width=document.body.offsetWidth;
  height=document.body.offsetHeight;
  color="red";
  background=pageBGC;
}
with (lDiv.style) {
  //alert(mDiv.offsetWidth+' '+mDiv.offsetHeight+' '+mDiv.style.pixelHeight)
  width=idxW;
  height=mDiv.style.pixelHeight-navH;
  overflow="auto";
  color=indexFGC;
  background=indexBGC;
}
with (nDiv.style) {
  //alert(mDiv.offsetWidth+' '+mDiv.offsetHeight)
  top=lDiv.style.height;
  left=lDiv.style.left;
  width=lDiv.style.width;
  height=navH;
  overflow="auto";
  color="violet";
  background=indexBGC;
}
var rDivW=(mDiv.style.pixelWidth-idxW)+'px'
var rDivH=mDiv.style.height;
//document.all.rDiv.style.overflow = "scroll";
with (rDiv.style) {
  overflow="auto";
  padding=0;
  width=rDivW;
  height=rDivH;
  color=pageHeadFGC;
  backgroundColor="transparent";
}
if (!iniFlag){
 iniFlag=place();
}
}

function place() {
  if (document.loaded==null||(document.loaded!=null&&document.loaded.flag==false)){alert('indexFile: ' +idxFile+ ' not found!'); return;}
  var preFlag=false;
  str$=pageTitle;
  str$+='<div id=\"capArea\">'+cpyr$+'</div>';
  rDiv.innerHTML=str$;
  with (titleCell.style) {
    color=pageHeadFGC;
    background=pageHeadBGC; 
  }
  preFlag=loadImages();
  style$='ul.idxList li.idxItem, ul.idxList li.nonImgI{color:'+liDot+';}ul.idxList li.idxItem a, ul.idxList li.nonImgI a{color:'+liFGC+';}a.idxItem:hover, a.nonImgI:hover{color:'+liHover+';}';
  str$='<div id=\"idxPgHd\">' +idxTitle+hideIdx$+ '<hr></div><style>'+style$+'</style>';
  var x=0;
  var thisII='';
  with (document) for (var i=0; i<mapZoneA.length; i++) {
    var listId='idxBox'.concat(i);
    label$=mapZoneA[i][0]; 
    str$+='<div class=\"idxTerm\" onClick=\"parent.togVis(' +listId+ ');\" onMouseOver=\"parent.doHand(this,\'Category: '+escApost(label$)+'\')\">' +label$+ '</div>'
    str$+='<ul class=\"idxList\" id=\"' +listId+ '\">';
    for (j=1; j<mapZoneA[i].length; j++) {
      df$=aFile(mapZoneA[i][j]);        
      if (srcIdxA[x]<1000) {typII='idxItem';}else{typII='nonImgI';}
      tSlide$='<div class=\"thmCell\" id=\"tSlide'+x+'\"></div>'; 
      label$=aCapt(imgList[datIdxA[x]]);
      str$+='<li class=\"'+typII+'\" id=\"item' +x+ '\">';
      str$+='<a href=\"javascript:void()\" class=\"'+typII+'\" id=\"thm' +x+ '\" onClick=\"doVisit('+x+'); return false;\" onMouseOver=\"window.status=\'Source: ' +df$+ '\'; return true;\">';
      str$+=tSlide$;
      str$+=label$;
      str$+='</a></li>';
      x++;
    }
    str$+='</ul>';
  }
str$+=cpyr$;
lDiv.innerHTML=str$; 
with (document) for (i=0;i<srcIdxA.length;i++){
  if (srcIdxA[i]>=1000){setIdx(all.tags("li").item("item"+i),readyClr)};
}

  with (idxPgHd.style) {
    color=idxHdFGC;
    background="transparent"; 
  }

  with (document) for (i = 0 ; i < all.tags("div").length ; i++) {
    elem=all.tags("div").item(i);
    if (elem.className=="idxTerm") {
      with (elem.style) {
        fontWeight="bold";
        textDecoration="underline";
        lineHeight="150%";
      } 
    } else if (elem.className=="idxItem") {
      with (elem.style) {
        color="tan";
      } 
    }
}
nDiv.innerHTML=selBox;
upBut.disabled=false;
dnBut.disabled=false;
tgBut.disabled=false;
document.onkeydown=getKey;
togIdx();
doVisi(lDiv,rDiv);
if (preFlag) {begMs=nowMsec();checkImgTimer(.1);}else if (prgWin!=null){prgWin.close();prgFlag=false;}
return preFlag;
}

function getDiv(){
str$='<div id="\oSlideDiv\">';
str$+='<img id=\"oSlideImg\">';
str$+='<div id=\"aWinNum\">#</div>';
str$+='</div>';
str$+='<div id=\"oCapDiv\">';
str$+='<div id=\"capBgDiv\">capBgDiv</div>';
str$+='<div id=\"capFgDiv\">capFgDiv</div>';
str$+='<div class=\"cred8\" id=\"creDiv\"></div>';
str$+='<div class=\"cpyrt\" id=\"cpyDiv\"></div>';
str$+='</div>';
str$+='<div id=\"oTaskBar\">taskBar</div>';
//str$+='<div id=\"oInfoDiv\">oInfoDiv</div>';
return str$;
}

function getFrame(inURL){
statMsg=inURL + ': ';
str$=bordeSpec$;
str$+=' width='+rDiv.style.width;
str$+=' height='+rDiv.style.height;
str$+=' src='+inURL;
str$='<iframe id=\"iViewFrm\" scrolling=\"auto\" '+str$+'></iframe>'; 
style$='style=\"top:'+((rDiv.clientHeight/2)-10)+';left:'+((rDiv.clientWidth/2)-100)+'\"'
str$+='<div id=\"aWinNum\"></div>';
str$+='<div id=\"statDiv\" '+style$+ '></div>';
return str$;
}

function displaySlide(dir) {
var success=false;
if (dir=='up') {slideNow++}else if (dir=='dn'){slideNow--}else{slideNow=dir};
if (slideNow==document.srcIdxA.length){slideNow=0}
if (slideNow==-1){slideNow=document.srcIdxA.length-1}
doHilight(document.all.item("thm"+slideNow));
doVisited(document.all.item("item"+slideNow));
var curObj=rDiv;
doHide(curObj);
//alert(curObj.id)
//alert(slideNow+' '+document.srcIdxA[slideNow])
clearTimeout(ckDocT)
waitMore=maxSec;
if (document.srcIdxA[slideNow]<1000){
  regSet=setReg(slideNow);
  success=regSet;
  imgModeSel.disabled=false;
  imgProcSel.disabled=false;
  doVisi(curObj);
  curObj=document.all.item('oSlideImg');
  //alert(curObj.id)
  }
else {
  imgModeSel.disabled=false;
  imgProcSel.disabled=true;
//alert(document.srcIdxA[slideNow]+' '+slideNow)
  var fileSpec=getSrc(slideNow);
  if(justFE(fileSpec)=='nul') {
    fileSpec='sophinul.htm';
    }
  else if (justFN(fileSpec)=='sophitmp'){    
  }; 
  curObj.innerHTML=getFrame(fileSpec);
//  curObj.innerHTML=getFrame(getSrc(document.srcIdxA[slideNow]-1000));
  doVisi(curObj);
  curObj=document.all.item('iViewFrm');
  tmpObj=null;
  checkDoc(curObj);   
  success=true;
  //alert(curObj.id)
  }

if (!success) {return false}
str$=String(slideNow)+showIdx$
aWinNum.innerHTML=str$;
chkCompl(curObj,.1);

//if (!idxFlag){
  //showIdx.style.display='block'
  //aWinNum.style.cursor='hand';
  //aWinNum.style.borderColor='blue';
  //aWinNum.onclick=togIdx;
//  }  
//else {
  //showIdx.style.display='none';
  //aWinNum.style.cursor="default";
  //aWinNum.onclick=null;
  //aWinNum.style.borderColor='pink';
//}
//return success;
}

function doResize(){
if (regSet) {setReg(slideNow)}
}

function setReg(idx){
var srcIdx=document.srcIdxA[idx];
var capIdx=document.datIdxA[idx]+1;
var crdIdx=capIdx+1;
var portrait=true;
if (document.imgArray[srcIdx]==null||!document.imgArray[srcIdx].complete) {return false}
if (document.all.item('oSlideImg')==null){rDiv.innerHTML=getDiv();}
//doHide(oSlideImg)
oSlideImg.src=document.imgArray[srcIdx].src
//alert('oSlideImg.complete:'+oSlideImg.complete+' srcIdx:'+srcIdx+' capIdx:'+capIdx );
imageWidth=document.imgArray[srcIdx].width;
imageHeight=document.imgArray[srcIdx].height;
var success=doOther(capIdx,crdIdx);
if (imageWidth>imageHeight){portrait=false}
statMsg=justFS(oSlideImg.src)+ mode$+layout$(portrait);
window.status=statMsg;
//alert(statMsg)
return success;
}

function doOther(capIdx,crdIdx) {
  var avaW=rDiv.offsetWidth;
  var avaH=rDiv.offsetHeight;
  var imgW=imageWidth;
  var imgH=imageHeight;
  var imageW=avaW;
  var imageH=avaH;
  var rF=imageW/imgW;
  var yF=imageH/imgH;
  if (yF<rF){rF=yF;};
  if (scrnFit){mode$='desktop: '}else{rF=1;mode$='normal: '}
  //alert(mag+' '+scrnFit+' '+slideNow+' '+rF)
  imgW=Math.round(imgW*rF*(mag/10+1));
  imgH=Math.round(imgH*rF*(mag/10+1)); 
  if(mag>0){
    mode$+='enlarge'}
  else if (mag<0){
    mode$+='reduce'}
  else{
    mode$+='size'};
  mode$=' '+ mode$+' '+String(Math.round(mag*10+100))+'%: '+imgW+'px X '+imgH+'px';
  //alert('scrnFit:'+scrnFit+' avaW:'+avaW+' avaH:'+avaH+' '+oSlideImg.id+'.width:'+oSlideImg.width+' '+oSlideImg.id+'.height:'+oSlideImg.height) 
  with (oSlideImg.style) {
    width=imgW+'px';
    height=imgH+'px';
  }
  with (oSlideDiv.style) {
    width=oSlideImg.style.width;
    height=oSlideImg.style.height;
  }
  var slideBot=oSlideDiv.offsetTop+oSlideDiv.offsetHeight;
  var cSize=1;
  var pad=0;
  oSlideDiv.style.marginTop=pad;
  with (capFgDiv.style) {
    height=0;
    width=oSlideDiv.offsetWidth*cSize;
    fontSize=capSize+'pt';
  }
  capFgDiv.innerHTML=imgList[capIdx];
  with (oCapDiv.style) {
    height=capFgDiv.offsetHeight;   
    if ((rDiv.offsetHeight-oSlideDiv.offsetHeight)<oCapDiv.offsetHeight) {
      cSize=.92
      capFgDiv.style.width=oSlideDiv.offsetWidth*cSize;
      left=oSlideDiv.offsetLeft+(oSlideDiv.offsetWidth/2)-(capFgDiv.offsetWidth/2);
      width=capFgDiv.offsetWidth;
      capBgDiv.filters.item("DXImageTransform.Microsoft.Alpha").opacity="30";
      //pad=rDiv.offsetHeight-oSlideImg.offsetHeight;
      top=(slideBot*.98)-capFgDiv.offsetHeight+pad;
      }
    else{
      left=oSlideDiv.offsetLeft;
      width=oSlideDiv.offsetWidth;
      capBgDiv.filters.item("DXImageTransform.Microsoft.Alpha").opacity="100";
      //pad=rDiv.offsetHeight-(slideBot+oCapDiv.offsetHeight);
      top=slideBot+pad;
    }
  }  
  with (capBgDiv.style) {
    width=capFgDiv.offsetWidth;
    height=capFgDiv.offsetHeight;
  }
  oSlideDiv.style.marginTop=pad;
  with (oCapDiv.style) {
  }
  with (oTaskBar.style) {
    top=lDiv.clientHeight-oTaskBar.offsetHeight;
    width=oSlideImg.style.width;
    //zIndex=4;
  }
//oInfoDiv.innerHTML=imgList[crdIdx];
//with (oInfoDiv.style) {
//  top=((rDiv.clientHeight/2)-(oInfoDiv.offsetHeight/2))+'px';
//  left=((rDiv.clientWidth/2)-(oInfoDiv.offsetWidth/2))+'px';
//}
//alert(rDiv.clientWidth/2+' '+oInfoDiv.offsetWidth/2+' '+oInfoDiv.style.top+' '+oInfoDiv.style.left)
//doVisi(oInfoDiv);
//alert(oInfoDiv.id)
setCap();
doVisi(oSlideDiv);
return true;
}

var ckDocT=0;
tmpObj=null;
function checkDoc(o){
    if (o!=null&&o!='') {tmpObj=o}else{o=tmpObj}
    nowStat=o.readyState;
    if (nowStat=='complete'){
      var curTit=window.parent.frames(o.id).document.title
      if (curTit=='SOPHISTO DOC'){ckDocT=setTimeout("checkDoc();",3000);}
    }
    else  {
      o.onreadystatechange=checkDoc;        
    }
    statDiv.innerText=curTit+' '+nowStat;
        //oSlideFrm.window.document.title
        //alert(window.document.frames(0).document.title);   
        //alert(window.parent.frames(0).document.title);   
        //window.parent.frames(0).document.title="BLAHBLAH";
        //window.parent.frames(0).document.all.oDiv.style.backgroundColor='blue';
        //alert(window.parent.frames(0).document.all.oBold.id)
        //alert(window.parent.frames(0).document.all.oDiv.style.backgroundColor);
        //var curTit=window.parent.oSlideFrm.document.title
        //document.all.oSlideFrm.style.width=(document.all.oSlideFrm.offsetHeight*.9)+'px';
}
