/* -----------------------------------------------------------------------
	Client:		Remington Hotels
	Title:		Shared scripts
	Author:		Jason Garber, jgarber@esitemarketing.com
	Copyright:	E-site Marketing, LLC, http://www.esitemarketing.com
	Created:	19 May 2006
------------------------------------------------------------------------- */

/* ----- window.onload rewriting function ------------------------------- */
function addLoadEvent( func ) {
	var oldonload = window.onload;
	if ( typeof window.onload != "function" ) {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

	// From: http://simon.incutio.com/archive/2004/05/26/addLoadEvent
	// Usage:
	// 		addLoadEvent( myFunction );
	// 		addLoadEvent( function() { /* more code to run on page load */  });


/* ----- Run function when DOM is loaded -------------------------------- */
function onDomReady( f ) {
	var t = setInterval( function() {
		if ( typeof document.getElementsByTagName != "undefined" && typeof document.getElementById != "undefined" && ( document.getElementsByTagName( "body" )[0] != null || document.body != null ) ) {
			f(); clearInterval( t );
		}
	}, 250 );
}

	// based on brothercake's domFunction: http://www.brothercake.com/site/resources/scripts/domready/
	// and Dave Rolsky's DOM.Ready: http://www.openjsan.org/doc/a/au/autarch/DOM/Ready/0.14/lib/DOM/Ready.html
	// Usage:
	//		onDomReady( myFunction );


/* ----- Flash activation for IE ---------------------------------------- */
function activateActiveX() {
	if ( !document.getElementsByTagName ) return false;
	if ( !document.body.outerHTML ) return false;
	if ( !document.compatMode ) return false;
	var elems = new Array( "object", "applet" );
	for ( h = 0; h < elems.length; h++ ) {
		var objects = document.getElementsByTagName( elems[h] );
		for( var i = 0; i < objects.length; i++ ) {
			var params = "";
			for ( var j = 0; j < objects[i].childNodes.length; j++ ) {
				params += objects[i].childNodes[j].outerHTML;
			}
			objects[i].outerHTML = objects[i].outerHTML.replace( "</" + elems[h].toUpperCase() + ">", params + "</" + elems[h].toUpperCase() + ">" );
		}
	}
}
onDomReady( activateActiveX );