//**************************************
// Rotation Panel
//**************************************
var rotationAutoIntervalID;
var rotationIndex = 0;
var rotationPanels = new Array();
var rotating = false;

function rotationPanelInit()
{
	if($('rotationPanel1') == null)
		return;
	rotationPanels[0] = $('rotationPanel1');
	rotationPanels[1] = $('rotationPanel2');
	rotationAutoIntervalID = setInterval('rotationPanelAuto()', 10000);
}	

function rotationPanelAuto()
{
	rotationPanelMoveNext(true);
}

function rotationPanelSelect(index)
{
	if(index == rotationIndex || rotating)
		return;
		
	rotationPanelHide();
	rotationIndex = index;
	if(rotationIndex < 0)
		rotationIndex = 0;
	if(rotationIndex >= rotationPanels.length)
		rotationIndex = rotationPanels.length - 1;
	rotationPanelShow();
	
	clearInterval(rotationAutoIntervalID);
}

function rotationPanelMovePrevious()
{
	if(rotating)
		return;
		
	rotationPanelHide();
	rotationIndex--;
	if(rotationIndex < 0)
		rotationIndex = rotationPanels.length - 1;
	rotationPanelShow();
	
	clearInterval(rotationAutoIntervalID);
}

function rotationPanelMoveNext()
{
	rotationPanelMoveNext(false);
}

function rotationPanelMoveNext(auto)
{
	if(rotating)
		return;
	
	rotationPanelHide();
	rotationIndex++;
	if(rotationIndex >= rotationPanels.length)
		rotationIndex = 0;
	rotationPanelShow();
	
	if(!auto)
		clearInterval(rotationAutoIntervalID);
}

function rotationPanelShow()
{
	hideToolTipPopup();
	Effect.Appear(rotationPanels[rotationIndex], { duration:0.5, from:0.0, to:1.0 });
	rotating = true;
	window.setTimeout("rotating = false;", 250);
}

function rotationPanelHide()
{
	Effect.Fade(rotationPanels[rotationIndex], { duration:0.5, from:1.0, to:0.0 });
}

//**************************************
// Product Tooltip
//**************************************
var mouseX;
var mouseY;
function showToolTipPopup(title, artist)
{
	$('ToolTipTitle').innerHTML = title;
	$('ToolTipArtist').innerHTML = artist;
	var popup = $('ToolTipPopup');
	popup.style.left = (mouseX + 10) + 'px';
	popup.style.top = (mouseY + 10) + 'px';
	popup.style.display = 'block';
}

function hideToolTipPopup()
{
	var popup = $('ToolTipPopup');
	popup.style.display = 'none';
}

function getMousePosition(e)
{
	mouseX = Event.pointerX(e);
    mouseY = Event.pointerY(e);
}

//**************************************
// Init Code
//**************************************
function Template3Init()
{
	Event.observe(document, "mousemove", getMousePosition, false); 
	rotationPanelInit();
}

function Template3InitNoRotationPanels()
{
	Event.observe(document, "mousemove", getMousePosition, false); 
}