﻿function setupResizingItem(container, item, ratio) {
    $(document).ready(function () {
        setBG(container, item, ratio);
    });
    $(window).resize(function () {
        setBG(container, item, ratio);
    });
}


function setBG(container, item, ratio) {
    //// BG
    var videoRatio = ratio;

    $(container).height($(window).height());
    //$(".BGPad").height($(window).height());

    if (videoRatio > $(window).width() / $(window).height()) //// Vertical Screen
    {
        $(item).height($(window).height());
        $(item).width($(window).height() * videoRatio);
        $(item).css({ "margin-left": -($(window).height() * videoRatio - $(window).width()) / 2 });
    }
    else  //// Horizontal Screen
    {
        $(item).height($(window).width() / videoRatio);
        $(item).width($(window).width());
        $(item).css({ "margin-top": -($(window).width() / videoRatio - $(window).height()) / 2 });
    }
}

var scrolIndex = 1;
function scrollLeft2(container) {
    if (scrolIndex>1)
        scrolIndex--;
    $(container).scrollTo('div:eq(' + scrolIndex + ')', 500);
}


function scrollRight(container) {
    if ($(container).children("div").children("div").length - 1 > scrolIndex)
        scrolIndex++;
    else
        scrolIndex = 1;
    $(container).scrollTo('div:eq(' + scrolIndex + ')', 500);
}



