
// contains js for use sitewide

window.addEvent('domready',function() {

	// setup the home page slideshow
	if($("homeslide")) { var myShow = new Slideshow("homeslide", null, { delay: 4000, duration: 2000, captions: false, controller: false, loader:true }); }


	// runs the equal heights function.
	equalHeights();

	$$('ul.links>li').each(function(el) { 
		
		//Adding MouseOver Event
		el.addEvent('mouseover', function(e) {
			
			if(!this.hasClass('divider')) {
			
				// setup variables to hold the chosen li.divider
				var p = this.getPrevious('li.divider');
				var n = this.getNext('li.divider');
				
				// change the background image if there is a previous li.divider
				if(p) { this.getPrevious('li.divider').setStyle('background-image','url(images/bg-divider-right.png)'); }
				
				// change the background image if there is a next li.divider
				if(n) { this.getNext('li.divider').setStyle('background-image','url(images/bg-divider-left.png)'); }
				
				this.setStyle('background-color','#FFFFFF');
				this.getLast('a').setStyle('color','#BE1E2D');
								
			}
			
		});

			//Adding MouseOut Event
		el.addEvent('mouseout', function(e) {
			
			if(!this.hasClass('divider')) {
			
				var p = this.getPrevious('li.divider');
				var n = this.getNext('li.divider');
							
				// change the background image if there is a previous li.divider
				if(p) { 
					this.getPrevious('li.divider').setStyle('background-image',p.hasClass('first') ? 'none' : 'url(images/bg-divider.png)'); 
				}
				
				// change the background image if there is a next li.divider
				if(n) { 
					this.getNext('li.divider').setStyle('background-image',n.hasClass('last') ? 'none' : 'url(images/bg-divider.png)'); 
				}
								
				this.setStyle('background-color','transparent');
				this.getLast('a').setStyle('color','#FFFFFF');
				
			}

		});		
			
	});

});	

// sorts out the heights of the boxes on the home page
// and makes them equal height should they not be!	
function equalHeights() {
var height = 0;

divs = $$('.boxleft','.boxright');
 
divs.each( function(e){
 if (e.offsetHeight > height){
  height = e.offsetHeight;
 }
});
 
divs.each( function(e){
 e.setStyle( 'height', height + 'px' );
 if (e.offsetHeight > height) {
  e.setStyle( 'height', (height - (e.offsetHeight - height)) + 'px' );
 }
}); 
}

