﻿function fbPost(target_id, url, sid)
{
    var msg = '';
    var action_link;
    var attachment;
    var auto_publish = true;
    callPublish(msg, attachment, action_link, target_id, auto_publish);
}

function fbAward(target_id, type, score)
{
    //alert("award!!");
    var msg = '';
    var action_link = [{ 'text': 'Become A Fan!', 'href': 'http://www.facebook.com/apps/application.php?id=211638528095'}];
    var attachment;
    var auto_publish = true;
    switch (type)
    {
        case "1strike":
            //alert("strike");
            attachment = { 'name': 'Strike!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': '' + fbname + ' just knocked down ten \'pinguins\' with a single ball in Ten-Pin Crazy Golfing.  Maybe one of them had your face on it?  Get your revenge with a few frames of your own!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/1strike.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "2strikes":
            attachment = { 'name': 'It\'s the Double!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored two strikes in a row in Ten-Pin Crazy Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/2strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "3strikes":
            attachment = { 'name': 'What a Turkey!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored three strikes in a row in Ten-Pin Crazy Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/3strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "4strikes":
            attachment = { 'name': 'Lucky Like a Clover!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored four strike in a row in Ten-Pin Crazy Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/4strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "5strikes":
            attachment = { 'name': 'With One Hand!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored five strikes in a row in Ten-Pin Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/5strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "6strikes":
            attachment = { 'name': 'Half a Dozen of the Other!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored six strikes in a row in Ten-Pin Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/6strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "7strikes":
            attachment = { 'name': 'Lucky for Some!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored seven strikes in a row in Ten-Pin Crazy Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/7strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "8strikes":
            attachment = { 'name': 'Double Clover!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored eight strikes in a row in Ten-Pin Crazy Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/8strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "9strikes":
            attachment = { 'name': 'Fellowship of the Bowl!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored nine strikes in a row in Ten-Pin Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/9strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "10strikes":
            attachment = { 'name': 'On Course!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored ten strikes in a row in Ten-Pin Crazy Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/10strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "11strikes":
            attachment = { 'name': 'Nearly There!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just scored eleven strikes in Ten-Pin Crazy Golfing!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/11strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "12strikes":
            attachment = { 'name': 'PERFECT GAME!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just played a perfect game on Ten-Pin Crazy Golfing.  You ain\'t beating that, because there aren\'t any more points in the game!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/12strikes.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "lv5comp":
            //alert("5lev");
            attachment = { 'name': 'Half Way Hero!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just finished the fifth course on Ten-Pin Crazy Golfing with a score of ' + score + '.  I bet you could do better than that!  Give it a try!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/level5Complete.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "lv10comp":
            attachment = { 'name': 'The Big Finish!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': '' + fbname + ' has completed all ten courses in Ten-Pin Crazy Golfing.  Took \'em a while too...  Show them how it\'s done! Final Score:' + score, 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/level10Complete.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "over100":
            attachment = { 'name': 'What a Century!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': ''+fbname+' has just broken the hundred point barrier in Ten-Pin Crazy Golfing, but don\'t fret, there are plenty of Pinguins left for you!', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/scoreOver100.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
        case "nopins":
            attachment = { 'name': 'Conservationist!', 'href': 'http://apps.facebook.com/tenpincrazygolfing/', 'description': '' + fbname + ' left all the pinguins standing.  They\'re not endangered, you know?', 'media': [{ 'type': 'image', 'src': 'http://facebook.matmi.com/tenpincrazygolfing/facebookAwards/noPinsDown.jpg', 'href': 'http://apps.facebook.com/tenpincrazygolfing/'}] };
            break;
    } 
    callPublish(msg, attachment, action_link, target_id, auto_publish);
}


function callPublish(msg, attachment, action_link, target_id, auto_publish)
{
    //FB.ensureInit(function ()
    //{
        FB.Connect.streamPublish(msg, attachment, action_link, target_id, null, null, auto_publish);
    //});
}

function sendEmail(recipientsArray, subjectString, textString,fbmlString)
{

    FB.ApiClient.notifications_sendEmail(recipientsArray, subjectString, textString, fbmlString, function () { });
}



