
function usertolist(artist, visitor) {
globalArtist = artist;
globalAction = "add";
if (ajax) {
ajax.open('get','artist2list.php?action=add&user=' + visitor + '&artist=' + encodeURIComponent(artist));
// Note to myself: handle_check call here CANNOT look like handle_check(). DONT KNOW WHY.
ajax.onreadystatechange = handle_check;
ajax.send(null);
}
else
{
clickid = artist + '-click';
}
}


function userfromlist(artist, visitor) {
globalArtist = artist;
globalAction = "remove";
if (ajax) {
ajax.open('get','artist2list.php?action=remove&user=' + visitor + '&artist=' + encodeURIComponent(artist));
// Note to myself: handle_check call here CANNOT look like handle_check(). DONT KNOW WHY.
ajax.onreadystatechange = handle_check;
ajax.send(null);
}
else
{
clickid = artist + '-click';
}
}


// userfromsearchlist is a duplicate function insofaras it uses most of the code
// from "userfromlist". However, this function will be used on the main shortlist page,
// where I actually want to "remove" the artists from the page once you click "Remove".
// this style change could probably be folded into another option for the userfromlist
// function but I'll keep it simple for now.

function userfromshortlist(artist, visitor) {
globalArtist = artist;
globalAction = "remove";
if (ajax) {
ajax.open('get','artist2list.php?action=remove&user=' + visitor + '&artist=' + encodeURIComponent(artist));
// Note to myself: handle_check call here CANNOT look like handle_check(). DONT KNOW WHY.
ajax.onreadystatechange = handle_removal;
ajax.send(null);
}
else
{
clickid = artist + '-click';
//document.getElementById(clickid).innerHTML = "NO-AJAX";
}
}


function handle_check() {

if ((ajax.readyState == 4) && (ajax.status == 200))
{

var clickid = globalArtist + '-click';

document.getElementById(clickid).innerHTML = ajax.responseText;
if (globalAction == "add")
{
document.getElementById(globalArtist).style.border = '3px red solid';
}
if (globalAction == "remove")
{
document.getElementById(globalArtist).style.border = '3px white solid';
}
}
}


function handle_removal() {

if ((ajax.readyState == 4) && (ajax.status == 200))
{

document.getElementById(globalArtist).style.display = "none";

}
}

