var aiframe=null;

var growIframe = function()
	{
		var height = screen.height /2;
		if(aiframe) 
		{
			aiframe.style.height=height;
		}
		aiframe=null;
	}

var qlink = function(elmnt)
	{
		window.clearTimeout();
		if(aiframe) growiframe();
		var href = elmnt.getAttribute('href');
		var iframe = document.createElement("iframe");
		iframe.setAttribute('src',href);
		iframe.setAttribute('width','100%');
		iframe.setAttribute('height', 0);
		elmnt.parentNode.replaceChild(iframe, elmnt);
		aiframe=iframe;
		window.setTimeout('growIframe()', 200);
		return false;
	}

hasClass = function(node, className)
{
	if(!className) return false;
	return node.className.match(new RegExp('(^|\\s)' + className + '(\\s|$)'));
}
getElementsByClass = function(node, className, tag)
{
	var rval = new Array();
	if(className === undefined) return rval;
	var elements = node.getElementsByTagName(tag);
	for(i=elements.length; --i >=0; )
	{
		if(hasClass(elements[i], className))
		{
			rval.unshift(elements[i]);
		}
	}
	return rval;
}

var initComplete = function()
	{
		document.body.className = '';
		var entries = getElementsByClass(document.body, 'entry', 'div');
		entries.forEach(function(n) {
				n.style.height = 'auto';
			});
	}
var initExpand= function()
	{
		document.body.className = 'expanded';
		var entries = getElementsByClass(document.body, 'entry', 'div');
		entries.forEach(function(n) {
				n.style.height = n.HEIGHT;
			});
		window.setTimeout('initComplete()', 1000);
	}
var init = function()
	{
		document.body.className = 'collapsed';
		var entries = getElementsByClass(document.body, 'entry', 'div');
		entries.forEach(function(n) {
				n.HEIGHT = n.clientHeight;
				n.style.height = 0;
			});
		window.setTimeout('initExpand()', 10);
	}

if(document.addEventListener)
	document.addEventListener("DOMContentLoaded", init, false);
else document.onload = init;

