/*
	Global variables
*/
var pageHeight   	= 256;
var ifraPageHeight  = 256;
var fontSize     	= 16;
var fontSizeStates	= new Array("smaller", "small", "medium", "large", "larger", "largest");
var fontSizeIndex	= 2;
var colShift   	 	= 3;
var lineCount    	= 1;

function ifraInit() 
{
     pageHeight = ifraPageHeight;
	lineCount = Math.floor(pageHeight/lineHeight);
	var1 = Math.floor(pageHeight/lineHeight) * lineHeight;
	if(var1 != pageHeight) 
	{
		var2 = Math.floor((pageHeight - var1) / (lineHeight - fontSize));
		if ((lineHeight - fontSize) > var2) 
		{
		   	var2 = pageHeight - var1 - 2;
		   	borderBottom = var2 + "px solid #fff";
		   	pageHeight = var1 + 2;
		}
		else 
		{
			borderBottom = "none";
			pageHeight = var1;
		}			
	}
	else 
	{
		borderBottom = "none";
	}
				
	return true;
}


function setSizes() 
{
	switch (fontSizeStates[fontSizeIndex]) 
	{
		case "smaller":
			fontSize   = 10;
			lineHeight = 12;
			//lineCount  = 21;
			colOffset  = 0;
			//pageHeight = 254;
			//borderBottom = "2px solid #fff";
			ifraInit();
			break;
		case "small":
			fontSize   = 11;
			lineHeight = 15;
			//lineCount  = 17;
			colOffset  = 0;
			//pageHeight = 256;
			//borderBottom = "none";
			ifraInit();
			break;
		case "medium":
			fontSize   = 12;
			lineHeight = 16;
			//lineCount  = 16;
			colOffset  = 0;
			//pageHeight = 256;
			//borderBottom = "none";
			ifraInit();
			break;
		case "large":
			fontSize   = 17;
			lineHeight = 18;
			//lineCount  = 14;
			colOffset  = 0;
			//pageHeight = 256;
			//borderBottom = "none";
			ifraInit();
			break;
		case "larger":
			fontSize   = 18;
			lineHeight = 22;
			//lineCount  = 14;
			colOffset  = 0;
			//pageHeight = 254;
			//borderBottom = "2px solid #fff";
			ifraInit();
			break;
		case "largest":
			fontSize   = 20;
			lineHeight = 22;
			//lineCount  = 11;
			colOffset  = 0;
			//pageHeight = 244;
			//borderBottom = "12px solid #fff";
			ifraInit();
			break;
		default:
			fontSize   = 12;
			lineHeight = 16;
			//lineCount  = 16;
			colOffset  = 0;
			//pageHeight = 256;
			//borderBottom = "none";
			ifraInit();			
	}
}

function changeFontSize(arg) 
{
	if (arg == "+") 
	{
		if (fontSizeIndex < fontSizeStates.length - 1) 
		{
			fontSizeIndex ++;
		} 
	} 
	else if (arg == "-") 
	{
		if (fontSizeIndex > 0) 
		{
			fontSizeIndex --;
		} 
	}
	setSizes();
	for (i = 0; i < colShift; i ++) {		
		if (document.getElementById("column-" + (i + 1)))
		{
			document.getElementById("column-" + (i + 1)).style.fontSize = fontSize + "px";
			document.getElementById("column-" + (i + 1)).style.lineHeight = lineHeight + "px";
		}
		
    	if (document.getElementById("page-1")) 
		{
        	document.getElementById("page-1").style.height = pageHeight + "px";
    		document.getElementById("page-1").style.borderBottom = borderBottom;
        }
	}
}
