//
// Dynamic IFrame Functions
// By: Collin Partridge - Feb 2008
// -------------------------------------------------------------
//
// This function continuously polls the page's hash, and when a
// change is detected, sets the height of the iframe being
// controlled to the value specified in the hash. The iframe must
// have the id 'iframeForm' for this function to work.
//
// To use this functionality, just reference this javascript
// file. Polling will start automatically.
//

location.hash = '#';
var curHash = location.hash;

function checkMessages()
{
	if (curHash != location.hash)
	{
		curHash = location.hash;
		
		if (curHash.length > 0)
		{
			var height;
			var scrollToTop;
			var hashIndex = curHash.indexOf('#') + 1;
			
			if (curHash.indexOf('+') == -1)
			{
				height = curHash.substring(hashIndex);
				scrollToTop = false;
			}
			else
			{
				height = curHash.substring(hashIndex, curHash.indexOf('+'));
				scrollToTop = true;
			}
			
			if (!isNaN(height))
			{
				if (parseInt(height) > 200)
				{
					height = parseInt(height) + 30;
					
					// iframe to be controlled must have this specific id
					var iframe = document.getElementById('iframeForm');
					
					if (iframe)
					{
					  iframe.style.height = height + 'px';
					}
				}
			}
			
			if (scrollToTop)
			{
				scroll(0, 0);
			}
		}
	}
	
	setTimeout('checkMessages()', 200);
}

setTimeout('checkMessages()', 200);
