// function addremove(favid,){
function addremove(uid,euid,num,status){

// alert(euid);
// Configure those variables as appropriate

var divid = 'status';
var url = 'favscript/addremove.php';


// The XMLHttpRequest object

var xmlHttp;
try{
xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
}
catch (e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
}
catch (e){
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Your browser does not support AJAX.");
return false;
}
}
}


// Generate timestamp for preventing IE caching the GET request

fetch_unix_timestamp = function()
{
return parseInt(new Date().getTime().toString().substring(0, 10))
}

var timestamp = fetch_unix_timestamp();
var nocacheurl = url+"?t="+timestamp;


// This code sends the variables through AJAX and gets the response

// Demonstration of whats happening
// alert(nocacheurl+"&uid="+uid+"&euid="+euid);
// favscript/addremove.php?t=1251856692&uid=27&euid=121
xmlHttp.open("GET",nocacheurl+"&uid="+uid+"&euid="+euid,true);
xmlHttp.send(null);


// Finally, some code for button toggle

var button = document.getElementById('button');


switch(button.name)
{
case 'button0':
  button.src = 'http://www.salon-cafe.com/layout/pc/images/button/favorite_d_jp.gif';
  button.name = 'button1';
  document.getElementById('f_num').innerHTML = num;
  if(status == 1){
	document.getElementById('f_num').innerHTML = num;
  }else{
    document.getElementById('f_num').innerHTML = num+1;
  }
  break;
case 'button1':
  button.src = 'http://www.salon-cafe.com/layout/pc/images/button/favorite_jp.gif';
  button.name = 'button0';
  if(status == 1){
	document.getElementById('f_num').innerHTML = num-1;
  }else{
    document.getElementById('f_num').innerHTML = num;
  }
  break;
}





}
