﻿/*
 * photos.js
 *
 * Enable previous and next functionality in the albums by hitting the left/right arrows on the keyboard.
 */

var keys = {
    Left : 37,
    Right : 39
}

function init() {
    try {
        var prev = document.getElementById("prev");
        var next = document.getElementById("next");
        if (prev || next) {
            document.onkeyup = function (evt) {
                var keyCode = (window.event) ? window.event.keyCode : evt.which;
                
                switch (keyCode) {
                    case keys.Left:
                        if (prev) window.location = prev.href;
                        break;
                    case keys.Right:
                        if (next) window.location = next.href;
                        break;
                }       
            }
        }
    }
    catch (e) {
        // ignore exception... not that important...
    }
}
