﻿var min=10;
var max=18;

var h1Min=19;
var h1Max=27;

var h2Min=17;
var h2Max=25;

var h3Min=15;
var h3Max=23;

var h4Min=15;
var h4Max=23;

var h5Min=12;
var h5Max=19;

var tdMin=12;
var tdMax=19;

function increaseFontSize() {
    increase();
    increaseTagRight('h1');
    increaseTagRight('h2');
    increaseTagRight('h3');
    increaseTagRight('h4');
    increaseTagRight('h5');
    increaseTagRight('h6');
	increaseTagRight('td');
    
    increaseTagFull('h1');
    increaseTagFull('h2');
    increaseTagFull('h3');
    increaseTagFull('h4');
    increaseTagFull('h5');
    increaseTagFull('h6');
	increaseTagFull('');
}

function increase() {
    var p = document.getElementById('content');

    if(p.style.fontSize) {
        var s = parseInt(p.style.fontSize.replace("px",""));
    } else {
        var s = 12;
    }
    if(s!=max) {
        s += 1;
    }
    p.style.fontSize = s+"px"
}

function increaseTagFull(tag) {
    if (document.getElementById('content_full')){
        var p = document.getElementById('content_full').getElementsByTagName(tag);
        for(i=0;i<p.length;i++) {
          if(p[i].style.fontSize) {
             var s = parseInt(p[i].style.fontSize.replace("px",""));
          } else {
             if (tag=='h1'){var s = h1Min;}
             if (tag=='h2'){var s = h1Min;}
             if (tag=='h3'){var s = h1Min;}
             if (tag=='h4'){var s = h1Min;}
             if (tag=='h5'){var s = h1Min;}
          }
          
          if (tag=='h1'){if(s!=h1Max){s += 1;}}
          if (tag=='h2'){if(s!=h2Max){s += 1;}}
          if (tag=='h3'){if(s!=h3Max){s += 1;}}
          if (tag=='h4'){if(s!=h4Max){s += 1;}}
          if (tag=='h5'){if(s!=h5Max){s += 1;}}
          
          p[i].style.fontSize = s+"px"
        }
    }
}

function increaseTagRight(tag) {
    if (document.getElementById('content_right')){
        var p = document.getElementById('content_right').getElementsByTagName(tag);
        for(i=0;i<p.length;i++) {
          if(p[i].style.fontSize) {
             var s = parseInt(p[i].style.fontSize.replace("px",""));
          } else {
             if (tag=='h1'){var s = h1Min;}
             if (tag=='h2'){var s = h2Min;}
             if (tag=='h3'){var s = h3Min;}
             if (tag=='h4'){var s = h4Min;}
             if (tag=='h5'){var s = h5Min;}
          }
          
          if (tag=='h1'){if(s!=h1Max){s += 1;}}
          if (tag=='h2'){if(s!=h2Max){s += 1;}}
          if (tag=='h3'){if(s!=h3Max){s += 1;}}
          if (tag=='h4'){if(s!=h4Max){s += 1;}}
          if (tag=='h5'){if(s!=h5Max){s += 1;}}
          
          p[i].style.fontSize = s+"px"
        }
    }
}

function decreaseFontSize() {
    decrease();
    decreaseTagRight('h1');
    decreaseTagRight('h2');
    decreaseTagRight('h3');
    decreaseTagRight('h4');
    decreaseTagRight('h5');
    decreaseTagRight('h6');
    
    decreaseTagFull('h1');
    decreaseTagFull('h2');
    decreaseTagFull('h3');
    decreaseTagFull('h4');
    decreaseTagFull('h5');
    decreaseTagFull('h6');
}

function decrease() {
    var p = document.getElementById('content');

    if(p.style.fontSize) {
        var s = parseInt(p.style.fontSize.replace("px",""));
    } else {
        var s = 12;
    }
    if(s!=min) {
        s -= 1;
    }
    p.style.fontSize = s+"px"
}

function decreaseTagFull(tag) {
    if (document.getElementById('content_full')){
        var p = document.getElementById('content_full').getElementsByTagName(tag);
        for(i=0;i<p.length;i++) {
          if(p[i].style.fontSize) {
             var s = parseInt(p[i].style.fontSize.replace("px",""));
          } else {
             if (tag=='h1'){var s = h1Max;}
             if (tag=='h2'){var s = h2Max;}
             if (tag=='h3'){var s = h3Max;}
             if (tag=='h4'){var s = h4Max;}
             if (tag=='h5'){var s = h5Max;}
          }
          
          if (tag=='h1'){if(s!=h1Min){s -= 1;}}
          if (tag=='h2'){if(s!=h2Min){s -= 1;}}
          if (tag=='h3'){if(s!=h3Min){s -= 1;}}
          if (tag=='h4'){if(s!=h4Min){s -= 1;}}
          if (tag=='h5'){if(s!=h5Min){s -= 1;}}
          
          p[i].style.fontSize = s+"px"
        }
    }
}

function decreaseTagRight(tag) {
    if (document.getElementById('content_right')){
        var p = document.getElementById('content_right').getElementsByTagName(tag);
        for(i=0;i<p.length;i++) {
          if(p[i].style.fontSize) {
             var s = parseInt(p[i].style.fontSize.replace("px",""));
          } else {
             if (tag=='h1'){var s = h1Min;}
             if (tag=='h2'){var s = h2Min;}
             if (tag=='h3'){var s = h3Min;}
             if (tag=='h4'){var s = h4Min;}
             if (tag=='h5'){var s = h5Min;}
          }
          
          if (tag=='h1'){if(s!=h1Min){s -= 1;}}
          if (tag=='h2'){if(s!=h2Min){s -= 1;}}
          if (tag=='h3'){if(s!=h3Min){s -= 1;}}
          if (tag=='h4'){if(s!=h4Min){s -= 1;}}
          if (tag=='h5'){if(s!=h5Min){s -= 1;}}
          
          p[i].style.fontSize = s+"px"
        }
    }
}