// Misc javascript functions for lakevacationsidaho
// 1/30/2010

function showEmailForm() {
    var arrayPageSize = getPageSize();
    
    $("#overlay").width(arrayPageSize[0] + 'px');
    $("#overlay").height(arrayPageSize[1] + 'px');
    
    // calculate top and left offset for the lightbox 
    var arrayPageScroll = getScrollOffsets();
    var windowSize = getWindowSize();
    var lightboxTop = arrayPageScroll[1] + (windowSize[1] / 10);
    var lightboxLeft = arrayPageScroll[0];
    $("#lightbox").css("left", lightboxLeft + 'px');
    $("#lightbox").css("top", lightboxTop + 'px');
    
    $("#overlay").show();
    $("#lightbox").show();
}

function closeEmailForm() {
    $('#overlay').hide();
    $('#lightbox').hide();
}

function getPageSize() {
    var xScroll = $(document).scrollLeft();
    var yScroll = $(document).scrollTop();
    
    var windowWidth = $(document).width();
    var windowHeight = $(document).height();
    
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
        pageHeight = windowHeight;
    } else { 
        pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){  
        pageWidth = windowWidth;        
    } else {
        pageWidth = xScroll;
    }
    
    return [pageWidth,pageHeight];
}

function getWindowSize() {
    var windowWidth, windowHeight;
    windowWidth = $(window).width();
    windowHeight = $(window).height();
    return [windowWidth, windowHeight];
}

function getScrollOffsets() {
    var xScroll, yScroll;

    xScroll = $(window).scrollLeft();
    yScroll = $(window).scrollTop();
    return [xScroll, yScroll];
}