﻿function showGBContent(title, url) {

    $("#GBcontentHolderC").css('visibility', 'hidden');

    $('html, body').animate({ scrollTop: 0 }, 'slow', function() {

        $("#overlayC").css('top', '0').fadeIn('50');
        $("body").css("overflow-x", "hidden");


        $("#overlayzC").css('top', '0').fadeIn('50');

        $('#inlineHtmlContent').html('');
        //load iframe content into iframe

        $('iframe#GBcontentHolderC').attr('src', url);
        $('iframe#GBcontentHolderC').load(function() {
            //fix IE6 & IE7 height
            if ($.browser.msie == true && $.browser.version <= 7) {
                this.style.height = this.contentWindow.document.body.offsetHeight + 16 + 'px';
            }
            else if ($.browser.msie == true && $.browser.version >= 7) {
                this.style.height = this.contentWindow.document.body.offsetHeight + 8 + 'px';
            }
            else {
                this.style.height = this.contentWindow.document.body.offsetHeight + 20 + 'px';
            }

            $('iframe#GBcontentHolderC').show();
            $("#GBcontentTitle").show();
        });

        //$("#GBcontentTitle").html(title);

        $("#GBcontentHolderC").css('visibility', 'visible');
        $(document).find('select').css('visibility', 'hidden');

        $("#overlayC").height('0px');
        $("#overlayC").height($(document).height());

        $(window).scroll(function() {
            if ($("#overlayC").css('display') == 'block') {
                //$("#overlayzC").css('top', getYOffset());
                $("#overlayC").css('top', '0px');
                $("#overlayC").css('bottom', '0px');
                $("#overlayC").height($(document).height());
            }
        });

        $(window).resize(function() {
            if ($("#overlayC").css('display') == 'block') {
                $("#overlayC").css('top', '0px');
                $("#overlayC").css('bottom', '0px');
                $("#overlayC").height($(document).height());
                //$("#overlayzC").css('top', getYOffset());
            }
        });

    });

}


function showGBContentInline(title, htmlContent) {
    $("body").css("overflow-x", "hidden");
    $("#overlayC").css('top', getYOffset()).fadeIn('50');
    $("#overlayzC").css('top', getYOffset()).fadeIn('50');

    $('#inlineHtmlContent').html('');
    $('iframe#GBcontentHolderC').hide();
    $('#inlineHtmlContent').html(htmlContent);

    $("#GBcontentTitle").html(title);

    $(document).find('select').css('visibility', 'hidden');

    $("#overlayC").height($(document).height());

    //Custom Title
    //$("#GBcontentTitle").attr('src', '/includes/buildImgBar.asp?s=' + escape(title.replace(/ /gi, '+')) + '&c=u');

    $(window).scroll(function() {
        if ($("#overlayC").css('display') == 'block') {
            $("#overlayzC").css('top', getYOffset());
            $("#overlayC").css('top', '0px');
            $("#overlayC").css('bottom', '0px');
            $("#overlayC").height($(document).height());
        }
    });

    $(window).resize(function() {
        if ($("#overlayC").css('display') == 'block') {
            $("#overlayC").css('top', '0px');
            $("#overlayC").css('bottom', '0px');
            $("#overlayC").height($(document).height());
            $("#overlayzC").css('top', getYOffset());
        }
    });

}

function closeGBFLASH() {
    $(document).find('select').css('visibility', 'visible');
    $("body").css("overflow-x", "auto");
    $("#overlay").fadeOut('50');
    $("#overlayz").fadeOut('50', function() { $("#lbImg").attr('src', ''); });
}

function closeGBContent() {
    $(document).find('select').css('visibility', 'visible');
    
    if (!$.browser.msie)
    $("body").css("overflow-x", "auto");
    
    $("#overlayC").fadeOut('50');
    $("#overlayzC").fadeOut('50', function() { $("#lbImg").attr('src', ''); });
    $("#GBcontentTitle").hide();
    $('iframe#GBcontentHolderC').hide();
}

function closebox() {
    
    $(document).find('select').css('visibility', 'visible');
    $("body").css("overflow-x", "auto");
    $("#overlay").fadeOut('50');
    $("#overlayz").fadeOut('50', function() { $("#lbImg").attr('src', ''); });
}

function getYOffset() {
    var pageY;
    if (typeof (window.pageYOffset) == 'number') {
        pageY = window.pageYOffset;
    }
    else {
        pageY = document.body.scrollTop;
    }
    return pageY;
}

function resizeFrame() {
    var f = document.getElementById('GBcontentHolderC');
    f.style.height = f.contentWindow.document.body.scrollHeight + "px";
}
