﻿function ancSoloImagesClick() {
    getRequest("soloImages");
}

function ancGroupImagesClick() {
    getRequest("groupImages");
}
function getBrowserHeight() {
    var intH = 0;
    var intW = 0;

    if (typeof window.innerWidth == 'number') {
        intH = window.innerHeight;
        intW = window.innerWidth;
    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        intH = document.documentElement.clientHeight;
        intW = document.documentElement.clientWidth;
    }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        intH = document.body.clientHeight;
        intW = document.body.clientWidth;
    }

    return { width: parseInt(intW), height: parseInt(intH) };
}

function showProgress() {
    var elem = document.getElementById("dvLoader");
    var bws = getBrowserHeight();

    elem.style.left = parseInt((bws.width - 100) / 2) + "px";
    elem.style.top = 100 + "px"; // parseInt((bws.height - 100) / 2);

    $("#dvLoader").css("display", "block");
    $("#dvFade").css("display", "block")
}
function hideProgress() {
    $("#dvLoader").css("display", "none");
    $("#dvFade").css("display", "none")
}

function getRequest(type) {
    showProgress();
    var container = $("#dvPotsContent");   

    if (type != "") {
        $.ajax({
            url: "/ajaxProvider.aspx?type=" + type,
            cache: false,
            dataType: 'json',
            success: function (data) {
                var Requestedtype = data.type;
                $(container).html(data.data);
                hideProgress();
                var hash = location.hash;
                if (hash.length > 0)
                    location.href = location.href.replace(hash, '#' + Requestedtype);
                else
                    location.href = location.href + "#" + Requestedtype;

                if (Requestedtype.indexOf("detail") > -1 || Requestedtype == "groupImages" ) {
                    hs.registerOverlay({
                        thumbnailId: null,
                        overlayId: 'controlbar',
                        position: 'top right',
                        hideOnMouseOut: true
                    });

                    hs.graphicsDir = '/js/graphics/';
                    hs.outlineType = 'outer-glow';
                    hs.wrapperClassName = 'outer-glow';
                }

                
            }
        });
    }
}

jQuery.preloadImages = function () {
    var a = (typeof arguments[0] == 'object') ? arguments[0] : arguments;
    for (var i = a.length - 1; i >= 0; i--) {
        jQuery("<img>").attr("src", a[i]);
    }
}


function preload(arrayOfImages) {
    $(arrayOfImages).each(function () {
        $('<img/>')[0].src = this;
    });
}

