
// All scripts on this page are the work of Timothy Edwards, DBA Can2Can, who asserts all author's rights under Copyright law
// permision granted to use _as is, with copyright stement_ as a callable script file on non-commercial sites
// link to your file with "<script language = "Javascript" src="Office.js">;"

function c2cSubScanPix(){
// scan the loaded page, and setup pointers to images that scripts reference...
// the server can add or delete images as a result of SSIs
var vTop13 = 0
{c2cZClockPoint = vTop13}
{c2cSecMonitPoint = vTop13}
{c2cViewPortPoint = vTop13}
{c2cDoveAniPoint = vTop13}
{c2cVolePoint = vTop13}
{c2cHitPoint = vTop13}
{c2cGlyphTickerPoint = vTop13}
for ( i = 0; i < document.images.length; i++){
if (document.images[i].name == "c2OfficeZClock") {c2cZClockPoint = vTop13}
if (document.images[i].name == "c2OfficeSecMonitor") {c2cSecMonitPoint = vTop13}
if (document.images[i].name == "c2OfficeViewPort") {c2cViewPortPoint = vTop13}
if (document.images[i].name == "c2OfficeDove") {c2cDoveAniPoint = vTop13}
if (document.images[i].name == "c2AvreyTheVole") {c2cVolePoint = vTop13}
if (document.images[i].name == "c2PageHits") {c2cHitPoint = vTop13}
if (document.images[i].name == "c2BajGlyphNews") {c2cGlyphTickerPoint = vTop13}
vTop13 ++ }
}

function c2cSubWakeDove(){
// initialize picture pointers
c2cSubScanPix()
// turn on the security monitor scan
c2cSubSecMonScanStep()
// replace the sleeping dove/applet loading pix with a waking-up animation
if (document.images[c2cDoveAniPoint].name == "c2OfficeDove") (document.images[c2cDoveAniPoint].src="wdove.gif")
setTimeout("c2cSubDoveIsAlert()",4000)
}

function c2cSubDoveIsAlert() {
c2cSubSecMonScanStep()
// it's been long enough, the dove is sitting up, replace with normal activity.
if (document.images[c2cDoveAniPoint].name == "c2OfficeDove") (document.images[c2cDoveAniPoint].src="Dove.gif")
// and start the clock.
// Tried this, it crashes - c2cHitCount='<% =iCount%>';
if (getCookie("c2cHitCount").length > 0) (c2cHitCount = getCookie("c2cHitCount"))
c2cLedNumbers(c2cHitPoint-1,4,c2cHitCount)
c2cSubShowZuluTime()
}

function c2cSubUnlockSecMon() {
// unlock the security monitor scan by setting the increment to one
c2cSecMonitStep = 1
return 0
}

function c2cSubLockSecMonTo(intMapView) {
// lock the security scan on the selected view by setting the pointer to the selection
// and setting the increment to zero, so the pointer will not move away
c2cSecMonitStep = 0
c2cVPAniFlag = 0
c2cSecMonNowView = intMapView
// don't wait for the next update, show it fast
c2cSubScanPix()
document.images[c2cSecMonitPoint].src=c2SecMonImage[c2cSecMonNowView].src
return 1
}

function c2cSubSecMonScanStep() {
// if the security monitor is scanning, move to the next view.
if (c2cSecMonitStep == 0) return 0
c2cSecMonNowView += c2cSecMonitStep
if (c2cSecMonNowView >= 18) c2cSecMonNowView = 0
if (document.images[c2cSecMonitPoint].name != "c2OfficeSecMonitor") (c2cSubScanPix())
document.images[c2cSecMonitPoint].src=c2SecMonImage[c2cSecMonNowView].src
if (c2cSecMonNowView == 9) c2cSubWalkTheVole()
if (c2cSecMonNowView != 17) return 0
if (c2cVPAniFlag == 1) return 0
var ptr = c2cOfficeTime.getMinutes()
ptr = ptr % 5
if (ptr == 0) document.images[c2cViewPortPoint].src="Awin1.gif"
if (ptr == 1) document.images[c2cViewPortPoint].src="Awin2.gif"
if (ptr == 2) document.images[c2cViewPortPoint].src="Awin3.gif"
if (ptr == 3) document.images[c2cViewPortPoint].src="Awin4.gif"
if (ptr == 4) document.images[c2cViewPortPoint].src="Awin5.gif"
c2cVPAniFlag = 1
return 0
}

// replace the start position still with the animation.
function c2cSubWalkTheVole() {
var ptr = c2cOfficeTime.getSeconds()
ptr = ptr % 2
if (document.images[c2cVolePoint].name != "c2AvreyTheVole") (c2cSubScanPix())
if (document.images[c2cVolePoint].name != "c2AvreyTheVole") return 0
c2cSlowVole += 1
if (c2cSlowVole >= 3) c2cSlowVole = 0
if (c2cSlowVole != 1) return 0
// 0 is in-box, 1 is center of desk, 2 is nestbox
if (c2cVoleIsAt == 0 && ptr == 0) document.images[c2cVolePoint].src="deskani1.gif"
if (c2cVoleIsAt == 1 && ptr == 0) document.images[c2cVolePoint].src="deskani3.gif"
if (c2cVoleIsAt == 2 && ptr == 0) document.images[c2cVolePoint].src="deskani4.gif"
if (c2cVoleIsAt == 0 && ptr == 1) document.images[c2cVolePoint].src="deskani2.gif"
if (c2cVoleIsAt == 1 && ptr == 1) document.images[c2cVolePoint].src="deskani6.gif"
if (c2cVoleIsAt == 2 && ptr == 1) document.images[c2cVolePoint].src="deskani5.gif"
if (c2cVoleIsAt == 0 && ptr == 0) var c2cVoleMovingTo=2
if (c2cVoleIsAt == 1 && ptr == 0) var c2cVoleMovingTo=2
if (c2cVoleIsAt == 2 && ptr == 0) var c2cVoleMovingTo=0
if (c2cVoleIsAt == 0 && ptr == 1) var c2cVoleMovingTo=1
if (c2cVoleIsAt == 1 && ptr == 1) var c2cVoleMovingTo=0
if (c2cVoleIsAt == 2 && ptr == 1) var c2cVoleMovingTo=1
c2cVoleIsAt = c2cVoleMovingTo
return 0
}

// place Avrey (the Vole's name) at his start position
function c2cSubWhereIsTheVole() {
var ptr = c2cOfficeTime.getMinutes()
c2cVoleIsAt = ptr % 3
var grt = unescape("%3e")
if (c2cVoleIsAt == 0) document.write('<img src="deskani0.gif" width="520" height="70" name="c2AvreyTheVole" border="0" valign="top" cellpadding="0" usemap=#desk' + grt)
if (c2cVoleIsAt == 1) document.write('<img src="deskani7.gif" width="520" height="70" name="c2AvreyTheVole" border="0" valign="top" cellpadding="0" usemap=#desk' + grt)
if (c2cVoleIsAt == 2) document.write('<img src="deskani0.gif" width="520" height="70" name="c2AvreyTheVole" border="0" valign="top" cellpadding="0" usemap=#desk' + grt)
// 0 is in-box, 1 is center of desk, 2 is nestbox
return 0
}

function c2cSubShowZuluTime() {
c2cOfficeTime = new Date()
var tzt = (c2cOfficeTime.getTimezoneOffset() / 60)
c2cOfficeTime.setHours(c2cOfficeTime.getHours() + tzt)
var hrs = c2cOfficeTime.getHours()
var min = c2cOfficeTime.getMinutes()
c2sub7SegReadout(0,min,hrs,1,4)
// set the time-slicing so the clock runs 1 in 4, the security monitor runs 2 in 4, and the news ticker runs 4 in 4.
c2cSubSecMonScanStep()
c2subBajGlyphScrollUp()
setTimeout("c2cTickSlice1()",300)
}

function c2cTickSlice1(){
c2subBajGlyphScrollUp()
setTimeout("c2cTickSlice2()",300)
}

function c2cTickSlice2(){
c2cSubSecMonScanStep()
c2subBajGlyphScrollUp()
setTimeout("c2cTickSlice3()",300)
}

function c2cTickSlice3(){
c2subBajGlyphScrollUp()
setTimeout("c2cSubShowZuluTime()",300)
}


