function toggleQuicklist (scene_id) {
	var box = document.getElementById("quicklist_" + scene_id);
	if (box) box.onclick = null;
	jQuery.ajax({
		type: "POST",
		url: "/ajax/action_quicklist.php",
		data: "id=" + scene_id + "&action=toggle",
		success: function (msg) {
			var message = "Malformed request";
			if (msg == 1)
				message = "Scene " + scene_id + " has been added to your quicklist"
			else if (msg == 3)
				message = "Scene " + scene_id + " has been removed from quicklist";
			else if (msg == 4)
				message = "Unable to remove scene from quicklist";
			else if (msg == 2)
				message = "Unable to add scene to quicklist";
			try {jQuery.jGrowl(message); } catch (e) {}
			if (box){
				box.onclick = function() {toggleQuicklist(scene_id);};
				box.className = msg == 1? "remove" : "quicklist";
			}
		}
	});
}


function toggleQuicklist_player(scene_id) {
	var box = document.getElementById("quicklist_" + scene_id);
	if (box) box.onclick = null;
	jQuery.ajax({
		type: "POST",
		url: "/ajax/action_quicklist.php",
		data: "id=" + scene_id + "&action=toggle",
		success: function (msg) {
			increment = 0;
			var message = "Malformed request";
			if (msg == 1) {
				increment = 1;
				message = "Scene " + scene_id + " has been added to your quicklist"
			} else if (msg == 3) {
				increment = -1;
				message = "Scene " + scene_id + " has been removed from quicklist";
			} else if (msg == 4)
				message = "Unable to remove scene from quicklist";
			else if (msg == 2)
				message = "Unable to add scene to quicklist";
			try {jQuery.jGrowl(message); } catch (e) {}
			if (box) {
				box.onclick = function() {toggleQuicklist(scene_id);};
				box.className = msg == 1? "remove" : "quicklist";
			}
			var count = jQuery("#playlists .smallInfo span");
			var num = parseInt(count.html().match(/\d+/));
			count.html(count.html().replace(num, num + increment));
			populateQuickList();			
		}
	});	
}



/* ajax call to populate the quicklist on a player page */
function populateQuickList() {
	jQuery.ajax({
		type: "GET",
		url: "/ajax/quicklist_section.php",
		success: function (msg) {
			jQuery('#quicklist-section').html(msg);
		}
	});

}

