﻿$(document).ready(function() {


    $("ul.sf-menu").superfish({
        animation: { opacity: 'show', height: 'show' },
        speed: 'fast',
        autoArrows: false,
        delay: 100             // .1 second delay on mouseout

    });

    $('textarea.expanding').autogrow({
        lineHeight: 14
    });

    $('a[rel*=facebox]').facebox();

    $('.row, .inputBox').focus(function() {
        $(this).parents('.row').addClass("highlightrow");
    }).blur(function() {
        $(this).parents('.row').removeClass("highlightrow");
    });


    // Scrolling ticker function on CPA Cafe page
    $(function() {

        //cache the ticker
        var ticker = $("#ticker");

        //hide the scrollbar
        ticker.css("overflow", "hidden");

        //animator function
        function animator(currentItem) {

            //work out new anim duration
            var distance = currentItem.width();
            duration = (distance + parseInt(currentItem.css("marginLeft"))) / 0.025;

            //animate the first child of the ticker
            currentItem.animate({ marginLeft: -distance }, duration, "linear", function() {

                //move current item to the bottom
                currentItem.appendTo(currentItem.parent()).css("marginLeft", 0);

                //recurse
                animator(currentItem.parent().children(":first"));
            });
        };

        //start the ticker
        animator(ticker.children(":first"));

    });





}); 