// ###########################
// created by: Ben Weeks
// Created Date: 14th July 2005
// Company: webtechy.co.uk
// Last Modified By:
// Last MOdified Date:
// Version: 1.00
// ###########################

var iMinimizeTimeID;
var sCaptionID = "NewsCaption";

function WaitToMinimize()
{
	// Waiting for the window to load ...
	iMinimizeTimeID = setInterval(" MinimizeCaption()",250)
}

function MinimizeCaption()
{
	iIterations = iIterations + 1;

	// Check to see if we've been checking for too long and something has gone wrong.
	if (iIterations < iMaxIterations)
	{
		if (document.getElementById(sCaptionID))
		{
			// OK, the page has now presumably
			// loaded, so we no longer need to
			// check for this.
			//alert("Debug: Caption DIV found.");
			clearInterval(iMinimizeTimeID);
			// Get the source of the image.
			//if (document.getElementById(sCaptionID) == "")
			//debugger;
			if (document.getElementById(sCaptionID).innerText.length < 3)
			{
				// Then no text exists in the Telerik
				// control and we should pre-populate it.
				//alert("Debug: Hiding the caption DIV.");
				document.getElementById(sCaptionID).style.display = "none";
			}
		}
	}
	else
	{
		// The window has taken too long to load, so
		// clear the timer to prevent the users
		// browser crashing.
		clearInterval(iMinimizeTimeID);
		//alert("The page took too long to load\nand the image could not\nbe repositioned.");
	}
}

// Start calling this function to wait for the
// page to load. When the page has loaded, then
// we can hide the caption box if it is empty.
// We could dynamically alter the OnLoad event 
// handler of the BODY tag hich would probably be 
// a tidier and less CPU intensive task.

WaitToMinimize();
