﻿
/* Website initialization and page load functions */

/* Resize the site for either 1024 or 1200+ widths whenever the browser window is resized */
window.onresize = resizeSite;

/* Function to resize the site: defines two different discreet sizes */
function resizeSite() {

    var newWidth = pageWidth();
    
    if (newWidth < 1260) {
        document.getElementById('divBody').style.width = '1000px';
        }
    else
        document.getElementById('divBody').style.width = '1200px';

}

/* Start of special delays section */
/* The following items set a delay on the resize event to make sure the user's finished the resize before actually changing the site's size */
/* NOTE: Not used - performance seems fine on tests. There was supposed to be a performance hit on IE using the above but I've not seen it. - gpd */

/*
var resizeTimeoutId;
function window_resize(e) {
    window.clearTimeout(resizeTimeoutId);
    resizeTimeoutId = window.setTimeout('resizeSite();', 200);
}
*/

/* End of special delays section */





/* Page Load region */





/* The following function allows multiple functions to be executed upon page load. Upon each call it creates a new onload function containing and calling all prior ones plus the new one.
    ************ COULD NOT GET IT TO WORK *******************
Two syntaxes can be used:
1) addLoadEvent(nameOfSomeFunctionToRunOnPageLoad());
2) addLoadEvent(function () { Put the function body statements here between squiggly brackets });     :::: example ::::  addLoadEvent(function () { alert("Loading page!") });
*/

/*
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function () {
            oldonload();
            func();
        }
    }
}
*/

/* Use the above to add functionality to page load */
/* addLoadEvent(resizeSite()); */


/* End Page Load region*/












function getElementWidth(id) 
{
    return document.getElementById(id).style.width != null ? document.getElementById(id).style.width : 0;
}

function getElementHeight(id) {
    return document.getElementById(id).style.height != null ? document.getElementById(id).style.height : 0;
}

function resizeElement(id, eHeight, eWidth) {
    alert('id: ' + id + ' height: ' + eHeight + ' width: ' + eWidth)
}

function test(id) {
    alert(getObjectById(id).id)
}


/* cross-browser function to get objects by id */
function getObjectById(id) {
    var returnVar
    if (document.getElementById)
        returnVar = document.getElementById(id);
    else if (document.all)
        returnVar = document.all[id];
    else if (document.layers)
        returnVar = document.layers[id];
    else
        returnVar = 'Not Found!'
    return returnVar;
}


function findControl(tagName, controlId) {
    var aControls = document.getElementsByTagName(tagName);
    if (aControls == null)
        return null;
    for (var i = 0; i < aControls.length; i++) {
        var j = aControls[i].id.lastIndexOf(controlId);
        if ((j - 1) && (j == (aControls[i].id.length - controlId.length)))
            return aControls[i];
    }
    return null;
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() { return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null; }
function pageHeight() { return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null; }
function posLeft() { return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0; }
function posTop() { return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0; } 
function posRight() { return posLeft() + pageWidth(); } function posBottom() { return posTop() + pageHeight(); }
                    
