// // *************************************************************** // The following DHTML code demonstrates the cool things one can do with // javascript. The code is used to execute the: moving spotlight, // text snake, countdown, fading screen, and popup windows. // *************************************************************** var N = (document.layers) ? true : false; var IE = (document.all) ? true : false; var HEXADECNUM = new Array(HEX_SIZE); var TEXTPOSX = new Array(); var TEXTPOSY = new Array(); var TEXTMSG = new String('Worry ...'); var ENDDATE = new Date('Jan 1, 2002'); var TARGMS = ENDDATE.getTime(); var COUNTID, SPOTID, STRINGID; var X, Y; var PAGEWIDTH, PAGEHEIGHT; var TEXTLEN; var HEX_SIZE = 16; function StartUp() { CountDownInit(); StringInit(); SpotInit(); FadeInit(); } function FadeInit() { ScreenFade(255, 255, 255, 0, 0, 0, 20); } function CountDownInit() { var sScreenTimer = new String(); var oTimer = new Object(); var dtNow = new Date(); var iNowMs = dtNow.getTime(); var iDaysLeft = parseInt((TARGMS - iNowMs) / 86400000); var iHoursLeft = 23 - dtNow.getHours(); var iMinLeft = 59 - dtNow.getMinutes(); var iSecLeft = 59 - dtNow.getSeconds(); sScreenTimer = 'There are ' + iDaysLeft + ' Days remaining. (' + iDaysLeft + ':' + iHoursLeft + ':' + iMinLeft + ':' + iSecLeft + ')' sScreenTimer = '<CENTER><FONT SIZE=6 COLOR=#00FF00><B>' + sScreenTimer + '</B></FONT></CENTER>'; if (IE) { document.all['divTimer'].innerHTML = sScreenTimer; } else { oTimer = document.divBody.document.divTimer.document; oTimer.open(); oTimer.write(sScreenTimer); oTimer.close(); } COUNTID = setTimeout('CountDownInit()', 1000); } function SpotInit() { PAGEWIDTH = (N) ? innerWidth : document.body.offsetWidth; PAGEHEIGHT = (N) ? innerHeight : document.body.offsetHeight; oBody = new MakeDivObj('divBody'); oBody.DivClip(0, 0, 0, 0); if (IE) { oBody.oDivObj.width = PAGEWIDTH + 10; oBody.oDivObj.height = PAGEHEIGHT + 20; } oCircle = new MakeDivObj('divCircle', 'divBody'); oCircle.oDivObj.visibility = 'visible'; if (N) document.captureEvents(Event.MOUSEMOVE | Event.CLICK); document.onmousemove = MoveCircle; document.onclick = DisplayBody; } function HexConvert(iNumber) { var HexString = new String('00'); if (iNumber >= 255) { sHexString = 'ff'; } else { sHexString = '' + HEXADECNUM[(Math.floor(iNumber / HEX_SIZE))] + HEXADECNUM[(iNumber % HEX_SIZE)]; } return sHexString; } function ScreenFade(iStartRed, iStartGreen, iStartBlue, iStopRed, iStopGreen, iStopBlue, iStep) { var oFloor = Math.floor; var sHexRed = new String; var sHexGreen = new String; var sHexBlue = new String; var i, iBeginStep, iEndStep; for(i = 0; i < 10; i++) { HEXADECNUM[i] = i; } HEXADECNUM[10] = 'a'; HEXADECNUM[11] = 'b'; HEXADECNUM[12] = 'c'; HEXADECNUM[13] = 'd'; HEXADECNUM[14] = 'e'; HEXADECNUM[15] = 'f'; for(i = 0; i <= iStep; i++) { iBeginStep = ((iStep - i) / iStep); iEndStep = (i / iStep); sHexRed = HexConvert(oFloor(iStartRed * iBeginStep + iStopRed * iEndStep)); sHexGreen = HexConvert(oFloor(iStartGreen * iBeginStep + iStopGreen * iEndStep)); sHexBlue = HexConvert(oFloor(iStartBlue * iBeginStep + iStopBlue * iEndStep)); document.bgColor = '#' + sHexRed + sHexGreen + sHexBlue; } } function MakeDivObj(sDivObj, sNestDivObj) { sNestDivObj = (!sNestDivObj) ? '' : 'document.' + sNestDivObj + '.'; this.oDivObj = (N) ? eval(sNestDivObj + 'document.' + sDivObj) : eval('document.all.' + sDivObj + '.style'); this.DivExpand = FuncDivExpand; this.DivExpandClip = FuncDivExpandClip; this.DivClip = FuncDivClip; this.Obj = sDivObj + 'Object'; eval(this.Obj + '=this'); return this; } function FuncDivClip(iTop, iRight, iBottom, iLeft) { if (N) { this.oDivObj.clip.top = iTop; this.oDivObj.clip.right = iRight; this.oDivObj.clip.bottom = iBottom; this.oDivObj.clip.left = iLeft; } else { this.oDivObj.clip = 'rect(' + iTop + ',' + iRight + ',' + iBottom + ',' + iLeft + ')'; } } function FuncDivExpandClip(iTop, iRight, iBottom, iLeft, iTopInc, iRightInc, iBottomInc, iLeftInc, iIncStart, iIncStop) { iTop = iTop + iTopInc; iRight = iRight + iRightInc; iBottom = iBottom + iBottomInc; iLeft = iLeft + iLeftInc; this.DivClip(iTop, iRight, iBottom, iLeft); if (iIncStop < iIncStart) { iIncStop++; this.divshowing = true; SPOTID = setTimeout(this.Obj + '.DivExpandClip(' + iTop + ',' + iRight + ',' + iBottom + ',' + iLeft + ',' + iTopInc + ',' + iRightInc + ',' + iBottomInc + ',' + iLeftInc + ',' + iIncStart + ',' + iIncStop + ')', 50); } else { this.divshowing = false; } } function FuncDivExpand(iTopEnd, iRightEnd, iBottomEnd, iLeftEnd, iInc) { var i, iMaxInc; var aClipVal = new Array(); if (N) { aClipVal[0] = this.oDivObj.clip.top; aClipVal[1] = this.oDivObj.clip.right; aClipVal[2] = this.oDivObj.clip.bottom; aClipVal[3] = this.oDivObj.clip.left; } else { aClipVal = this.oDivObj.clip; aClipVal = aClipVal.slice(5, aClipVal.length - 1); aClipVal = aClipVal.split(' '); for (i = 0; i < 4; i++) { aClipVal[i] = parseInt(aClipVal[i]); } } iMaxInc = Math.max( Math.max(Math.abs((iTopEnd - aClipVal[0]) / iInc), Math.abs((iRightEnd - aClipVal[1]) / iInc)), Math.max(Math.abs((iBottomEnd - aClipVal[2]) / iInc), Math.abs((iLeftEnd - aClipVal[3]) / iInc)) ); if (!this.divshowing) { this.DivExpandClip( aClipVal[0], aClipVal[1], aClipVal[2], aClipVal[3], (iTopEnd - aClipVal[0]) / iMaxInc, (iRightEnd - aClipVal[1]) / iMaxInc, (iBottomEnd - aClipVal[2]) / iMaxInc, (iLeftEnd - aClipVal[3]) / iMaxInc, iMaxInc, 0); } } function MoveCircle(e) { var iOffset = 100; X = (N) ? e.pageX : event.x; Y = (N) ? e.pageY : event.y; oBody.DivClip(Y - iOffset, X + iOffset, Y + iOffset, X - iOffset); oCircle.oDivObj.left = X - iOffset; oCircle.oDivObj.top = Y - iOffset; } function DisplayBody() { if (N) document.releaseEvents(Event.MOUSEMOVE | Event.CLICK); document.onmousemove = null; document.onclick = null; oCircle.oDivObj.visibility = 'hidden'; oBody.DivExpand(-20, PAGEWIDTH + 20, PAGEHEIGHT + 30, -20, 20); if (N) document.captureEvents(Event.MOUSEMOVE); document.onmousemove = MouseMoveEventCall; if (IE) document.all['divCircle'].blur(); oPopUp = new MakeDivObj('divLink', 'divBody'); oPopUp.showing = false; oMsgString = new MakeDivObj('divTxtStr', 'divBody'); oMsgString.showing = false; FollowString(); oMsgString.showing = true; return true; } function MouseMoveEventCall(e) { if (oPopUp.showing || oMsgString.showing) { X = (N) ? e.pageX : document.body.scrollLeft + event.clientX; Y = (N) ? e.pageY : document.body.scrollTop + event.clientY; oPopUp.oDivObj.left = X + 10; oPopUp.oDivObj.top = Y + 10; } } function DisplayPopUp(sTitle, sText) { sHtmlTxt = new String("<TABLE WIDTH=100 BORDER=0 CELLPADDING=1 CELLSPACING=0 BGCOLOR='#800080'><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><SPAN ID='spanPopUp'><B><FONT COLOR='#FFFFFF'>" + sTitle + "</FONT></B></SPAN></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR='#CCCCFF'><TR><TD><SPAN ID='spanPopUp'><FONT COLOR='#000000'>" + sText + "</FONT><SPAN></TD></TR></TABLE></TD></TR></TABLE>"); if (N) { oPopUp.oDivObj.document.open(); oPopUp.oDivObj.document.write(sHtmlTxt); oPopUp.oDivObj.document.close(); } else { document.all['divLink'].innerHTML = sHtmlTxt; } oPopUp.showing = true; oPopUp.oDivObj.visibility = 'visible'; return true; } function HidePopUp() { oPopUp.showing = false; oPopUp.oDivObj.visibility = 'hidden'; return true; } function StringInit() { sHtmlTxt = new String(""); var i; TEXTLEN = TEXTMSG.length; TEXTMSG = TEXTMSG.split(''); for (i = 0; i <= TEXTLEN; i++) { TEXTPOSX[i] = -50; } for (i = 0; i <= TEXTLEN; i++) { TEXTPOSY[i] = -50; } for (i = 0; i <= TEXTLEN; i++) { sHtmlTxt = sHtmlTxt + "<SPAN ID='spanTxtMsg" + i + "' CLASS='spanTxtStr'>" + TEXTMSG[i] + "</SPAN>"; } if (N) { oMsgString.oDivObj.document.open(); oMsgString.oDivObj.document.write(sHtmlTxt); oMsgString.oDivObj.document.close(); } else { document.all['divTxtStr'].innerHTML = sHtmlTxt; } } function FollowString() { var oTextString = new Object(); var iTextInc = 20; var i; if (oMsgString.showing) { for (i = TEXTLEN; i >= 1; i--) { TEXTPOSX[i] = TEXTPOSX[i-1] + iTextInc; TEXTPOSY[i] = TEXTPOSY[i-1]; } TEXTPOSX[0] = X + iTextInc; TEXTPOSY[0] = Y; if (IE) { for (i = 0; i < TEXTLEN; i++) { oTextString = eval('spanTxtMsg' + i + '.style'); oTextString.posLeft = TEXTPOSX[i]; oTextString.posTop = TEXTPOSY[i]; } } else { for (i = 0; i < TEXTLEN; i++) { oTextString = eval('document.spanTxtMsg' + i); oTextString.left = TEXTPOSX[i]; oTextString.top = TEXTPOSY[i]; } } } STRINGID = setTimeout('FollowString()', 30); } function CloseWin() { if (N) document.releaseEvents(Event.MOUSEMOVE | Event.CLICK); document.onmousemove = null; document.onclick = null; clearTimeout(COUNTID); clearTimeout(SPOTID); clearTimeout(STRINGID); } //