<!-- 

//function downloadManager(winURL, winName, winFeatures, winObj)
//{
//  var theWin; // this will hold our opened window 
//
//  // first check to see if the window already exists
//  if (winObj != null)
//  {
//    // the window has already been created, but did the user close it?
//    // if so, then reopen it. Otherwise make it the active window.
//    if (!winObj.closed) {
//      winObj.focus();
//      return winObj;
//    } 
//    // otherwise fall through to the code below to re-open the window
//  }
//
//  // if we get here, then the window hasn't been created yet, or it
//  // was closed by the user.
//  theWin = window.open(winURL, winName, winFeatures); 
//  return theWin;
//} 


 
//function downloadManager(){
//
//var winName = 'Downloads';
//if (!window[winName] || window[winName].closed) {
//window[winName] = window.open('http://stronglycoded.co.uk/clients/sekforde/SekfordeJS/MultiFileDL.html', 'Downloads', 'width=350, height=250, menubar=no, scrollbars=no, toolbar=no, location=no, directories=no, resizable=no, top=20, left=20'); 
//}
//window[winName].focus();
//}







// Player functions
function playAudio(ID,Title,Artist){
    window.document.AudioPlayer.SetVariable('$ID',ID);
	window.document.AudioPlayer.SetVariable('$Title',Title);
	window.document.AudioPlayer.SetVariable('$Artist',Artist);
}


// Highlight track
var playing
var playingPosition
var cancel
function trackPlaying(ID,position){
	// Cancel old playing track
	if (playing != null) {
	cancel = true	
	var highlightImg = String(playing) + 'Img'
	var highlightTop = String(playing) + 'Top'
	var highlightBase = String(playing) + 'Base'
	var highlightButtons = 'buttons' + String(playing)
	var highlightInfo = 'trackInfo' + String(playing)
	// Odd or even?
	if (pageID == 2) { // Your playlist where there's no odd or even
		var topClass = directoryClass + 'Top'
		var baseClass = directoryClass + 'Base'
	} else {
		if ((parseFloat(playingPosition) + 1)%2) {
			var topClass = directoryClass + 'Odd';
			var baseClass = directoryClass + 'OddBase';
		} else {
			var topClass = directoryClass + 'Even';
			var baseClass = directoryClass + 'EvenBase';
		}
	}
	// The images we switch back to depend on the page - this is set in the JS include
	document.getElementById(highlightImg).src = audioImg;
	document.getElementById(highlightTop).className = topClass;
	document.getElementById(highlightBase).className = baseClass;
	// Set info panel back to either blue or grey
	if (pageID == 0) { // Music search
		if (toggleTrack == playing) {
			panelColour = 1
		} else {
			panelColour = 0
		}
		// Now call function
		resultColour(playing,(parseFloat(playingPosition) + 1),panelColour)
	}
	// Turn off Delete and Alt buttons on Your Playlist
	if (pageID == 2) {
		document.getElementById(String(playing) + 'Del').src = '/Images/Search/Inactive/Delete.gif';
		document.getElementById(String(playing) + 'Alt').src = '/Images/Search/Inactive/Alt.gif';
	}
	cancel = false
	}
	// Flash track and set panel to red
	var imgID = String(ID) + 'Img'
	var topID = String(ID) + 'Top'
	var baseID = String(ID) + 'Base'
	var buttonsID = 'buttons' + String(ID)
	var infoID = 'trackInfo' + String(ID)
	// Different pages uses different class for the highlight
	if (pageID == 2) { // Your playlist
		var topHighlight = 'playlistHighlight'
		var baseHighlight = 'playlistHighlightBase'
	} else {
		var topHighlight = 'directoryHighlight'
		var baseHighlight = 'directoryHighlightBase'
	}
	setTimeout("document.getElementById('" + imgID + "').src = '/Images/Search/Playing.gif';",250)
	setTimeout("document.getElementById('" + topID + "').className = '" + topHighlight + "';",250)
	setTimeout("document.getElementById('" + baseID + "').className = '" + baseHighlight + "';",250)
	// Music search checks for which track is toggled open
	if (pageID == 0) {
		setTimeout("document.getElementById('" + buttonsID + "').className = 'resultRolloverButtons';",250)
		setTimeout("document.getElementById('" + infoID + "').className = 'trackHighlight';",250)
	}
	// Highlight other buttons on Your Playlist
	if (pageID == 2) {
		setTimeout("document.getElementById('" + String(ID) + "Del').src = '/Images/Search/Active/Delete.gif';",250)
		setTimeout("document.getElementById('" + String(ID) + "Alt').src = '/Images/Search/Active/Alt.gif';",250)
	}
	new Effect.Pulsate(String(ID),{duration:0.5,pulses:1});
	// Set values for track currently playing
	playing = String(ID)
	playingPosition = position
}


// De-highlight track once it has stopped playing
function stopPlaying(ID,position){
	cancel = true
	var highlightImg = String(ID) + 'Img'
	var highlightTop = String(ID) + 'Top'
	var highlightBase = String(ID) + 'Base'
	// Odd or even?
	if (pageID == 2) { // Your playlist where there's no odd or even
		var topClass = directoryClass + 'Top'
		var baseClass = directoryClass + 'Base'
	} else {
		if ((parseFloat(position) + 1)%2) {
			var topClass = directoryClass + 'Odd';
			var baseClass = directoryClass + 'OddBase';
		} else {
			var topClass = directoryClass + 'Even';
			var baseClass = directoryClass + 'EvenBase';
		}
	}
	// The images we switch back to depend on the page - this is set in the JS include
	document.getElementById(highlightImg).src = audioImg;
	document.getElementById(highlightTop).className = topClass;
	document.getElementById(highlightBase).className = baseClass;
	if (pageID == 0) { // Music search
	resultColour(ID,(parseFloat(position) + 1),0)
	}
	// Turn off Delete and Alt buttons on Your Playlist
	if (pageID == 2) {
	document.getElementById(String(ID) + 'Del').src = '/Images/Search/Inactive/Delete.gif';
	document.getElementById(String(ID) + 'Alt').src = '/Images/Search/Inactive/Alt.gif';
	}	
	cancel = false
	playing = null
}


// Highlight track on rollover for 'Your Playlist' page
function mouseDetect(ID,button,state) {
if (playing != ID) { // If track is playing don't do anything
// Over or out?
if (parseFloat(state) == 1) { // Mouse over
	mode = 'Active'
} else {
	mode = 'Inactive'
}
// How handle action
if (button == 0) { // Delete
	var imgHighlight = String(ID) + 'Del'
	var buttonSrc = '/Images/Search/' + mode +'/Delete.gif';
} else if (button == 1) { // Alternative versions
	var imgHighlight = String(ID) + 'Alt'
	var buttonSrc = '/Images/Search/' + mode +'/Alt.gif';
} else if (button == 2) { // Audio sample
	var imgHighlight = String(ID) + 'Img'
	var buttonSrc = '/Images/Search/' + mode +'/Audio.gif';
}
// Switch graphic
document.getElementById(imgHighlight).src = buttonSrc;
}
}


// Coming soon
function comingSoon() {
	alert('Coming Soon');
}


// Add track with AJAX
function addTrack(ID,Track) {
// Create AJAX request
new Ajax.Request('/NoIndex/AJAX/Add-Track.asp',   {    
method:'post',
parameters: {Playlist:ID},
onSuccess: function(transport){
	//alert(escape(Track))
	var response = transport.responseText || "0";
	new Effect.Pulsate('playlist', {duration:0.5,pulses:1});
	setTimeout("document.getElementById('playlistCount').innerHTML = '" + response + "';",250)
	setTimeout("document.getElementById('latestSong').innerHTML = \"" + unescape(Track) + "\";",250)
	if (response == 1) {
	setTimeout("document.getElementById('trackCount').innerHTML = 'TRACK';",250)
	} else {
	setTimeout("document.getElementById('trackCount').innerHTML = 'TRACKS';",250)
	}
	//alert("Success! \n\n" + response);
	},
	onFailure: function(){
	alert('Sorry, there was an error and the track was not added to your playlist.')
	}
});
}


// Dynamically grey out save playlist options
function savePlaylist() {
var type = multiChoice(document.Save.elements['PlaylistType']);
// New
if (type == 'New') {
	// Enable
	document.Save.PlaylistName.disabled = false;
	document.getElementById('PlaylistName').className = 'textField';
	document.Save.PlaylistDesc.disabled = false;
	document.getElementById('PlaylistDesc').className = 'textField';
	document.getElementById('Name').className = 'black';
	document.getElementById('Desc').className = 'black';
	// Disable drop menu 
	document.Save.ExistingPlaylists.disabled = true;
	document.getElementById('ExistingPlaylists').className = 'selectDisabled';
	document.getElementById('Existing').className = 'grey';
	}
	// Append or Overwrite
	else if (type == 'Append'||type == 'Overwrite') {
	// Enable 
	document.Save.ExistingPlaylists.disabled = false;
	document.getElementById('ExistingPlaylists').className = 'select';
	document.getElementById('Existing').className = 'black';
	// Disable fields
	document.Save.PlaylistName.value = '';
	document.Save.PlaylistName.disabled = true;
	document.getElementById('PlaylistName').className = 'textDisabled';
	document.Save.PlaylistDesc.value = '';
	document.Save.PlaylistDesc.disabled = true;
	document.getElementById('PlaylistDesc').className = 'textDisabled';
	document.getElementById('Name').className = 'grey';
	document.getElementById('Desc').className = 'grey';
	}
}


// Grey out save playlist options
function greyOut() {
	// Disable drop menu 
	document.Save.ExistingPlaylists.disabled = true;
	document.getElementById('ExistingPlaylists').className = 'selectDisabled';
	document.getElementById('Existing').className = 'grey';
}


// Select all download checkboxes
function selectAll()
{
count = document.Playlist.elements.length;
for (i=0; i < count; i++) {
	document.Playlist.elements[i].checked = 1;
	}
}

// JS equivalent of Left VB function
function Left(str,n)
/***
IN: str - the string we are LEFTing
    n - the number of characters we want to return
RETVAL: n characters from the left side of the string
***/
{
	if (n <= 0)     // Invalid bound, return blank string
    	return "";
	else if (n > String(str).length)   // Invalid bound, return
		return str;                // entire string
	else // Valid bound, return appropriate substring
		return String(str).substring(0,n);
}


// JS equivalent of Right VB function
function Right(str,n)
/***
IN: str - the string we are RIGHTing
    n - the number of characters we want to return
RETVAL: n characters from the right side of the string
***/
{
	if (n <= 0)     // Invalid bound, return blank string
		return "";
	else if (n > String(str).length)   // Invalid bound, return
		return str;                     // entire string
	else { // Valid bound, return appropriate substring
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}


// JS equivalent of Len VB function
function Len(str)
/***
IN: str - the string whose length we are interested in
RETVAL: The number of characters in the string
***/
{  return String(str).length;  }


// Read status of radio button set
function multiChoice(object) {
	for(var i=0;i<object.length;i++)
	{
		if(object[i].checked==true)
		{
		return object[i].value;
		}
	}
	return 'null';
}


// Cookie Functions
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/; domain=" + location.hostname + ";";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name) {
	createCookie(name,"",-1);
}


// Acrobat Popup
function acrobatPopup() {
	window.open('http://www.adobe.com/products/acrobat/readstep2.html','acrobat','width=770,height=450,top=10,left=10,scrollbars=yes,resizable=yes');
}

// Standard Macromedia Generated Functions
function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// -->
