/*
	Home Top Rotator
*/
function rotatePicture()
{
	if(rotatePicNum >= (rotatePicTotal - 1))
		rotatePicNum  = -1;
	switchPicture(++rotatePicNum);
}
function switchPicture(num)
{
	var current_image;
	for(i=0; i < rotatePicTotal; i++)
	{
		if(document.getElementById('rotate_pic_'+(i+1)).style.display != 'none')
		{
			current_image = i + 1;
			if(i != num && ! homeRotating)
			{
				homeRotating = true;
				// reset timer
				clearTimeout(rotatePicTimer);
				// Do all effects at once
				new Effect.Parallel([   
					new Effect.Appear('rotate_nav_'+current_image, { sync:true }),
					new Effect.Fade('rotate_pic_'+(i+1), { sync:true }),
					new Effect.Appear('rotate_pic_'+(num+1), { sync:true }),
					new Effect.Fade('rotate_nav_'+(num+1), { sync:true })
				], { 
				  duration: 1.0,
				  afterFinish:function() {
					homeRotating = false;
					rotatePicNum = num;
					// Milliseconds
					return rotateTimer(rotateTime);
				  	}
				});
				
			}
		}
	}
	
}
function rotateTimer(t)
{
	rotateTime = t;
	if(typeof(rotatePicTotal) != 'undefined' && rotatePicTotal > 0)
		rotatePicTimer = setTimeout("rotatePicture();", t);
}
/*
	Home Bottom Slider
*/
function slidePicture(num)
{
	//var current_image2 = 0;
	for(i=0; i < 6; i++)
	{
		if(document.getElementById('rotate_hap_'+(i+1)).style.display != 'none')
		{
			num2 = i+1;
			if(num2 != num && ! homeSliding)
			{
				homeSliding = true;
				new Effect.Parallel([   
					new Effect.BlindUp('rotate_hap_'+num2, { sync:true, scaleX:true, scaleY:false }),
					new Effect.BlindDown('rotate_hap_'+num, { sync:true, scaleX:true, scaleY:false })
				], { 
				  duration: 0.5,
				  afterFinish:function() { homeSliding = false; }
				});
			}
		}
	}
}
var homeRotating = false;
var homeSliding = false;
var rotatePicTimer;
var rotateTime;
imgPreLoader(new Array(webroot+'img/rotator/home_1.jpg',webroot+'img/rotator/home_2.jpg',webroot+'img/rotator/home_3.jpg',webroot+'img/rotator/home_4.jpg',webroot+'img/rotator/nav_home.jpg'));