 if (window.XMLHttpRequest)
  {
  xmlHttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
  }

 function addToFavorites(shopid) {
    document.getElementById('AJAXAddToFavoritesIndicator').style.display = "inline";
	xmlHttp.open("GET", "/ajax.favorites.php?action=add&shopid=" + shopid, true);
	xmlHttp.onreadystatechange=addToFavorites__;
	xmlHttp.send(null);
	// ToDo: Indicator
 }
 
 function addToFavorites__() {
 	if(xmlHttp.readyState == 4) {
		document.getElementById('AJAXAddToFavoritesIndicator').style.display = "none";
		if(xmlHttp.responseXML.getElementsByTagName('status')[0].firstChild.nodeValue == "ADDED")
		  document.getElementById('AJAXAddToFavoritesStatus_Added').style.display="inline";
		if(xmlHttp.responseXML.getElementsByTagName('status')[0].firstChild.nodeValue == "ALREADY_EXISTS")
		  document.getElementById('AJAXAddToFavoritesStatus_Error').style.display="inline";

        setTimeout("addToFavoritesStatusHide();", 4000);
 	}
 }
 
 function addToFavoritesStatusHide() {
 	document.getElementById('AJAXAddToFavoritesStatus_Error').style.display="none";
 	document.getElementById('AJAXAddToFavoritesStatus_Added').style.display="none";
 }
 

 function removeFromFavorites(shopid) {
    document.getElementById('AJAXRemoveFromFavoritesIndicator').style.display = "inline";
	xmlHttp.open("GET", "/ajax.favorites.php?action=delete&shopid=" + shopid, true);
	xmlHttp.onreadystatechange=removeFromFavorites__;
	xmlHttp.send(null);
 }
 
 function removeFromFavorites__() {
 	if(xmlHttp.readyState == 4) {
		document.getElementById('AJAXRemoveFromFavoritesIndicator').style.display = "none";
		
		if(xmlHttp.responseXML.getElementsByTagName('status')[0].firstChild.nodeValue == "DELETED")
		  document.getElementById('AJAXRemoveFromFavorites_Done').style.display="inline";
        setTimeout("removeFromFavoritesStatusHide();", 4000);
 	}
 }
 
 function removeFromFavoritesStatusHide()  {
 	document.getElementById('AJAXRemoveFromFavorites_Done').style.display="none";
 }

 
function checkInput(e)
{
    if(!e) {
        e = window.event;
    }
    if(e.which) {
        taste = e.which;
    } else if(e.keyCode) {
        taste = e.keyCode;
    }
    if(taste == 13)
      document.searchform.submit();
} 
