var currbox,prevbox;var dx,dy; var x,y;var t;var release
forgeturl=0;savecommand=0;accum="";mousemoving=0;filnaminput=0;showhich=0;sb=0
objs=new Array(20);
tie=new Array(5);tie[0]=""
ns = window.Event ? true : false;
document.write("<link rel=stylesheet type='text/css' href='"+stylfile+".css'>")
// if(ns)document.write("<link rel=stylesheet href='"+stylfile+"ns.css'>")   //1.21.09  online tried to load ntytoday as css
document.write("<iframe id=test name=test frameborder=no  style='position:absolute;display:none;'></iframe>")
objerrs=""
//function setobj(obj,parm,val){document.getElementById(obj).style[parm] = val;}
   //  use this for debugging   -- may need to loose ORs in parm test and find test for existence that excludes 0 and ""
function setobj(obj,parm,val){
  if(document.getElementById(obj)){ 
    if(document.getElementById(obj).style[parm]||document.getElementById(obj).style[parm]==0||document.getElementById(obj).style[parm]=="") document.getElementById(obj).style[parm] = val;
      else objerrs+=" noparm "+obj+" "+parm+ " "+setobj.caller.name
   }else objerrs+=" noobj "+obj +" " +setobj.caller.name
}


function getobj(obj,parm,st){currp=document.getElementById(obj).style[parm];if(!st)stripunits();return(currp)}
function stripunits(){currp=parseInt(currp.substring(0,currp.length-2));}
function insert(div,text,html){!html?document.getElementById(div).innerHTML=text:document.getElementById(div).innerText=text}
function getext(div){return(document.getElementById(div).innerHTML)}
function comm(text,html){insert('info',text,html)}
function show (nam) {setobj(nam,'visibility','visible')}
function hide (nam) {setobj(nam,'visibility','hidden')}
function asc(chr){return(chr.charCodeAt(0))}
function chr(asc){return(String.fromCharCode(asc))}
function getkeydown(e){
  if(release)return(0)
  if(ns)code=e.which;else code=e.keyCode

  if(code==39){boxlefts(boxleft(0,prevbox)+1,prevbox)}
  if(code==37){boxlefts(boxleft(0,prevbox)-1,prevbox)}
  if(code==40){boxtop(boxtop(0,prevbox)+1,prevbox)}
  if(code==38){boxtop(boxtop(0,prevbox)-1,prevbox)}

  if(code==83)getallobjs(0)                   // Save Obj locs
  if(code==68){if(debug){debug=0;insert('info',"");}else debug=1}   // toggle debug, clear info on off
  
  if(code==79)comm(objs)                      // Objs
  if(code==86)getallobjs(1)                   // View Obj locs

/*
  if(code==65){comm(picpause+" "+picinc)}
  if(code==74){clearInterval(t);trigjig(4,5)} // Jiggle
  if(code==69){stopjig();}                    // End Jiggle
  if(code==84){togglejiggle()}                // Toggle jiggle
  if(code==82)randomlayout()                 // Random layout
  if(code==78)layout()                        // Normal Layout
  if(code==66){suckdowntext()}
  if(code==67){blowuptext()}
  if(code==70){document.getElementById('play1').innerHTML='BLAH'}   // document.getElementById('myytplayer').top0)}
  if(code==68){clearInterval(tt);toggledow();} //Dow
  if(code==67){                        // Contents of test iframe
    if(ns)comm(document.getElementById('test').contentDocument.body.innerHTML)
     else comm(document.getElementById('test').outerHTML)
   }
  if(code==73)comm(document.frames["test"].document.body.innerHTML) //I.e. iframe cont
  if(code==76)document.getElementById('test').src='test.txt'; //Load iframe
*/
}
function getidobjs(){
  currnode=document.getElementById('bodynode').childNodes
  accum=""
  for(i=0;currnode[i];i++)if(currnode[i].id)accum+=currnode[i].id+" "
  objs=accum.split(" ")
  nobjs=objs.length-2
  if(debug)comm(nobjs+" "+objs)
  return(accum)
}
function getallobjs(viewonly){
  collstr=""
  for (i=1;i<=nobjs;i++){
    j=objs[i]
    if(viewonly)collstr+=j+".top0="+getobj(j,'top')+";"+j+".left0="+getobj(j,'left')+";"+String.fromCharCode(13)
      else {
        currobj="document.getElementById('"+j+"')"
        collstr+="if("+currobj+"){"+currobj+".top0="+getobj(j,'top')+";"+currobj+".left0="+getobj(j,'left')+";}"+String.fromCharCode(13)
       }
   }
  comm(collstr)
  if(!viewonly)savbrks()
}
function savbrks() {
   win1=window.open("","testwindow","scrollbars=yes,menubar=yes,status=yes,height=402,width=602")
   win1.document.open("text/html")
   win1.document.write(collstr)
   win1.document.close ()
}
function div(id,clas,styl){
    if(!styl)styl=""
    tp=Math.round(Math.random()*(200))+100;
    lft=Math.round(Math.random()*(300))+200
   document.write("<div id="+id+" onmouseDown='omd(this.id)' style='position:absolute;top:"+tp+";left:"+lft+";"+styl+"' class="+clas+">")
}
function togglejiggle(){if(jiggle){clearInterval(t);jiggle=0} else {jiggle=1;trigobjs()}}
function trigobjs(){if(jiggle){clearInterval(t);t=setInterval("jigglerange(8,12)",50)}}

function stopjig(){clearInterval(t);}
function trigjig(fromobj,toobj){t=setInterval("jigglerange("+fromobj+","+toobj+")",jiggleclockrate) }
function jigglerange(from,to){
  njigs=to-from
  objn=Math.round(Math.random()*(njigs))+from
  flip=Math.round(Math.random()*500)
  if(flip>50)parm="top";else parm="left"
//   parm="left"
  flip=Math.round(Math.random()*100)
  if(flip>50)dir=1;else dir=-1
  curparmval=getobj(objs[objn],parm)
  if(parm=='left'){if(curparmval<=ledge)dir=1;if(curparmval>=redge)dir=-1;}
  if(parm=='top'){if(curparmval<=tedge)dir=1;if(curparmval>=bedge)dir=-1;}
  incr=dir*jigmovlim
  setobj(objs[objn],parm,incr+curparmval)
}
function randomlayout(){
  for(i=1;i<=nobjs;i++){
      if(document.getElementById(objs[i]) && document.getElementById(objs[i]).top0){
        setobj(objs[i],"top",Math.round(Math.random()*(200))+100)
        setobj(objs[i],"left",Math.round(Math.random()*(300))+200)
       }
   }
}
function layout(){
  for(i=1;i<=nobjs;i++){
     currobj=document.getElementById(objs[i])
      if(currobj && currobj.top0){
        setobj(objs[i],"top",currobj.top0)
        setobj(objs[i],"left",currobj.left0)
	 }
      else {setobj(objs[i],"top",0);setobj(objs[i],"left",0)}
   }
  if(document.getElementById('thephrase1')||document.getElementById('picbuf1')||document.getElementById('widescreen'))
   adjbufs()
}
function catchclick(){if(forgeturl){forgeturl=0;return false} else return true }
function startmov(e){blurinputs();mousemoving=1;forgeturl=0;mousxy(e);} // mousedown anywhere in doc
function stopmove(e){mousemoving=0;mousxy(e);if(currbox){prevbox=currbox;currbox=0}} // mouseup  "
function mover(e){if(mousemoving){forgeturl=1;mousxy(e);}} // mousemove		"
function mousxy(e){
  if(ns){x=e.clientX;y=e.clientY}
    else {x=event.clientX;y=event.clientY;}
  if(!ns || (e.target.type!="text" && e.target.type!="textarea"))ns?e.preventDefault():event.returnValue=false
  if(currbox){
    if(tie[0]==currbox){
       distmovdx=(x-dx)-boxleft()
       distmovdy=(y-dy)-boxtop()
       boxlefts(boxleft(0,tie[1])+distmovdx,tie[1]);
       boxtop(boxtop(0,tie[1])+distmovdy,tie[1]);
     }
    if(tie[2]==currbox){
       distmovdx=(x-dx)-boxleft()
       distmovdy=(y-dy)-boxtop()
       boxlefts(boxleft(0,tie[3])+distmovdx,tie[3]);
       boxtop(boxtop(0,tie[3])+distmovdy,tie[3]);
     }
    boxleft(x-dx);
    boxtop(y-dy);
   }
  if(debug)comm(x+","+y+" "+currbox  +" "+ (currbox?document.getElementById(currbox).style.zIndex:"")+" "+ 
 (ns?e.target.className:'') +" "+ (ns?e.target.tagName:'')+" "+(ns?e.target.type:''))
}
function omd (boxid) {
   if(release){currbox=0;return(0)}
   currbox=boxid
   if(!ns){x=event.clientX;y=event.clientY;}
   dx=x-boxleft();dy=y-boxtop()
}
function blurinputs(){
  allinputs=document.getElementsByTagName('input')
  numinputs=allinputs.length
  for (i=0;i<numinputs;i++) allinputs.item(i).blur()
}
if(ns){
  document.addEventListener("mousedown",startmov,true)   // if not true objs don't follow cursor
  document.addEventListener("mouseup",stopmove,false)    // up and move either true or false OK
  document.addEventListener("mousemove",mover,false)
}
function boxtop(yval,forbox){if(!forbox)forbox=currbox;if(!yval)return(getobj(forbox,"top")); else setobj(forbox,"top",yval);}

function boxleft(xval,forbox){if(!forbox)forbox=currbox;if(!xval)return(getobj(forbox,"left")); else setobj(forbox,"left",xval);}
function boxlefts(xval,forbox){if(!forbox)forbox=currbox; setobj(forbox,"left",xval);}
function blogdate(daynum,ins){
  updateparms(daynum)
  str=parent.parent.days[dayofwk]+", "+parent.parent.months[monthnum] +" "+ parent.parent.dayofmo+", 20"+ parent.parent.year
  if(!ins)document.write(str); else return(str)
}

function getprops(obj){accum=""; for(var i in eval(obj))accum=accum+" "+i;  return(accum)}
function hgetprops(obj){
   accum="";
   for(var i in eval(obj))
   accum=accum+document.all[i].id+" "
   comm (accum)
}

document.write("<script src='datelib.js'><\/script>")
document.write("<\/head><body id=bodynode TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0 MARGINWIDTH=0 onload='startdow();if(startrandom)randomlayout();else layout();self.focus()' onkeyDown='getkeydown(event);' onmouseMove='if(!ns)mover()' onmouseDown='if(!ns)startmov()' onmouseUp='if(!ns)stopmove()'>")
document.write("<div style='position:absolute;left:200;top:10;' id=dummy><\/div>")
div('info','smallest')
document.write("<\/div>")
if(dowstart)document.write("<script src='dow09.js'><\/script>")
