//   8/23/08   Copyright (C) 2008. All rights reserved.



function browserheight()
{
	return  window.innerHeight  ?  window.innerHeight : document.body.clientHeight;
}



function browserwidth()
{
	return  window.innerWidth  ?  window.innerWidth : document.body.clientWidth;
}



function getparam (div, param)
{

	var		classname,
			params,
			regexp,
			results,
			text,
			value;



	classname = div.className;

	//////////////////////////////////////////////////////////////////////////
	//									//
	// does the classname include a pair of empty or non-empty square	//
	// brackets? If so, the classname includes one or more parameters	//
	//									//
	//////////////////////////////////////////////////////////////////////////
	if (results = classname.match (/\[.*]/)) {
		params = results[0];

		//////////////////////////////////////////////////////////////////////////
		//									//
		// param must appear immediately after [ or |, and may be followed	//
		// by any number of characters that must be followed by | or ]		//
		//									//
		//////////////////////////////////////////////////////////////////////////
		regexp = new RegExp ("[\\[|\\|]" + param + ".*?[\\|\\]|]");
		if (results = params.match (regexp)) {
			text = results[0];
			value = text.substring (1 + param.length, text.length - 1);
		}
	}

	return value;
}



function getstyleinfo (object, property)
{
	var		value;

 
	if (property == 'height') {
		value = object.clientHeight + 'px';
	}
	else {
		if (object.currentStyle) {
			if ((pos = property.indexOf ("-")) >= 0) {
				property = property.slice (0, pos) + property.charAt (pos + 1).toUpperCase() + property.slice (pos + 2);
			}
			value = object.currentStyle[property];
		}
		else if (window.getComputedStyle) {
			value = window.getComputedStyle (object, '').getPropertyValue (property);
		}
	}

	return  value;
}



function getsubdivs (div)
{
	var		children,
			node,
			pos,
			subdivs;


	subdivs = [];
	children = div.childNodes;
	for (pos = 0; pos < children.length; pos++) {
		node = children[pos];

		if (node.nodeName == "DIV") {
			subdivs[subdivs.length] = node;
		}
	}

	return  subdivs;
}



function isdigit (chr)
{
	return  chr >= '0'  &&  chr <= '9';
}



function topx (text, maxpixels)
{
	var		len,
			percent,
			pixels,
			text,
			unit;


	pixels = 0;
	if (text.length > 0  &&  isdigit (text.charAt (0))) {
		len = text.length;

		if (text.charAt (len - 1) == '%') {
			percent = text.slice (0, len - 1);
			pixels = percent*maxpixels/100;		
		}
		else {
			unit = text.slice (len - 2);
			value = text.slice (0, len - 2);

			if (unit == 'px') {
				pixels = value;
			}
			else if (unit == 'em') {
				points = getstyleinfo (document.body, "font-size");
				len = points.length;
				points = points.slice (0, len - 2);
				pixels = 1.3333*points * value;
			}
		}
	}

	return  Math.round (pixels);
}