/*
	jQuery OneFBLike v1.0 - http://www.onerutter.com/onefblike
	Copyright (c) 2010 Jake Rutter
	This plugin available for use in all personal or commercial projects under both MIT and GPL licenses.
*/

(function($){  
    $.fn.extend({
        oneFBLike: function(options) {  
        
            //Set the default values, use comma to separate the settings 
            var defaults = {  
            }  
            
            var options =  $.extend(defaults, options);  
                        
            return this.each(function() {  
                var o = options;  
                var obj = $(this);
                
                jQuery('body').append('<div id="fb-root"></div>');
                
                // setup FB Developers App Link
                window.fbAsyncInit = function() {
				FB.init({appId: o.appID, status: true, cookie: true, xfbml: true});
				};
			
				(function() {
				var e = document.createElement('script'); e.async = true;
				e.src = document.location.protocol +
				'//connect.facebook.net/en_US/all.js';
				document.getElementById('fb-root').appendChild(e);
				}());

                // Determine the length of items here and calculate the number hidden
                var dynUrl = document.location;
                var fbDIV = obj;
                                                                
                fbDIV.each(function(){
                		jQuery(fbDIV).html('<fb:like href="'+dynUrl+'" width="450" height="40"/>')
				});

                              
            });  
        } 
    }); 
})(jQuery);