﻿function h100_calcheight()
{
    if (window.innerHeight)
        window.height = innerHeight;
    else if (document.documentElement && document.documentElement.offsetHeight)
        window.height = document.documentElement.offsetHeight;
    else if (document.body)
        window.height = document.body.offsetHeight;
    return window.height;
}

function h100_calcwidth()
{
    if (window.innerWidth)
        window.width = innerWidth;
    else if (document.documentElement && document.documentElement.offsetWidth)
        window.width = document.documentElement.offsetWidth;
    else if (document.body)
        window.width = document.body.offsetWidth;
    return window.width;
}

function h100_resizeobjs()
{
    var h = 0 + h100_calcheight();
    var w = 0 + h100_calcwidth();
//alert('resize... ' + h + ' ' + window.h100_objs);
    var o, i;
    //for (i = 0; i < window.h100_objs.length; i++)
    for (o in window.h100_objs)
    {
        var diff = window.h100_objs[o];
        var wdiff;
        var oo;
        
        if (typeof(diff.length) != 'undefined')
        {
            wdiff = diff[0];
            diff = diff[1];
        }
            
        if (typeof(o.style) == 'undefined')
            oo = document.getElementById(o);
        else
            oo = o;
        
        //alert(o + ' | ' + oo + ' | ' + diff + ' | ' + wdiff);
        
        if (typeof(diff) != 'undefined')
            oo.style.height = (h + diff) + 'px';
        if (typeof(wdiff) != 'undefined')
            oo.style.width = (w + wdiff) + 'px';
    }
}

function h100_init(objs_to_resize)
{
    window.h100_objs = objs_to_resize;
    window.onresize = function() { h100_resizeobjs(); return true; };
    h100_resizeobjs();
}

