var min=12;
var max=18;

var h1min=24;
var h1max=30;

var h2min=15;
var h2max=21;

var h3min=20;
var h3max=26;
function increaseFontSize() {
   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 = 12;
	      }
	      if(s!=max) {
	         s += 1;
	      }
	      p[i].style.fontSize = s+"px"
   }	
   createCookie('fontsize',s,7)
   	
   var span = document.getElementsByTagName('span');	   
   for(i=0;i<span.length;i++) {
	      if(span[i].style.fontSize) {
	         var s = parseInt(span[i].style.fontSize.replace("px",""));
	      } else {
	         var s = 12;
	      }
	      if(s!=max) {
	         s += 1;
	      }
	      span[i].style.fontSize = s+"px"
   }
      
   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 = 24;
	      }
	      if(s!=h1max) {
	         s += 1;
	      }
	      h1[i].style.fontSize = s+"px"
   }		  
   createCookie('fontsizeh1',s,7)
   		      
   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 = 15;
	      }
	      if(s!=h2max) {
	         s += 1;
	      }
	      h2[i].style.fontSize = s+"px"
   }		  
   createCookie('fontsizeh2',s,7)  
    		      
   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 = 20;
	      }
	      if(s!=h3max) {
	         s += 1;
	      }
	      h3[i].style.fontSize = s+"px"
   }		  
   createCookie('fontsizeh3',s,7)
    
   var ul = document.getElementsByTagName('ul');
   for(i=0;i<ul.length;i++) {
	      if(ul[i].style.fontSize) {
	         var s = parseInt(ul[i].style.fontSize.replace("px",""));
	      } else {
	         var s = 12;
	      }
	      if(s!=max) {
	         s += 1;
	      }
	      ul[i].style.fontSize = s+"px"
   }
}


function decreaseFontSize() {
   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 = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }     
   createCookie('fontsize',s,7)
   
   var span = document.getElementsByTagName('span');
   for(i=0;i<span.length;i++) {
      if(span[i].style.fontSize) {
         var s = parseInt(span[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      span[i].style.fontSize = s+"px"
   }
   
   var ul = document.getElementsByTagName('ul');
   for(i=0;i<ul.length;i++) {
      if(ul[i].style.fontSize) {
         var s = parseInt(ul[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      ul[i].style.fontSize = s+"px"
   }
   
   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 = 24;
      }
      if(s!=h1min) {
         s -= 1;
      }
      h1[i].style.fontSize = s+"px"
   }   
   createCookie('fontsizeh1',s,7)
   
   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 = 24;
      }
      if(s!=h2min) {
         s -= 1;
      }
      h2[i].style.fontSize = s+"px"
   }   
   createCookie('fontsizeh2',s,7)
   
   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 = 15;
      }
      if(s!=h3min) {
         s -= 1;
      }
      h3[i].style.fontSize = s+"px"
   }   
   createCookie('fontsizeh3',s,7)
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function setfontsize(){
	var p = document.getElementsByTagName('p');
	   for(i=0;i<p.length;i++) {
	      p[i].style.fontSize = readCookie("fontsize")+"px"
   }	
   			
   var span = document.getElementsByTagName('span');
	   for(i=0;i<span.length;i++) {
	      span[i].style.fontSize = readCookie("fontsize")+"px"
   }		
   		
   var ul = document.getElementsByTagName('ul');
	   for(i=0;i<ul.length;i++) {
	      ul[i].style.fontSize = readCookie("fontsize")+"px"
   }			   
   
   var h1 = document.getElementsByTagName('h1');
	   for(i=0;i<h1.length;i++) {
	      h1[i].style.fontSize = readCookie("fontsizeh1")+"px"
   }				   
   
   var h2 = document.getElementsByTagName('h2');
	   for(i=0;i<h2.length;i++) {
	      h2[i].style.fontSize = readCookie("fontsizeh2")+"px"
   }				   
   
   var h3 = document.getElementsByTagName('h3');
	   for(i=0;i<h3.length;i++) {
	      h3[i].style.fontSize = readCookie("fontsizeh3")+"px"
   }	
}
