﻿hs.graphicsDir = '/highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.wrapperClassName = 'controls-in-heading';
hs.fadeInOut = true;
hs.allowMultipleInstances = false;
hs.restoreTitle = 'Click to close image, click and drag to move.'; // Use arrow keys for next and previous.';

//function isSafari() {
//    return (navigator.userAgent.search(/Safari/i) >= 0 && navigator.userAgent.search(/Chrome/i) == -1);
//}
//function isChrome() {
//    return (navigator.userAgent.search(/Chrome/i) >= 0);
//}
//function isFirefox() {
//    return (navigator.userAgent.search(/Firefox/i) >= 0);
//}
function isWebKit() {
    return (navigator.userAgent.search(/WebKit/i) >= 0);
}
//function isMSIE() {
//    return (navigator.userAgent.search(/MSIE/i) >= 0);
//}

function scrollLock(e) {
    $(this).scrollTop(e.data.top);
    return false;
}

hs.Expander.prototype.onBeforeExpand = function (sender) {
    if (isWebKit())
        document.body.style.overflow = 'hidden'; // for IE use: document.body.scroll = 'no'
    else {
        var topPos = (self.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
        $(window).bind('scroll', { top: topPos }, scrollLock);
    }
};

hs.Expander.prototype.onBeforeClose = function (sender) {
    if (isWebKit())
        document.body.style.overflow = 'auto'; // for IE use: document.body.scroll = ''
    else {
        $(window).unbind('scroll', scrollLock); // unbinds lock
    }
};

function setMaxPopupHeight() {
    hs.height = parseInt(document.documentElement.clientHeight) - 110;
}

$(document).ready(onload = setMaxPopupHeight);
onresize = setMaxPopupHeight;

hs.onKeyDown = function (sender, e) {
    /// when a html popup opens, page up/down and scroll up/down close the popup
    /// if you click on the popup first they then work to scroll the inner html document, but after clicking, escape no longer closes the popup.

    /// best option available was to disable the  page up/down and scroll up/down keys when html first opens - any user will at least not see the window close

    // Key Codes:
    // Page Down (34), Arrow right (39), Arrow down (40)
    // Page Up (33), Arrow left (37), Arrow up (38)
    if (e.keyCode == 34 || e.keyCode == 40 || e.keyCode == 33 || e.keyCode == 38)
        return false;
}



