// Initialize the arrays containing our size info.

var pixelArray = new Array('80%','90%','100%','110%','120%','130%','140%'); // Possible font px sizes
var countOfPixels = pixelArray.length;
var initSize = 2; // Array position of inital px size
var cookiesitename = "Centrotherm-font-size";

function fontSizer(inc) {
	/*if (!document.getElementById) return;*/
	var size = readCookie(cookiesitename) == null ? initSize : readCookie(cookiesitename);
	size = parseInt(inc)+parseInt(size);
	if (size < 0 ) { size = 0; }	
	if (size > countOfPixels ) { size = countOfPixels-1; }
	
	doFontSizing(size);	
	
	createCookie(cookiesitename, size, 365);
}

function fontSizerOnLoad() {	
	/*if (!document.getElementById) return;*/
	var size = readCookie(cookiesitename);
	if (size < 0 || size == null) { size = initSize; }
	if (size > countOfPixels ) { size = countOfPixels; }	
	/*switchPic();*/
	doFontSizing(size);
}

function doFontSizing(theFontSize) {			
	// Bugfix: Elements inside table would not resize with only the code below, so we do them seperatly.
	// NOTE: This only resizes the font, nothing else.
	// Resize by ID does not work with this.
	//aTables = document.getElementsByTagName('table');
	//for(i = 0; i < aTables.length; i++){
	//		aTables[i].style.fontSize = pixelArray[theFontSize];
	//}
	
	// if you rather want to size an individual element by ID, use this:
	// resizeContainer = document.getElementById('nameOfConainingElement');	
	// and uncomment the if statements at the start of each function
	
	
	resizeContainer = document.getElementsByTagName('body')[0];
	if(resizeContainer.style.fontSize != pixelArray[theFontSize])
	resizeContainer.style.fontSize = pixelArray[theFontSize];	
}

function normalSize() {
	/*if (!document.getElementById) return;*/
	
	var size = initSize;
	
	doFontSizing(size);	
	createCookie(cookiesitename, size, 365);
}

function normalSizePrint() {
	/*if (!document.getElementById) return;*/
	
	var size = initSize;
	
	doFontSizing(size);	
}
function getfontsize()
{
  var ireturn = readCookie(cookiesitename);
  if(ireturn)
  {
    return ireturn;
  }
  return initSize;
}
/*function switchPic(size){	
	theImage = document.getElementById('dIndexBanner').firstChild;		
	imagePath = theImage.src;
	
}*/


addLoadEvent( function (e) {
	fontSizerOnLoad(readCookie());
});
