
var xmlhttp;


function addfav(uid) {
	loadFav('/xmldata/addfav.cfm?fid='+uid);
}

function loadFav(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for all new browsers
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5 and IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=fav_state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function fav_state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = OK
	if(xmlhttp.responseText.indexOf('1') > -1){
		alert('Favorite Added!');
	} else if ( xmlhttp.responseText.indexOf('3') > -1) {
		alert('Surely, you are your own favorite, but you cant do that!');
	} else {
		alert('Favorite already exists!');
	}
    
	
	}
  else
    {
    alert("Problem retrieving XML data");
    }
  }
}
