// Random image function for ADA and You
function random_ADA(){
  var myimages=new Array()
  myimages[1]="img/ada01_1.jpg"
  myimages[2]="img/ada01_2.jpg"

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<img src="'+myimages[ry]+'">')
}
// Random image function for Managing D
function random_MAN(){
  var myimages=new Array()
  myimages[1]="img/man01_1.jpg"
  myimages[2]="img/man01_2.jpg"

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<img src="'+myimages[ry]+'">')
}
// Random image function for Why Me?
function random_WHY(){
  var myimages=new Array()
  myimages[1]="img/why01_1.jpg"
  myimages[2]="img/why01_2.jpg"

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<img src="'+myimages[ry]+'">')
}
// Random image function for Tesch West
function random_TESCHWEST(){
  var myimages=new Array()
  myimages[1]="img/tw_01.jpg"
  myimages[2]="img/tw_02.jpg"
  myimages[3]="img/tw_03.jpg"

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<img src="'+myimages[ry]+'">')
}
// Random image function for Chris Stokes
function random_CHRISSTOKES(){
  var myimages=new Array()
  myimages[1]="img/cs_01.jpg"
  myimages[2]="img/cs_02.jpg"
  myimages[3]="img/cs_03.jpg"

  var ry=Math.floor(Math.random()*myimages.length)

  if (ry==0)
     ry=1
     document.write('<img src="'+myimages[ry]+'">')
}
// Popup function for popup windows that need to be resized
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// scrolling down to anchor links and
// highlighting anchor links
Event.observe(window, 'load', function() {
		myhighlighter = new AnchorHighlighter('a.anchorlink', 'li.anchor', '#ffffff', '#93c630', '#000000', '#ffffff');
		$$('li .back-to-top', 'div .back-to-top').each(function(element) {
		element.observe('click', function(event) {
		  new Effect.ScrollTo('top');
		  Event.stop(event);
		}.bindAsEventListener(element))
		})
	}
);

AnchorHighlighter = Class.create();
AnchorHighlighter.prototype = {
	lastAnchor: null,
				
	initialize: function(linkclass, anchorclass, startcolor, endcolor, startfont, endfont) {
		this.anchors = $$(anchorclass);
		this.startcolor = startcolor;
		this.endcolor = endcolor;
		this.startfont = startfont;
		this.endfont = endfont;
		
		$$(linkclass).each(function(e) {
			Event.observe(e, 'click', this.highlight.bindAsEventListener(this));
		}.bind(this));				
	},
	
	highlight: function(event) {
		var element = $(Event.element(event));
                var name = element.href.substr(element.href.indexOf('#')+1);

		this.anchors.each(function(e) {
			if(e.id == name)
			{
				if(this.lastAnchor != null && this.lastAnchor.id != e.id)
				{
					this.lastAnchor.setStyle({color: this.startfont});							
					var oldchange = new Effect.Highlight(this.lastAnchor, {startcolor: this.endcolor, endcolor: this.startcolor, restorecolor: this.startcolor});
				}
				
				e.setStyle({color: this.endfont});
                var scroller = new Effect.ScrollTo(e.id, {duration: .6, offset: -20});
				var newchange = new Effect.Highlight(e, {startcolor: this.startcolor, endcolor: this.endcolor, restorecolor: this.endcolor});
									
				this.lastAnchor = e;
				delete newchange;
				delete oldchange;
                delete scroller;
				throw $break;
			}
		}.bind(this));
         Event.stop(event);
	}			
};



// This function loads the definied functions on page load
function init() {

}