/*
 * Facebox (for jQuery)
 * version: 1.2s (05/05/2008)
 * @requires jQuery v1.2 or later
 *
 * Examples at http://famspam.com/facebox/
 *
 * Licensed under the MIT:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ]
 */
function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft;
    }
    return new Array(xScroll,yScroll)
}

function getPageHeight() {
    var windowHeight
    if (self.innerHeight) {
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) {
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) {
        windowHeight = document.body.clientHeight;
    }
    return windowHeight
}

function showOverlay() {
    if ($('#box_overlay').length == 0)
        $("body").append('<div id="box_overlay" class="box_hide"></div>')

    $('#box_overlay').hide().addClass("box_overlayBG")
    .css('opacity', 0.94)
    .click(function() {
        $(document).trigger('close.box')
    })
    .fadeIn(200)
    return false
}

function hideOverlay() {

    $('#box_overlay').fadeOut(200, function(){
        $("#box_overlay").removeClass("box_overlayBG")
        $("#box_overlay").addClass("box_hide")
        $("#box_overlay").remove()
    })

    return false
}

$(document).bind('close.box', function() {
    $('#insidebox').fadeOut(function() {
        $('#insidebox').css('display', 'none');
    })
    hideOverlay()
})

function closebox() {
    $(document).trigger('close.box')
}
