jQuery(document).ready(function(){
        var inner_url = facebook_url;
        jQuery("#socialbookmarkscript_div_link").remove();
        if (typeof facebook_url == "undefined" || facebook_url == "") {
                facebook_url = window.location;
        }
        var newtop = '22px';
        var newheight = 120;
        if (facebook_vcenter==true) {
                newtop = (jQuery(window).height() - newheight)/2  + 'px';
        }

        if (facebook_position=='right') {

                var $newdiv1 = jQuery('<div id="fblink"/>')
                jQuery('#facebooksidepanel_div').prepend($newdiv1);
                jQuery("#fblink").css({ width:'35px', height:newheight+'px', float:'left'});
                jQuery("#fblink").click(function() {
                  window.location.href = ""+inner_url;
                });

                jQuery("#facebooksidepanel_div").css({
                                                                                   position:'fixed',
                                                                                   top:newtop,
                                                                                   right:'-91px',
                                                                                   width:'120px',
                                                                                   height:newheight+'px',
                                                                                   display:'block',
                                                                                   cursor:'pointer',
                                                                                   'z-index':'100',
                                                                                   'background-color':'transparent',
                                                                                   'background-image': 'url(tpl/images/sidepanel_facebook_back.png)',
                                                                                   'background-repeat':'no-repeat'
                                                                                   });
                jQuery("#facebooksidepanel_div").mouseenter(function(){
                  jQuery("#facebooksidepanel_div").animate({ right:'0px' }, 150 );
                });
                jQuery("#facebooksidepanel_div").mouseleave(function(){
                  jQuery("#facebooksidepanel_div").animate({ right:'-91px' }, 150 );
                });
                jQuery("#fblink").mouseenter(function(){
                  jQuery("#facebooksidepanel_div").animate({ right:'0px' }, 150 );
                });
                jQuery('<iframe />', {
                        name:        'socialbookmarkscript_facebook',
                        id:                'socialbookmarkscript_facebook',
                        src:        'http://www.facebook.com/plugins/like.php?href='+facebook_url+'&layout=box_count&show_faces=false&width=100&action=like&font=arial',
                        style:        'overflow:hidden; border:none; borderwidth:0px; width:77px; padding:0; margin:0; height:62px; margin-top:18px; margin-left:0px;',
                        scrolling: 'no',
                        border: 0,
                        frameborder: 0
                }).appendTo(jQuery("#facebooksidepanel_div"));

        } else {

                var $newdiv1 = jQuery('<div id="fblink"/>')
                jQuery('#facebooksidepanel_div').prepend($newdiv1);
                jQuery("#fblink").css({ width:'35px', height:newheight+'px', float:'right'});
                jQuery("#fblink").click(function() {
                  window.location.href = ""+inner_url;
                });

                jQuery("#facebooksidepanel_div").css({
                                                                                   position:'fixed',
                                                                                   top:newtop,
                                                                                   left:'-91px',
                                                                                   width:'120px',
                                                                                   height:newheight+'px',
                                                                                   display:'block',
                                                                                   cursor:'pointer',
                                                                                   'z-index':'100',
                                                                                   'background-color':'transparent',
                                                                                   'background-image': 'url(tpl/images/socialmedia_facebook_sidepanel_left.png)',
                                                                                   'background-repeat':'no-repeat'
                                                                                   });
                jQuery("#facebooksidepanel_div").mouseenter(function(){
                 jQuery("#facebooksidepanel_div").animate({ left:'0px' }, 150 );
                });
                jQuery("#facebooksidepanel_div").mouseleave(function(){
                  jQuery("#facebooksidepanel_div").animate({ left:'-91px' }, 150 );
                });
                jQuery('<iframe />', {
                        name:        'socialbookmarkscript_facebook',
                        id:                'socialbookmarkscript_facebook',
                        src:        'http://www.facebook.com/plugins/like.php?href='+facebook_url+'&layout=box_count&show_faces=false&width=100&action=like&font=arial',
                        style:        'overflow:hidden; border:none; borderwidth:0px; width:77px; padding:0; margin:0; height:62px; margin-top:18px; margin-left:5px;',
                        scrolling: 'no',
                        border: 0,
                        frameborder: 0
                }).appendTo(jQuery("#facebooksidepanel_div"));

        }




});
