﻿$(function () {

    $("#container").wrapInner(document.createElement("tr"));
    $("#container").wrapInner(document.createElement("table"));
    $("article, figure").wrap("<td>");

    var intX = null;
    var once = 0;

    $('#container').mousedown(function (event) {
        $('html,body').stop();
        intX = event.pageX;
        return false;
    });

    $(document).mousemove(function (event) {
        if (intX !== null) {
            var moveX = $(window).scrollLeft() + -(event.pageX - intX);
            $(window).scrollLeft(moveX);


            if ($(window).scrollLeft() == 0) {
                if (!once) {
                    intX = event.pageX;
                    once = 1;
                }
                $('#container').css({ left: -moveX });
            }

            $(this).css({ 'MozUserSelect': 'none' });
            return false;
        }
    });

    $(document).mouseup(function (event) {
        if (intX !== null) {
            once = 0;
            intX = null;

        }
    });

    $('input, select, option, label, textarea, button').mousedown(function () {
        $(this).focus();
    });


});
