﻿// JScript File
var activeMenuRowId = 'none';

function mouseOver(menuRowId)
{
	if (menuRowId == activeMenuRowId)
		return;

	var menu_row = document.getElementById(menuRowId);
	menu_row.style.backgroundColor = '#111111';
}

function mouseOut(menuRowId)
{
	if (menuRowId == activeMenuRowId)
		return;
		
	var menu_row = document.getElementById(menuRowId);
	menu_row.style.backgroundColor = 'transparent';
}

function selected(menuRowId)
{
	if (activeMenuRowId != 'none')
	{
		var menu_row = document.getElementById(activeMenuRowId);
		menu_row.style.backgroundColor = 'transparent';
	}
	
	activeMenuRowId = menuRowId;
	
	var menu_row = document.getElementById(menuRowId);
	menu_row.style.backgroundColor = 'black';
}

function changeImageURL(item, value)
{
	item.src			= value;
}

/* front page */
var currentPanel = 0;
var newPanel = 0;
var imageButton = new Array();

function MouseOver(item, num)
{
	if (num != currentPanel)
		changeImageURL(item, 'images/BlankOver.png');			
}

function MouseOut(item, num)
{
	if (num != currentPanel)
		changeImageURL(item, 'images/Blank.png');
}

function SetCurrentPanel(num)
{
	if (imageButton[0] == null)
		FillImageArray();

	changeImageURL(imageButton[currentPanel], 'images/Blank.png');	
	currentPanel = num;
	changeImageURL(imageButton[currentPanel], 'images/BlankSelected.png');
}

function FillImageArray()
{
	imageButton[0] = document.getElementById('ctl00_ContentPlaceHolder1_ctl01_ImageButton1');		
	imageButton[1] = document.getElementById('ctl00_ContentPlaceHolder1_ctl01_ImageButton2');
	imageButton[2] = document.getElementById('ctl00_ContentPlaceHolder1_ctl01_ImageButton3');
	imageButton[3] = document.getElementById('ctl00_ContentPlaceHolder1_ctl01_ImageButton4');
}

function GetCurrentPanel()
{
	return currentPanel;
}

function SetNewPanel(num)
{
	newPanel = num;
}	

function GetNewPanel()
{
	return newPanel;
}

function MovePanel(panel1, panel2)
{
	var location = Sys.UI.DomElement.getLocation(panel1);
	panel2.style.position = 'absolute';
	panel2.style.top = location.y + 'px';
	panel2.style.left = location.x + 'px';
}

function SwitchTargetControl() 
{
	var animation = $find("animateme");
	
	if (animation != null)
		animation.get_OnClickBehavior().play();
}

var refresh_interval = null;

function StartAd()
{
	if (refresh_interval == null)
	{
		currentPanel = 0;
		newPanel = 0;
		FillImageArray();
		refresh_interval = window.setInterval( "Play()", 5000 );
	}
}

function StopAd()
{
	if (refresh_interval != null)
	{
		window.clearInterval(refresh_interval);
	}
		
	refresh_interval = null;
}

function Play()
{
	var next_panel = (currentPanel + 1) % 4;
	SetNewPanel(next_panel); 
	SwitchTargetControl();		
}

