function flyingStar(oindex) {
this.reset = function () {
var hAng = ( Math.PI / 2.1 ) * ( Math.random() - 0.5 ), vAng = ( Math.PI / 2.1 ) * ( Math.random() - 0.5 );
if( Math.abs( hAng ) < 0.02 && Math.abs( vAng ) < 0.02 ) { return false; }
this.x = 100 * Math.sin( hAng ) * Math.cos( vAng );
this.y = 100 * Math.cos( hAng ) * Math.cos( vAng );
this.z = 100 * Math.sin( vAng );
return true;
}
if( document.layers ) {
document.write( '<layer name="ostarNum'+oindex+'" height="1" width="1" bgcolor="#ffffff" left="0" top="0" clip="0,0,2,2"> </layer>' );
} else {
document.write( '<div id="ostarNum'+oindex+'" style="position:absolute;height:1px;width:1px;clip:rect(0px 2px 2px 0px);background-color:#ffffff;left:0px;top:0px;"></div>' );
}
}
function getRefToDivNest( divID, oDoc ) {
if( !oDoc ) { oDoc = document; }
if( document.layers ) {
if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
y = getRefToDivNest(divID,oDoc.layers[x].document); }
return y; } }
if( document.getElementById ) { return document.getElementById(divID); }
if( document.all ) { return document.all[divID]; }
return document[divID];
}
function moveStars() {
var getWidth = 0, getHeight = 0, getScrollHeight = 0, getScrollWidth = 0;
if( typeof( window.innerWidth ) == 'number' ) { getWidth = window.innerWidth; getHeight = window.innerHeight; } else {
if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
getWidth = document.documentElement.clientWidth; getHeight = document.documentElement.clientHeight; } else {
if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
getWidth = document.body.clientWidth; getHeight = document.body.clientHeight; } } }
if( typeof( window.pageYOffset ) == 'number' ) { getScrollHeight = pageYOffset; getScrollWidth = pageXOffset; } else {
if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { getScrollHeight = document.body.scrollTop; getScrollWidth = document.body.scrollLeft; } else {
if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { getScrollHeight = document.documentElement.scrollTop; getScrollWidth = document.documentElement.scrollLeft; } }
}
if( getHeight < 30 || getWidth < 30 ) { return; }
for( var x = 0; x < flyStarArray.length; x++ ) {
var theStar = getRefToDivNest('ostarNum'+x); if( !theStar ) { return; }
if( theStar.style ) { theStar = theStar.style; } var oPix = document.childNodes ? 'px' : 0;
do {
var tmpleft = Math.round( ( getWidth / 2 ) + ( ( ( getWidth > getHeight ) ? getWidth : getHeight ) * ( Math.atan( flyStarArray[x].x / flyStarArray[x].y ) / ( Math.PI / 2 ) ) ) );
var tmptop = Math.round( ( getHeight / 2 ) + ( ( ( getWidth > getHeight ) ? getWidth : getHeight ) * ( Math.atan( flyStarArray[x].z / flyStarArray[x].y ) / ( Math.PI / 2 ) ) ) );
} while( ( tmpleft < 0 || tmpleft > getWidth - 20 || tmptop < 0 || tmptop > getHeight - 30 ) && flyStarArray[x].reset() );
theStar.left = ( tmpleft + getScrollWidth ) + oPix; theStar.top = ( tmptop + getScrollHeight ) + oPix;
var oDist = Math.sqrt( Math.pow( flyStarArray[x].x, 2 ) + Math.pow( flyStarArray[x].y, 2 ) + Math.pow( flyStarArray[x].z, 2 ) );
oDist = ( oDist < 30 ) ? 3 : ( oDist < 60 ) ? 2 : 1; theStar.width = oDist + oPix; theStar.height = oDist + oPix; theStar.pixelWidth = oDist; theStar.pixelHeight = oDist;
if( theStar.clip && theStar.clip.bottom ) { theStar.clip.bottom = oDist; theStar.clip.right = oDist; } else { theStar.clip = 'rect( 0px ' + oDist + 'px ' + oDist + 'px 0px )'; }
flyStarArray[x].y -= 4;
}
}
var flyStarArray = [];
for( var x = 0; x < 30; x++ ) { flyStarArray[x] = new flyingStar(x); do { flyStarArray[x].reset(); } while( !flyStarArray[x].x ); }
window.setInterval('moveStars();',75);