// METHOD :: Sends are commendation to a friend
function sendToFriend(button) {

   var canSubmit = true;
   canSubmit = XValidate(document.getElementById("sendto_name"), XChecks.checkLength, 1) ? canSubmit : false;
   canSubmit = XValidate(document.getElementById("sendto_mail"), XChecks.isMail, 1)      ? canSubmit : false;

   if (!canSubmit) {
      return;
   }

   button.disabled = true;

   var params = "content=com_content" +
                "&task=send"          +
                "&sendto_name="       + encodeURIComponent(document.getElementById("sendto_name").value) +
                "&sendto_mail="       + encodeURIComponent(document.getElementById("sendto_mail").value) +
                "&id="                + document.getElementById("item_id").value;
                "&"                   + Math.random();

   XAjax(params, false);
   XPopup.hide();

   return false;
}

function doVote(button) {
   button.disabled = true;
   
   var params = "content=com_content" +
                "&task=vote"          +
                "&vote_grade="        + encodeURIComponent(document.getElementById("vote_grade").value) +
                "&id="                + document.getElementById("item_id").value;
                "&"                   + Math.random();

   XAjax(params, false, function(a) {alert(a);});
   XPopup.hide();

   return false;      
}

// Send to friend validation
fieldValidator.add("sendto_name", "keyup", function(){XValidate(this, XChecks.checkLength, 1);});
fieldValidator.add("sendto_mail", "keyup", function(){XValidate(this, XChecks.isMail, 1);});

// Vote validation
fieldValidator.add("vote_grade", "change", function(){XValidate(this, XChecks.checkLength, 1);});