jQuery(document).ready(function ($) {

    // Listings Scroll
    $('.properties-info-container .slider_control_right').click(function(e) {

        var list = $('.properties-info-container .featured-property-list');
        var total = list.children('li').length;
        var theID = list.attr('id');

        var currentItem = list.find('li.current');
        var item = currentItem.index();

        if (item < 0) {
            item = 0;
        } else {
            currentItem.removeClass('current');
        }

        var listitem = list.find('li:eq(' + item + ')');

        var height = listitem.outerWidth(true);

        //var offset = $(this).parent().parent().css('marginTop').replace("px", "");
        //height = height - offset;


        if (item >= total - 4) {
            item = total - 4;
        } else {
            list.animate({'left':'-=' + height + 'px'}, 250);
            item++;
        }

        list.children('li:eq(' + item + ')').addClass('current');

        e.preventDefault();

    });

    $('.properties-info-container .slider_control_left').click(function(e) {

        var list = $('.properties-info-container .featured-property-list');
        var total = list.children('li').length;
        var theID = list.attr('id');

        var currentItem = list.children('li.current');
        var item = currentItem.index();


        if (item > 0) {

            item--;

            currentItem.removeClass('current');

            var listitem = list.find('li:eq(' + item + ')');

            var height = listitem.outerWidth(true);

            //var offset = $(this).parent().parent().css('marginTop').replace("px", "");
            //height = height - offset;

            if (item < 0) {
                item = 0;
            } else {
                list.animate({'left':'+=' + height + 'px'}, 250);
            }

            list.children('li:eq(' + item + ')').addClass('current');
        } else {
            list.children('li:eq(0)').addClass('current');
        }

        e.preventDefault();

    });
});

