/*
Author: 		Gabriel Desjardins
Copyrights:		

Inspiration : 	http://karma.nucleuscms.org/item/108;
				http://msdn.microsoft.com/workshop/author/dhtml/overview/activating_activex.asp

*/

/*
This work is licensed under the Creative Commons Attribution 2.5 License. 
To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ 
or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
*/


function AutoActivateActiveXControls() {
	if (window.ActiveXObject) {
		var arrObj = document.getElementsByTagName('OBJECT');
		var a, i, o, j;
		for (i=0; i<arrObj.length; i++) {
			o = document.createElement('object');
			a = [];
			for (atrb in arrObj[i].attributes) {
				a.push(atrb, arrObj[i][atrb]);
			}
			for (j=0; j<arrObj[i].childNodes.length; j++) {
				a.push(arrObj[i].childNodes[j].getAttribute('name'), arrObj[i].childNodes[j].getAttribute('value'));
			}
			arrObj[i].parentNode.replaceChild(o, arrObj[i]);
			for (j=0; j<a.length; j++) {
				try
				{
					o.setAttribute(a[j++], a[j]);
				}
				catch(e)
				{
					;
				}
			}
		}
	}
}