
var SocialButtons = {};

var ElementNameToAlignWith;
var SocialButtonElementName;
var TopOffset;
var LeftOffset;

SocialButtons.init = function (classToAlignWith, socialButtonsElementName, topPos, leftPos) {

    ElementNameToAlignWith = classToAlignWith;
    SocialButtonElementName = socialButtonsElementName;
    TopOffset = topPos;
    LeftOffset = leftPos;

    $(window).bind("resize", SocialButtons.checkWindowResize);
    $(window).bind("scroll", SocialButtons.checkWindowResize);
    SocialButtons.checkWindowResize();
};

SocialButtons.checkWindowResize = function () {
    var w = $(window).width();
    var s = $(window).scrollTop();

    var leftPos = $(ElementNameToAlignWith).offset().left;
    var topPos = $(ElementNameToAlignWith).offset().top;
    s = topPos - s;

    //for peppers only as of now - not for booking engine only for DNN side
    var topMargin = $(SocialButtonElementName).css("margin-top").replace('px', '');

    if (s < TopOffset - topMargin) {
        s = TopOffset - topMargin;
    }

    $(SocialButtonElementName).css({ position: 'fixed', top: s, left: leftPos - LeftOffset });
};

