$(document).ready(function () {

    var windowWidth = 0;
    var domainName = document.domain;
    switch (domainName) {
        case 'rodev': windowWidth = 556; break;
        case 'www.rosesonly.com.au': windowWidth = 556; break;
        case 'hodev': windowWidth = 575; break;
        case 'www.hampersonly.com.au': windowWidth = 575; break;
    }

    $(".banner-window").css({ 'width': windowWidth });
    $(".banner-window").show();
    $(".banner-paging").show();
    $(".banner-paging a:first").addClass("active");

    var imageWidth = $(".banner-window").width();
    var imageSum = $(".banner-images img").size();
    var imageReelWidth = imageWidth * imageSum;

    $(".banner-images").css({ 'width': imageReelWidth });

    rotate = function () {
        var triggerID = $active.attr("rel") - 1;
        var image_reelPosition = triggerID * imageWidth;

        $(".banner-paging a").removeClass('active');
        $active.addClass('active');

        $(".banner-images").stop().animate({
            left: -image_reelPosition
        }, 500);

    };

    rotateSwitch = function () {
        play = setInterval(function () {
            $active = $('.banner-paging a.active').next();
            if ($active.length === 0) {
                $active = $('.banner-paging a:first');
            }
            rotate();
        }, 5000);
    };

    rotateSwitch();

    $(".banner-images a").hover(function () {
        clearInterval(play);
    }, function () {
        rotateSwitch();
    });

    $(".banner-paging a").click(function () {
        $active = $(this);
        clearInterval(play);
        rotate();
        rotateSwitch();
        return false;
    });

});
