function checkNodes(node, fontS, lineH)
{
	if (node.tagName)
	{
		node.style.fontSize = fontS;
		node.style.lineHeight = lineH;
		for (var i=0; i<node.childNodes.length; i++)
		{
			if (node.childNodes[i].tagName == 'p' || node.childNodes[i].tagName == 'P')
			{
				node.childNodes[i].style.fontSize = fontS;
				node.childNodes[i].style.lineHeight = lineH;
			}
			checkNodes(node.childNodes[i], fontS, lineH);
		}
	}
}

function setTextSize(textType) {
	var spContent = document.getElementById('spContent');
	var docSummary = document.getElementById('pSummary');
	

	switch (textType)
	{
		case '1':
			if (spContent)
			{
				checkNodes(spContent, '11px', '15px');
			}
			if (docSummary)
			{
				checkNodes(docSummary, '13px', '18px');
			}			
			break;
		case '2':
			if (spContent)
			{
				checkNodes(spContent, '14px', '20px');
			}
			if (docSummary)
			{
				checkNodes(docSummary, '18px', '23px');			
			}
			break;
		case '3':
			if (spContent)
			{				
				checkNodes(spContent, '17px', '25px');	
			}
			if (docSummary)
			{
				checkNodes(docSummary, '23px', '28px');				
			}
			break;
	}
}

function trapKD(btn, event)
{
	if (document.all)
	{
		if (event.keyCode == 13)
		{
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
	else if (document.getElementById)
	{
		if (event.which == 13)
		{
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
	else if(document.layers)
	{
		if(event.which == 13)
		{
			event.returnValue=false;
			event.cancel = true;
			btn.click();
		}
	}
}

function openPopUp(url, width, height, options)
{
	if (!options || options == '')
	{
		options = "location=no,status=no,menubar=no,scrollbars=no,resizable=no,toolbar=no";
	}
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	window.open(url, "_blank", "left=" + left + ",top=" + top + ",height=" + height + ",width=" + width + "," + options);
}


function formatNumber(number, format)
{
	// use: formatNumber(number, "format")

	var separator = ",";  // use comma as 000's separator
	var decpoint = ".";  // use period as decimal point
	var percent = "%";
	var currency = "$";

    if (number - 0 != number) return null;  // if number is NaN return null
    var useSeparator = format.indexOf(separator) != -1;  // use separators in number
    var usePercent = format.indexOf(percent) != -1;  // convert output to percentage
    var useCurrency = format.indexOf(currency) != -1;  // use currency format
    var isNegative = (number < 0);
    number = Math.abs (number);
    if (usePercent) number *= 100;
    format = strip(format, separator + percent + currency);  // remove key characters
    number = "" + number;  // convert number input to string

	// split input value into LHS and RHS using decpoint as divider
    var dec = number.indexOf(decpoint) != -1;
    var nleftEnd = (dec) ? number.substring(0, number.indexOf(".")) : number;
    var nrightEnd = (dec) ? number.substring(number.indexOf(".") + 1) : "";

	// split format string into LHS and RHS using decpoint as divider
    dec = format.indexOf(decpoint) != -1;
    var sleftEnd = (dec) ? format.substring(0, format.indexOf(".")) : format;
    var srightEnd = (dec) ? format.substring(format.indexOf(".") + 1) : "";

	// adjust decimal places by cropping or adding zeros to LHS of number
    if (srightEnd.length < nrightEnd.length) 
    {
		var nextChar = nrightEnd.charAt(srightEnd.length) - 0;
		nrightEnd = nrightEnd.substring(0, srightEnd.length);
		if (nextChar >= 5) nrightEnd = "" + ((nrightEnd - 0) + 1);  // round up

		while (srightEnd.length > nrightEnd.length) 
		{
			nrightEnd = "0" + nrightEnd;
		}

		if (srightEnd.length < nrightEnd.length) 
		{
			nrightEnd = nrightEnd.substring(1);
			nleftEnd = (nleftEnd - 0) + 1;
		}
    }
    else 
    {
		for (var i=nrightEnd.length; srightEnd.length > nrightEnd.length; i++)
		{
			if (srightEnd.charAt(i) == "0") 
			{
				nrightEnd += "0";  // append zero to RHS of number
			}
			else 
			{
				break;
			}
		}
	}

	// adjust leading zeros
    sleftEnd = strip(sleftEnd, "#");  // remove hashes from LHS of format
    while (sleftEnd.length > nleftEnd.length) 
    {
		nleftEnd = "0" + nleftEnd;  // prepend zero to LHS of number
    }

    if (useSeparator) nleftEnd = separate(nleftEnd, separator);  // add separator
    var output = nleftEnd + ((nrightEnd != "") ? "." + nrightEnd : "");  //combine parts
    output = ((useCurrency) ? currency : "") + output + ((usePercent) ? percent : "");
    if (isNegative) 
    {
      // patch suggested by Tom Denn 25/4/2001
      output = (useCurrency) ? "(" + output + ")" : "-" + output;
    }
    return output;
}

function strip(input, chars) 
{  
	// strip all characters in 'chars' from input
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++)
    {
		if (chars.indexOf(input.charAt(i)) == -1) 
		{
			output += input.charAt(i);
		}
    }
    return output;
}

function separate(input, separator)
{  
	// format input using 'separator' to mark 000's
    input = "" + input;
    var output = "";  // initialise output string
    for (var i=0; i < input.length; i++) 
    {
		if (i != 0 && (input.length - i) % 3 == 0)
		{	
			output += separator;
		}
		output += input.charAt(i);
    }
    return output;
}


function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	
	this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

