soundManager.url = 'http://www.slaughtercult.de/swf/';
var mySound;
soundManager.debugMode = false;

var mp3TrackArray = new Array("SaldorianSpell.MP3","BeneathTheMoonScarsAbove.MP3","KataklysmicBretherens.MP3","TheDescentToTheLastCircle.MP3","GlanceAtTheHorizon.MP3","DispatchingTheCurseOfUncreation.MP3","SuitorOfDeath.MP3","TheSaturnineChapel.MP3","das_alleine.mp3","tempestous_sermonizers.mp3","bearer_of_blackest_might.mp3","unearthing_cosmic_decay.mp3","hora_nocturna.mp3","malignant_deathcult.mp3","cimonar_de_nuit.mp3","to_necromancy.mp3","WicherZaGorami.mp3","ChroniclerOfChaos.mp3","SpectralRunletsOfTulwod.mp3","ScaffoldSalvation.mp3","TheDeadHateTheLiving.mp3","ThroughRottingStench.mp3","NocturnalMarch.mp3","Thanatos.mp3","HoraRuid.mp3","FollowtheCallsforBattle.mp3","IntheLandoftheMountainsofTrees.mp3","OurGloriousPresence.mp3","PestilentialDeathride.mp3","TowardsBerzenelon.mp3","ArsMoriendi.mp3","ThePestcalledHumanity.mp3","Slaughtercult.mp3","Saldor.mp3","Centuriesofmine.mp3","underneath.mp3");
var mp3TitleArray = new Array("Saldorian Spell","Beneath the Moon Scars Above", "Kataklysmic Bretherens", "The Descent to the Last Circle", "Glance At the Horizon", "Dispatching the Curse of Uncreation", "Suitor of Death", "The Saturnine Chapel","Das All-Eine","Tempestous Sermonizers of forthcoming Death","Bearer of Blackest Might","Unearthing Cosmic Decay","Hora Nocturna","Malignant Deathcult","Cimonar de Nuit","...to Necromancy","Wicher Za Gorami","Chronicler of Chaos","Spectral Runlets of Tulwod","Scaffold Salvation","The Dead Hate the Living","Through Rotting Stench","Nocturnal March","Thanatos","Hora Ruid","Follow the Calls for Battle","In the Land of the Mountains of Trees","Our Glorious Presence","Pestilential Deathride","Towards Berzenelon","Ars Moriendi","The Pest Called Humanity","Slaughtercult","Saldor","Centuries of Mine","Underneath Stars of the East");
var mp3AlbumArray = new Array("Saldorian Spell","Saldorian Spell","Saldorian Spell","Saldorian Spell","Saldorian Spell","Saldorian Spell","Saldorian Spell","Saldorian Spell","Hora Nocturna","Hora Nocturna","Hora Nocturna","Hora Nocturna","Hora Nocturna","Hora Nocturna","Hora Nocturna","Hora Nocturna","Nocturnal March","Nocturnal March","Nocturnal March","Nocturnal March","Nocturnal March","Nocturnal March","Nocturnal March","Follow the Calls for Battle","Follow the Calls for Battle","Follow the Calls for Battle","Follow the Calls for Battle","Follow the Calls for Battle","Follow the Calls for Battle","Follow the Calls for Battle","The Pest Called Humanity","The Pest Called Humanity","The Pest Called Humanity","The Pest Called Humanity","The Pest Called Humanity","Underneath Stars of the East");
var curIndex = 0;
var maxIndex = 36;


soundManager.onload = function()
{
	//mySound = getMySound(mp3TrackArray, mp3TitleArray,curIndex)
	//mySound.play()
}

function LoadTrack()
{
	var selectedID = document.getElementById('mp3TrackSelectionId').value;
	if (selectedID != "")
	{	
		curIndex = selectedID;
		stopFile();
		mySound = getMySound(mp3TrackArray, mp3TitleArray,curIndex)
		mySound.play()
	}
}

function getMySound(fcMp3TrackArray, fcMp3TitleArray,fcCurIndex)
{
  var curSong = fcMp3TitleArray[fcCurIndex];
  var curUrl  = fcMp3TrackArray[fcCurIndex];

  mySound = soundManager.createSound({id: '' + curSong ,url: '../audio/' + curUrl});

  document.getElementById('curTrackID').innerHTML = 'Album: <b>"' + mp3AlbumArray[curIndex] + '"</b>';
  document.getElementById('curAlbumID').innerHTML = 'Now playing: <b>"' +fcMp3TitleArray[curIndex] + '"</b>';

  return mySound;
}

function playFile()
{

	stopFile();
	document.getElementById('mp3TrackSelectionId').value = curIndex;
	mySound = getMySound(mp3TrackArray, mp3TitleArray,curIndex)
	mySound.play();
}

function stopFile()
{
	try
	{ mySound.stop(); }
	catch(err){}
}

function pauseFile()
{
	mySound.pause();
}

var volumeLevel = 20;

function raiseVolume()
{
	volumeLevel = volumeLevel + 1;
	mySound.setVolume(volumeLevel);
}

function lowerVolume()
{
	volumeLevel = volumeLevel - 1;
		mySound.setVolume(volumeLevel);
}

function previousTrack()
{
	curIndex = curIndex - 1;
	if (curIndex < 0)
	{ curIndex = maxIndex;}

	document.getElementById('mp3TrackSelectionId').value = curIndex;
	stopFile();
	
	mySound = getMySound(mp3TrackArray, mp3TitleArray,curIndex)
	mySound.play()
}

function nextTrack()
{
	curIndex = curIndex + 1;
	if (curIndex > maxIndex)
	{ curIndex = 0;}

	document.getElementById('mp3TrackSelectionId').value = curIndex;
	stopFile();

	mySound = getMySound(mp3TrackArray, mp3TitleArray,curIndex)
	mySound.play()
}

function mp3OnFinish()
{
	nextTrack();
}