﻿

var bw, pw, c = 0, count, current = 0;
jQuery(document).ready(function() {
    bw = 860;
    jQuery('#mycarousel li').each(function() {
        c++;
    });
    pw = c * 205 + c * 10;
    count = c;
    var x7 = 0;
    var x14 = 0;
    jQuery('.jcarousel-next').click(function() {
        if (current < count - 4) {
            current++;
        } else {
            current = 0;
        }
        var m = parseInt(jQuery('#mycarousel').css('marginLeft')), d = current * 215;
        //if ((x7 - d) &lt; (bw - pw - x7)) d = Math.abs(bw - pw - x14);
        jQuery('#mycarousel').stop().animate({ 'marginLeft': (x7 - d) + 'px' }, Math.abs(x7 - d - m));
        //setCurrecntCounter();
    });
    jQuery('.jcarousel-prev').click(function() {
        if (current > 0) {
            current--;
        } else {
            current = count - 4;
        }
        var m = parseInt(jQuery('#mycarousel').css('marginLeft')), d = current * 215;
        //if ((x7 - d) &gt; (bw - pw - x7)) d = Math.abs(bw - pw - x14);
        jQuery('#mycarousel').stop().animate({ 'marginLeft': (x7 - d) + 'px' }, Math.abs(x7 - d - m));
        //setCurrecntCounter();
    });
});
