// Initialise popup pointer
var popupWin = null;

function chooseLabel(prefix){
	var label;
	label = document.getElementById("chooseLabel");
	window.location = prefix+"/"+label.value;
}

function playPopup(popupWin) {
	if (location.host == "localhost"){
		var playerPath = "/jamfac";
	}else{
		var playerPath = "";
	}

	var url = playerPath + "/player.asp";
	var leftPos = this.screen.width-350;
	popupWin = open( "", "popupWin", "width=318,height=188,left="+leftPos );
	if( !popupWin || popupWin.closed || !popupWin.doSomething ) {
		popupWin = window.open( url, "popupWin", "width=318,height=188,status=0,toolbar=0,left="+leftPos  );
	} else {
		popupWin.close();
		popupWin = window.open( url, "popupWin", "width=318,height=188,status=0,toolbar=0,left="+leftPos  );
	return popupWin
	}
}

function cuePopup(popupWin) {
	var url = "/player.asp";
	popupWin = open( "", "popupWin", "width=318,height=188,status=0,toolbar=0,left="+leftPos  );
	var leftPos = window.innerWidth-350;
	if( !popupWin || popupWin.closed || !popupWin.doSomething ) {
		popupWin = window.open( url, "popupWin", "width=318,height=188,status=0,toolbar=0,left="+leftPos  );
	} else {
		popupWin.focus();
		popupWin.opener.history.back();
	}
	return popupWin
}

function ajaxPlayASP(track){
}

function playButtonHandler(track, sessionID, trackName, artist){
	ajaxPlayASP(track, sessionID, trackName, artist);
	playPopup();
}

function ajaxPlayASP(track, sessionID, trackName, artist)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  if (location.host == "localhost"){
		var playerPath = "/jamfac";
	}else{
		var playerPath = "";
	}
  xmlHttp.open("GET",playerPath+"/play.asp?track="+track+"&sessionID="+sessionID+"&name="+trackName+"&artist="+artist,true);
  xmlHttp.send(null);
  }

  