// DR1.0 :: domReady 
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
//******************************************************
//DOM-ready watcher
function domReady()
{
	//start or increment the counter
	domReady.n = typeof domReady.n == 'undefined' ? 0 : domReady.n + 1;
   domReady.tOut = 250;
	
	//if DOM methods are supported, and the body element exists
	//(using a double-check including document.body, for the benefit of older moz builds [eg ns7.1] 
	//in which getElementsByTagName('body')[0] is undefined, unless this script is in the body section)
	//>>> and any elements the script is going to manipulate exist
	if (typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)	|| (domReady.ndl && document.getElementById(domReady.ndl) != null) )
	{
	//>>>-- DOM SCRIPTING GOES HERE --<<<
		for (var i=0,f;f=domReady.aReadies[i];i++) {
         if (f.func) {
				if ((f.id) && (document.getElementById(f.id))) {
					f.func();
				}
				else {
					f.func();
				}
			}	
			
      } 
	//>>>-----------------------------<<<
	}
	//otherwise if we haven't reached 60 (so timeout after 15 seconds)
	//in practise, I've never seen this take longer than 7 iterations [in kde 3.2.2 
	//in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time]
	else if(domReady.n < 60)
	{
		//restart the watcher
		//using the syntax ('domReady()', n) rather than (domReady, n)
		//because the latter doesn't work in Safari 1.0
		setTimeout('domReady()', domReady.tOut);
	}
};
//Mods
domReady.aReadies =  new Array();
domReady.add = function (f) {
	domReady.aReadies.push(f);
}
domReady.setTimer =function(iNewTimer) {
	domReady.tOut = iNewTimer;
}





