﻿var min = 10;
var max = 18;
var tags = new Array('h1', 'div', 'p', 'a', 'td', 'li', 'span');

function decreaseFontSize() {
    var content = document.getElementById('pagecontent');
    for (j = 0; j < tags.length; j++) {
        var p = content.getElementsByTagName(tags[j]);
        for (i = 0; i < p.length; i++) {
            var fs = getStyle(p[i], "font-size", "fontSize");
            var s;
            if (fs) {
                var test = fs.match("px");
                if (test != null) {
                    s = fs.replace("px", "") * 0.75;
                }
                else {
                    s = parseInt(fs.replace("pt", ""));
                }
            }
            else {
                var s = 12;
            }
            if (s > min) {
                s -= 1;
            }
            p[i].style.fontSize = s + "pt"
            p[i].style.lineHeight = (s + 1) + "pt";
        }
    }
}

function increaseFontSize() {
    var content = document.getElementById('pagecontent');
    for (j = 0; j < tags.length; j++) {
        var p = content.getElementsByTagName(tags[j]);
        for (i = 0; i < p.length; i++) {
            var fs = getStyle(p[i], "font-size", "fontSize");
            var s;
            if (fs) {
                var test = fs.match("px");
                if (test != null) {
                    s = fs.replace("px", "") * 0.75;
                }
                else {
                    s = parseInt(fs.replace("pt", ""));
                }
            }
            else {
                var s = 12;
            }
            if (s != max) {
                s += 1;
            }
            p[i].style.fontSize = s + "pt";
            p[i].style.lineHeight = (s + 1) + "pt";
        }
    }
}

function getStyle(obj, styleProp, ieStyleProp) {
    if (obj.currentStyle)
        var y = obj.currentStyle[ieStyleProp];
    else if (window.getComputedStyle)
        var y = document.defaultView.getComputedStyle(obj, null).getPropertyValue(styleProp);
    return y;
}