function contactVendor(vendor_id) {
  url = "/ad/contactVendor/"+vendor_id;
  doPopUp(url, 800, 300);
}

function sendToFriend() {
  url = "/ad/sendToFriend/"+window.vendor_id;
  doPopUp(url, 800, 300);
}

function addToFave(vendor_id) {
  new Ajax.Request('/ajax.php',
        {
          method: 'post',
          parameters: {c:'FavoritesController', m:'add', vendor_id: window.vendor_id},
          onSuccess: function(transport) {
            response = transport.responseText;
            if(response.indexOf("SUCCESS") > -1) {
              document.getElementById("fav").innerHTML = "Added!";
            } else if(response.indexOf("log in")) {
              alert("Please log in first!");
            } else {
              alert("An error occured while adding to your favorites.");
            }
          },
          onFailure: function(transport) {
            alert("An error occured while adding to your favorites.");
          }
        }
  );
}

function doPopUp(url, width, height) {
  window.open(url,'','resize=off,titlebar=false,status=false,menubar=false,location=false,scrollbars=false,toolbar=no,width='+width+',height='+height);
}