/* ----- License and Acknowledgements ----------------------------------- */
/*
	This software is licensed under the CC-LGPL <http://creativecommons.org/licenses/LGPL/2.1/>

	activateActiveX v1.0 (published 7 May 2006)
	onDomReady v1.0 (published 7 May 2006) is based on the following works:
		- brothercake's domFunction <http://www.brothercake.com/site/resources/scripts/domready/>
		- Dave Rolsky's DOM.Ready <http://www.openjsan.org/doc/a/au/autarch/DOM/Ready/0.14/lib/DOM/Ready.html>
*/


/* ----- 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 );
}


/* ----- Flash activation for IE ---------------------------------------- */
/* Jeremy Wischusen - 6/25/2007 : 11:23 AM - the orginal version of this 
 * activation script would strip out flash vars causing things like 
 * the slideshow widget for MyMag to fail in IE6. This would have effected any flash
 * piece that uses flash vars to pass values into flash as the values would be 
 * erased during the copy procedure. Solution referenced at 
 * http://www.nathanderksen.com/blog/2006/04/19/a-potential-solution-to-the-eolas-flash-woes-the-object-replacement-method/#comment-2261
 */
function activateActiveX() {
	if ( !document.getElementsByTagName || !document.body.outerHTML || !document.compatMode ) return false;
	var elems = new Array( "object", "embed", "applet" );
	for ( h = 0; h < elems.length; h++ ) {
		var objects = document.getElementsByTagName( elems[h] );
		for( var i = 0; i < objects.length; i++ ) {
			/*Refresh was killing gigya initialization.
			The following if check skips Gigya objects.
			*/
			if (objects[i].id !='wfmodule_divWildfirePostMain' && objects[i].id != "princessbride"){ 
			
			var params = "";
			for ( var j = 0; j < objects[i].childNodes.length; j++ ) {
				var parm = objects[i].childNodes[j];
				if (parm.tagName == 'PARAM'){
					params += parm.outerHTML;
				}
				//params += objects[i].childNodes[j].outerHTML;

			}
			var tag = objects[i].outerHTML.split(">")[0] + ">";
var newObject = tag + params + objects[i].innerHTML + " </object>";
objects[i].outerHTML = newObject;
			
			}

			
			
			//objects[i].outerHTML = objects[i].outerHTML.replace( "</" + elems[h].toUpperCase() + ">", params + "</" + elems[h].toUpperCase() + ">" );
		}
	}
}
onDomReady( activateActiveX );
