var vstart1, vstart2, vstop1, vstop2, vstop1sav, vstop2sav;
vidstim=0

function blowuptext(){
   if(alreadyfading)return(0)
   autopictslide=1;
   if(whoson()>npics)moving=1
   picstartstop()
   if(whoson()>npics)moving=0
   otherowner=1;
   curtxt=whoson()+''
   blowup(curtxt)
   blowup(curtxt+'b')
   if(hd1=document.getElementById('head'+curtxt))hd1.style.zIndex=19
   if(hd1b=document.getElementById('head'+curtxt+'b'))hd1b.style.zIndex=19
   blubg=document.getElementById('blowupbg')
   bluscr=document.getElementById('blupscreen')

   if(lft=itm.bgleft)blubg.style.left=lft; else blubg.style.left=340
   if(tp=itm.bgtop)blubg.style.top=tp; else blubg.style.top=95
   if(wdth=itm.bgwidth)blubg.style.width=wdth; else blubg.style.width=650
   bluscr.style.left=boxleft(0,blubg.id)-1
   bluscr.style.top=boxtop(0,blubg.id)-1
   bluscr.style.width=blubg.style.width
   blubg.style.visibility="visible"
   bluscr.style.visibility="visible"

   if(bgh=itm.bgheight){
      bght=blubg.style.height
      botb=document.getElementById('blubotbar').style.top
      botb1=document.getElementById('blubotbar1').style.top
      unzt=document.getElementById('unzoomonoff').style.top
      lcov=document.getElementById('bluleftcover').style.height
      lcovb=document.getElementById('bluleftcoverb').style.height
      rcov=document.getElementById('blurightcover').style.height
      rcovb=document.getElementById('blurightcoverb').style.height

      blubg.style.height=bgh
      document.getElementById('blubotbar').style.top=bgh+1
      document.getElementById('blubotbar1').style.top=bgh+2
      document.getElementById('unzoomonoff').style.top=bgh+92
      document.getElementById('bluleftcover').style.height=bgh+1
      document.getElementById('bluleftcoverb').style.height=bgh+1
      document.getElementById('blurightcover').style.height=bgh+1
      document.getElementById('blurightcoverb').style.height=bgh+1
    }
   if(bgw=itm.bgwidth){
      bgw=blubg.style.width
      botw=document.getElementById('blubotbar').style.width
      botw1=document.getElementById('blubotbar1').style.width
      topw=document.getElementById('blutopbar').style.width
      topw1=document.getElementById('blutopbar2').style.width
      rcovlft=document.getElementById('blurightcover').style.left
      rcovblft=document.getElementById('blurightcoverb').style.left
      
      blubg.style.width=bgw
      document.getElementById('blutopbar').style.width=boxwidth(0,blubg.id)+1
      document.getElementById('blutopbar2').style.width=boxwidth(0,blubg.id)+2
      document.getElementById('blurightcover').style.left=boxwidth(0,blubg.id)
      document.getElementById('blurightcoverb').style.left=boxwidth(0,blubg.id)+1
      document.getElementById('blubotbar').style.width=boxwidth(0,blubg.id)+1
      document.getElementById('blubotbar1').style.width=boxwidth(0,blubg.id)+2
    }
   show('unzoomonoff')
   hide('zoomonoff')
}
function blowup(artnum){
   id='article'+artnum
   itm=document.getElementById(id)
   orgfs=itm.style.fontSize
   orglh=itm.style.lineHeight
   if(id.indexOf('b')==-1)orgw=boxwidth(0,id); else orgwb=boxwidth(0,id)
   if(id.indexOf('b')==-1)orgl=boxleft(0,id); else orglb=boxleft(0,id); 
   orgbgc=itm.style.backgroundColor
   orgp=itm.style.padding
   orgfw=itm.style.fontWeight
   orgff=itm.style.fontFamily
   orgz=itm.style.zIndex

   itm.style.fontSize=11
   itm.style.lineHeight="13px"
   if(bgwdth=itm.width){boxwidth(bgwdth,id)}  //itm.style.left=bglft
     else itm.style.width=300
   if(bglft=itm.left){boxlefts(bglft,id)}  //itm.style.left=bglft
     else  itm.style.left=((artnum.indexOf('b')==-1)?orgl-100:orglb-8)
   savunz=boxleft(0,'unzoomonoff')
   if(unzl=itm.unzlft)boxlefts(unzl,'unzoomonoff')
   itm.style.backgroundColor="white"
   itm.style.fontWeight=100
   itm.style.fontFamily="verdana"
   itm.style.zIndex=19
}
function suckdowntext(nopicstart){
   curtxt=whoson()+''
   suckdown(curtxt)
   suckdown(curtxt+'b')
   if(hd1=document.getElementById('head'+curtxt))hd1.style.zIndex=17
   if(hd1b=document.getElementById('head'+curtxt+'b'))hd1b.style.zIndex=17
   blubg=document.getElementById('blowupbg')
   blubg.style.visibility="hidden"
   bluscr=document.getElementById('blupscreen')
   bluscr.style.visibility="hidden"
   hide('unzoomonoff')
   show('zoomonoff')
   otherowner=0
   if(!itm.bgheight){}  //{if(!nopicstart)picstartstop()}   //5.7.09 don't restart play aftr suckdown; restore else 5.9.09
    else {                    // reset normal zoom parameters for frame bg and control
      blubg.style.height=bght
      document.getElementById('blubotbar').style.top=botb
      document.getElementById('blubotbar1').style.top=botb1
      document.getElementById('unzoomonoff').style.top=unzt
      document.getElementById('bluleftcover').style.height=lcov
      document.getElementById('bluleftcoverb').style.height=lcovb
      document.getElementById('blurightcover').style.height=rcov
      document.getElementById('blurightcoverb').style.height=rcovb
    }
   if(itm.bgwidth){
      blubg.style.width=bgw
      document.getElementById('blubotbar').style.width=botw
      document.getElementById('blubotbar1').style.width=botw1
      document.getElementById('blutopbar').style.width=topw
      document.getElementById('blutopbar2').style.width=topw1
      document.getElementById('blurightcover').style.left=rcovlft
      document.getElementById('blurightcoverb').style.left=rcovblft
    }
}
function suckdown(artnum){
   id='article'+artnum
   itm=document.getElementById(id)

   itm.style.fontSize=orgfs
   itm.style.lineHeight=orglh
//   comm(itm.className.width)
   if(id.indexOf('b')==-1)itm.style.width=(isNaN(orgw)?206:orgw); else itm.style.width=(isNaN(orgwb)?206:orgwb);
   if(id.indexOf('b')==-1) itm.style.left=orgl; else itm.style.left=orglb
//   if(id.indexOf('b')==-1)boxwidth(orgw,id); else boxwidth(orgwb,id);
//   itm.style.left=boxleft(0,id)+((artnum.indexOf('b')==-1)?100:-8)
   itm.style.backgroundColor=orgbgc
   itm.style.padding=orgp
   itm.style.fontWeight=orgfw
   itm.style.fontFamily=orgff
   itm.style.zIndex=orgz
   boxlefts(savunz,'unzoomonoff')
}
function zoomon(){
  if(document.getElementById('unzoomonoff').style.visibility=='visible')return(1)
    else return(0)
}

function crossfade(from,to){
  if(alreadyfading)return(0)
   else alreadyfading=1
//   comm("from="+from+" to="+to)
  zixsets(to,from)
  t7=setInterval('nextfade('+from+','+to+')',fadeclockrate)
  colr=1118481   // 111111
  fadectr=14
  curcolr=0
  nextfade(from,to)
  return(1)
}
function nextfade(from,to){
  if(fadectr-- >0){
     curcolr= curcolr+colr
     curopcolr=(15*colr)-curcolr
     if(curcolr>7000000 && curcolr<8000000)zixsets(from,to)
     fadeobj('article',from,'',curcolr)
     fadeobj('article',from,'b',curcolr)
     fadeobj('head',from,'',curcolr)
     fadeobj('head',from,'b',curcolr)

     fadeobj('article',to,'',curopcolr)
     fadeobj('article',to,'b',curopcolr)
     fadeobj('head',to,'',curopcolr)
     fadeobj('head',to,'b',curopcolr)
     showobjset(to)
   }
   else { showobjset(from,1);clearInterval(t7);alreadyfading=0;}
 }
function fadeobj(objtyp,objid,id2,shade){
    if(thisobj= document.getElementById(objtyp+objid+id2))thisobj.style.color=shade.toString(16)
}
function showobjset(to,noshow){
   if(thisobj=document.getElementById('article'+to))noshow?hide(thisobj.id):show(thisobj.id)
   if(thisobj=document.getElementById('article'+to+'b'))noshow?hide(thisobj.id):show(thisobj.id)
   if(thisobj=document.getElementById('head'+to))noshow?hide(thisobj.id):show(thisobj.id)
   if(thisobj=document.getElementById('head'+to+'b'))noshow?hide(thisobj.id):show(thisobj.id)
}
function zixsets(from,to){
   if(thisobj=document.getElementById('article'+to)) thisobj.style.zIndex=17
   if(thisobj=document.getElementById('article'+to+'b')) thisobj.style.zIndex=17
   if(thisobj=document.getElementById('head'+to)) thisobj.style.zIndex=17
   if(thisobj=document.getElementById('head'+to+'b')) thisobj.style.zIndex=17

   if(thisobj=document.getElementById('article'+from)) thisobj.style.zIndex=16
   if(thisobj=document.getElementById('article'+from+'b')) thisobj.style.zIndex=16
   if(thisobj=document.getElementById('head'+from)) thisobj.style.zIndex=16
   if(thisobj=document.getElementById('head'+from+'b')) thisobj.style.zIndex=16
}
function whoson0(){
  for (i=1;i<=narticles;i++){
    if(thisart=document.getElementById('article'+i)){
      if(thisart.style.visibility!='hidden')return(i)
     }
   }
}
function whoson(){
 frst=0; secnd=0; thrd=0
  for (i=1;i<=narticles;i++){
    if(thisart=document.getElementById('article'+i)){
      if(thisart.style.visibility!='hidden')if(!frst)frst=i;else if(!secnd)secnd=1;else if(!thrd)thrd=i
     }
   }
  if(thrd){hide('article'+secnd);hide('article'+frst);return(thrd)}
   else if(secnd){hide('article'+frst);return(secnd)}
     else return(frst)
}

function picstartstop(){
   if(!moving){
     otherowner=0;
     if(whoson()!=showpic && !zoomon())crossfade(whoson(),showpic)
   }
   if(zoomon()){
     suckdowntext();
     if(!document.getElementById("article"+whoson()+"b").bgheight){autopictslide=1;}
       else {crossfade(whoson(),showpic); autopictslide=0}
    }
    else if(autopictslide){autopictslide=0;stopiclock();chcontrolword('picplay','&nbsp;&nbsp;PLAY');}
     else {autopictslide=1;startpiclock();chcontrolword('picplay','PAUSE');};

//     else {autopictslide=1;chcontrolword('picplay','PAUSE');pause('startpiclock()',200);};
}
function crawlstartstop(){
   if(autoon){autoon=0;stopclock();chcontrolword('crawlplay','&nbsp;&nbsp;PLAY&nbsp;');}
     else {autoon=1;startclock();chcontrolword('crawlplay','PAUSE');}
   return false;
}
function dowstartstop(){
  if(dowon){clearInterval(tt);dowon=0;insert('dowplay','&nbsp;PLAY&nbsp;')}
    else {cntr=0;dowon=1;startdow();insert('dowplay','&nbsp;STOP&nbsp;')}
  return false;
}
function jigstartstop(){
  if(jiggle){clearInterval(t);jiggle=0;insert('namejig','&nbsp;ON&nbsp;')}
    else {jiggle=1;trigjig2();insert('namejig','&nbsp;OFF&nbsp;')}
  return false;
}

function musicstartstop(){
  if(document.getElementById('musplay').innerHTML == "&nbsp;STOP&nbsp;"){
      insert('imeemplayer',stopstring);
      insert('musplay','&nbsp;PLAY&nbsp;');
//      autopictslide=0;stopiclock();chcontrolword('picplay','&nbsp;&nbsp;PLAY');
//      if(zoomon())suckdowntext(1);
//      crossfade(5,showpic);otherowner=0;
      autopictslide=1;picstartstop();if(zoomon())suckdowntext(1);crossfade(5,showpic);otherowner=0;  // 986
    }
    else{
      insert('imeemplayer',playstring);
      insert('musplay','&nbsp;STOP&nbsp;');
 //     otherowner=1;autopictslide=0;stopiclock();chcontrolword('picplay','&nbsp;&nbsp;PLAY');
      autopictslide=1;picstartstop(); stopiclock()
      showlyrics()
     }
}
function trigjig2(){t=setInterval("jigglename()",jiggleclockrate) }
function jigglename(){
  objn=Math.round(Math.random()*(1))+1  // 1 or 2
  flip=Math.round(Math.random()*500)
  if(flip>50)parm="top";else parm="left"
  flip=Math.round(Math.random()*100)
  if(flip>50)dir=1;else dir=-1
  if(objn==1)jigobj='blogname';else jigobj='shadow'
  curparmval=getobj(jigobj,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(jigobj,parm,incr+curparmval)
}
function showlyrics(){
//  if(!moving){
    otherowner=1
    nowon=whoson()
//    comm(nowon)
    if(document.getElementById('unzoomonoff').style.visibility=='visible'){suckdowntext(1)}
    if(nowon!=5){crossfade(nowon,5);chcontrolword('picplay','&nbsp;SHOW')}  // codepause('prezoom()',500)}
//   }
}
function prezoom(){if(!zoomon()){alreadyfading=0;blowuptext()}}
function showmovieinfo(){
//  if(!moving){
    otherowner=1
    nowon=whoson()
//    comm(nowon)
    if(zoombe)if(document.getElementById('unzoomonoff').style.visibility=='visible'){suckdowntext(1)}
    if(nowon!=6){crossfade(nowon,6);chcontrolword('picplay','&nbsp;SHOW')}
//   }
}
function zoombe(){
  if(document.getElementById('unzoomonoff'))return(1)
    else return(0)
}
function pause(fn,tim){t9=setTimeout(fn,tim)}
function startpiclock(){
    clearTimeout(t9);
    if(autopictslide){
      t1=setInterval("autopicleft()",picslideclockrate)
      moving=1
     }
}
function stopiclock(){clearInterval(t1)}
function chcontrolword(whichid,to){document.getElementById(whichid).innerHTML=to}

function autopicleft(){
  widthctr+=picinc;
  if(widthctr>stopwidth){
     if(widthctr<(stopwidth+picinc)){
       svscrinc=picinc
       picinc=picinc-(widthctr-stopwidth)
       if(bufleft("picbuf1",(picfirstloop?picendbuf2:picendbuf1),picrtmarg,picinc,picfirstloop))picfirstloop=1
       picinc=svscrinc
      }
     widthctr=0;
     stopiclock()
     moving=0
     elapsd=boxleft(0,"picbuf1")* -1
     cpn=parseInt(elapsd/picwid)
     if(!picfirstloop){hidepic=cpn+1;showpic=cpn+2;if(showpic>npics)showpic=1}
       else {hidepic=(cpn?cpn:npics);showpic=cpn+1}
     prev=((showpic-1)==0?4:showpic-1)
//     comm(prev+" "+showpic)
     if(!otherowner&&!moving) crossfade(prev,showpic)
     hide("slidecapt"+hidepic);show("slidecapt"+showpic)
     if(!otherowner)pause("startpiclock()",picpause)
   }
   else if(bufleft("picbuf1",(picfirstloop?picendbuf2:picendbuf1),picrtmarg,picinc,picfirstloop))picfirstloop=1
}
function bufleft(bufname,endbuf,prtmarg,slinc,firstpass){
  var xscrl,nexbufst
  clearTimeout(t9);
  xscrl=slinc;
  nexbufst= -(endbuf-boxleft(0,bufname) + slinc)
  insert('picinfo2',"&nbsp;"+(showpic==npics?1:showpic+1)+"&nbsp;")
  if(nexbufst >= 0){
       boxlefts(boxleft(0,bufname)-xscrl,bufname);
       boxwidth(boxwidth(0,bufname)+xscrl,bufname);
     }
      else if(loopon){
        if(!firstpass){
           document.getElementById(bufname).id=bufname+"99"
           document.getElementById(bufname+"b").id=bufname
           firstpass=1
           hide(bufname+"99");
           show(bufname)
         }
        boxlefts(nexbufst,bufname);
        boxwidth(browidth-nexbufst-prtmarg,bufname);    // elim: if lt 8, FF oflos
        return firstpass
      }
}
function capspos(){        // override pos file settings and layout; rather than set each one by hand
  for(i=1;i<=npics;i++){
    setobj("slidecapt"+i,"top",captop);
    setobj("slidecapt"+i,"left",capleft);
   }
}

function startclock(){t2=setInterval("autoleft()",crawlclockrate)}
function stopclock(){autoon=0;clearInterval(t2)}
function autoleft(){if(autoon)phraseleft()}

function relparms(divid){
  var curbufn=strip1st(9,phrasename)
  retstr= "SPEED <span style='background-color:white;color:black;font-size:7;'>&nbsp;"+scrollinc+ "&nbsp;</span> ELAPSED: <span style='background-color:white;color:black;font-size:7;'>&nbsp;"+((boxleft(0,phrasename))*-1 +750)+
    "&nbsp;</span>  REMAIN: <span style='background-color:white;color:black;font-size:7;'>&nbsp;"+((parseInt(eval("endbuf"+curbufn)))-boxleft(0,phrasename))*-1+"&nbsp;</span>"
  insert(divid,"&nbsp; &nbsp; &nbsp; &nbsp;"+retstr)
}
function phraseleft(right){
  var xscrl,nexbufst
  if(!right)xscrl=scrollinc; else xscrl=-scrollinc
  bufn=Number(strip1st(9,phrasename))
  nexbufst= -(eval("endbuf"+bufn)-boxleft(0,phrasename) + scrollinc)
  relparms('crawlinfo')
  if(nexbufst >= 0){
       boxlefts(boxleft(0,phrasename)-xscrl,phrasename);
       boxwidth(boxwidth(0,phrasename)+xscrl,phrasename);
     }
     else if(bufn<nbufs){
       phrasename="thephrase"+(++bufn)

 //      boxlefts(nexbufst,phrasename)
      boxlefts(100,phrasename)

       boxwidth(browidth-nexbufst,phrasename)
       show(phrasename); hide("thephrase"+(--bufn))
     }
      else if(loopon){
        if(firstloop){
           document.getElementById("thephrase1").id="thephrase99"
           document.getElementById("thephrase"+(nbufs+1)).id="thephrase1"
           endbuf1=eval("endbuf"+(nbufs+1))
           firstloop=0
         }
//        boxlefts(nexbufst,"thephrase1");
        boxlefts(30,"thephrase1");

        boxwidth(browidth-nexbufst-rtmarg,"thephrase1");    // if lt 8, FF oflos
        if(nbufs==1)hide("thephrase99");else hide("thephrase"+nbufs)
        show("thephrase1")
        phrasename="thephrase1"
      }
}

function adjbufs(){    // this runs at end of layout if "thephrase1" exists; and so runs after this page is loaded
//  comm(objerrs)
  if(document.getElementById('thephrase2')){
    document.getElementById('thephrase2').style.top=document.getElementById('thephrase1').top0
    boxwidth((browidth-document.getElementById('thephrase1').left0)-rtmarg,"thephrase1")//so IE no oflo; FF:<8 oflos
    boxwidth((browidth-document.getElementById('thephrase2').left0)-rtmarg,"thephrase2")//so IE no oflo
   }
  if(document.getElementById('picbuf1b')){
    document.getElementById('picbuf1b').style.top=document.getElementById('picbuf1').top0
    boxwidth((browidth-document.getElementById('picbuf1').left0)-picrtmarg,"picbuf1")//so IE no oflo; FF:<8 oflos
    boxwidth((browidth-document.getElementById('picbuf1b').left0)-picrtmarg,"picbuf1b")//so IE no oflo
   }
  capspos();show('slidecapt1');
  if(autoon){startclock();insert('crawlplay','&nbsp;PAUSE&nbsp;')}
  if(autopictslide){pause("startpiclock()",picpause);insert('picplay','PAUSE')}
  if(dowon)insert('dowplay','&nbsp;STOP&nbsp;')

  if(document.getElementById('buzzbutton')){boxlefts(buttleft,'buzzbutton');boxtop(buttop,'buzzbutton');}

  codepause("finadj()",1000)        // fucking IE needs this pause, the piece of shit
}

function finadj(){
  if(vidhole1 = document.getElementById("vidhole1id")){
    vidhole1.style.position="absolute";
    vidhole1.style.top=boxtop(0,'widescreen')+document.getElementById('widescreen').voff   //-50;
    vidhole1.style.left=boxleft(0,'widescreen')+((zzz=document.getElementById('widescreen').hoff)?zzz:34)
    vidhole1.style.zIndex=4;
   }
  if(vidhole2 = document.getElementById("vidhole2id")){
    vidhole2.style.position="absolute";
    vidhole2.style.top=boxtop(0,'widescreen2')+document.getElementById('widescreen2').voff;
    vidhole2.style.left=boxleft(0,'widescreen2')+((zzz=document.getElementById('widescreen2').hoff)?zzz:34)
    vidhole2.style.zIndex=2;
   }
}
function onYouTubePlayerReady(playerId) {
  playrid=playerId+"id"
  playrsvideo=playerId+"video"
  eval(playerId+'=document.getElementById(playrid)')
//  comm(eval(playerId+'.id'))
  playrobj=document.getElementById(playrid)
  playrobj.style.position="absolute";
  if(playerId=='vidhole1'){
    playrobj.style.top=boxtop(0,'widescreen')+document.getElementById('widescreen').voff   // -50;
    playrobj.style.left=boxleft(0,'widescreen')+((zzz=document.getElementById('widescreen').hoff)?zzz:34) // 34
    playrobj.addEventListener("onStateChange","updatestate");
    playrobj.style.zIndex=4;
    if(vstart1)vidstim=vstart1; else vidstim=0
   }
  if(playerId=='vidhole2'){
    playrobj.style.top=boxtop(0,'widescreen2')+document.getElementById('widescreen2').voff;  // 0
    playrobj.style.left=boxleft(0,'widescreen2')+((zzz=document.getElementById('widescreen2').hoff)?zzz:34)
    playrobj.addEventListener("onStateChange","updatestate2");
    playrobj.style.zIndex=2;
    if(vstart2)vidstim=vstart2; else vidstim=0
   }
    cuevid(playrid,eval(playrsvideo),vidstim)
  nwvl=getVolume(playrid)+1
  insert('vidvol','&nbsp;'+(nwvl<10?('0'+nwvl):nwvl)+'&nbsp;')
  if(playrobj.isMuted()){playrobj.unMute();insert('vidmuteonoff','&nbsp;OFF&nbsp;');}
  updatestate()
  //showvidinfo();
  //setInterval("showvidinfo()", 250);
}

function updatestate(newstate){
  if(newstate==-1)vidstate='&nbsp;&nbsp;PRE&nbsp;&nbsp;'
  if(newstate==1)vidstate='&nbsp;&nbsp;PLAYING&nbsp;&nbsp;'
  if(newstate==2)vidstate='&nbsp;&nbsp;PAUSED&nbsp;&nbsp;'
  if(newstate==3)vidstate='&nbsp;&nbsp;BUFFER&nbsp;&nbsp;'
  if(newstate==5)vidstate='&nbsp;&nbsp;CUED&nbsp;&nbsp;'
//  if(newstate==0){
//    chcontrolword('vidplay','&nbsp;PLAY&nbsp;');
//    vidstate='&nbsp;&nbsp;CUED&nbsp;&nbsp;'
//    show('suisclucover')
//    vidplaying=0;
//    if(online)document.getElementById(whplayer).pauseVideo();
//   }
}
function updatestate2(newstate){
  if(newstate==-1)vidstate2='&nbsp;&nbsp;PRE&nbsp;&nbsp;'
  if(newstate==1)vidstate2='&nbsp;&nbsp;PLAYING&nbsp;&nbsp;'
  if(newstate==2)vidstate2='&nbsp;&nbsp;PAUSED&nbsp;&nbsp;'
  if(newstate==3)vidstate2='&nbsp;&nbsp;BUFFER&nbsp;&nbsp;'
  if(newstate==5)vidstate2='&nbsp;&nbsp;CUED&nbsp;&nbsp;'
//  if(newstate==0){
//     chcontrolword('vidplay2','&nbsp;PLAY&nbsp;');
//     vidstate2='&nbsp;&nbsp;CUED&nbsp;&nbsp;'
//     show('apocacoflo423x343')
//     vidplaying2=0;
//     if(online)document.getElementById(whplayer).pauseVideo();
//   }
}

function resetplyr(whplayer){
  if(whplayer=='vidhole1id'){
    clearInterval(t3)
    chcontrolword('vidplay','&nbsp;PLAY&nbsp;');
    vidstate='&nbsp;&nbsp;CUED&nbsp;&nbsp;'
    insert('vdstat',vidstate)

    if(document.getElementById('suisclucover'))show('suisclucover')   // legacy kluge
      else show('vid1img')

    vidplaying=0;
    vstop1=vstop1sav
    if(online)document.getElementById(whplayer).cueVideoById(vidhole1video,(vstart1?vstart1:0))

   }else{
      clearInterval(t4)
      chcontrolword('vidplay2','&nbsp;PLAY&nbsp;');
      vidstate2='&nbsp;&nbsp;CUED&nbsp;&nbsp;'
      insert('vdstat2',vidstate)
      if(document.getElementById('coflocover'))show('coflocover')    // legacy kluge
         else show('vid2img')
      vidplaying2=0;
      vstop2=vstop2sav
      if(online)document.getElementById(whplayer).cueVideoById(vidhole2video,(vstart2?vstart2:0));
     }
}
function showvidinfo(whplayer){
  if(online)vidtm=parseInt(document.getElementById(whplayer).getCurrentTime());else vidtm=0
  if(online)vidur=parseInt(document.getElementById(whplayer).getDuration());else vidur=0

  if(whplayer=='vidhole1id'){
     insert("vidinfo","&nbsp;&nbsp;TIME&nbsp;<span id=vidtime style='background-color:white;color:black;'>&nbsp; &nbsp;"+vidtm+"&nbsp;&nbsp;</span> / <span id=viddur style='background-color:white;color:black;'>&nbsp;&nbsp;"+vidur+"&nbsp;&nbsp;</span>&nbsp<span id=vdstat style='background-color:white;color:black;'>&nbsp;&nbsp;"+vidstate+"&nbsp;&nbsp;</span>")

       if(vstop1 && vstop1<=vidtm){
        if(vnext1){vstop1=0;document.getElementById(whplayer).seekTo(vnext1,1)}
          else resetplyr(whplayer)
      }
   }
    else{
     insert("vidinfo2","&nbsp;&nbsp;TIME&nbsp;<span id=vidtime2 style='background-color:white;color:black;'>&nbsp; &nbsp;"+vidtm+"&nbsp;&nbsp;</span> / <span id=viddur2 style='background-color:white;color:black;'>&nbsp;&nbsp;"+vidur+"&nbsp;&nbsp;</span>&nbsp<span id=vdstat2 style='background-color:white;color:black;'>&nbsp;&nbsp;"+vidstate2+"&nbsp;&nbsp;</span>")

     if(vstop2&&vstop2<=vidtm){
        if(vnext2){vstop2=0;document.getElementById(whplayer).seekTo(vnext2,1)}
          else resetplyr(whplayer)
       }
   }
  if(vidur&&vidur==vidtm)resetplyr(whplayer)
//  comm("vstop1= "+ vstop1)
}
function loadvid(whplayer,id, startSeconds) {
   if(document.getElementById(whplayer)){
      if(whplayer=='vidhole1id'){
         chcontrolword('vidplay','PAUSE');
         vidplaying=1;
         if(document.getElementById('suisclucover'))hide('suisclucover')   // legacy kluge
            else hide('vid1img')
         if(vstart1)vidstim=vstart1; else vidstim=0
         vstop1=vstop1sav
         t3=setInterval("showvidinfo('"+whplayer+"')", 250);
       }
         else{
           chcontrolword('vidplay2','PAUSE');
           vidplaying2=1;
           if(document.getElementById('coflocover'))hide('coflocover')   // legacy kluge
              else hide('vid2img')
           if(vstart2)vidstim=vstart2; else vidstim=0
           vstop2=vstop2sav
           t4=setInterval("showvidinfo('"+whplayer+"')", 250);
          }
      if(online)document.getElementById(whplayer).loadVideoById(id, parseInt(vidstim)); 
     }
}
function cuevid(whplayer,id, startSeconds) {if (document.getElementById(whplayer) && online) {document.getElementById(whplayer).cueVideoById(id, startSeconds);}}

function playvid(whplayer,cover){
  if(cover)hide(cover)
  if(whplayer=='vidhole1id'){
     if(vidplaying){vidplaying=0;if(online)document.getElementById(whplayer).pauseVideo();chcontrolword('vidplay','&nbsp;PLAY&nbsp;');}
      else {
        vidplaying=1;
        chcontrolword('vidplay','PAUSE');
//        showmovieinfo()
        insert('lyricreplay','<a href="javascript:void(0);"  style="color:white;" onclick="loadvid(\'vidhole1id\',vidhole1video);">REPLAY&nbsp;&nbsp;&nbsp;</a>')
        if(online)document.getElementById(whplayer).playVideo();        // online set in dow09.js
        t3=setInterval("showvidinfo('"+whplayer+"')", 250);
      }
    }else{                  // VIDEO/SONG 2
     if(vidplaying2){vidplaying2=0;if(online)document.getElementById(whplayer).pauseVideo();chcontrolword('vidplay2','&nbsp;PLAY&nbsp;');}
      else {
        vidplaying2=1;
//        showlyrics()
        insert('lyricreplay2','<a href="javascript:void(0);"  style="color:white;" onclick="loadvid(\'vidhole2id\',vidhole2video);">REPLAY&nbsp;&nbsp;&nbsp;</a>')
//        hide('musicword1');hide('musicword2');hide('musicword3');
        chcontrolword('vidplay2','PAUSE');
        if(online)document.getElementById(whplayer).playVideo();        // online set in dow09.js
        t4=setInterval("showvidinfo('"+whplayer+"')", 250);
      }
     }
}
function mutevid(whplayer){
 if(online){
  if (document.getElementById(whplayer)){
    if(document.getElementById(whplayer).isMuted()){
      document.getElementById(whplayer).unMute();
      if(whplayer=='vidhole1id')insert('vidmuteonoff','&nbsp;OFF&nbsp;')
        else insert('vidmuteonoff2','&nbsp;OFF&nbsp;')
     }
     else {
        document.getElementById(whplayer).mute();
        if(whplayer=='vidhole1id')insert('vidmuteonoff','&nbsp;&nbsp;ON&nbsp;')
          else insert('vidmuteonoff2','&nbsp;&nbsp;ON&nbsp;')
      }
   }
 }else{
   if(whplayer=='vidhole1id'){
     if(getext('vidmuteonoff')=='&nbsp;OFF&nbsp;')insert('vidmuteonoff','&nbsp;&nbsp;ON&nbsp;');
      else insert('vidmuteonoff','&nbsp;OFF&nbsp;');
    }else{
       if(getext('vidmuteonoff2')=='&nbsp;OFF&nbsp;')insert('vidmuteonoff2','&nbsp;&nbsp;ON&nbsp;');
        else insert('vidmuteonoff2','&nbsp;OFF&nbsp;');
      }
   }
}
function setVolume(whplayer,newVolume) {if (document.getElementById(whplayer)&&online) {document.getElementById(whplayer).setVolume(newVolume); } else return(5)}
function getVolume(whplayer) {if (document.getElementById(whplayer)&&online) {return document.getElementById(whplayer).getVolume();}else return(5)}

function codepause(fn,tim){t8=setTimeout(fn,tim)}
function setslower(){scrollinc-=speedincr;if(scrollinc<minscrollinc)scrollinc=minscrollinc;}
function strip1st(n,altbox){bnum=(altbox?altbox:currbox).substring(n,(altbox?altbox:currbox).length);return(bnum)}
function boxwidth(width,forbox){if(!forbox)forbox=currbox;if(!width)return(getobj(forbox,"width"));else setobj(forbox,"width",width) }
function getbrowidth(){
 if(self.innerWidth)browidth=self.innerWidth;
   else if(document.documentElement && document.documentElement.clientWidth)browidth=document.documentElement.clientWidth;
 	 else if (document.body)browidth=document.body.clientWidth;
 return(browidth)
}
