/**
 * Modern News Ticker
 * Copyright (c) CreativeTier
 * contact@CreativeTier.com
 * www.CreativeTier.com
 */ (function (e) {
    var t = {
        effect: "scroll"
    };
    var n = {
        scroll: {
            scrollInterval:20,
            transitionTime:500
        },
        slide: {
            slideDistance:100,
            displayTime:4e3,
            transitionTime:350
        }
    };
    var i = {
        init: function (t) {
            var i = {};

            e.extend(i, {
                effect: t.effect
            });
            e.extend(i, n[i.effect]);
            e.extend(i, t);
            return this.each(function () {
                function w() {
                    p.addClass("mt-hide");
                    h.addClass("mt-preloader");
                    p.children().remove();
                    p.css("margin-left", 0);
                    d.css("opacity", "1").removeClass("mt-hide");
                    p.append(d);
                }
                function E() {
                    h.removeClass("mt-preloader");
                    p.removeClass("mt-hide");
                    x()
                }

                function x() {
                    if (i.effect != "scroll") p.children("li:not(:first)").addClass("mt-hide");
                            k();
                            _()
                }
                function N(e) {
                    C(e.data.type)
                }
                function C(t) {
                    if (!s) {
                        s = true;
                        if (t == "prev") {
                            switch (i.effect) {
                            case "scroll":
                                p.css({
                                    "margin-left": -e(p.children(":last")).outerWidth()
                                }).children(":last").prependTo(p);
                                p.animate({
                                    "margin-left": 0
                                }, i.transitionTime, function () {
                                    s = false;
                                });
                                break;
                            case "slide":
                                p.children(":first").animate({
                                    opacity: 0
                                }, i.transitionTime, function () {
                                    e(this).addClass("mt-hide");
                                    p.children(":last").prependTo(p).removeClass("mt-hide").css({
                                        opacity: 0,
                                        "margin-left": i.slideDistance
                                    }).animate({
                                        opacity: 1,
                                        "margin-left": 0
                                    });
                                    s = false
                                });
                                break
                            }
                        } else {
                            switch (i.effect) {
                            case "scroll":
                                p.animate({
                                    "margin-left": -e(p.children(":first")).outerWidth()
                                }, i.transitionTime, function () {
                                    p.css("margin-left", 0).children(":first").appendTo(p);
                                    s = false;
                                });
                                break;
                            case "slide":
                                p.children(":first").animate({
                                    opacity: 0
                                }, i.transitionTime, function () {
                                    e(this).addClass("mt-hide").appendTo(p);
                                    p.children(":first").removeClass("mt-hide").css({
                                        opacity: 0,
                                        "margin-left": i.slideDistance
                                    }).animate({
                                        opacity: 1,
                                        "margin-left": 0
                                    });
                                    s = false
                                });
                                break
                            }
                        }
                    }
                }
                function k() {
                    n = true;
                    if (i.effect == "scroll") {
                        t = setInterval(function () {
                            var t = parseFloat(p.css("margin-left")) - 1;
                            p.css("margin-left", t);
                            if (Math.abs(t) > e(p.children("li")[0]).outerWidth()) {
                                p.css("margin-left", 0).children(":first").appendTo(p)
                            }
                        }, i.scrollInterval)
                    } else {
                        t = setInterval(function () {
                            C("next")
                        }, i.displayTime)
                    }
                }
                function L() {
                    n = false;
                    clearInterval(t)
                }
                function M(e) {
                    var t = e.html().split("");
                    var n = 0;
                    e.html("_");
                    var r = setInterval(function () {
                        var i = e.html().split("_")[0] + t[n++];
                        if (n != t.length) {
                            i += "_"
                        }
                        e.html(i);
                    }, i.typeInterval)
                }
                function _() {
                    y.addClass("mt-pause")
                }
                function D() {
                    y.removeClass("mt-pause")
                }
                function P() {
                    return false
                }
                var t;
                var n = false;
                var s = false;
                var f;
                var l = e(this);
                var c = l.children(".mt-label");
                var h = l.children(".mt-news");
                var p = h.children("ul");
                var d = p.children("li");
                var v = l.children(".mt-controls");
                var m = v.children(".mt-prev");
                var g = v.children(".mt-next");
                var y = v.children(".mt-play");
                if (i.effect == "scroll") l.addClass("mt-scroll");
                c.css("width", c.width());
                var b = l.width();
                if (c.length) b -= c.outerWidth() + parseFloat(c.css("margin-right"));
                if (v.length) b -= v.outerWidth() + parseFloat(v.css("margin-left"));
                h.css("width", b);
                m.mousedown(P).bind("click", {
                    type: "prev"
                }, N);
                g.mousedown(P).bind("click", {
                    type: "next"
                }, N);
                y.mousedown(P).click(function () {

                        if (n) {
                            L();
                            D()
                        } else {
                            k();
                            _()
                        }

                });
                    x()
            })
        },
        pause: function () {
            return this.each(function () {
                e(this).data("pause")()
            })
        },
        resume: function () {
            return this.each(function () {
                e(this).data("resume")()
            })
        },
    };
    e.fn.modernTicker = function (t) {
        if (i[t]) {
            return i[t].apply(this, Array.prototype.slice.call(arguments, 1))
        } else if (typeof t === "object" || !t) {
            return i.init.apply(this, arguments)
        //} else {
        //    e.error("Method " + t + " does not exist on jQuery.modernTicker")
        }
    }
})(jQuery)




$(document).ready(function() {

	$("#home-ticker").modernTicker({
		effect: "scroll",
		scrollInterval: 20,
		transitionTime: 500
	});
	// slide : slideDistance: 100, displayTime: 4000, transitionTime: 350
	// scroll : scrollInterval: 20, transitionTime: 500

});











