
// for <P>
var pmin=8;
var pmax=18;
function increaseFontSizeP() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=pmax) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function decreaseFontSizeP() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=pmin) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}

//function findFirstDescendant(parent, tagname)
//{
//   parent = document.getElementById(parent);
//   var descendants = parent.getElementsByTagName(tagname);
//   if ( descendants.length )
//      return descendants[0];
//   return null;
//}




// for <h1>
var h1min=18;
var h1max=28;
function increaseFontSizeH1() {
   var h1 = document.getElementsByTagName('h1');
   //var h1 = findFirstDescendant('resizearea', 'h1');
   //var h1 = document.getElementById('resizearea').getElementsByTagName('h1')[0];
   for(i=0;i<h1.length;i++) {
      if(h1[i].style.fontSize) {
         var s = parseInt(h1[i].style.fontSize.replace("px",""));
      } else {
         var s = 20;
      }
      if(s!=h1max) {
         s += 1;
      }
      h1[i].style.fontSize = s+"px"
   }
}
function decreaseFontSizeH1() {
   var h1 = document.getElementsByTagName('h1');
   for(i=0;i<h1.length;i++) {
      if(h1[i].style.fontSize) {
         var s = parseInt(h1[i].style.fontSize.replace("px",""));
      } else {
         var s = 20;
      }
      if(s!=h1min) {
         s -= 1;
      }
      h1[i].style.fontSize = s+"px"
   }   
}

// for <h2>
var h2min=18;
var h2max=28;
function increaseFontSizeH2() {
   var h2 = document.getElementsByTagName('h2');
   for(i=0;i<h2.length;i++) {
      if(h2[i].style.fontSize) {
         var s = parseInt(h2[i].style.fontSize.replace("px",""));
      } else {
         var s = 20;
      }
      if(s!=h2max) {
         s += 1;
      }
      h2[i].style.fontSize = s+"px"
   }
}
function decreaseFontSizeH2() {
   var h2 = document.getElementsByTagName('h2');
   for(i=0;i<h2.length;i++) {
      if(h2[i].style.fontSize) {
         var s = parseInt(h2[i].style.fontSize.replace("px",""));
      } else {
         var s = 20;
      }
      if(s!=h2min) {
         s -= 1;
      }
      h2[i].style.fontSize = s+"px"
   }   
}

// for <h3>
var h3min=12;
var h3max=22;
function increaseFontSizeH3() {
   var h3 = document.getElementsByTagName('h3');
   for(i=0;i<h3.length;i++) {
      if(h3[i].style.fontSize) {
         var s = parseInt(h3[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=h3max) {
         s += 1;
      }
      h3[i].style.fontSize = s+"px"
   }
}
function decreaseFontSizeH3() {
   var h3 = document.getElementsByTagName('h3');
   for(i=0;i<h3.length;i++) {
      if(h3[i].style.fontSize) {
         var s = parseInt(h3[i].style.fontSize.replace("px",""));
      } else {
         var s = 14;
      }
      if(s!=h3min) {
         s -= 1;
      }
      h3[i].style.fontSize = s+"px"
   }   
}

// for <h4>
var h4min=8;
var h4max=18;
function increaseFontSizeH4() {
   var h4 = document.getElementsByTagName('h4');
   for(i=0;i<h4.length;i++) {
      if(h4[i].style.fontSize) {
         var s = parseInt(h4[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=h4max) {
         s += 1;
      }
      h4[i].style.fontSize = s+"px"
   }
}
function decreaseFontSizeH4() {
   var h4 = document.getElementsByTagName('h4');
   for(i=0;i<h4.length;i++) {
      if(h4[i].style.fontSize) {
         var s = parseInt(h4[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=h4min) {
         s -= 1;
      }
      h4[i].style.fontSize = s+"px"
   }   
}



function increaseFontSize() {
    increaseFontSizeP();
    increaseFontSizeH1();
    increaseFontSizeH2();
    increaseFontSizeH3();
    increaseFontSizeH4();
}

function decreaseFontSize() {
    decreaseFontSizeP();
    decreaseFontSizeH1();
    decreaseFontSizeH2();
    decreaseFontSizeH3();
    decreaseFontSizeH4();
}