/**
 * Funkcionalita k stranke Mariana Vargu
 *
 * Autor: ARS NOVA s.r.o.
 */

var animationIndex = 0;
var background = [new Array(6), new Array(6), new Array(6), new Array(6)];
var rolloverBgCells = new Array(0);
var playTimeout = null;
var copyrightFlag = false;

background[0][0] = [158,160,163,165,168,171,173,176,178,183,186,188,191,194,196,199,201,204,201,196,194,191,186,183,181,178,173,171,168,163,160,158,153,150,147,145,140,137,137,140,140,140,142,142,145,145,145,147,147,147,150,150,150,153,153,155,155,155,158,158];
background[0][1] = [145,145,147,147,147,147,150,150,150,150,147,147,147,147,145,145,145,145,142,142,142,142,140,140,142,145,150,153,155,158,160,163,168,171,173,176,178,181,186,188,191,188,186,183,181,178,176,173,171,168,168,165,163,160,158,155,153,150,147,145];
background[0][2] = [204,204,204,204,206,206,206,206,206,206,206,209,209,209,209,209,209,211,211,211,211,211,211,211,214,214,214,214,209,204,199,191,186,181,176,171,165,160,153,147,142,137,140,145,147,153,155,160,163,168,171,173,178,181,186,188,194,196,201,204];
background[0][3] = [173,171,168,165,163,160,158,155,153,150,147,145,142,140,142,142,145,147,147,150,153,153,155,155,158,160,160,163,165,165,168,171,171,173,176,176,178,178,181,183,183,186,188,188,191,191,188,188,186,186,183,183,181,181,178,178,176,176,173,173];
background[0][4] = [119,122,124,127,127,130,132,135,137,140,140,142,145,147,150,153,153,155,158,160,160,158,158,155,155,155,153,153,150,150,150,147,147,145,145,145,142,142,140,140,140,137,137,135,135,135,132,132,130,130,130,127,127,124,124,124,122,122,119,119];
background[0][5] = [145,142,142,140,137,137,135,135,132,130,130,127,124,124,122,122,119,117,117,114,112,112,109,109,107,107,109,109,112,112,114,114,114,117,117,119,119,122,122,122,124,124,127,127,130,130,130,132,132,135,135,137,137,137,140,140,142,142,145,145];

background[1][0] = [199,196,194,191,191,188,186,183,181,178,176,173,173,171,168,165,163,160,158,155,155,153,150,147,145,142,137,135,132,132,132,135,135,135,135,135,137,137,137,137,137,140,140,140,140,140,142,142,142,142,142,145,145,145,155,163,173,181,191,199];
background[1][1] = [147,147,145,145,142,142,142,140,140,137,137,137,137,140,140,140,140,140,140,142,142,142,142,142,142,145,145,145,145,145,145,147,147,147,147,147,147,150,150,150,147,145,142,140,135,132,130,127,124,122,124,127,130,132,135,137,140,142,145,147];
background[1][2] = [160,160,160,158,158,158,158,158,155,155,155,155,155,153,153,153,155,155,158,158,160,160,163,163,165,165,168,168,171,171,173,173,176,176,178,178,181,181,183,183,186,186,188,188,191,191,188,186,183,183,181,178,176,173,171,168,168,165,163,160];
background[1][3] = [137,140,142,145,147,147,150,153,155,158,163,165,168,171,176,178,181,183,188,191,186,183,178,173,171,165,163,158,153,150,145,140,137,132,130,124,124,124,127,127,127,127,127,130,130,130,130,132,132,132,132,132,135,135,135,135,135,137,137,137];
background[1][4] = [178,178,176,176,176,173,173,173,171,171,171,168,168,165,165,165,163,163,163,160,160,160,158,158,158,155,155,155,153,153,153,150,150,150,147,147,147,145,145,142,142,142,140,140,140,137,137,137,135,135,140,142,147,153,158,160,165,171,173,178];
background[1][5] = [107,109,112,117,119,122,124,127,130,135,137,140,142,145,147,153,155,158,158,155,155,153,153,150,150,147,147,145,145,142,142,140,140,137,137,135,135,132,132,132,130,130,127,127,124,124,122,122,119,119,117,117,114,114,112,112,109,109,107,107];

background[2][0] = [127,130,132,137,140,142,145,147,150,155,158,160,163,165,168,173,176,178,173,165,160,153,147,140,135,127,122,114,109,101,96,89,83,89,94,99,104,107,112,117,122,127,132,137,142,147,150,155,160,165,171,165,160,155,150,147,142,137,132,127];
background[2][1] = [158,158,155,155,153,153,150,150,147,147,145,145,142,142,142,140,140,137,137,135,135,132,132,130,130,127,127,127,124,124,122,122,119,119,117,117,114,114,112,112,114,117,119,122,124,127,132,135,137,140,142,145,147,150,153,153,155,155,158,158];
background[2][2] = [140,142,147,150,155,158,163,165,168,173,176,181,183,188,191,188,186,183,181,178,176,173,171,168,165,163,160,158,155,153,150,150,150,150,147,147,147,147,147,147,147,145,145,145,145,145,145,145,145,142,142,142,142,142,142,142,140,140,140,140];
background[2][3] = [107,109,112,112,114,117,119,119,122,124,127,130,130,132,135,137,137,140,142,145,147,147,150,153,155,155,158,160,163,165,165,168,171,173,173,176,178,181,183,183,186,188,191,191,194,196,188,183,176,171,163,158,150,145,137,132,124,119,112,107];
background[2][4] = [155,150,147,142,137,132,130,124,119,117,112,117,122,124,127,127,132,150,147,147,145,142,140,140,137,135,135,132,130,130,127,124,122,122,119,117,117,114,112,112,109,107,104,104,101,104,109,112,117,119,122,127,130,135,137,140,145,147,153,155];
background[2][5] = [168,165,165,163,160,160,158,158,155,153,153,150,147,147,145,145,142,140,140,137,135,135,132,130,130,127,127,124,122,122,119,117,117,114,114,112,109,109,107,109,112,114,119,122,124,127,130,132,135,140,142,145,147,150,153,155,160,163,165,168];

background[3][0] = [86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,89,91,94,96,99,101,104,107,112,114,117,119,122,124,127,130,132,135,132,127,124,122,119,114,112,109,107,101,99,96,94,89,86];
background[3][1] = [147,147,150,150,153,153,153,155,155,155,158,158,160,160,160,158,158,158,158,155,155,155,153,153,153,150,150,150,150,147,147,147,145,145,145,145,142,142,142,142,142,140,140,140,140,140,140,140,140,137,137,137,137,137,140,140,142,145,145,147];
background[3][2] = [173,171,165,163,158,155,153,147,145,147,147,150,150,153,153,155,155,158,158,155,153,150,147,145,142,140,137,135,132,130,127,124,122,119,117,114,112,109,107,104,101,99,104,107,112,114,119,124,127,132,137,140,145,147,153,158,160,165,168,173];
background[3][3] = [132,132,130,130,127,127,127,124,124,122,122,119,119,119,117,117,114,114,114,112,112,109,109,112,112,114,117,117,119,119,122,124,124,127,130,130,132,135,135,137,137,140,142,142,145,147,147,150,150,153,155,155,158,155,150,147,142,140,135,132];
background[3][4] = [165,165,165,165,165,165,163,163,160,158,155,155,153,150,147,147,145,142,140,140,137,135,132,132,130,127,124,124,122,122,122,119,119,119,119,119,117,117,117,119,122,124,127,130,132,135,137,140,142,145,147,150,153,153,155,158,160,160,163,165];
background[3][5] = [96,101,104,109,114,117,122,124,130,135,137,142,147,150,155,158,163,168,171,176,176,173,173,171,171,171,168,168,168,165,165,163,163,163,160,160,158,158,158,155,155,155,153,153,150,150,145,142,137,135,130,127,122,119,114,112,107,104,99,96];

function animateBackground() {
	var theCells = document.getElementsByName('bgCell');
	for (var i = 0; i < theCells.length; i++) {
		var theClasses = theCells[i].className;
		var theClassesWithBgChanged = theClasses.replace(
			/^(.*)\b(bgColor)[0-9]+\b(.*)$/,
			'$1$2' + background[Math.floor(i / 6)][i % 6][animationIndex] + '$3');
		var theClassesChanged = theClassesWithBgChanged.replace(
			/^(.*)\b(bgDarkColor)[0-9]+\b(.*)$/,
			'$1$2' + Math.round(0.35 * background[Math.floor(i / 6)][i % 6][animationIndex] - 0.65) + '$3');
		theCells[i].className = theClassesChanged;
	}
	animationIndex = (animationIndex + 1) % 60;
	setTimeout('animateBackground()', 83);
}

function showRollover(anElement, aRolloverIndex) {
	var theRollover = document.getElementById('rollover' + aRolloverIndex);
	theRollover.style.visibility = "visible";
	anElement.style.cursor = navigator.appName == 'Microsoft Internet Explorer' ? 'hand' : 'pointer';
	if (aRolloverIndex < rolloverBgCells.length) {
		var theCells = document.getElementsByName('bgCell');
		var theIndexes = rolloverBgCells[aRolloverIndex];
		for (var i = 0; i < theIndexes.length; i++) {
			var theIndex = theIndexes[i];
			var theClasses = theCells[theIndex].className.replace(
				/^(.*)\b(bgColor)[0-9]+\b(.*)$/,
				'$1bgDarkColor' + Math.round(0.35 * background[Math.floor(theIndex / 6)][theIndex % 6][animationIndex] - 0.65) + '$3');
			theCells[theIndex].className = theClasses;
		}
	}
}

function showRolloverWithPointer(anElement, aRolloverIndex) {
	var theRollover = document.getElementById('rollover' + aRolloverIndex);
	theRollover.style.visibility = "visible";
	if (aRolloverIndex < rolloverBgCells.length) {
		var theCells = document.getElementsByName('bgCell');
		var theIndexes = rolloverBgCells[aRolloverIndex];
		for (var i = 0; i < theIndexes.length; i++) {
			var theIndex = theIndexes[i];
			var theClasses = theCells[theIndex].className.replace(
				/^(.*)\b(bgColor)[0-9]+\b(.*)$/,
				'$1bgDarkColor' + Math.round(0.35 * background[Math.floor(theIndex / 6)][theIndex % 6][animationIndex] - 0.65) + '$3');
			theCells[theIndex].className = theClasses;
		}
	}
}

function hideRollover(aRolloverIndex) {
	var theRollover = document.getElementById('rollover' + aRolloverIndex);
	theRollover.style.visibility = "hidden";
	if (aRolloverIndex < rolloverBgCells.length) {
		var theCells = document.getElementsByName('bgCell');
		var theIndexes = rolloverBgCells[aRolloverIndex];
		for (var i = 0; i < theIndexes.length; i++) {
			var theIndex = theIndexes[i];
			var theClasses = theCells[theIndex].className.replace(
				/^(.*)\b(bgDarkColor)[0-9]+\b(.*)$/,
				'$1bgColor' + background[Math.floor(theIndex / 6)][theIndex % 6][animationIndex] + '$3');
			theCells[theIndex].className = theClasses;
		}
	}
}

function initPlayer(aCopyrightFlag, anURL) {
	var theEx = null;
	var thePlayer = document.player;
	copyrightFlag = aCopyrightFlag;
	if (! copyrightFlag) {
		return;
	}
	if (thePlayer) {
		try {
			switch (thePlayer.tagName) {
				case 'OBJECT':
					thePlayer.FileName = anURL;
					playTimeout = setTimeout('startPlay()', 100);
					break;
				case 'EMBED':
					thePlayer.SetResetPropertiesOnReload(false);
					var theURLParts = anURL.split('/');
					setTimeout('setURLForEmbed("' + theURLParts[theURLParts.length - 2] + '/' + theURLParts[theURLParts.length - 1] + '")', 100);
					break;
			}
		} catch (theEx) {
		}
	}
}

function playSongPreview(anURL) {
	var theEx = null;
	var thePlayer = document.player;
	if (! copyrightFlag) {
		return;
	}
	if (playTimeout != null) {
		clearTimeout(playTimeout);
	}
	if (thePlayer) {
		try {
			switch (thePlayer.tagName) {
				case 'OBJECT':
					thePlayer.FileName = anURL;
					playTimeout = setTimeout('startPlay()', 100);
					break;
				case 'EMBED':
					var theURLParts = anURL.split('/');
					playTimeout = setTimeout('setURLForEmbed("' + theURLParts[theURLParts.length - 1] + '")', 100);
					break;
			}
		} catch (theEx) {
			alert(theEx);
		}
	}
}

function setURLForEmbed(anURL) {
	playTimeout = null;
	var theEx = null;
	var thePlayer = document.player;
	try {
		var theOldURL = thePlayer.GetURL();
		if (theOldURL == '') {
			playTimeout = setTimeout('setURLForEmbed("' + anURL + '")', 100);
		} else {
			thePlayer.SetURL(anURL);
			playTimeout = setTimeout('startPlay()', 100);
		}
	} catch (theEx) {
		alert(theEx);
	}
}

function startPlay() {
	playTimeout = null;
	var theEx = null;
	var thePlayable = false;
	var thePlayer = document.player;
	try {
		switch (thePlayer.tagName) {
			case 'OBJECT':
				thePlayable = thePlayer.ReadyState > 2;
				break;
			case 'EMBED':
				var theState = thePlayer.GetPluginStatus();
				thePlayable = theState == 'Playable' || theState == 'Complete';
				break;
		}
		if (thePlayable) {
			thePlayer.Play();
		} else {
			playTimeout = setTimeout('startPlay()', 100);
		}
	} catch (theEx) {
	}
}
