/*
jQuery OneFBLike v1.0 - http://onerutter.com/open-source/jquery-facebook-like-plugin.html
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 = {
                appID: '',
                siteTitle: '',
                siteName: '',
                siteImage: '',
                buttonWidth: 300,
                buttonHeight: 80,
                showfaces: false,
                font: 'lucida grande',
                layout: 'normal',
                action: 'like',
                colorscheme: 'light',
                productId: '',
                currentDivId: '',
                categoryId: ''
            }

            var options = $.extend(defaults, options);

            return this.each(function () {
                var o = options;
                var obj = $(this);

                // Grab the URL and assign it to a variable
                var dynUrl = document.location;
                if (o.productId != '' && o.categoryId != '') {
                    //var baseUrl = GetBaseURL();
                    dynUrl = o.categoryId + "/" + o.productId + "/" + o.siteTitle.replace(/[^a-zA-Z0-9-_]/g, '') + "/";
                }

                //dynUrl = dynUrl.replace(/[^a-zA-Z0-9-_]/g, '');
                dynUrl = GetBaseURL() + "Order/Index/" + dynUrl;

                var fbDIV = obj;
                //alert(dynUrl);
                // Apply the like button to an element on the page and include all available options
                // If no options are passed in from the page, the defaults will be applied            
                jQuery(fbDIV).html('<fb:like href="' + dynUrl + '" width="' + o.buttonWidth + '" height="' + o.buttonHeight + '" show_faces="' + o.showfaces + '" font="' + o.font + '" layout="' + o.layout + '" action="' + o.action + '" colorscheme="' + o.colorscheme + '" />');

            });
        }
    });
})(jQuery);
