﻿/* Fader */
(function($) {

    $.fn.ebofader = function(options) {

        var defaults = {
            alignment: "bottom",
            title: "",
            showTitle: false,
            showBubble: false
        };

        var options = $.extend(defaults, options);

        return this.each(function() {
            var objFadeElement = $(this);
            var curr = 0
            var intervalID = null

            function FadeIn() {
                $("div:eq(" + curr + ")", objFadeElement).fadeIn(3000)
            }

            function DoAnimation() {
                $("div:eq(" + curr + ")", objFadeElement).fadeOut(3000, FadeIn);
                curr = curr + 1
                if (curr >= $("div", objFadeElement).size()) {
                    curr = 0
                }
            }

            function StartAnimation() {
                intervalID = setInterval(DoAnimation, 8000)
            }

            function StopAnimation() {
                clearInterval(intervalID)
            }

            objFadeElement.hover(StopAnimation, StartAnimation)

            StartAnimation()
        });
    };
})(jQuery);

/* Popup */
(function($) {

    $.fn.ebopopup = function(options) {

        var defaults = {
            alignment: "bottom",
            title: "",
            showTitle: false,
            showBubble: false,
            popupchildElementID: "div#SigninPopup",
            callback: null
        };

        var options = $.extend(defaults, options);

        return this.each(function() {
            var objPopupElement = $(this);
            var popupchildElement = $(options.popupchildElementID);

            objPopupElement.click(
            function onpopupclick() {
                var p = objPopupElement.offset();
                var w = objPopupElement.width();
                var h = objPopupElement.outerHeight();
                var tw = $("div#SigninPopup").width()
                var th = $("div#SigninPopup").height()
                //var tl = p.left - (tw / 2) + (w / 2);
                var tl = p.left;
                $("div#SigninPopup").css({ top: (p.top + 15) + "px", left: tl + "px" }).show('slow');

                _TrapOtherClick = function(event) {
                    if ($(event.target) != objPopupElement && !$(event.target).parent().hasClass("SPopup")) {
                        popupchildElement.hide('slow')
                        if (options.callback) options.callback()
                    }
                }

                $(document.body).mousedown(_TrapOtherClick);
            });

            $("a.close", $("div#SigninPopup")).click(
                function() {
                    $("div#SigninPopup").hide('slow');
                }
            );
        });
    };
})(jQuery);

/* Rounded Corner */
(function($) {
    $.fn.eboroundedcorner = function(options) {
        var defaults = {
            corners: "tl,tr,bl,br",
            borderColor: "#32434d",
            prefixChar :"b"
        };

        var options = $.extend(defaults, options);

        return this.each(function() {
            var objElement = $(this);

            if (objElement.attr("rounded") != "1") {
                var strBgColor = ""
                for (var i = 4; i >= 1; i--) {
                    strBgColor = "style=\"background-color:" + options.borderColor + "\""
                    if (i == 1) strBgColor = ""
                    objElement.prepend("<b class=\"" + options.prefixChar + i + "\"" + strBgColor + "></b>");
                    objElement.append("<b class=\"" + options.prefixChar + i + "\"" + strBgColor + "></b>");
                }
                objElement.attr("rounded", "1")
            }
        });
    };
})(jQuery);

function DoEboTrack()
{
}
