﻿var gAgendaLink = 'http://www.google.com/calendar/embed?showTitle=0&showPrint=0&showTabs=0&showCalendars=0&mode=AGENDA&height=308&wkst=1&bgcolor=%23ffffff&src=webmaster%40bgcest.com&color=%232952A3&src=p%23weather%40group.v.calendar.google.com&color=%23A32929&ctz=America%2FDenver'
var gCalendarLink = 'http://www.google.com/calendar/embed?showPrint=0&showTabs=0&showCalendars=0&height=550&wkst=1&bgcolor=%23FFFFFF&src=webmaster%40bgcest.com&color=%232952A3&src=p%23weather%40group.v.calendar.google.com&color=%23A32929&ctz=America%2FDenver';
function getPageScroll() {

    var yScroll;

    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
        yScroll = document.documentElement.scrollTop;
    } else if (document.body) {// all other Explorers
        yScroll = document.body.scrollTop;
    }

    arrayPageScroll = new Array('', yScroll)
    return arrayPageScroll;
}
function getPageSize() {

    var xScroll, yScroll;

    if (window.innerHeight && window.scrollMaxY) {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
        xScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }

    // 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;
    }


    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight)
    return arrayPageSize;
}
var overlayDone = false;
function CreateOverLay(objID) {
    var overlay = document.getElementById(objID);
    var pageSize = getPageSize();
    if (!overlayDone) {
        overlay.style.zIndex = '90';
        overlay.style.width = '100%'
        overlay.style.height = (pageSize[1] + 'px');
        overlay.style.display = 'block';
        overlay.style.top = '0px';
        overlay.style.left = '0px';
        CenterObject('GoogleCalHolder', 600, 750, 'GoogleCal');
        overlayDone = true;
    } else {
        var iHolder = document.getElementById('GoogleCalHolder');
        var iInner = document.getElementById('GoogleCal');
        iInner.style.width = '308px';
        iInner.style.height = '308px';
        iInner.src = gAgendaLink;
        iHolder.style.position = 'relative';
        iHolder.style.width = 'auto';
        iHolder.style.height = 'auto';
        iHolder.style.top = '0px';
        iHolder.style.left = '0px';
        overlay.style.width = '1px';
        overlay.style.height = '1px';
        overlay.style.top = '-5px';
        document.getElementById('bigCalendar').value = 'Enlarge Calendar/See Whole Month';
        document.getElementById('bigCalendar').style.height = 'auto';
        overlayDone = false;
    }
}
function CenterObject(outerID, objHeight, objWidth, innerID) {
    //get page information
    var pgSize = getPageSize();
    var objHolder = document.getElementById(outerID);
    objHolder.style.width = objWidth + 'px';
    objHolder.style.height = objHeight + 'px';
    objHolder.style.position = 'absolute';
    objHolder.style.zIndex = '100';
    objHolder.style.top = (pgSize[1] - objHeight) / 2 + 'px';
    objHolder.style.left = (pgSize[0] - objWidth) / 2 + 'px';
    var calFrame = document.getElementById(innerID);
    calFrame.style.width = objWidth + 'px';
    calFrame.style.height = (objHeight - 50) + 'px';
    calFrame.src = gCalendarLink;
    document.getElementById('bigCalendar').value = 'Shrink Calendar/Go Back to Agenda';
    document.getElementById('bigCalendar').style.height = '50px';
}