// JavaScript Document



function slideShow(slide_num, slide_elem) {
	//for loops through all <li> within ul#slide_names
	for(var i = 0; i < slide_elem.parentNode.parentNode.childNodes.length; i++) 
	{	
		//if the <li> has any classes attached to it...
		if(slide_elem.parentNode.parentNode.childNodes[i].className) 
		{
			//the classes attached to the <li> are removed...
			slide_elem.parentNode.parentNode.childNodes[i].className = slide_elem.parentNode.parentNode.childNodes[i].className.replace(/ active/g, "");
		}
	}
	//the <li> sent to function is given the class "active"
	slide_elem.parentNode.className += " active";
	//creates a variable out of the div#slides containing the actual images, the first <ul> within the div
	var obj = document.getElementById("slides");
	//if the <ul> has a margin not equal to zero...
	if(obj.style.marginLeft != 0) 
	{	
		//the left margin assigned to <ul> is saved as an integer
		var x = parseInt(obj.style.marginLeft.replace(/px/g, "")); 
		//that left margin is then reversed to be made the positive of the same magnitude
		x = -x;
	}
	else //if the left margin equals zero
	{	
		//the left margin is saved
		var x = obj.style.marginLeft;
	}
	//the slide_number is lessened by one increment so that the left margin will take it to the far left of the slide rather than the far right
	--slide_num;
	//a variable is created which is the slide_number times the width of one slide - this is where the left margin SHOULD be set
	var newx = slide_num*530;
	//the current left margin and the new left margin is sent to slideIt function
	slideIt(x, newx);
}

function slideIt(x, newx) //inspired by Jeremy Keith - www.adactio.com
{ 
	//if the new left margin is greater than the old left margin
	if (newx > x) 
	{
		//x is updated to be incrementally moved closer to newx
		x += Math.ceil((newx-x)/2);
	}
	//if the new left margin is less than the old left margin
	else if (newx < x) 
	{	
		//x is updated to be incrementally moved closer to newx
		x += Math.floor((newx-x)/2);
	}
	//if the new margin and the old margin are the same
	else if (newx == x) 
	{
		//the process is complete and the function will stop
		return true;
	}
	//the first ul in the #slides div is updated to reflect a new left margin in pixels (which is the negative of x)
	var obj = document.getElementById("slides").style.marginLeft = -x + 'px';
	//the function is repeated until the x reaches the newx
	var time = setTimeout('slideIt('+x+', '+newx+')', 75);
}