// 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 playSong(song) {		 
  var str = thisfile + "?action=song&id=" + song;
  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() { 
	
  var str = thisfile + "?action=song&array=yes&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";

 
////	org
 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');");
 // 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');");
} 