﻿
function parseQueryString(_1) { var _2 = {}; if (_1 == undefined) { _1 = location.search ? location.search : ""; } if (_1.charAt(0) == "?") { _1 = _1.substring(1); } _1 = _1.replace("+", " "); var _3 = _1.split(/[&;]/g); for (var i = 0; i < _3.length; i++) { var _5 = _3[i].split("="); var _6 = decodeURIComponent(_5[0]); var _7 = decodeURIComponent(_5[1]); if (!_2[_6]) { _2[_6] = []; } _2[_6].push((_5.length == 1) ? "" : _7); } return _2; }

function bestFit(image, container) {
    try {
        if (image == null ||
           container == null) {
            return;
        }

        var iz = container;
        var img = image;
        var cw = container.clientWidth;
        var ch = container.clientHeight;

        if (ch == 0 && cw == 0) {//For Firefox
            cw = Number(container.style.width.replace('px', ''));
            ch = Number(container.style.height.replace('px', ''));
        }

        cw -= 2;
        ch -= 2;

        img.removeAttribute('width');
        img.removeAttribute('height');

        if (image.clientHeight <= ch &&
           image.clientWidth <= cw) {
            return;
        }

        // calculate the aspect ratio
        var ar = img.width / img.height;

        if (ar >= 1.0) {
            img.width = cw - 2;
        }
        else {
            image.width = Math.floor(ch * ar) - 2;
        }

        if (img.height > ch) {
            img.removeAttribute('width');
            img.width = Math.floor(ch * ar) - 2;
        }
    }
    catch (e) {
        alert('bestFit error: ' + e.message);
    }
}

function resizeImage(image, width, height) {
    try {
        if (image == null) {
            return;
        }

        var img = image;
        var cw = width;
        var ch = height;

        cw -= 2;
        ch -= 2;

        img.removeAttribute('width');
        img.removeAttribute('height');

        if (image.clientHeight <= ch &&
           image.clientWidth <= cw) {
            return;
        }

        // calculate the aspect ratio
        var ar = img.width / img.height;

        if (ar >= 1.0) {
            img.width = cw - 2;
        }
        else {
            image.width = Math.floor(ch * ar) - 2;
        }

        if (img.height > ch) {
            img.removeAttribute('width');
            img.width = Math.floor(ch * ar) - 2;
        }
    }
    catch (e) {
        alert('bestFit error: ' + e.message);
    }
}

function highLightSelection(objId, beforeSend) {
    obj = document.getElementById(objId);
    obj.style.borderWidth = 4;

    if (beforeSend == true) {
        obj.style.borderColor = "#F3A841";
    }
    else {
        obj.style.borderColor = "#B4FD8B";
    }
}

function scrollUp(obj, first) {
    if (first == true) {
        scrolling = true;
    }

    obj.scrollTop -= 10;
    lastScrollPosition = obj.scrollTop;

    if (scrolling == true) {
        setTimeout("scrollUp(document.getElementById('" + obj.id + "'), false)", 30)
    }
}

function scrollDown(obj, first) {
    if (first == true) {
        scrolling = true;
    }

    obj.scrollTop += 10;
    lastScrollPosition = obj.scrollTop;

    if (scrolling == true) {
        setTimeout("scrollDown(document.getElementById('" + obj.id + "'), false)", 30)
    }
}

function StopScroll() {
    scrolling = false;
}

function returnToScrollPosiotion(obj) {
    obj.scrollTop = lastScrollPosition;
}

var FlashReplace = {
    elmToReplace: null,
    flashIsInstalled: null,
    defaultFlashVersion: 9,
    replace: function(elmToReplace, src, id, width, height, version, params) {
        this.elmToReplace = document.getElementById(elmToReplace);
        this.flashIsInstalled = this.checkForFlash(version || this.defaultFlashVersion);
        if (this.elmToReplace && this.flashIsInstalled) {
            var obj = '<object' + ((window.ActiveXObject) ? ' id="' + id + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="' + src + '"' : '');
            obj += ' width="' + width + '"';
            obj += ' height="' + height + '"';
            obj += '>';
            var param = '<param';
            param += ' name="movie"';
            param += ' value="' + src + '"';
            param += '>';
            param += '';
            var extraParams = '';
            var extraAttributes = '';
            for (var i in params) {
                extraParams += '<param name="' + i + '" value="' + params[i] + '">';
                extraAttributes += ' ' + i + '="' + params[i] + '"';
            }
            var embed = '<embed id="' + id + '" src="' + src + '" type="application/x-shockwave-flash" wmode="transparent" width="' + width + '" height="' + height + '"';
            var embedEnd = extraAttributes + '></embed>';
            var objEnd = '</object>';
            this.elmToReplace.innerHTML = obj + param + extraParams + embed + embedEnd + objEnd;
        }
    },

    checkForFlash: function(version) {
        this.flashIsInstalled = false;
        var flash;
        if (window.ActiveXObject) {
            try {
                flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));
                this.flashIsInstalled = true;
            }
            catch (e) {
                // Throws an error if the version isn't available			
            }
        }
        else if (navigator.plugins && navigator.mimeTypes.length > 0) {
            flash = navigator.plugins["Shockwave Flash"];
            if (flash) {
                var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*\s(\d+\.\d+).*/, "$1");
                if (flashVersion >= version) {
                    this.flashIsInstalled = true;
                }
            }
        }
        return this.flashIsInstalled;
    }
};

//This prototype is provided by the Mozilla foundation and//is distributed under the MIT license.//http://www.ibiblio.org/pub/Linux/LICENSES/mit.license
Array.prototype.indexOf = function(elt /*, from*/) { var len = this.length; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) from += len; for (; from < len; from++) { if (from in this && this[from].toUpperCase() === elt.toUpperCase()) return from; } return -1; };