/* This script makes the images on the homepage scroll in a loop */

var timer1;
var timer2;
var timer3;
var timer4;
var ch = 0;

var static_pos = Math.floor(Math.random()*7);
static_pos++;

var slider_pos;

if (static_pos == 7)
{
	slider_pos = 1;
}
else
{
	slider_pos = static_pos + 1;
}



function dothisnow()
{
roll2(); 		/* sets the static pic */
roll(); 		/* sets the slider pic */
		
timer1 = setTimeout('left()', 2000);
}

function change_static()
{
	if (static_pos == 7)
	{
		static_pos = 2;
	}
	else
	{
		if (static_pos == 6)
		{
			static_pos = 1;
		}
		else
		{
			static_pos = static_pos + 2;
		}
	}
}

function change_slider()
{
	if (slider_pos == 7)
	{
		slider_pos = 2;
	}
	else
	{
		if (slider_pos == 6)
		{
			slider_pos = 1;
		}
		else
		{
			slider_pos = slider_pos + 2;
		}
	}
}

function roll2()
{
	image = document.getElementById("static");
	string1 = "images/home/home_";
	string2 = static_pos;
	
	image.src = string1+string2+".png";
}

function roll()
{
	image = document.getElementById("slider");
	string1 = "images/home/home_";
	string2 = slider_pos;
	
	image.src = string1+string2+".png";
}

function left()
{	
	clearTimeout(timer4);
	
	timer2 = setTimeout("visible()", 100);
	
	if (ch == 0)
	{
		ch = 1;
		MM_effectSlide('slide_pic', 2500, '0%', '100%', true, true);
	}
	else
	{
		ch = 0;
		MM_effectSlide('slide_pic', 2500, '0%', '100%', true, true);
	}
	
	timer3 = setTimeout("swap()", 2500);
}

function swap()
{		
		if (ch == 1)
		{
			change_static();
			roll2();
		}
		else
		{
			change_slider();
			roll();
		}
		
		timer4 = setTimeout('left()', 2000);
}

function visible()		/* form is hidden when page loads, this function is called 100 ms into the slide out */
{
	slide_pic.style.visibility = 'visible';
}



