// Name of the main music player file
var thisfile = "index.php";

function mailFriend(album,artist,song,genre) {
	var id = (new Date()).getTime();
	eval("page" + id + " = window.open('" + thisfile + "?action=mailfriend&album=" + album + "&artist=" + artist + "&song=" + song + "&genre=" + genre + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=340,height=340,left = 362,top = 234');");
}

function showLyrics(song) {
	var id = (new Date()).getTime();
	eval("page" + id + " = window.open('" + thisfile + "?action=lyrics&song=" + song + "', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=300,left = 362,top = 234');");
}

function rateSong(song) {
	var id = (new Date()).getTime();
	eval("page" + id + " = window.open('" + thisfile + "?action=rate&song=" + song + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=340,left = 362,top = 234');");
}

function ratePlaylist(song) {
	var id = (new Date()).getTime();
	eval("page" + id + " = window.open('rateplaylist.php?action=rateplaylist&song=" + song + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=340,left = 362,top = 234');");
} 

function playSong(song,AlbmId) {
  var str = thisfile + "?action=song&id=" + song +"&AId=" + AlbmId;
  var id = "player";
  eval("page" + id + " = window.open('" + str + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=468,height=280,left = 362,top = 234');");
}


function playAll(Aid) { 
  var str = thisfile + "?action=song&array=yes&Aid=" + Aid +"&id=";
  for (var i=0;i<document.listing.elements.length;i++) 
  { 
    var curelement = document.listing.elements[i]; 
    if( curelement.checked == 1 ) {
		str = str + curelement.value + ",";
	}
	
	
  }   
  var id = "player";
 eval("page" + id + " = window.open('" + str + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width=468,height=280,left = 362,top = 234');");
 // location.href = str;
}

function addToPlaylist(song) {
	var id = (new Date()).getTime();
	eval("page" + id + " = window.open('" + thisfile + "?action=playlist&id=" + song + "', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=300,left = 362,top = 234');");
}

function removeFromPlaylist(song, playlist) {
	var id = (new Date()).getTime();
	eval("page" + id + " = window.open('" + thisfile + "?action=removefromplaylist&playlist=" + playlist + "&id=" + song + "', '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=300,left = 362,top = 234');");
}

function addAllToPlaylist() { 
  var str = "" + thisfile + "?action=playlist&id=";
  for (var i=0;i<document.listing.elements.length;i++) 
  { 
    var curelement = document.listing.elements[i]; 
    if( curelement.checked == 1 ) {
		str = str + curelement.value + ",";
	}
  }
  var id = (new Date()).getTime();
  eval("page" + id + " = window.open('" + str + "', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=300,left = 362,top = 234');");
}

function selectAll() { 
	for (var i=0;i<document.listing.elements.length;i++) 
	{
		//	if(document.listing.elements[i].type);
	}

  for (var i=0;i<document.listing.elements.length;i++) 
  { 
    var curelement;
	if(document.listing.elements[i].type=='checkbox')
	  {
		curelement = document.listing.elements[i]; 
		curelement.checked = 1;
	  }
  } 
 
}

function selectNone() { 
  for (var i=0;i<document.listing.elements.length;i++) 
  {
    var curelement = document.listing.elements[i]; 
    curelement.checked = 0;
  } 
}

function download_song(album,artist,song,genre,counter) {	
	var id = (new Date()).getTime();
	eval("page" + id + " = window.open('download_songs.php?action=mailfriend&album=" + album + "&artist=" + artist + "&song=" + song + "&genre=" + genre + "&counter="+counter+"', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=1,width=500,height=250,left = 362,top = 234');");
} 

function ArtistPopup(id) 
{
  window.open ('artistpopup.php?memid='+id,"mywindow", 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=300,left = 362,top = 234');
}
/*
function SelectSong() {
alert("Please earn points to play this song");
var abc = document.listing.song_id;
//alert(abc);
    abc.checked = false;
    return false;
}
*/

function SelectSong() {
var abc = document.listing.song_id;
	
	 window.open('index.php?action=nopoints', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=0,width=500,height=300,left = 362,top = 234');
	
	

//window.open ('user_points.php',"mywindow", 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=500,height=500,left = 362,top = 234');


    abc.checked = false;
    return false;
}


function EnlargeImg(id,flag) 
{

  window.open ('artist_large_img.php?memid='+id +'&flag='+flag,"mywindow", 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=500,height=500,left = 362,top = 234');
  
 
}
