$(document).ready(function () {
    function startScrolling(scroller_obj, velocity, start_from) {
        scroller_obj.children().bind('marquee', function (event, c) {
            var ob = $(this);
            var sw = parseInt(ob.parent().width());
            var tw = parseInt(ob.width());
            var tl = parseInt(ob.position().left);
            var v = 19000;
            var dr = (v * tw / sw) + v;
            switch (start_from) {
                case 'right':
                    if (typeof c == 'undefined') {
                        ob.css({ left: sw });
                        sw = -tw;
                    } else {
                        sw = tl - (tw + sw);
                    };
                    break;
                default:
                    if (typeof c == 'undefined') {
                        ob.css({ left: -tw });
                    } else {
                        sw += tl + tw;
                    };
            }
            ob.animate({ left: sw },
						{ duration: dr,
						    easing: 'linear',
						    complete: function () { ob.trigger('marquee'); },
						    step: function () {
						        if (start_from == 'right') {
						            if (parseInt(ob.position().left) < -parseInt(ob.width())) {
						                ob.stop();
						                ob.trigger('marquee');
						            };
						        } else {
						            if (parseInt(ob.position().left) > parseInt(ob.parent().width())) {
						                ob.stop();
						                ob.trigger('marquee');
						            };
						        };
						    }
						});
        }).trigger('marquee');
        scroller_obj.mouseover(function () {
            $(this).children().stop();
        });
        scroller_obj.mouseout(function () {
            $(this).children().trigger('marquee', ['resume']);
        });
    };
    $('.scroller').css("cursor", "pointer");
    var scroller = $('.scroller');
    var scrolling_velocity = 1;
    var scrolling_from = 'right';
    startScrolling(scroller, scrolling_velocity, scrolling_from);

    if (window.location.pathname.indexOf("personal") != -1) {
        $("#whatsnew").addClass("homeboxl1");
        $("#jCarousel li").css("width", "285px");
        $("#jCarousel li").css("padding-top", "13px");
        $(".jCarouselLite").jCarouselLite({
            visible: 4,
            mouseWheel: true,
            auto: 1800,
            vertical: true,
            speed: 3000
        });
    } else {
        $("#whatsnew").addClass("homeboxl");
        $(".jCarouselLite").jCarouselLite({
            visible: 4,
            mouseWheel: true,
            auto: 1800,
            vertical: true,
            speed: 3000
        });
    }

    $('#features').jshowoff({ speed: 5000, changeSpeed: 1000 });
});

