//getting the page name for a variable
var tr = window.location.pathname
len = tr.length
rs = 0
for (i = len; i > 0; i--) {
vb = tr.substring(i,i+1)
if (vb == "/" && rs == 0) {
var sPage =  tr.substring(i+1,len);
if (sPage == "") sPage = "default.htm";
rs = 1
}
}

//Fade in headers - original code courtesy of TwinHelix www.twinhelix.com (I tweaked it a bit...)
// An array of colours that will be applied to H1 tags.
var h1Cols = ['#FFFFFF', '#FDFAE8', '#F9F1C6', '#F5E9A0', '#F2E07B', '#EED752'];

// Main script.
var h1Arr = [];
function h1Setup()
{
 h1Arr = document.getElementsByTagName('h1');
 for (var h = 0; h < h1Arr.length; h++)
 {
  var h1 = h1Arr[h], text = h1.firstChild.nodeValue;
  h1.removeChild(h1.firstChild);
  h1.animNodes = [];
  for (var i = 0; i < text.length; i++)
  {
   var span = document.createElement('span');
   span.appendChild(document.createTextNode(text.substring(i, i+1)));
   h1.appendChild(span);
   h1.animNodes[h1.animNodes.length] = span;
  }
  h1.animCount = 0;
  h1.animTimer = setInterval('h1Anim(' + h + ')', 50);
 }
};
function h1Anim(h)
{
 var h1 = h1Arr[h], c = h1.animCount++, noAnim = 1;
 for (var i = 0; i < h1.animNodes.length; i++)
 {
  var s = h1.animNodes[i], frac = Math.max(0, Math.min(1, (c-i)/10)),
   marg = document.all && !window.opera ? 'marginRight' : 'marginLeft';
  if (s.animDone) continue;
  noAnim = 0;
  s.style.color = h1Cols[Math.floor(frac * h1Cols.length)];
  if (frac == 1)
  {
   s.style[marg] = '0';
   s.animDone = 1;
  }
  else s.style[marg] = 0.6*(1-frac) + 'em';
 }
 if (noAnim) clearInterval(h1.animTimer);
 h1.style.visibility = 'inherit';
};
//this is populating onLoad in the body tag
if (document.documentElement)
{
 // Hide H1 elements for animation and trigger show on load.
 document.write('<style type="text/css"> h1 { visibility: hidden } </style>');
 var h1aOL = window.onload;
 window.onload = function()
 {
  if (h1aOL) h1aOL();
  h1Setup();
  if (sPage == "portfolio.htm") {Next(1,number)};
  currentpage();
 }
}

//the details of the navigation links
var blank = "&nbsp;<br>&nbsp;"
function dynamictext(text) {
//document.getElementById("hosting").title=text
document.getElementById('details').innerHTML = text;
//thing = hosting.getAttribute("title");
}


//changes the class of the link to the current page 
function currentpage() {
if (sPage != "default.htm") {
document.getElementById(sPage).className="current";
}}

function rollon(element) {
if (element != sPage) {
document.getElementById(element).className="navroll";
}}

function rollout(element) {
if (element != sPage) {
document.getElementById(element).className="nav";
}}

function display_page(url) {
  window.open(url,'Anti', 'toolbar=no,status=no,width=720,height=650,scrollbars=yes')
}

//random image script for circle pics for pages other than the home page
DolphinSmall = new Array(
  "http://www.smartdolphins.com/images/circles/smaller/jesse.jpg",
  "http://www.smartdolphins.com/images/circles/smaller/claude.jpg",
  "http://www.smartdolphins.com/images/circles/smaller/adrian.jpg",
  "http://www.smartdolphins.com/images/circles/smaller/dave.jpg"
)
function RandomImageSmall(howMany) {
  if (howMany > 3){howMany = 3} //no more than 3 will be displayed
  RandomNumber = Math.floor(Math.random()*DolphinSmall.length)
  ImageOne = DolphinSmall[RandomNumber]
  ImageTwo = DolphinSmall[RandomNumber-1]
  ImageThree = DolphinSmall[RandomNumber+1]
  if (RandomNumber < 1 ) {
  ImageTwo = DolphinSmall[RandomNumber+1]
  ImageThree = DolphinSmall[RandomNumber+2]
  }
  if (RandomNumber > (DolphinSmall.length-2) ) {
  ImageTwo = DolphinSmall[RandomNumber-1]
  ImageThree = DolphinSmall[RandomNumber-2]
  }
  ImageText = "<img src='" + ImageOne + "' alt='' border='0' width='130' height='130'>"
  if (howMany == 2) {
  ImageText = "<img src='" + ImageOne + "' alt='' border='0' width='130' height='130'><br><br><img src='" + ImageTwo + "' alt='' border='0' width='130' height='130'>"
  }
  if (howMany == 3) {
  ImageText = "<img src='" + ImageOne + "' alt='' border='0' width='130' height='130'><br><br><img src='" + ImageTwo + "' alt='' border='0' width='130' height='130'><br><br><img src='" + ImageThree + "' alt='' border='0' width='130' height='130'>"
  }
  return ImageText
}
DolphinLarge = new Array(
  "http://www.smartdolphins.com/images/circles/adrian.jpg",
  "http://www.smartdolphins.com/images/circles/claude.jpg",
  "http://www.smartdolphins.com/images/circles/jesse.jpg",
  "http://www.smartdolphins.com/images/circles/dave.jpg"
)
function RandomImageLarge() {
  RandomNumber = Math.floor(Math.random()*DolphinLarge.length)
  ImageOne = DolphinLarge[RandomNumber]
  ImageTwo = DolphinLarge[RandomNumber-1]
  ImageThree = DolphinLarge[RandomNumber+1]
  if (RandomNumber < 1 ) {
  ImageTwo = DolphinLarge[RandomNumber+1]
  ImageThree = DolphinLarge[RandomNumber+2]
  }
  if (RandomNumber > (DolphinLarge.length-2) ) {
  ImageTwo = DolphinLarge[RandomNumber-1]
  ImageThree = DolphinLarge[RandomNumber-2]
  }
  tabletext = "<table width='200' border='0' align='right' cellpadding='0' cellspacing='0'><tr> <td><img src='" + ImageOne + "' alt='' border='0' width='150' height='150'></td></tr><tr> <td align='right' valign='middle'><img src='" + ImageTwo + "' alt='' border='0' width='150' height='150'><img src='images/spacer.gif' width='8' height='10'></td></tr><tr> <td valign='top'><img src='" + ImageThree + "' alt='' border='0' width='150' height='150'></td></tr></table>"
  return tabletext
}

