/* Created by Ian Archambeau 09/08/09 PLEASE ONLY MODIFY INBETWEEN THE BRACKETS ON LINE 5 as this changes initial content which is shown! */

window.addEvent('load', function() {

initialContent(0); /* Sets the initial default content shown 0 being first, 1 being second etc */
$('portlist').getElements('.listing').addEvent('mouseenter', function(){
												removeStyle(); /* Remove previous actives background */
												this.setStyles({
													background: 'url(images/liactive.jpg) no-repeat',
													color: '#fff'
												});
												place = findPlace(this.get('html')); /* Finds the place of the listing and displays the appropriate content div */
												findContent(place);
												
												});
});

function initialContent(i) {
	stopScroll(); /* Prevents browser from expanding to the full size of images! */
	setActive(i);
	findContent(i);
	
}

function removeStyle() {
	$('portlist').getElements('.listing').setStyles({
													background: 'none',
													color: '#cdcdcd'
												});
}

function findPlace(searchString) {
	var theList = $$('.listing');
	for(i=0;i<theList.length;i++)
	{
		if (theList[i].get('html') == searchString)
		{
			return i;
		}
	}
}

function setActive(i) {
	var theList = $$('.listing');
	theList[i].setStyles({
													background: 'url(images/liactive.jpg) no-repeat',
													color: '#fff'
					  });
}

function findContent(searchString) {
	var portList = $$('.showcase');
	var slideOut = new Fx.Slide('test');
	$('test').set('html', portList[searchString].get('html'));
	slideOut.slideIn();
	

}

function stopScroll() {
	var theList = $$('.showcase');
	for(i=0;i<theList.length;i++)
	{
		var slideIt = new Fx.Slide(theList[i]);
		slideIt.hide();
	}
}