// JavaScript Document

function GetToddFBWall() {
$('#toddfb').fbWall({id:'ToddandTheBookofPureEvil',accessToken:'AAAC7gAoWDQ0BAHm7OoVx2sSWGOhWdLiZAy6ZCwpTrOD6PQsDNwZAqZCUdZCqJosKyvqISG0Y3pRAPn3bZCRWdLLC3fiEmbefYZD',showGuestEntries:true,showComments:true,max:5,timeConversion:24});
}

function GetToddSidebarWall () {
$('#sidetoddfb').fbWall({id:'ToddandTheBookofPureEvil',accessToken:'AAAC7gAoWDQ0BAHm7OoVx2sSWGOhWdLiZAy6ZCwpTrOD6PQsDNwZAqZCUdZCqJosKyvqISG0Y3pRAPn3bZCRWdLLC3fiEmbefYZD',showGuestEntries:true,showComments:false,max:3,timeConversion:24});
}

function fbToddGo(postMsg) {
	FB.login(function(response)
		 {
        if (response.authResponse)
        {
            //alert('Logged in!');

            // Post message to friend's wall

            var opts = {
                message : postMsg,
                //name : 'Blah blah',
                //link : 'http://pixelpusher.ca/',
                //description : 'Description here',
                //picture : 'http://pixelpusher.ca/pic.jpg'
            };

            FB.api('/ToddandTheBookofPureEvil/feed', 'post', opts, function(response)
            {
                if (!response || response.error)
                {
                    alert('Posting error occured');
                }
                else
                {
                    //alert('Success - Post ID: ' + response.id);
					location.reload();
                }
            });
        }
        else
        {
            alert('Not logged in');
        }
    }, { scope : 'publish_stream' });
};

    
 
 $(document).ready(function() {
	GetToddFBWall();
	GetToddSidebarWall();
	
	$('a#btnMessagePost').live('click',function(e) {
		e.preventDefault();
		var postMsg = $('#wallMessage').val();
		fbToddGo(postMsg);
	});
	
});
