function FRL_strip_class(e, c) {
	e.className = e.className.replace(new RegExp("\\b" + c + "\\b"), "");
}

function FRL_append_class (e, c) {
	var pattern = RegExp("\\b" + c + "\\b");
	if(! pattern.test(e.className)) {
		if(e.className.length) {
			e.className += ' ' + c;
		}
		else {
			e.className = c;
		}
	}
}

function FRL_inner_size() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	return {'width' : myWidth, 'height' : myHeight};
}

function FRL_fit_to_window() {
	var inner = inner_size();
	var tar_width = document.getElementById('Framework').clientWidth + 8;
	var tar_height = document.getElementById('Framework').clientHeight + 8;
	
	var cur_width = inner['width'] >= tar_width ? inner['width'] : tar_width;
	var cur_height = inner['height'] >= tar_height ? inner['height'] : tar_height;
	
  var changed = false;
	while(inner['height'] < tar_height) {
		window.resizeTo(cur_width, cur_height);
		inner = inner_size();
		changed = true;
		cur_height += 5;
	}
	if(changed) {
		changed = false;
		cur_height -= 5;
	}

	while(inner['width'] < tar_width) {
		window.resizeTo(cur_width, cur_height);
		inner = inner_size();
		changed = true;
		cur_width += 5;
	}
	if(changed) {
		changed = false;
		cur_width -= 5;
	}
	
	/* After both height and width are large enough to encompas the 
		page content the size needs to be decreased to remove any extra
		space that was taken up by the scroll bars, etc.
	 */
	while(inner['width'] > tar_width) {
		window.resizeTo(cur_width, cur_height);
		inner = inner_size();
		changed = true;
		cur_width--;
	}
	if(changed) {
		changed = false;
		cur_width++;
	}
		
	while(inner['height'] > tar_height) {
		window.resizeTo(cur_width, cur_height);
		inner = inner_size();
		changed = true;
		cur_height--;
	}
	if(changed) {
		changed = false;
		cur_height++;
	}
}

function FRL_about_obj(obj) {
	var lst = '';
	for (attrib in obj) {
		lst += "\n" + attrib + ' => ' + obj[attrib];
	}
	alert (lst);
}
