function scrollablePlay() {
    if($('#actionButtonPlay').attr('title')!='Playing') {
        var horizontalScrollIndex = apiHorizontal.getIndex();
        apiHorizontal.play();
        //apiHorizontal.begin();
        apiHorizontal.seekTo(horizontalScrollIndex,0);
        $('#actionButtonPlay').attr('src','images/Decipher/next0.gif');
        $('#actionButtonPause').attr('src','images/Decipher/pause.gif');
        $('#actionButtonPause').attr('title','Click to Pause');
        $('#actionButtonPlay').attr('title','Playing');
        //Setting isHovered 1, we make the scroller go on
        //if(typeof(isHovered) != 'undefined') { isHovered = 0; }
        scrollableHorizontalOnSeek();
    }
}

function scrollableStop() {
    apiHorizontal.stop();
    $('#actionButtonPause').attr('src','images/Decipher/pause0.gif');
    $('#actionButtonPlay').attr('src','images/Decipher/next.gif');
    $('#actionButtonPause').attr('title','Paused');
    $('#actionButtonPlay').attr('title','Click to Play');
}

function scrollableHorizontalOnSeek() {
    if($('#actionButtonPlay').attr('title')=='Playing') {
        var horizontalScrollSize = apiHorizontal.getSize();
        var horizontalScrollIndex = apiHorizontal.getIndex();
        //alert('Horizontal Scroll Size:'+horizontalScrollSize+' Horizontal Scroll index:'+horizontalScrollIndex);
        if (horizontalScrollIndex==horizontalScrollSize-1) {
            setTimeout("if($('#actionButtonPlay').attr('title')=='Playing') apiHorizontal.begin()",window.ScrollableInterval);
        }
    }
}

function pauseScrollableBannerByHovering() {
    //If no item has been hovered yet, the variable isHovered doesn't exist, so we create it.
    if(typeof(isHovered) == 'undefined') { window.isHovered = 0; }

    $(".scrollableBanner .items .item").hover(function() { // Whenever an item is hovered
        if($('#actionButtonPlay').attr('title')=='Playing') {
            //alert('test1');
            scrollableStop();
            $('#actionButtonPlay').attr('title','Paused by Hovering');
            isHovered = 1; //Setting isHovered 1, we stop the scroller from going on
        }
    }, function() {
        if($('#actionButtonPlay').attr('title')=='Paused by Hovering') {
            //alert('test2');
            scrollablePlay();
            isHovered = 0;//Setting isHovered 1, we make the scroller go on
        }
    });
}


