$(document).ready(function() {

  $.ajax({
          url: "https://graph.facebook.com/1472352902/feed", // replace the number with the PAGEID of the FB page
          dataType: "jsonp",
          cache: true,
          error: function(e) {
               $("#wrapper").append("Error loading document".e);
          },
          success: function(data) {
               var string = "";
               var title = "";
               var likecode = "";
               var tweetcode = "";
              
               $mycounter = 0;

				string += '<h4>Ideas Worth Sharing  ';
				string += '<a href="http://www.facebook.com/interversant" target="_new"><img height="16" src="http://www.topnews.in/files/Facebook-Icon.png"></a>';
				string += '<a href="http://www.linkedin.com/pub/paul-riecks/0/681/34a" target="_new"><img height="16" src="http://www.ee360studios.com/Logo%20Files/linkedin-icon.png"></a>';
				string += '</h4>';

               string += '<ul>';

               $.each(data.data, function(i, item) {
              
                    if($mycounter>4) {  return; } // select the number of items to load in the widget

                    fblinkarray = item.id.split("_");
                    fbfulllink = 'http://www.facebook.com/permalink.php?story_fbid=' +fblinkarray[1]+ '&id=' +fblinkarray[0];
                   likecode = '<iframe src="http://www.facebook.com/plugins/like.php?href='+item.id+'&amp;layout=button_count&amp;show_faces=false&amp;width=125&amp;action=like&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:125px; height:22px;" allowTransparency="true"></iframe>';
                    linkherecode = location.href+'#'+item.id;    

                    string += '<li><a href="'+fbfulllink+'">'+item.name+'</a></li>'; // replace the href with the correct page to link to

                    $mycounter++;
              
               });
               
               string += '</ul>';

               $("#fbfeedwidgetwrapper").html(string);  // this is the name of the div that gets the results

               }         
          });
 });



