﻿function fbs_click()
{
    u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'facebook','toolbar=0,status=0,width=626,height=436');return false;
}
function digg_click()
{
    u=location.href;t=document.title;window.open('http://digg.com/submit?phase=2&amp;url='+encodeURIComponent(u)+'&amp;title='+encodeURIComponent(t), 'digg', 'toolbar=0,status=0,scrollbars=1,resizable=0');return false;
}
function delicious_click()
{
    u=location.href;t=document.title;window.open('http://del.icio.us/post?url='+encodeURIComponent(u)+'&amp;title='+encodeURIComponent(t), 'delicious', 'toolbar=0,status=0,scrollbars=1,resizable=0');return false;
}
function yahoo_click()
{
    u=location.href;window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(u)+'&amp;=', 'yahoo', 'toolbar=0,status=0,scrollbars=1,resizable=0');return false;
}
function google_click()
{
    u=location.href;t=document.title;window.open('http://www.google.com/bookmarks/mark?op=add&amp;bkmk='+encodeURIComponent(u)+'&amp;title='+encodeURIComponent(t), 'google', 'toolbar=0,status=0,scrollbars=1,resizable=0');return false;
}

function btnSend_Click(sURL)
{
    var sMessage = document.getElementById('txtMessage').value;
    var sTitle = document.title;
    var sSenderEmail = document.getElementById('txtSenderEmail').value;
    var sRecipientEmail = document.getElementById('txtRecipientEmail').value;

    Searches.Ajax.TellAFriend.Service.AJAX_SendEmail(sMessage, 
                                                      sURL,
                                                      sTitle,
                                                      sSenderEmail,
                                                      sRecipientEmail,
                                                      credentials,
                                                      OnSucceeded_Send,
                                                      OnFailed_Send)
}

function OnSucceeded_Send(result,
                          eventArgs)
{
     document.getElementById('spnMessage').innerHTML = result;

     var btn = document.getElementById('btnSent');

     if (result == "Article Sent")
     {
         document.getElementById('txtRecipientEmail').value = "";
         if (btn.value == 'Send Another')
         {
             btn.value = 'Send One More';
         }
         else
         {
             btn.value = 'Send Another';
         }
     }
}

function OnFailed_Send(error)
{
    window.alert(error.get_message());
    document.getElementById('spnMessage').innerHTML = 'Error: no message sent.';
}