function initNav()
{
	if (typeof document.body.style.maxHeight == 'undefined')
	{
		var nav = document.getElementById("main-nav");
		var lis = nav.getElementsByTagName("li");
		for (var i=0; i<lis.length; i++)
		{
			lis[i].onmouseover = function()
			{
				this.className += " hover";
			}
			lis[i].onmouseout = function()
			{
				this.className = this.className.replace(" hover", "");
			}
		}
	}
}

var slides;
var duration = 6000;
var all_slides = [];
var quotes = [];
var autoplay = true;
var current = 0;
function imgFadeSlide()
{
	if(document.getElementById('big-image'))
	{
		var temp = 0;
		all_slides = $$('#big-image li');
		quotes = $$('#quote-holder li');
		slides = all_slides.length;
		if(slides>1)
		{
			for(var i=0; i<slides; i++)
				all_slides[i].style.zIndex = 888-i;
			setTimeout('slideOff(' + 0 +')', duration);
			
			var all_thumbs = $$('#thumbnails li a');
			all_thumbs.each(function(el, i)
			{
				el.href = 'javascript:;';
				el.onclick = function()
				{
					autoplay = false;

					if(!temp++)
						$$(all_slides).fade(0);
					else
					{
						all_slides[current].fade(0);
						all_slides[i].style.zIndex = 900;
					}
					all_slides[i].fade(1);
					current = i;
					
					quotes.setStyle('display', 'none');
					quotes[i].setStyle('display', 'block');
				}
			;})
		}
	}
}
function slideOff(_index)
{
	if(autoplay)
	{
		all_slides[_index].fade(0);
		if(_index==slides-1)
			_index=-1;
		++_index;
		current = _index;
	
		quotes.setStyle('display', 'none');
		quotes[_index].setStyle('display', 'block');
		setTimeout('slideOn(' + _index + ')', 1000);
	}
}
function slideOn(_index)
{
	if(_index!=0)
		reset_z_index(_index-1);
	else
		reset_z_index(slides-1);
	setTimeout('slideOff(' + _index + ')', duration);
}
function reset_z_index(_index)
{
	all_slides[_index].style.zIndex = all_slides[_index].getStyle('z-index').toInt() - slides;
	all_slides[_index].fade(1);
}


if (window.addEventListener)
	window.addEventListener("load", imgFadeSlide, false);
else if (window.attachEvent)
{
	window.attachEvent("onload", imgFadeSlide);
	window.attachEvent("onload", initNav);
}
