﻿//----------------------------------------------------------------------------------
$(function() {

    if (window.addEventListener)
        window.addEventListener('DOMMouseScroll', handleWheel, false);
    window.onmousewheel = document.onmousewheel = handleWheel;

    if (window.attachEvent)
        window.attachEvent("onmousewheel", handleWheel);
});
//----------------------------------------------------------------------------------
function InitFlexPaperViewer(source, containerId) {

    InitCustomFlexPaperViewer(source, containerId, '100%', '100%', "FlexPaperViewer/FlexPaperViewer.swf");
}
//----------------------------------------------------------------------------------
function InitFlexPaperViewer2(source, containerId, flashViewer) {

    InitCustomFlexPaperViewer(source, containerId, '100%', '100%', flashViewer);
}
//----------------------------------------------------------------------------------
function InitCustomFlexPaperViewer(source, containerId, width, height, flashViewer) {

    var flashvars = null;
    var params = null;
    var attributes = null;
    var xiSwfUrlStr = null;
    var swfVersionStr = null;

    swfVersionStr = "9.0.124";
    xiSwfUrlStr = "${expressInstallSwf}";

    params = {}
    params.quality = "high";
    params.bgcolor = "#ffffff";
    params.allowscriptaccess = "sameDomain";
    params.allowfullscreen = "true";
    attributes = {};
    attributes.id = "FlexPaperViewer";
    attributes.name = "FlexPaperViewer";


    flashvars = {
        SwfFile: escape(source),
        Scale: 0.6,
        ZoomTransition: "easeOut",
        ZoomTime: 0.5,
        ZoomInterval: 0.1,
        FitPageOnLoad: false,
        FitWidthOnLoad: true,
        PrintEnabled: true,
        FullScreenAsMaxWindow: true,
        localeChain: "en_US"
    };

    swfobject.embedSWF(
                flashViewer, containerId,
                width, height,
                swfVersionStr, xiSwfUrlStr,
                flashvars, params, attributes);

    swfobject.createCSS("#flashContent", "display:block;text-align:left;");
}
//----------------------------------------------------------------------------------
function handleWheel(event) {
    try {
        if (!window.document.FlexPaperViewer.hasFocus()) { return true; }
        window.document.FlexPaperViewer.setViewerFocus(true);
        window.document.FlexPaperViewer.focus();

        if (navigator.appName == "Netscape") {
            if (event.detail)
                delta = 0;
            if (event.preventDefault) {
                event.preventDefault();
                event.returnValue = false;
            }
        }
        return false;
    } catch (err) { return true; }
}
//----------------------------------------------------------------------------------
function OpenFlashPopup(source, dialogContainerId, flashContainerId) {

    InitFlexPaperViewer(source, flashContainerId);
    
    $('#' + dialogContainerId).dialog({
        width: 400,
        height: 550
    });
}
//----------------------------------------------------------------------------------
function OpenFlashPopup2(source, dialogContainerId, flashContainerId, flashViewer) {

    InitFlexPaperViewer2(source, flashContainerId, flashViewer)

    $('#' + dialogContainerId).dialog({
        width: 400,
        height: 550
    });
}
//----------------------------------------------------------------------------------
