﻿


var UMotor = function () {
    'use strict';
};

UMotor.prototype = (function (jquery, undefined) {
    'use strict';
    var $j = jquery;
    var defineScroller = function (scrollEl, buttonEl, interval) {
        var scrollRoot = $j(scrollEl).scrollable({ circular: true }).navigator().autoscroll({ autoplay: true, interval: interval });


    };

    var defineExposeMask = function (color, exposedEl, fadetime) {
        // place a mask but let selected elements show through (expose)
        $j(exposedEl).expose({ opacity: 1, loadSpeed: 0, closeSpeed: fadetime });
        $j.mask.close();

    };
    var isStartPage = function () {
        return (location.href === 'http://' + location.host + '/');
    };
    var carouselInt;
    var exposeInt;
    return {
        defineScroller: defineScroller,
        defineExposeMask: defineExposeMask,
        isStartPage: isStartPage,
        carouselInt: carouselInt,
        exposeInt: exposeInt
    };
} (jQuery));

var UpplandsMotor = UpplandsMotor || new UMotor();

jQuery(function () {


    if (UpplandsMotor.isStartPage()) {
        if (UpplandsMotor.exposeInt) {
            UpplandsMotor.defineExposeMask('#789', '#scroller', UpplandsMotor.exposeInt);
        };
    };
    //only add scroller if element is on page
    if (jQuery('.scrollable')[0]) {
        UpplandsMotor.defineScroller('.scrollable', '.navi', UpplandsMotor.carouselInt);
    };


    //only add ui-buttons to navigation if brands-menu exist
    if (jQuery('#brands-menu')[0]) {
        jQuery("#brands-menu a").button().
            addClass("um-ui-button").corner('6px');
    };

});

