//**************************************
// Image Rollovers
//**************************************
if(document.images)
{
	imgPagerPrev = new Image();
	imgPagerPrev.src = "images/art/template1/pager_prev_off.gif";
	imgPagerPrev_mouseover = new Image();
	imgPagerPrev_mouseover.src = "images/art/template1/pager_prev_on.gif";
	
	imgPagerNext = new Image();
	imgPagerNext.src = "images/art/template1/pager_next_off.gif";
	imgPagerNext_mouseover = new Image();
	imgPagerNext_mouseover.src = "images/art/template1/pager_next_on.gif";
	
	imgPagerPage = new Image();
	imgPagerPage.src = "images/art/template1/pager_off.gif";
	imgPagerPage_mouseover = new Image();
	imgPagerPage_mouseover.src = "images/art/template1/pager_on.gif";
	imgPagerPage_selected = new Image();
	imgPagerPage_selected.src = "images/art/template1/pager_selected.gif";
}

//**************************************
// Rotation Panel
//**************************************
var rotationAutoIntervalID;
var rotationIndex = 0;
var rotationPanels = new Array();
var rotationPagerImages = new Array();
var rotating = false;

function rotationPanelInit()
{
	if($('rotationPanel1') == null)
		return;
		
	rotationPanels[0] = $('rotationPanel1');
	rotationPanels[1] = $('rotationPanel2');
	rotationPanels[2] = $('rotationPanel3');
	rotationPagerImages[0] = $('imgPagerPage1');
	rotationPagerImages[1] = $('imgPagerPage2');
	rotationPagerImages[2] = $('imgPagerPage3');
	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();
	rotationPagerImages[rotationIndex].src = imgPagerPage_selected.src;
	Effect.Appear(rotationPanels[rotationIndex], { duration:0.5, from:0.0, to:1.0 });
	rotating = true;
	window.setTimeout("rotating = false;", 250);
}

function rotationPanelHide()
{
	rotationPagerImages[rotationIndex].src = imgPagerPage.src;
	Effect.Fade(rotationPanels[rotationIndex], { duration:0.5, from:1.0, to:0.0 });
}

function pagerOnImgOut(index)
{
	if(rotationIndex != index)
		rotationPagerImages[index].src = imgPagerPage.src;
}

function pagerOnImgOver(index)
{
	if(rotationIndex != index)
		rotationPagerImages[index].src = imgPagerPage_mouseover.src;
}

//**************************************
// 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 Template1Init()
{
	Event.observe(document, "mousemove", getMousePosition, false); 
	rotationPanelInit();
}