var blackPic="";       var blackBG="black";   var blackFG="white";
var blackLink="aqua";  var blackAL="red";     var blackVL="#FFFFFF";
var whitePic="";       var whiteBG="white";   var whiteFG="black";
var whiteLink="blue";  var whiteAL="red";     var whiteVL="purple";


function blackButton(path)
{
var temp='<a onClick="blackGround()"><img src="' +  path + 'whiteonblack.gif"></a>';
document.write(temp);
}

function whiteButton(path)
{
var temp='<a onClick="whiteGround()"><img src="' +  path + 'blackonwhite.gif"></a>';
document.write(temp);
}

function blackGround()
{
  document.body.background=blackPic;  document.bgColor=blackBG;
  document.fgColor=blackFG;           document.linkColor=blackLink;
  document.alinkColor=blackAL;        document.vlinkColor=blackVL;
}
function whiteGround()
{
  document.body.background=whitePic;  document.fgColor=whiteFG; 
  document.bgColor=whiteBG;           document.linkColor=whiteLink;      
  document.alinkColor=whiteAL;        document.vlinkColor=whiteVL;
}

function dice(dieNo, dieType)
{
var roll = 0;
var i = 0;
while (i<dieNo)
{
  i++;
  var randomno = Math.random();
  roll = roll + Math.round( (dieType-1) * randomno ) + 1;
}
return roll;
}

function ShowFileInfo(filespec)
{
  var fso, f, s;
//  fso = new ActiveXObject("Scripting.FileSystemObject");
  f = document.GetFile(filespec);
  s = "Created: " + f.DateCreated;
  return(s);
}


function makeLinkBar(linkBar)
{
var lb = linkBar
var splitInd = 0;
var thisLink;
while (splitInd > -1)
{
  splitInd = lb.search('~');
  document.write('<TD align="center"><font size="2">')
  thisLink = lb.slice(0, splitInd)
  lb = lb.slice( (splitInd+1), (lb.length-1) )
  document.write(thisLink)
  document.write('</font></TD>')
}
}

function randomRectLogoHor()
{
var roll = dice(1, 5);
if (roll ==  1)   {  return 'thumbs/ship-1.jpg'     }
if (roll ==  2)   {  return 'thumbs/ship-2.jpg'     }
if (roll ==  3)   {  return 'thumbs/ship-3.jpg'     }
if (roll ==  4)   {  return 'thumbs/ship-4.jpg'     }
if (roll ==  5)   {  return 'thumbs/space-3.jpg'    }
return '';
}

function randomSquareLogo()
{
var roll = dice(1, 14);
if (roll ==  1)   {  return 'thumbs/green-orb.jpg'  }
if (roll ==  2)   {  return 'thumbs/hover1-s.gif'   }
if (roll ==  3)   {  return 'thumbs/island.jpg'     }
if (roll ==  4)   {  return 'thumbs/orb1.jpg'       }
if (roll ==  5)   {  return 'thumbs/pa-logo.jpg'    }
if (roll ==  6)   {  return 'thumbs/skull1.jpg'     }
if (roll ==  7)   {  return 'thumbs/skull2.jpg'     }
if (roll ==  8)   {  return 'thumbs/skull3.jpg'     }
if (roll ==  9)   {  return 'thumbs/skull4.jpg'     }
if (roll == 10)   {  return 'thumbs/space-1.jpg'    }
if (roll == 11)   {  return 'thumbs/space-2.jpg'    }
if (roll == 12)   {  return 'thumbs/spheregrid.jpg' }
if (roll == 13)   {  return 'thumbs/spstat-1.jpg'   }
if (roll == 14)   {  return 'thumbs/spstat-1b.jpg'  }
return '';
}

function masthead(title, imgLoc, path, horConst, vertConst, legalText, linkBar, linkNo)
{
var lastUpdated;
var picPath = path + '../RikoGrafX/';                            var imageLoc = imgLoc;
if (imageLoc == 'RANDOM')  { imageLoc = randomSquareLogo() };    imageLoc = picPath + imageLoc;
document.write('<TABLE NAME="mastTable" BORDER="2" CELLPADDING="0" CELLSPACING="0"><TR>');
document.write('<TD ALIGN="right" rowspan="3">');
document.write('<img NAME="mastheadImg" src="' + imageLoc + '">');
document.write('</TD>');    document.write('<TD ALIGN="left" colspan="' + (linkNo+2) + '">');
document.write(title);      document.write('</TD>');       document.write('</TR><TR>');
document.write('<TD ALIGN="right" colspan="' + (linkNo+2) + '">');
document.write(legalText);
document.write('</TD>');   document.write('</TR><TR>');
document.write('<TD>');     blackButton(path);             document.write('</TD>');
makeLinkBar(linkBar);       document.write('<TD ALIGN="right">');    whiteButton(path);
document.write('</TD>');    document.write('</TR></TABLE>');         document.write('</TABLE>');
//Resize image
var hSize = mastheadImg.width;    var vSize = mastheadImg.height;
var hratio = hSize / vSize;       var vratio = vSize / hSize;
if ((horConst>0)&&(vertConst<1)) 
{  mastheadImg.width = horConst;    vSize = horConst * vSize / hSize;   mastheadImg.height = vSize; }
if ((horConst<1)&&(vertConst>0)) 
{   mastheadImg.height = vertConst;    mastheadImg.width = vertConst * hSize / vSize;  }
if ((horConst>0)&&(vertConst>0)) 
{   mastheadImg.height = vertConst;    mastheadImg.width = horConst;  }
}


function mastheadXR(title, imgLoc, path, horConst, vertConst, legalText, linkBar, linkNo)
{
var picPath = path + '../RikoGrafX/';
var imageLoc = imgLoc;
if (imageLoc == 'RANDOM')  { imageLoc = randomSquareLogo() }
//if (imageLoc == 'RANDOM')  { imageLoc = randomRectLogoHor() }
imageLoc = picPath + imageLoc;

document.write('<TABLE NAME="mastTable" BORDER="2" CELLPADDING="0" CELLSPACING="0"><TR>');
document.write('<TD ALIGN="right" rowspan="2">');
document.write('<img NAME="mastheadImg" src="' + imageLoc + '">');
document.write('</TD>');
document.write('<TD ALIGN="left" colspan="' + (linkNo+1) + '">');
document.write(title);
document.write('</TD>');
document.write('</TR><TR>');
document.write('<TD ALIGN="right" colspan="' + (linkNo+1) + '">');
document.write(legalText);
document.write('test</TD>');
document.write('</TR><TR>');
document.write('<TD>');
blackButton(path);
document.write('</TD>');
makeLinkBar(linkBar);
document.write('<TD ALIGN="right">');
whiteButton(path);
document.write('</TD>');
document.write('</TR></TABLE>');
document.write('</TABLE>');
//Resize image
var hSize = mastheadImg.width;
var vSize = mastheadImg.height;
var hratio = hSize / vSize;
var vratio = vSize / hSize;
if ((horConst>0)&&(vertConst<1)) 
{
  mastheadImg.width = horConst;
  vSize = horConst * vSize / hSize;
  mastheadImg.height = vSize;
}
if ((horConst<1)&&(vertConst>0)) 
{
  mastheadImg.height = vertConst;
  mastheadImg.width = vertConst * hSize / vSize;
}
if ((horConst>0)&&(vertConst>0)) 
{
  mastheadImg.height = vertConst;
  mastheadImg.width = horConst;
}
}
