<!--

// Global functions

document.getElementsByClassName=function(cl)
  {
    var retnode = [];
    var myclass = new RegExp('\\b'+cl+'\\b');
    var elem = this.getElementsByTagName('*');

    for (var i = 0; i < elem.length; i++)
      {
        var classes = elem[i].className;

        if (myclass.test(classes))
          retnode.push(elem[i]);
      }
    return retnode;
  }

// Load Timer

var startTime=new Date();

function FixPrecision(num)
  {
    var stringNum = String(num);

    if (stringNum.indexOf('.')==-1)
      return stringNum+'.00';

    var newNum = stringNum.split('.');

    newNum[1]=(newNum[1].length>2)?newNum[1].subString(0,2):newNum[1];

    if (newNum[1].length==1)
      newNum[1]+="0"

    return newNum[0]+'.'+newNum[1];
  }

function StopTime()
  {
    var a=FixPrecision((new Date()-startTime)/1000);

    document.getElementById("endTime").innerHTML=a;
  }

window.onload = StopTime;

// Rainbow and Wave Text

function toSpans(span) {
  var str=span.firstChild.data;
  var a=str.length;
  span.removeChild(span.firstChild);
  for(var i=0; i<a; i++) {
    var theSpan=document.createElement("SPAN");
    theSpan.appendChild(document.createTextNode(str.charAt(i)));
    span.appendChild(theSpan);
  }
}

// Rainbow

function RainbowSpan(span, hue, deg, brt, spd, hspd) {
    this.deg=(deg==null?360:Math.abs(deg));
    this.hue=(hue==null?0:Math.abs(hue)%360);
    this.hspd=(hspd==null?3:Math.abs(hspd)%360);
    this.length=span.firstChild.data.length;
    this.span=span;
    this.speed=(spd==null?50:Math.abs(spd));
    this.hInc=this.deg/this.length;
    this.brt=(brt==null?255:Math.abs(brt)%256);
    this.timer=null;
    toSpans(span);
    this.moveRainbow();
}

RainbowSpan.prototype.moveRainbow = function() {
  if(this.hue>359) this.hue-=360;
  var color;
  var b=this.brt;
  var a=this.length;
  var h=this.hue;

  for(var i=0; i<a; i++) {

    if(h>359) h-=360;

    if(h<60) { color=Math.floor(((h)/60)*b); red=b;grn=color;blu=0; }
    else if(h<120) { color=Math.floor(((h-60)/60)*b); red=b-color;grn=b;blu=0; }
    else if(h<180) { color=Math.floor(((h-120)/60)*b); red=0;grn=b;blu=color; }
    else if(h<240) { color=Math.floor(((h-180)/60)*b); red=0;grn=b-color;blu=b; }
    else if(h<300) { color=Math.floor(((h-240)/60)*b); red=color;grn=0;blu=b; }
    else { color=Math.floor(((h-300)/60)*b); red=b;grn=0;blu=b-color; }

    h+=this.hInc;

    this.span.childNodes[i].style.color="rgb("+red+", "+grn+", "+blu+")";
  }
  this.hue+=this.hspd;
}

// WaveText
// I built the WaveText functions modeled after the Rainbow ones - RAPMD

function WaveTextSpan(span, dir, min, max, spd)
  {
    this.min=(min==null?5:Math.abs(min));
    this.max=(max==null?72:Math.abs(max));
    this.dir=(dir==null?1:Math.abs(dir));
    this.fact=Math.abs(dir);
    this.length=span.firstChild.data.length;
    this.span=span;
    this.speed=(spd==null?50:Math.abs(spd));
    this.timer=null;

    toSpans(span);
    this.moveWaveText();
  }

WaveTextSpan.prototype.moveWaveText = function()
  {
    var a=this.length;
    var s, d;

    s=(this.span.childNodes[0].style.fontSize)?parseInt(this.span.childNodes[0].style.fontSize):this.min+1;

    if(s<=this.min)
      this.dir=this.fact;
    else
      {
        if(s>=this.max)
          this.dir=-this.fact;
      }

    d=this.dir;

    for(var i=0; i<a; i++) {
      if(s<=this.min)
        d=this.fact;
      else
        {
          if(s>=this.max)
            d=-this.fact;
        }

      s+=d;

      this.span.childNodes[i].style.fontSize=s+'px';
    }
  }

// Image viewer with menu

var current = 0;

function next()
  {
    if (document.slideform.slide[current+1])
      {
        document.images.show.src = document.slideform.slide[current+1].value;
        document.slideform.slide.selectedIndex = ++current;
      }
    else
      first();
  }

function previous()
  {
    if (current-1 >= 0)
      {
        document.images.show.src = document.slideform.slide[current-1].value;
        document.slideform.slide.selectedIndex = --current;
      }
    else
      last();
  }

function first()
  {
    current = 0;
    document.images.show.src = document.slideform.slide[0].value;
    document.slideform.slide.selectedIndex = 0;
  }

function last()
  {
    current = document.slideform.slide.length-1;
    document.images.show.src = document.slideform.slide[current].value;
    document.slideform.slide.selectedIndex = current;
  }

function change()
  {
    current = document.slideform.slide.selectedIndex;
    document.images.show.src = document.slideform.slide[current].value;
  }

// Content Rotation

function RotateContent(rt, delay, idx, first)
  {
    var Divs;
    var rc=idx;

    Divs=document.getElementsByClassName(rt);

    if(first==0)
      {
        for(var i=rc+1;i<Divs.length;i++)
          Divs[i].style.display="none";
      }

    Divs[rc].style.display="none";

    rc++;

    if(rc==Divs.length)
      rc=0;

    Divs[rc].style.display="inline";

    setTimeout(function () { RotateContent(rt, delay, rc, 1); } , delay);
  }

// Count characters left in text area for comments

function CountCharacters(Cmt,Cnt,size)
  {
    var count=document.getElementById(Cnt);
    var ta=document.getElementById(Cmt);
    var sc=document.getElementById('ShowComment');
    var a;

    if (ta.value.length>size)
      ta.value=ta.value.substring(0,size);

    a=String(size-ta.value.length);
    count.innerHTML=a;

    if(a<Cnt)
      {
        sc.innerHTML=ta.value.replace(/\s?\r?\n\r?\n+/g,'<p>').
            replace(/(\<\/?)script/g,"$1noscript");
      }
    else
      sc.innerHTML='Nothing to preview...';
  }

// Reset Comment Form

function CommentResetForm()
  {
    document.getElementById("CommentForm").reset();

    CountCharacters('Comment','CommentCounter',1048576);
  }

-->

