var xmlHttp

function addremoveFavorite(BID, CMID, stype, redirect, description, sessid)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var type="";
if (document.getElementById('searchlink').innerHTML == "Remove Search" || document.getElementById('searchlink').innerHTML == "Remove from MyLN")
   type = "Remove"
else
   type = "Add"
//alert(type);
//alert(document.getElementById('searchlink').innerHTML);
var FAVID = document.getElementById('FAVID').innerHTML
var url="/MyLN/AddRemoveFavorite.aspx";
url=url+"?BID=" + BID + "&CMID=" + CMID + "&FAVID=" + FAVID + "&type=" + type + "&stype=" + stype + "&redirect=" + redirect + "&description=" + description + "&SessionID=" + sessid;
url=url+"&sid="+Math.random();
//alert(url);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4){ 
   //alert(xmlHttp.responseText);
   if (document.getElementById('CMID').innerHTML == "7")
      document.getElementById('FAVID').innerHTML = xmlHttp.responseText;
      
   if (xmlHttp.responseText == "1")
      window.location="/memberservices/03_signin.aspx";
   else{
      if (document.getElementById('searchlink').innerHTML == "Add to MyLN")
         document.getElementById('searchlink').innerHTML = "Remove from MyLN";
      else {
         if (document.getElementById('searchlink').innerHTML == "Remove from MyLN")
            document.getElementById('searchlink').innerHTML = "Add to MyLN";
         else{
            if (document.getElementById('searchlink').innerHTML == "Save Search in MyLN")
               document.getElementById('searchlink').innerHTML = "Remove Search";
            else
               document.getElementById('searchlink').innerHTML = "Save Search in MyLN";
               }
         }
      }  
   }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}