// JavaScript Document
// set the developer key in a global variable so it doesn't have to be included
// in each function call

///without www
//_iLikeDevKey = "dk01_FFNvSuPTs6FmpOp0nyxCIIvj6Reicgib9-5TNhXCWU=";

///www
_iLikeDevKey = "dk01t5KUaBvuEcCIuGiSO3e2GJeGt2iNyw4elnGtJM7kAL0=";


// this function will be called when the page loads to draw the intial song
// inside the div "song1"
//iLikeDisplaySong({elId:"song1", songName:"Parsec", artistName:"Stereolab"});

// this is a callback function which receives a track from the song chooser dialog
// and updates the song display
function iLikeSongSelected(trackId) {
	iLikeDisplaySong({elId:"song1", trackIds:trackId});
}

// this is a convenience function which draws the playlist in view, add, or edit mode
function showPlaylist(mode) {
	iLikeDisplayPlaylist({elId:"playlist1", playlistName: "2", editMode: mode});
}

// render the playlist in view mode when the page loads
//showPlaylist("view");

//iLikeDisplaySong({elId:"s1", songName: "Get It On", artistName: "T. Rex"});
//showPlaylist("view");

function showPlaylist(mode) {
	iLikeDisplayPlaylist({elId:"p1", playlistName: "3", editMode: mode, onDisplay: myPlaylistCallback, maxHeight: "150"});
}

function mySongCallback(song_id, song_name, artist_name) {
//	if(song_id - 0 > 0) {
//		detailsDiv = document.getElementById("chooser_details");
//		if(detailsDiv) {
//			detailsDiv.innerHTML = "You chose:<br/>'" + song_name + "' (id: " + song_id + ")<br/> by '" + artist_name +"'";
		thanksWilliamMain.changeText(song_id + "---" + artist_name + "---" + song_name);
//		}
//		iLikeDisplaySong({elId:"s1", trackIds: song_id});
//	}
}

function myPlaylistCallback(data) {
	msg = "Last playlist callback:<br/>";
	for(prop in data) {
		msg += prop + ": " + data[prop] + "<br/>";
	}
	
	detailsDiv = document.getElementById("playlist_details");
	
	if(detailsDiv) {
		detailsDiv.innerHTML = msg;
	}
}

function iLikeOnDisplaySong(data){
	msg = "Song callback:<br/>";

	for(prop in data) {
		msg += prop + ": " + data[prop] + "\r\n";
	}
}