﻿shortcut.add
("Down", function() {
    if (cur_row < limit_row) {
        RemoveImageFocus("image_" + cur_row + "_" + cur_col);
        cur_row++;
        SetImageFocus("image_" + cur_row + "_" + cur_col);
        var link = placeHolder + "_link_" + cur_row + "_" + cur_col;
        SetLinkFocus(link);
    }
}
,
{
    'type': 'keydown',
    'propagate': true,
    'target': document
}
);

shortcut.add
("Up", function() {
    if (cur_row > 0) {
        RemoveImageFocus("image_" + cur_row + "_" + cur_col);
        cur_row--;
        SetImageFocus("image_" + cur_row + "_" + cur_col);
        var link = placeHolder + "_link_" + cur_row + "_" + cur_col;
        SetLinkFocus(link);
    }
}
,
{
    'type': 'keydown',
    'propagate': true,
    'target': document
}
);

shortcut.add
("Left", function() {
    RemoveImageFocus("image_" + cur_row + "_" + cur_col);
    if (cur_col > 0) {
        cur_col--;
    }
    SetImageFocus("image_" + cur_row + "_" + cur_col);
    var link = placeHolder + "_link_" + cur_row + "_" + cur_col;
    SetLinkFocus(link);
}
,
{
    'type': 'keydown',
    'propagate': true,
    'target': document
}
);

shortcut.add
("Right", function() {
    RemoveImageFocus("image_" + cur_row + "_" + cur_col);
    if (cur_row == limit_row && limitToRight != 0) {
        if ((cur_col + 1) < limitToRight) {
            cur_col++;
        }
    } else {
        if (cur_col < limit_col) {
            cur_col++;
        }
    }
    SetImageFocus("image_" + cur_row + "_" + cur_col);
    var link = placeHolder + "_link_" + cur_row + "_" + cur_col;
    SetLinkFocus(link);
}
,
{
    'type': 'keydown',
    'propagate': true,
    'target': document
}
);

shortcut.add
("Enter", function() {
    var link = placeHolder + "_link_" + cur_row + "_" + cur_col;
    SetLinkFocus(link);
}
,
{
    'type': 'keydown',
    'propagate': true,
    'target': document
}
);
