/*------------------------------------------------------------
	Document Font Sizer - Copyright 2008 - Kevin P. Wojdak.  All rights reserved.
	Coded by: Kevin P. Wojdak (kwojdak@usa.net)
	Web Site: http://www.wojzworld.com
	
	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on 
	their own website if, and only if, 
	this entire copyright notice is included.
--------------------------------------------------------------*/

//Specify spectrum of different font sizes 0-6:
// xx-small = 0
// x-small  = 1
// small    = 2
// medium   = 3
// large    = 4
// x-large  = 5
// xx-large = 6

var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );

// Specify affected tags and initial size. Add or remove from list in the same structure.
// Structure to hold tags and their initial sizes
function tagSize (tg,siz) {
	this.nmTag = tg;
	this.tgSize = siz;
}

var szTags = new Array();
szTags[0] = new tagSize('body',2);
//szTags[1] = new tagSize('div',2);
//szTags[1] = new tagSize('td',2);
//szTags[2] = new tagSize('tr',2);
//szTags[4] = new tagSize('a',2);
szTags[1] = new tagSize('h1',4);
szTags[2] = new tagSize('h2',3);
szTags[3] = new tagSize('h3',2);
szTags[4] = new tagSize('p',2);

function getSize(trg) {
	for (c=0; c < szTags.length; c++) {
		if (szTags[c].nmTag == trg) {
			return szTags[c].tgSize;
		}
	}
	return 0;
}

function fs( trgt,inc ) {
	if (!document.getElementById) return
	var d = document,tg1 = null,i,j,listTags,sz;
	sz = getSize(trgt);
	
	sz += inc;
	if ( sz < 0 ) sz = 0;
	if ( sz > 6 ) sz = 6;
	startSz = sz;
	
	if ( !( tg1 = d.getElementById( trgt ) ) ) tg1 = d.getElementsByTagName( trgt )[ 0 ];
	tg1.style.fontSize = szs[ sz ];

	for ( i = 0 ; i < szTags.length ; i++ ) {
		listTags = tg1.getElementsByTagName( szTags[ i ].nmTag );
		sz = getSize(szTags[i].nmTag);
		sz += inc;
		if ( sz < 0 ) sz = 0;
		if ( sz > 6 ) sz = 6;
		for ( j = 0 ; j < listTags.length ; j++ ) {
			listTags[ j ].style.fontSize = szs[ sz ];
			szTags[i].tgSize = sz;
		}
	}
}
